From 797cfb973c49fe2988d4351c9f0a8ae7847ee11f Mon Sep 17 00:00:00 2001 From: Marcin <84280969+nemoforte@users.noreply.github.com> Date: Tue, 26 Mar 2024 09:58:49 +0100 Subject: [PATCH] Feature: Adaptive address prefix (#9) This branch introduces support for a default bech32 address prefix (hrp) queried from the network, and thus specific to each network. Until now, default prefix was hardcoded ('kira'), which was removed in this branch. The new model for the default bech32 prefix was already introduced on Adaptive Default Token feature, which has analogous purpose and was initially intended to implement together. But due to work organization purposes, the Adaptive Bech32 Address Prefix is introduced separately. List of changes: - deleted wallet_details.dart which contained hardcoded default bech32 prefix - created getter "bech32Address" in wallet_address.dart, which extracts the hrp data from QueryTokenAliases or QueryValidators - created "WalletAddress.fromBech32ValidatorsPage()" to enable viewing addresses in ValidatorsPage when not signed in. Also, changed "bech32Hrp" field to optional, because it is needed only to store the bech32 hrp value in case of using this constructor. - cleaned up wallet_address.dart - removed not used and invalid methods related to hex. They were created based on wrong assumptions 2 years ago. - modified tab list controllers, so that each of them requires Wallet Address and uses its getter to get default prefix from Network Module. This change solved bug with broken queries (if network changed, but address in request contained old prefix). - changed "valoperWalletAddress" to String value "valkey", because wallet should only represent signed in user, and valkey prefix should be fetched from network - changed order of tests in identity_registrar_cubit_test.dart to properly simulate the process after implementing My Account access block - cannot get IR data without getting bech32 prefix from network --- .../balances_list_controller.dart | 9 +- .../staking_page/staking_list_controller.dart | 7 +- .../transactions_list_controller.dart | 9 +- .../undelegation_list_controller.dart | 6 +- .../delegations/validator_staking_model.dart | 1 + .../staking_msg_delegate_form_model.dart | 20 +-- .../staking_msg_undelegate_form_model.dart | 18 +-- .../staking/staking_msg_delegate_model.dart | 14 +- .../staking/staking_msg_undelegate_model.dart | 14 +- .../undelegations/undelegation_model.dart | 1 + .../models/validators/validator_model.dart | 11 +- .../validator_simplified_model.dart | 4 +- lib/shared/models/wallet/wallet.dart | 17 +-- lib/shared/models/wallet/wallet_address.dart | 77 +++------- lib/shared/models/wallet/wallet_details.dart | 34 ----- lib/test/utils/test_utils.dart | 15 +- .../balance_page/balance_page.dart | 9 +- .../menu/my_account_page/my_account_page.dart | 4 +- .../staking_page/staking_page.dart | 2 +- .../transactions_page/transactions_page.dart | 7 +- .../undelegations_page.dart | 2 +- .../staking_tx_delegate_page.dart | 3 +- .../staking_tx_undelegate_page.dart | 3 +- .../token_dropdown/token_dropdown_list.dart | 2 +- pubspec.yaml | 2 +- .../api_kira/broadcast_service_test.dart | 5 +- test/unit/blocs/generic/auth_cubit_test.dart | 1 + .../identity_registrar_cubit_test.dart | 60 +++++--- .../create_wallet_drawer_page_cubit_test.dart | 5 +- .../tx_form_builder_cubit_test.dart | 3 +- .../transactions/tx_process_cubit_test.dart | 6 +- .../network_list/network_list_cubit_test.dart | 4 +- .../api/query_transactions_service_test.dart | 4 +- .../api/query_validators_service_test.dart | 8 +- .../api_kira/broadcast_service_test.dart | 13 +- .../staking_filter_options_test.dart | 7 +- .../undelegations_filter_options_test.dart | 7 +- ...fication_requests_filter_options_test.dart | 6 +- .../validators_filter_options_test.dart | 63 ++++---- .../validators_sort_options_test.dart | 137 +++++++++--------- .../identity_registrar/ir_model_test.dart | 9 +- .../staking_msg_delegate_form_model_test.dart | 38 ++--- ...taking_msg_undelegate_form_model_test.dart | 30 ++-- .../shared/models/wallet/keyfile_test.dart | 11 +- .../models/wallet/wallet_address_test.dart | 43 ++---- .../shared/models/wallet/wallet_test.dart | 16 +- .../utils/transactions/tx_utils_test.dart | 4 + 47 files changed, 377 insertions(+), 394 deletions(-) delete mode 100644 lib/shared/models/wallet/wallet_details.dart diff --git a/lib/shared/controllers/menu/my_account_page/balances_page/balances_list_controller.dart b/lib/shared/controllers/menu/my_account_page/balances_page/balances_list_controller.dart index 4a0628a8..34293dad 100644 --- a/lib/shared/controllers/menu/my_account_page/balances_page/balances_list_controller.dart +++ b/lib/shared/controllers/menu/my_account_page/balances_page/balances_list_controller.dart @@ -6,14 +6,15 @@ import 'package:miro/infra/services/api_kira/query_balance_service.dart'; import 'package:miro/infra/services/cache/favourites_cache_service.dart'; import 'package:miro/shared/models/balances/balance_model.dart'; import 'package:miro/shared/models/list/pagination_details_model.dart'; +import 'package:miro/shared/models/wallet/wallet_address.dart'; class BalancesListController implements IListController { final FavouritesCacheService favouriteCacheService = FavouritesCacheService(domainName: 'balances'); final QueryBalanceService queryBalanceService = globalLocator(); - final String address; + final WalletAddress walletAddress; BalancesListController({ - required this.address, + required this.walletAddress, }); @override @@ -27,7 +28,7 @@ class BalancesListController implements IListController { if (favouriteBalances.isNotEmpty) { // TODO(dominik): implement request Balances by name PageData balancesPageData = await queryBalanceService.getBalanceModelList( - QueryBalanceReq(address: address, offset: 0, limit: 500), + QueryBalanceReq(address: walletAddress.bech32Address, offset: 0, limit: 500), forceRequestBool: forceRequestBool, ); @@ -41,7 +42,7 @@ class BalancesListController implements IListController { @override Future> getPageData(PaginationDetailsModel paginationDetailsModel, {bool forceRequestBool = false}) async { PageData balancesPageData = await queryBalanceService.getBalanceModelList( - QueryBalanceReq(address: address, limit: paginationDetailsModel.limit, offset: paginationDetailsModel.offset), + QueryBalanceReq(address: walletAddress.bech32Address, limit: paginationDetailsModel.limit, offset: paginationDetailsModel.offset), forceRequestBool: forceRequestBool, ); return balancesPageData; diff --git a/lib/shared/controllers/menu/my_account_page/staking_page/staking_list_controller.dart b/lib/shared/controllers/menu/my_account_page/staking_page/staking_list_controller.dart index 118744ff..942b9eeb 100644 --- a/lib/shared/controllers/menu/my_account_page/staking_page/staking_list_controller.dart +++ b/lib/shared/controllers/menu/my_account_page/staking_page/staking_list_controller.dart @@ -6,14 +6,15 @@ import 'package:miro/infra/services/api_kira/query_delegations_service.dart'; import 'package:miro/infra/services/cache/favourites_cache_service.dart'; import 'package:miro/shared/models/delegations/validator_staking_model.dart'; import 'package:miro/shared/models/list/pagination_details_model.dart'; +import 'package:miro/shared/models/wallet/wallet_address.dart'; class StakingListController implements IListController { final FavouritesCacheService _favouritesCacheService = FavouritesCacheService(domainName: 'staking'); final QueryDelegationsService _queryDelegationsService = globalLocator(); - final String delegatorAddress; + final WalletAddress walletAddress; StakingListController({ - required this.delegatorAddress, + required this.walletAddress, }); @override @@ -30,7 +31,7 @@ class StakingListController implements IListController { Future> getPageData(PaginationDetailsModel paginationDetailsModel, {bool forceRequestBool = false}) async { PageData stakingPageData = await _queryDelegationsService.getValidatorStakingModelList( QueryDelegationsReq( - delegatorAddress: delegatorAddress, + delegatorAddress: walletAddress.bech32Address, offset: paginationDetailsModel.offset, limit: paginationDetailsModel.limit, ), diff --git a/lib/shared/controllers/menu/my_account_page/transactions_page/transactions_list_controller.dart b/lib/shared/controllers/menu/my_account_page/transactions_page/transactions_list_controller.dart index 1d9d84a3..16be62a4 100644 --- a/lib/shared/controllers/menu/my_account_page/transactions_page/transactions_list_controller.dart +++ b/lib/shared/controllers/menu/my_account_page/transactions_page/transactions_list_controller.dart @@ -9,11 +9,12 @@ import 'package:miro/shared/models/transactions/list/tx_direction_type.dart'; import 'package:miro/shared/models/transactions/list/tx_list_item_model.dart'; import 'package:miro/shared/models/transactions/list/tx_sort_type.dart'; import 'package:miro/shared/models/transactions/list/tx_status_type.dart'; +import 'package:miro/shared/models/wallet/wallet_address.dart'; class TransactionsListController implements IListController { final FavouritesCacheService favouriteCacheService = FavouritesCacheService(domainName: 'transactions'); final QueryTransactionsService queryTransactionsService = globalLocator(); - final String address; + final WalletAddress walletAddress; List? directionFilters; List? statusFilters; @@ -21,7 +22,7 @@ class TransactionsListController implements IListController { DateTime? endDateTime; TransactionsListController({ - required this.address, + required this.walletAddress, }); @override @@ -38,7 +39,7 @@ class TransactionsListController implements IListController { Future> getPageData(PaginationDetailsModel paginationDetailsModel, {bool forceRequestBool = false}) async { PageData transactionsPageData = await queryTransactionsService.getTransactionList( QueryTransactionsReq( - address: address, + address: walletAddress.bech32Address, limit: paginationDetailsModel.limit, offset: paginationDetailsModel.offset, sort: TxSortType.dateDESC, @@ -47,7 +48,7 @@ class TransactionsListController implements IListController { status: statusFilters, direction: directionFilters, ), - forceRequestBool: forceRequestBool, + forceRequestBool: forceRequestBool, ); return transactionsPageData; } diff --git a/lib/shared/controllers/menu/my_account_page/undelegations_page/undelegation_list_controller.dart b/lib/shared/controllers/menu/my_account_page/undelegations_page/undelegation_list_controller.dart index 93b0792c..8a157b8f 100644 --- a/lib/shared/controllers/menu/my_account_page/undelegations_page/undelegation_list_controller.dart +++ b/lib/shared/controllers/menu/my_account_page/undelegations_page/undelegation_list_controller.dart @@ -11,10 +11,10 @@ import 'package:miro/shared/models/wallet/wallet_address.dart'; class UndelegationListController implements IListController { final FavouritesCacheService _favouritesCacheService = FavouritesCacheService(domainName: 'undelegations'); final QueryUndelegationsService _queryUndelegationsService = globalLocator(); - final WalletAddress undelegatorWalletAddress; + final WalletAddress walletAddress; UndelegationListController({ - required this.undelegatorWalletAddress, + required this.walletAddress, }); @override @@ -31,7 +31,7 @@ class UndelegationListController implements IListController { Future> getPageData(PaginationDetailsModel paginationDetailsModel, {bool forceRequestBool = false}) async { PageData undelegationPageData = await _queryUndelegationsService.getUndelegationModelList( QueryUndelegationsReq( - undelegatorAddress: undelegatorWalletAddress.bech32Address, + undelegatorAddress: walletAddress.bech32Address, offset: paginationDetailsModel.offset, limit: paginationDetailsModel.limit, ), diff --git a/lib/shared/models/delegations/validator_staking_model.dart b/lib/shared/models/delegations/validator_staking_model.dart index 97ea99ef..0cbd0918 100644 --- a/lib/shared/models/delegations/validator_staking_model.dart +++ b/lib/shared/models/delegations/validator_staking_model.dart @@ -27,6 +27,7 @@ class ValidatorStakingModel extends AListItem { walletAddress: WalletAddress.fromBech32(delegation.validatorInfo.address), moniker: delegation.validatorInfo.moniker, logo: delegation.validatorInfo.logo, + valkey: delegation.validatorInfo.valkey, ), ); } diff --git a/lib/shared/models/transactions/form_models/staking_msg_delegate_form_model.dart b/lib/shared/models/transactions/form_models/staking_msg_delegate_form_model.dart index c8696523..cb9418d7 100644 --- a/lib/shared/models/transactions/form_models/staking_msg_delegate_form_model.dart +++ b/lib/shared/models/transactions/form_models/staking_msg_delegate_form_model.dart @@ -10,8 +10,8 @@ import 'package:miro/shared/models/wallet/wallet_address.dart'; class StakingMsgDelegateFormModel extends AMsgFormModel { // Form fields + String? _valkey; WalletAddress? _delegatorWalletAddress; - WalletAddress? _valoperWalletAddress; List? _tokenAmountModels; // Values required to be saved to allow editing transaction @@ -20,18 +20,18 @@ class StakingMsgDelegateFormModel extends AMsgFormModel { TokenDenominationModel? tokenDenominationModel; StakingMsgDelegateFormModel({ + String? valkey, WalletAddress? delegatorWalletAddress, - WalletAddress? valoperWalletAddress, List? tokenAmountModels, this.balanceModel, this.tokenAliasModel, this.tokenDenominationModel, - }) : _delegatorWalletAddress = delegatorWalletAddress, - _valoperWalletAddress = valoperWalletAddress, + }) : _valkey = valkey, + _delegatorWalletAddress = delegatorWalletAddress, _tokenAmountModels = tokenAmountModels; /// Method [buildTxMsgModel] throws [Exception] if at least one of the fields: - /// [_delegatorWalletAddress], [_valoperWalletAddress] or [_tokenAmountModels] + /// [_valkey], [_delegatorWalletAddress] or [_tokenAmountModels] /// is not filled (equal null) or [_tokenAmountModels] is empty List. /// @override @@ -41,8 +41,8 @@ class StakingMsgDelegateFormModel extends AMsgFormModel { throw Exception('Cannot build StakingMsgDelegateModel. Form is not valid'); } return StakingMsgDelegateModel( + valkey: _valkey!, delegatorWalletAddress: _delegatorWalletAddress!, - valoperWalletAddress: _valoperWalletAddress!, tokenAmountModels: _tokenAmountModels!, ); } @@ -50,7 +50,7 @@ class StakingMsgDelegateFormModel extends AMsgFormModel { @override bool canBuildTxMsg() { bool amountZeroBool = tokenAmountModels?.length == 1 && tokenAmountModels?.first.getAmountInDefaultDenomination() == Decimal.zero; - bool fieldsFilledBool = _delegatorWalletAddress != null && _valoperWalletAddress != null && tokenAmountModels != null && amountZeroBool == false; + bool fieldsFilledBool = _delegatorWalletAddress != null && _valkey != null && tokenAmountModels != null && amountZeroBool == false; return fieldsFilledBool; } @@ -61,10 +61,10 @@ class StakingMsgDelegateFormModel extends AMsgFormModel { notifyListeners(); } - WalletAddress? get valoperWalletAddress => _valoperWalletAddress; + String? get valkey => _valkey; - set valoperWalletAddress(WalletAddress? validatorWalletAddress) { - _valoperWalletAddress = validatorWalletAddress; + set valoperWalletAddress(String? valkey) { + _valkey = valkey; notifyListeners(); } diff --git a/lib/shared/models/transactions/form_models/staking_msg_undelegate_form_model.dart b/lib/shared/models/transactions/form_models/staking_msg_undelegate_form_model.dart index c1aed7a1..052cfb96 100644 --- a/lib/shared/models/transactions/form_models/staking_msg_undelegate_form_model.dart +++ b/lib/shared/models/transactions/form_models/staking_msg_undelegate_form_model.dart @@ -10,8 +10,8 @@ import 'package:miro/shared/models/wallet/wallet_address.dart'; class StakingMsgUndelegateFormModel extends AMsgFormModel { // Form fields + String? _valkey; WalletAddress? _delegatorWalletAddress; - WalletAddress? _valoperWalletAddress; List? _tokenAmountModels; // Values required to be saved to allow editing transaction @@ -20,18 +20,18 @@ class StakingMsgUndelegateFormModel extends AMsgFormModel { TokenDenominationModel? tokenDenominationModel; StakingMsgUndelegateFormModel({ + String? valkey, WalletAddress? delegatorWalletAddress, - WalletAddress? valoperWalletAddress, List? tokenAmountModels, this.balanceModel, this.tokenAliasModel, this.tokenDenominationModel, - }) : _delegatorWalletAddress = delegatorWalletAddress, - _valoperWalletAddress = valoperWalletAddress, + }) : _valkey = valkey, + _delegatorWalletAddress = delegatorWalletAddress, _tokenAmountModels = tokenAmountModels; /// Method [buildTxMsgModel] throws [Exception] if at least one of the fields: - /// [_delegatorWalletAddress], [_valoperWalletAddress] or [_tokenAmountModels] + /// [_valkey], [_delegatorWalletAddress] or [_tokenAmountModels] /// is not filled (equal null) or [_tokenAmountModels] is empty List. /// @override @@ -41,8 +41,8 @@ class StakingMsgUndelegateFormModel extends AMsgFormModel { throw Exception('Cannot build StakingMsgUndelegateModel. Form is not valid'); } return StakingMsgUndelegateModel( + valkey: _valkey!, delegatorWalletAddress: _delegatorWalletAddress!, - valoperWalletAddress: _valoperWalletAddress!, tokenAmountModels: _tokenAmountModels!, ); } @@ -50,7 +50,7 @@ class StakingMsgUndelegateFormModel extends AMsgFormModel { @override bool canBuildTxMsg() { bool amountZeroBool = tokenAmountModels?.length == 1 && tokenAmountModels?.first.getAmountInDefaultDenomination() == Decimal.zero; - bool fieldsFilledBool = _delegatorWalletAddress != null && _valoperWalletAddress != null && tokenAmountModels != null && amountZeroBool == false; + bool fieldsFilledBool = _delegatorWalletAddress != null && _valkey != null && tokenAmountModels != null && amountZeroBool == false; return fieldsFilledBool; } @@ -61,10 +61,10 @@ class StakingMsgUndelegateFormModel extends AMsgFormModel { notifyListeners(); } - WalletAddress? get valoperWalletAddress => _valoperWalletAddress; + String? get valkey => _valkey; set valoperWalletAddress(WalletAddress? validatorWalletAddress) { - _valoperWalletAddress = validatorWalletAddress; + _valkey = valkey; notifyListeners(); } diff --git a/lib/shared/models/transactions/messages/staking/staking_msg_delegate_model.dart b/lib/shared/models/transactions/messages/staking/staking_msg_delegate_model.dart index 50bfd7cf..e8f9349d 100644 --- a/lib/shared/models/transactions/messages/staking/staking_msg_delegate_model.dart +++ b/lib/shared/models/transactions/messages/staking/staking_msg_delegate_model.dart @@ -14,27 +14,27 @@ import 'package:miro/shared/models/transactions/messages/tx_msg_type.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; class StakingMsgDelegateModel extends ATxMsgModel { + final String valkey; final WalletAddress delegatorWalletAddress; - final WalletAddress valoperWalletAddress; final List tokenAmountModels; const StakingMsgDelegateModel({ + required this.valkey, required this.delegatorWalletAddress, - required this.valoperWalletAddress, required this.tokenAmountModels, }) : super(txMsgType: TxMsgType.msgDelegate); StakingMsgDelegateModel.single({ + required this.valkey, required this.delegatorWalletAddress, - required this.valoperWalletAddress, required TokenAmountModel tokenAmountModel, }) : tokenAmountModels = [tokenAmountModel], super(txMsgType: TxMsgType.msgDelegate); factory StakingMsgDelegateModel.fromMsgDto(MsgDelegate msgDelegate) { return StakingMsgDelegateModel( + valkey: msgDelegate.valoperAddress, delegatorWalletAddress: WalletAddress.fromBech32(msgDelegate.delegatorAddress), - valoperWalletAddress: WalletAddress.fromBech32(msgDelegate.valoperAddress), tokenAmountModels: msgDelegate.amounts .map((Coin coin) => TokenAmountModel( defaultDenominationAmount: Decimal.parse(coin.amount), @@ -48,7 +48,7 @@ class StakingMsgDelegateModel extends ATxMsgModel { ATxMsg toMsgDto() { return MsgDelegate( delegatorAddress: delegatorWalletAddress.bech32Address, - valoperAddress: valoperWalletAddress.bech32Address, + valoperAddress: valkey, amounts: tokenAmountModels.map((TokenAmountModel tokenAmountModel) { return Coin( denom: tokenAmountModel.tokenAliasModel.defaultTokenDenominationModel.name, @@ -72,7 +72,7 @@ class StakingMsgDelegateModel extends ATxMsgModel { @override String? getSubtitle(TxDirectionType txDirectionType) { - return valoperWalletAddress.bech32Address; + return valkey; } @override @@ -81,5 +81,5 @@ class StakingMsgDelegateModel extends ATxMsgModel { } @override - List get props => [delegatorWalletAddress, valoperWalletAddress, tokenAmountModels]; + List get props => [delegatorWalletAddress, valkey, tokenAmountModels]; } diff --git a/lib/shared/models/transactions/messages/staking/staking_msg_undelegate_model.dart b/lib/shared/models/transactions/messages/staking/staking_msg_undelegate_model.dart index aa6f7479..271dc6f4 100644 --- a/lib/shared/models/transactions/messages/staking/staking_msg_undelegate_model.dart +++ b/lib/shared/models/transactions/messages/staking/staking_msg_undelegate_model.dart @@ -14,27 +14,27 @@ import 'package:miro/shared/models/transactions/messages/tx_msg_type.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; class StakingMsgUndelegateModel extends ATxMsgModel { + final String valkey; final WalletAddress delegatorWalletAddress; - final WalletAddress valoperWalletAddress; final List tokenAmountModels; const StakingMsgUndelegateModel({ + required this.valkey, required this.delegatorWalletAddress, - required this.valoperWalletAddress, required this.tokenAmountModels, }) : super(txMsgType: TxMsgType.msgUndelegate); StakingMsgUndelegateModel.single({ + required this.valkey, required this.delegatorWalletAddress, - required this.valoperWalletAddress, required TokenAmountModel tokenAmountModel, }) : tokenAmountModels = [tokenAmountModel], super(txMsgType: TxMsgType.msgUndelegate); factory StakingMsgUndelegateModel.fromMsgDto(MsgUndelegate msgUndelegate) { return StakingMsgUndelegateModel( + valkey: msgUndelegate.valoperAddress, delegatorWalletAddress: WalletAddress.fromBech32(msgUndelegate.delegatorAddress), - valoperWalletAddress: WalletAddress.fromBech32(msgUndelegate.valoperAddress), tokenAmountModels: msgUndelegate.amounts .map((Coin coin) => TokenAmountModel( defaultDenominationAmount: Decimal.parse(coin.amount), @@ -48,7 +48,7 @@ class StakingMsgUndelegateModel extends ATxMsgModel { ATxMsg toMsgDto() { return MsgUndelegate( delegatorAddress: delegatorWalletAddress.bech32Address, - valoperAddress: valoperWalletAddress.bech32Address, + valoperAddress: valkey, amounts: tokenAmountModels.map((TokenAmountModel tokenAmountModel) { return Coin( denom: tokenAmountModel.tokenAliasModel.defaultTokenDenominationModel.name, @@ -72,7 +72,7 @@ class StakingMsgUndelegateModel extends ATxMsgModel { @override String? getSubtitle(TxDirectionType txDirectionType) { - return valoperWalletAddress.bech32Address; + return valkey; } @override @@ -81,5 +81,5 @@ class StakingMsgUndelegateModel extends ATxMsgModel { } @override - List get props => [delegatorWalletAddress, valoperWalletAddress, tokenAmountModels]; + List get props => [delegatorWalletAddress, valkey, tokenAmountModels]; } diff --git a/lib/shared/models/undelegations/undelegation_model.dart b/lib/shared/models/undelegations/undelegation_model.dart index f259e15d..c6c23cb3 100644 --- a/lib/shared/models/undelegations/undelegation_model.dart +++ b/lib/shared/models/undelegations/undelegation_model.dart @@ -29,6 +29,7 @@ class UndelegationModel extends AListItem { walletAddress: WalletAddress.fromBech32(undelegation.validatorInfo.address), moniker: undelegation.validatorInfo.moniker, logo: undelegation.validatorInfo.logo, + valkey: undelegation.validatorInfo.valkey, ), tokens: undelegation.tokens .map((Coin e) => TokenAmountModel( diff --git a/lib/shared/models/validators/validator_model.dart b/lib/shared/models/validators/validator_model.dart index de7d7446..f174d3d2 100644 --- a/lib/shared/models/validators/validator_model.dart +++ b/lib/shared/models/validators/validator_model.dart @@ -11,10 +11,10 @@ class ValidatorModel extends AListItem { final int uptime; final String moniker; final String streak; + final String valkey; final StakingPoolStatus stakingPoolStatus; final ValidatorStatus validatorStatus; final WalletAddress walletAddress; - final WalletAddress valoperWalletAddress; final String? contact; final String? description; final String? logo; @@ -27,10 +27,10 @@ class ValidatorModel extends AListItem { required this.uptime, required this.moniker, required this.streak, + required this.valkey, required this.stakingPoolStatus, required this.validatorStatus, required this.walletAddress, - required this.valoperWalletAddress, this.contact, this.description, this.logo, @@ -50,8 +50,8 @@ class ValidatorModel extends AListItem { streak: validator.streak, stakingPoolStatus: StakingPoolStatus.fromString(validator.stakingPoolStatus), validatorStatus: validatorStatus, - walletAddress: WalletAddress.fromBech32(validator.address), - valoperWalletAddress: WalletAddress.fromBech32(validator.valkey), + walletAddress: WalletAddress.fromBech32ValidatorsPage(validator.address), + valkey: validator.valkey, contact: validator.contact, description: validator.description, logo: validator.logo, @@ -74,6 +74,7 @@ class ValidatorModel extends AListItem { moniker: moniker, logo: logo, website: website, + valkey: valkey, ); static int _calcUptime(Validator validator) { @@ -89,6 +90,6 @@ class ValidatorModel extends AListItem { @override String toString() { - return 'ValidatorModel{top: $top, uptime: $uptime, moniker: $moniker, streak: $streak, stakingPool: $stakingPoolStatus, validatorStatus: $validatorStatus, walletAddress: $walletAddress, valoperWalletAddress: $valoperWalletAddress, contact: $contact, description: $description, logo: $logo, social: $social, website: $website, favourite: $isFavourite}'; + return 'ValidatorModel{top: $top, uptime: $uptime, moniker: $moniker, streak: $streak, valkey: $valkey, stakingPool: $stakingPoolStatus, validatorStatus: $validatorStatus, walletAddress: $walletAddress, contact: $contact, description: $description, logo: $logo, social: $social, website: $website, favourite: $isFavourite}'; } } diff --git a/lib/shared/models/validators/validator_simplified_model.dart b/lib/shared/models/validators/validator_simplified_model.dart index 6a67062f..94ecb341 100644 --- a/lib/shared/models/validators/validator_simplified_model.dart +++ b/lib/shared/models/validators/validator_simplified_model.dart @@ -5,15 +5,17 @@ class ValidatorSimplifiedModel extends Equatable { final WalletAddress walletAddress; final String? logo; final String? moniker; + final String? valkey; final String? website; const ValidatorSimplifiedModel({ required this.walletAddress, this.logo, this.moniker, + this.valkey, this.website, }); @override - List get props => [walletAddress, logo, moniker, website]; + List get props => [walletAddress, logo, moniker, valkey, website]; } diff --git a/lib/shared/models/wallet/wallet.dart b/lib/shared/models/wallet/wallet.dart index 8cf9ed02..fe388a53 100644 --- a/lib/shared/models/wallet/wallet.dart +++ b/lib/shared/models/wallet/wallet.dart @@ -5,7 +5,6 @@ import 'package:equatable/equatable.dart'; import 'package:hex/hex.dart'; import 'package:miro/shared/models/wallet/mnemonic.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; -import 'package:miro/shared/models/wallet/wallet_details.dart'; import 'package:miro/shared/utils/cryptography/secp256k1.dart'; import 'package:pointycastle/export.dart'; @@ -23,14 +22,10 @@ class Wallet extends Equatable { /// The wallet hex private key final Uint8List privateKey; - - /// Blockchain network details - final WalletDetails walletDetails; const Wallet({ required this.address, required this.privateKey, - this.walletDetails = WalletDetails.defaultWalletDetails, }); /// ** HEAVY OPERATION ** @@ -41,7 +36,6 @@ class Wallet extends Equatable { factory Wallet.derive({ required Mnemonic mnemonic, String lastDerivationPathSegment = '0', - WalletDetails walletDetails = WalletDetails.defaultWalletDetails, }) { final int lastDerivationPathSegmentCheck = int.tryParse(lastDerivationPathSegment) ?? -1; if (lastDerivationPathSegmentCheck < 0) { @@ -58,9 +52,8 @@ class Wallet extends Equatable { final Uint8List publicKeyBytes = Secp256k1.privateKeyBytesToPublic(derivedNode.privateKey!); return Wallet( - address: WalletAddress.fromPublicKey(publicKeyBytes, bech32Hrp: walletDetails.bech32Hrp), + address: WalletAddress.fromPublicKey(publicKeyBytes), privateKey: derivedNode.privateKey!, - walletDetails: walletDetails, ); } @@ -73,7 +66,7 @@ class Wallet extends Equatable { privateKey: privateKey, ); } - + /// Returns the associated [publicKey] as an [ECPublicKey] instance. ECPublicKey get ecPublicKey { final ECCurve_secp256k1 secp256k1 = ECCurve_secp256k1(); @@ -81,13 +74,13 @@ class Wallet extends Equatable { final ECPoint? curvePoint = point * ecPrivateKey.d; return ECPublicKey(curvePoint, ECCurve_secp256k1()); } - + /// Returns the associated [privateKey] as an [ECPrivateKey] instance. ECPrivateKey get ecPrivateKey { final BigInt privateKeyInt = BigInt.parse(HEX.encode(privateKey), radix: 16); return ECPrivateKey(privateKeyInt, ECCurve_secp256k1()); } - + @override - List get props => [address, privateKey, walletDetails]; + List get props => [address, privateKey]; } diff --git a/lib/shared/models/wallet/wallet_address.dart b/lib/shared/models/wallet/wallet_address.dart index fcc6e966..ff6b97f1 100644 --- a/lib/shared/models/wallet/wallet_address.dart +++ b/lib/shared/models/wallet/wallet_address.dart @@ -1,85 +1,52 @@ import 'dart:typed_data'; import 'package:equatable/equatable.dart'; -import 'package:miro/shared/utils/crypto_address_parser.dart'; +import 'package:miro/blocs/generic/network_module/network_module_bloc.dart'; +import 'package:miro/config/locator.dart'; import 'package:miro/shared/utils/cryptography/bech32/bech32.dart'; import 'package:miro/shared/utils/cryptography/bech32/bech32_pair.dart'; -import 'package:miro/shared/utils/cryptography/keccak256.dart'; import 'package:miro/shared/utils/cryptography/secp256k1.dart'; /// Represents an wallet address. /// Source: https://github.com/LmFlutterSDK/web3dart/blob/master/lib/src/credentials/address.dart class WalletAddress extends Equatable { - static final RegExp _basicAddress = RegExp('^(0x)?[0-9a-f]{40}', caseSensitive: false); - - /// The length of an ethereum address, in bytes. + /// The length of a wallet address, in bytes. static const int addressByteLength = 20; final Uint8List addressBytes; - final String bech32Hrp; + final String? _bech32Hrp; - /// An ethereum address from the raw address bytes. + /// Stores raw address bytes and allows to create bech32Address based on hrp (human readable part). const WalletAddress({ required this.addressBytes, - required this.bech32Hrp, - }) : assert(addressBytes.length == addressByteLength, 'Address should be $addressByteLength bytes length'); + String? bech32Hrp, + }) : _bech32Hrp = bech32Hrp, + assert(addressBytes.length == addressByteLength, 'Address should be $addressByteLength bytes length'); - /// Constructs an Ethereum address from a public key. The address is formed by + /// Constructs a wallet address from a public key. The address is formed by /// the last 20 bytes of the keccak hash of the public key. - factory WalletAddress.fromPublicKey(Uint8List publicKey, {required String bech32Hrp}) { - return WalletAddress(addressBytes: Secp256k1.publicKeyToAddress(publicKey), bech32Hrp: bech32Hrp); + factory WalletAddress.fromPublicKey(Uint8List publicKey) { + return WalletAddress(addressBytes: Secp256k1.publicKeyToAddress(publicKey)); } + // Hrp data extracted from QueryTokenAliases factory WalletAddress.fromBech32(String bech32Address) { final Bech32Pair bech32pair = Bech32.decode(bech32Address); - return WalletAddress(addressBytes: bech32pair.data, bech32Hrp: bech32pair.hrp); + return WalletAddress(addressBytes: bech32pair.data); } - /// Parses an Ethereum address from the hexadecimal representation. The - /// representation must have a length of 20 bytes (or 40 hexadecimal chars), - /// and can optionally be prefixed with "0x". - /// - /// If [enforceEip55] is true or the address has both uppercase and lowercase - /// chars, the address must be valid according to [EIP 55](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md). - // TODO(dominik): Currently unused. Remove before release - factory WalletAddress.fromHex(String hex, {required String bech32Hrp, bool enforceEip55 = false}) { - if (!_basicAddress.hasMatch(hex)) { - throw ArgumentError.value(hex, 'address', 'Must be a hex string with a length of 40, optionally prefixed with "0x"'); - } - - if (!enforceEip55 && (hex.toUpperCase() == hex || hex.toLowerCase() == hex)) { - return WalletAddress(addressBytes: CryptoAddressParser.hexToBytes(hex), bech32Hrp: bech32Hrp); - } - - // Validates as of EIP 55, https://ethereum.stackexchange.com/a/1379 - final String address = CryptoAddressParser.stripHexPrefix(hex); - final String hash = CryptoAddressParser.bytesToHex(Keccak256.encodeAscii(address.toLowerCase())); - for (int i = 0; i < 40; i++) { - // the nth letter should be uppercase if the nth digit of casemap is 1 - final int hashedPos = int.parse(hash[i], radix: 16); - if ((hashedPos > 7 && address[i].toUpperCase() != address[i]) || (hashedPos <= 7 && address[i].toLowerCase() != address[i])) { - throw ArgumentError('Address has invalid case-characters and is thus not EIP-55 conformant, rejecting. Address was: $hex'); - } - } - - return WalletAddress(addressBytes: CryptoAddressParser.hexToBytes(hex), bech32Hrp: bech32Hrp); - } - - /// A hexadecimal representation of this address, padded to a length of 40 - /// characters or 20 bytes, but not prefixed with "0x". - // TODO(dominik): Currently unused. Remove before release - String get hexWithoutPrefix { - return CryptoAddressParser.stripHexPrefix(hex); + // Hrp data extracted from QueryValidators + factory WalletAddress.fromBech32ValidatorsPage(String bech32Address) { + final Bech32Pair bech32pair = Bech32.decode(bech32Address); + return WalletAddress(addressBytes: bech32pair.data, bech32Hrp: bech32pair.hrp); } - /// A hexadecimal representation of this address, padded to a length of 40 - /// characters or 20 bytes, and prefixed with "0x". - // TODO(dominik): Currently unused. Remove before release - String get hex => CryptoAddressParser.bytesToHex(addressBytes, forcePadLength: 40); - /// Returns the associated [address] as a Bech32 string. - String get bech32Address => Bech32.encode(bech32Hrp, addressBytes); + String get bech32Address { + String bech32Hrp = _bech32Hrp ?? globalLocator().tokenDefaultDenomModel.bech32AddressPrefix!; + return Bech32.encode(bech32Hrp, addressBytes); + } /// Returns the associated [address] as a Bech32 string. String buildBech32AddressShort({required String delimiter}) { @@ -90,5 +57,5 @@ class WalletAddress extends Equatable { } @override - List get props => [bech32Address]; + List get props => [addressBytes]; } diff --git a/lib/shared/models/wallet/wallet_details.dart b/lib/shared/models/wallet/wallet_details.dart deleted file mode 100644 index b4a8f117..00000000 --- a/lib/shared/models/wallet/wallet_details.dart +++ /dev/null @@ -1,34 +0,0 @@ -import 'package:equatable/equatable.dart'; - -/// Contains information about a blockchain network -class WalletDetails extends Equatable { - static const WalletDetails defaultWalletDetails = WalletDetails(bech32Hrp: 'kira', name: 'Kira Network'); - - /// Bech32 human readable part - final String bech32Hrp; - - /// Human readable chain name - final String? name; - - /// Chain icon url - final String? iconUrl; - - /// Default token name - final String? defaultTokenName; - - /// Contains the information of a network. - const WalletDetails({ - required this.bech32Hrp, - this.name = '', - this.iconUrl, - this.defaultTokenName, - }); - - @override - List get props => [ - bech32Hrp, - name, - iconUrl, - defaultTokenName, - ]; -} diff --git a/lib/test/utils/test_utils.dart b/lib/test/utils/test_utils.dart index bb6ff3c3..36034521 100644 --- a/lib/test/utils/test_utils.dart +++ b/lib/test/utils/test_utils.dart @@ -50,10 +50,10 @@ class TestUtils { ); static final NetworkUnknownModel healthyNetworkUnknownModel = NetworkUnknownModel( - connectionStatusType: ConnectionStatusType.disconnected, - uri: Uri.parse('https://healthy.kira.network'), - name: 'healthy-mainnet', - lastRefreshDateTime: defaultLastRefreshDateTime, + connectionStatusType: ConnectionStatusType.disconnected, + uri: Uri.parse('https://healthy.kira.network'), + name: 'healthy-mainnet', + lastRefreshDateTime: defaultLastRefreshDateTime, ); static final NetworkUnknownModel unhealthyNetworkUnknownModel = NetworkUnknownModel( @@ -112,6 +112,13 @@ class TestUtils { lastRefreshDateTime: defaultLastRefreshDateTime, ); + static final NetworkOfflineModel initialNetworkOfflineModel = NetworkOfflineModel( + connectionStatusType: ConnectionStatusType.disconnected, + name: 'offline-mainnet', + uri: Uri.parse('https://offline.kira.network'), + lastRefreshDateTime: defaultLastRefreshDateTime, + ); + static final NetworkOfflineModel networkOfflineModel = NetworkOfflineModel( connectionStatusType: ConnectionStatusType.disconnected, name: 'offline-mainnet', diff --git a/lib/views/pages/menu/my_account_page/balance_page/balance_page.dart b/lib/views/pages/menu/my_account_page/balance_page/balance_page.dart index f8997185..0f48b96c 100644 --- a/lib/views/pages/menu/my_account_page/balance_page/balance_page.dart +++ b/lib/views/pages/menu/my_account_page/balance_page/balance_page.dart @@ -7,17 +7,18 @@ import 'package:miro/shared/controllers/menu/my_account_page/balances_page/balan import 'package:miro/shared/controllers/menu/my_account_page/balances_page/balances_list_controller.dart'; import 'package:miro/shared/controllers/menu/my_account_page/balances_page/balances_sort_options.dart'; import 'package:miro/shared/models/balances/balance_model.dart'; +import 'package:miro/shared/models/wallet/wallet_address.dart'; import 'package:miro/views/pages/menu/my_account_page/balance_page/balance_list_item/balance_list_item_builder.dart'; import 'package:miro/views/pages/menu/my_account_page/balance_page/balance_list_title/balance_list_title.dart'; import 'package:miro/views/widgets/generic/responsive/responsive_value.dart'; import 'package:miro/views/widgets/kira/kira_list/infinity_list/sliver_infinity_list/sliver_infinity_list.dart'; class BalancePage extends StatefulWidget { - final String address; + final WalletAddress walletAddress; final ScrollController parentScrollController; const BalancePage({ - required this.address, + required this.walletAddress, required this.parentScrollController, Key? key, }) : super(key: key); @@ -35,7 +36,7 @@ class _BalancePage extends State { searchComparator: BalancesFilterOptions.search, ); - late final BalancesListController balancesListController = BalancesListController(address: widget.address); + late final BalancesListController balancesListController = BalancesListController(walletAddress: widget.walletAddress); late final FavouritesBloc favouritesBloc = FavouritesBloc( listController: balancesListController, ); @@ -60,7 +61,7 @@ class _BalancePage extends State { balanceModel: balanceModel, scrollController: widget.parentScrollController, ), - listController: BalancesListController(address: widget.address), + listController: balancesListController, scrollController: widget.parentScrollController, singlePageSize: listHeight ~/ itemSize + 5, title: BalanceListTitle(searchBarTextEditingController: searchBarTextEditingController), diff --git a/lib/views/pages/menu/my_account_page/my_account_page.dart b/lib/views/pages/menu/my_account_page/my_account_page.dart index 4f2e703e..9fce5603 100644 --- a/lib/views/pages/menu/my_account_page/my_account_page.dart +++ b/lib/views/pages/menu/my_account_page/my_account_page.dart @@ -75,8 +75,8 @@ class _MyAccountPage extends State with SingleTickerProviderState SliverTabBarView( tabController: tabController, children: [ - BalancePage(address: wallet.address.bech32Address, parentScrollController: scrollController), - TransactionsPage(address: wallet.address.bech32Address, parentScrollController: scrollController), + BalancePage(walletAddress: wallet.address, parentScrollController: scrollController), + TransactionsPage(walletAddress: wallet.address, parentScrollController: scrollController), IdentityRegistrarPage(walletAddress: wallet.address), VerificationRequestsPage(walletAddress: wallet.address, parentScrollController: scrollController), StakingPage(walletAddress: wallet.address), diff --git a/lib/views/pages/menu/my_account_page/staking_page/staking_page.dart b/lib/views/pages/menu/my_account_page/staking_page/staking_page.dart index 76b93ba9..40994665 100644 --- a/lib/views/pages/menu/my_account_page/staking_page/staking_page.dart +++ b/lib/views/pages/menu/my_account_page/staking_page/staking_page.dart @@ -63,7 +63,7 @@ class _StakingPage extends State { validatorStakingModel: validatorStakingModel, scrollController: scrollController, ), - listController: StakingListController(delegatorAddress: widget.walletAddress.bech32Address), + listController: StakingListController(walletAddress: widget.walletAddress), scrollController: scrollController, singlePageSize: listHeight ~/ StakingListItemDesktop.height + 5, hasBackgroundBool: ResponsiveWidget.isLargeScreen(context), diff --git a/lib/views/pages/menu/my_account_page/transactions_page/transactions_page.dart b/lib/views/pages/menu/my_account_page/transactions_page/transactions_page.dart index 6ed7d03c..c08ff6c3 100644 --- a/lib/views/pages/menu/my_account_page/transactions_page/transactions_page.dart +++ b/lib/views/pages/menu/my_account_page/transactions_page/transactions_page.dart @@ -3,6 +3,7 @@ import 'package:miro/config/theme/design_colors.dart'; import 'package:miro/generated/l10n.dart'; import 'package:miro/shared/controllers/menu/my_account_page/transactions_page/transactions_list_controller.dart'; import 'package:miro/shared/models/transactions/list/tx_list_item_model.dart'; +import 'package:miro/shared/models/wallet/wallet_address.dart'; import 'package:miro/views/pages/menu/my_account_page/transactions_page/transaction_list_item/desktop/transaction_list_item_desktop_layout.dart'; import 'package:miro/views/pages/menu/my_account_page/transactions_page/transaction_list_item/transaction_list_item_builder.dart'; import 'package:miro/views/pages/menu/my_account_page/transactions_page/transactions_list_title.dart'; @@ -11,11 +12,11 @@ import 'package:miro/views/widgets/kira/kira_list/sliver_paginated_list/page_siz import 'package:miro/views/widgets/kira/kira_list/sliver_paginated_list/sliver_paginated_list.dart'; class TransactionsPage extends StatefulWidget { - final String address; + final WalletAddress walletAddress; final ScrollController parentScrollController; const TransactionsPage({ - required this.address, + required this.walletAddress, required this.parentScrollController, Key? key, }) : super(key: key); @@ -26,7 +27,7 @@ class TransactionsPage extends StatefulWidget { class _TransactionsPage extends State { final TextEditingController searchBarTextEditingController = TextEditingController(); - late final TransactionsListController transactionsListController = TransactionsListController(address: widget.address); + late final TransactionsListController transactionsListController = TransactionsListController(walletAddress: widget.walletAddress); int pageSize = 10; @override diff --git a/lib/views/pages/menu/my_account_page/undelegations_page/undelegations_page.dart b/lib/views/pages/menu/my_account_page/undelegations_page/undelegations_page.dart index bbeb32f8..d67a043d 100644 --- a/lib/views/pages/menu/my_account_page/undelegations_page/undelegations_page.dart +++ b/lib/views/pages/menu/my_account_page/undelegations_page/undelegations_page.dart @@ -64,7 +64,7 @@ class _UndelegationsPageState extends State { undelegationModel: undelegationModel, ), scrollController: widget.parentScrollController, - listController: UndelegationListController(undelegatorWalletAddress: widget.walletAddress), + listController: UndelegationListController(walletAddress: widget.walletAddress), singlePageSize: listHeight ~/ UndelegationListItemDesktop.height + 5, hasBackgroundBool: ResponsiveWidget.isLargeScreen(context), listHeaderWidget: ResponsiveWidget.isLargeScreen(context) ? listHeaderWidget : null, diff --git a/lib/views/pages/transactions/tx_send/staking_tx_delegate_page/staking_tx_delegate_page.dart b/lib/views/pages/transactions/tx_send/staking_tx_delegate_page/staking_tx_delegate_page.dart index ee8e0851..a9368bc7 100644 --- a/lib/views/pages/transactions/tx_send/staking_tx_delegate_page/staking_tx_delegate_page.dart +++ b/lib/views/pages/transactions/tx_send/staking_tx_delegate_page/staking_tx_delegate_page.dart @@ -10,7 +10,6 @@ import 'package:miro/shared/models/tokens/token_alias_model.dart'; import 'package:miro/shared/models/transactions/form_models/staking_msg_delegate_form_model.dart'; import 'package:miro/shared/models/transactions/messages/tx_msg_type.dart'; import 'package:miro/shared/models/validators/validator_simplified_model.dart'; -import 'package:miro/shared/models/wallet/wallet_address.dart'; import 'package:miro/views/pages/transactions/tx_send/staking_tx_delegate_page/staking_tx_delegate_confirm_dialog.dart'; import 'package:miro/views/pages/transactions/tx_send/staking_tx_delegate_page/staking_tx_delegate_form_dialog.dart'; import 'package:miro/views/widgets/transactions/send/tx_process_wrapper.dart'; @@ -36,7 +35,7 @@ class _StakingTxDelegatePage extends State { txMsgType: TxMsgType.msgDelegate, msgFormModel: StakingMsgDelegateFormModel( delegatorWalletAddress: authCubit.state?.address, - valoperWalletAddress: WalletAddress(addressBytes: widget.validatorSimplifiedModel.walletAddress.addressBytes, bech32Hrp: 'kiravaloper'), + valkey: widget.validatorSimplifiedModel.valkey, ), ); diff --git a/lib/views/pages/transactions/tx_send/staking_tx_undelegate_page/staking_tx_undelegate_page.dart b/lib/views/pages/transactions/tx_send/staking_tx_undelegate_page/staking_tx_undelegate_page.dart index 41e03173..ca085369 100644 --- a/lib/views/pages/transactions/tx_send/staking_tx_undelegate_page/staking_tx_undelegate_page.dart +++ b/lib/views/pages/transactions/tx_send/staking_tx_undelegate_page/staking_tx_undelegate_page.dart @@ -8,7 +8,6 @@ import 'package:miro/config/locator.dart'; import 'package:miro/shared/models/transactions/form_models/staking_msg_undelegate_form_model.dart'; import 'package:miro/shared/models/transactions/messages/tx_msg_type.dart'; import 'package:miro/shared/models/validators/validator_simplified_model.dart'; -import 'package:miro/shared/models/wallet/wallet_address.dart'; import 'package:miro/views/pages/transactions/tx_send/staking_tx_undelegate_page/staking_tx_undelegate_confirm_dialog.dart'; import 'package:miro/views/pages/transactions/tx_send/staking_tx_undelegate_page/staking_tx_undelegate_form_dialog.dart'; import 'package:miro/views/widgets/transactions/send/tx_process_wrapper.dart'; @@ -32,7 +31,7 @@ class _StakingTxUndelegatePage extends State { txMsgType: TxMsgType.msgUndelegate, msgFormModel: StakingMsgUndelegateFormModel( delegatorWalletAddress: authCubit.state?.address, - valoperWalletAddress: WalletAddress(addressBytes: widget.validatorSimplifiedModel.walletAddress.addressBytes, bech32Hrp: 'kiravaloper'), + valkey: widget.validatorSimplifiedModel.valkey, ), ); diff --git a/lib/views/widgets/transactions/token_form/token_dropdown/token_dropdown_list.dart b/lib/views/widgets/transactions/token_form/token_dropdown/token_dropdown_list.dart index 2d906a85..1c74723c 100644 --- a/lib/views/widgets/transactions/token_form/token_dropdown/token_dropdown_list.dart +++ b/lib/views/widgets/transactions/token_form/token_dropdown/token_dropdown_list.dart @@ -40,7 +40,7 @@ class _TokenDropdownList extends State { searchComparator: BalancesFilterOptions.search, ); - late final BalancesListController balancesListController = BalancesListController(address: widget.walletAddress?.bech32Address ?? ''); + late final BalancesListController balancesListController = BalancesListController(walletAddress: widget.walletAddress!); late final FavouritesBloc favouritesBloc = FavouritesBloc( listController: balancesListController, ); diff --git a/pubspec.yaml b/pubspec.yaml index 417cdc83..9c285859 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.25.1 +version: 1.26.0 environment: sdk: ">=3.1.3" diff --git a/test/integration/infra/services/api_kira/broadcast_service_test.dart b/test/integration/infra/services/api_kira/broadcast_service_test.dart index 6a4423f7..ceeafbda 100644 --- a/test/integration/infra/services/api_kira/broadcast_service_test.dart +++ b/test/integration/infra/services/api_kira/broadcast_service_test.dart @@ -30,7 +30,6 @@ import 'package:miro/shared/models/transactions/tx_remote_info_model.dart'; import 'package:miro/shared/models/transactions/unsigned_tx_model.dart'; import 'package:miro/shared/models/wallet/mnemonic.dart'; import 'package:miro/shared/models/wallet/wallet.dart'; -import 'package:miro/shared/models/wallet/wallet_address.dart'; import 'package:miro/shared/utils/network_utils.dart'; import 'package:miro/shared/utils/transactions/tx_utils.dart'; import 'package:miro/test/utils/test_utils.dart'; @@ -235,7 +234,7 @@ Future main() async { feeTokenAmountModel: feeTokenAmountModel, txMsgModel: StakingMsgDelegateModel.single( delegatorWalletAddress: senderWallet.address, - valoperWalletAddress: WalletAddress.fromBech32('kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7'), + valkey: 'kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7', tokenAmountModel: TokenAmountModel( defaultDenominationAmount: Decimal.fromInt(100), tokenAliasModel: TokenAliasModel.local('ukex'), @@ -257,7 +256,7 @@ Future main() async { feeTokenAmountModel: feeTokenAmountModel, txMsgModel: StakingMsgUndelegateModel.single( delegatorWalletAddress: senderWallet.address, - valoperWalletAddress: WalletAddress.fromBech32('kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7'), + valkey: 'kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7', tokenAmountModel: TokenAmountModel(defaultDenominationAmount: Decimal.fromInt(100), tokenAliasModel: TokenAliasModel.local('ukex')), ), ); diff --git a/test/unit/blocs/generic/auth_cubit_test.dart b/test/unit/blocs/generic/auth_cubit_test.dart index b5229053..86070927 100644 --- a/test/unit/blocs/generic/auth_cubit_test.dart +++ b/test/unit/blocs/generic/auth_cubit_test.dart @@ -11,6 +11,7 @@ import 'package:miro/test/utils/test_utils.dart'; // fvm flutter test test/unit/blocs/generic/auth_cubit_test.dart --platform chrome --null-assertions Future main() async { await initMockLocator(); + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); group('Tests of [AuthCubit] process', () { test('Should return states assigned to specific actions', () async { diff --git a/test/unit/blocs/generic/identity_registrar_cubit_test.dart b/test/unit/blocs/generic/identity_registrar_cubit_test.dart index 757511bb..2d5d1dd4 100644 --- a/test/unit/blocs/generic/identity_registrar_cubit_test.dart +++ b/test/unit/blocs/generic/identity_registrar_cubit_test.dart @@ -3,9 +3,6 @@ import 'package:miro/blocs/generic/identity_registrar/a_identity_registrar_state import 'package:miro/blocs/generic/identity_registrar/identity_registrar_cubit.dart'; import 'package:miro/blocs/generic/identity_registrar/states/identity_registrar_loaded_state.dart'; import 'package:miro/blocs/generic/identity_registrar/states/identity_registrar_loading_state.dart'; -import 'package:miro/blocs/generic/network_module/events/network_module_connect_event.dart'; -import 'package:miro/blocs/generic/network_module/network_module_bloc.dart'; -import 'package:miro/config/locator.dart'; import 'package:miro/shared/models/identity_registrar/ir_model.dart'; import 'package:miro/shared/models/identity_registrar/ir_record_model.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; @@ -34,27 +31,13 @@ void main() { // ************************************************************************************************ // Act - await actualIdentityRegistrarCubit.refresh(); + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); actualIdentityRegistrarState = actualIdentityRegistrarCubit.state; // Assert expectedIdentityRegistrarState = const IdentityRegistrarLoadingState(); - TestUtils.printInfo('Should return [IdentityRegistrarLoadingState] if [WalletAddress NOT exists] and [network DISCONNECTED]'); - expect(actualIdentityRegistrarState, expectedIdentityRegistrarState); - - // ************************************************************************************************ - - // Act - await actualIdentityRegistrarCubit.setWalletAddress(TestUtils.wallet.address); - actualIdentityRegistrarState = actualIdentityRegistrarCubit.state; - - // Assert - expectedIdentityRegistrarState = IdentityRegistrarLoadedState( - irModel: IRModel.empty(walletAddress: TestUtils.wallet.address), - ); - - TestUtils.printInfo('Should return [IdentityRegistrarLoadedState] with [EMPTY IRModel] if [WalletAddress exists] but [network DISCONNECTED]'); + TestUtils.printInfo('Should return [IdentityRegistrarLoadingState] if [WalletAddress NOT exists] and [network CONNECTED]'); expect(actualIdentityRegistrarState, expectedIdentityRegistrarState); // ************************************************************************************************ @@ -65,15 +48,14 @@ void main() { // Assert TestUtils.printInfo( - 'Should return [IdentityRegistrarLoadedState] with [EMPTY IRModel] if [WalletAddress exists] but [network DISCONNECTED] and [IdentityRegistrarCubit refreshed]'); + 'Should return [IdentityRegistrarLoadingState] if [WalletAddress NOT exists] and [network CONNECTED] and [IdentityRegistrarCubit refreshed]'); expect(actualIdentityRegistrarState, expectedIdentityRegistrarState); // ************************************************************************************************ // Act - globalLocator().add(NetworkModuleConnectEvent(TestUtils.networkHealthyModel)); + await actualIdentityRegistrarCubit.setWalletAddress(TestUtils.wallet.address); await Future.delayed(const Duration(milliseconds: 100)); - await actualIdentityRegistrarCubit.refresh(); actualIdentityRegistrarState = actualIdentityRegistrarCubit.state; // Assert @@ -116,14 +98,44 @@ void main() { TestUtils.printInfo('Should return [IdentityRegistrarLoadedState] with [FILLED IRModel] if [WalletAddress exists] and [network CONNECTED]'); expect(actualIdentityRegistrarState, expectedIdentityRegistrarState); + // ************************************************************************************************ + // Act await actualIdentityRegistrarCubit.setWalletAddress(null); + await Future.delayed(const Duration(milliseconds: 500)); + actualIdentityRegistrarState = actualIdentityRegistrarCubit.state; // Assert expectedIdentityRegistrarState = const IdentityRegistrarLoadingState(); - TestUtils.printInfo('Should return [IdentityRegistrarLoadingState] if [WalletAddress NOT exists] and [network CONNECTED]'); + TestUtils.printInfo('Should return [IdentityRegistrarLoadingState] if [WalletAddress NOT exists]'); + expect(actualIdentityRegistrarState, expectedIdentityRegistrarState); + + // ************************************************************************************************ + + // Act + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://offline.kira.network')); + actualIdentityRegistrarState = actualIdentityRegistrarCubit.state; + + // Assert + expectedIdentityRegistrarState = const IdentityRegistrarLoadingState(); + + TestUtils.printInfo('Should return [IdentityRegistrarLoadingState] if [WalletAddress NOT exists] and [network DISCONNECTED]'); + expect(actualIdentityRegistrarState, expectedIdentityRegistrarState); + + // ************************************************************************************************ + + // Act + await actualIdentityRegistrarCubit.setWalletAddress(TestUtils.wallet.address); + actualIdentityRegistrarState = actualIdentityRegistrarCubit.state; + + // Assert + expectedIdentityRegistrarState = IdentityRegistrarLoadedState( + irModel: IRModel.empty(walletAddress: TestUtils.wallet.address), + ); + + TestUtils.printInfo('Should return [IdentityRegistrarLoadedState] with [EMPTY IRModel] if [WalletAddress exists] but [network DISCONNECTED]'); expect(actualIdentityRegistrarState, expectedIdentityRegistrarState); // ************************************************************************************************ @@ -134,7 +146,7 @@ void main() { // Assert TestUtils.printInfo( - 'Should return [IdentityRegistrarLoadingState] if [WalletAddress NOT exists] and [network CONNECTED] and [IdentityRegistrarCubit refreshed]'); + 'Should return [IdentityRegistrarLoadedState] with [EMPTY IRModel] if [WalletAddress exists] but [network DISCONNECTED] and [IdentityRegistrarCubit refreshed]'); expect(actualIdentityRegistrarState, expectedIdentityRegistrarState); }); }); diff --git a/test/unit/blocs/pages/drawer/create_wallet_drawer_page_cubit_test.dart b/test/unit/blocs/pages/drawer/create_wallet_drawer_page_cubit_test.dart index 0b114619..2cfb74fe 100644 --- a/test/unit/blocs/pages/drawer/create_wallet_drawer_page_cubit_test.dart +++ b/test/unit/blocs/pages/drawer/create_wallet_drawer_page_cubit_test.dart @@ -10,8 +10,9 @@ import 'package:miro/test/utils/test_utils.dart'; // To run this test type in console: // fvm flutter test test/unit/blocs/pages/drawer/create_wallet_drawer_page_cubit_test.dart --platform chrome --null-assertions -void main() { - initMockLocator(); +Future main() async { + await initMockLocator(); + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); group('Tests of [CreateWalletDrawerPageCubit] process', () { test('Should return [ACreateWalletDrawerPageState] consistent with current action', () async { diff --git a/test/unit/blocs/pages/transactions/tx_form_builder_cubit_test.dart b/test/unit/blocs/pages/transactions/tx_form_builder_cubit_test.dart index bb99fc3d..bfe961c0 100644 --- a/test/unit/blocs/pages/transactions/tx_form_builder_cubit_test.dart +++ b/test/unit/blocs/pages/transactions/tx_form_builder_cubit_test.dart @@ -21,6 +21,7 @@ import 'mock_data/mock_msg_form_model.dart'; // fvm flutter test test/unit/blocs/pages/transactions/tx_form_builder_cubit_test.dart --platform chrome --null-assertions Future main() async { await initMockLocator(); + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); AuthCubit authCubit = globalLocator(); @@ -128,7 +129,7 @@ Future main() async { // Assert TestUtils.printInfo('Should [throw Exception] if [ALL required fields EMPTY] (UnsignedTxModel cannot be built)'); expect( - () => actualTxFormBuilderCubit.buildUnsignedTx(), + () => actualTxFormBuilderCubit.buildUnsignedTx(), throwsA(isA()), ); diff --git a/test/unit/blocs/pages/transactions/tx_process_cubit_test.dart b/test/unit/blocs/pages/transactions/tx_process_cubit_test.dart index 65c43df3..bb909b80 100644 --- a/test/unit/blocs/pages/transactions/tx_process_cubit_test.dart +++ b/test/unit/blocs/pages/transactions/tx_process_cubit_test.dart @@ -25,8 +25,9 @@ import 'package:miro/test/utils/test_utils.dart'; // To run this test type in console: // fvm flutter test test/unit/blocs/pages/transactions/tx_process_cubit_test.dart --platform chrome --null-assertions -void main() { - initMockLocator(); +Future main() async { + await initMockLocator(); + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); AuthCubit actualAuthCubit = globalLocator(); SignedTxModel signedTxModel = SignedTxModel( @@ -75,7 +76,6 @@ void main() { // Act await actualAuthCubit.signIn(TestUtils.wallet); - await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); await actualTxProcessCubit.init(); // Assert diff --git a/test/unit/blocs/widgets/network_list/network_list_cubit_test.dart b/test/unit/blocs/widgets/network_list/network_list_cubit_test.dart index 815df0a1..82d03832 100644 --- a/test/unit/blocs/widgets/network_list/network_list_cubit_test.dart +++ b/test/unit/blocs/widgets/network_list/network_list_cubit_test.dart @@ -58,7 +58,7 @@ Future main() async { expectedNetworkListState = NetworkListLoadedState(networkStatusModelList: [ TestUtils.networkUnhealthyModel, TestUtils.networkHealthyModel, - TestUtils.networkOfflineModel, + TestUtils.initialNetworkOfflineModel, ]); TestUtils.printInfo('Should return NetworkListLoadedState containing ANetworkStatusModels list with disconnected status'); @@ -77,7 +77,7 @@ Future main() async { expectedNetworkListState = NetworkListLoadedState(networkStatusModelList: [ TestUtils.networkUnhealthyModel, TestUtils.networkHealthyModel.copyWith(connectionStatusType: ConnectionStatusType.connected), - TestUtils.networkOfflineModel, + TestUtils.initialNetworkOfflineModel, ]); TestUtils.printInfo( diff --git a/test/unit/infra/services/api/query_transactions_service_test.dart b/test/unit/infra/services/api/query_transactions_service_test.dart index a185972e..05b5eae7 100644 --- a/test/unit/infra/services/api/query_transactions_service_test.dart +++ b/test/unit/infra/services/api/query_transactions_service_test.dart @@ -193,7 +193,7 @@ Future main() async { txMsgModels: [ StakingMsgDelegateModel( delegatorWalletAddress: WalletAddress.fromBech32('kira143q8vxpvuykt9pq50e6hng9s38vmy844n8k9wx'), - valoperWalletAddress: WalletAddress.fromBech32('kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7'), + valkey: 'kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7', tokenAmountModels: [ TokenAmountModel(defaultDenominationAmount: Decimal.fromInt(100), tokenAliasModel: TokenAliasModel.local('ukex')) ], @@ -218,7 +218,7 @@ Future main() async { txMsgModels: [ StakingMsgUndelegateModel( delegatorWalletAddress: WalletAddress.fromBech32('kira143q8vxpvuykt9pq50e6hng9s38vmy844n8k9wx'), - valoperWalletAddress: WalletAddress.fromBech32('kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7'), + valkey: 'kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7', tokenAmountModels: [ TokenAmountModel(defaultDenominationAmount: Decimal.fromInt(100), tokenAliasModel: TokenAliasModel.local('ukex')) ], diff --git a/test/unit/infra/services/api/query_validators_service_test.dart b/test/unit/infra/services/api/query_validators_service_test.dart index f0f58980..a43cbb91 100644 --- a/test/unit/infra/services/api/query_validators_service_test.dart +++ b/test/unit/infra/services/api/query_validators_service_test.dart @@ -49,7 +49,7 @@ Future main() async { stakingPoolStatus: StakingPoolStatus.enabled, validatorStatus: ValidatorStatus.active, walletAddress: WalletAddress.fromBech32('kira1fffuhtsuc6qskp4tsy5ptjssshynacj462ptdy'), - valoperWalletAddress: WalletAddress.fromBech32('kiravaloper1fffuhtsuc6qskp4tsy5ptjssshynacj4fvag4g'), + valkey: 'kiravaloper1fffuhtsuc6qskp4tsy5ptjssshynacj4fvag4g', ), ValidatorModel( top: 2, @@ -59,7 +59,7 @@ Future main() async { stakingPoolStatus: StakingPoolStatus.withdraw, validatorStatus: ValidatorStatus.active, walletAddress: WalletAddress.fromBech32('kira1gfqq3kqn7tuhnpph4487d57c00dkptt3hefgkk'), - valoperWalletAddress: WalletAddress.fromBech32('kiravaloper1gfqq3kqn7tuhnpph4487d57c00dkptt3yl4tw6'), + valkey: 'kiravaloper1gfqq3kqn7tuhnpph4487d57c00dkptt3yl4tw6', ), ValidatorModel( top: 3, @@ -69,7 +69,7 @@ Future main() async { stakingPoolStatus: StakingPoolStatus.disabled, validatorStatus: ValidatorStatus.active, walletAddress: WalletAddress.fromBech32('kira13hrpqkv53t82n2e72kfr3kuvvvr3565p234g3g'), - valoperWalletAddress: WalletAddress.fromBech32('kiravaloper13hrpqkv53t82n2e72kfr3kuvvvr3565pehftfy'), + valkey: 'kiravaloper13hrpqkv53t82n2e72kfr3kuvvvr3565pehftfy', ), ], ); @@ -123,7 +123,7 @@ Future main() async { top: 44, uptime: 98, walletAddress: WalletAddress.fromBech32('kira1vxvugjt7u0lpzgkpv5hr7qwu2v4rx64d597s3l'), - valoperWalletAddress: WalletAddress.fromBech32('kiravaloper1vxvugjt7u0lpzgkpv5hr7qwu2v4rx64d8rznfn'), + valkey: 'kiravaloper1vxvugjt7u0lpzgkpv5hr7qwu2v4rx64d8rznfn', moniker: 'medium', streak: '1167583', validatorStatus: ValidatorStatus.active, diff --git a/test/unit/infra/services/api_kira/broadcast_service_test.dart b/test/unit/infra/services/api_kira/broadcast_service_test.dart index 725935d2..c7bd8429 100644 --- a/test/unit/infra/services/api_kira/broadcast_service_test.dart +++ b/test/unit/infra/services/api_kira/broadcast_service_test.dart @@ -1,7 +1,7 @@ import 'package:decimal/decimal.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:miro/blocs/generic/network_module/events/network_module_auto_connect_event.dart'; import 'package:miro/blocs/generic/network_module/events/network_module_connect_event.dart'; -import 'package:miro/blocs/generic/network_module/events/network_module_disconnect_event.dart'; import 'package:miro/blocs/generic/network_module/network_module_bloc.dart'; import 'package:miro/blocs/generic/network_module/network_module_state.dart'; import 'package:miro/config/locator.dart'; @@ -32,7 +32,6 @@ import 'package:miro/shared/models/transactions/tx_remote_info_model.dart'; import 'package:miro/shared/models/transactions/unsigned_tx_model.dart'; import 'package:miro/shared/models/wallet/mnemonic.dart'; import 'package:miro/shared/models/wallet/wallet.dart'; -import 'package:miro/shared/models/wallet/wallet_address.dart'; import 'package:miro/shared/utils/network_utils.dart'; import 'package:miro/shared/utils/transactions/tx_utils.dart'; import 'package:miro/test/mock_locator.dart'; @@ -602,8 +601,8 @@ Future main() async { memo: 'Test of MsgDelegate message', feeTokenAmountModel: feeTokenAmountModel, txMsgModel: StakingMsgDelegateModel.single( + valkey: 'kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7', delegatorWalletAddress: senderWallet.address, - valoperWalletAddress: WalletAddress.fromBech32('kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7'), tokenAmountModel: TokenAmountModel( defaultDenominationAmount: Decimal.fromInt(100), tokenAliasModel: TokenAliasModel.local('ukex'), @@ -693,8 +692,8 @@ Future main() async { memo: 'Test of MsgUndelegate message', feeTokenAmountModel: feeTokenAmountModel, txMsgModel: StakingMsgUndelegateModel.single( + valkey: 'kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7', delegatorWalletAddress: senderWallet.address, - valoperWalletAddress: WalletAddress.fromBech32('kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7'), tokenAmountModel: TokenAmountModel( defaultDenominationAmount: Decimal.fromInt(100), tokenAliasModel: TokenAliasModel.local('ukex'), @@ -972,13 +971,13 @@ Future main() async { NetworkModuleBloc networkModuleBloc = globalLocator(); // Act - networkModuleBloc.add(NetworkModuleDisconnectEvent()); + networkModuleBloc.add(NetworkModuleAutoConnectEvent(TestUtils.offlineNetworkUnknownModel)); await Future.delayed(const Duration(milliseconds: 500)); // Assert - NetworkModuleState expectedNetworkModuleState = NetworkModuleState.disconnected(); + NetworkModuleState expectedNetworkModuleState = NetworkModuleState.connected(TestUtils.networkOfflineModel); - TestUtils.printInfo('Should return [NetworkModuleState.disconnected()]'); + TestUtils.printInfo('Should return [NetworkModuleState.connected with NetworkOfflineModel]'); expect(networkModuleBloc.state, expectedNetworkModuleState); // **************************************************************************************** diff --git a/test/unit/shared/controllers/menu/my_acount_page/staking_page/staking_filter_options_test.dart b/test/unit/shared/controllers/menu/my_acount_page/staking_page/staking_filter_options_test.dart index 8e01683a..207c625b 100644 --- a/test/unit/shared/controllers/menu/my_acount_page/staking_page/staking_filter_options_test.dart +++ b/test/unit/shared/controllers/menu/my_acount_page/staking_page/staking_filter_options_test.dart @@ -6,10 +6,15 @@ import 'package:miro/shared/models/tokens/token_alias_model.dart'; import 'package:miro/shared/models/validators/staking_pool_status.dart'; import 'package:miro/shared/models/validators/validator_simplified_model.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; +import 'package:miro/test/mock_locator.dart'; +import 'package:miro/test/utils/test_utils.dart'; // To run this test type in console: // fvm flutter test test/unit/shared/controllers/menu/my_acount_page/staking_page/staking_filter_options_test.dart --platform chrome --null-assertions -void main() { +Future main() async { + await initMockLocator(); + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); + final ValidatorSimplifiedModel validatorSimplifiedModel1 = ValidatorSimplifiedModel( walletAddress: WalletAddress.fromBech32('kira1ymx5gpvswq0cmj6zkdxwa233sdgq2k5zzfge8w'), moniker: 'GENESIS VALIDATOR', diff --git a/test/unit/shared/controllers/menu/my_acount_page/undelegations_page/undelegations_filter_options_test.dart b/test/unit/shared/controllers/menu/my_acount_page/undelegations_page/undelegations_filter_options_test.dart index 378f26bf..d68c8fbe 100644 --- a/test/unit/shared/controllers/menu/my_acount_page/undelegations_page/undelegations_filter_options_test.dart +++ b/test/unit/shared/controllers/menu/my_acount_page/undelegations_page/undelegations_filter_options_test.dart @@ -7,10 +7,15 @@ import 'package:miro/shared/models/tokens/token_amount_model.dart'; import 'package:miro/shared/models/undelegations/undelegation_model.dart'; import 'package:miro/shared/models/validators/validator_simplified_model.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; +import 'package:miro/test/mock_locator.dart'; +import 'package:miro/test/utils/test_utils.dart'; // To run this test type in console: // fvm flutter test test/unit/shared/controllers/menu/my_acount_page/undelegations_page/undelegations_filter_options_test.dart --platform chrome --null-assertions -void main() { +Future main() async { + await initMockLocator(); + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); + final ValidatorSimplifiedModel validatorSimplifiedModel1 = ValidatorSimplifiedModel( walletAddress: WalletAddress.fromBech32('kira1ymx5gpvswq0cmj6zkdxwa233sdgq2k5zzfge8w'), moniker: 'GENESIS VALIDATOR', diff --git a/test/unit/shared/controllers/menu/my_acount_page/verification_requests_page/verification_requests_filter_options_test.dart b/test/unit/shared/controllers/menu/my_acount_page/verification_requests_page/verification_requests_filter_options_test.dart index 2299b92f..0c09a873 100644 --- a/test/unit/shared/controllers/menu/my_acount_page/verification_requests_page/verification_requests_filter_options_test.dart +++ b/test/unit/shared/controllers/menu/my_acount_page/verification_requests_page/verification_requests_filter_options_test.dart @@ -6,11 +6,15 @@ import 'package:miro/shared/models/identity_registrar/ir_inbound_verification_re import 'package:miro/shared/models/identity_registrar/ir_user_profile_model.dart'; import 'package:miro/shared/models/tokens/token_amount_model.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; +import 'package:miro/test/mock_locator.dart'; import 'package:miro/test/utils/test_utils.dart'; // To run this test type in console: // fvm flutter test test/unit/shared/controllers/menu/my_acount_page/verification_requests_page/verification_requests_filter_options_test.dart --platform chrome --null-assertions -void main() { +Future main() async { + await initMockLocator(); + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); + final IRUserProfileModel irUserProfileModel1 = IRUserProfileModel( walletAddress: WalletAddress.fromBech32('kira143q8vxpvuykt9pq50e6hng9s38vmy844n8k9wx'), username: 'somnitear', diff --git a/test/unit/shared/controllers/menu/validators_page/validators_filter_options_test.dart b/test/unit/shared/controllers/menu/validators_page/validators_filter_options_test.dart index e7e7afc5..7dccb2e7 100644 --- a/test/unit/shared/controllers/menu/validators_page/validators_filter_options_test.dart +++ b/test/unit/shared/controllers/menu/validators_page/validators_filter_options_test.dart @@ -5,8 +5,15 @@ import 'package:miro/shared/models/validators/staking_pool_status.dart'; import 'package:miro/shared/models/validators/validator_model.dart'; import 'package:miro/shared/models/validators/validator_status.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; +import 'package:miro/test/mock_locator.dart'; +import 'package:miro/test/utils/test_utils.dart'; + +// To run this test type in console: +// fvm flutter test test/unit/shared/controllers/menu/validators_page/validators_filter_options_test.dart --platform chrome --null-assertions +Future main() async { + await initMockLocator(); + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); -void main() { WalletAddress walletAddress1 = WalletAddress.fromBech32('kira1fffuhtsuc6qskp4tsy5ptjssshynacj462ptdy'); WalletAddress walletAddress2 = WalletAddress.fromBech32('kira1gfqq3kqn7tuhnpph4487d57c00dkptt3hefgkk'); WalletAddress walletAddress3 = WalletAddress.fromBech32('kira13hrpqkv53t82n2e72kfr3kuvvvr3565p234g3g'); @@ -16,24 +23,24 @@ void main() { WalletAddress walletAddress7 = WalletAddress.fromBech32('kira19l6sa78vw6sr85ktujy9nps9kq7j3pnmeppkqp'); WalletAddress walletAddress8 = WalletAddress.fromBech32('kira1zcptq6kkzp7dcu6a5r9hqd84g8xtrdx3mvnv8s'); - WalletAddress valoperWalletAddress1 = WalletAddress.fromBech32('kiravaloper1fffuhtsuc6qskp4tsy5ptjssshynacj4fvag4g'); - WalletAddress valoperWalletAddress2 = WalletAddress.fromBech32('kiravaloper1gfqq3kqn7tuhnpph4487d57c00dkptt3yl4tw6'); - WalletAddress valoperWalletAddress3 = WalletAddress.fromBech32('kiravaloper13hrpqkv53t82n2e72kfr3kuvvvr3565pehftfy'); - WalletAddress valoperWalletAddress4 = WalletAddress.fromBech32('kiravaloper1ydv40l75gy83x6lgy3gq08nn5ylxmf2f6kztaj'); - WalletAddress valoperWalletAddress5 = WalletAddress.fromBech32('kiravaloper154a6j42c8dtafrnpcxhf6rnemkqh3ehvm9s5zl'); - WalletAddress valoperWalletAddress6 = WalletAddress.fromBech32('kiravaloper14pkvvmxx6g7gay7cxl65zseazs0zjhh2lyqldy'); - WalletAddress valoperWalletAddress7 = WalletAddress.fromBech32('kiravaloper19l6sa78vw6sr85ktujy9nps9kq7j3pnm28a4cd'); - WalletAddress valoperWalletAddress8 = WalletAddress.fromBech32('kiravaloper1zcptq6kkzp7dcu6a5r9hqd84g8xtrdx3g200lu'); + String valkey1 = 'kiravaloper1fffuhtsuc6qskp4tsy5ptjssshynacj4fvag4g'; + String valkey2 = 'kiravaloper1gfqq3kqn7tuhnpph4487d57c00dkptt3yl4tw6'; + String valkey3 = 'kiravaloper13hrpqkv53t82n2e72kfr3kuvvvr3565pehftfy'; + String valkey4 = 'kiravaloper1ydv40l75gy83x6lgy3gq08nn5ylxmf2f6kztaj'; + String valkey5 = 'kiravaloper154a6j42c8dtafrnpcxhf6rnemkqh3ehvm9s5zl'; + String valkey6 = 'kiravaloper14pkvvmxx6g7gay7cxl65zseazs0zjhh2lyqldy'; + String valkey7 = 'kiravaloper19l6sa78vw6sr85ktujy9nps9kq7j3pnm28a4cd'; + String valkey8 = 'kiravaloper1zcptq6kkzp7dcu6a5r9hqd84g8xtrdx3g200lu'; List validatorsList = [ - ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple5', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valoperWalletAddress: valoperWalletAddress1), - ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana4', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress2), - ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut3', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress3), - ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen2', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress4), - ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig1', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valoperWalletAddress: valoperWalletAddress5), - ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape2', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress6), - ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry3', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress7), - ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice4', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress8), + ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple5', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valkey: valkey1), + ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana4', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey2), + ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut3', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey3), + ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen2', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey4), + ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig1', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valkey: valkey5), + ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape2', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey6), + ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry3', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey7), + ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice4', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey8), ]; group('Tests of filterByActiveValidators', () { @@ -46,8 +53,8 @@ void main() { // Assert List expectedValidatorsList = [ - ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple5', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valoperWalletAddress: valoperWalletAddress1), - ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig1', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valoperWalletAddress: valoperWalletAddress5), + ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple5', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valkey: valkey1), + ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig1', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valkey: valkey5), ]; expect(actualValidatorsList, expectedValidatorsList); @@ -64,8 +71,8 @@ void main() { // Assert List expectedValidatorsList = [ - ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana4', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress2), - ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape2', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress6), + ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana4', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey2), + ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape2', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey6), ]; expect(actualValidatorsList, expectedValidatorsList); @@ -82,8 +89,8 @@ void main() { // Assert List expectedValidatorsList = [ - ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut3', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress3), - ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry3', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress7), + ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut3', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey3), + ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry3', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey7), ]; expect(actualValidatorsList, expectedValidatorsList); @@ -100,8 +107,8 @@ void main() { // Assert List expectedValidatorsList = [ - ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen2', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress4), - ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice4', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress8), + ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen2', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey4), + ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice4', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey8), ]; expect(actualValidatorsList, expectedValidatorsList); @@ -118,7 +125,7 @@ void main() { // Assert List expectedValidatorsList = [ - ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple5', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valoperWalletAddress: valoperWalletAddress1), + ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple5', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valkey: valkey1), ]; expect(actualValidatorsList, expectedValidatorsList); @@ -133,8 +140,8 @@ void main() { // Assert List expectedValidatorsList = [ - ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple5', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valoperWalletAddress: valoperWalletAddress1), - ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig1', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valoperWalletAddress: valoperWalletAddress5), + ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple5', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valkey: valkey1), + ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig1', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valkey: valkey5), ]; expect(actualValidatorsList, expectedValidatorsList); diff --git a/test/unit/shared/controllers/menu/validators_page/validators_sort_options_test.dart b/test/unit/shared/controllers/menu/validators_page/validators_sort_options_test.dart index 7333ccdf..f3117fdd 100644 --- a/test/unit/shared/controllers/menu/validators_page/validators_sort_options_test.dart +++ b/test/unit/shared/controllers/menu/validators_page/validators_sort_options_test.dart @@ -4,8 +4,15 @@ import 'package:miro/shared/models/validators/staking_pool_status.dart'; import 'package:miro/shared/models/validators/validator_model.dart'; import 'package:miro/shared/models/validators/validator_status.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; +import 'package:miro/test/mock_locator.dart'; +import 'package:miro/test/utils/test_utils.dart'; + +// To run this test type in console: +// fvm flutter test test/unit/shared/controllers/menu/validators_page/validators_sort_options_test.dart --platform chrome --null-assertions +Future main() async { + await initMockLocator(); + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); -void main() { WalletAddress walletAddress1 = WalletAddress.fromBech32('kira1fffuhtsuc6qskp4tsy5ptjssshynacj462ptdy'); WalletAddress walletAddress2 = WalletAddress.fromBech32('kira1gfqq3kqn7tuhnpph4487d57c00dkptt3hefgkk'); WalletAddress walletAddress3 = WalletAddress.fromBech32('kira13hrpqkv53t82n2e72kfr3kuvvvr3565p234g3g'); @@ -15,24 +22,24 @@ void main() { WalletAddress walletAddress7 = WalletAddress.fromBech32('kira19l6sa78vw6sr85ktujy9nps9kq7j3pnmeppkqp'); WalletAddress walletAddress8 = WalletAddress.fromBech32('kira1zcptq6kkzp7dcu6a5r9hqd84g8xtrdx3mvnv8s'); - WalletAddress valoperWalletAddress1 = WalletAddress.fromBech32('kiravaloper1fffuhtsuc6qskp4tsy5ptjssshynacj4fvag4g'); - WalletAddress valoperWalletAddress2 = WalletAddress.fromBech32('kiravaloper1gfqq3kqn7tuhnpph4487d57c00dkptt3yl4tw6'); - WalletAddress valoperWalletAddress3 = WalletAddress.fromBech32('kiravaloper13hrpqkv53t82n2e72kfr3kuvvvr3565pehftfy'); - WalletAddress valoperWalletAddress4 = WalletAddress.fromBech32('kiravaloper1ydv40l75gy83x6lgy3gq08nn5ylxmf2f6kztaj'); - WalletAddress valoperWalletAddress5 = WalletAddress.fromBech32('kiravaloper154a6j42c8dtafrnpcxhf6rnemkqh3ehvm9s5zl'); - WalletAddress valoperWalletAddress6 = WalletAddress.fromBech32('kiravaloper14pkvvmxx6g7gay7cxl65zseazs0zjhh2lyqldy'); - WalletAddress valoperWalletAddress7 = WalletAddress.fromBech32('kiravaloper19l6sa78vw6sr85ktujy9nps9kq7j3pnm28a4cd'); - WalletAddress valoperWalletAddress8 = WalletAddress.fromBech32('kiravaloper1zcptq6kkzp7dcu6a5r9hqd84g8xtrdx3g200lu'); + String valkey1 = 'kiravaloper1fffuhtsuc6qskp4tsy5ptjssshynacj4fvag4g'; + String valkey2 = 'kiravaloper1gfqq3kqn7tuhnpph4487d57c00dkptt3yl4tw6'; + String valkey3 = 'kiravaloper13hrpqkv53t82n2e72kfr3kuvvvr3565pehftfy'; + String valkey4 = 'kiravaloper1ydv40l75gy83x6lgy3gq08nn5ylxmf2f6kztaj'; + String valkey5 = 'kiravaloper154a6j42c8dtafrnpcxhf6rnemkqh3ehvm9s5zl'; + String valkey6 = 'kiravaloper14pkvvmxx6g7gay7cxl65zseazs0zjhh2lyqldy'; + String valkey7 = 'kiravaloper19l6sa78vw6sr85ktujy9nps9kq7j3pnm28a4cd'; + String valkey8 = 'kiravaloper1zcptq6kkzp7dcu6a5r9hqd84g8xtrdx3g200lu'; List validatorsList = [ - ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valoperWalletAddress: valoperWalletAddress1), - ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress2), - ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress3), - ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress4), - ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valoperWalletAddress: valoperWalletAddress5), - ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress6), - ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress7), - ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress8), + ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valkey: valkey1), + ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey2), + ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey3), + ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey4), + ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valkey: valkey5), + ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey6), + ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey7), + ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey8), ]; group('Tests of sortByTop', () { @@ -42,14 +49,14 @@ void main() { // Assert List expectedValidatorsList = [ - ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valoperWalletAddress: valoperWalletAddress1), - ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress2), - ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress3), - ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress4), - ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valoperWalletAddress: valoperWalletAddress5), - ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress6), - ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress7), - ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress8), + ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valkey: valkey1), + ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey2), + ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey3), + ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey4), + ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valkey: valkey5), + ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey6), + ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey7), + ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey8), ]; expect(actualValidatorsList, expectedValidatorsList); @@ -61,14 +68,14 @@ void main() { // Assert List expectedValidatorsList = [ - ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress8), - ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress7), - ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress6), - ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valoperWalletAddress: valoperWalletAddress5), - ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress4), - ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress3), - ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress2), - ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valoperWalletAddress: valoperWalletAddress1), + ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey8), + ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey7), + ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey6), + ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valkey: valkey5), + ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey4), + ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey3), + ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey2), + ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valkey: valkey1), ]; expect(actualValidatorsList, expectedValidatorsList); @@ -82,14 +89,14 @@ void main() { // Assert List expectedValidatorsList = [ - ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valoperWalletAddress: valoperWalletAddress1), - ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress2), - ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress3), - ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress4), - ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valoperWalletAddress: valoperWalletAddress5), - ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress6), - ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress7), - ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress8), + ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valkey: valkey1), + ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey2), + ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey3), + ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey4), + ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valkey: valkey5), + ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey6), + ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey7), + ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey8), ]; expect(actualValidatorsList, expectedValidatorsList); @@ -101,14 +108,14 @@ void main() { // Assert List expectedValidatorsList = [ - ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress8), - ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress7), - ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress6), - ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valoperWalletAddress: valoperWalletAddress5), - ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress4), - ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress3), - ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress2), - ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valoperWalletAddress: valoperWalletAddress1), + ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey8), + ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey7), + ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey6), + ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valkey: valkey5), + ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey4), + ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey3), + ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey2), + ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valkey: valkey1), ]; expect(actualValidatorsList, expectedValidatorsList); @@ -122,14 +129,14 @@ void main() { // Assert List expectedValidatorsList = [ - ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valoperWalletAddress: valoperWalletAddress1), - ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valoperWalletAddress: valoperWalletAddress5), - ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress2), - ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress6), - ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress3), - ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress7), - ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress4), - ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress8), + ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valkey: valkey1), + ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valkey: valkey5), + ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey2), + ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey6), + ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey3), + ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey7), + ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey4), + ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey8), ]; expect(actualValidatorsList, expectedValidatorsList); @@ -141,14 +148,14 @@ void main() { // Assert List expectedValidatorsList = [ - ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress4), - ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress8), - ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress3), - ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress7), - ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress2), - ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valoperWalletAddress: valoperWalletAddress6), - ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valoperWalletAddress: valoperWalletAddress1), - ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valoperWalletAddress: valoperWalletAddress5), + ValidatorModel(top: 4, walletAddress: walletAddress4, moniker: 'dasheen', validatorStatus: ValidatorStatus.paused, uptime: 4, streak: '40', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey4), + ValidatorModel(top: 8, walletAddress: walletAddress8, moniker: 'ice', validatorStatus: ValidatorStatus.paused, uptime: 8, streak: '80', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey8), + ValidatorModel(top: 3, walletAddress: walletAddress3, moniker: 'coconut', validatorStatus: ValidatorStatus.jailed, uptime: 3, streak: '30', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey3), + ValidatorModel(top: 7, walletAddress: walletAddress7, moniker: 'huckleberry', validatorStatus: ValidatorStatus.jailed, uptime: 7, streak: '70', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey7), + ValidatorModel(top: 2, walletAddress: walletAddress2, moniker: 'banana', validatorStatus: ValidatorStatus.inactive, uptime: 2, streak: '20', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey2), + ValidatorModel(top: 6, walletAddress: walletAddress6, moniker: 'grape', validatorStatus: ValidatorStatus.inactive, uptime: 6, streak: '60', stakingPoolStatus: StakingPoolStatus.disabled, valkey: valkey6), + ValidatorModel(top: 1, walletAddress: walletAddress1, moniker: 'apple', validatorStatus: ValidatorStatus.active, uptime: 1, streak: '10', stakingPoolStatus: StakingPoolStatus.enabled, valkey: valkey1), + ValidatorModel(top: 5, walletAddress: walletAddress5, moniker: 'fig', validatorStatus: ValidatorStatus.active, uptime: 5, streak: '50', stakingPoolStatus: StakingPoolStatus.withdraw, valkey: valkey5), ]; expect(actualValidatorsList, expectedValidatorsList); diff --git a/test/unit/shared/models/identity_registrar/ir_model_test.dart b/test/unit/shared/models/identity_registrar/ir_model_test.dart index 350e6802..a0b0b391 100644 --- a/test/unit/shared/models/identity_registrar/ir_model_test.dart +++ b/test/unit/shared/models/identity_registrar/ir_model_test.dart @@ -2,8 +2,15 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:miro/shared/models/identity_registrar/ir_model.dart'; import 'package:miro/shared/models/identity_registrar/ir_record_model.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; +import 'package:miro/test/mock_locator.dart'; +import 'package:miro/test/utils/test_utils.dart'; + +// To run this test type in console: +// fvm flutter test test/unit/shared/models/identity_registrar/ir_model_test.dart --platform chrome --null-assertions +Future main() async { + await initMockLocator(); + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); -void main() { group('Tests of IRModel.isEmpty()', () { test('Should return [true] if all records are empty', () { // Arrange diff --git a/test/unit/shared/models/transactions/form_models/staking_msg_delegate_form_model_test.dart b/test/unit/shared/models/transactions/form_models/staking_msg_delegate_form_model_test.dart index 81c44dc5..4a6d2d20 100644 --- a/test/unit/shared/models/transactions/form_models/staking_msg_delegate_form_model_test.dart +++ b/test/unit/shared/models/transactions/form_models/staking_msg_delegate_form_model_test.dart @@ -7,9 +7,9 @@ import 'package:miro/shared/models/transactions/messages/a_tx_msg_model.dart'; import 'package:miro/shared/models/transactions/messages/staking/staking_msg_delegate_model.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; -void main() { +Future main() async { WalletAddress actualDelegatorWalletAddress = WalletAddress.fromBech32('kira143q8vxpvuykt9pq50e6hng9s38vmy844n8k9wx'); - WalletAddress actualValoperWalletAddress = WalletAddress.fromBech32('kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7'); + String actualValkey = 'kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7'; List actualTokenAmountModels = [ TokenAmountModel( defaultDenominationAmount: Decimal.fromInt(100), @@ -22,7 +22,7 @@ void main() { // Arrange StakingMsgDelegateFormModel actualStakingMsgDelegateFormModel = StakingMsgDelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: actualTokenAmountModels, ); @@ -32,7 +32,7 @@ void main() { // Assert StakingMsgDelegateModel expectedStakingMsgDelegateModel = StakingMsgDelegateModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: actualTokenAmountModels, ); @@ -43,7 +43,7 @@ void main() { // Arrange StakingMsgDelegateFormModel actualStakingMsgDelegateFormModel = StakingMsgDelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: [ TokenAmountModel( defaultDenominationAmount: Decimal.fromInt(0), @@ -54,7 +54,7 @@ void main() { // Assert expect( - () => actualStakingMsgDelegateFormModel.buildTxMsgModel(), + () => actualStakingMsgDelegateFormModel.buildTxMsgModel(), throwsA(isA()), ); }); @@ -63,28 +63,28 @@ void main() { // Arrange StakingMsgDelegateFormModel actualStakingMsgDelegateFormModel = StakingMsgDelegateFormModel( delegatorWalletAddress: null, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: actualTokenAmountModels, ); // Assert expect( - () => actualStakingMsgDelegateFormModel.buildTxMsgModel(), + () => actualStakingMsgDelegateFormModel.buildTxMsgModel(), throwsA(isA()), ); }); - test('Should [throw Exception] if at least one of required form fields is empty (valoperWalletAddress)', () { + test('Should [throw Exception] if at least one of required form fields is empty (valkey)', () { // Arrange StakingMsgDelegateFormModel actualStakingMsgDelegateFormModel = StakingMsgDelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: null, + valkey: null, tokenAmountModels: actualTokenAmountModels, ); // Assert expect( - () => actualStakingMsgDelegateFormModel.buildTxMsgModel(), + () => actualStakingMsgDelegateFormModel.buildTxMsgModel(), throwsA(isA()), ); }); @@ -93,13 +93,13 @@ void main() { // Arrange StakingMsgDelegateFormModel actualStakingMsgDelegateFormModel = StakingMsgDelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: null, ); // Assert expect( - () => actualStakingMsgDelegateFormModel.buildTxMsgModel(), + () => actualStakingMsgDelegateFormModel.buildTxMsgModel(), throwsA(isA()), ); }); @@ -110,7 +110,7 @@ void main() { // Arrange StakingMsgDelegateFormModel actualStakingMsgDelegateFormModel = StakingMsgDelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: actualTokenAmountModels, ); @@ -125,7 +125,7 @@ void main() { // Arrange StakingMsgDelegateFormModel actualStakingMsgDelegateFormModel = StakingMsgDelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: [ TokenAmountModel( defaultDenominationAmount: Decimal.fromInt(0), @@ -145,7 +145,7 @@ void main() { // Arrange StakingMsgDelegateFormModel actualStakingMsgDelegateFormModel = StakingMsgDelegateFormModel( delegatorWalletAddress: null, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: actualTokenAmountModels, ); @@ -156,11 +156,11 @@ void main() { expect(actualBuildAvailableBool, false); }); - test('Should [return FALSE] if at least one of required form fields is empty (valoperWalletAddress)', () { + test('Should [return FALSE] if at least one of required form fields is empty (valkey)', () { // Arrange StakingMsgDelegateFormModel actualStakingMsgDelegateFormModel = StakingMsgDelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: null, + valkey: null, tokenAmountModels: actualTokenAmountModels, ); @@ -175,7 +175,7 @@ void main() { // Arrange StakingMsgDelegateFormModel actualStakingMsgDelegateFormModel = StakingMsgDelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: null, ); diff --git a/test/unit/shared/models/transactions/form_models/staking_msg_undelegate_form_model_test.dart b/test/unit/shared/models/transactions/form_models/staking_msg_undelegate_form_model_test.dart index 57b1d231..ad8886dc 100644 --- a/test/unit/shared/models/transactions/form_models/staking_msg_undelegate_form_model_test.dart +++ b/test/unit/shared/models/transactions/form_models/staking_msg_undelegate_form_model_test.dart @@ -7,9 +7,9 @@ import 'package:miro/shared/models/transactions/messages/a_tx_msg_model.dart'; import 'package:miro/shared/models/transactions/messages/staking/staking_msg_undelegate_model.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; -void main() { +Future main() async { WalletAddress actualDelegatorWalletAddress = WalletAddress.fromBech32('kira143q8vxpvuykt9pq50e6hng9s38vmy844n8k9wx'); - WalletAddress actualValoperWalletAddress = WalletAddress.fromBech32('kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7'); + String actualValkey = 'kiravaloper1c6slygj2tx7hzm0mn4qeflqpvngj73c2cw7fh7'; List actualTokenAmountModels = [ TokenAmountModel( defaultDenominationAmount: Decimal.fromInt(100), @@ -22,7 +22,7 @@ void main() { // Arrange StakingMsgUndelegateFormModel actualStakingMsgUndelegateFormModel = StakingMsgUndelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: actualTokenAmountModels, ); @@ -37,7 +37,7 @@ void main() { // Arrange StakingMsgUndelegateFormModel actualStakingMsgUndelegateFormModel = StakingMsgUndelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: [ TokenAmountModel( defaultDenominationAmount: Decimal.fromInt(0), @@ -57,7 +57,7 @@ void main() { // Arrange StakingMsgUndelegateFormModel actualStakingMsgUndelegateFormModel = StakingMsgUndelegateFormModel( delegatorWalletAddress: null, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: actualTokenAmountModels, ); @@ -68,11 +68,11 @@ void main() { expect(actualBuildAvailableBool, false); }); - test('Should [return FALSE] if at least one of required form fields is empty (valoperWalletAddress)', () { + test('Should [return FALSE] if at least one of required form fields is empty (valkey)', () { // Arrange StakingMsgUndelegateFormModel actualStakingMsgUndelegateFormModel = StakingMsgUndelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: null, + valkey: null, tokenAmountModels: actualTokenAmountModels, ); @@ -87,7 +87,7 @@ void main() { // Arrange StakingMsgUndelegateFormModel actualStakingMsgUndelegateFormModel = StakingMsgUndelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: null, ); @@ -104,7 +104,7 @@ void main() { // Arrange StakingMsgUndelegateFormModel actualStakingMsgUndelegateFormModel = StakingMsgUndelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: actualTokenAmountModels, ); @@ -114,7 +114,7 @@ void main() { // Assert StakingMsgUndelegateModel expectedStakingMsgUndelegateModel = StakingMsgUndelegateModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: actualTokenAmountModels, ); @@ -125,7 +125,7 @@ void main() { // Arrange StakingMsgUndelegateFormModel actualStakingMsgUndelegateFormModel = StakingMsgUndelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: [ TokenAmountModel( defaultDenominationAmount: Decimal.fromInt(0), @@ -145,7 +145,7 @@ void main() { // Arrange StakingMsgUndelegateFormModel actualStakingMsgUndelegateFormModel = StakingMsgUndelegateFormModel( delegatorWalletAddress: null, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: actualTokenAmountModels, ); @@ -156,11 +156,11 @@ void main() { ); }); - test('Should [throw Exception] if at least one of required form fields is empty (valoperWalletAddress)', () { + test('Should [throw Exception] if at least one of required form fields is empty (valkey)', () { // Arrange StakingMsgUndelegateFormModel actualStakingMsgUndelegateFormModel = StakingMsgUndelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: null, + valkey: null, tokenAmountModels: actualTokenAmountModels, ); @@ -175,7 +175,7 @@ void main() { // Arrange StakingMsgUndelegateFormModel actualStakingMsgUndelegateFormModel = StakingMsgUndelegateFormModel( delegatorWalletAddress: actualDelegatorWalletAddress, - valoperWalletAddress: actualValoperWalletAddress, + valkey: actualValkey, tokenAmountModels: null, ); diff --git a/test/unit/shared/models/wallet/keyfile_test.dart b/test/unit/shared/models/wallet/keyfile_test.dart index 4481c67a..38b57343 100644 --- a/test/unit/shared/models/wallet/keyfile_test.dart +++ b/test/unit/shared/models/wallet/keyfile_test.dart @@ -7,8 +7,15 @@ import 'package:miro/shared/models/wallet/keyfile.dart'; import 'package:miro/shared/models/wallet/mnemonic.dart'; import 'package:miro/shared/models/wallet/wallet.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; +import 'package:miro/test/mock_locator.dart'; +import 'package:miro/test/utils/test_utils.dart'; + +// To run this test type in console: +// fvm flutter test test/unit/shared/models/wallet/keyfile_test.dart --platform chrome --null-assertions +Future main() async { + await initMockLocator(); + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); -void main() { // @formatter:off const String keyFileJSONString = '{\n' ' "bech32Address": "kira1gdury9ednrjj8fluwj9ea5e6cu5jr9jvekl7u3",\n' @@ -26,7 +33,7 @@ void main() { // Expected Values of tests // const WalletDetails expectedWalletDetails = Wallet.defaultWalletDetails; final Uint8List expectedAddressBytes = Uint8List.fromList([67, 120, 50, 23, 45, 152, 229, 35, 167, 252, 116, 139, 158, 211, 58, 199, 41, 33, 150, 76]); - final WalletAddress expectedAddress = WalletAddress(addressBytes: expectedAddressBytes, bech32Hrp: actualWallet.address.bech32Hrp); + final WalletAddress expectedAddress = WalletAddress(addressBytes: expectedAddressBytes); final Uint8List expectedPrivateKey = Uint8List.fromList([158, 115, 126, 2, 208, 98, 193, 1, 114, 159, 189, 20, 131, 168, 118, 66, 223, 196, 48, 193, 71, 233, 115, 59, 192, 240, 216, 104, 85, 120, 94, 60]); final Wallet expectedWallet = Wallet(address: expectedAddress, privateKey: expectedPrivateKey); diff --git a/test/unit/shared/models/wallet/wallet_address_test.dart b/test/unit/shared/models/wallet/wallet_address_test.dart index c30d378c..b62fa18f 100644 --- a/test/unit/shared/models/wallet/wallet_address_test.dart +++ b/test/unit/shared/models/wallet/wallet_address_test.dart @@ -2,25 +2,30 @@ import 'dart:typed_data'; import 'package:flutter_test/flutter_test.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; +import 'package:miro/test/mock_locator.dart'; +import 'package:miro/test/utils/test_utils.dart'; + +// To run this test type in console: +// fvm flutter test test/unit/shared/models/wallet/wallet_address_test.dart --platform chrome --null-assertions +Future main() async { + await initMockLocator(); + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); -void main() { // @formatter:off // Actual values for tests final Uint8List actualAddressBytes = Uint8List.fromList([67, 120, 50, 23, 45, 152, 229, 35, 167, 252, 116, 139, 158, 211, 58, 199, 41, 33, 150, 76]); final Uint8List actualPublicKeyBytes = Uint8List.fromList([2, 230, 163, 243, 204, 78, 142, 181, 242, 255, 18, 127, 23, 240, 26, 81, 90, 37, 87, 1, 55, 60, 94, 73, 154, 3, 71, 10, 32, 131, 46, 111, 124]); const String actualBech32Address = 'kira1gdury9ednrjj8fluwj9ea5e6cu5jr9jvekl7u3'; - const String actualHexAddress = '0x437832172d98e523a7fc748b9ed33ac72921964c'; - const String actualBech32Hrp = 'kira'; - final WalletAddress actualWalletAddress = WalletAddress(addressBytes: actualAddressBytes, bech32Hrp: actualBech32Hrp); + final WalletAddress actualWalletAddress = WalletAddress(addressBytes: actualAddressBytes); // Expected values for tests - final WalletAddress expectedWalletAddress = WalletAddress(addressBytes: actualAddressBytes, bech32Hrp: actualBech32Hrp); + final WalletAddress expectedWalletAddress = WalletAddress(addressBytes: actualAddressBytes); // @formatter:on group('Tests of WalletAddress.fromPublicKey() constructor', () { test('Should return correct WalletAddress from given public key bytes', () { expect( - WalletAddress.fromPublicKey(actualPublicKeyBytes, bech32Hrp: actualBech32Hrp), + WalletAddress.fromPublicKey(actualPublicKeyBytes), expectedWalletAddress, ); }); @@ -33,32 +38,6 @@ void main() { ); }); }); - group('Tests of WalletAddress.fromHex() constructor', () { - test('Should return correct WalletAddress from given hex address', () { - expect( - WalletAddress.fromHex(actualHexAddress, bech32Hrp: actualBech32Hrp), - expectedWalletAddress, - ); - }); - }); - - group('Tests of hex getter', () { - test('Should return correct calculated hex address with 0x prefix', () { - expect( - actualWalletAddress.hex, - '0x437832172d98e523a7fc748b9ed33ac72921964c', - ); - }); - }); - - group('Tests of hexWithoutPrefix getter', () { - test('Should return correct hex address without 0x prefix', () { - expect( - actualWalletAddress.hexWithoutPrefix, - '437832172d98e523a7fc748b9ed33ac72921964c', - ); - }); - }); group('Tests of bech32Address getter', () { test('Should return correct bech32 address', () { diff --git a/test/unit/shared/models/wallet/wallet_test.dart b/test/unit/shared/models/wallet/wallet_test.dart index 5ecac568..b08e8247 100644 --- a/test/unit/shared/models/wallet/wallet_test.dart +++ b/test/unit/shared/models/wallet/wallet_test.dart @@ -4,17 +4,21 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:miro/shared/models/wallet/mnemonic.dart'; import 'package:miro/shared/models/wallet/wallet.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; -import 'package:miro/shared/models/wallet/wallet_details.dart'; +import 'package:miro/test/mock_locator.dart'; +import 'package:miro/test/utils/test_utils.dart'; -void main() { - // @formatter:off +// To run this test type in console: +// fvm flutter test test/unit/shared/models/wallet/wallet_test.dart --platform chrome --null-assertions +Future main() async { + await initMockLocator(); + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); + // @formatter:off // Actual Values for tests const String actualMnemonicString = 'equal success expand debris crash despair awake bachelor athlete discover drop tilt reveal give oven polar party exact sign chalk hurdle move tilt chronic'; final Mnemonic actualMnemonic = Mnemonic(value: actualMnemonicString); final Wallet actualWallet = Wallet.derive(mnemonic: actualMnemonic); - const WalletDetails actualWalletDetails = WalletDetails.defaultWalletDetails; const Map actualKeyFilePublicJSON = { 'version': '1.0.1', @@ -33,7 +37,7 @@ void main() { Wallet expectedWallet = Wallet( privateKey: Uint8List.fromList(expectedPrivateKey), - address: WalletAddress(addressBytes: Uint8List.fromList(expectedAddress), bech32Hrp: actualWalletDetails.bech32Hrp), + address: WalletAddress(addressBytes: Uint8List.fromList(expectedAddress)), ); // @formatter:on @@ -81,7 +85,7 @@ void main() { expectedPrivateKey, ); }); - + test('Should create valid bech32 address from given mnemonic', () async { expect( actualWallet.address.bech32Address, diff --git a/test/unit/shared/utils/transactions/tx_utils_test.dart b/test/unit/shared/utils/transactions/tx_utils_test.dart index a2058ead..388cd1ec 100644 --- a/test/unit/shared/utils/transactions/tx_utils_test.dart +++ b/test/unit/shared/utils/transactions/tx_utils_test.dart @@ -11,11 +11,15 @@ import 'package:miro/shared/models/transactions/tx_remote_info_model.dart'; import 'package:miro/shared/models/transactions/unsigned_tx_model.dart'; import 'package:miro/shared/models/wallet/wallet_address.dart'; import 'package:miro/shared/utils/transactions/tx_utils.dart'; +import 'package:miro/test/mock_locator.dart'; import 'package:miro/test/utils/test_utils.dart'; // To run this test type in console: // fvm flutter test test/unit/shared/utils/transactions/tx_utils_test.dart --platform chrome --null-assertions Future main() async { + await initMockLocator(); + await TestUtils.setupNetworkModel(networkUri: Uri.parse('https://healthy.kira.network/')); + group('Tests of TxUtils.buildAmountString() method', () { // Arrange TokenDenominationModel ukex = const TokenDenominationModel(name: 'ukex', decimals: 0);