Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: ⚡ Use AEIP21 updates to display recent txn #1221

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
435 changes: 246 additions & 189 deletions lib/application/account/account_notifier.dart

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/application/account/account_notifier.g.dart

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

13 changes: 10 additions & 3 deletions lib/application/account/accounts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import 'dart:async';

import 'package:aewallet/application/account/accounts_notifier.dart';
import 'package:aewallet/application/address_service.dart';
import 'package:aewallet/model/data/account.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
Expand All @@ -12,10 +13,16 @@ part 'accounts.g.dart';
@riverpod
Future<Account?> accountWithGenesisAddress(
Ref ref,
String genesisAddress,
) async {
String address, {
bool searchGenesisAddress = false,
}) async {
var addressToSearch = address;
if (searchGenesisAddress) {
addressToSearch = await ref.watch(genesisAddressProvider(address).future);
}

final accounts = await ref.watch(accountsNotifierProvider.future);
return accounts.getAccountWithGenesisAddress(genesisAddress);
return accounts.getAccountWithGenesisAddress(addressToSearch);
}

@riverpod
Expand Down
52 changes: 34 additions & 18 deletions lib/application/account/accounts.g.dart

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

10 changes: 0 additions & 10 deletions lib/application/account/accounts_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ class AccountsNotifier extends _$AccountsNotifier {

return ref.read(accountNotifierProvider(accountName).notifier);
}

// TODO(Chralu): check if this works
Future<void> clearRecentTransactionsFromCache() async {
final accounts = await future;
for (final account in accounts) {
await ref
.read(accountNotifierProvider(account.name).notifier)
.clearRecentTransactionsFromCache();
}
}
}

extension AccountsExt on Iterable<Account> {
Expand Down
2 changes: 1 addition & 1 deletion lib/application/account/accounts_notifier.g.dart

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

16 changes: 0 additions & 16 deletions lib/application/account/selected_account.dart
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
/// SPDX-License-Identifier: AGPL-3.0-or-later

import 'dart:async';

import 'package:aewallet/application/account/accounts_notifier.dart';
import 'package:aewallet/model/blockchain/recent_transaction.dart';
import 'package:aewallet/model/data/account_token.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'selected_account.g.dart';

@riverpod
Future<List<RecentTransaction>?> selectedAccountRecentTransactions(
Ref ref,
) async {
return ref
.watch(
accountsNotifierProvider.select(
(accounts) => accounts.valueOrNull?.selectedAccount,
),
)
?.recentTransactions;
}

@riverpod
List<AccountToken> selectedAccountNFTFiltered(
Ref ref,
Expand Down
20 changes: 0 additions & 20 deletions lib/application/account/selected_account.g.dart

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

15 changes: 15 additions & 0 deletions lib/application/address_service.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:aewallet/application/api_service.dart';
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';
Expand All @@ -10,3 +11,17 @@ AddressService addressService(Ref ref) {
final environment = ref.watch(environmentProvider);
return AddressService(environment.endpoint);
}

@riverpod
Future<String> genesisAddress(Ref ref, String address) async {
final apiService = ref.watch(apiServiceProvider);
var genesisAddress = address;
try {
genesisAddress =
(await apiService.getGenesisAddress(address)).address ?? address;
} catch (e)
// ignore: empty_catches
{}

return genesisAddress;
}
Loading
Loading