From a7882bb0c5420ba81a2c6a6691336924040b34d6 Mon Sep 17 00:00:00 2001 From: Jenya476 Date: Fri, 7 Jun 2024 15:56:30 +0300 Subject: [PATCH] Fixed evm signAndSendTransaction method --- src/providers/ConnectionProvider/Evm.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/providers/ConnectionProvider/Evm.ts b/src/providers/ConnectionProvider/Evm.ts index bc1146f..051067e 100644 --- a/src/providers/ConnectionProvider/Evm.ts +++ b/src/providers/ConnectionProvider/Evm.ts @@ -3,7 +3,8 @@ import {ChainSymbol, ChainType, RawEvmTransaction} from '@allbridge/bridge-core- import Web3 from 'web3'; import {AbstractProvider} from 'web3-core'; import {toChecksumAddress} from 'web3-utils'; -import { Buffer } from "buffer"; +import {Buffer} from "buffer"; + window.Buffer = window.Buffer || Buffer; declare global { @@ -15,7 +16,9 @@ declare global { class EvmWallet implements EvmWalletProvider { chainType = ChainType.EVM as const; web3 = new Web3(this._ethereum); - constructor(public chainSymbol: ChainSymbol) {} + + constructor(public chainSymbol: ChainSymbol) { + } private get _ethereum(): AbstractProvider { if (!window.ethereum) { @@ -33,11 +36,10 @@ class EvmWallet implements EvmWalletProvider { } async signAndSendTransaction(rawTransaction: RawEvmTransaction): Promise { - const gasLimit = await this.web3.eth.estimateGas(rawTransaction); - const signedTx = await this.web3.eth.sendTransaction({ - ...rawTransaction, - gas: gasLimit, - }); + const gas = await this.web3.eth.estimateGas(rawTransaction); + // @ts-ignore + const feeOptions: { maxPriorityFeePerGas: string | number | undefined, maxFeePerGas: string | number | undefined } = {maxPriorityFeePerGas: null, maxFeePerGas: null}; + const signedTx = await this.web3.eth.sendTransaction({...rawTransaction, gas, ...feeOptions}); return signedTx.transactionHash; } }