diff --git a/packages/account/src/account.ts b/packages/account/src/account.ts index 0a486c473..a412fd45a 100644 --- a/packages/account/src/account.ts +++ b/packages/account/src/account.ts @@ -2,12 +2,12 @@ import { walletContracts } from '@0xsequence/abi' import { commons, universal } from '@0xsequence/core' import { migrator, defaults, version } from '@0xsequence/migration' import { ChainId, NetworkConfig } from '@0xsequence/network' -import { FeeOption, FeeQuote, isRelayer, Relayer, RpcRelayer } from '@0xsequence/relayer' -import { tracker } from '@0xsequence/sessions' -import { SignatureOrchestrator } from '@0xsequence/signhub' +import { type FeeOption, type FeeQuote, isRelayer, type Relayer, RpcRelayer } from '@0xsequence/relayer' +import type { tracker } from '@0xsequence/sessions' +import type { SignatureOrchestrator } from '@0xsequence/signhub' import { encodeTypedDataDigest, getFetchRequest } from '@0xsequence/utils' import { Wallet } from '@0xsequence/wallet' -import { ethers } from 'ethers' +import { ethers, MessagePrefix } from 'ethers' import { AccountSigner, AccountSignerOptions } from './signer' export type AccountStatus = { @@ -788,12 +788,37 @@ export class Account { return this.relayer(chainId).relay({ ...bootstrapTxs, chainId }, feeQuote) } + /** + * Signs a message. + * + * This method will sign the message using the account associated with this signer + * and the specified chain ID. If the message is already prefixed with the EIP-191 + * prefix, it will be hashed directly. Otherwise, it will be prefixed before hashing. + * + * @param message - The message to sign. Can be a string or BytesLike. + * @param chainId - The chain ID to use for signing + * @param cantValidateBehavior - Behavior when the wallet cannot validate on-chain + * @returns A Promise that resolves to the signature as a hexadecimal string + */ signMessage( message: ethers.BytesLike, chainId: ethers.BigNumberish, cantValidateBehavior: 'ignore' | 'eip6492' | 'throw' = 'ignore' ): Promise { - return this.signDigest(ethers.keccak256(message), chainId, true, cantValidateBehavior) + const messageHex = ethers.hexlify(message); + const prefixHex = ethers.hexlify(ethers.toUtf8Bytes(MessagePrefix)); + + let digest: string; + + // We check if the message is already prefixed with EIP-191 + // This will avoid breaking changes for codebases where the message is already prefixed + if (messageHex.substring(2).startsWith(prefixHex.substring(2))) { + digest = ethers.keccak256(message); + } else { + digest = ethers.hashMessage(message); + } + + return this.signDigest(digest, chainId, true, cantValidateBehavior); } async signTransactions( diff --git a/packages/account/src/signer.ts b/packages/account/src/signer.ts index 56b4b16ab..093e4f34d 100644 --- a/packages/account/src/signer.ts +++ b/packages/account/src/signer.ts @@ -77,6 +77,24 @@ export class AccountSigner implements ethers.AbstractSigner { return this.account.address } + /** + * Signs a message. + * + * This method will sign the message using the account associated with this signer + * and the specified chain ID. The message is already being prefixed with the EIP-191 prefix. + * + * @param message - The message to sign. Can be a string or BytesLike. + * @returns A Promise that resolves to the signature as a hexadecimal string + * + * @example + * ```typescript + * const signer = account.getSigner(chainId) + * + * const message = "Hello, Sequence!"; + * const signature = await signer.signMessage(message); + * console.log(signature); + * // => "0x123abc..." (hexadecimal signature) + */ signMessage(message: string | ethers.BytesLike): Promise { return this.account.signMessage(message, this.chainId, this.options?.cantValidateBehavior ?? 'throw') } diff --git a/packages/account/tests/account.spec.ts b/packages/account/tests/account.spec.ts index 0aa96ff8e..a21b6ea8b 100644 --- a/packages/account/tests/account.spec.ts +++ b/packages/account/tests/account.spec.ts @@ -1,7 +1,7 @@ import { walletContracts } from '@0xsequence/abi' import { commons, v1, v2 } from '@0xsequence/core' -import { migrator } from '@0xsequence/migration' -import { NetworkConfig } from '@0xsequence/network' +import type { migrator } from '@0xsequence/migration' +import type { NetworkConfig } from '@0xsequence/network' import { LocalRelayer, Relayer } from '@0xsequence/relayer' import { tracker, trackers } from '@0xsequence/sessions' import { Orchestrator } from '@0xsequence/signhub' @@ -9,7 +9,7 @@ import * as utils from '@0xsequence/tests' import { Wallet } from '@0xsequence/wallet' import * as chai from 'chai' import chaiAsPromised from 'chai-as-promised' -import { ethers } from 'ethers' +import { concat, ethers, MessagePrefix, toUtf8Bytes } from 'ethers' import hardhat from 'hardhat' import { Account } from '../src/account' @@ -284,7 +284,7 @@ describe('Account', () => { const valid = await commons.EIP1271.isValidEIP1271Signature( account.address, - ethers.keccak256(msg), + ethers.hashMessage(msg), sig, networks[0].provider! ) @@ -300,7 +300,7 @@ describe('Account', () => { const valid = await commons.EIP1271.isValidEIP1271Signature( accountOuter.address, - ethers.keccak256(msg), + ethers.hashMessage(msg), sig, networks[0].provider! ) @@ -369,7 +369,7 @@ describe('Account', () => { const msg = ethers.toUtf8Bytes('Hello World') const sig = await account.signMessage(msg, networks[0].chainId, 'eip6492') - const valid = await account.reader(networks[0].chainId).isValidSignature(account.address, ethers.keccak256(msg), sig) + const valid = await account.reader(networks[0].chainId).isValidSignature(account.address, ethers.hashMessage(msg), sig) expect(valid).to.be.true }) @@ -382,7 +382,7 @@ describe('Account', () => { const valid = await accountOuter .reader(networks[0].chainId) - .isValidSignature(accountOuter.address, ethers.keccak256(msg), sig) + .isValidSignature(accountOuter.address, ethers.hashMessage(msg), sig) expect(valid).to.be.true }) @@ -423,7 +423,7 @@ describe('Account', () => { const valid = await accountOuter .reader(networks[0].chainId) - .isValidSignature(accountOuter.address, ethers.keccak256(msg), sig) + .isValidSignature(accountOuter.address, ethers.hashMessage(msg), sig) expect(valid).to.be.true }) @@ -573,7 +573,32 @@ describe('Account', () => { const valid = await commons.EIP1271.isValidEIP1271Signature( account.address, - ethers.keccak256(msg), + ethers.hashMessage(msg), + sig, + networks[0].provider! + ) + + expect(valid).to.be.true + }) + + it('Should sign a message, already prefixed with EIP-191', async () => { + const msg = ethers.toUtf8Bytes('Hello World') + + const prefixedMessage = concat([ + toUtf8Bytes(MessagePrefix), + toUtf8Bytes(String(msg.length)), + msg + ]) + + const sig = await account.signMessage(prefixedMessage, networks[0].chainId) + + const canOnchainValidate = await account.status(networks[0].chainId).then(s => s.canOnchainValidate) + expect(canOnchainValidate).to.be.false + await account.doBootstrap(networks[0].chainId) + + const valid = await commons.EIP1271.isValidEIP1271Signature( + account.address, + ethers.hashMessage(msg), sig, networks[0].provider! ) @@ -627,7 +652,7 @@ describe('Account', () => { const valid = await commons.EIP1271.isValidEIP1271Signature( account.address, - ethers.keccak256(msg), + ethers.hashMessage(msg), sig, networks[0].provider! ) @@ -705,7 +730,7 @@ describe('Account', () => { const valid = await commons.EIP1271.isValidEIP1271Signature( account.address, - ethers.keccak256(msg), + ethers.hashMessage(msg), sig, networks[0].provider! ) @@ -1281,7 +1306,7 @@ describe('Account', () => { const msg = ethers.toUtf8Bytes('I like that you are reading our tests') const sig = await account.signMessage(msg, networks[0].chainId, 'eip6492') - const valid = await account.reader(networks[0].chainId).isValidSignature(account.address, ethers.keccak256(msg), sig) + const valid = await account.reader(networks[0].chainId).isValidSignature(account.address, ethers.hashMessage(msg), sig) expect(valid).to.be.true }) @@ -1297,7 +1322,7 @@ describe('Account', () => { const msg = ethers.toUtf8Bytes('Sending a hug') const sig = await account.signMessage(msg, networks[0].chainId, 'ignore') - const valid = await account.reader(networks[0].chainId).isValidSignature(account.address, ethers.keccak256(msg), sig) + const valid = await account.reader(networks[0].chainId).isValidSignature(account.address, ethers.hashMessage(msg), sig) expect(valid).to.be.false }) @@ -1316,7 +1341,7 @@ describe('Account', () => { const msg = ethers.toUtf8Bytes('Everything seems to be working fine so far') const sig = await account.signMessage(msg, networks[0].chainId, 'eip6492') - const valid = await account.reader(networks[0].chainId).isValidSignature(account.address, ethers.keccak256(msg), sig) + const valid = await account.reader(networks[0].chainId).isValidSignature(account.address, ethers.hashMessage(msg), sig) expect(valid).to.be.true }) @@ -1350,7 +1375,7 @@ describe('Account', () => { const msg = ethers.toUtf8Bytes('Everything seems to be working fine so far') const sig = await account.signMessage(msg, networks[0].chainId, 'ignore') - const valid = await account.reader(networks[0].chainId).isValidSignature(account.address, ethers.keccak256(msg), sig) + const valid = await account.reader(networks[0].chainId).isValidSignature(account.address, ethers.hashMessage(msg), sig) expect(valid).to.be.false }) diff --git a/packages/api/src/api.gen.ts b/packages/api/src/api.gen.ts index d9507163f..d2279bc3a 100644 --- a/packages/api/src/api.gen.ts +++ b/packages/api/src/api.gen.ts @@ -1,13 +1,13 @@ /* eslint-disable */ -// sequence-api v0.4.0 c3eb9010746703c095291691cd8f08dc04999062 +// sequence-api v0.4.0 c420a4f1777b406e7de6c3130329b15602e179e2 // -- -// Code generated by webrpc-gen@v0.22.0 with typescript generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.23.2 with typescript generator. DO NOT EDIT. // // webrpc-gen -schema=api.ridl -target=typescript -client -out=./clients/api.gen.ts export const WebrpcHeader = 'Webrpc' -export const WebrpcHeaderValue = 'webrpc@v0.22.0;gen-typescript@v0.16.1;sequence-api@v0.4.0' +export const WebrpcHeaderValue = 'webrpc@v0.23.2;gen-typescript@v0.16.3;sequence-api@v0.4.0' // WebRPC description and code-gen version export const WebRPCVersion = 'v1' @@ -16,7 +16,7 @@ export const WebRPCVersion = 'v1' export const WebRPCSchemaVersion = 'v0.4.0' // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = 'c3eb9010746703c095291691cd8f08dc04999062' +export const WebRPCSchemaHash = 'c420a4f1777b406e7de6c3130329b15602e179e2' type WebrpcGenVersions = { webrpcGenVersion: string @@ -53,16 +53,16 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions { } } - const [_, webrpcGenVersion] = versions[0].split('@') - const [codeGenName, codeGenVersion] = versions[1].split('@') - const [schemaName, schemaVersion] = versions[2].split('@') + const [_, webrpcGenVersion] = versions[0]!.split('@') + const [codeGenName, codeGenVersion] = versions[1]!.split('@') + const [schemaName, schemaVersion] = versions[2]!.split('@') return { - webrpcGenVersion, - codeGenName, - codeGenVersion, - schemaName, - schemaVersion + webrpcGenVersion: webrpcGenVersion ?? '', + codeGenName: codeGenName ?? '', + codeGenVersion: codeGenVersion ?? '', + schemaName: schemaName ?? '', + schemaVersion: schemaVersion ?? '' } } @@ -95,6 +95,12 @@ export enum TokenType { ERC1155 = 'ERC1155' } +export enum TransakBuySell { + UNKNOWN = 'UNKNOWN', + BUY = 'BUY', + SELL = 'SELL' +} + export interface Version { webrpcVersion: string schemaVersion: string @@ -200,6 +206,22 @@ export interface TupleComponent { value: any } +export interface IntentPrecondition { + type: string + chainID: string + data: any +} + +export interface IntentSolution { + transactions: Array +} + +export interface Transactions { + chainID: string + transactions: Array + preconditions?: Array +} + export interface Transaction { delegateCall: boolean revertOnError: boolean @@ -207,7 +229,6 @@ export interface Transaction { target: string value: string data: string - call?: ContractCall } export interface UserStorage { @@ -422,6 +443,25 @@ export interface SardinePaymentOption { processingTime: string } +export interface SwapPermit2Price { + currencyAddress: string + currencyBalance: string + price: string + maxPrice: string + transactionValue: string +} + +export interface SwapPermit2Quote { + currencyAddress: string + currencyBalance: string + price: string + maxPrice: string + to: string + transactionData: string + transactionValue: string + approveData: string +} + export interface SwapPrice { currencyAddress: string currencyBalance: string @@ -500,6 +540,168 @@ export interface AdoptedChildWallet { address: string } +export interface Lootbox { + chainId: number + projectId: number + contractAddress: string + contentBytes: Array + content: Array + createdAt?: string +} + +export interface LootboxContent { + tokenAddresses: Array + tokenIds: Array> + amounts: Array> +} + +export interface TransakCountry { + alpha2: string + alpha3: string + isAllowed: boolean + isLightKycAllowed: boolean + name: string + currencyCode: string + supportedDocuments: Array + partners: Array + states: Array +} + +export interface TransakPartner { + name: string + isCardPayment: boolean + currencyCode: string +} + +export interface TransakState { + code: string + name: string + isAllowed: boolean +} + +export interface TransakCryptoCurrency { + id: string + coinID: string + address: string + addressAdditionalData: any + createdAt: string + decimals: number + image: TransakCryptoCurrencyImage + isAllowed: boolean + isPopular: boolean + isStable: boolean + name: string + roundOff: number + symbol: string + isIgnorePriceVerification: boolean + imageBk: TransakCryptoCurrencyImage + kycCountriesNotSupported: Array + network: TransakCryptoCurrencyNetwork + uniqueID: string + tokenType: string + tokenIdentifier: string + isPayInAllowed: boolean + isSuspended: boolean +} + +export interface TransakCryptoCurrencyImage { + large: string + small: string + thumb: string +} + +export interface TransakCryptoCurrencyNetwork { + name: string + fiatCurrenciesNotSupported: Array + chainID: string +} + +export interface TransakCryptoCurrencyNetworkFiatNotSupported { + fiatCurrency: string + paymentMethod: string +} + +export interface TransakFiatCurrency { + symbol: string + supportingCountries: Array + logoSymbol: string + name: string + paymentOptions: Array + isPopular: boolean + isAllowed: boolean + roundOff: number + isPayOutAllowed: boolean + defaultCountryForNFT: string + icon: string + displayMessage: string +} + +export interface TransakFiatCurrencyPaymentOption { + name: string + id: string + isNftAllowed: boolean + isNonCustodial: boolean + processingTime: string + displayText: boolean + icon: string + limitCurrency: string + isActive: boolean + provider: string + maxAmount: number + minAmount: number + defaultAmount: number + isConverted: boolean + visaPayoutCountries: Array + mastercardPayoutCountries: Array + isPayOutAllowed: boolean + minAmountForPayOut: number + maxAmountForPayOut: number + defaultAmountForPayOut: number +} + +export interface TransakPrice { + quoteID: string + conversionPrice: number + marketConversionPrice: number + slippage: number + fiatCurrency: string + cryptoCurrency: string + paymentMethod: string + fiatAmount: number + cryptoAmount: number + isBuyOrSell: string + network: string + feeDecimal: number + totalFee: number + feeBreakdown: Array + nonce: number + cryptoLiquidityProvider: string + notes: Array +} + +export interface TransakPriceFeeBreakdown { + Name: string + Value: number + ID: string + Ids: Array +} + +export interface TransakGetPriceParams { + fiatCurrency: string + cryptoCurrency: string + isBuyOrSell: TransakBuySell + network: string + paymentMethod: string + fiatAmount: number + cryptoAmount: number + quoteCountryCode: string +} + +export interface TransakChain { + name: string + chainId: number +} + export interface API { ping(headers?: object, signal?: AbortSignal): Promise version(headers?: object, signal?: AbortSignal): Promise @@ -582,6 +784,14 @@ export interface API { headers?: object, signal?: AbortSignal ): Promise + transakGetCountries(headers?: object, signal?: AbortSignal): Promise + transakGetCryptoCurrencies(headers?: object, signal?: AbortSignal): Promise + transakGetFiatCurrencies(headers?: object, signal?: AbortSignal): Promise + transakGetPrice(args: TransakGetPriceArgs, headers?: object, signal?: AbortSignal): Promise + transakGetSupportedNFTCheckoutChains( + headers?: object, + signal?: AbortSignal + ): Promise getCoinPrices(args: GetCoinPricesArgs, headers?: object, signal?: AbortSignal): Promise getCollectiblePrices( args: GetCollectiblePricesArgs, @@ -615,9 +825,18 @@ export interface API { signal?: AbortSignal ): Promise listAdoptedWallets(args: ListAdoptedWalletsArgs, headers?: object, signal?: AbortSignal): Promise + getSwapPermit2Price(args: GetSwapPermit2PriceArgs, headers?: object, signal?: AbortSignal): Promise + getSwapPermit2Prices( + args: GetSwapPermit2PricesArgs, + headers?: object, + signal?: AbortSignal + ): Promise + getSwapPermit2Quote(args: GetSwapPermit2QuoteArgs, headers?: object, signal?: AbortSignal): Promise getSwapPrice(args: GetSwapPriceArgs, headers?: object, signal?: AbortSignal): Promise getSwapPrices(args: GetSwapPricesArgs, headers?: object, signal?: AbortSignal): Promise getSwapQuote(args: GetSwapQuoteArgs, headers?: object, signal?: AbortSignal): Promise + getSwapQuoteV2(args: GetSwapQuoteV2Args, headers?: object, signal?: AbortSignal): Promise + intentQuery(args: IntentQueryArgs, headers?: object, signal?: AbortSignal): Promise listCurrencyGroups(headers?: object, signal?: AbortSignal): Promise addOffchainInventory( args: AddOffchainInventoryArgs, @@ -654,6 +873,14 @@ export interface API { headers?: object, signal?: AbortSignal ): Promise + saveLootbox(args: SaveLootboxArgs, headers?: object, signal?: AbortSignal): Promise + getLootbox(args: GetLootboxArgs, headers?: object, signal?: AbortSignal): Promise + deleteLootbox(args: DeleteLootboxArgs, headers?: object, signal?: AbortSignal): Promise + updateLootboxContent( + args: UpdateLootboxContentArgs, + headers?: object, + signal?: AbortSignal + ): Promise } export interface PingArgs {} @@ -957,6 +1184,33 @@ export interface GetSardineNFTCheckoutOrderStatusArgs { export interface GetSardineNFTCheckoutOrderStatusReturn { resp: SardineOrder } +export interface TransakGetCountriesArgs {} + +export interface TransakGetCountriesReturn { + regions: Array +} +export interface TransakGetCryptoCurrenciesArgs {} + +export interface TransakGetCryptoCurrenciesReturn { + currencies: Array +} +export interface TransakGetFiatCurrenciesArgs {} + +export interface TransakGetFiatCurrenciesReturn { + currencies: Array +} +export interface TransakGetPriceArgs { + params: TransakGetPriceParams +} + +export interface TransakGetPriceReturn { + price: TransakPrice +} +export interface TransakGetSupportedNFTCheckoutChainsArgs {} + +export interface TransakGetSupportedNFTCheckoutChainsReturn { + chains: Array +} export interface GetCoinPricesArgs { tokens: Array } @@ -1102,6 +1356,41 @@ export interface ListAdoptedWalletsReturn { page: Page wallets: Array } +export interface GetSwapPermit2PriceArgs { + buyCurrencyAddress: string + sellCurrencyAddress: string + buyAmount: string + chainId: number + slippagePercentage?: number +} + +export interface GetSwapPermit2PriceReturn { + swapPermit2Price: SwapPermit2Price +} +export interface GetSwapPermit2PricesArgs { + userAddress: string + buyCurrencyAddress: string + buyAmount: string + chainId: number + slippagePercentage?: number +} + +export interface GetSwapPermit2PricesReturn { + swapPermit2Prices: Array +} +export interface GetSwapPermit2QuoteArgs { + userAddress: string + buyCurrencyAddress: string + sellCurrencyAddress: string + buyAmount: string + chainId: number + includeApprove: boolean + slippagePercentage?: number +} + +export interface GetSwapPermit2QuoteReturn { + swapPermit2Quote: SwapPermit2Quote +} export interface GetSwapPriceArgs { buyCurrencyAddress: string sellCurrencyAddress: string @@ -1137,6 +1426,27 @@ export interface GetSwapQuoteArgs { export interface GetSwapQuoteReturn { swapQuote: SwapQuote } +export interface GetSwapQuoteV2Args { + userAddress: string + buyCurrencyAddress: string + sellCurrencyAddress: string + buyAmount: string + chainId: number + includeApprove: boolean + slippagePercentage?: number +} + +export interface GetSwapQuoteV2Return { + swapQuote: SwapQuote +} +export interface IntentQueryArgs { + wallet: string + preconditions: Array +} + +export interface IntentQueryReturn { + solutions: Array +} export interface ListCurrencyGroupsArgs {} export interface ListCurrencyGroupsReturn { @@ -1194,6 +1504,36 @@ export interface ListOffchainPaymentsReturn { page: Page payments: Array } +export interface SaveLootboxArgs { + lootbox: Lootbox +} + +export interface SaveLootboxReturn { + merkleRoot: string +} +export interface GetLootboxArgs { + contractAddress: string + chainId: number +} + +export interface GetLootboxReturn { + lootbox: Lootbox +} +export interface DeleteLootboxArgs { + contractAddress: string + chainId: number +} + +export interface DeleteLootboxReturn { + status: boolean +} +export interface UpdateLootboxContentArgs { + lootbox: Lootbox +} + +export interface UpdateLootboxContentReturn { + merkleRoot: string +} // // Client @@ -1897,6 +2237,84 @@ export class API implements API { ) } + transakGetCountries = (headers?: object, signal?: AbortSignal): Promise => { + return this.fetch(this.url('TransakGetCountries'), createHTTPRequest({}, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + regions: >_data.regions + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + transakGetCryptoCurrencies = (headers?: object, signal?: AbortSignal): Promise => { + return this.fetch(this.url('TransakGetCryptoCurrencies'), createHTTPRequest({}, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + currencies: >_data.currencies + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + transakGetFiatCurrencies = (headers?: object, signal?: AbortSignal): Promise => { + return this.fetch(this.url('TransakGetFiatCurrencies'), createHTTPRequest({}, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + currencies: >_data.currencies + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + transakGetPrice = (args: TransakGetPriceArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch(this.url('TransakGetPrice'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + price: _data.price + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + transakGetSupportedNFTCheckoutChains = ( + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('TransakGetSupportedNFTCheckoutChains'), createHTTPRequest({}, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + chains: >_data.chains + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + getCoinPrices = (args: GetCoinPricesArgs, headers?: object, signal?: AbortSignal): Promise => { return this.fetch(this.url('GetCoinPrices'), createHTTPRequest(args, headers, signal)).then( res => { @@ -2186,6 +2604,63 @@ export class API implements API { ) } + getSwapPermit2Price = ( + args: GetSwapPermit2PriceArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetSwapPermit2Price'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + swapPermit2Price: _data.swapPermit2Price + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getSwapPermit2Prices = ( + args: GetSwapPermit2PricesArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetSwapPermit2Prices'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + swapPermit2Prices: >_data.swapPermit2Prices + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getSwapPermit2Quote = ( + args: GetSwapPermit2QuoteArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetSwapPermit2Quote'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + swapPermit2Quote: _data.swapPermit2Quote + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + getSwapPrice = (args: GetSwapPriceArgs, headers?: object, signal?: AbortSignal): Promise => { return this.fetch(this.url('GetSwapPrice'), createHTTPRequest(args, headers, signal)).then( res => { @@ -2231,6 +2706,36 @@ export class API implements API { ) } + getSwapQuoteV2 = (args: GetSwapQuoteV2Args, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch(this.url('GetSwapQuoteV2'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + swapQuote: _data.swapQuote + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + intentQuery = (args: IntentQueryArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch(this.url('IntentQuery'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + solutions: >_data.solutions + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + listCurrencyGroups = (headers?: object, signal?: AbortSignal): Promise => { return this.fetch(this.url('ListCurrencyGroups'), createHTTPRequest({}, headers, signal)).then( res => { @@ -2377,6 +2882,70 @@ export class API implements API { } ) } + + saveLootbox = (args: SaveLootboxArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch(this.url('SaveLootbox'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + merkleRoot: _data.merkleRoot + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getLootbox = (args: GetLootboxArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch(this.url('GetLootbox'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + lootbox: _data.lootbox + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + deleteLootbox = (args: DeleteLootboxArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch(this.url('DeleteLootbox'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + status: _data.status + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + updateLootboxContent = ( + args: UpdateLootboxContentArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('UpdateLootboxContent'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + merkleRoot: _data.merkleRoot + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } } const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => { @@ -2450,7 +3019,7 @@ export class WebrpcEndpointError extends WebrpcError { constructor( name: string = 'WebrpcEndpoint', code: number = 0, - message: string = 'endpoint error', + message: string = `endpoint error`, status: number = 0, cause?: string ) { @@ -2463,7 +3032,7 @@ export class WebrpcRequestFailedError extends WebrpcError { constructor( name: string = 'WebrpcRequestFailed', code: number = -1, - message: string = 'request failed', + message: string = `request failed`, status: number = 0, cause?: string ) { @@ -2476,7 +3045,7 @@ export class WebrpcBadRouteError extends WebrpcError { constructor( name: string = 'WebrpcBadRoute', code: number = -2, - message: string = 'bad route', + message: string = `bad route`, status: number = 0, cause?: string ) { @@ -2489,7 +3058,7 @@ export class WebrpcBadMethodError extends WebrpcError { constructor( name: string = 'WebrpcBadMethod', code: number = -3, - message: string = 'bad method', + message: string = `bad method`, status: number = 0, cause?: string ) { @@ -2502,7 +3071,7 @@ export class WebrpcBadRequestError extends WebrpcError { constructor( name: string = 'WebrpcBadRequest', code: number = -4, - message: string = 'bad request', + message: string = `bad request`, status: number = 0, cause?: string ) { @@ -2515,7 +3084,7 @@ export class WebrpcBadResponseError extends WebrpcError { constructor( name: string = 'WebrpcBadResponse', code: number = -5, - message: string = 'bad response', + message: string = `bad response`, status: number = 0, cause?: string ) { @@ -2528,7 +3097,7 @@ export class WebrpcServerPanicError extends WebrpcError { constructor( name: string = 'WebrpcServerPanic', code: number = -6, - message: string = 'server panic', + message: string = `server panic`, status: number = 0, cause?: string ) { @@ -2541,7 +3110,7 @@ export class WebrpcInternalErrorError extends WebrpcError { constructor( name: string = 'WebrpcInternalError', code: number = -7, - message: string = 'internal error', + message: string = `internal error`, status: number = 0, cause?: string ) { @@ -2554,7 +3123,7 @@ export class WebrpcClientDisconnectedError extends WebrpcError { constructor( name: string = 'WebrpcClientDisconnected', code: number = -8, - message: string = 'client disconnected', + message: string = `client disconnected`, status: number = 0, cause?: string ) { @@ -2567,7 +3136,7 @@ export class WebrpcStreamLostError extends WebrpcError { constructor( name: string = 'WebrpcStreamLost', code: number = -9, - message: string = 'stream lost', + message: string = `stream lost`, status: number = 0, cause?: string ) { @@ -2580,7 +3149,7 @@ export class WebrpcStreamFinishedError extends WebrpcError { constructor( name: string = 'WebrpcStreamFinished', code: number = -10, - message: string = 'stream finished', + message: string = `stream finished`, status: number = 0, cause?: string ) { @@ -2595,7 +3164,7 @@ export class UnauthorizedError extends WebrpcError { constructor( name: string = 'Unauthorized', code: number = 1000, - message: string = 'Unauthorized access', + message: string = `Unauthorized access`, status: number = 0, cause?: string ) { @@ -2608,7 +3177,7 @@ export class PermissionDeniedError extends WebrpcError { constructor( name: string = 'PermissionDenied', code: number = 1001, - message: string = 'Permission denied', + message: string = `Permission denied`, status: number = 0, cause?: string ) { @@ -2621,7 +3190,7 @@ export class SessionExpiredError extends WebrpcError { constructor( name: string = 'SessionExpired', code: number = 1002, - message: string = 'Session expired', + message: string = `Session expired`, status: number = 0, cause?: string ) { @@ -2634,7 +3203,7 @@ export class MethodNotFoundError extends WebrpcError { constructor( name: string = 'MethodNotFound', code: number = 1003, - message: string = 'Method not found', + message: string = `Method not found`, status: number = 0, cause?: string ) { @@ -2647,7 +3216,7 @@ export class RequestConflictError extends WebrpcError { constructor( name: string = 'RequestConflict', code: number = 1004, - message: string = 'Conflict with target resource', + message: string = `Conflict with target resource`, status: number = 0, cause?: string ) { @@ -2660,7 +3229,7 @@ export class AbortedError extends WebrpcError { constructor( name: string = 'Aborted', code: number = 1005, - message: string = 'Request aborted', + message: string = `Request aborted`, status: number = 0, cause?: string ) { @@ -2673,7 +3242,7 @@ export class GeoblockedError extends WebrpcError { constructor( name: string = 'Geoblocked', code: number = 1006, - message: string = 'Geoblocked region', + message: string = `Geoblocked region`, status: number = 0, cause?: string ) { @@ -2686,7 +3255,7 @@ export class RateLimitedError extends WebrpcError { constructor( name: string = 'RateLimited', code: number = 1007, - message: string = 'Rate-limited. Please slow down.', + message: string = `Rate-limited. Please slow down.`, status: number = 0, cause?: string ) { @@ -2699,7 +3268,7 @@ export class ProjectNotFoundError extends WebrpcError { constructor( name: string = 'ProjectNotFound', code: number = 1008, - message: string = 'Project not found', + message: string = `Project not found`, status: number = 0, cause?: string ) { @@ -2712,7 +3281,7 @@ export class AccessKeyNotFoundError extends WebrpcError { constructor( name: string = 'AccessKeyNotFound', code: number = 1101, - message: string = 'Access key not found', + message: string = `Access key not found`, status: number = 0, cause?: string ) { @@ -2725,7 +3294,7 @@ export class AccessKeyMismatchError extends WebrpcError { constructor( name: string = 'AccessKeyMismatch', code: number = 1102, - message: string = 'Access key mismatch', + message: string = `Access key mismatch`, status: number = 0, cause?: string ) { @@ -2738,7 +3307,7 @@ export class InvalidOriginError extends WebrpcError { constructor( name: string = 'InvalidOrigin', code: number = 1103, - message: string = 'Invalid origin for Access Key', + message: string = `Invalid origin for Access Key`, status: number = 0, cause?: string ) { @@ -2751,7 +3320,7 @@ export class InvalidServiceError extends WebrpcError { constructor( name: string = 'InvalidService', code: number = 1104, - message: string = 'Service not enabled for Access key', + message: string = `Service not enabled for Access key`, status: number = 0, cause?: string ) { @@ -2764,7 +3333,7 @@ export class UnauthorizedUserError extends WebrpcError { constructor( name: string = 'UnauthorizedUser', code: number = 1105, - message: string = 'Unauthorized user', + message: string = `Unauthorized user`, status: number = 0, cause?: string ) { @@ -2777,7 +3346,7 @@ export class QuotaExceededError extends WebrpcError { constructor( name: string = 'QuotaExceeded', code: number = 1200, - message: string = 'Quota request exceeded', + message: string = `Quota request exceeded`, status: number = 0, cause?: string ) { @@ -2790,7 +3359,7 @@ export class QuotaRateLimitError extends WebrpcError { constructor( name: string = 'QuotaRateLimit', code: number = 1201, - message: string = 'Quota rate limit exceeded', + message: string = `Quota rate limit exceeded`, status: number = 0, cause?: string ) { @@ -2803,7 +3372,7 @@ export class NoDefaultKeyError extends WebrpcError { constructor( name: string = 'NoDefaultKey', code: number = 1300, - message: string = 'No default access key found', + message: string = `No default access key found`, status: number = 0, cause?: string ) { @@ -2816,7 +3385,7 @@ export class MaxAccessKeysError extends WebrpcError { constructor( name: string = 'MaxAccessKeys', code: number = 1301, - message: string = 'Access keys limit reached', + message: string = `Access keys limit reached`, status: number = 0, cause?: string ) { @@ -2829,7 +3398,7 @@ export class AtLeastOneKeyError extends WebrpcError { constructor( name: string = 'AtLeastOneKey', code: number = 1302, - message: string = 'You need at least one Access Key', + message: string = `You need at least one Access Key`, status: number = 0, cause?: string ) { @@ -2842,7 +3411,7 @@ export class TimeoutError extends WebrpcError { constructor( name: string = 'Timeout', code: number = 1900, - message: string = 'Request timed out', + message: string = `Request timed out`, status: number = 0, cause?: string ) { @@ -2855,7 +3424,7 @@ export class InvalidArgumentError extends WebrpcError { constructor( name: string = 'InvalidArgument', code: number = 2000, - message: string = 'Invalid argument', + message: string = `Invalid argument`, status: number = 0, cause?: string ) { @@ -2868,7 +3437,7 @@ export class UnavailableError extends WebrpcError { constructor( name: string = 'Unavailable', code: number = 2002, - message: string = 'Unavailable resource', + message: string = `Unavailable resource`, status: number = 0, cause?: string ) { @@ -2881,7 +3450,7 @@ export class QueryFailedError extends WebrpcError { constructor( name: string = 'QueryFailed', code: number = 2003, - message: string = 'Query failed', + message: string = `Query failed`, status: number = 0, cause?: string ) { @@ -2894,7 +3463,7 @@ export class NotFoundError extends WebrpcError { constructor( name: string = 'NotFound', code: number = 3000, - message: string = 'Resource not found', + message: string = `Resource not found`, status: number = 0, cause?: string ) { @@ -2907,7 +3476,7 @@ export class UnsupportedNetworkError extends WebrpcError { constructor( name: string = 'UnsupportedNetwork', code: number = 3008, - message: string = 'Unsupported network', + message: string = `Unsupported network`, status: number = 0, cause?: string ) { diff --git a/packages/guard/src/guard.gen.ts b/packages/guard/src/guard.gen.ts index 58b4cf54e..96a777cdc 100644 --- a/packages/guard/src/guard.gen.ts +++ b/packages/guard/src/guard.gen.ts @@ -1,13 +1,13 @@ /* eslint-disable */ // sequence-guard v0.4.0 d6b4a3c89539b494875af543fff459df65bb7b9e // -- -// Code generated by webrpc-gen@v0.22.0 with typescript generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.23.2 with typescript generator. DO NOT EDIT. // // webrpc-gen -schema=guard.ridl -target=typescript -client -out=./clients/guard.gen.ts export const WebrpcHeader = 'Webrpc' -export const WebrpcHeaderValue = 'webrpc@v0.22.0;gen-typescript@v0.16.1;sequence-guard@v0.4.0' +export const WebrpcHeaderValue = 'webrpc@v0.23.2;gen-typescript@v0.16.3;sequence-guard@v0.4.0' // WebRPC description and code-gen version export const WebRPCVersion = 'v1' @@ -53,16 +53,16 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions { } } - const [_, webrpcGenVersion] = versions[0].split('@') - const [codeGenName, codeGenVersion] = versions[1].split('@') - const [schemaName, schemaVersion] = versions[2].split('@') + const [_, webrpcGenVersion] = versions[0]!.split('@') + const [codeGenName, codeGenVersion] = versions[1]!.split('@') + const [schemaName, schemaVersion] = versions[2]!.split('@') return { - webrpcGenVersion, - codeGenName, - codeGenVersion, - schemaName, - schemaVersion + webrpcGenVersion: webrpcGenVersion ?? '', + codeGenName: codeGenName ?? '', + codeGenVersion: codeGenVersion ?? '', + schemaName: schemaName ?? '', + schemaVersion: schemaVersion ?? '' } } @@ -577,7 +577,7 @@ export class WebrpcEndpointError extends WebrpcError { constructor( name: string = 'WebrpcEndpoint', code: number = 0, - message: string = 'endpoint error', + message: string = `endpoint error`, status: number = 0, cause?: string ) { @@ -590,7 +590,7 @@ export class WebrpcRequestFailedError extends WebrpcError { constructor( name: string = 'WebrpcRequestFailed', code: number = -1, - message: string = 'request failed', + message: string = `request failed`, status: number = 0, cause?: string ) { @@ -603,7 +603,7 @@ export class WebrpcBadRouteError extends WebrpcError { constructor( name: string = 'WebrpcBadRoute', code: number = -2, - message: string = 'bad route', + message: string = `bad route`, status: number = 0, cause?: string ) { @@ -616,7 +616,7 @@ export class WebrpcBadMethodError extends WebrpcError { constructor( name: string = 'WebrpcBadMethod', code: number = -3, - message: string = 'bad method', + message: string = `bad method`, status: number = 0, cause?: string ) { @@ -629,7 +629,7 @@ export class WebrpcBadRequestError extends WebrpcError { constructor( name: string = 'WebrpcBadRequest', code: number = -4, - message: string = 'bad request', + message: string = `bad request`, status: number = 0, cause?: string ) { @@ -642,7 +642,7 @@ export class WebrpcBadResponseError extends WebrpcError { constructor( name: string = 'WebrpcBadResponse', code: number = -5, - message: string = 'bad response', + message: string = `bad response`, status: number = 0, cause?: string ) { @@ -655,7 +655,7 @@ export class WebrpcServerPanicError extends WebrpcError { constructor( name: string = 'WebrpcServerPanic', code: number = -6, - message: string = 'server panic', + message: string = `server panic`, status: number = 0, cause?: string ) { @@ -668,7 +668,7 @@ export class WebrpcInternalErrorError extends WebrpcError { constructor( name: string = 'WebrpcInternalError', code: number = -7, - message: string = 'internal error', + message: string = `internal error`, status: number = 0, cause?: string ) { @@ -681,7 +681,7 @@ export class WebrpcClientDisconnectedError extends WebrpcError { constructor( name: string = 'WebrpcClientDisconnected', code: number = -8, - message: string = 'client disconnected', + message: string = `client disconnected`, status: number = 0, cause?: string ) { @@ -694,7 +694,7 @@ export class WebrpcStreamLostError extends WebrpcError { constructor( name: string = 'WebrpcStreamLost', code: number = -9, - message: string = 'stream lost', + message: string = `stream lost`, status: number = 0, cause?: string ) { @@ -707,7 +707,7 @@ export class WebrpcStreamFinishedError extends WebrpcError { constructor( name: string = 'WebrpcStreamFinished', code: number = -10, - message: string = 'stream finished', + message: string = `stream finished`, status: number = 0, cause?: string ) { @@ -722,7 +722,7 @@ export class UnauthorizedError extends WebrpcError { constructor( name: string = 'Unauthorized', code: number = 1000, - message: string = 'Unauthorized access', + message: string = `Unauthorized access`, status: number = 0, cause?: string ) { @@ -735,7 +735,7 @@ export class PermissionDeniedError extends WebrpcError { constructor( name: string = 'PermissionDenied', code: number = 1001, - message: string = 'Permission denied', + message: string = `Permission denied`, status: number = 0, cause?: string ) { @@ -748,7 +748,7 @@ export class SessionExpiredError extends WebrpcError { constructor( name: string = 'SessionExpired', code: number = 1002, - message: string = 'Session expired', + message: string = `Session expired`, status: number = 0, cause?: string ) { @@ -761,7 +761,7 @@ export class MethodNotFoundError extends WebrpcError { constructor( name: string = 'MethodNotFound', code: number = 1003, - message: string = 'Method not found', + message: string = `Method not found`, status: number = 0, cause?: string ) { @@ -774,7 +774,7 @@ export class RequestConflictError extends WebrpcError { constructor( name: string = 'RequestConflict', code: number = 1004, - message: string = 'Conflict with target resource', + message: string = `Conflict with target resource`, status: number = 0, cause?: string ) { @@ -787,7 +787,7 @@ export class AbortedError extends WebrpcError { constructor( name: string = 'Aborted', code: number = 1005, - message: string = 'Request aborted', + message: string = `Request aborted`, status: number = 0, cause?: string ) { @@ -800,7 +800,7 @@ export class GeoblockedError extends WebrpcError { constructor( name: string = 'Geoblocked', code: number = 1006, - message: string = 'Geoblocked region', + message: string = `Geoblocked region`, status: number = 0, cause?: string ) { @@ -813,7 +813,7 @@ export class RateLimitedError extends WebrpcError { constructor( name: string = 'RateLimited', code: number = 1007, - message: string = 'Rate-limited. Please slow down.', + message: string = `Rate-limited. Please slow down.`, status: number = 0, cause?: string ) { @@ -826,7 +826,7 @@ export class InvalidArgumentError extends WebrpcError { constructor( name: string = 'InvalidArgument', code: number = 2001, - message: string = 'Invalid argument', + message: string = `Invalid argument`, status: number = 0, cause?: string ) { @@ -839,7 +839,7 @@ export class UnavailableError extends WebrpcError { constructor( name: string = 'Unavailable', code: number = 2002, - message: string = 'Unavailable resource', + message: string = `Unavailable resource`, status: number = 0, cause?: string ) { @@ -852,7 +852,7 @@ export class QueryFailedError extends WebrpcError { constructor( name: string = 'QueryFailed', code: number = 2003, - message: string = 'Query failed', + message: string = `Query failed`, status: number = 0, cause?: string ) { @@ -865,7 +865,7 @@ export class ValidationFailedError extends WebrpcError { constructor( name: string = 'ValidationFailed', code: number = 2004, - message: string = 'Validation Failed', + message: string = `Validation Failed`, status: number = 0, cause?: string ) { @@ -878,7 +878,7 @@ export class NotFoundError extends WebrpcError { constructor( name: string = 'NotFound', code: number = 3000, - message: string = 'Resource not found', + message: string = `Resource not found`, status: number = 0, cause?: string ) { diff --git a/packages/marketplace/src/marketplace.gen.ts b/packages/marketplace/src/marketplace.gen.ts index 51ef99079..8e259cf21 100644 --- a/packages/marketplace/src/marketplace.gen.ts +++ b/packages/marketplace/src/marketplace.gen.ts @@ -1,14 +1,14 @@ /* eslint-disable */ -// marketplace-api 272a2d3c9208fb21b84c88a2a8cbd9ab8e29964d +// marketplace-api 8c729a93a7f162793cbc496f93aeecae1ab4eeaf // -- -// Code generated by webrpc-gen@v0.21.1 with typescript generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.23.2 with typescript generator. DO NOT EDIT. // // webrpc-gen -schema=marketplace.ridl -target=typescript -client -out=./clients/marketplace.gen.ts export const WebrpcHeader = 'Webrpc' export const WebrpcHeaderValue = - 'webrpc@v0.21.1;gen-typescript@v0.15.1;marketplace-api@v0.0.0-272a2d3c9208fb21b84c88a2a8cbd9ab8e29964d' + 'webrpc@v0.23.2;gen-typescript@v0.16.3;marketplace-api@v0.0.0-8c729a93a7f162793cbc496f93aeecae1ab4eeaf' // WebRPC description and code-gen version export const WebRPCVersion = 'v1' @@ -17,7 +17,7 @@ export const WebRPCVersion = 'v1' export const WebRPCSchemaVersion = '' // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = '272a2d3c9208fb21b84c88a2a8cbd9ab8e29964d' +export const WebRPCSchemaHash = '8c729a93a7f162793cbc496f93aeecae1ab4eeaf' type WebrpcGenVersions = { webrpcGenVersion: string @@ -54,16 +54,16 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions { } } - const [_, webrpcGenVersion] = versions[0].split('@') - const [codeGenName, codeGenVersion] = versions[1].split('@') - const [schemaName, schemaVersion] = versions[2].split('@') + const [_, webrpcGenVersion] = versions[0]!.split('@') + const [codeGenName, codeGenVersion] = versions[1]!.split('@') + const [schemaName, schemaVersion] = versions[2]!.split('@') return { - webrpcGenVersion, - codeGenName, - codeGenVersion, - schemaName, - schemaVersion + webrpcGenVersion: webrpcGenVersion ?? '', + codeGenName: codeGenName ?? '', + codeGenVersion: codeGenVersion ?? '', + schemaName: schemaName ?? '', + schemaVersion: schemaVersion ?? '' } } @@ -119,24 +119,14 @@ export enum MarketplaceKind { unknown = 'unknown', sequence_marketplace_v1 = 'sequence_marketplace_v1', sequence_marketplace_v2 = 'sequence_marketplace_v2', + blur = 'blur', + zerox = 'zerox', opensea = 'opensea', - magic_eden = 'magic_eden', - mintify = 'mintify', looks_rare = 'looks_rare', x2y2 = 'x2y2', - sudo_swap = 'sudo_swap', - coinbase = 'coinbase', - rarible = 'rarible', - nftx = 'nftx', - foundation = 'foundation', - manifold = 'manifold', - zora = 'zora', - blur = 'blur', - super_rare = 'super_rare', - okx = 'okx', - element = 'element', - aqua_xyz = 'aqua_xyz', - auranft_co = 'auranft_co' + alienswap = 'alienswap', + payment_processor = 'payment_processor', + mintify = 'mintify' } export enum OrderbookKind { @@ -169,7 +159,8 @@ export enum OrderStatus { inactive = 'inactive', expired = 'expired', cancelled = 'cancelled', - filled = 'filled' + filled = 'filled', + decimals_missing = 'decimals_missing' } export enum ContractType { @@ -179,9 +170,18 @@ export enum ContractType { ERC1155 = 'ERC1155' } +export enum CollectionPriority { + unknown = 'unknown', + low = 'low', + normal = 'normal', + high = 'high' +} + export enum CollectionStatus { unknown = 'unknown', created = 'created', + syncing_contract_metadata = 'syncing_contract_metadata', + synced_contract_metadata = 'synced_contract_metadata', syncing_metadata = 'syncing_metadata', synced_metadata = 'synced_metadata', syncing_tokens = 'syncing_tokens', @@ -189,7 +189,8 @@ export enum CollectionStatus { syncing_orders = 'syncing_orders', active = 'active', failed = 'failed', - inactive = 'inactive' + inactive = 'inactive', + incompatible_type = 'incompatible_type' } export enum ProjectStatus { @@ -204,6 +205,14 @@ export enum CollectibleStatus { inactive = 'inactive' } +export enum CurrencyStatus { + unknown = 'unknown', + created = 'created', + syncing_metadata = 'syncing_metadata', + active = 'active', + failed = 'failed' +} + export enum WalletKind { unknown = 'unknown', sequence = 'sequence' @@ -217,7 +226,8 @@ export enum StepType { createListing = 'createListing', createOffer = 'createOffer', signEIP712 = 'signEIP712', - signEIP191 = 'signEIP191' + signEIP191 = 'signEIP191', + cancel = 'cancel' } export enum TransactionCrypto { @@ -248,6 +258,17 @@ export enum ExecuteType { order = 'order' } +export enum ActivityAction { + unknown = 'unknown', + listing = 'listing', + offer = 'offer', + mint = 'mint', + sale = 'sale', + listingCancel = 'listingCancel', + offerCancel = 'offerCancel', + transfer = 'transfer' +} + export interface Page { page: number pageSize: number @@ -282,6 +303,8 @@ export interface CollectiblesFilter { notInAccounts?: Array ordersCreatedBy?: Array ordersNotCreatedBy?: Array + inCurrencyAddresses?: Array + notInCurrencyAddresses?: Array } export interface Order { @@ -290,8 +313,9 @@ export interface Order { side: OrderSide status: OrderStatus chainId: number + originName: string collectionContractAddress: string - tokenId: string + tokenId?: string createdBy: string priceAmount: string priceAmountFormatted: string @@ -300,6 +324,7 @@ export interface Order { priceCurrencyAddress: string priceDecimals: number priceUSD: number + priceUSDFormatted: string quantityInitial: string quantityInitialFormatted: string quantityRemaining: string @@ -328,6 +353,8 @@ export interface FeeBreakdown { export interface CollectibleOrder { metadata: TokenMetadata order?: Order + listing?: Order + offer?: Order } export interface OrderFilter { @@ -336,23 +363,12 @@ export interface OrderFilter { currencies?: Array } -export interface Activity { - type: string - fromAddress: string - toAddress: string - txHash: string - timestamp: number - tokenId: string - tokenImage: string - tokenName: string - currency?: Currency -} - export interface Collection { status: CollectionStatus chainId: number contractAddress: string contractType: ContractType + priority: CollectionPriority tokenQuantityDecimals: number config: CollectionConfig createdAt: string @@ -363,6 +379,8 @@ export interface Collection { export interface CollectionConfig { lastSynced: { [key: string]: CollectionLastSynced } collectiblesSynced: string + activitiesSynced: string + activitiesSyncedContinuity: string } export interface CollectionLastSynced { @@ -385,6 +403,7 @@ export interface Collectible { contractAddress: string status: CollectibleStatus tokenId: string + decimals: number createdAt: string updatedAt: string deletedAt?: string @@ -393,6 +412,7 @@ export interface Collectible { export interface Currency { chainId: number contractAddress: string + status: CurrencyStatus name: string symbol: string decimals: number @@ -420,6 +440,7 @@ export interface Step { data: string to: string value: string + price: string signature?: Signature post?: PostRequest executeType?: ExecuteType @@ -477,9 +498,31 @@ export interface CheckoutOptions { onRamp: Array } +export interface Activity { + chainId: number + contractAddress: string + tokenId: string + action: ActivityAction + txHash: string + from: string + to?: string + quantity: string + quantityDecimals: number + priceAmount?: string + priceAmountFormatted?: string + priceCurrencyAddress?: string + priceDecimals?: number + activityCreatedAt: string + uniqueHash: string + createdAt: string + updatedAt: string + deletedAt?: string +} + export interface Admin { createCollection(args: CreateCollectionArgs, headers?: object, signal?: AbortSignal): Promise getCollection(args: GetCollectionArgs, headers?: object, signal?: AbortSignal): Promise + updateCollection(args: UpdateCollectionArgs, headers?: object, signal?: AbortSignal): Promise listCollections(args: ListCollectionsArgs, headers?: object, signal?: AbortSignal): Promise deleteCollection(args: DeleteCollectionArgs, headers?: object, signal?: AbortSignal): Promise syncCollection(args: SyncCollectionArgs, headers?: object, signal?: AbortSignal): Promise @@ -506,6 +549,13 @@ export interface GetCollectionArgs { export interface GetCollectionReturn { collection: Collection } +export interface UpdateCollectionArgs { + collection: Collection +} + +export interface UpdateCollectionReturn { + collection: Collection +} export interface ListCollectionsArgs { projectId: number page?: Page @@ -568,6 +618,7 @@ export interface DeleteCurrencyReturn { export interface Marketplace { listCurrencies(headers?: object, signal?: AbortSignal): Promise + getCollectionDetail(args: GetCollectionDetailArgs, headers?: object, signal?: AbortSignal): Promise getCollectible(args: GetCollectibleArgs, headers?: object, signal?: AbortSignal): Promise getLowestPriceOfferForCollectible( args: GetLowestPriceOfferForCollectibleArgs, @@ -599,6 +650,16 @@ export interface Marketplace { headers?: object, signal?: AbortSignal ): Promise + getCountOfListingsForCollectible( + args: GetCountOfListingsForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise + getCountOfOffersForCollectible( + args: GetCountOfOffersForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise getCollectibleLowestOffer( args: GetCollectibleLowestOfferArgs, headers?: object, @@ -649,6 +710,11 @@ export interface Marketplace { headers?: object, signal?: AbortSignal ): Promise + generateCancelTransaction( + args: GenerateCancelTransactionArgs, + headers?: object, + signal?: AbortSignal + ): Promise execute(args: ExecuteArgs, headers?: object, signal?: AbortSignal): Promise listCollectibles(args: ListCollectiblesArgs, headers?: object, signal?: AbortSignal): Promise getCountOfAllCollectibles( @@ -662,6 +728,16 @@ export interface Marketplace { signal?: AbortSignal ): Promise getFloorOrder(args: GetFloorOrderArgs, headers?: object, signal?: AbortSignal): Promise + listCollectionActivities( + args: ListCollectionActivitiesArgs, + headers?: object, + signal?: AbortSignal + ): Promise + listCollectibleActivities( + args: ListCollectibleActivitiesArgs, + headers?: object, + signal?: AbortSignal + ): Promise listCollectiblesWithLowestListing( args: ListCollectiblesWithLowestListingArgs, headers?: object, @@ -692,6 +768,13 @@ export interface ListCurrenciesArgs {} export interface ListCurrenciesReturn { currencies: Array } +export interface GetCollectionDetailArgs { + contractAddress: string +} + +export interface GetCollectionDetailReturn { + collection: Collection +} export interface GetCollectibleArgs { contractAddress: string tokenId: string @@ -758,6 +841,24 @@ export interface ListOffersForCollectibleReturn { offers: Array page?: Page } +export interface GetCountOfListingsForCollectibleArgs { + contractAddress: string + tokenId: string + filter?: OrderFilter +} + +export interface GetCountOfListingsForCollectibleReturn { + count: number +} +export interface GetCountOfOffersForCollectibleArgs { + contractAddress: string + tokenId: string + filter?: OrderFilter +} + +export interface GetCountOfOffersForCollectibleReturn { + count: number +} export interface GetCollectibleLowestOfferArgs { contractAddress: string tokenId: string @@ -864,6 +965,16 @@ export interface GenerateOfferTransactionArgs { export interface GenerateOfferTransactionReturn { steps: Array } +export interface GenerateCancelTransactionArgs { + collectionAddress: string + maker: string + marketplace: MarketplaceKind + orderId: string +} + +export interface GenerateCancelTransactionReturn { + steps: Array +} export interface ExecuteArgs { signature: string executeType: ExecuteType @@ -908,6 +1019,25 @@ export interface GetFloorOrderArgs { export interface GetFloorOrderReturn { collectible: CollectibleOrder } +export interface ListCollectionActivitiesArgs { + contractAddress: string + page?: Page +} + +export interface ListCollectionActivitiesReturn { + activities: Array + page?: Page +} +export interface ListCollectibleActivitiesArgs { + contractAddress: string + tokenId: string + page?: Page +} + +export interface ListCollectibleActivitiesReturn { + activities: Array + page?: Page +} export interface ListCollectiblesWithLowestListingArgs { contractAddress: string filter?: CollectiblesFilter @@ -1014,6 +1144,21 @@ export class Admin implements Admin { ) } + updateCollection = (args: UpdateCollectionArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch(this.url('UpdateCollection'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + collection: _data.collection + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + listCollections = (args: ListCollectionsArgs, headers?: object, signal?: AbortSignal): Promise => { return this.fetch(this.url('ListCollections'), createHTTPRequest(args, headers, signal)).then( res => { @@ -1164,6 +1309,25 @@ export class Marketplace implements Marketplace { ) } + getCollectionDetail = ( + args: GetCollectionDetailArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetCollectionDetail'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + collection: _data.collection + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + getCollectible = (args: GetCollectibleArgs, headers?: object, signal?: AbortSignal): Promise => { return this.fetch(this.url('GetCollectible'), createHTTPRequest(args, headers, signal)).then( res => { @@ -1295,6 +1459,44 @@ export class Marketplace implements Marketplace { ) } + getCountOfListingsForCollectible = ( + args: GetCountOfListingsForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetCountOfListingsForCollectible'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + count: _data.count + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getCountOfOffersForCollectible = ( + args: GetCountOfOffersForCollectibleArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetCountOfOffersForCollectible'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + count: _data.count + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + getCollectibleLowestOffer = ( args: GetCollectibleLowestOfferArgs, headers?: object, @@ -1487,6 +1689,25 @@ export class Marketplace implements Marketplace { ) } + generateCancelTransaction = ( + args: GenerateCancelTransactionArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GenerateCancelTransaction'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + steps: >_data.steps + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + execute = (args: ExecuteArgs, headers?: object, signal?: AbortSignal): Promise => { return this.fetch(this.url('Execute'), createHTTPRequest(args, headers, signal)).then( res => { @@ -1571,6 +1792,46 @@ export class Marketplace implements Marketplace { ) } + listCollectionActivities = ( + args: ListCollectionActivitiesArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('ListCollectionActivities'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + activities: >_data.activities, + page: _data.page + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + listCollectibleActivities = ( + args: ListCollectibleActivitiesArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('ListCollectibleActivities'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + activities: >_data.activities, + page: _data.page + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + listCollectiblesWithLowestListing = ( args: ListCollectiblesWithLowestListingArgs, headers?: object, @@ -1763,7 +2024,7 @@ export class WebrpcEndpointError extends WebrpcError { constructor( name: string = 'WebrpcEndpoint', code: number = 0, - message: string = 'endpoint error', + message: string = `endpoint error`, status: number = 0, cause?: string ) { @@ -1776,7 +2037,7 @@ export class WebrpcRequestFailedError extends WebrpcError { constructor( name: string = 'WebrpcRequestFailed', code: number = -1, - message: string = 'request failed', + message: string = `request failed`, status: number = 0, cause?: string ) { @@ -1789,7 +2050,7 @@ export class WebrpcBadRouteError extends WebrpcError { constructor( name: string = 'WebrpcBadRoute', code: number = -2, - message: string = 'bad route', + message: string = `bad route`, status: number = 0, cause?: string ) { @@ -1802,7 +2063,7 @@ export class WebrpcBadMethodError extends WebrpcError { constructor( name: string = 'WebrpcBadMethod', code: number = -3, - message: string = 'bad method', + message: string = `bad method`, status: number = 0, cause?: string ) { @@ -1815,7 +2076,7 @@ export class WebrpcBadRequestError extends WebrpcError { constructor( name: string = 'WebrpcBadRequest', code: number = -4, - message: string = 'bad request', + message: string = `bad request`, status: number = 0, cause?: string ) { @@ -1828,7 +2089,7 @@ export class WebrpcBadResponseError extends WebrpcError { constructor( name: string = 'WebrpcBadResponse', code: number = -5, - message: string = 'bad response', + message: string = `bad response`, status: number = 0, cause?: string ) { @@ -1841,7 +2102,7 @@ export class WebrpcServerPanicError extends WebrpcError { constructor( name: string = 'WebrpcServerPanic', code: number = -6, - message: string = 'server panic', + message: string = `server panic`, status: number = 0, cause?: string ) { @@ -1854,7 +2115,7 @@ export class WebrpcInternalErrorError extends WebrpcError { constructor( name: string = 'WebrpcInternalError', code: number = -7, - message: string = 'internal error', + message: string = `internal error`, status: number = 0, cause?: string ) { @@ -1867,7 +2128,7 @@ export class WebrpcClientDisconnectedError extends WebrpcError { constructor( name: string = 'WebrpcClientDisconnected', code: number = -8, - message: string = 'client disconnected', + message: string = `client disconnected`, status: number = 0, cause?: string ) { @@ -1880,7 +2141,7 @@ export class WebrpcStreamLostError extends WebrpcError { constructor( name: string = 'WebrpcStreamLost', code: number = -9, - message: string = 'stream lost', + message: string = `stream lost`, status: number = 0, cause?: string ) { @@ -1893,7 +2154,7 @@ export class WebrpcStreamFinishedError extends WebrpcError { constructor( name: string = 'WebrpcStreamFinished', code: number = -10, - message: string = 'stream finished', + message: string = `stream finished`, status: number = 0, cause?: string ) { @@ -1908,7 +2169,7 @@ export class UnauthorizedError extends WebrpcError { constructor( name: string = 'Unauthorized', code: number = 1000, - message: string = 'Unauthorized access', + message: string = `Unauthorized access`, status: number = 0, cause?: string ) { @@ -1921,7 +2182,7 @@ export class PermissionDeniedError extends WebrpcError { constructor( name: string = 'PermissionDenied', code: number = 1001, - message: string = 'Permission denied', + message: string = `Permission denied`, status: number = 0, cause?: string ) { @@ -1934,7 +2195,7 @@ export class SessionExpiredError extends WebrpcError { constructor( name: string = 'SessionExpired', code: number = 1002, - message: string = 'Session expired', + message: string = `Session expired`, status: number = 0, cause?: string ) { @@ -1947,7 +2208,7 @@ export class MethodNotFoundError extends WebrpcError { constructor( name: string = 'MethodNotFound', code: number = 1003, - message: string = 'Method not found', + message: string = `Method not found`, status: number = 0, cause?: string ) { @@ -1960,7 +2221,7 @@ export class TimeoutError extends WebrpcError { constructor( name: string = 'Timeout', code: number = 2000, - message: string = 'Request timed out', + message: string = `Request timed out`, status: number = 0, cause?: string ) { @@ -1973,7 +2234,7 @@ export class InvalidArgumentError extends WebrpcError { constructor( name: string = 'InvalidArgument', code: number = 2001, - message: string = 'Invalid argument', + message: string = `Invalid argument`, status: number = 0, cause?: string ) { @@ -1986,7 +2247,7 @@ export class NotFoundError extends WebrpcError { constructor( name: string = 'NotFound', code: number = 3000, - message: string = 'Resource not found', + message: string = `Resource not found`, status: number = 0, cause?: string ) { @@ -1999,7 +2260,7 @@ export class UserNotFoundError extends WebrpcError { constructor( name: string = 'UserNotFound', code: number = 3001, - message: string = 'User not found', + message: string = `User not found`, status: number = 0, cause?: string ) { @@ -2012,7 +2273,7 @@ export class ProjectNotFoundError extends WebrpcError { constructor( name: string = 'ProjectNotFound', code: number = 3002, - message: string = 'Project not found', + message: string = `Project not found`, status: number = 0, cause?: string ) { @@ -2025,7 +2286,7 @@ export class InvalidTierError extends WebrpcError { constructor( name: string = 'InvalidTier', code: number = 3003, - message: string = 'Invalid subscription tier', + message: string = `Invalid subscription tier`, status: number = 0, cause?: string ) { @@ -2038,7 +2299,7 @@ export class ProjectLimitReachedError extends WebrpcError { constructor( name: string = 'ProjectLimitReached', code: number = 3005, - message: string = 'Project limit reached', + message: string = `Project limit reached`, status: number = 0, cause?: string ) { @@ -2051,7 +2312,7 @@ export class NotImplementedError extends WebrpcError { constructor( name: string = 'NotImplemented', code: number = 9999, - message: string = 'Not Implemented', + message: string = `Not Implemented`, status: number = 0, cause?: string ) { @@ -2086,7 +2347,33 @@ export enum errors { NotImplemented = 'NotImplemented' } -const webrpcErrorByCode: { [code: number]: any } = { +export enum WebrpcErrorCodes { + WebrpcEndpoint = 0, + WebrpcRequestFailed = -1, + WebrpcBadRoute = -2, + WebrpcBadMethod = -3, + WebrpcBadRequest = -4, + WebrpcBadResponse = -5, + WebrpcServerPanic = -6, + WebrpcInternalError = -7, + WebrpcClientDisconnected = -8, + WebrpcStreamLost = -9, + WebrpcStreamFinished = -10, + Unauthorized = 1000, + PermissionDenied = 1001, + SessionExpired = 1002, + MethodNotFound = 1003, + Timeout = 2000, + InvalidArgument = 2001, + NotFound = 3000, + UserNotFound = 3001, + ProjectNotFound = 3002, + InvalidTier = 3003, + ProjectLimitReached = 3005, + NotImplemented = 9999 +} + +export const webrpcErrorByCode: { [code: number]: any } = { [0]: WebrpcEndpointError, [-1]: WebrpcRequestFailedError, [-2]: WebrpcBadRouteError, diff --git a/packages/metadata/src/metadata.gen.ts b/packages/metadata/src/metadata.gen.ts index 5202db29d..4adfdda1e 100644 --- a/packages/metadata/src/metadata.gen.ts +++ b/packages/metadata/src/metadata.gen.ts @@ -1,13 +1,13 @@ /* eslint-disable */ // sequence-metadata v0.4.0 9594f86f8681f364dd514a1bd7cae1c1dc77e3de // -- -// Code generated by webrpc-gen@v0.21.1 with typescript generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.23.2 with typescript generator. DO NOT EDIT. // // webrpc-gen -schema=metadata.ridl -target=typescript -client -out=./clients/metadata.gen.ts export const WebrpcHeader = 'Webrpc' -export const WebrpcHeaderValue = 'webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-metadata@v0.4.0' +export const WebrpcHeaderValue = 'webrpc@v0.23.2;gen-typescript@v0.16.3;sequence-metadata@v0.4.0' // WebRPC description and code-gen version export const WebRPCVersion = 'v1' @@ -53,16 +53,16 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions { } } - const [_, webrpcGenVersion] = versions[0].split('@') - const [codeGenName, codeGenVersion] = versions[1].split('@') - const [schemaName, schemaVersion] = versions[2].split('@') + const [_, webrpcGenVersion] = versions[0]!.split('@') + const [codeGenName, codeGenVersion] = versions[1]!.split('@') + const [schemaName, schemaVersion] = versions[2]!.split('@') return { - webrpcGenVersion, - codeGenName, - codeGenVersion, - schemaName, - schemaVersion + webrpcGenVersion: webrpcGenVersion ?? '', + codeGenName: codeGenName ?? '', + codeGenVersion: codeGenVersion ?? '', + schemaName: schemaName ?? '', + schemaVersion: schemaVersion ?? '' } } @@ -2321,7 +2321,7 @@ export class WebrpcEndpointError extends WebrpcError { constructor( name: string = 'WebrpcEndpoint', code: number = 0, - message: string = 'endpoint error', + message: string = `endpoint error`, status: number = 0, cause?: string ) { @@ -2334,7 +2334,7 @@ export class WebrpcRequestFailedError extends WebrpcError { constructor( name: string = 'WebrpcRequestFailed', code: number = -1, - message: string = 'request failed', + message: string = `request failed`, status: number = 0, cause?: string ) { @@ -2347,7 +2347,7 @@ export class WebrpcBadRouteError extends WebrpcError { constructor( name: string = 'WebrpcBadRoute', code: number = -2, - message: string = 'bad route', + message: string = `bad route`, status: number = 0, cause?: string ) { @@ -2360,7 +2360,7 @@ export class WebrpcBadMethodError extends WebrpcError { constructor( name: string = 'WebrpcBadMethod', code: number = -3, - message: string = 'bad method', + message: string = `bad method`, status: number = 0, cause?: string ) { @@ -2373,7 +2373,7 @@ export class WebrpcBadRequestError extends WebrpcError { constructor( name: string = 'WebrpcBadRequest', code: number = -4, - message: string = 'bad request', + message: string = `bad request`, status: number = 0, cause?: string ) { @@ -2386,7 +2386,7 @@ export class WebrpcBadResponseError extends WebrpcError { constructor( name: string = 'WebrpcBadResponse', code: number = -5, - message: string = 'bad response', + message: string = `bad response`, status: number = 0, cause?: string ) { @@ -2399,7 +2399,7 @@ export class WebrpcServerPanicError extends WebrpcError { constructor( name: string = 'WebrpcServerPanic', code: number = -6, - message: string = 'server panic', + message: string = `server panic`, status: number = 0, cause?: string ) { @@ -2412,7 +2412,7 @@ export class WebrpcInternalErrorError extends WebrpcError { constructor( name: string = 'WebrpcInternalError', code: number = -7, - message: string = 'internal error', + message: string = `internal error`, status: number = 0, cause?: string ) { @@ -2425,7 +2425,7 @@ export class WebrpcClientDisconnectedError extends WebrpcError { constructor( name: string = 'WebrpcClientDisconnected', code: number = -8, - message: string = 'client disconnected', + message: string = `client disconnected`, status: number = 0, cause?: string ) { @@ -2438,7 +2438,7 @@ export class WebrpcStreamLostError extends WebrpcError { constructor( name: string = 'WebrpcStreamLost', code: number = -9, - message: string = 'stream lost', + message: string = `stream lost`, status: number = 0, cause?: string ) { @@ -2451,7 +2451,7 @@ export class WebrpcStreamFinishedError extends WebrpcError { constructor( name: string = 'WebrpcStreamFinished', code: number = -10, - message: string = 'stream finished', + message: string = `stream finished`, status: number = 0, cause?: string ) { @@ -2466,7 +2466,7 @@ export class UnauthorizedError extends WebrpcError { constructor( name: string = 'Unauthorized', code: number = 1000, - message: string = 'Unauthorized access', + message: string = `Unauthorized access`, status: number = 0, cause?: string ) { @@ -2479,7 +2479,7 @@ export class PermissionDeniedError extends WebrpcError { constructor( name: string = 'PermissionDenied', code: number = 1001, - message: string = 'Permission denied', + message: string = `Permission denied`, status: number = 0, cause?: string ) { @@ -2492,7 +2492,7 @@ export class SessionExpiredError extends WebrpcError { constructor( name: string = 'SessionExpired', code: number = 1002, - message: string = 'Session expired', + message: string = `Session expired`, status: number = 0, cause?: string ) { @@ -2505,7 +2505,7 @@ export class MethodNotFoundError extends WebrpcError { constructor( name: string = 'MethodNotFound', code: number = 1003, - message: string = 'Method not found', + message: string = `Method not found`, status: number = 0, cause?: string ) { @@ -2518,7 +2518,7 @@ export class RequestConflictError extends WebrpcError { constructor( name: string = 'RequestConflict', code: number = 1004, - message: string = 'Conflict with target resource', + message: string = `Conflict with target resource`, status: number = 0, cause?: string ) { @@ -2531,7 +2531,7 @@ export class FailError extends WebrpcError { constructor( name: string = 'Fail', code: number = 1005, - message: string = 'Request Failed', + message: string = `Request Failed`, status: number = 0, cause?: string ) { @@ -2544,7 +2544,7 @@ export class GeoblockedError extends WebrpcError { constructor( name: string = 'Geoblocked', code: number = 1006, - message: string = 'Geoblocked region', + message: string = `Geoblocked region`, status: number = 0, cause?: string ) { @@ -2557,7 +2557,7 @@ export class TimeoutError extends WebrpcError { constructor( name: string = 'Timeout', code: number = 2000, - message: string = 'Request timed out', + message: string = `Request timed out`, status: number = 0, cause?: string ) { @@ -2570,7 +2570,7 @@ export class InvalidArgumentError extends WebrpcError { constructor( name: string = 'InvalidArgument', code: number = 2001, - message: string = 'Invalid argument', + message: string = `Invalid argument`, status: number = 0, cause?: string ) { @@ -2583,7 +2583,7 @@ export class RequiredArgumentError extends WebrpcError { constructor( name: string = 'RequiredArgument', code: number = 2002, - message: string = 'Required argument missing', + message: string = `Required argument missing`, status: number = 0, cause?: string ) { @@ -2596,7 +2596,7 @@ export class QueryFailedError extends WebrpcError { constructor( name: string = 'QueryFailed', code: number = 2003, - message: string = 'Query failed', + message: string = `Query failed`, status: number = 0, cause?: string ) { @@ -2609,7 +2609,7 @@ export class ValidationFailedError extends WebrpcError { constructor( name: string = 'ValidationFailed', code: number = 2004, - message: string = 'Validation failed', + message: string = `Validation failed`, status: number = 0, cause?: string ) { @@ -2622,7 +2622,7 @@ export class RateLimitedError extends WebrpcError { constructor( name: string = 'RateLimited', code: number = 2005, - message: string = 'Rate limited', + message: string = `Rate limited`, status: number = 0, cause?: string ) { @@ -2635,7 +2635,7 @@ export class NotFoundError extends WebrpcError { constructor( name: string = 'NotFound', code: number = 3000, - message: string = 'Resource not found', + message: string = `Resource not found`, status: number = 0, cause?: string ) { @@ -2648,7 +2648,7 @@ export class ProjectNotFoundError extends WebrpcError { constructor( name: string = 'ProjectNotFound', code: number = 3002, - message: string = 'Project not found', + message: string = `Project not found`, status: number = 0, cause?: string ) { @@ -2661,7 +2661,7 @@ export class ChainNotFoundError extends WebrpcError { constructor( name: string = 'ChainNotFound', code: number = 3003, - message: string = 'Chain not found', + message: string = `Chain not found`, status: number = 0, cause?: string ) { @@ -2674,7 +2674,7 @@ export class TokenDirectoryDisabledError extends WebrpcError { constructor( name: string = 'TokenDirectoryDisabled', code: number = 4001, - message: string = 'Token Directory is disabled', + message: string = `Token Directory is disabled`, status: number = 0, cause?: string ) { @@ -2714,7 +2714,38 @@ export enum errors { TokenDirectoryDisabled = 'TokenDirectoryDisabled' } -const webrpcErrorByCode: { [code: number]: any } = { +export enum WebrpcErrorCodes { + WebrpcEndpoint = 0, + WebrpcRequestFailed = -1, + WebrpcBadRoute = -2, + WebrpcBadMethod = -3, + WebrpcBadRequest = -4, + WebrpcBadResponse = -5, + WebrpcServerPanic = -6, + WebrpcInternalError = -7, + WebrpcClientDisconnected = -8, + WebrpcStreamLost = -9, + WebrpcStreamFinished = -10, + Unauthorized = 1000, + PermissionDenied = 1001, + SessionExpired = 1002, + MethodNotFound = 1003, + RequestConflict = 1004, + Fail = 1005, + Geoblocked = 1006, + Timeout = 2000, + InvalidArgument = 2001, + RequiredArgument = 2002, + QueryFailed = 2003, + ValidationFailed = 2004, + RateLimited = 2005, + NotFound = 3000, + ProjectNotFound = 3002, + ChainNotFound = 3003, + TokenDirectoryDisabled = 4001 +} + +export const webrpcErrorByCode: { [code: number]: any } = { [0]: WebrpcEndpointError, [-1]: WebrpcRequestFailedError, [-2]: WebrpcBadRouteError, diff --git a/packages/network/src/constants.ts b/packages/network/src/constants.ts index a524cf596..8356a459d 100644 --- a/packages/network/src/constants.ts +++ b/packages/network/src/constants.ts @@ -136,13 +136,7 @@ export enum ChainId { // MOONBEAM MOONBEAM = 1284, - MOONBASE_ALPHA = 1287, - - //MONAD_TESTNET - MONAD_TESTNET = 10143, - - //SOMNIA_TESTNET - SOMNIA_TESTNET = 50312 + MOONBASE_ALPHA = 1287 } export const networks: Record = { @@ -1115,41 +1109,6 @@ export const networks: Record = { name: 'Tez', decimals: 18 } - }, - [ChainId.MONAD_TESTNET]: { - chainId: ChainId.MONAD_TESTNET, - type: NetworkType.TESTNET, - name: 'monad-testnet', - title: 'MONAD Testnet', - logoURI: `https://assets.sequence.info/images/networks/medium/${ChainId.MONAD_TESTNET}.webp`, - testnet: true, - blockExplorer: { - name: 'MONAD Testnet Explorer', - rootUrl: 'https://testnet.monadexplorer.com/' - }, - nativeToken: { - symbol: 'MON', - name: 'MON', - decimals: 18 - } - }, - - [ChainId.SOMNIA_TESTNET]: { - chainId: ChainId.SOMNIA_TESTNET, - type: NetworkType.TESTNET, - name: 'somnia-testnet', - title: 'SOMNIA Testnet', - logoURI: `https://assets.sequence.info/images/networks/medium/${ChainId.SOMNIA_TESTNET}.webp`, - testnet: true, - blockExplorer: { - name: 'SOMNIA Testnet Explorer', - rootUrl: 'https://somnia-testnet.socialscan.io/' - }, - nativeToken: { - symbol: 'STT', - name: 'STT', - decimals: 18 - } } } diff --git a/packages/relayer/src/rpc-relayer/relayer.gen.ts b/packages/relayer/src/rpc-relayer/relayer.gen.ts index f300935a8..ad17ee96b 100644 --- a/packages/relayer/src/rpc-relayer/relayer.gen.ts +++ b/packages/relayer/src/rpc-relayer/relayer.gen.ts @@ -1,13 +1,13 @@ /* eslint-disable */ // sequence-relayer v0.4.1 da20208d66be29ad86d2662ca38c4425bc5910f8 // -- -// Code generated by webrpc-gen@v0.22.0 with typescript generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.23.2 with typescript generator. DO NOT EDIT. // // webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts export const WebrpcHeader = 'Webrpc' -export const WebrpcHeaderValue = 'webrpc@v0.22.0;gen-typescript@v0.16.1;sequence-relayer@v0.4.1' +export const WebrpcHeaderValue = 'webrpc@v0.23.2;gen-typescript@v0.16.3;sequence-relayer@v0.4.1' // WebRPC description and code-gen version export const WebRPCVersion = 'v1' @@ -53,16 +53,16 @@ function parseWebrpcGenVersions(header: string): WebrpcGenVersions { } } - const [_, webrpcGenVersion] = versions[0].split('@') - const [codeGenName, codeGenVersion] = versions[1].split('@') - const [schemaName, schemaVersion] = versions[2].split('@') + const [_, webrpcGenVersion] = versions[0]!.split('@') + const [codeGenName, codeGenVersion] = versions[1]!.split('@') + const [schemaName, schemaVersion] = versions[2]!.split('@') return { - webrpcGenVersion, - codeGenName, - codeGenVersion, - schemaName, - schemaVersion + webrpcGenVersion: webrpcGenVersion ?? '', + codeGenName: codeGenName ?? '', + codeGenVersion: codeGenVersion ?? '', + schemaName: schemaName ?? '', + schemaVersion: schemaVersion ?? '' } } @@ -1263,7 +1263,7 @@ export class WebrpcEndpointError extends WebrpcError { constructor( name: string = 'WebrpcEndpoint', code: number = 0, - message: string = 'endpoint error', + message: string = `endpoint error`, status: number = 0, cause?: string ) { @@ -1276,7 +1276,7 @@ export class WebrpcRequestFailedError extends WebrpcError { constructor( name: string = 'WebrpcRequestFailed', code: number = -1, - message: string = 'request failed', + message: string = `request failed`, status: number = 0, cause?: string ) { @@ -1289,7 +1289,7 @@ export class WebrpcBadRouteError extends WebrpcError { constructor( name: string = 'WebrpcBadRoute', code: number = -2, - message: string = 'bad route', + message: string = `bad route`, status: number = 0, cause?: string ) { @@ -1302,7 +1302,7 @@ export class WebrpcBadMethodError extends WebrpcError { constructor( name: string = 'WebrpcBadMethod', code: number = -3, - message: string = 'bad method', + message: string = `bad method`, status: number = 0, cause?: string ) { @@ -1315,7 +1315,7 @@ export class WebrpcBadRequestError extends WebrpcError { constructor( name: string = 'WebrpcBadRequest', code: number = -4, - message: string = 'bad request', + message: string = `bad request`, status: number = 0, cause?: string ) { @@ -1328,7 +1328,7 @@ export class WebrpcBadResponseError extends WebrpcError { constructor( name: string = 'WebrpcBadResponse', code: number = -5, - message: string = 'bad response', + message: string = `bad response`, status: number = 0, cause?: string ) { @@ -1341,7 +1341,7 @@ export class WebrpcServerPanicError extends WebrpcError { constructor( name: string = 'WebrpcServerPanic', code: number = -6, - message: string = 'server panic', + message: string = `server panic`, status: number = 0, cause?: string ) { @@ -1354,7 +1354,7 @@ export class WebrpcInternalErrorError extends WebrpcError { constructor( name: string = 'WebrpcInternalError', code: number = -7, - message: string = 'internal error', + message: string = `internal error`, status: number = 0, cause?: string ) { @@ -1367,7 +1367,7 @@ export class WebrpcClientDisconnectedError extends WebrpcError { constructor( name: string = 'WebrpcClientDisconnected', code: number = -8, - message: string = 'client disconnected', + message: string = `client disconnected`, status: number = 0, cause?: string ) { @@ -1380,7 +1380,7 @@ export class WebrpcStreamLostError extends WebrpcError { constructor( name: string = 'WebrpcStreamLost', code: number = -9, - message: string = 'stream lost', + message: string = `stream lost`, status: number = 0, cause?: string ) { @@ -1393,7 +1393,7 @@ export class WebrpcStreamFinishedError extends WebrpcError { constructor( name: string = 'WebrpcStreamFinished', code: number = -10, - message: string = 'stream finished', + message: string = `stream finished`, status: number = 0, cause?: string ) { @@ -1408,7 +1408,7 @@ export class UnauthorizedError extends WebrpcError { constructor( name: string = 'Unauthorized', code: number = 1000, - message: string = 'Unauthorized access', + message: string = `Unauthorized access`, status: number = 0, cause?: string ) { @@ -1421,7 +1421,7 @@ export class PermissionDeniedError extends WebrpcError { constructor( name: string = 'PermissionDenied', code: number = 1001, - message: string = 'Permission denied', + message: string = `Permission denied`, status: number = 0, cause?: string ) { @@ -1434,7 +1434,7 @@ export class SessionExpiredError extends WebrpcError { constructor( name: string = 'SessionExpired', code: number = 1002, - message: string = 'Session expired', + message: string = `Session expired`, status: number = 0, cause?: string ) { @@ -1447,7 +1447,7 @@ export class MethodNotFoundError extends WebrpcError { constructor( name: string = 'MethodNotFound', code: number = 1003, - message: string = 'Method not found', + message: string = `Method not found`, status: number = 0, cause?: string ) { @@ -1460,7 +1460,7 @@ export class RequestConflictError extends WebrpcError { constructor( name: string = 'RequestConflict', code: number = 1004, - message: string = 'Conflict with target resource', + message: string = `Conflict with target resource`, status: number = 0, cause?: string ) { @@ -1473,7 +1473,7 @@ export class AbortedError extends WebrpcError { constructor( name: string = 'Aborted', code: number = 1005, - message: string = 'Request aborted', + message: string = `Request aborted`, status: number = 0, cause?: string ) { @@ -1486,7 +1486,7 @@ export class GeoblockedError extends WebrpcError { constructor( name: string = 'Geoblocked', code: number = 1006, - message: string = 'Geoblocked region', + message: string = `Geoblocked region`, status: number = 0, cause?: string ) { @@ -1499,7 +1499,7 @@ export class RateLimitedError extends WebrpcError { constructor( name: string = 'RateLimited', code: number = 1007, - message: string = 'Rate-limited. Please slow down.', + message: string = `Rate-limited. Please slow down.`, status: number = 0, cause?: string ) { @@ -1512,7 +1512,7 @@ export class ProjectNotFoundError extends WebrpcError { constructor( name: string = 'ProjectNotFound', code: number = 1008, - message: string = 'Project not found', + message: string = `Project not found`, status: number = 0, cause?: string ) { @@ -1525,7 +1525,7 @@ export class AccessKeyNotFoundError extends WebrpcError { constructor( name: string = 'AccessKeyNotFound', code: number = 1101, - message: string = 'Access key not found', + message: string = `Access key not found`, status: number = 0, cause?: string ) { @@ -1538,7 +1538,7 @@ export class AccessKeyMismatchError extends WebrpcError { constructor( name: string = 'AccessKeyMismatch', code: number = 1102, - message: string = 'Access key mismatch', + message: string = `Access key mismatch`, status: number = 0, cause?: string ) { @@ -1551,7 +1551,7 @@ export class InvalidOriginError extends WebrpcError { constructor( name: string = 'InvalidOrigin', code: number = 1103, - message: string = 'Invalid origin for Access Key', + message: string = `Invalid origin for Access Key`, status: number = 0, cause?: string ) { @@ -1564,7 +1564,7 @@ export class InvalidServiceError extends WebrpcError { constructor( name: string = 'InvalidService', code: number = 1104, - message: string = 'Service not enabled for Access key', + message: string = `Service not enabled for Access key`, status: number = 0, cause?: string ) { @@ -1577,7 +1577,7 @@ export class UnauthorizedUserError extends WebrpcError { constructor( name: string = 'UnauthorizedUser', code: number = 1105, - message: string = 'Unauthorized user', + message: string = `Unauthorized user`, status: number = 0, cause?: string ) { @@ -1590,7 +1590,7 @@ export class QuotaExceededError extends WebrpcError { constructor( name: string = 'QuotaExceeded', code: number = 1200, - message: string = 'Quota request exceeded', + message: string = `Quota request exceeded`, status: number = 0, cause?: string ) { @@ -1603,7 +1603,7 @@ export class QuotaRateLimitError extends WebrpcError { constructor( name: string = 'QuotaRateLimit', code: number = 1201, - message: string = 'Quota rate limit exceeded', + message: string = `Quota rate limit exceeded`, status: number = 0, cause?: string ) { @@ -1616,7 +1616,7 @@ export class NoDefaultKeyError extends WebrpcError { constructor( name: string = 'NoDefaultKey', code: number = 1300, - message: string = 'No default access key found', + message: string = `No default access key found`, status: number = 0, cause?: string ) { @@ -1629,7 +1629,7 @@ export class MaxAccessKeysError extends WebrpcError { constructor( name: string = 'MaxAccessKeys', code: number = 1301, - message: string = 'Access keys limit reached', + message: string = `Access keys limit reached`, status: number = 0, cause?: string ) { @@ -1642,7 +1642,7 @@ export class AtLeastOneKeyError extends WebrpcError { constructor( name: string = 'AtLeastOneKey', code: number = 1302, - message: string = 'You need at least one Access Key', + message: string = `You need at least one Access Key`, status: number = 0, cause?: string ) { @@ -1655,7 +1655,7 @@ export class TimeoutError extends WebrpcError { constructor( name: string = 'Timeout', code: number = 1900, - message: string = 'Request timed out', + message: string = `Request timed out`, status: number = 0, cause?: string ) { @@ -1668,7 +1668,7 @@ export class InvalidArgumentError extends WebrpcError { constructor( name: string = 'InvalidArgument', code: number = 2001, - message: string = 'Invalid argument', + message: string = `Invalid argument`, status: number = 0, cause?: string ) { @@ -1681,7 +1681,7 @@ export class UnavailableError extends WebrpcError { constructor( name: string = 'Unavailable', code: number = 2002, - message: string = 'Unavailable resource', + message: string = `Unavailable resource`, status: number = 0, cause?: string ) { @@ -1694,7 +1694,7 @@ export class QueryFailedError extends WebrpcError { constructor( name: string = 'QueryFailed', code: number = 2003, - message: string = 'Query failed', + message: string = `Query failed`, status: number = 0, cause?: string ) { @@ -1707,7 +1707,7 @@ export class NotFoundError extends WebrpcError { constructor( name: string = 'NotFound', code: number = 3000, - message: string = 'Resource not found', + message: string = `Resource not found`, status: number = 0, cause?: string ) { @@ -1720,7 +1720,7 @@ export class InsufficientFeeError extends WebrpcError { constructor( name: string = 'InsufficientFee', code: number = 3004, - message: string = 'Insufficient fee', + message: string = `Insufficient fee`, status: number = 0, cause?: string ) {