Skip to content

Commit

Permalink
Fixed evm signAndSendTransaction method
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenya476 committed Jun 7, 2024
1 parent 49589cc commit a7882bb
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/providers/ConnectionProvider/Evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand All @@ -33,11 +36,10 @@ class EvmWallet implements EvmWalletProvider {
}

async signAndSendTransaction(rawTransaction: RawEvmTransaction): Promise<string> {
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;
}
}
Expand Down

0 comments on commit a7882bb

Please sign in to comment.