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

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

Open
sondnm opened this issue Nov 3, 2022 · 5 comments

Comments

@sondnm
Copy link

sondnm commented Nov 3, 2022

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?

@attente
Copy link
Contributor

attente commented Nov 3, 2022

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

@attente
Copy link
Contributor

attente commented Nov 3, 2022

Also, can you try calling:

await wallet.sendSignedTransactions(signedTransactions)

directly to see if that resolves your issue?

@sondnm
Copy link
Author

sondnm commented Nov 3, 2022

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.

@attente
Copy link
Contributor

attente commented Nov 3, 2022

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.)

@sondnm
Copy link
Author

sondnm commented Nov 4, 2022

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants