mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
94 files changed, -5926 net lines. No stubs, no generators, no dead enum
values, no orphan switch branches. Removed for principled reasons (we
do not ship these chains) and to make the codebase smaller and friendlier
to contribute to.
What's gone:
- lib/{solana,tron,zano,decred,zcash,haven}/ directories
- lib/exchange/provider/jupiter_exchange_provider.dart (Solana-only)
- lib/entities/haven_seed_store.dart
- WalletType.{solana,tron,zano,decred,zcash,haven} enum values
(HiveField IDs are pinned: Wownero stays at 12, all surviving types
keep their IDs, so existing user-saved wallets deserialize unchanged)
- All ~70 lib/ files that imported the removed chain stubs or branched
on the removed WalletType values
- backupSeeds(Box<HavenSeedStore>) abstract method + Wownero implementation
- Jupiter exchange branches in send/exchange view models
- TronGrid usage settings, Zano alias lookups, Zcash transparent address
handling, Decred default-spv-nodes branches, Haven seed migration
What stays (intentional):
- CryptoCurrency.{xhv,sol,trx,dcr,zano,zec} enum entries in cw_core —
they're still used as exchange/swap currency identifiers in
address_validator.dart and elsewhere. The wallet types are gone but
the *currencies* are still tradeable through Trocador.
- cw_core/spl_token.dart and cw_core/tron_token.dart Hive adapters in
main.dart — the tokens still register as Hive types for backwards-
compat with any old box data.
- lib/buy/{moonpay,robinhood,onramper,dfx,kryptonim,meld}/ provider
source files (just stripped of solana/tron/etc references; providers
themselves remain dormant per provider_types.dart).
Pinned-ID note: WalletType enum now has gaps in @HiveField IDs (4, 10,
11, 13, 14, 18 removed). This is deliberate — re-using a freed ID later
would mis-deserialize old hive boxes. Don't renumber.
Bundled config / CI hasn't changed; configure.dart was already free of
these chains in commit 4eb7db0b7.
159 lines
5.8 KiB
Dart
159 lines
5.8 KiB
Dart
import 'package:hash_wallet/bitcoin/bitcoin.dart';
|
|
import 'package:hash_wallet/di.dart';
|
|
import 'package:hash_wallet/entities/auto_generate_subaddress_status.dart';
|
|
import 'package:hash_wallet/entities/fiat_api_mode.dart';
|
|
import 'package:hash_wallet/entities/wallet_manager.dart';
|
|
import 'package:hash_wallet/evm/evm.dart';
|
|
import 'package:hash_wallet/reactions/wallet_connect.dart';
|
|
import 'package:hash_wallet/utils/tor.dart';
|
|
import 'package:cw_core/crypto_currency.dart';
|
|
import 'package:cw_core/sync_status.dart';
|
|
import 'package:cw_core/transaction_history.dart';
|
|
import 'package:cw_core/balance.dart';
|
|
import 'package:cw_core/transaction_info.dart';
|
|
import 'package:cw_core/utils/print_verbose.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
import 'package:hash_wallet/reactions/check_connection.dart';
|
|
import 'package:hash_wallet/reactions/on_wallet_sync_status_change.dart';
|
|
import 'package:hash_wallet/store/dashboard/fiat_conversion_store.dart';
|
|
import 'package:hash_wallet/store/app_store.dart';
|
|
import 'package:hash_wallet/store/settings_store.dart';
|
|
import 'package:hash_wallet/core/fiat_conversion_service.dart';
|
|
import 'package:cw_core/wallet_base.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
|
|
ReactionDisposer? _onCurrentWalletChangeReaction;
|
|
ReactionDisposer? _onCurrentWalletChangeFiatRateUpdateReaction;
|
|
//ReactionDisposer _onCurrentWalletAddressChangeReaction;
|
|
|
|
void startCurrentWalletChangeReaction(
|
|
AppStore appStore, SettingsStore settingsStore, FiatConversionStore fiatConversionStore) {
|
|
_onCurrentWalletChangeReaction?.reaction.dispose();
|
|
_onCurrentWalletChangeFiatRateUpdateReaction?.reaction.dispose();
|
|
//_onCurrentWalletAddressChangeReaction?.reaction?dispose();
|
|
|
|
//_onCurrentWalletAddressChangeReaction = reaction((_) => appStore.wallet.walletAddresses.address,
|
|
//(String address) async {
|
|
//if (address == appStore.wallet.walletInfo.yatLastUsedAddress) {
|
|
// return;
|
|
//}
|
|
|
|
//try {
|
|
// final yatStore = getIt.get<YatStore>();
|
|
// await updateEmojiIdAddress(
|
|
// appStore.wallet.walletInfo.yatEmojiId,
|
|
// appStore.wallet.walletAddresses.address,
|
|
// yatStore.apiKey,
|
|
// appStore.wallet.type
|
|
// );
|
|
// appStore.wallet.walletInfo.yatLastUsedAddress = address;
|
|
// await appStore.wallet.walletInfo.save();
|
|
//} catch (e) {
|
|
// printV(e.toString());
|
|
//}
|
|
//});
|
|
|
|
_onCurrentWalletChangeReaction = reaction((_) => appStore.wallet,
|
|
(WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>?
|
|
wallet) async {
|
|
try {
|
|
if (wallet == null) {
|
|
return;
|
|
}
|
|
|
|
await getIt.get<WalletManager>().ensureGroupHasHashedIdentifier(wallet);
|
|
|
|
int? chainId;
|
|
if (isEVMCompatibleChain(wallet.type)) {
|
|
chainId = evm!.getSelectedChainId(wallet);
|
|
}
|
|
|
|
final node = settingsStore.getCurrentNode(wallet.type, chainId: chainId);
|
|
|
|
startWalletSyncStatusChangeReaction(wallet, settingsStore);
|
|
startCheckConnectionReaction(wallet, settingsStore);
|
|
|
|
await Future.delayed(Duration.zero);
|
|
|
|
if (wallet.type == WalletType.monero ||
|
|
wallet.type == WalletType.wownero ||
|
|
wallet.type == WalletType.bitcoin ||
|
|
wallet.type == WalletType.litecoin ||
|
|
wallet.type == WalletType.bitcoinCash ||
|
|
wallet.type == WalletType.dogecoin) {
|
|
_setAutoGenerateSubaddressStatus(wallet, settingsStore);
|
|
}
|
|
|
|
if (wallet.type == WalletType.bitcoin) {
|
|
bitcoin!.updatePayjoinState(wallet, settingsStore.usePayjoin);
|
|
}
|
|
|
|
if (settingsStore.currentBuiltinTor) {
|
|
await ensureTorStarted(context: null);
|
|
}
|
|
|
|
await wallet.connectToNode(node: node);
|
|
SyncingSyncStatus.blockHistory.clear();
|
|
if (wallet.type == WalletType.nano || wallet.type == WalletType.banano) {
|
|
final powNode = settingsStore.getCurrentPowNode(wallet.type);
|
|
await wallet.connectToPowNode(node: powNode);
|
|
}
|
|
|
|
if (wallet.walletInfo.address.isEmpty) {
|
|
wallet.walletInfo.address = wallet.walletAddresses.address;
|
|
|
|
await wallet.walletInfo.save();
|
|
}
|
|
|
|
if (isEVMCompatibleChain(wallet.type)) {
|
|
await evm!.discoverAndAddWalletTokens(wallet);
|
|
}
|
|
} catch (e) {
|
|
printV(e.toString());
|
|
}
|
|
});
|
|
|
|
_onCurrentWalletChangeFiatRateUpdateReaction = reaction((_) => appStore.wallet,
|
|
(WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo>?
|
|
wallet) async {
|
|
try {
|
|
if (wallet == null || settingsStore.fiatApiMode == FiatApiMode.disabled) {
|
|
return;
|
|
}
|
|
|
|
fiatConversionStore.prices[wallet.currency] = 0;
|
|
fiatConversionStore.prices[wallet.currency] = await FiatConversionService.fetchPrice(
|
|
crypto: wallet.currency,
|
|
fiat: settingsStore.fiatCurrency,
|
|
torOnly: settingsStore.fiatApiMode == FiatApiMode.torOnly);
|
|
|
|
Iterable<CryptoCurrency>? currencies;
|
|
if (isEVMCompatibleChain(wallet.type)) {
|
|
currencies = evm!.getERC20Currencies(appStore.wallet!).where((element) => element.enabled);
|
|
}
|
|
|
|
if (currencies != null) {
|
|
for (final currency in currencies) {
|
|
() async {
|
|
fiatConversionStore.prices[currency] = await FiatConversionService.fetchPrice(
|
|
crypto: currency,
|
|
fiat: settingsStore.fiatCurrency,
|
|
torOnly: settingsStore.fiatApiMode == FiatApiMode.torOnly);
|
|
}.call();
|
|
}
|
|
}
|
|
} catch (e) {
|
|
printV(e.toString());
|
|
}
|
|
});
|
|
}
|
|
|
|
void _setAutoGenerateSubaddressStatus(
|
|
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> wallet,
|
|
SettingsStore settingsStore,
|
|
) async {
|
|
wallet.isEnabledAutoGenerateSubaddress =
|
|
settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.enabled ||
|
|
settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.initialized;
|
|
}
|