add extra check to prevent full failure in case of server indexing issue

This commit is contained in:
julian 2023-10-17 15:26:03 -06:00
parent 4db85cb5f1
commit 0374907ecd

View file

@ -468,7 +468,7 @@ class EthTokenWallet extends ChangeNotifier with EthTokenCache {
} }
final response2 = await EthereumAPI.getEthTokenTransactionsByTxids( final response2 = await EthereumAPI.getEthTokenTransactionsByTxids(
response.value!.map((e) => e.transactionHash).toList(), response.value!.map((e) => e.transactionHash).toSet().toList(),
); );
if (response2.value == null) { if (response2.value == null) {
@ -477,14 +477,25 @@ class EthTokenWallet extends ChangeNotifier with EthTokenCache {
} }
final List<Tuple2<EthTokenTxDto, EthTokenTxExtraDTO>> data = []; final List<Tuple2<EthTokenTxDto, EthTokenTxExtraDTO>> data = [];
for (final tokenDto in response.value!) { for (final tokenDto in response.value!) {
try {
final txExtra = response2.value!.firstWhere(
(e) => e.hash == tokenDto.transactionHash,
);
data.add( data.add(
Tuple2( Tuple2(
tokenDto, tokenDto,
response2.value!.firstWhere( txExtra,
(e) => e.hash == tokenDto.transactionHash,
),
), ),
); );
} catch (_) {
// Server indexing failed for some reason. Instead of hard crashing or
// showing no transactions we just skip it here. Not ideal but better
// than nothing showing up
Logging.instance.log(
"Server error: Transaction ${tokenDto.transactionHash} not found.",
level: LogLevel.Error,
);
}
} }
final List<Tuple2<Transaction, Address?>> txnsData = []; final List<Tuple2<Transaction, Address?>> txnsData = [];