Skip to content

Commit

Permalink
fix: removed estimatedGas from sendEvmTransaction (#1107)
Browse files Browse the repository at this point in the history
  • Loading branch information
impelcrypto authored Jan 2, 2024
1 parent 4e7b3f8 commit 4d1ad64
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/v2/services/implementations/MetamaskWalletService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,12 @@ export class MetamaskWalletService extends WalletService implements IWalletServi
try {
const web3 = new Web3(this.provider as any);
const rawTx = await getRawEvmTransaction(web3, from, to, data, value);

// Memo: passing this variable (estimatedGas) to `sendTransaction({gas: estimatedGas})` causes an error when sending `withdrawal` transactions.
// the function goes the catch statement if something goes wrong while getting the estimatedGas. This way, the UI prevents sending invalid transactions which could cause loss of assets.
const estimatedGas = await web3.eth.estimateGas(rawTx);
const transactionHash = await web3.eth
.sendTransaction({ ...rawTx, gas: estimatedGas })
.sendTransaction({ ...rawTx })
.once('transactionHash', (transactionHash) => {
this.eventAggregator.publish(new BusyMessage(true));
})
Expand Down

0 comments on commit 4d1ad64

Please sign in to comment.