@@ -92,7 +92,7 @@ const signTransaction = async ({
92 } else if (walletType === WALLET_TYPES.TREZOR) {
92 } else if (walletType === WALLET_TYPES.TREZOR) {
93 await trezorSignTransaction(stx, walletHdPath);
93 await trezorSignTransaction(stx, walletHdPath);
94 } else if (walletType === WALLET_TYPES.METAMASK) {
94 } else if (walletType === WALLET_TYPES.METAMASK) {
95− return metamaskSignTransaction(stx, wallet.address);
95+ return metamaskSignTransaction(utx, wallet.address);
97 stx.sign(wallet.privateKey);
97 stx.sign(wallet.privateKey);
@@ -102,24 +102,16 @@ const signTransaction = async ({
103const sendSignedTransaction = (web3, stx, doubtNonceError) => {
103const sendSignedTransaction = (web3, stx, doubtNonceError) => {
104 // Handle fake metamask transaction
104 // Handle fake metamask transaction
105 if (stx instanceof FakeMetamaskTransaction) {
107 if (stx instanceof FakeMetamaskTransaction) {
106− const { ethereum } = window;
108+ eventEmitter = web3.eth.sendTransaction(stx.txnData);
107− const sendTxs = {
109+ } else {
108− method: 'eth_sendTransaction',
110+ eventEmitter = web3.eth.sendSignedTransaction(rawTx);
109− params: [stx.txnData],
111+ rawTx = hexify(stx.serialize());
110− from: stx.txnData.from,
112− return new Promise((resolve, reject) =>
113− ethereum.sendAsync(sendTxs, (err, data) =>
114− err ? reject(err) : resolve(data.result)
118− const rawTx = hexify(stx.serialize());
120 return new Promise(async (resolve, reject) => {
113 return new Promise(async (resolve, reject) => {
121− web3.eth
114+ eventEmitter
122− .sendSignedTransaction(rawTx)
123 .on('transactionHash', hash => {
115 .on('transactionHash', hash => {
124 resolve(hash);
116 resolve(hash);
@@ -132,7 +124,7 @@ const sendSignedTransaction = (web3, stx, doubtNonceError) => {
132 const isNonceError =
124 const isNonceError =
133 message.includes("the tx doesn't have the correct nonce.") ||
125 message.includes("the tx doesn't have the correct nonce.") ||
134 message.includes('nonce too low');
126 message.includes('nonce too low');
135− if (isKnownError || (doubtNonceError && isNonceError)) {
127+ if (rawTx && (isKnownError || (doubtNonceError && isNonceError))) {
136 console.log(
128 console.log(
137 'tx send error likely from gas tank submission, ignoring:',
129 'tx send error likely from gas tank submission, ignoring:',
@@ -141,7 +133,8 @@ const sendSignedTransaction = (web3, stx, doubtNonceError) => {
141 resolve(txHash);
133 resolve(txHash);
143 console.error(err);
135 console.error(err);
144− reject(err.message || 'Transaction sending failed!');
136+ const wrappedErr = err instanceof Error ? err : new Error(message);