diff --git a/lib/screen/wallet_connect/send/wc_send_transaction_bloc.dart b/lib/screen/wallet_connect/send/wc_send_transaction_bloc.dart index 53da29dda..80cbe0ec8 100644 --- a/lib/screen/wallet_connect/send/wc_send_transaction_bloc.dart +++ b/lib/screen/wallet_connect/send/wc_send_transaction_bloc.dart @@ -45,10 +45,15 @@ class WCSendTransactionBloc final newState = state.clone(); final exchangeRate = await _currencyService.getExchangeRates(); newState.exchangeRate = exchangeRate; - emit(newState); try { - newState.feeOptionValue = await _ethereumService.estimateFee( + final estimatedFee = await _ethereumService.estimateFee( persona, event.index, event.address, event.amount, event.data); + final balance = await _ethereumService + .getBalance(await persona.getETHEip55Address(index: event.index)); + newState + ..feeOptionValue = estimatedFee + ..fee = newState.feeOptionValue!.getFee(state.feeOption) + ..balance = balance.getInWei; } on RPCError catch (e) { log.info('WC Send tx bloc: RPCError: ' 'errorCode: ${e.errorCode} ' @@ -73,11 +78,6 @@ class WCSendTransactionBloc add(event); }); } - newState.fee = newState.feeOptionValue!.getFee(state.feeOption); - - final balance = - await _ethereumService.getBalance(await persona.getETHEip55Address()); - newState.balance = balance.getInWei; emit(newState); }); diff --git a/lib/screen/wallet_connect/send/wc_send_transaction_page.dart b/lib/screen/wallet_connect/send/wc_send_transaction_page.dart index 34655358e..30e2021b5 100644 --- a/lib/screen/wallet_connect/send/wc_send_transaction_page.dart +++ b/lib/screen/wallet_connect/send/wc_send_transaction_page.dart @@ -133,11 +133,11 @@ class _WCSendTransactionPageState extends State { state.fee != null ? state.fee! + amount.getInWei : null; final theme = Theme.of(context); final ethAmountText = '${ethFormatter.format(amount.getInWei)} ETH ' - '(${state.exchangeRate.ethToUsd(amount.getInWei)} USD)'; + '(${state.exchangeRate?.ethToUsd(amount.getInWei) ?? '-'} USD)'; final ethTotalAmountText = total == null ? '- ETH (- USD)' : '${ethFormatter.format(total)} ETH' - ' (${state.exchangeRate.ethToUsd(total)} USD)'; + ' (${state.exchangeRate?.ethToUsd(total) ?? '-'} USD)'; return Stack( children: [ Container( @@ -471,7 +471,7 @@ class _WCSendTransactionPageState extends State { } final fee = state.feeOptionValue!.getFee(feeOption ?? state.feeOption); return '${ethFormatter.format(fee)} ETH ' - '(${state.exchangeRate.ethToUsd(fee)} USD)'; + '(${state.exchangeRate?.ethToUsd(fee) ?? '-'} USD)'; } } diff --git a/lib/screen/wallet_connect/send/wc_send_transaction_state.dart b/lib/screen/wallet_connect/send/wc_send_transaction_state.dart index aa08a9483..1b4f0360d 100644 --- a/lib/screen/wallet_connect/send/wc_send_transaction_state.dart +++ b/lib/screen/wallet_connect/send/wc_send_transaction_state.dart @@ -68,8 +68,8 @@ class WCSendTransactionRejectEvent extends WCSendTransactionEvent { WCSendTransactionRejectEvent( this.peerMeta, this.requestId, { - this.topic, required this.isWalletConnect2, + this.topic, this.isIRL = false, }); } @@ -81,7 +81,7 @@ class WCSendTransactionState { bool isError = false; FeeOption feeOption; FeeOptionValue? feeOptionValue; - CurrencyExchangeRate exchangeRate; + CurrencyExchangeRate? exchangeRate; WCSendTransactionState({ this.fee, @@ -90,7 +90,7 @@ class WCSendTransactionState { this.isError = false, this.feeOption = DEFAULT_FEE_OPTION, this.feeOptionValue, - this.exchangeRate = const CurrencyExchangeRate(eth: "1.0", xtz: "1.0"), + this.exchangeRate, }); WCSendTransactionState clone() => WCSendTransactionState(