diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..7f34c7a88 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @0xsequence/disable-codeowners-notifications @0xsequence/core diff --git a/CODEOWNERS b/CODEOWNERS deleted file mode 100644 index 956457a04..000000000 --- a/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @0xsequence/core diff --git a/packages/0xsequence/CHANGELOG.md b/packages/0xsequence/CHANGELOG.md index f424f4972..82ed64410 100644 --- a/packages/0xsequence/CHANGELOG.md +++ b/packages/0xsequence/CHANGELOG.md @@ -1,5 +1,53 @@ # 0xsequence +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/abi@2.2.6 + - @0xsequence/account@2.2.6 + - @0xsequence/api@2.2.6 + - @0xsequence/auth@2.2.6 + - @0xsequence/core@2.2.6 + - @0xsequence/guard@2.2.6 + - @0xsequence/indexer@2.2.6 + - @0xsequence/metadata@2.2.6 + - @0xsequence/migration@2.2.6 + - @0xsequence/network@2.2.6 + - @0xsequence/provider@2.2.6 + - @0xsequence/relayer@2.2.6 + - @0xsequence/sessions@2.2.6 + - @0xsequence/signhub@2.2.6 + - @0xsequence/utils@2.2.6 + - @0xsequence/wallet@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/abi@2.2.5 + - @0xsequence/account@2.2.5 + - @0xsequence/api@2.2.5 + - @0xsequence/auth@2.2.5 + - @0xsequence/core@2.2.5 + - @0xsequence/guard@2.2.5 + - @0xsequence/indexer@2.2.5 + - @0xsequence/metadata@2.2.5 + - @0xsequence/migration@2.2.5 + - @0xsequence/network@2.2.5 + - @0xsequence/provider@2.2.5 + - @0xsequence/relayer@2.2.5 + - @0xsequence/sessions@2.2.5 + - @0xsequence/signhub@2.2.5 + - @0xsequence/utils@2.2.5 + - @0xsequence/wallet@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/0xsequence/package.json b/packages/0xsequence/package.json index 4c92b8e33..05eb6aa9d 100644 --- a/packages/0xsequence/package.json +++ b/packages/0xsequence/package.json @@ -1,6 +1,6 @@ { "name": "0xsequence", - "version": "2.2.4", + "version": "2.2.6", "description": "Sequence: a modular web3 stack and smart wallet for Ethereum chains", "repository": "https://github.com/0xsequence/sequence.js", "source": "src/index.ts", diff --git a/packages/abi/CHANGELOG.md b/packages/abi/CHANGELOG.md index ff5f8ed7c..d8278a023 100644 --- a/packages/abi/CHANGELOG.md +++ b/packages/abi/CHANGELOG.md @@ -1,5 +1,18 @@ # @0xsequence/abi +## 2.2.6 + +### Patch Changes + +- Update relayer package + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook + ## 2.2.4 ### Patch Changes diff --git a/packages/abi/package.json b/packages/abi/package.json index b8388a0a5..f98a58614 100644 --- a/packages/abi/package.json +++ b/packages/abi/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/abi", - "version": "2.2.4", + "version": "2.2.6", "description": "abi sub-package for Sequence", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/abi", "source": "src/index.ts", diff --git a/packages/abi/src/wallet/index.ts b/packages/abi/src/wallet/index.ts index cb9bdf867..73a90929a 100644 --- a/packages/abi/src/wallet/index.ts +++ b/packages/abi/src/wallet/index.ts @@ -4,8 +4,10 @@ import * as erc6492 from './erc6492' import * as factory from './factory' import * as mainModule from './mainModule' import * as mainModuleUpgradable from './mainModuleUpgradable' +import * as moduleHooks from './moduleHooks' import * as sequenceUtils from './sequenceUtils' import * as requireFreshSigner from './libs/requireFreshSigners' +import * as walletProxyHook from './walletProxyHook' export const walletContracts = { erc6492, @@ -14,6 +16,8 @@ export const walletContracts = { factory, mainModule, mainModuleUpgradable, + moduleHooks, sequenceUtils, - requireFreshSigner + requireFreshSigner, + walletProxyHook } diff --git a/packages/abi/src/wallet/moduleHooks.ts b/packages/abi/src/wallet/moduleHooks.ts new file mode 100644 index 000000000..e35174b94 --- /dev/null +++ b/packages/abi/src/wallet/moduleHooks.ts @@ -0,0 +1,248 @@ +export const abi = [ + { + inputs: [ + { + internalType: 'bytes4', + name: '_signature', + type: 'bytes4' + } + ], + name: 'HookAlreadyExists', + type: 'error' + }, + { + inputs: [ + { + internalType: 'bytes4', + name: '_signature', + type: 'bytes4' + } + ], + name: 'HookDoesNotExist', + type: 'error' + }, + { + inputs: [ + { + internalType: 'address', + name: '_sender', + type: 'address' + }, + { + internalType: 'address', + name: '_self', + type: 'address' + } + ], + name: 'OnlySelfAuth', + type: 'error' + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'bytes4', + name: '_signature', + type: 'bytes4' + }, + { + indexed: false, + internalType: 'address', + name: '_implementation', + type: 'address' + } + ], + name: 'DefinedHook', + type: 'event' + }, + { + stateMutability: 'payable', + type: 'fallback' + }, + { + inputs: [ + { + internalType: 'bytes4', + name: '_signature', + type: 'bytes4' + }, + { + internalType: 'address', + name: '_implementation', + type: 'address' + } + ], + name: 'addHook', + outputs: [], + stateMutability: 'nonpayable', + type: 'function' + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address' + }, + { + internalType: 'address', + name: '', + type: 'address' + }, + { + internalType: 'uint256[]', + name: '', + type: 'uint256[]' + }, + { + internalType: 'uint256[]', + name: '', + type: 'uint256[]' + }, + { + internalType: 'bytes', + name: '', + type: 'bytes' + } + ], + name: 'onERC1155BatchReceived', + outputs: [ + { + internalType: 'bytes4', + name: '', + type: 'bytes4' + } + ], + stateMutability: 'nonpayable', + type: 'function' + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address' + }, + { + internalType: 'address', + name: '', + type: 'address' + }, + { + internalType: 'uint256', + name: '', + type: 'uint256' + }, + { + internalType: 'uint256', + name: '', + type: 'uint256' + }, + { + internalType: 'bytes', + name: '', + type: 'bytes' + } + ], + name: 'onERC1155Received', + outputs: [ + { + internalType: 'bytes4', + name: '', + type: 'bytes4' + } + ], + stateMutability: 'nonpayable', + type: 'function' + }, + { + inputs: [ + { + internalType: 'address', + name: '', + type: 'address' + }, + { + internalType: 'address', + name: '', + type: 'address' + }, + { + internalType: 'uint256', + name: '', + type: 'uint256' + }, + { + internalType: 'bytes', + name: '', + type: 'bytes' + } + ], + name: 'onERC721Received', + outputs: [ + { + internalType: 'bytes4', + name: '', + type: 'bytes4' + } + ], + stateMutability: 'nonpayable', + type: 'function' + }, + { + inputs: [ + { + internalType: 'bytes4', + name: '_signature', + type: 'bytes4' + } + ], + name: 'readHook', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address' + } + ], + stateMutability: 'view', + type: 'function' + }, + { + inputs: [ + { + internalType: 'bytes4', + name: '_signature', + type: 'bytes4' + } + ], + name: 'removeHook', + outputs: [], + stateMutability: 'nonpayable', + type: 'function' + }, + { + inputs: [ + { + internalType: 'bytes4', + name: '_interfaceID', + type: 'bytes4' + } + ], + name: 'supportsInterface', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool' + } + ], + stateMutability: 'pure', + type: 'function' + }, + { + stateMutability: 'payable', + type: 'receive' + } +] as const diff --git a/packages/abi/src/wallet/walletProxyHook.ts b/packages/abi/src/wallet/walletProxyHook.ts new file mode 100644 index 000000000..d977e1f0a --- /dev/null +++ b/packages/abi/src/wallet/walletProxyHook.ts @@ -0,0 +1,9 @@ +export const abi = [ + { + type: 'function', + name: 'PROXY_getImplementation', + inputs: [], + outputs: [{ name: '', type: 'address', internalType: 'address' }], + stateMutability: 'view' + } +] as const diff --git a/packages/account/CHANGELOG.md b/packages/account/CHANGELOG.md index ba7dbe324..b31435ab2 100644 --- a/packages/account/CHANGELOG.md +++ b/packages/account/CHANGELOG.md @@ -1,5 +1,37 @@ # @0xsequence/account +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/abi@2.2.6 + - @0xsequence/core@2.2.6 + - @0xsequence/migration@2.2.6 + - @0xsequence/network@2.2.6 + - @0xsequence/relayer@2.2.6 + - @0xsequence/sessions@2.2.6 + - @0xsequence/utils@2.2.6 + - @0xsequence/wallet@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/abi@2.2.5 + - @0xsequence/core@2.2.5 + - @0xsequence/migration@2.2.5 + - @0xsequence/network@2.2.5 + - @0xsequence/relayer@2.2.5 + - @0xsequence/sessions@2.2.5 + - @0xsequence/utils@2.2.5 + - @0xsequence/wallet@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/account/package.json b/packages/account/package.json index 2ed5806c9..28521ec8e 100644 --- a/packages/account/package.json +++ b/packages/account/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/account", - "version": "2.2.4", + "version": "2.2.6", "description": "tools for migrating sequence wallets to new versions", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/account", "source": "src/index.ts", diff --git a/packages/account/src/account.ts b/packages/account/src/account.ts index 8ca3fca73..0a486c473 100644 --- a/packages/account/src/account.ts +++ b/packages/account/src/account.ts @@ -402,13 +402,46 @@ export class Account { status: AccountStatus, chainId: ethers.BigNumberish ): Promise { + txs = Array.isArray(txs) ? txs : [txs] // if onchain wallet config is not up to date // then we should append an extra transaction that updates it // to the latest "lazy" state if (status.onChain.imageHash !== status.imageHash) { const wallet = this.walletForStatus(chainId, status) const updateConfig = await wallet.buildUpdateConfigurationTransaction(status.config) - return [Array.isArray(txs) ? txs : [txs], updateConfig.transactions].flat() + txs = [...txs, ...updateConfig.transactions] + } + + // On immutable chains, we add the WalletProxyHook + const { proxyImplementationHook } = this.contexts[status.config.version] + if (proxyImplementationHook && (chainId === ChainId.IMMUTABLE_ZKEVM || chainId === ChainId.IMMUTABLE_ZKEVM_TESTNET)) { + const provider = this.providerFor(chainId) + if (provider) { + const hook = new ethers.Contract(this.address, walletContracts.walletProxyHook.abi, provider) + let implementation + try { + implementation = await hook.PROXY_getImplementation() + } catch (e) { + // Handle below + console.log('Error getting implementation address', e) + } + if (!implementation || implementation === ethers.ZeroAddress) { + console.log('Adding wallet proxy hook') + const hooksInterface = new ethers.Interface(walletContracts.moduleHooks.abi) + const tx: commons.transaction.Transaction = { + to: this.address, + data: hooksInterface.encodeFunctionData(hooksInterface.getFunction('addHook')!, [ + '0x90611127', + proxyImplementationHook + ]), + gasLimit: 50000, // Expected ~28k gas. Buffer added + delegateCall: false, + revertOnError: false, + value: 0 + } + txs = [tx, ...txs] + } + } } return txs diff --git a/packages/api/CHANGELOG.md b/packages/api/CHANGELOG.md index 27c26041e..02debad96 100644 --- a/packages/api/CHANGELOG.md +++ b/packages/api/CHANGELOG.md @@ -1,5 +1,18 @@ # @0xsequence/api +## 2.2.6 + +### Patch Changes + +- Update relayer package + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook + ## 2.2.4 ### Patch Changes diff --git a/packages/api/package.json b/packages/api/package.json index a0a2b893d..ca3731728 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/api", - "version": "2.2.4", + "version": "2.2.6", "description": "api sub-package for Sequence", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/api", "source": "src/index.ts", diff --git a/packages/api/src/api.gen.ts b/packages/api/src/api.gen.ts index 7794b1dda..711f1f184 100644 --- a/packages/api/src/api.gen.ts +++ b/packages/api/src/api.gen.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -// sequence-api v0.4.0 470a0f88ea399c2a57ff8c22da54358c033ed5f0 +// sequence-api v0.4.0 24814ebb88457c0545aa80e8388cb0f08ec59bec // -- -// Code generated by webrpc-gen@v0.18.7 with typescript generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT. // // webrpc-gen -schema=api.ridl -target=typescript -client -out=./clients/api.gen.ts @@ -12,7 +12,7 @@ export const WebRPCVersion = 'v1' export const WebRPCSchemaVersion = 'v0.4.0' // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = '470a0f88ea399c2a57ff8c22da54358c033ed5f0' +export const WebRPCSchemaHash = '24814ebb88457c0545aa80e8388cb0f08ec59bec' // // Types @@ -78,6 +78,12 @@ export interface SequenceContext { utils: string } +export interface PublicKey { + id: string + x: string + y: string +} + export interface User { address: string username: string @@ -362,7 +368,7 @@ export interface SwapPrice { currencyAddress: string currencyBalance: string price: string - to: string + maxPrice: string transactionValue: string } @@ -432,6 +438,10 @@ export interface PaymentResponse { txData: string } +export interface AdoptedChildWallet { + address: string +} + export interface API { ping(headers?: object, signal?: AbortSignal): Promise version(headers?: object, signal?: AbortSignal): Promise @@ -445,6 +455,8 @@ export interface API { headers?: object, signal?: AbortSignal ): Promise + registerPublicKey(args: RegisterPublicKeyArgs, headers?: object, signal?: AbortSignal): Promise + getPublicKey(args: GetPublicKeyArgs, headers?: object, signal?: AbortSignal): Promise friendList(args: FriendListArgs, headers?: object, signal?: AbortSignal): Promise getFriendByAddress(args: GetFriendByAddressArgs, headers?: object, signal?: AbortSignal): Promise searchFriends(args: SearchFriendsArgs, headers?: object, signal?: AbortSignal): Promise @@ -539,6 +551,8 @@ export interface API { headers?: object, signal?: AbortSignal ): Promise + listAdoptedWallets(args: ListAdoptedWalletsArgs, 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 listCurrencyGroups(headers?: object, signal?: AbortSignal): Promise @@ -635,6 +649,20 @@ export interface SendPasswordlessLinkArgs { export interface SendPasswordlessLinkReturn { status: boolean } +export interface RegisterPublicKeyArgs { + publicKey: PublicKey +} + +export interface RegisterPublicKeyReturn { + status: boolean +} +export interface GetPublicKeyArgs { + id: string +} + +export interface GetPublicKeyReturn { + publicKey: PublicKey +} export interface FriendListArgs { nickname?: string page?: Page @@ -971,8 +999,6 @@ export interface RemoveLinkedWalletArgs { parentWalletMessage: string parentWalletSignature: string linkedWalletAddress: string - linkedWalletMessage: string - linkedWalletSignature: string signatureChainId: string } @@ -997,11 +1023,31 @@ export interface ValidateWaaSVerificationNonceArgs { export interface ValidateWaaSVerificationNonceReturn { walletAddress: string } +export interface ListAdoptedWalletsArgs { + page?: Page +} + +export interface ListAdoptedWalletsReturn { + page: Page + wallets: Array +} +export interface GetSwapPriceArgs { + buyCurrencyAddress: string + sellCurrencyAddress: string + buyAmount: string + chainId: number + slippagePercentage?: number +} + +export interface GetSwapPriceReturn { + swapPrice: SwapPrice +} export interface GetSwapPricesArgs { userAddress: string buyCurrencyAddress: string buyAmount: string chainId: number + slippagePercentage?: number } export interface GetSwapPricesReturn { @@ -1014,6 +1060,7 @@ export interface GetSwapQuoteArgs { buyAmount: string chainId: number includeApprove: boolean + slippagePercentage?: number } export interface GetSwapQuoteReturn { @@ -1086,7 +1133,7 @@ export class API implements API { protected path = '/rpc/API/' constructor(hostname: string, fetch: Fetch) { - this.hostname = hostname + this.hostname = hostname.replace(/\/*$/, '') this.fetch = (input: RequestInfo, init?: RequestInit) => fetch(input, init) } @@ -1224,6 +1271,36 @@ export class API implements API { ) } + registerPublicKey = (args: RegisterPublicKeyArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch(this.url('RegisterPublicKey'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + status: _data.status + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + getPublicKey = (args: GetPublicKeyArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch(this.url('GetPublicKey'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + publicKey: _data.publicKey + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + friendList = (args: FriendListArgs, headers?: object, signal?: AbortSignal): Promise => { return this.fetch(this.url('FriendList'), createHTTPRequest(args, headers, signal)).then( res => { @@ -1999,6 +2076,41 @@ export class API implements API { ) } + listAdoptedWallets = ( + args: ListAdoptedWalletsArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('ListAdoptedWallets'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + page: _data.page, + wallets: >_data.wallets + } + }) + }, + 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 => { + return buildResponse(res).then(_data => { + return { + swapPrice: _data.swapPrice + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + getSwapPrices = (args: GetSwapPricesArgs, headers?: object, signal?: AbortSignal): Promise => { return this.fetch(this.url('GetSwapPrices'), createHTTPRequest(args, headers, signal)).then( res => { diff --git a/packages/auth/CHANGELOG.md b/packages/auth/CHANGELOG.md index 25aaf916d..57cc503cf 100644 --- a/packages/auth/CHANGELOG.md +++ b/packages/auth/CHANGELOG.md @@ -1,5 +1,45 @@ # @0xsequence/auth +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/abi@2.2.6 + - @0xsequence/account@2.2.6 + - @0xsequence/api@2.2.6 + - @0xsequence/core@2.2.6 + - @0xsequence/indexer@2.2.6 + - @0xsequence/metadata@2.2.6 + - @0xsequence/migration@2.2.6 + - @0xsequence/network@2.2.6 + - @0xsequence/sessions@2.2.6 + - @0xsequence/signhub@2.2.6 + - @0xsequence/utils@2.2.6 + - @0xsequence/wallet@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/abi@2.2.5 + - @0xsequence/account@2.2.5 + - @0xsequence/api@2.2.5 + - @0xsequence/core@2.2.5 + - @0xsequence/indexer@2.2.5 + - @0xsequence/metadata@2.2.5 + - @0xsequence/migration@2.2.5 + - @0xsequence/network@2.2.5 + - @0xsequence/sessions@2.2.5 + - @0xsequence/signhub@2.2.5 + - @0xsequence/utils@2.2.5 + - @0xsequence/wallet@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/auth/package.json b/packages/auth/package.json index d052ed0e3..001da2ac5 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/auth", - "version": "2.2.4", + "version": "2.2.6", "description": "auth sub-package for Sequence", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/auth", "source": "src/index.ts", diff --git a/packages/auth/src/services.ts b/packages/auth/src/services.ts index 20967fb5d..fdc4bc9c9 100644 --- a/packages/auth/src/services.ts +++ b/packages/auth/src/services.ts @@ -271,7 +271,7 @@ export class Services { async getIndexerGateway(tryAuth: boolean = true): Promise { if (!this.indexerGateway) { const jwtAuth = (await this.getJWT(tryAuth)).token - this.indexerGateway = new SequenceIndexerGateway(this.settings.sequenceMetadataUrl, undefined, jwtAuth) + this.indexerGateway = new SequenceIndexerGateway(this.settings.sequenceIndexerGatewayUrl, undefined, jwtAuth) } return this.indexerGateway diff --git a/packages/builder/CHANGELOG.md b/packages/builder/CHANGELOG.md index 5136f5e70..3b18e6771 100644 --- a/packages/builder/CHANGELOG.md +++ b/packages/builder/CHANGELOG.md @@ -1,5 +1,18 @@ # @0xsequence/builder +## 2.2.6 + +### Patch Changes + +- Update relayer package + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook + ## 2.2.4 ### Patch Changes diff --git a/packages/builder/package.json b/packages/builder/package.json index 695784f16..5fdfa9c29 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/builder", - "version": "2.2.4", + "version": "2.2.6", "description": "builder sub-package for Sequence", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/builder", "source": "src/index.ts", diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index e75e8e2a2..872a2bb9c 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,25 @@ # @0xsequence/core +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/abi@2.2.6 + - @0xsequence/utils@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/abi@2.2.5 + - @0xsequence/utils@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/core/package.json b/packages/core/package.json index 938135f3d..5430dfae8 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/core", - "version": "2.2.4", + "version": "2.2.6", "description": "core primitives for interacting with the sequence wallet contracts", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/core", "source": "src/index.ts", diff --git a/packages/core/src/commons/context.ts b/packages/core/src/commons/context.ts index 7794efae9..72feabc0a 100644 --- a/packages/core/src/commons/context.ts +++ b/packages/core/src/commons/context.ts @@ -12,6 +12,8 @@ export type WalletContext = { guestModule: string walletCreationCode: string + + proxyImplementationHook?: string } export function addressOf(context: WalletContext, imageHash: ethers.BytesLike) { diff --git a/packages/core/src/v2/index.ts b/packages/core/src/v2/index.ts index f921265a4..d3b534bd6 100644 --- a/packages/core/src/v2/index.ts +++ b/packages/core/src/v2/index.ts @@ -21,5 +21,6 @@ export const DeployedWalletContext: WalletContext = { guestModule: '0xfea230Ee243f88BC698dD8f1aE93F8301B6cdfaE', mainModule: '0xfBf8f1A5E00034762D928f46d438B947f5d4065d', mainModuleUpgradable: '0x4222dcA3974E39A8b41c411FeDDE9b09Ae14b911', - walletCreationCode: '0x603a600e3d39601a805130553df3363d3d373d3d3d363d30545af43d82803e903d91601857fd5bf3' + walletCreationCode: '0x603a600e3d39601a805130553df3363d3d373d3d3d363d30545af43d82803e903d91601857fd5bf3', + proxyImplementationHook: '0x1f56dbAD5e8319F0DE9a323E24A31b5077dEB1a4' } diff --git a/packages/core/src/version.ts b/packages/core/src/version.ts index 9f9d1a94e..747940916 100644 --- a/packages/core/src/version.ts +++ b/packages/core/src/version.ts @@ -1 +1 @@ -export const VERSION = '2.2.4' +export const VERSION = '2.2.6' diff --git a/packages/deployer/CHANGELOG.md b/packages/deployer/CHANGELOG.md index 2ddde6b00..076944a68 100644 --- a/packages/deployer/CHANGELOG.md +++ b/packages/deployer/CHANGELOG.md @@ -1,5 +1,23 @@ # @0xsequence/deployer +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/utils@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/utils@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/deployer/package.json b/packages/deployer/package.json index e4a968a4f..bc1eb7b17 100644 --- a/packages/deployer/package.json +++ b/packages/deployer/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/deployer", - "version": "2.2.4", + "version": "2.2.6", "description": "deployer sub-package for Sequence", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/deployer", "source": "src/index.ts", diff --git a/packages/guard/CHANGELOG.md b/packages/guard/CHANGELOG.md index 0247be081..0a4ec8e8b 100644 --- a/packages/guard/CHANGELOG.md +++ b/packages/guard/CHANGELOG.md @@ -1,5 +1,29 @@ # @0xsequence/guard +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/account@2.2.6 + - @0xsequence/core@2.2.6 + - @0xsequence/signhub@2.2.6 + - @0xsequence/utils@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/account@2.2.5 + - @0xsequence/core@2.2.5 + - @0xsequence/signhub@2.2.5 + - @0xsequence/utils@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/guard/package.json b/packages/guard/package.json index d13c152b4..009881420 100644 --- a/packages/guard/package.json +++ b/packages/guard/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/guard", - "version": "2.2.4", + "version": "2.2.6", "description": "guard sub-package for Sequence", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/guard", "source": "src/index.ts", diff --git a/packages/guard/src/guard.gen.ts b/packages/guard/src/guard.gen.ts index 519740c29..5a9a6add2 100644 --- a/packages/guard/src/guard.gen.ts +++ b/packages/guard/src/guard.gen.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -// sequence-guard v0.4.0 5b203e30a5c79b2b9a37483ce17500a51b94ebe1 +// sequence-guard v0.4.0 d6b4a3c89539b494875af543fff459df65bb7b9e // -- -// Code generated by webrpc-gen@v0.18.6 with typescript generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT. // // webrpc-gen -schema=guard.ridl -target=typescript -client -out=./clients/guard.gen.ts @@ -12,7 +12,7 @@ export const WebRPCVersion = 'v1' export const WebRPCSchemaVersion = 'v0.4.0' // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = '5b203e30a5c79b2b9a37483ce17500a51b94ebe1' +export const WebRPCSchemaHash = 'd6b4a3c89539b494875af543fff459df65bb7b9e' // // Types @@ -208,7 +208,7 @@ export class Guard implements Guard { protected path = '/rpc/Guard/' constructor(hostname: string, fetch: Fetch) { - this.hostname = hostname + this.hostname = hostname.replace(/\/*$/, '') this.fetch = (input: RequestInfo, init?: RequestInit) => fetch(input, init) } @@ -676,6 +676,19 @@ export class UnauthorizedError extends WebrpcError { } } +export class PermissionDeniedError extends WebrpcError { + constructor( + name: string = 'PermissionDenied', + code: number = 1001, + message: string = 'Permission denied', + status: number = 0, + cause?: string + ) { + super(name, code, message, status, cause) + Object.setPrototypeOf(this, PermissionDeniedError.prototype) + } +} + export class SessionExpiredError extends WebrpcError { constructor( name: string = 'SessionExpired', @@ -689,6 +702,32 @@ export class SessionExpiredError extends WebrpcError { } } +export class MethodNotFoundError extends WebrpcError { + constructor( + name: string = 'MethodNotFound', + code: number = 1003, + message: string = 'Method not found', + status: number = 0, + cause?: string + ) { + super(name, code, message, status, cause) + Object.setPrototypeOf(this, MethodNotFoundError.prototype) + } +} + +export class RequestConflictError extends WebrpcError { + constructor( + name: string = 'RequestConflict', + code: number = 1004, + message: string = 'Conflict with target resource', + status: number = 0, + cause?: string + ) { + super(name, code, message, status, cause) + Object.setPrototypeOf(this, RequestConflictError.prototype) + } +} + export class AbortedError extends WebrpcError { constructor( name: string = 'Aborted', @@ -702,6 +741,32 @@ export class AbortedError extends WebrpcError { } } +export class GeoblockedError extends WebrpcError { + constructor( + name: string = 'Geoblocked', + code: number = 1006, + message: string = 'Geoblocked region', + status: number = 0, + cause?: string + ) { + super(name, code, message, status, cause) + Object.setPrototypeOf(this, GeoblockedError.prototype) + } +} + +export class RateLimitedError extends WebrpcError { + constructor( + name: string = 'RateLimited', + code: number = 1007, + message: string = 'Rate-limited. Please slow down.', + status: number = 0, + cause?: string + ) { + super(name, code, message, status, cause) + Object.setPrototypeOf(this, RateLimitedError.prototype) + } +} + export class InvalidArgumentError extends WebrpcError { constructor( name: string = 'InvalidArgument', @@ -780,8 +845,13 @@ export enum errors { WebrpcStreamLost = 'WebrpcStreamLost', WebrpcStreamFinished = 'WebrpcStreamFinished', Unauthorized = 'Unauthorized', + PermissionDenied = 'PermissionDenied', SessionExpired = 'SessionExpired', + MethodNotFound = 'MethodNotFound', + RequestConflict = 'RequestConflict', Aborted = 'Aborted', + Geoblocked = 'Geoblocked', + RateLimited = 'RateLimited', InvalidArgument = 'InvalidArgument', Unavailable = 'Unavailable', QueryFailed = 'QueryFailed', @@ -802,8 +872,13 @@ const webrpcErrorByCode: { [code: number]: any } = { [-9]: WebrpcStreamLostError, [-10]: WebrpcStreamFinishedError, [1000]: UnauthorizedError, + [1001]: PermissionDeniedError, [1002]: SessionExpiredError, + [1003]: MethodNotFoundError, + [1004]: RequestConflictError, [1005]: AbortedError, + [1006]: GeoblockedError, + [1007]: RateLimitedError, [2001]: InvalidArgumentError, [2002]: UnavailableError, [2003]: QueryFailedError, diff --git a/packages/indexer/CHANGELOG.md b/packages/indexer/CHANGELOG.md index 674ab4d17..c2de6d65f 100644 --- a/packages/indexer/CHANGELOG.md +++ b/packages/indexer/CHANGELOG.md @@ -1,5 +1,18 @@ # @0xsequence/indexer +## 2.2.6 + +### Patch Changes + +- Update relayer package + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook + ## 2.2.4 ### Patch Changes diff --git a/packages/indexer/package.json b/packages/indexer/package.json index 7b85df32c..0dc0dc385 100644 --- a/packages/indexer/package.json +++ b/packages/indexer/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/indexer", - "version": "2.2.4", + "version": "2.2.6", "description": "indexer sub-package for Sequence", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/indexer", "source": "src/index.ts", diff --git a/packages/marketplace/CHANGELOG.md b/packages/marketplace/CHANGELOG.md index dd3a0b33d..854301f0d 100644 --- a/packages/marketplace/CHANGELOG.md +++ b/packages/marketplace/CHANGELOG.md @@ -1,5 +1,18 @@ # @0xsequence/marketplace +## 2.2.6 + +### Patch Changes + +- Update relayer package + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook + ## 2.2.4 ### Patch Changes diff --git a/packages/marketplace/package.json b/packages/marketplace/package.json index 3ab22f6dd..0911d8e60 100644 --- a/packages/marketplace/package.json +++ b/packages/marketplace/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/marketplace", - "version": "2.2.4", + "version": "2.2.6", "description": "marketplace sub-package for Sequence", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/marketplace", "source": "src/index.ts", diff --git a/packages/metadata/CHANGELOG.md b/packages/metadata/CHANGELOG.md index 541b5c61f..30bbccb40 100644 --- a/packages/metadata/CHANGELOG.md +++ b/packages/metadata/CHANGELOG.md @@ -1,5 +1,18 @@ # @0xsequence/metadata +## 2.2.6 + +### Patch Changes + +- Update relayer package + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook + ## 2.2.4 ### Patch Changes diff --git a/packages/metadata/package.json b/packages/metadata/package.json index a56162cf9..0564b9d8c 100644 --- a/packages/metadata/package.json +++ b/packages/metadata/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/metadata", - "version": "2.2.4", + "version": "2.2.6", "description": "metadata sub-package for Sequence", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/metadata", "source": "src/index.ts", diff --git a/packages/migration/CHANGELOG.md b/packages/migration/CHANGELOG.md index 8fd8a8560..81a86558b 100644 --- a/packages/migration/CHANGELOG.md +++ b/packages/migration/CHANGELOG.md @@ -1,5 +1,27 @@ # @0xsequence/migration +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/abi@2.2.6 + - @0xsequence/core@2.2.6 + - @0xsequence/wallet@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/abi@2.2.5 + - @0xsequence/core@2.2.5 + - @0xsequence/wallet@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/migration/package.json b/packages/migration/package.json index dbddc101c..9bdbeb8e9 100644 --- a/packages/migration/package.json +++ b/packages/migration/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/migration", - "version": "2.2.4", + "version": "2.2.6", "description": "tools for migrating sequence wallets to new versions", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/migration", "source": "src/index.ts", diff --git a/packages/network/CHANGELOG.md b/packages/network/CHANGELOG.md index 5f21a2f7b..a96ca3674 100644 --- a/packages/network/CHANGELOG.md +++ b/packages/network/CHANGELOG.md @@ -1,5 +1,29 @@ # @0xsequence/network +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/core@2.2.6 + - @0xsequence/indexer@2.2.6 + - @0xsequence/relayer@2.2.6 + - @0xsequence/utils@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/core@2.2.5 + - @0xsequence/indexer@2.2.5 + - @0xsequence/relayer@2.2.5 + - @0xsequence/utils@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/network/package.json b/packages/network/package.json index cb72c6a66..45540e410 100644 --- a/packages/network/package.json +++ b/packages/network/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/network", - "version": "2.2.4", + "version": "2.2.6", "description": "network sub-package for Sequence", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/network", "source": "src/index.ts", diff --git a/packages/network/src/constants.ts b/packages/network/src/constants.ts index c2a7aaef6..4b03dc4cb 100644 --- a/packages/network/src/constants.ts +++ b/packages/network/src/constants.ts @@ -852,7 +852,7 @@ export const networks: Record = { testnet: false, blockExplorer: { name: 'Soneium Explorer', - rootUrl: 'https://xckc3jvrzboyo8w4.blockscout.com/' + rootUrl: 'https://soneium.blockscout.com/' }, nativeToken: { symbol: 'ETH', diff --git a/packages/provider/CHANGELOG.md b/packages/provider/CHANGELOG.md index 213f9ce69..14e0ff4fd 100644 --- a/packages/provider/CHANGELOG.md +++ b/packages/provider/CHANGELOG.md @@ -1,5 +1,39 @@ # @0xsequence/provider +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/abi@2.2.6 + - @0xsequence/account@2.2.6 + - @0xsequence/auth@2.2.6 + - @0xsequence/core@2.2.6 + - @0xsequence/migration@2.2.6 + - @0xsequence/network@2.2.6 + - @0xsequence/relayer@2.2.6 + - @0xsequence/utils@2.2.6 + - @0xsequence/wallet@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/abi@2.2.5 + - @0xsequence/account@2.2.5 + - @0xsequence/auth@2.2.5 + - @0xsequence/core@2.2.5 + - @0xsequence/migration@2.2.5 + - @0xsequence/network@2.2.5 + - @0xsequence/relayer@2.2.5 + - @0xsequence/utils@2.2.5 + - @0xsequence/wallet@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/provider/package.json b/packages/provider/package.json index 4345780f6..8c0471219 100644 --- a/packages/provider/package.json +++ b/packages/provider/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/provider", - "version": "2.2.4", + "version": "2.2.6", "description": "provider sub-package for Sequence", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/provider", "source": "src/index.ts", diff --git a/packages/react-native/CHANGELOG.md b/packages/react-native/CHANGELOG.md index a6768fd2f..f515e545e 100644 --- a/packages/react-native/CHANGELOG.md +++ b/packages/react-native/CHANGELOG.md @@ -1,5 +1,23 @@ # @0xsequence/react-native +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/waas@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/waas@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/react-native/package.json b/packages/react-native/package.json index 577a80103..938e8ee48 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/react-native", - "version": "2.2.4", + "version": "2.2.6", "description": "react-native compat-lib sub-package for Sequence", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/react-native", "source": "src/index.ts", diff --git a/packages/relayer/CHANGELOG.md b/packages/relayer/CHANGELOG.md index 03a87d53a..a9c1a2e85 100644 --- a/packages/relayer/CHANGELOG.md +++ b/packages/relayer/CHANGELOG.md @@ -1,5 +1,27 @@ # @0xsequence/relayer +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/abi@2.2.6 + - @0xsequence/core@2.2.6 + - @0xsequence/utils@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/abi@2.2.5 + - @0xsequence/core@2.2.5 + - @0xsequence/utils@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/relayer/package.json b/packages/relayer/package.json index e2ee490f8..2e36b864f 100644 --- a/packages/relayer/package.json +++ b/packages/relayer/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/relayer", - "version": "2.2.4", + "version": "2.2.6", "description": "relayer sub-package for Sequence", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/relayer", "source": "src/index.ts", diff --git a/packages/relayer/src/index.ts b/packages/relayer/src/index.ts index 95a8eb287..48c29b8ec 100644 --- a/packages/relayer/src/index.ts +++ b/packages/relayer/src/index.ts @@ -54,6 +54,17 @@ export interface Relayer { delay?: number, maxFails?: number ): Promise + + // getMetaTransactions returns a list of meta transactions for a given project and gas tank + getMetaTransactions(projectId: number, page?: proto.Page): Promise<{ + page: proto.Page, + transactions: proto.MetaTxnLog[] + }> + + // getTransactionCost returns the used fee cost for gas tank during a given period + getTransactionCost(projectId: number, from: string, to: string): Promise<{ + cost: number + }> } export * from './local-relayer' diff --git a/packages/relayer/src/local-relayer.ts b/packages/relayer/src/local-relayer.ts index c0aacf899..9cf3a0acd 100644 --- a/packages/relayer/src/local-relayer.ts +++ b/packages/relayer/src/local-relayer.ts @@ -1,6 +1,6 @@ import { ethers } from 'ethers' import { logger } from '@0xsequence/utils' -import { FeeOption, FeeQuote, Relayer } from '.' +import { FeeOption, FeeQuote, proto, Relayer } from '.' import { ProviderRelayer, ProviderRelayerOptions } from './provider-relayer' import { commons } from '@0xsequence/core' @@ -76,6 +76,19 @@ export class LocalRelayer extends ProviderRelayer implements Relayer { return responsePromise } } + + async getMetaTransactions(projectId: number, page?: proto.Page): Promise<{ + page: proto.Page, + transactions: proto.MetaTxnLog[] + }> { + return { page: { page: 0, pageSize: 100 }, transactions: [] } + } + + async getTransactionCost(projectId: number, from: string, to: string): Promise<{ + cost: number + }> { + return { cost: 0 } + } } function isAbstractSigner(signer: any): signer is ethers.AbstractSigner { diff --git a/packages/relayer/src/provider-relayer.ts b/packages/relayer/src/provider-relayer.ts index 86652efe1..17800a921 100644 --- a/packages/relayer/src/provider-relayer.ts +++ b/packages/relayer/src/provider-relayer.ts @@ -1,6 +1,6 @@ import { ethers } from 'ethers' import { walletContracts } from '@0xsequence/abi' -import { FeeOption, FeeQuote, Relayer, SimulateResult } from '.' +import { FeeOption, FeeQuote, proto, Relayer, SimulateResult } from '.' import { logger, Optionals } from '@0xsequence/utils' import { commons } from '@0xsequence/core' @@ -59,6 +59,15 @@ export abstract class ProviderRelayer implements Relayer { waitForReceipt?: boolean ): Promise + abstract getTransactionCost(projectId: number, from: string, to: string): Promise<{ + cost: number + }> + + abstract getMetaTransactions(projectId: number, page?: proto.Page): Promise<{ + page: proto.Page, + transactions: proto.MetaTxnLog[] + }> + async simulate(wallet: string, ...transactions: commons.transaction.Transaction[]): Promise { return ( await Promise.all( @@ -248,6 +257,8 @@ export abstract class ProviderRelayer implements Relayer { return waitReceipt() } } + + } function isAbstractProvider(provider: any): provider is ethers.AbstractProvider { diff --git a/packages/relayer/src/rpc-relayer/index.ts b/packages/relayer/src/rpc-relayer/index.ts index 5b04a6893..bde372eb1 100644 --- a/packages/relayer/src/rpc-relayer/index.ts +++ b/packages/relayer/src/rpc-relayer/index.ts @@ -304,6 +304,19 @@ export class RpcRelayer implements Relayer { wait: async (confirmations?: number) => this.provider!.waitForTransaction(txReceipt.transactionHash, confirmations) } as commons.transaction.TransactionResponse } + + async getMetaTransactions(projectId: number, page?: proto.Page): Promise<{ + page: proto.Page, + transactions: proto.MetaTxnLog[] + }> { + return this.service.getMetaTransactions({ projectId, page }) + } + + async getTransactionCost(projectId: number, from: string, to: string): Promise<{ + cost: number + }> { + return this.service.getTransactionCost({ projectId, from, to }) + } } class MetaTransactionResponseException { diff --git a/packages/relayer/src/rpc-relayer/relayer.gen.ts b/packages/relayer/src/rpc-relayer/relayer.gen.ts index 91ce2e9b0..27714d417 100644 --- a/packages/relayer/src/rpc-relayer/relayer.gen.ts +++ b/packages/relayer/src/rpc-relayer/relayer.gen.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -// sequence-relayer v0.4.1 1e27d0fd295aa5897878939595ef0c6adc54b1a3 +// sequence-relayer v0.4.1 dd95e21fa884c6564199bc3dd5f588534827ffe2 // -- -// Code generated by webrpc-gen@v0.18.6 with typescript generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT. // // webrpc-gen -schema=relayer.ridl -target=typescript -client -out=./clients/relayer.gen.ts @@ -12,7 +12,7 @@ export const WebRPCVersion = 'v1' export const WebRPCSchemaVersion = 'v0.4.1' // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = '1e27d0fd295aa5897878939595ef0c6adc54b1a3' +export const WebRPCSchemaHash = 'dd95e21fa884c6564199bc3dd5f588534827ffe2' // // Types @@ -62,10 +62,10 @@ export interface RuntimeStatus { ver: string branch: string commitHash: string + chainID: number useEIP1559: boolean senders: Array checks: RuntimeChecks - numTxnsRelayed: NumTxnsRelayed } export interface SenderStatus { @@ -77,12 +77,6 @@ export interface SenderStatus { export interface RuntimeChecks {} -export interface NumTxnsRelayed { - prev: number - current: number - period: number -} - export interface SequenceContext { factory: string mainModule: string @@ -93,6 +87,7 @@ export interface SequenceContext { export interface GasTank { id: number + chainId: number name: string currentBalance: number unlimited: boolean @@ -114,6 +109,7 @@ export interface GasSponsor { id: number gasTankId: number projectId: number + chainId: number address: string name: string active: boolean @@ -142,6 +138,7 @@ export interface MetaTxn { export interface MetaTxnLog { id: number + chainId: number projectId: number txnHash: string txnNonce: string @@ -172,17 +169,6 @@ export interface MetaTxnLog { createdAt: string } -export interface MetaTxnEntry { - id: number - metaTxnID: string - txnStatus: ETHTxnStatus - txnRevertReason: string - index: number - logs?: Array - updatedAt: string - createdAt: string -} - export interface MetaTxnReceipt { id: string status: string @@ -293,6 +279,7 @@ export interface Relayer { signal?: AbortSignal ): Promise getMetaTransactions(args: GetMetaTransactionsArgs, headers?: object, signal?: AbortSignal): Promise + getTransactionCost(args: GetTransactionCostArgs, headers?: object, signal?: AbortSignal): Promise sentTransactions(args: SentTransactionsArgs, headers?: object, signal?: AbortSignal): Promise pendingTransactions(args: PendingTransactionsArgs, headers?: object, signal?: AbortSignal): Promise getGasTank(args: GetGasTankArgs, headers?: object, signal?: AbortSignal): Promise @@ -329,6 +316,12 @@ export interface Relayer { headers?: object, signal?: AbortSignal ): Promise + getProjectBalance(args: GetProjectBalanceArgs, headers?: object, signal?: AbortSignal): Promise + adjustProjectBalance( + args: AdjustProjectBalanceArgs, + headers?: object, + signal?: AbortSignal + ): Promise } export interface PingArgs {} @@ -359,6 +352,7 @@ export interface GetChainIDReturn { export interface SendMetaTxnArgs { call: MetaTxn quote?: string + projectID?: number } export interface SendMetaTxnReturn { @@ -425,7 +419,6 @@ export interface GetMetaTxnNetworkFeeOptionsReturn { } export interface GetMetaTransactionsArgs { projectId: number - gasTankId: number page?: Page } @@ -433,6 +426,15 @@ export interface GetMetaTransactionsReturn { page: Page transactions: Array } +export interface GetTransactionCostArgs { + projectId: number + from: string + to: string +} + +export interface GetTransactionCostReturn { + cost: number +} export interface SentTransactionsArgs { filter?: SentTransactionsFilter page?: Page @@ -577,6 +579,22 @@ export interface ListGasTankBalanceAdjustmentsReturn { page: Page adjustments: Array } +export interface GetProjectBalanceArgs { + projectId: number +} + +export interface GetProjectBalanceReturn { + balance: number +} +export interface AdjustProjectBalanceArgs { + projectId: number + amount: number + identifier: string +} + +export interface AdjustProjectBalanceReturn { + balance: number +} // // Client @@ -587,7 +605,7 @@ export class Relayer implements Relayer { protected path = '/rpc/Relayer/' constructor(hostname: string, fetch: Fetch) { - this.hostname = hostname + this.hostname = hostname.replace(/\/*$/, '') this.fetch = (input: RequestInfo, init?: RequestInit) => fetch(input, init) } @@ -822,6 +840,25 @@ export class Relayer implements Relayer { ) } + getTransactionCost = ( + args: GetTransactionCostArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('GetTransactionCost'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + cost: _data.cost + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + sentTransactions = (args: SentTransactionsArgs, headers?: object, signal?: AbortSignal): Promise => { return this.fetch(this.url('SentTransactions'), createHTTPRequest(args, headers, signal)).then( res => { @@ -1099,6 +1136,40 @@ export class Relayer implements Relayer { } ) } + + getProjectBalance = (args: GetProjectBalanceArgs, headers?: object, signal?: AbortSignal): Promise => { + return this.fetch(this.url('GetProjectBalance'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + balance: _data.balance + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + adjustProjectBalance = ( + args: AdjustProjectBalanceArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('AdjustProjectBalance'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + balance: _data.balance + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } } const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => { @@ -1349,6 +1420,19 @@ export class MethodNotFoundError extends WebrpcError { } } +export class RequestConflictError extends WebrpcError { + constructor( + name: string = 'RequestConflict', + code: number = 1004, + message: string = 'Conflict with target resource', + status: number = 0, + cause?: string + ) { + super(name, code, message, status, cause) + Object.setPrototypeOf(this, RequestConflictError.prototype) + } +} + export class AbortedError extends WebrpcError { constructor( name: string = 'Aborted', @@ -1362,6 +1446,19 @@ export class AbortedError extends WebrpcError { } } +export class GeoblockedError extends WebrpcError { + constructor( + name: string = 'Geoblocked', + code: number = 1006, + message: string = 'Geoblocked region', + status: number = 0, + cause?: string + ) { + super(name, code, message, status, cause) + Object.setPrototypeOf(this, GeoblockedError.prototype) + } +} + export class InvalidArgumentError extends WebrpcError { constructor( name: string = 'InvalidArgument', @@ -1414,6 +1511,19 @@ export class NotFoundError extends WebrpcError { } } +export class InsufficientFeeError extends WebrpcError { + constructor( + name: string = 'InsufficientFee', + code: number = 3004, + message: string = 'Insufficient fee', + status: number = 0, + cause?: string + ) { + super(name, code, message, status, cause) + Object.setPrototypeOf(this, InsufficientFeeError.prototype) + } +} + export enum errors { WebrpcEndpoint = 'WebrpcEndpoint', WebrpcRequestFailed = 'WebrpcRequestFailed', @@ -1429,11 +1539,14 @@ export enum errors { Unauthorized = 'Unauthorized', PermissionDenied = 'PermissionDenied', MethodNotFound = 'MethodNotFound', + RequestConflict = 'RequestConflict', Aborted = 'Aborted', + Geoblocked = 'Geoblocked', InvalidArgument = 'InvalidArgument', Unavailable = 'Unavailable', QueryFailed = 'QueryFailed', - NotFound = 'NotFound' + NotFound = 'NotFound', + InsufficientFee = 'InsufficientFee' } const webrpcErrorByCode: { [code: number]: any } = { @@ -1451,11 +1564,14 @@ const webrpcErrorByCode: { [code: number]: any } = { [1000]: UnauthorizedError, [1001]: PermissionDeniedError, [1003]: MethodNotFoundError, + [1004]: RequestConflictError, [1005]: AbortedError, + [1006]: GeoblockedError, [2001]: InvalidArgumentError, [2002]: UnavailableError, [2003]: QueryFailedError, - [3000]: NotFoundError + [3000]: NotFoundError, + [3004]: InsufficientFeeError } export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise diff --git a/packages/replacer/CHANGELOG.md b/packages/replacer/CHANGELOG.md index 56a7e45af..65106e094 100644 --- a/packages/replacer/CHANGELOG.md +++ b/packages/replacer/CHANGELOG.md @@ -1,5 +1,25 @@ # @0xsequence/replacer +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/abi@2.2.6 + - @0xsequence/core@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/abi@2.2.5 + - @0xsequence/core@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/replacer/package.json b/packages/replacer/package.json index af2914093..40b7cb454 100644 --- a/packages/replacer/package.json +++ b/packages/replacer/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/replacer", - "version": "2.2.4", + "version": "2.2.6", "description": "EIP-5719 client implementation", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/replacer", "source": "src/index.ts", diff --git a/packages/sessions/CHANGELOG.md b/packages/sessions/CHANGELOG.md index f32487486..b214d6459 100644 --- a/packages/sessions/CHANGELOG.md +++ b/packages/sessions/CHANGELOG.md @@ -1,5 +1,29 @@ # @0xsequence/sessions +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/core@2.2.6 + - @0xsequence/migration@2.2.6 + - @0xsequence/replacer@2.2.6 + - @0xsequence/utils@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/core@2.2.5 + - @0xsequence/migration@2.2.5 + - @0xsequence/replacer@2.2.5 + - @0xsequence/utils@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/sessions/package.json b/packages/sessions/package.json index 1c36155b9..232f3bcfe 100644 --- a/packages/sessions/package.json +++ b/packages/sessions/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/sessions", - "version": "2.2.4", + "version": "2.2.6", "description": "tools for migrating sequence wallets to new versions", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/sessions", "source": "src/index.ts", diff --git a/packages/sessions/src/trackers/remote/sessions.gen.ts b/packages/sessions/src/trackers/remote/sessions.gen.ts index c230dcc68..3322c1e90 100644 --- a/packages/sessions/src/trackers/remote/sessions.gen.ts +++ b/packages/sessions/src/trackers/remote/sessions.gen.ts @@ -1,10 +1,14 @@ /* eslint-disable */ -// sessions v0.0.1 67f782e8acfe452f905078a7423ed5d27c6639a8 +// sessions v0.0.1 48681273e3b0249c5feb593b9af1b59dc6a14869 // -- -// Code generated by webrpc-gen@v0.20.3 with typescript generator. DO NOT EDIT. +// Code generated by webrpc-gen@v0.22.1 with typescript generator. DO NOT EDIT. // // webrpc-gen -schema=sessions.ridl -target=typescript -client -out=./clients/sessions.gen.ts +export const WebrpcHeader = 'Webrpc' + +export const WebrpcHeaderValue = 'webrpc@v0.22.1;gen-typescript@v0.16.2;sessions@v0.0.1' + // WebRPC description and code-gen version export const WebRPCVersion = 'v1' @@ -12,7 +16,55 @@ export const WebRPCVersion = 'v1' export const WebRPCSchemaVersion = 'v0.0.1' // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = '67f782e8acfe452f905078a7423ed5d27c6639a8' +export const WebRPCSchemaHash = '48681273e3b0249c5feb593b9af1b59dc6a14869' + +type WebrpcGenVersions = { + webrpcGenVersion: string + codeGenName: string + codeGenVersion: string + schemaName: string + schemaVersion: string +} + +export function VersionFromHeader(headers: Headers): WebrpcGenVersions { + const headerValue = headers.get(WebrpcHeader) + if (!headerValue) { + return { + webrpcGenVersion: '', + codeGenName: '', + codeGenVersion: '', + schemaName: '', + schemaVersion: '' + } + } + + return parseWebrpcGenVersions(headerValue) +} + +function parseWebrpcGenVersions(header: string): WebrpcGenVersions { + const versions = header.split(';') + if (versions.length < 3) { + return { + webrpcGenVersion: '', + codeGenName: '', + codeGenVersion: '', + schemaName: '', + schemaVersion: '' + } + } + + const [_, webrpcGenVersion] = versions[0].split('@') + const [codeGenName, codeGenVersion] = versions[1].split('@') + const [schemaName, schemaVersion] = versions[2].split('@') + + return { + webrpcGenVersion, + codeGenName, + codeGenVersion, + schemaName, + schemaVersion + } +} // // Types @@ -127,9 +179,9 @@ export interface Signature { } export interface SignerSignature { - referenceChainID?: string signer?: string signature: string + referenceChainID?: string } export interface ConfigUpdate { @@ -474,9 +526,12 @@ export class Sessions implements Sessions { } const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => { + const reqHeaders: { [key: string]: string } = { ...headers, 'Content-Type': 'application/json' } + reqHeaders[WebrpcHeader] = WebrpcHeaderValue + return { method: 'POST', - headers: { ...headers, 'Content-Type': 'application/json' }, + headers: reqHeaders, body: JSON.stringify(body || {}), signal } @@ -541,7 +596,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 ) { @@ -554,7 +609,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 ) { @@ -567,7 +622,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 ) { @@ -580,7 +635,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 ) { @@ -593,7 +648,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 ) { @@ -606,7 +661,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 ) { @@ -619,7 +674,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 ) { @@ -632,7 +687,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 ) { @@ -645,7 +700,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 ) { @@ -658,7 +713,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 ) { @@ -671,7 +726,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 ) { @@ -686,7 +741,7 @@ export class InvalidArgumentError extends WebrpcError { constructor( name: string = 'InvalidArgument', code: number = 1, - message: string = 'invalid argument', + message: string = `invalid argument`, status: number = 0, cause?: string ) { @@ -696,7 +751,7 @@ export class InvalidArgumentError extends WebrpcError { } export class NotFoundError extends WebrpcError { - constructor(name: string = 'NotFound', code: number = 2, message: string = 'not found', status: number = 0, cause?: string) { + constructor(name: string = 'NotFound', code: number = 2, message: string = `not found`, status: number = 0, cause?: string) { super(name, code, message, status, cause) Object.setPrototypeOf(this, NotFoundError.prototype) } @@ -718,7 +773,23 @@ export enum errors { NotFound = 'NotFound' } -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, + InvalidArgument = 1, + NotFound = 2 +} + +export const webrpcErrorByCode: { [code: number]: any } = { [0]: WebrpcEndpointError, [-1]: WebrpcRequestFailedError, [-2]: WebrpcBadRouteError, diff --git a/packages/signhub/CHANGELOG.md b/packages/signhub/CHANGELOG.md index a418c5204..7b881b155 100644 --- a/packages/signhub/CHANGELOG.md +++ b/packages/signhub/CHANGELOG.md @@ -1,5 +1,23 @@ # @0xsequence/signhub +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/core@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/core@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/signhub/package.json b/packages/signhub/package.json index 1843e362b..09a3461d3 100644 --- a/packages/signhub/package.json +++ b/packages/signhub/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/signhub", - "version": "2.2.4", + "version": "2.2.6", "description": "orchestrates a series of signers, provides visibility into the signing process, and to the signers themselves", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/signhub", "source": "src/index.ts", diff --git a/packages/tests/CHANGELOG.md b/packages/tests/CHANGELOG.md index 47fbdd821..a5fb3b1e4 100644 --- a/packages/tests/CHANGELOG.md +++ b/packages/tests/CHANGELOG.md @@ -1,5 +1,25 @@ # @0xsequence/tests +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/core@2.2.6 + - @0xsequence/utils@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/core@2.2.5 + - @0xsequence/utils@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/tests/package.json b/packages/tests/package.json index 3c082e56f..7cdc75f8c 100644 --- a/packages/tests/package.json +++ b/packages/tests/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/tests", - "version": "2.2.4", + "version": "2.2.6", "description": "test tools for sequence.js", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/tests", "source": "src/index.ts", diff --git a/packages/tests/src/context/v2.ts b/packages/tests/src/context/v2.ts index d30c9e6de..2e06deb4f 100644 --- a/packages/tests/src/context/v2.ts +++ b/packages/tests/src/context/v2.ts @@ -43,6 +43,7 @@ export async function deployV2Context(signer: ethers.Signer): Promise + chains: Array } export interface WaasAuthenticatorAdmin { @@ -267,33 +265,34 @@ export interface WaasAuthenticatorAdmin { createTenant(args: CreateTenantArgs, headers?: object, signal?: AbortSignal): Promise updateTenant(args: UpdateTenantArgs, headers?: object, signal?: AbortSignal): Promise nextMigrationBatch(args: NextMigrationBatchArgs, headers?: object, signal?: AbortSignal): Promise - processMigrationBatch(args: ProcessMigrationBatchArgs, headers?: object, signal?: AbortSignal): Promise + processMigrationBatch( + args: ProcessMigrationBatchArgs, + headers?: object, + signal?: AbortSignal + ): Promise } -export interface VersionArgs { -} +export interface VersionArgs {} export interface VersionReturn { - version: Version -} -export interface RuntimeStatusArgs { + version: Version } +export interface RuntimeStatusArgs {} export interface RuntimeStatusReturn { - status: RuntimeStatus -} -export interface ClockArgs { + status: RuntimeStatus } +export interface ClockArgs {} export interface ClockReturn { - serverTime: string + serverTime: string } export interface GetTenantArgs { projectId: number } export interface GetTenantReturn { - tenant: Tenant + tenant: Tenant } export interface CreateTenantArgs { projectId: number @@ -306,7 +305,7 @@ export interface CreateTenantArgs { export interface CreateTenantReturn { tenant: Tenant - upgradeCode: string + upgradeCode: string } export interface UpdateTenantArgs { projectId: number @@ -317,7 +316,7 @@ export interface UpdateTenantArgs { } export interface UpdateTenantReturn { - tenant: Tenant + tenant: Tenant } export interface NextMigrationBatchArgs { migration: Migration @@ -327,7 +326,7 @@ export interface NextMigrationBatchArgs { export interface NextMigrationBatchReturn { page: Page - items: Array + items: Array } export interface ProcessMigrationBatchArgs { migration: Migration @@ -336,12 +335,10 @@ export interface ProcessMigrationBatchArgs { } export interface ProcessMigrationBatchReturn { - logs: {[key: string]: Array} - errors: {[key: string]: string} + logs: { [key: string]: Array } + errors: { [key: string]: string } } - - // // Client // @@ -358,51 +355,52 @@ export class WaasAuthenticator implements WaasAuthenticator { private url(name: string): string { return this.hostname + this.path + name } - + registerSession = (args: RegisterSessionArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('RegisterSession'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - session: (_data.session), - response: (_data.response), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('RegisterSession'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + session: _data.session, + response: _data.response + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + sendIntent = (args: SendIntentArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('SendIntent'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - response: (_data.response), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('SendIntent'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + response: _data.response + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + chainList = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('ChainList'), - createHTTPRequest({}, headers, signal) - ).then((res) => { - return buildResponse(res).then(_data => { - return { - chains: >(_data.chains), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('ChainList'), createHTTPRequest({}, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + chains: >_data.chains + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - } export class WaasAuthenticatorAdmin implements WaasAuthenticatorAdmin { protected hostname: string @@ -417,128 +415,140 @@ export class WaasAuthenticatorAdmin implements WaasAuthenticatorAdmin { private url(name: string): string { return this.hostname + this.path + name } - + version = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('Version'), - createHTTPRequest({}, headers, signal) - ).then((res) => { - return buildResponse(res).then(_data => { - return { - version: (_data.version), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + version: _data.version + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + runtimeStatus = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('RuntimeStatus'), - createHTTPRequest({}, headers, signal) - ).then((res) => { - return buildResponse(res).then(_data => { - return { - status: (_data.status), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + status: _data.status + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + clock = (headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('Clock'), - createHTTPRequest({}, headers, signal) - ).then((res) => { - return buildResponse(res).then(_data => { - return { - serverTime: (_data.serverTime), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('Clock'), createHTTPRequest({}, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + serverTime: _data.serverTime + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + getTenant = (args: GetTenantArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('GetTenant'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - tenant: (_data.tenant), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('GetTenant'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + tenant: _data.tenant + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + createTenant = (args: CreateTenantArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('CreateTenant'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - tenant: (_data.tenant), - upgradeCode: (_data.upgradeCode), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('CreateTenant'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + tenant: _data.tenant, + upgradeCode: _data.upgradeCode + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - + updateTenant = (args: UpdateTenantArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('UpdateTenant'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - tenant: (_data.tenant), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - nextMigrationBatch = (args: NextMigrationBatchArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('NextMigrationBatch'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - page: (_data.page), - items: >(_data.items), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) - } - - processMigrationBatch = (args: ProcessMigrationBatchArgs, headers?: object, signal?: AbortSignal): Promise => { - return this.fetch( - this.url('ProcessMigrationBatch'), - createHTTPRequest(args, headers, signal)).then((res) => { - return buildResponse(res).then(_data => { - return { - logs: <{[key: string]: Array}>(_data.logs), - errors: <{[key: string]: string}>(_data.errors), - } - }) - }, (error) => { - throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) - }) + return this.fetch(this.url('UpdateTenant'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + tenant: _data.tenant + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + nextMigrationBatch = ( + args: NextMigrationBatchArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('NextMigrationBatch'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + page: _data.page, + items: >_data.items + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) + } + + processMigrationBatch = ( + args: ProcessMigrationBatchArgs, + headers?: object, + signal?: AbortSignal + ): Promise => { + return this.fetch(this.url('ProcessMigrationBatch'), createHTTPRequest(args, headers, signal)).then( + res => { + return buildResponse(res).then(_data => { + return { + logs: <{ [key: string]: Array }>_data.logs, + errors: <{ [key: string]: string }>_data.errors + } + }) + }, + error => { + throw WebrpcRequestFailedError.new({ cause: `fetch(): ${error.message || ''}` }) + } + ) } - } - const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => { +const createHTTPRequest = (body: object = {}, headers: object = {}, signal: AbortSignal | null = null): object => { return { method: 'POST', headers: { ...headers, 'Content-Type': 'application/json' }, @@ -552,18 +562,18 @@ const buildResponse = (res: Response): Promise => { let data try { data = JSON.parse(text) - } catch(error) { + } catch (error) { let message = '' - if (error instanceof Error) { + if (error instanceof Error) { message = error.message } throw WebrpcBadResponseError.new({ status: res.status, - cause: `JSON.parse(): ${message}: response text: ${text}`}, - ) + cause: `JSON.parse(): ${message}: response text: ${text}` + }) } if (!res.ok) { - const code: number = (typeof data.code === 'number') ? data.code : 0 + const code: number = typeof data.code === 'number' ? data.code : 0 throw (webrpcErrorByCode[code] || WebrpcError).new(data) } return data @@ -745,7 +755,6 @@ export class WebrpcStreamFinishedError extends WebrpcError { } } - // Schema errors export class UnauthorizedError extends WebrpcError { @@ -852,7 +861,6 @@ export class TooManyAttemptsError extends WebrpcError { } } - export enum errors { WebrpcEndpoint = 'WebrpcEndpoint', WebrpcRequestFailed = 'WebrpcRequestFailed', @@ -872,7 +880,7 @@ export enum errors { ProofVerificationFailed = 'ProofVerificationFailed', AnswerIncorrect = 'AnswerIncorrect', ChallengeExpired = 'ChallengeExpired', - TooManyAttempts = 'TooManyAttempts', + TooManyAttempts = 'TooManyAttempts' } const webrpcErrorByCode: { [code: number]: any } = { @@ -894,8 +902,7 @@ const webrpcErrorByCode: { [code: number]: any } = { [7002]: ProofVerificationFailedError, [7003]: AnswerIncorrectError, [7004]: ChallengeExpiredError, - [7005]: TooManyAttemptsError, + [7005]: TooManyAttemptsError } export type Fetch = (input: RequestInfo, init?: RequestInit) => Promise - diff --git a/packages/waas/src/clients/intent.gen.ts b/packages/waas/src/clients/intent.gen.ts index 923df5387..0cd21e215 100644 --- a/packages/waas/src/clients/intent.gen.ts +++ b/packages/waas/src/clients/intent.gen.ts @@ -6,19 +6,18 @@ // webrpc-gen -schema=intent.ridl -target=typescript -out=./intent.gen.ts // WebRPC description and code-gen version -export const WebRPCVersion = "v1" +export const WebRPCVersion = 'v1' // Schema version of your RIDL schema -export const WebRPCSchemaVersion = "v0.1.0" +export const WebRPCSchemaVersion = 'v0.1.0' // Schema hash generated from your RIDL schema -export const WebRPCSchemaHash = "2ceeffac8ca0cebead69d58a1aa7a27d30ecb864" +export const WebRPCSchemaHash = '2ceeffac8ca0cebead69d58a1aa7a27d30ecb864' // // Types // - export enum IntentName { initiateAuth = 'initiateAuth', openSession = 'openSession', @@ -314,11 +313,9 @@ export interface IntentResponseSessionOpened { wallet: string } -export interface IntentResponseSessionClosed { -} +export interface IntentResponseSessionClosed {} -export interface IntentResponseValidateSession { -} +export interface IntentResponseValidateSession {} export interface IntentResponseValidationRequired { sessionId: string @@ -407,8 +404,7 @@ export interface IntentResponseAccountFederated { account: Account } -export interface IntentResponseAccountRemoved { -} +export interface IntentResponseAccountRemoved {} export interface IntentResponseIdToken { idToken: string diff --git a/packages/waas/src/intents/messages.ts b/packages/waas/src/intents/messages.ts index 6d6ac489c..b8869bf2c 100644 --- a/packages/waas/src/intents/messages.ts +++ b/packages/waas/src/intents/messages.ts @@ -24,7 +24,12 @@ export type SignTypedDataArgs = { typedData: any } -export function signTypedData({ wallet, chainId, typedData, lifespan }: SignTypedDataArgs & BaseArgs): Intent { +export function signTypedData({ + wallet, + chainId, + typedData, + lifespan +}: SignTypedDataArgs & BaseArgs): Intent { return makeIntent(IntentName.signTypedData, lifespan, { wallet, network: chainId.toString(), diff --git a/packages/wallet/CHANGELOG.md b/packages/wallet/CHANGELOG.md index b1d5c5f84..dbfb6500f 100644 --- a/packages/wallet/CHANGELOG.md +++ b/packages/wallet/CHANGELOG.md @@ -1,5 +1,33 @@ # @0xsequence/wallet +## 2.2.6 + +### Patch Changes + +- Update relayer package +- Updated dependencies + - @0xsequence/abi@2.2.6 + - @0xsequence/core@2.2.6 + - @0xsequence/network@2.2.6 + - @0xsequence/relayer@2.2.6 + - @0xsequence/signhub@2.2.6 + - @0xsequence/utils@2.2.6 + +## 2.2.5 + +### Patch Changes + +- auth: fix sequence indexer gateway url +- account: immutable wallet proxy hook +- Updated dependencies +- Updated dependencies + - @0xsequence/abi@2.2.5 + - @0xsequence/core@2.2.5 + - @0xsequence/network@2.2.5 + - @0xsequence/relayer@2.2.5 + - @0xsequence/signhub@2.2.5 + - @0xsequence/utils@2.2.5 + ## 2.2.4 ### Patch Changes diff --git a/packages/wallet/package.json b/packages/wallet/package.json index 1f8341f32..805670fd2 100644 --- a/packages/wallet/package.json +++ b/packages/wallet/package.json @@ -1,6 +1,6 @@ { "name": "@0xsequence/wallet", - "version": "2.2.4", + "version": "2.2.6", "description": "wallet sub-package for Sequence", "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/wallet", "source": "src/index.ts",