@@ -5,6 +5,7 @@ import 'package:decimal/decimal.dart';
55import 'package:ethereum_addresses/ethereum_addresses.dart' ;
66import 'package:http/http.dart' ;
77import 'package:isar/isar.dart' ;
8+ import 'package:web3dart/json_rpc.dart' show RPCError;
89import 'package:web3dart/web3dart.dart' as web3;
910
1011import '../../../dto/ethereum/eth_tx_dto.dart' ;
@@ -556,18 +557,24 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface {
556557 await _initCredentials ();
557558 }
558559
559- final txid = await client.sendTransaction (
560- _credentials! ,
561- txData.web3dartTransaction! ,
562- chainId: txData.chainId! .toInt (),
563- );
560+ try {
561+ final txid = await client.sendTransaction (
562+ _credentials! ,
563+ txData.web3dartTransaction! ,
564+ chainId: txData.chainId! .toInt (),
565+ );
564566
565- final data = (prepareTempTx ?? _prepareTempTx)(
566- txData.copyWith (txid: txid, txHash: txid),
567- (await getCurrentReceivingAddress ())! .value,
568- );
567+ final data = (prepareTempTx ?? _prepareTempTx)(
568+ txData.copyWith (txid: txid, txHash: txid),
569+ (await getCurrentReceivingAddress ())! .value,
570+ );
569571
570- return await updateSentCachedTxData (txData: data);
572+ return await updateSentCachedTxData (txData: data);
573+ } on RPCError catch (e) {
574+ final message =
575+ "${e .toString ()}${e .data == null ? "" : e .data .toString ()}" ;
576+ throw Exception (message);
577+ }
571578 }
572579
573580 @override
0 commit comments