sequence.js icon indicating copy to clipboard operation
sequence.js copied to clipboard

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

Open sondnm opened this issue 2 years ago • 5 comments

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?

sondnm avatar Nov 03 '22 04:11 sondnm

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

attente avatar Nov 03 '22 13:11 attente

Also, can you try calling:

await wallet.sendSignedTransactions(signedTransactions)

directly to see if that resolves your issue?

attente avatar Nov 03 '22 13:11 attente

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.

sondnm avatar Nov 03 '22 17:11 sondnm

Can you please try is copying this: https://github.com/0xsequence/sequence.js/blob/114d881a5125cdd2cf2faf9ec750397831fd3e3a/packages/relayer/src/rpc-relayer/index.ts#L189-L197. This code should give you to (the "to" address) and input (the calldata).

(Replace this with your BaseRelayer if necessary.)

attente avatar Nov 03 '22 21:11 attente

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.

sondnm avatar Nov 04 '22 01:11 sondnm