From 4705394fce6616f763014f07494759bc407f32b0 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Wed, 7 Jun 2023 03:06:25 +0300 Subject: [PATCH] Refactor signing/sending transactions --- cw_ethereum/lib/ethereum_client.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cw_ethereum/lib/ethereum_client.dart b/cw_ethereum/lib/ethereum_client.dart index f36288ee6..995664fa4 100644 --- a/cw_ethereum/lib/ethereum_client.dart +++ b/cw_ethereum/lib/ethereum_client.dart @@ -104,7 +104,6 @@ class EthereumClient { required CryptoCurrency currency, }) async { bool _isEthereum = currency == CryptoCurrency.eth; - final estimatedGas = BigInt.from(_isEthereum ? 21000 : 50000); final price = await _client!.getGasPrice(); @@ -118,11 +117,15 @@ class EthereumClient { final signedTransaction = await _client!.signTransaction(privateKey, transaction); + final estimatedGas; final Function _sendTransaction; if (_isEthereum) { + estimatedGas = BigInt.from(21000); _sendTransaction = () async => await sendTransaction(signedTransaction); } else { + estimatedGas = BigInt.from(50000); + final erc20 = Erc20( client: _client!, address: EthereumAddress.fromHex(_erc20Currencies[currency]!),