From cf8f1662dd7d70f3da395eb6cd51d16559313c54 Mon Sep 17 00:00:00 2001 From: gabaldon Date: Fri, 16 Feb 2024 10:53:45 +0100 Subject: [PATCH] fix(test): fix syncronization when master account has no mine tx --- integration_test/test_utils.dart | 2 +- lib/bloc/crypto/crypto_bloc.dart | 35 ++++++++++++++-------------- lib/bloc/explorer/explorer_bloc.dart | 2 +- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/integration_test/test_utils.dart b/integration_test/test_utils.dart index ec5ef2ab..3edb031c 100644 --- a/integration_test/test_utils.dart +++ b/integration_test/test_utils.dart @@ -80,7 +80,7 @@ Future tapButton( case String: finder = widgetByText(value); break; - case IconDataSolid: + case IconData: finder = widgetByIcon(value); break; case PaddedButton: diff --git a/lib/bloc/crypto/crypto_bloc.dart b/lib/bloc/crypto/crypto_bloc.dart index 6fb587d5..175f6c53 100644 --- a/lib/bloc/crypto/crypto_bloc.dart +++ b/lib/bloc/crypto/crypto_bloc.dart @@ -326,23 +326,24 @@ class CryptoBloc extends Bloc { /// retrieve any Block Hashes final addressBlocks = await apiExplorer.address( value: account.address, - tab: 'blocks') as PaginatedRequest; - - /// retrieve each block - for (int i = 0; i < addressBlocks.data.blocks.length; i++) { - BlockInfo blockInfo = addressBlocks.data.blocks.elementAt(i); - String _hash = blockInfo.hash; - var result = await apiExplorer.hash(_hash); - - /// create a MintEntry from the BlockInfo and MintInfo - BlockDetails blockDetails = result as BlockDetails; - MintEntry mintEntry = MintEntry.fromBlockMintInfo( - blockInfo, - blockDetails, - ); - account.mintHashes.add(mintEntry.blockHash); - account.mints.add(mintEntry); - await db.addMint(mintEntry); + tab: 'blocks') as PaginatedRequest; + if (addressBlocks.data != null) { + /// retrieve each block + for (int i = 0; i < addressBlocks.data!.blocks.length; i++) { + BlockInfo blockInfo = addressBlocks.data!.blocks.elementAt(i); + String _hash = blockInfo.hash; + var result = await apiExplorer.hash(_hash); + + /// create a MintEntry from the BlockInfo and MintInfo + BlockDetails blockDetails = result as BlockDetails; + MintEntry mintEntry = MintEntry.fromBlockMintInfo( + blockInfo, + blockDetails, + ); + account.mintHashes.add(mintEntry.blockHash); + account.mints.add(mintEntry); + await db.addMint(mintEntry); + } } return account; } catch (e) { diff --git a/lib/bloc/explorer/explorer_bloc.dart b/lib/bloc/explorer/explorer_bloc.dart index 7c0d19e6..96fd497f 100644 --- a/lib/bloc/explorer/explorer_bloc.dart +++ b/lib/bloc/explorer/explorer_bloc.dart @@ -377,7 +377,7 @@ class ExplorerBloc extends Bloc { if (mintEntry != null) { /// this mintEntry.status check for "confirmed" is in the local database - if (mintEntry.status != "confirmed") { + if (mintEntry.status != TxStatusLabel.confirmed) { MintEntry mintEntry = await explorer.getMint(blockInfo); await account.addMint(mintEntry); }