Skip to content

Commit

Permalink
chore: 🚨 Use Ref to prepare riverpod 3
Browse files Browse the repository at this point in the history
  • Loading branch information
redDwarf03 committed Dec 10, 2024
1 parent d7b09da commit d7a2883
Show file tree
Hide file tree
Showing 91 changed files with 547 additions and 291 deletions.
9 changes: 4 additions & 5 deletions lib/application/account/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ part 'accounts_notifier.dart';
part 'providers.g.dart';

@riverpod
AccountRepository _accountRepository(_AccountRepositoryRef ref) =>
AccountRepository();
AccountRepository _accountRepository(Ref ref) => AccountRepository();

@riverpod
Future<List<Account>> _sortedAccounts(_SortedAccountsRef ref) async {
Future<List<Account>> _sortedAccounts(Ref ref) async {
final accounts = await ref.watch(
AccountProviders.accounts.future,
);
Expand All @@ -43,7 +42,7 @@ Future<List<Account>> _sortedAccounts(_SortedAccountsRef ref) async {

@riverpod
List<AccountToken> _getAccountNFTFiltered(
_GetAccountNFTFilteredRef ref,
Ref ref,
Account account, {
bool? favorite,
}) {
Expand Down Expand Up @@ -107,7 +106,7 @@ class AccountRepository {

@Riverpod(keepAlive: true)
AccountLocalRepositoryInterface _accountsRepository(
_AccountsRepositoryRef ref,
Ref ref,
) =>
AccountLocalRepository();

Expand Down
22 changes: 17 additions & 5 deletions lib/application/account/providers.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/application/address_service.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import 'package:aewallet/modules/aeswap/application/session/provider.dart';
import 'package:archethic_lib_dart/archethic_lib_dart.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'address_service.g.dart';

@riverpod
AddressService addressService(AddressServiceRef ref) {
AddressService addressService(Ref ref) {
final environment = ref.watch(environmentProvider);
return AddressService(environment.endpoint);
}
6 changes: 4 additions & 2 deletions lib/application/address_service.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions lib/application/aeswap/dex_token.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ import 'package:aewallet/modules/aeswap/util/riverpod.dart';
import 'package:archethic_dapp_framework_flutter/archethic_dapp_framework_flutter.dart'
as aedappfm;
import 'package:collection/collection.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'dex_token.g.dart';

@riverpod
DexTokenRepositoryImpl _dexTokenRepository(_DexTokenRepositoryRef ref) =>
DexTokenRepositoryImpl _dexTokenRepository(Ref ref) =>
DexTokenRepositoryImpl(apiService: ref.watch(apiServiceProvider));

@riverpod
Future<DexToken?> _getTokenFromAddress(
_GetTokenFromAddressRef ref,
Ref ref,
address,
) async {
final environment = ref.read(environmentProvider);
Expand All @@ -28,7 +29,7 @@ Future<DexToken?> _getTokenFromAddress(

@riverpod
Future<List<DexToken>> _tokensFromAccount(
_TokensFromAccountRef ref,
Ref ref,
) async {
final accountSelected = ref.watch(
AccountProviders.accounts.select(
Expand All @@ -46,7 +47,7 @@ Future<List<DexToken>> _tokensFromAccount(

@riverpod
Future<List<DexToken>> _dexTokenBases(
_DexTokenBasesRef ref,
Ref ref,
) async {
final repository = ref.watch(_dexTokenRepositoryProvider);
final environment = ref.read(environmentProvider);
Expand All @@ -55,7 +56,7 @@ Future<List<DexToken>> _dexTokenBases(

@riverpod
Future<DexToken?> _dexTokenBase(
_DexTokenBaseRef ref,
Ref ref,
String address,
) async {
final dexTokens = await ref.watch(_dexTokenBasesProvider.future);
Expand All @@ -66,7 +67,7 @@ Future<DexToken?> _dexTokenBase(

@riverpod
Future<String?> _getTokenIcon(
_GetTokenIconRef ref,
Ref ref,
address,
) async {
final tokenDescription =
Expand All @@ -78,7 +79,7 @@ Future<String?> _getTokenIcon(
// TODO(reddwarf03): Doublon with ae_token.dart in aedappfm (ae_token is perhaps obsolete now)
@riverpod
Future<double> _estimateTokenInFiat(
_EstimateTokenInFiatRef ref,
Ref ref,
String tokenAddress,
) async {
if (tokenAddress.isUCO) {
Expand All @@ -102,7 +103,7 @@ Future<double> _estimateTokenInFiat(
/// if `lpTokenAmount` hasn't changed.
@riverpod
Future<({double token1, double token2})> _getRemoveAmounts(
_GetRemoveAmountsRef ref,
Ref ref,
String poolAddress,
double lpTokenAmount,
) async {
Expand All @@ -127,7 +128,7 @@ Future<({double token1, double token2})> _getRemoveAmounts(

@riverpod
Future<double> _estimateLPTokenInFiat(
_EstimateLPTokenInFiatRef ref,
Ref ref,
String token1Address,
String token2Address,
double lpTokenAmount,
Expand Down
38 changes: 28 additions & 10 deletions lib/application/aeswap/dex_token.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d7a2883

Please sign in to comment.