Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skale-nebula: deploy gas limit = 10m #607

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/account/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
23 changes: 17 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,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) {
Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand Down