From 078ce473ccff0bb54966e10a8d94143a7554d938 Mon Sep 17 00:00:00 2001 From: William Hua Date: Thu, 7 Nov 2024 15:58:44 -0500 Subject: [PATCH] skale-nebula: deploy gas limit = 10m (#607) --- packages/account/src/account.ts | 9 ++++++++- packages/wallet/src/wallet.ts | 23 +++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/packages/account/src/account.ts b/packages/account/src/account.ts index 9fc182a7d..64a1bdf57 100644 --- a/packages/account/src/account.ts +++ b/packages/account/src/account.ts @@ -700,9 +700,16 @@ export class Account { // Add wallet deployment if needed if (!status.onChain.deployed) { + let gasLimit: bigint | undefined + switch (chainId) { + case BigInt(ChainId.SKALE_NEBULA): + gasLimit = 10000000n + break + } + // Wallet deployment will vary depending on the version // so we need to use the context to get the correct deployment - const deployTransaction = Wallet.buildDeployTransaction(status.original.context, status.original.imageHash) + const deployTransaction = Wallet.buildDeployTransaction(status.original.context, status.original.imageHash, gasLimit) transactions.push(...deployTransaction.transactions) } diff --git a/packages/wallet/src/wallet.ts b/packages/wallet/src/wallet.ts index 6eb74ef61..554ad292a 100644 --- a/packages/wallet/src/wallet.ts +++ b/packages/wallet/src/wallet.ts @@ -1,5 +1,6 @@ import { ethers } from 'ethers' import { commons, v1, v2 } from '@0xsequence/core' +import { ChainId } from '@0xsequence/network' import { SignatureOrchestrator, SignerState, Status } from '@0xsequence/signhub' import { encodeTypedDataDigest, subDigestOf } from '@0xsequence/utils' import { FeeQuote, Relayer } from '@0xsequence/relayer' @@ -65,7 +66,7 @@ export class Wallet< public context: commons.context.WalletContext public config: Y public address: string - public chainId: ethers.BigNumberish + public chainId: bigint public relayer?: Relayer @@ -78,7 +79,9 @@ export class Wallet< private _reader?: commons.reader.Reader constructor(options: WalletOptions) { - if (BigInt(options.chainId) === 0n && !options.coders.signature.supportsNoChainId) { + const chainId = BigInt(options.chainId) + + if (chainId === 0n && !options.coders.signature.supportsNoChainId) { throw new Error(`Sequence version ${options.config.version} doesn't support chainId 0`) } @@ -89,7 +92,7 @@ export class Wallet< this.orchestrator = options.orchestrator this.coders = options.coders this.address = options.address - this.chainId = options.chainId + this.chainId = chainId this.relayer = options.relayer this._reader = options.reader @@ -179,7 +182,14 @@ export class Wallet< throw new Error(`First address of config ${imageHash} doesn't match wallet address ${this.address}`) } - const bundle = Wallet.buildDeployTransaction(this.context, imageHash) + let gasLimit: bigint | undefined + switch (this.chainId) { + case BigInt(ChainId.SKALE_NEBULA): + gasLimit = 10000000n + break + } + + const bundle = Wallet.buildDeployTransaction(this.context, imageHash, gasLimit) if (metadata?.includeChildren) { const childBundle = await this.orchestrator.buildDeployTransaction(metadata) if (childBundle) { @@ -209,7 +219,8 @@ export class Wallet< static buildDeployTransaction( context: commons.context.WalletContext, - imageHash: string + imageHash: string, + gasLimit: ethers.BigNumberish = 100000n ): commons.transaction.TransactionBundle { const factoryInterface = new ethers.Interface(walletContracts.factory.abi) @@ -219,7 +230,7 @@ export class Wallet< { to: context.factory, data: factoryInterface.encodeFunctionData(factoryInterface.getFunction('deploy')!, [context.mainModule, imageHash]), - gasLimit: 100000, + gasLimit, delegateCall: false, revertOnError: true, value: 0