diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_fee_dropdown.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_fee_dropdown.dart index f2da6b9ac..fc049e093 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_fee_dropdown.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_fee_dropdown.dart @@ -342,14 +342,16 @@ class FeeDropDownChild extends ConsumerWidget { ), if (feeObject != null) Text( - estimatedTimeToBeIncludedInNextBlock( - Constants.targetBlockTimeInSeconds(manager.coin), - feeRateType == FeeRateType.fast - ? feeObject!.numberOfBlocksFast - : feeRateType == FeeRateType.slow - ? feeObject!.numberOfBlocksSlow - : feeObject!.numberOfBlocksAverage, - ), + manager.coin == Coin.ethereum + ? "" + : estimatedTimeToBeIncludedInNextBlock( + Constants.targetBlockTimeInSeconds(manager.coin), + feeRateType == FeeRateType.fast + ? feeObject!.numberOfBlocksFast + : feeRateType == FeeRateType.slow + ? feeObject!.numberOfBlocksSlow + : feeObject!.numberOfBlocksAverage, + ), style: STextStyles.desktopTextExtraExtraSmall(context) .copyWith( color: Theme.of(context) diff --git a/lib/services/ethereum/ethereum_api.dart b/lib/services/ethereum/ethereum_api.dart index 09f190eb0..38bf26930 100644 --- a/lib/services/ethereum/ethereum_api.dart +++ b/lib/services/ethereum/ethereum_api.dart @@ -503,7 +503,7 @@ abstract class EthereumAPI { if (json["success"] == true) { return EthereumResponse( GasTracker.fromJson( - Map.from(json["result"] as Map), + Map.from(json["result"]["result"] as Map), ), null, ); diff --git a/lib/services/ethereum/ethereum_token_service.dart b/lib/services/ethereum/ethereum_token_service.dart index 48eff2f00..624b6b59a 100644 --- a/lib/services/ethereum/ethereum_token_service.dart +++ b/lib/services/ethereum/ethereum_token_service.dart @@ -90,30 +90,10 @@ class EthTokenWallet extends ChangeNotifier with EthTokenCache { final myAddress = await currentReceivingAddress; final myWeb3Address = web3dart.EthereumAddress.fromHex(myAddress); - final est = await client.estimateGas( - sender: myWeb3Address, - to: web3dart.EthereumAddress.fromHex(address), - data: _sendFunction - .encodeCall([web3dart.EthereumAddress.fromHex(address), amount.raw]), - gasPrice: web3dart.EtherAmount.fromUnitAndValue( - web3dart.EtherUnit.wei, - fee, - ), - amountOfGas: BigInt.from(_gasLimit), - ); - final nonce = args?["nonce"] as int? ?? await client.getTransactionCount(myWeb3Address, atBlock: const web3dart.BlockNum.pending()); - final nResponse = await EthereumAPI.getAddressNonce(address: myAddress); - print("=============================================================="); - print("TOKEN client.estimateGas: $est"); - print("TOKEN estimateFeeFor : $feeEstimate"); - print("TOKEN nonce custom response: $nResponse"); - print("TOKEN actual nonce : $nonce"); - print("=============================================================="); - final tx = web3dart.Transaction.callContract( contract: _deployedContract, function: _sendFunction, @@ -179,7 +159,7 @@ class EthTokenWallet extends ChangeNotifier with EthTokenCache { // precision may be lost here hence the following amountString amount: (txData["recipientAmt"] as Amount).raw.toInt(), amountString: (txData["recipientAmt"] as Amount).toJsonString(), - fee: txData["fee"] as int, + fee: (txData["fee"] as Amount).raw.toInt(), height: null, isCancelled: false, isLelantus: false, diff --git a/lib/utilities/eth_commons.dart b/lib/utilities/eth_commons.dart index 9b74cdbfe..466a4aff0 100644 --- a/lib/utilities/eth_commons.dart +++ b/lib/utilities/eth_commons.dart @@ -15,7 +15,7 @@ class GasTracker { final int numberOfBlocksAverage; final int numberOfBlocksSlow; - final int timestamp; + final String lastBlock; const GasTracker({ required this.average, @@ -24,19 +24,20 @@ class GasTracker { required this.numberOfBlocksFast, required this.numberOfBlocksAverage, required this.numberOfBlocksSlow, - required this.timestamp, + required this.lastBlock, }); factory GasTracker.fromJson(Map json) { final targetTime = Constants.targetBlockTimeInSeconds(Coin.ethereum); return GasTracker( - average: Decimal.parse(json["average"]["price"].toString()), - fast: Decimal.parse(json["fast"]["price"].toString()), - slow: Decimal.parse(json["slow"]["price"].toString()), - numberOfBlocksAverage: (json["average"]["time"] as int) ~/ targetTime, - numberOfBlocksFast: (json["fast"]["time"] as int) ~/ targetTime, - numberOfBlocksSlow: (json["slow"]["time"] as int) ~/ targetTime, - timestamp: json["timestamp"] as int, + fast: Decimal.parse(json["FastGasPrice"].toString()), + average: Decimal.parse(json["ProposeGasPrice"].toString()), + slow: Decimal.parse(json["SafeGasPrice"].toString()), + // TODO fix hardcoded + numberOfBlocksFast: 30 ~/ targetTime, + numberOfBlocksAverage: 180 ~/ targetTime, + numberOfBlocksSlow: 240 ~/ targetTime, + lastBlock: json["LastBlock"] as String, ); } }