From d37c6a440d76007ee207df365e72e540067ea053 Mon Sep 17 00:00:00 2001 From: Chralu Date: Tue, 14 Jan 2025 11:25:06 +0100 Subject: [PATCH] refactor(TokenRepository): :recycle: Rework dependency injection. --- lib/application/aeswap/dex_token.g.dart | 2 +- lib/application/session/session.g.dart | 2 +- lib/application/tokens/tokens.dart | 48 ++- lib/application/tokens/tokens.g.dart | 24 +- lib/domain/models/app_wallet.freezed.dart | 6 +- lib/domain/models/token_parser.dart | 7 +- .../tokens/tokens.repository.dart | 8 +- .../tokens/tokens.repository.dart | 28 +- .../aeswap/application/pool/dex_pool.g.dart | 2 +- .../views/add_custom_token/bloc/provider.dart | 2 +- .../add_custom_token/bloc/provider.g.dart | 2 +- lib/ui/views/main/bloc/providers.g.dart | 2 +- test/token_parser_test.dart | 16 +- test/token_parser_test.mocks.dart | 375 +++++++----------- 14 files changed, 214 insertions(+), 310 deletions(-) diff --git a/lib/application/aeswap/dex_token.g.dart b/lib/application/aeswap/dex_token.g.dart index 24b92bde8..563cb7155 100644 --- a/lib/application/aeswap/dex_token.g.dart +++ b/lib/application/aeswap/dex_token.g.dart @@ -609,7 +609,7 @@ class _EstimateTokenInFiatProviderElement (origin as _EstimateTokenInFiatProvider).tokenAddress; } -String _$getRemoveAmountsHash() => r'5ef17a0246ccf402c8cfa2334909514bb491625f'; +String _$getRemoveAmountsHash() => r'0a78339142692cd07c56e184c689b75f88b969de'; /// This provider is used to cache request result /// It ensures, for example, that an oracle update won't trigger a new `getRemoveAmounts` request diff --git a/lib/application/session/session.g.dart b/lib/application/session/session.g.dart index d71be8f8c..151db10fc 100644 --- a/lib/application/session/session.g.dart +++ b/lib/application/session/session.g.dart @@ -6,7 +6,7 @@ part of 'session.dart'; // RiverpodGenerator // ************************************************************************** -String _$sessionNotifierHash() => r'c481183dbfd6ba2ad8bd4cb5348347ad50252b48'; +String _$sessionNotifierHash() => r'e7290af2bd177469103e4cd27791a831f8ca1ed0'; /// See also [SessionNotifier]. @ProviderFor(SessionNotifier) diff --git a/lib/application/tokens/tokens.dart b/lib/application/tokens/tokens.dart index ac6d4c5f8..b1e3d9e83 100644 --- a/lib/application/tokens/tokens.dart +++ b/lib/application/tokens/tokens.dart @@ -3,6 +3,7 @@ import 'dart:developer'; import 'package:aewallet/application/account/accounts_notifier.dart'; import 'package:aewallet/application/aeswap/dex_token.dart'; import 'package:aewallet/application/api_service.dart'; +import 'package:aewallet/domain/repositories/tokens/tokens.repository.dart'; import 'package:aewallet/infrastructure/repositories/tokens/tokens.repository.dart'; import 'package:aewallet/modules/aeswap/application/pool/dex_pool.dart'; import 'package:aewallet/modules/aeswap/application/session/provider.dart'; @@ -16,27 +17,33 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; part 'tokens.g.dart'; @riverpod -TokensRepositoryImpl tokensRepositoryImpl( +TokensRepository tokensRepository( Ref ref, -) => - TokensRepositoryImpl(); +) { + final apiService = ref.watch(apiServiceProvider); + final environment = ref.watch(environmentProvider); + return TokensRepositoryImpl( + apiService: apiService, + defTokensRepository: aedappfm.DefTokensRepositoryImpl(), + verifiedTokensRepository: aedappfm.VerifiedTokensRepositoryImpl( + apiService: apiService, + environment: environment, + ), + ); +} @riverpod Future> tokensFromAddresses( Ref ref, List addresses, -) async { - final apiService = ref.watch(apiServiceProvider); - - return ref - .watch( - tokensRepositoryImplProvider, - ) - .getTokensFromAddresses( - addresses, - apiService, - ); -} +) => + ref + .watch( + tokensRepositoryProvider, + ) + .getTokensFromAddresses( + addresses, + ); @riverpod Future> tokensFromUserBalance( @@ -47,8 +54,6 @@ Future> tokensFromUserBalance( bool withNotVerified = true, bool withCustomToken = true, }) async { - final apiService = ref.watch(apiServiceProvider); - final environment = ref.watch(environmentProvider); final poolListRaw = await ref.watch(DexPoolProviders.getPoolListRaw.future); final selectedAccount = @@ -56,18 +61,13 @@ Future> tokensFromUserBalance( if (selectedAccount == null) return []; - final tokensRepository = ref.watch(tokensRepositoryImplProvider); - final defTokensRepository = - ref.watch(aedappfm.defTokensRepositoryImplProvider); - return ref .watch( - tokensRepositoryImplProvider, + tokensRepositoryProvider, ) .getTokensFromUserBalance( selectedAccount.genesisAddress, selectedAccount.customTokenAddressList ?? [], - apiService, poolListRaw, environment, withUCO: withUCO, @@ -75,8 +75,6 @@ Future> tokensFromUserBalance( withLPToken: withLPToken, withNotVerified: withNotVerified, withCustomToken: withCustomToken, - defTokensRepository, - tokensRepository, ); } diff --git a/lib/application/tokens/tokens.g.dart b/lib/application/tokens/tokens.g.dart index 6b1341525..c30f913ef 100644 --- a/lib/application/tokens/tokens.g.dart +++ b/lib/application/tokens/tokens.g.dart @@ -6,27 +6,25 @@ part of 'tokens.dart'; // RiverpodGenerator // ************************************************************************** -String _$tokensRepositoryImplHash() => - r'6d0639fff11793ccb691c0bdb8aa86b99078ee47'; - -/// See also [tokensRepositoryImpl]. -@ProviderFor(tokensRepositoryImpl) -final tokensRepositoryImplProvider = - AutoDisposeProvider.internal( - tokensRepositoryImpl, - name: r'tokensRepositoryImplProvider', +String _$tokensRepositoryHash() => r'6c84cd42aedf92b5acc058616f6cdb4e4052ffb7'; + +/// See also [tokensRepository]. +@ProviderFor(tokensRepository) +final tokensRepositoryProvider = AutoDisposeProvider.internal( + tokensRepository, + name: r'tokensRepositoryProvider', debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') ? null - : _$tokensRepositoryImplHash, + : _$tokensRepositoryHash, dependencies: null, allTransitiveDependencies: null, ); @Deprecated('Will be removed in 3.0. Use Ref instead') // ignore: unused_element -typedef TokensRepositoryImplRef = AutoDisposeProviderRef; +typedef TokensRepositoryRef = AutoDisposeProviderRef; String _$tokensFromAddressesHash() => - r'3eb854cf86092bf7599a28a546924b3a2eb3bf14'; + r'7fc14a5559b66673be8758e145c675aaab127f00'; /// Copied from Dart SDK class _SystemHash { @@ -186,7 +184,7 @@ class _TokensFromAddressesProviderElement } String _$tokensFromUserBalanceHash() => - r'254d8d9be48aae28c96b9dcc1e1cbc98999ac8a6'; + r'c04c5f3beac60be756c1d1ed1773f96928deb5e5'; /// See also [tokensFromUserBalance]. @ProviderFor(tokensFromUserBalance) diff --git a/lib/domain/models/app_wallet.freezed.dart b/lib/domain/models/app_wallet.freezed.dart index 9aff8cf2b..4f67ad3d2 100644 --- a/lib/domain/models/app_wallet.freezed.dart +++ b/lib/domain/models/app_wallet.freezed.dart @@ -16,8 +16,7 @@ final _privateConstructorUsedError = UnsupportedError( /// @nodoc mixin _$AppWallet { - String get seed => - throw _privateConstructorUsedError; // TODO(redddwarf03): Mutualize keychain infos + String get seed => throw _privateConstructorUsedError; AppKeychain get appKeychain => throw _privateConstructorUsedError; KeychainSecuredInfos get keychainSecuredInfos => throw _privateConstructorUsedError; @@ -151,7 +150,6 @@ class _$AppWalletImpl extends _AppWallet { @override final String seed; -// TODO(redddwarf03): Mutualize keychain infos @override final AppKeychain appKeychain; @override @@ -196,7 +194,7 @@ abstract class _AppWallet extends AppWallet { const _AppWallet._() : super._(); @override - String get seed; // TODO(redddwarf03): Mutualize keychain infos + String get seed; @override AppKeychain get appKeychain; @override diff --git a/lib/domain/models/token_parser.dart b/lib/domain/models/token_parser.dart index 3d8014467..139efa202 100644 --- a/lib/domain/models/token_parser.dart +++ b/lib/domain/models/token_parser.dart @@ -1,4 +1,4 @@ -import 'package:aewallet/infrastructure/repositories/tokens/tokens.repository.dart'; +import 'package:aewallet/domain/repositories/tokens/tokens.repository.dart'; import 'package:aewallet/modules/aeswap/domain/models/dex_token.dart'; import 'package:aewallet/modules/aeswap/domain/models/util/get_pool_list_response.dart'; import 'package:archethic_dapp_framework_flutter/archethic_dapp_framework_flutter.dart' @@ -13,8 +13,8 @@ mixin TokenParser { List poolsListRaw, aedappfm.Environment environment, archethic.ApiService apiService, - aedappfm.DefTokensRepositoryImpl defTokensRepository, - TokensRepositoryImpl tokensRepository, + aedappfm.DefTokensRepositoryInterface defTokensRepository, + TokensRepository tokensRepository, ) async { String? pairSymbolToken1; String? pairSymbolToken2; @@ -46,7 +46,6 @@ mixin TokenParser { final tokensSymbolMap = await tokensRepository.getTokensFromAddresses( tokenSymbolSearch, - apiService, ); pairSymbolToken1 = token1Address != kUCOAddress ? tokensSymbolMap[token1Address]!.symbol diff --git a/lib/domain/repositories/tokens/tokens.repository.dart b/lib/domain/repositories/tokens/tokens.repository.dart index dccfe5647..210a6313b 100644 --- a/lib/domain/repositories/tokens/tokens.repository.dart +++ b/lib/domain/repositories/tokens/tokens.repository.dart @@ -1,4 +1,3 @@ -import 'package:aewallet/infrastructure/repositories/tokens/tokens.repository.dart'; import 'package:aewallet/modules/aeswap/domain/models/util/get_pool_list_response.dart'; import 'package:archethic_dapp_framework_flutter/archethic_dapp_framework_flutter.dart' as aedappfm; @@ -7,17 +6,14 @@ import 'package:archethic_lib_dart/archethic_lib_dart.dart' as archethic; abstract class TokensRepository { Future> getTokensFromAddresses( List addresses, - archethic.ApiService apiService, ); Future> getTokensFromUserBalance( String userGenesisAddress, List userTokenLocalAddresses, - archethic.ApiService apiService, List poolsListRaw, - aedappfm.Environment environment, - aedappfm.DefTokensRepositoryImpl defTokensRepositoryImpl, - TokensRepositoryImpl tokensRepositoryImpl, { + aedappfm.Environment environment, { + bool withUCO = true, bool withVerified = true, bool withLPToken = true, bool withNotVerified = true, diff --git a/lib/infrastructure/repositories/tokens/tokens.repository.dart b/lib/infrastructure/repositories/tokens/tokens.repository.dart index 3950bf73d..4d39638a6 100644 --- a/lib/infrastructure/repositories/tokens/tokens.repository.dart +++ b/lib/infrastructure/repositories/tokens/tokens.repository.dart @@ -9,10 +9,19 @@ import 'package:archethic_dapp_framework_flutter/archethic_dapp_framework_flutte import 'package:archethic_lib_dart/archethic_lib_dart.dart' as archethic; class TokensRepositoryImpl with TokenParser implements TokensRepository { + TokensRepositoryImpl({ + required this.defTokensRepository, + required this.apiService, + required this.verifiedTokensRepository, + }); + + final aedappfm.DefTokensRepositoryInterface defTokensRepository; + final archethic.ApiService apiService; + final aedappfm.VerifiedTokensRepositoryImpl verifiedTokensRepository; + @override Future> getTokensFromAddresses( List addresses, - archethic.ApiService apiService, ) async { final tokenMap = {}; @@ -62,11 +71,8 @@ class TokensRepositoryImpl with TokenParser implements TokensRepository { Future> getTokensFromUserBalance( String userGenesisAddress, List userTokenLocalAddresses, - archethic.ApiService apiService, List poolsListRaw, - aedappfm.Environment environment, - aedappfm.DefTokensRepositoryImpl defTokensRepositoryImpl, - TokensRepositoryImpl tokensRepositoryImpl, { + aedappfm.Environment environment, { bool withUCO = true, bool withVerified = true, bool withLPToken = true, @@ -80,7 +86,7 @@ class TokensRepositoryImpl with TokenParser implements TokensRepository { } if (withUCO) { final defUCOToken = - await defTokensRepositoryImpl.getDefToken(environment, kUCOAddress); + await defTokensRepository.getDefToken(environment, kUCOAddress); tokensList.add( aedappfm.ucoToken.copyWith( name: defUCOToken?.name ?? '', @@ -109,13 +115,9 @@ class TokensRepositoryImpl with TokenParser implements TokensRepository { if (tokenAddressList.isNotEmpty) { final tokenMap = await getTokensFromAddresses( tokenAddressList.toSet().toList(), - apiService, ); - final verifiedTokens = await aedappfm.VerifiedTokensRepositoryImpl( - apiService: apiService, - environment: environment, - ).getVerifiedTokens(); + final verifiedTokens = await verifiedTokensRepository.getVerifiedTokens(); final tokenBalances = balanceMap[userGenesisAddress]!.token; @@ -130,8 +132,8 @@ class TokensRepositoryImpl with TokenParser implements TokensRepository { poolsListRaw, environment, apiService, - defTokensRepositoryImpl, - tokensRepositoryImpl, + defTokensRepository, + this, ); final matchingBalances = tokenBalances.where( diff --git a/lib/modules/aeswap/application/pool/dex_pool.g.dart b/lib/modules/aeswap/application/pool/dex_pool.g.dart index e7e868acd..01700bdfe 100644 --- a/lib/modules/aeswap/application/pool/dex_pool.g.dart +++ b/lib/modules/aeswap/application/pool/dex_pool.g.dart @@ -714,7 +714,7 @@ class _PoolInfosProviderElement String get poolAddress => (origin as _PoolInfosProvider).poolAddress; } -String _$getPoolListHash() => r'c105fb2e6011358c360513fc7ad1d65ee2ef7520'; +String _$getPoolListHash() => r'2b9fa7f3aa2669e624a213bc4844b33356b87ecf'; /// See also [_getPoolList]. @ProviderFor(_getPoolList) diff --git a/lib/ui/views/add_custom_token/bloc/provider.dart b/lib/ui/views/add_custom_token/bloc/provider.dart index a7e88839b..2b4357097 100644 --- a/lib/ui/views/add_custom_token/bloc/provider.dart +++ b/lib/ui/views/add_custom_token/bloc/provider.dart @@ -50,7 +50,7 @@ class AddCustomTokenFormNotifier extends _$AddCustomTokenFormNotifier .read(verifiedTokensRepositoryProvider) .getVerifiedTokens(); final environment = ref.read(environmentProvider); - final tokensRepositoryImpl = ref.read(tokensRepositoryImplProvider); + final tokensRepositoryImpl = ref.read(tokensRepositoryProvider); final defTokensRepositoryImpl = ref.read(aedappfm.defTokensRepositoryImplProvider); diff --git a/lib/ui/views/add_custom_token/bloc/provider.g.dart b/lib/ui/views/add_custom_token/bloc/provider.g.dart index 088897558..f5f9d100a 100644 --- a/lib/ui/views/add_custom_token/bloc/provider.g.dart +++ b/lib/ui/views/add_custom_token/bloc/provider.g.dart @@ -7,7 +7,7 @@ part of 'provider.dart'; // ************************************************************************** String _$addCustomTokenFormNotifierHash() => - r'441e2c7fca977ae7ff3e496d5936db2f73f16fe1'; + r'da6d902ba2ae059d9503a9948fbca949435ba741'; /// See also [AddCustomTokenFormNotifier]. @ProviderFor(AddCustomTokenFormNotifier) diff --git a/lib/ui/views/main/bloc/providers.g.dart b/lib/ui/views/main/bloc/providers.g.dart index 81e64f758..5285c5df8 100644 --- a/lib/ui/views/main/bloc/providers.g.dart +++ b/lib/ui/views/main/bloc/providers.g.dart @@ -6,7 +6,7 @@ part of 'providers.dart'; // RiverpodGenerator // ************************************************************************** -String _$homePageHash() => r'75430f32f464429243926bd07a56a6036a7a17f0'; +String _$homePageHash() => r'b3a7e0d8b8465ba8f13decf492db4b8eeae87ec9'; /// Eagerly initializes providers (https://riverpod.dev/docs/essentials/eager_initialization). /// diff --git a/test/token_parser_test.dart b/test/token_parser_test.dart index 453e8aa6d..6b086f2bd 100644 --- a/test/token_parser_test.dart +++ b/test/token_parser_test.dart @@ -1,6 +1,7 @@ import 'dart:io'; + import 'package:aewallet/domain/models/token_parser.dart'; -import 'package:aewallet/infrastructure/repositories/tokens/tokens.repository.dart'; +import 'package:aewallet/domain/repositories/tokens/tokens.repository.dart'; import 'package:aewallet/modules/aeswap/domain/models/util/get_pool_list_response.dart'; import 'package:archethic_dapp_framework_flutter/archethic_dapp_framework_flutter.dart' as aedappfm; @@ -12,9 +13,9 @@ import 'package:mockito/mockito.dart'; @GenerateNiceMocks( [ - MockSpec(), + MockSpec(), MockSpec(), - MockSpec(), + MockSpec(), ], ) import 'token_parser_test.mocks.dart'; @@ -26,8 +27,8 @@ void main() { group('TokenParser - tokenModelToAETokenModel', () { late TokenParser tokenParser; - late MockTokensRepositoryImpl mockTokensRepository; - late MockDefTokensRepositoryImpl mockDefTokensRepository; + late MockTokensRepository mockTokensRepository; + late MockDefTokensRepositoryInterface mockDefTokensRepository; late MockApiService mockApiService; late aedappfm.Environment environment; late List verifiedTokens; @@ -35,8 +36,8 @@ void main() { setUp(() { Hive.init('${Directory.current.path}/test/tmp_data'); - mockTokensRepository = MockTokensRepositoryImpl(); - mockDefTokensRepository = MockDefTokensRepositoryImpl(); + mockTokensRepository = MockTokensRepository(); + mockDefTokensRepository = MockDefTokensRepositoryInterface(); mockApiService = MockApiService(); environment = aedappfm.Environment.testnet; tokenParser = _TokenParserImpl(); @@ -179,7 +180,6 @@ void main() { '00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4', ]), ), - any, ), ).thenAnswer( (_) async => { diff --git a/test/token_parser_test.mocks.dart b/test/token_parser_test.mocks.dart index f25374041..22c54377b 100644 --- a/test/token_parser_test.mocks.dart +++ b/test/token_parser_test.mocks.dart @@ -3,37 +3,33 @@ // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i10; -import 'dart:typed_data' as _i18; +import 'dart:async' as _i9; +import 'dart:typed_data' as _i16; -import 'package:aewallet/infrastructure/repositories/tokens/tokens.repository.dart' - as _i23; +import 'package:aewallet/domain/repositories/tokens/tokens.repository.dart' + as _i21; import 'package:aewallet/modules/aeswap/domain/models/util/get_pool_list_response.dart' - as _i24; + as _i22; import 'package:archethic_dapp_framework_flutter/archethic_dapp_framework_flutter.dart' - as _i9; -import 'package:archethic_dapp_framework_flutter/src/domain/models/ae_token.dart' as _i8; -import 'package:archethic_dapp_framework_flutter/src/domain/models/environment.dart' - as _i11; -import 'package:archethic_lib_dart/archethic_lib_dart.dart' as _i12; +import 'package:archethic_lib_dart/archethic_lib_dart.dart' as _i10; import 'package:archethic_lib_dart/src/model/address.dart' as _i6; -import 'package:archethic_lib_dart/src/model/balance.dart' as _i14; +import 'package:archethic_lib_dart/src/model/balance.dart' as _i12; import 'package:archethic_lib_dart/src/model/blockchain_version.dart' as _i7; -import 'package:archethic_lib_dart/src/model/endpoint.dart' as _i20; +import 'package:archethic_lib_dart/src/model/endpoint.dart' as _i18; import 'package:archethic_lib_dart/src/model/keychain.dart' as _i5; -import 'package:archethic_lib_dart/src/model/node.dart' as _i15; -import 'package:archethic_lib_dart/src/model/ownership.dart' as _i17; +import 'package:archethic_lib_dart/src/model/node.dart' as _i13; +import 'package:archethic_lib_dart/src/model/ownership.dart' as _i15; import 'package:archethic_lib_dart/src/model/smart_contracts/sc_call_function_request.dart' - as _i21; -import 'package:archethic_lib_dart/src/model/token.dart' as _i19; + as _i19; +import 'package:archethic_lib_dart/src/model/token.dart' as _i17; import 'package:archethic_lib_dart/src/model/transaction.dart' as _i4; import 'package:archethic_lib_dart/src/model/transaction_fee.dart' as _i3; -import 'package:archethic_lib_dart/src/model/transaction_input.dart' as _i16; +import 'package:archethic_lib_dart/src/model/transaction_input.dart' as _i14; import 'package:archethic_lib_dart/src/model/transaction_status.dart' as _i2; -import 'package:graphql/client.dart' as _i22; +import 'package:graphql/client.dart' as _i20; import 'package:mockito/mockito.dart' as _i1; -import 'package:mockito/src/dummies.dart' as _i13; +import 'package:mockito/src/dummies.dart' as _i11; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -121,65 +117,55 @@ class _FakeBlockchainVersionModel_6 extends _i1.SmartFake ); } -class _FakeAEToken_7 extends _i1.SmartFake implements _i8.AEToken { - _FakeAEToken_7( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); -} - -/// A class which mocks [DefTokensRepositoryImpl]. +/// A class which mocks [DefTokensRepositoryInterface]. /// /// See the documentation for Mockito's code generation for more information. -class MockDefTokensRepositoryImpl extends _i1.Mock - implements _i9.DefTokensRepositoryImpl { +class MockDefTokensRepositoryInterface extends _i1.Mock + implements _i8.DefTokensRepositoryInterface { @override - _i10.Future<_i8.AEToken?> getDefToken( - _i11.Environment? environment, + _i9.Future<_i8.AEToken?> getDefToken( + _i8.Environment? enviroment, String? address, ) => (super.noSuchMethod( Invocation.method( #getDefToken, [ - environment, + enviroment, address, ], ), - returnValue: _i10.Future<_i8.AEToken?>.value(), - returnValueForMissingStub: _i10.Future<_i8.AEToken?>.value(), - ) as _i10.Future<_i8.AEToken?>); + returnValue: _i9.Future<_i8.AEToken?>.value(), + returnValueForMissingStub: _i9.Future<_i8.AEToken?>.value(), + ) as _i9.Future<_i8.AEToken?>); } /// A class which mocks [ApiService]. /// /// See the documentation for Mockito's code generation for more information. -class MockApiService extends _i1.Mock implements _i12.ApiService { +class MockApiService extends _i1.Mock implements _i10.ApiService { @override String get endpoint => (super.noSuchMethod( Invocation.getter(#endpoint), - returnValue: _i13.dummyValue( + returnValue: _i11.dummyValue( this, Invocation.getter(#endpoint), ), - returnValueForMissingStub: _i13.dummyValue( + returnValueForMissingStub: _i11.dummyValue( this, Invocation.getter(#endpoint), ), ) as String); @override - _i10.Future<_i2.TransactionStatus> sendTx(_i4.Transaction? transaction) => + _i9.Future<_i2.TransactionStatus> sendTx(_i4.Transaction? transaction) => (super.noSuchMethod( Invocation.method( #sendTx, [transaction], ), returnValue: - _i10.Future<_i2.TransactionStatus>.value(_FakeTransactionStatus_0( + _i9.Future<_i2.TransactionStatus>.value(_FakeTransactionStatus_0( this, Invocation.method( #sendTx, @@ -187,17 +173,17 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { ), )), returnValueForMissingStub: - _i10.Future<_i2.TransactionStatus>.value(_FakeTransactionStatus_0( + _i9.Future<_i2.TransactionStatus>.value(_FakeTransactionStatus_0( this, Invocation.method( #sendTx, [transaction], ), )), - ) as _i10.Future<_i2.TransactionStatus>); + ) as _i9.Future<_i2.TransactionStatus>); @override - _i10.Future> getLastTransaction( + _i9.Future> getLastTransaction( List? addresses, { String? request = r' address, balance { token { address, amount }, uco }, chainLength, crossValidationStamps { nodePublicKey, signature }, data { content, ownerships { authorizedPublicKeys { encryptedSecretKey, publicKey } secret } ledger { uco { transfers { amount, to } }, token { transfers { amount, to, tokenAddress, tokenId } } } recipients, actionRecipients { action address args } } inputs { amount, from, tokenAddress, spent, tokenId, timestamp, type, }, originSignature, previousAddress, previousPublicKey, previousSignature, type, validationStamp { proofOfIntegrity, proofOfWork, signature, timestamp, ledgerOperations { fee, unspentOutputs { state } } }, version', @@ -208,32 +194,32 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { [addresses], {#request: request}, ), - returnValue: _i10.Future>.value( + returnValue: _i9.Future>.value( {}), returnValueForMissingStub: - _i10.Future>.value( + _i9.Future>.value( {}), - ) as _i10.Future>); + ) as _i9.Future>); @override - _i10.Future> getTransactionIndex(List? addresses) => + _i9.Future> getTransactionIndex(List? addresses) => (super.noSuchMethod( Invocation.method( #getTransactionIndex, [addresses], ), - returnValue: _i10.Future>.value({}), + returnValue: _i9.Future>.value({}), returnValueForMissingStub: - _i10.Future>.value({}), - ) as _i10.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i10.Future getStorageNoncePublicKey() => (super.noSuchMethod( + _i9.Future getStorageNoncePublicKey() => (super.noSuchMethod( Invocation.method( #getStorageNoncePublicKey, [], ), - returnValue: _i10.Future.value(_i13.dummyValue( + returnValue: _i9.Future.value(_i11.dummyValue( this, Invocation.method( #getStorageNoncePublicKey, @@ -241,17 +227,17 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { ), )), returnValueForMissingStub: - _i10.Future.value(_i13.dummyValue( + _i9.Future.value(_i11.dummyValue( this, Invocation.method( #getStorageNoncePublicKey, [], ), )), - ) as _i10.Future); + ) as _i9.Future); @override - _i10.Future> fetchBalance( + _i9.Future> fetchBalance( List? addresses, { String? request = r' token { address, amount, tokenId }, uco ', }) => @@ -261,27 +247,27 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { [addresses], {#request: request}, ), - returnValue: _i10.Future>.value( - {}), - returnValueForMissingStub: _i10.Future>.value( - {}), - ) as _i10.Future>); + returnValue: _i9.Future>.value( + {}), + returnValueForMissingStub: _i9.Future>.value( + {}), + ) as _i9.Future>); @override - _i10.Future> getTransactionContent( + _i9.Future> getTransactionContent( List? addresses) => (super.noSuchMethod( Invocation.method( #getTransactionContent, [addresses], ), - returnValue: _i10.Future>.value({}), + returnValue: _i9.Future>.value({}), returnValueForMissingStub: - _i10.Future>.value({}), - ) as _i10.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i10.Future>> getTransactionChain( + _i9.Future>> getTransactionChain( Map? addresses, { String? request = r' address, balance { token { address, amount }, uco }, chainLength, crossValidationStamps { nodePublicKey, signature }, data { content, ownerships { authorizedPublicKeys { encryptedSecretKey, publicKey } secret } ledger { uco { transfers { amount, to } }, token { transfers { amount, to, tokenAddress, tokenId } } } recipients, actionRecipients { action address args } } inputs { amount, from, tokenAddress, spent, tokenId, timestamp, type, }, originSignature, previousAddress, previousPublicKey, previousSignature, type, validationStamp { proofOfIntegrity, proofOfWork, signature, timestamp, ledgerOperations { fee, unspentOutputs { state } } }, version', @@ -298,26 +284,26 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { #fromCriteria: fromCriteria, }, ), - returnValue: _i10.Future>>.value( + returnValue: _i9.Future>>.value( >{}), returnValueForMissingStub: - _i10.Future>>.value( + _i9.Future>>.value( >{}), - ) as _i10.Future>>); + ) as _i9.Future>>); @override - _i10.Future> getNodeList() => (super.noSuchMethod( + _i9.Future> getNodeList() => (super.noSuchMethod( Invocation.method( #getNodeList, [], ), - returnValue: _i10.Future>.value(<_i15.Node>[]), + returnValue: _i9.Future>.value(<_i13.Node>[]), returnValueForMissingStub: - _i10.Future>.value(<_i15.Node>[]), - ) as _i10.Future>); + _i9.Future>.value(<_i13.Node>[]), + ) as _i9.Future>); @override - _i10.Future> networkTransactions( + _i9.Future> networkTransactions( String? type, int? page, { String? request = @@ -333,13 +319,13 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { {#request: request}, ), returnValue: - _i10.Future>.value(<_i4.Transaction>[]), + _i9.Future>.value(<_i4.Transaction>[]), returnValueForMissingStub: - _i10.Future>.value(<_i4.Transaction>[]), - ) as _i10.Future>); + _i9.Future>.value(<_i4.Transaction>[]), + ) as _i9.Future>); @override - _i10.Future>> getTransactionInputs( + _i9.Future>> getTransactionInputs( List? addresses, { String? request = r'amount, from, tokenAddress, spent, tokenId, timestamp, type', @@ -356,16 +342,15 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { #pagingOffset: pagingOffset, }, ), - returnValue: - _i10.Future>>.value( - >{}), + returnValue: _i9.Future>>.value( + >{}), returnValueForMissingStub: - _i10.Future>>.value( - >{}), - ) as _i10.Future>>); + _i9.Future>>.value( + >{}), + ) as _i9.Future>>); @override - _i10.Future> getTransaction( + _i9.Future> getTransaction( List? addresses, { String? request = r' address, balance { token { address, amount }, uco }, chainLength, crossValidationStamps { nodePublicKey, signature }, data { content, ownerships { authorizedPublicKeys { encryptedSecretKey, publicKey } secret } ledger { uco { transfers { amount, to } }, token { transfers { amount, to, tokenAddress, tokenId } } } recipients, actionRecipients { action address args } } inputs { amount, from, tokenAddress, spent, tokenId, timestamp, type, }, originSignature, previousAddress, previousPublicKey, previousSignature, type, validationStamp { proofOfIntegrity, proofOfWork, signature, timestamp, ledgerOperations { fee, unspentOutputs { state } } }, version', @@ -376,23 +361,22 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { [addresses], {#request: request}, ), - returnValue: _i10.Future>.value( + returnValue: _i9.Future>.value( {}), returnValueForMissingStub: - _i10.Future>.value( + _i9.Future>.value( {}), - ) as _i10.Future>); + ) as _i9.Future>); @override - _i10.Future<_i3.TransactionFee> getTransactionFee( + _i9.Future<_i3.TransactionFee> getTransactionFee( _i4.Transaction? transaction) => (super.noSuchMethod( Invocation.method( #getTransactionFee, [transaction], ), - returnValue: - _i10.Future<_i3.TransactionFee>.value(_FakeTransactionFee_1( + returnValue: _i9.Future<_i3.TransactionFee>.value(_FakeTransactionFee_1( this, Invocation.method( #getTransactionFee, @@ -400,35 +384,35 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { ), )), returnValueForMissingStub: - _i10.Future<_i3.TransactionFee>.value(_FakeTransactionFee_1( + _i9.Future<_i3.TransactionFee>.value(_FakeTransactionFee_1( this, Invocation.method( #getTransactionFee, [transaction], ), )), - ) as _i10.Future<_i3.TransactionFee>); + ) as _i9.Future<_i3.TransactionFee>); @override - _i10.Future>> getTransactionOwnerships( + _i9.Future>> getTransactionOwnerships( List? addresses) => (super.noSuchMethod( Invocation.method( #getTransactionOwnerships, [addresses], ), - returnValue: _i10.Future>>.value( - >{}), + returnValue: _i9.Future>>.value( + >{}), returnValueForMissingStub: - _i10.Future>>.value( - >{}), - ) as _i10.Future>>); + _i9.Future>>.value( + >{}), + ) as _i9.Future>>); @override _i4.Transaction newKeychainTransaction( String? seed, List? authorizedPublicKeys, - _i18.Uint8List? originPrivateKey, + _i16.Uint8List? originPrivateKey, int? blockchainTxVersion, { Map? servicesMap, }) => @@ -474,8 +458,8 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { @override _i4.Transaction newAccessKeychainTransaction( String? seed, - _i18.Uint8List? keychainAddress, - _i18.Uint8List? originPrivateKey, + _i16.Uint8List? keychainAddress, + _i16.Uint8List? originPrivateKey, int? blockchainTxVersion, ) => (super.noSuchMethod( @@ -515,12 +499,12 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { ) as _i4.Transaction); @override - _i10.Future<_i5.Keychain> getKeychain(String? seed) => (super.noSuchMethod( + _i9.Future<_i5.Keychain> getKeychain(String? seed) => (super.noSuchMethod( Invocation.method( #getKeychain, [seed], ), - returnValue: _i10.Future<_i5.Keychain>.value(_FakeKeychain_3( + returnValue: _i9.Future<_i5.Keychain>.value(_FakeKeychain_3( this, Invocation.method( #getKeychain, @@ -528,14 +512,14 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { ), )), returnValueForMissingStub: - _i10.Future<_i5.Keychain>.value(_FakeKeychain_3( + _i9.Future<_i5.Keychain>.value(_FakeKeychain_3( this, Invocation.method( #getKeychain, [seed], ), )), - ) as _i10.Future<_i5.Keychain>); + ) as _i9.Future<_i5.Keychain>); @override String getOriginKey() => (super.noSuchMethod( @@ -543,14 +527,14 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { #getOriginKey, [], ), - returnValue: _i13.dummyValue( + returnValue: _i11.dummyValue( this, Invocation.method( #getOriginKey, [], ), ), - returnValueForMissingStub: _i13.dummyValue( + returnValueForMissingStub: _i11.dummyValue( this, Invocation.method( #getOriginKey, @@ -560,7 +544,7 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { ) as String); @override - _i10.Future addOriginKey({ + _i9.Future addOriginKey({ String? originPublicKey, String? certificate, }) => @@ -573,7 +557,7 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { #certificate: certificate, }, ), - returnValue: _i10.Future.value(_i13.dummyValue( + returnValue: _i9.Future.value(_i11.dummyValue( this, Invocation.method( #addOriginKey, @@ -585,7 +569,7 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { ), )), returnValueForMissingStub: - _i10.Future.value(_i13.dummyValue( + _i9.Future.value(_i11.dummyValue( this, Invocation.method( #addOriginKey, @@ -596,10 +580,10 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { }, ), )), - ) as _i10.Future); + ) as _i9.Future); @override - _i10.Future> getToken( + _i9.Future> getToken( List? addresses, { String? request = r'genesis, name, id, supply, symbol, type, properties, decimals, collection, ownerships { authorizedPublicKeys { encryptedSecretKey, publicKey }, secret }', @@ -611,63 +595,61 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { {#request: request}, ), returnValue: - _i10.Future>.value({}), + _i9.Future>.value({}), returnValueForMissingStub: - _i10.Future>.value({}), - ) as _i10.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i10.Future> getNearestEndpoints() => (super.noSuchMethod( + _i9.Future> getNearestEndpoints() => (super.noSuchMethod( Invocation.method( #getNearestEndpoints, [], ), - returnValue: _i10.Future>.value(<_i20.Endpoint>[]), + returnValue: _i9.Future>.value(<_i18.Endpoint>[]), returnValueForMissingStub: - _i10.Future>.value(<_i20.Endpoint>[]), - ) as _i10.Future>); + _i9.Future>.value(<_i18.Endpoint>[]), + ) as _i9.Future>); @override - _i10.Future<_i6.Address> getGenesisAddress(String? address) => + _i9.Future<_i6.Address> getGenesisAddress(String? address) => (super.noSuchMethod( Invocation.method( #getGenesisAddress, [address], ), - returnValue: _i10.Future<_i6.Address>.value(_FakeAddress_4( + returnValue: _i9.Future<_i6.Address>.value(_FakeAddress_4( this, Invocation.method( #getGenesisAddress, [address], ), )), - returnValueForMissingStub: - _i10.Future<_i6.Address>.value(_FakeAddress_4( + returnValueForMissingStub: _i9.Future<_i6.Address>.value(_FakeAddress_4( this, Invocation.method( #getGenesisAddress, [address], ), )), - ) as _i10.Future<_i6.Address>); + ) as _i9.Future<_i6.Address>); @override - _i10.Future> callSCFunctionMulti( - {required List<_i21.SCCallFunctionRequest>? jsonRPCRequests}) => + _i9.Future> callSCFunctionMulti( + {required List<_i19.SCCallFunctionRequest>? jsonRPCRequests}) => (super.noSuchMethod( Invocation.method( #callSCFunctionMulti, [], {#jsonRPCRequests: jsonRPCRequests}, ), - returnValue: _i10.Future>.value([]), - returnValueForMissingStub: - _i10.Future>.value([]), - ) as _i10.Future>); + returnValue: _i9.Future>.value([]), + returnValueForMissingStub: _i9.Future>.value([]), + ) as _i9.Future>); @override - _i10.Future callSCFunction({ - required _i21.SCCallFunctionRequest? jsonRPCRequest, + _i9.Future callSCFunction({ + required _i19.SCCallFunctionRequest? jsonRPCRequest, bool? resultMap = false, }) => (super.noSuchMethod( @@ -679,7 +661,7 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { #resultMap: resultMap, }, ), - returnValue: _i10.Future.value(_FakeObject_5( + returnValue: _i9.Future.value(_FakeObject_5( this, Invocation.method( #callSCFunction, @@ -690,7 +672,7 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { }, ), )), - returnValueForMissingStub: _i10.Future.value(_FakeObject_5( + returnValueForMissingStub: _i9.Future.value(_FakeObject_5( this, Invocation.method( #callSCFunction, @@ -701,16 +683,16 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { }, ), )), - ) as _i10.Future); + ) as _i9.Future); @override - _i10.Future<_i7.BlockchainVersionModel> getBlockchainVersion() => + _i9.Future<_i7.BlockchainVersionModel> getBlockchainVersion() => (super.noSuchMethod( Invocation.method( #getBlockchainVersion, [], ), - returnValue: _i10.Future<_i7.BlockchainVersionModel>.value( + returnValue: _i9.Future<_i7.BlockchainVersionModel>.value( _FakeBlockchainVersionModel_6( this, Invocation.method( @@ -718,19 +700,18 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { [], ), )), - returnValueForMissingStub: - _i10.Future<_i7.BlockchainVersionModel>.value( - _FakeBlockchainVersionModel_6( + returnValueForMissingStub: _i9.Future<_i7.BlockchainVersionModel>.value( + _FakeBlockchainVersionModel_6( this, Invocation.method( #getBlockchainVersion, [], ), )), - ) as _i10.Future<_i7.BlockchainVersionModel>); + ) as _i9.Future<_i7.BlockchainVersionModel>); @override - void manageLinkException(_i22.QueryResult? result) => + void manageLinkException(_i20.QueryResult? result) => super.noSuchMethod( Invocation.method( #manageLinkException, @@ -754,7 +735,7 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { ], {#id: id}, ), - returnValue: _i13.dummyValue( + returnValue: _i11.dummyValue( this, Invocation.method( #setJsonRPCRequest, @@ -765,7 +746,7 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { {#id: id}, ), ), - returnValueForMissingStub: _i13.dummyValue( + returnValueForMissingStub: _i11.dummyValue( this, Invocation.method( #setJsonRPCRequest, @@ -793,14 +774,14 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { #getJsonRPCResultString, [body], ), - returnValue: _i13.dummyValue( + returnValue: _i11.dummyValue( this, Invocation.method( #getJsonRPCResultString, [body], ), ), - returnValueForMissingStub: _i13.dummyValue( + returnValueForMissingStub: _i11.dummyValue( this, Invocation.method( #getJsonRPCResultString, @@ -810,39 +791,30 @@ class MockApiService extends _i1.Mock implements _i12.ApiService { ) as String); } -/// A class which mocks [TokensRepositoryImpl]. +/// A class which mocks [TokensRepository]. /// /// See the documentation for Mockito's code generation for more information. -class MockTokensRepositoryImpl extends _i1.Mock - implements _i23.TokensRepositoryImpl { +class MockTokensRepository extends _i1.Mock implements _i21.TokensRepository { @override - _i10.Future> getTokensFromAddresses( - List? addresses, - _i12.ApiService? apiService, - ) => + _i9.Future> getTokensFromAddresses( + List? addresses) => (super.noSuchMethod( Invocation.method( #getTokensFromAddresses, - [ - addresses, - apiService, - ], + [addresses], ), returnValue: - _i10.Future>.value({}), + _i9.Future>.value({}), returnValueForMissingStub: - _i10.Future>.value({}), - ) as _i10.Future>); + _i9.Future>.value({}), + ) as _i9.Future>); @override - _i10.Future> getTokensFromUserBalance( + _i9.Future> getTokensFromUserBalance( String? userGenesisAddress, List? userTokenLocalAddresses, - _i12.ApiService? apiService, - List<_i24.GetPoolListResponse>? poolsListRaw, - _i11.Environment? environment, - _i9.DefTokensRepositoryImpl? defTokensRepositoryImpl, - _i23.TokensRepositoryImpl? tokensRepositoryImpl, { + List<_i22.GetPoolListResponse>? poolsListRaw, + _i8.Environment? environment, { bool? withUCO = true, bool? withVerified = true, bool? withLPToken = true, @@ -855,11 +827,8 @@ class MockTokensRepositoryImpl extends _i1.Mock [ userGenesisAddress, userTokenLocalAddresses, - apiService, poolsListRaw, environment, - defTokensRepositoryImpl, - tokensRepositoryImpl, ], { #withUCO: withUCO, @@ -869,64 +838,8 @@ class MockTokensRepositoryImpl extends _i1.Mock #withCustomToken: withCustomToken, }, ), - returnValue: _i10.Future>.value(<_i8.AEToken>[]), + returnValue: _i9.Future>.value(<_i8.AEToken>[]), returnValueForMissingStub: - _i10.Future>.value(<_i8.AEToken>[]), - ) as _i10.Future>); - - @override - _i10.Future<_i8.AEToken> tokenModelToAETokenModel( - _i19.Token? token, - List? verifiedTokens, - List<_i24.GetPoolListResponse>? poolsListRaw, - _i11.Environment? environment, - _i12.ApiService? apiService, - _i9.DefTokensRepositoryImpl? defTokensRepository, - _i23.TokensRepositoryImpl? tokensRepository, - ) => - (super.noSuchMethod( - Invocation.method( - #tokenModelToAETokenModel, - [ - token, - verifiedTokens, - poolsListRaw, - environment, - apiService, - defTokensRepository, - tokensRepository, - ], - ), - returnValue: _i10.Future<_i8.AEToken>.value(_FakeAEToken_7( - this, - Invocation.method( - #tokenModelToAETokenModel, - [ - token, - verifiedTokens, - poolsListRaw, - environment, - apiService, - defTokensRepository, - tokensRepository, - ], - ), - )), - returnValueForMissingStub: - _i10.Future<_i8.AEToken>.value(_FakeAEToken_7( - this, - Invocation.method( - #tokenModelToAETokenModel, - [ - token, - verifiedTokens, - poolsListRaw, - environment, - apiService, - defTokensRepository, - tokensRepository, - ], - ), - )), - ) as _i10.Future<_i8.AEToken>); + _i9.Future>.value(<_i8.AEToken>[]), + ) as _i9.Future>); }