Open
Description
Description
This issue covers two related to nonce problems in the current TransactionComposer and SignedTransactionComposer implementations:
Optional: User Story
Problem 1: JSON.stringify Fails with BigInt
As user I initialized a SignedTransactionComposer as in the examples and wanted to create SubAccount:
const { result } = await SignedTransactionComposer.init({
sender: accountId,
receiver: newAccountId,
deps: { rpcProvider, signer },
}).createAccount()
.transfer(100000000000000n)
.addFullAccessKey(newPrivateKey.getPublicKey().toString())
.signAndSend();`
As result I will get next error
TypeError: Do not know how to serialize a BigInt
at JSON.stringify (<anonymous>)
51 |
52 | if (!tx.actions.length || !tx.blockHash || !tx.nonce || !tx.publicKey || !tx.receiverId || !tx.signerId) {
> 53 | throw new Error(`invalid transaction: ${JSON.stringify(tx)}`);
| ^
54 | }
55 |
56 | return tx;
We can fix it with casting BigInt to String
Problem 2: Missing nonce cause transaction failures
If a user does not explicitly provide a `nonce` when composing a transaction, the system allows building the transaction but fails at execution time with an error like:Transaction nonce X must be larger than nonce of the used access key Y
The composer does not verify or automatically resolve the nonce before attempting to sign or send.
Proposals
I would work on it and bring next features
- Fix current error handling in method
buildTransactionObject
; - Verify nonce in SignedTransactionComposer while signing, provide it if doesn`t exist
- Autoincrement nonce after signing
- Describe nonce execution to the endUser
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
NEW❗