move confirmSend to a nicer place

This commit is contained in:
julian 2023-03-31 09:25:08 -06:00
parent 20c3da72a3
commit b3c4e690c7

View file

@ -220,29 +220,6 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB {
await updateCachedBalance(_balance!);
}
@override
Future<String> confirmSend({required Map<String, dynamic> txData}) async {
web3.Web3Client client = getEthClient();
final chainId = await client.getChainId();
final amount = txData['recipientAmt'] as int;
final decimalAmount = Format.satoshisToAmount(amount, coin: coin);
final bigIntAmount = amountToBigInt(
decimalAmount.toDouble(),
Constants.decimalPlacesForCoin(coin),
);
final tx = web3.Transaction(
to: web3.EthereumAddress.fromHex(txData['address'] as String),
gasPrice: web3.EtherAmount.fromUnitAndValue(
web3.EtherUnit.wei, txData['feeInWei']),
maxGas: _gasLimit,
value: web3.EtherAmount.inWei(bigIntAmount));
final transaction = await client.sendTransaction(_credentials, tx,
chainId: chainId.toInt());
return transaction;
}
@override
Future<int> estimateFeeFor(int satoshiAmount, int feeRate) async {
final fee = estimateFee(feeRate, _gasLimit, coin.decimals);
@ -484,6 +461,29 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB {
return txData;
}
@override
Future<String> confirmSend({required Map<String, dynamic> txData}) async {
web3.Web3Client client = getEthClient();
final chainId = await client.getChainId();
final amount = txData['recipientAmt'] as int;
final decimalAmount = Format.satoshisToAmount(amount, coin: coin);
final bigIntAmount = amountToBigInt(
decimalAmount.toDouble(),
Constants.decimalPlacesForCoin(coin),
);
final tx = web3.Transaction(
to: web3.EthereumAddress.fromHex(txData['address'] as String),
gasPrice: web3.EtherAmount.fromUnitAndValue(
web3.EtherUnit.wei, txData['feeInWei']),
maxGas: _gasLimit,
value: web3.EtherAmount.inWei(bigIntAmount));
final txid = await client.sendTransaction(_credentials, tx,
chainId: chainId.toInt());
return txid;
}
@override
Future<void> recoverFromMnemonic({
required String mnemonic,