mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
* fix android CI * feat: Add Robinhood Chain, all major flows done. minor issue now is our providers don't support it yet as its still pretty early, two weeks from launch * feat: Add Robinhood Chain, all major flows done. minor issue now is our providers don't support it yet as its still pretty early, two weeks from launch * Cleanup * auto-reformat * fix ui issue and contact listing for tokens * fix: missing icons and crash for fee priority in settings * chore: cleanup * fixes from feedbacks * fix: review issues and sync to latest dev feat: switch history api to etherscan, add history toggle to privacy settings, exclude robETH from exchange pickers, skip tokens discovery for chains that moralis hasn't indexed, add tests * fix: address Robinhood review comments * fix: show Solana token icons in history * fix: address review comments and default Robinhood to PublicNode * fix: revert filter and refuse unmapped networks in provider --------- Co-authored-by: Robert Malikowski <malikowskirobert@gmail.com>
60 lines
1.6 KiB
Dart
60 lines
1.6 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:cake_wallet/store/app_store.dart';
|
|
import 'package:cake_wallet/core/wallet_loading_service.dart';
|
|
import 'package:cw_core/wallet_base.dart';
|
|
import 'package:cw_core/wallet_info.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:cw_core/utils/print_verbose.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
|
|
part 'wallet_switcher_view_model.g.dart';
|
|
|
|
class WalletSwitcherViewModel = WalletSwitcherViewModelBase with _$WalletSwitcherViewModel;
|
|
|
|
abstract class WalletSwitcherViewModelBase with Store {
|
|
WalletSwitcherViewModelBase({
|
|
required this.appStore,
|
|
required this.walletLoadingService,
|
|
});
|
|
|
|
final AppStore appStore;
|
|
final WalletLoadingService walletLoadingService;
|
|
|
|
@observable
|
|
WalletInfo? selectedWallet;
|
|
|
|
@observable
|
|
bool isProcessing = false;
|
|
|
|
@action
|
|
Future<List<WalletInfo>> getWallets(WalletType? walletType) async {
|
|
final wiList = await WalletInfo.getAll();
|
|
if (walletType == null) return wiList;
|
|
return wiList.where((wallet) => wallet.type == walletType).toList();
|
|
}
|
|
|
|
@action
|
|
void selectWallet(WalletInfo walletInfo) => selectedWallet = walletInfo;
|
|
|
|
@action
|
|
Future<bool> switchToSelectedWallet() async {
|
|
if (selectedWallet == null) return false;
|
|
|
|
try {
|
|
isProcessing = true;
|
|
|
|
final wallet = await walletLoadingService.load(selectedWallet!.type, selectedWallet!.name);
|
|
|
|
await appStore.changeCurrentWallet(wallet);
|
|
|
|
return true;
|
|
} catch (e) {
|
|
printV('Failed to switch wallet: $e');
|
|
return false;
|
|
} finally {
|
|
isProcessing = false;
|
|
}
|
|
}
|
|
}
|