on master help sign in
Merge pull request #878 from urbit/t/fix-metamask-type

metamask: send TX nonces as a string

commitebdc206456d3669ff37dbbf27d35717909081020 authortomholford <16504501+tomholford@users.noreply.github.com> dateFri 14 Jan 2022, 22:22 (5 years ago) parentfe5615cfeb602f
1 file changed+7−1
src/lib/metamask.ts+7−1
src/lib/metamask.ts+7−1
@@ -27,7 +27,7 @@ const metamaskSendTransaction = async (txn: FakeSignableTx, web3: Web3) => {
2727 data: data.toString(),
2828 gasLimit,
2929 gasPrice,
30− nonce: Number(nonce),
30+ nonce: Number(nonce).toString(),
3131 to: to.toString(),
3232 from: toHex(from),
3333 };
@@ -48,6 +48,12 @@ const metamaskSendTransaction = async (txn: FakeSignableTx, web3: Web3) => {
4848 // signed tx, it makes us wait for confirmation outside of our own
4949 // waitForTransactionConfirm. because of this the progress bar loses
5050 // its progressiveness for metamask users.
51+
52+ // Per the web3 lib's Typescript declarations, sendTransaction
53+ // expects a Transaction nonce of type number to be passed in.
54+ // However, at runtime, Metamask throws an error indicating that
55+ // nonce should be a string.
56+ //@ts-ignore
5157 let receipt = await web3.eth.sendTransaction(metamaskFormattedTxn);
5258 txHash = receipt.transactionHash;
5359 }