@@ -150,23 +150,25 @@ class SendCryptoPresenter extends CompletePresenter<SendCryptoState> {
150
150
151
151
double sumBalance = token.balance! - double .parse (amount);
152
152
estimatedGasFee = await _estimatedFee (recipientAddress);
153
- sumBalance -= estimatedGasFee? .gasFee ?? 0.0 ;
154
- final estimatedFee = estimatedGasFee == null
155
- ? '--'
156
- : Validation .isExpoNumber (estimatedGasFee.gasFee.toString ())
157
- ? '0.000'
158
- : estimatedGasFee.gasFee.toString ();
159
-
160
- final result = await showTransactionDialog (context! ,
161
- amount: amount,
162
- balance: sumBalance.toString (),
163
- token: token,
164
- network: state.network? .label ?? '--' ,
165
- from: state.account! .address,
166
- to: recipient,
167
- estimatedFee: estimatedFee,
168
- onTap: (transactionType) => _nextTransactionStep (transactionType),
169
- networkSymbol: state.network? .symbol ?? '--' );
153
+ if (estimatedGasFee != null ) {
154
+ sumBalance -= estimatedGasFee.gasFee;
155
+ final estimatedFee = estimatedGasFee == null
156
+ ? '--'
157
+ : Validation .isExpoNumber (estimatedGasFee.gasFee.toString ())
158
+ ? '0.000'
159
+ : estimatedGasFee.gasFee.toString ();
160
+
161
+ final result = await showTransactionDialog (context! ,
162
+ amount: amount,
163
+ balance: sumBalance.toString (),
164
+ token: token,
165
+ network: state.network? .label ?? '--' ,
166
+ from: state.account! .address,
167
+ to: recipient,
168
+ estimatedFee: estimatedFee,
169
+ onTap: (transactionType) => _nextTransactionStep (transactionType),
170
+ networkSymbol: state.network? .symbol ?? '--' );
171
+ }
170
172
}
171
173
172
174
String ? checkAmountCeiling () {
@@ -203,7 +205,11 @@ class SendCryptoPresenter extends CompletePresenter<SendCryptoState> {
203
205
204
206
return gasFee;
205
207
} catch (e, s) {
206
- addError (e, s);
208
+ if (e is RPCError ) {
209
+ String errorMessage = e.message;
210
+ errorMessage = changeErrorMessage (errorMessage);
211
+ addError (errorMessage);
212
+ }
207
213
} finally {
208
214
loading = false ;
209
215
}
@@ -229,7 +235,7 @@ class SendCryptoPresenter extends CompletePresenter<SendCryptoState> {
229
235
hash: res,
230
236
status: TransactionStatus .pending,
231
237
type: TransactionType .sent,
232
- value: amount.getValueInUnit (EtherUnit .wei).toString (),
238
+ value: amount.getValueInUnitBI (EtherUnit .wei).toString (),
233
239
token: token,
234
240
timeStamp: DateTime .now ());
235
241
@@ -249,16 +255,21 @@ class SendCryptoPresenter extends CompletePresenter<SendCryptoState> {
249
255
BottomFlowDialog .of (context! ).close ();
250
256
}
251
257
String errorMessage = e.message;
252
- if (e.message.contains ('gas required exceeds allowance' )) {
253
- errorMessage = translate ('insufficient_balance_for_fee' ) ?? e.message;
254
- }
258
+ errorMessage = changeErrorMessage (errorMessage);
255
259
addError (errorMessage);
256
260
}
257
261
} finally {
258
262
loading = false ;
259
263
}
260
264
}
261
265
266
+ String changeErrorMessage (String message) {
267
+ if (message.contains ('gas required exceeds allowance' )) {
268
+ return translate ('insufficient_balance_for_fee' ) ?? message;
269
+ }
270
+ return message;
271
+ }
272
+
262
273
@override
263
274
Future <void > dispose () async {
264
275
super .dispose ();
0 commit comments