Skip to content

Commit

Permalink
skale-nebula: deploy gas limit = 10m
Browse files Browse the repository at this point in the history
  • Loading branch information
attente committed Nov 7, 2024
1 parent df6d53a commit 8165137
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
7 changes: 6 additions & 1 deletion packages/account/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,14 @@ export class Account {

// Add wallet deployment if needed
if (!status.onChain.deployed) {
let gasLimit: bigint | undefined
if (BigInt(chainId) === BigInt(ChainId.SKALE_NEBULA)) {
gasLimit = 10000000n
}

// 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)
}
Expand Down
21 changes: 15 additions & 6 deletions packages/wallet/src/wallet.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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

Expand All @@ -78,7 +79,9 @@ export class Wallet<
private _reader?: commons.reader.Reader

constructor(options: WalletOptions<T, Y, Z>) {
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`)
}

Expand All @@ -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
Expand Down Expand Up @@ -179,7 +182,12 @@ 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
if (this.chainId === BigInt(ChainId.SKALE_NEBULA)) {
gasLimit = 10000000n
}

const bundle = Wallet.buildDeployTransaction(this.context, imageHash, gasLimit)
if (metadata?.includeChildren) {
const childBundle = await this.orchestrator.buildDeployTransaction(metadata)
if (childBundle) {
Expand Down Expand Up @@ -209,7 +217,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)

Expand All @@ -219,7 +228,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
Expand Down

0 comments on commit 8165137

Please sign in to comment.