Skip to content

[@0xsequence/relayer] prepareTransactions doesn't work with undeployed wallets #309

Description

@sondnm

When calling prepareTransactions from base-relayer for the first transactions of an undeployed sequence wallet, this error was thrown

Uncaught Error: Unable to prepare transactions without a defined nonce

My approach was that I firstly signed the txns using wallet.signTransactions and then passed the attributes from the signed Transactions to prepareTransactions.

I found the issue was in these LOC

    const nonce = readSequenceNonce(...transactions)
    if (!nonce) {
      throw new Error('Unable to prepare transactions without a defined nonce')
    }

The transaction produced by signTransactions has the nonce of 0 instead of BigNumber { 0x0 } hence this check !nonce is true for both undefined and 0 values.

How can I do differently to use this prepareTransactions for the first txns?

Activity

  1. attente commented on Nov 3, 2022

    @attente
    Contributor

    Thanks for your report, could you please add what version of sequence.js you encountered this error on?

  2. attente commented on Nov 3, 2022

    @attente
    Contributor

    Also, can you try calling:

    await wallet.sendSignedTransactions(signedTransactions)
    

    directly to see if that resolves your issue?

  3. sondnm commented on Nov 3, 2022

    @sondnm
    Author

    could you please add what version of sequence.js you encountered this error on?

    I'm tested against v0.42.8

    await wallet.sendSignedTransactions(signedTransactions)

    This successfully deploy the wallet and execute the given transaction. However I wanted to get the output data to pass to our local relayer in another process instead of executing it immediately. Hence I needed the prepareTransactions output.

  4. attente commented on Nov 3, 2022

    @attente
    Contributor

    Can you please try is copying this:

    const { to: contract, execute } = await this.prependWalletDeploy(signedTxs)
    const walletAddress = addressOf(signedTxs.config, signedTxs.context)
    const walletInterface = new ethers.utils.Interface(walletContracts.mainModule.abi)
    const input = walletInterface.encodeFunctionData(walletInterface.getFunction('execute'), [
    sequenceTxAbiEncode(execute.transactions),
    execute.nonce,
    execute.signature
    ])
    . This code should give you to (the "to" address) and input (the calldata).

    (Replace this with your BaseRelayer if necessary.)

  5. sondnm commented on Nov 4, 2022

    @sondnm
    Author

    Thanks for the suggestion. I already gave it a try and it worked well. I guess the !nonce check with 0 value is a bug with prepareTransactions then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions