on master help sign in
Merge pull request #878 from urbit/t/fix-metamask-type
ebdc206tomholford
src/lib/metamask.ts+7−1
@@ -27,7 +27,7 @@ const metamaskSendTransaction = async (txn: FakeSignableTx, web3: Web3) => {
27 data: data.toString(),
27 data: data.toString(),
28 gasLimit,
28 gasLimit,
29 gasPrice,
29 gasPrice,
30− nonce: Number(nonce),
30+ nonce: Number(nonce).toString(),
31 to: to.toString(),
31 to: to.toString(),
32 from: toHex(from),
32 from: toHex(from),
33 };
33 };
@@ -48,6 +48,12 @@ const metamaskSendTransaction = async (txn: FakeSignableTx, web3: Web3) => {
48 // signed tx, it makes us wait for confirmation outside of our own
48 // signed tx, it makes us wait for confirmation outside of our own
49 // waitForTransactionConfirm. because of this the progress bar loses
49 // waitForTransactionConfirm. because of this the progress bar loses
50 // its progressiveness for metamask users.
50 // 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
51 let receipt = await web3.eth.sendTransaction(metamaskFormattedTxn);
57 let receipt = await web3.eth.sendTransaction(metamaskFormattedTxn);
52 txHash = receipt.transactionHash;
58 txHash = receipt.transactionHash;
53 }
59 }