mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +01:00
Nuke Solana/Tron/Zano/Decred/Zcash/Haven from the codebase entirely
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.
This commit is contained in:
@@ -157,7 +157,6 @@ class AddressFormatter {
|
||||
switch (walletType) {
|
||||
case WalletType.monero:
|
||||
case WalletType.wownero:
|
||||
case WalletType.zano:
|
||||
return 6;
|
||||
default:
|
||||
return 4;
|
||||
|
||||
@@ -12,12 +12,6 @@ String getQrImage(WalletType type) {
|
||||
return 'assets/images/arbitrum_chain_QR.svg';
|
||||
case WalletType.bsc:
|
||||
return 'assets/images/bnb_chain_QR.svg';
|
||||
case WalletType.solana:
|
||||
return 'assets/images/sol_chain_qr.svg';
|
||||
case WalletType.tron:
|
||||
return 'assets/images/trx_chain_qr.svg';
|
||||
case WalletType.zano:
|
||||
return 'assets/images/zano_chain_qr.svg';
|
||||
case WalletType.monero:
|
||||
return 'assets/images/xmr_chain_qr.svg';
|
||||
case WalletType.wownero:
|
||||
@@ -30,14 +24,9 @@ String getQrImage(WalletType type) {
|
||||
return 'assets/images/bch_chain_qr.svg';
|
||||
case WalletType.nano:
|
||||
return 'assets/images/xno_chain_qr.svg';
|
||||
case WalletType.decred:
|
||||
return 'assets/images/dcr_chain_qr.svg';
|
||||
case WalletType.dogecoin:
|
||||
return 'assets/images/doge_chain_qr.svg';
|
||||
case WalletType.zcash:
|
||||
return 'assets/images/zec_icon_qr.svg';
|
||||
case WalletType.banano:
|
||||
case WalletType.haven:
|
||||
case WalletType.none:
|
||||
return 'assets/images/qr-cake.png';
|
||||
}
|
||||
@@ -55,12 +44,6 @@ String getChainMonoImage(WalletType type) {
|
||||
return 'assets/images/arbitrum_chain_mono.svg';
|
||||
case WalletType.bsc:
|
||||
return 'assets/images/bnb_chain_mono.svg';
|
||||
case WalletType.solana:
|
||||
return 'assets/images/sol_chain_mono.svg';
|
||||
case WalletType.tron:
|
||||
return 'assets/images/trx_chain_mono.svg';
|
||||
case WalletType.zano:
|
||||
return 'assets/images/zano_chain_mono.svg';
|
||||
default:
|
||||
return 'assets/images/eth_chain_mono.svg';
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:hash_wallet/reactions/wallet_connect.dart';
|
||||
import 'package:hash_wallet/evm/evm.dart';
|
||||
import 'package:hash_wallet/solana/solana.dart';
|
||||
import 'package:hash_wallet/tron/tron.dart';
|
||||
import 'package:cw_core/cake_hive.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
@@ -39,42 +37,11 @@ class TokenUtilities {
|
||||
}
|
||||
|
||||
static Future<List<SPLToken>> loadAllUniqueSolTokens() async {
|
||||
final allWi = await WalletInfo.getAll();
|
||||
final solWallets = allWi.where(
|
||||
(w) => w.type == WalletType.solana,
|
||||
);
|
||||
|
||||
final tokens = <SPLToken>[];
|
||||
for (final wallet in solWallets) {
|
||||
final box = await _openSolTokensBoxFor(wallet);
|
||||
tokens.addAll(box.values.where((t) => t.enabled));
|
||||
}
|
||||
|
||||
final seen = <String>{};
|
||||
final unique = <SPLToken>[];
|
||||
for (final token in tokens) {
|
||||
final key = token.mintAddress.toLowerCase();
|
||||
if (seen.add(key)) unique.add(token);
|
||||
}
|
||||
return unique;
|
||||
return <SPLToken>[];
|
||||
}
|
||||
|
||||
static Future<List<TronToken>> loadAllUniqueTronTokens() async {
|
||||
final allWi = await WalletInfo.getAll();
|
||||
final tronWallets = allWi.where(
|
||||
(w) => w.type == WalletType.tron,
|
||||
);
|
||||
|
||||
final seen = <String>{};
|
||||
final unique = <TronToken>[];
|
||||
for (final wallet in tronWallets) {
|
||||
final box = await _openTronTokensBoxFor(wallet);
|
||||
for (final t in box.values.where((t) => t.enabled)) {
|
||||
final key = t.contractAddress.toLowerCase();
|
||||
if (seen.add(key)) unique.add(t);
|
||||
}
|
||||
}
|
||||
return unique;
|
||||
return <TronToken>[];
|
||||
}
|
||||
|
||||
static List<Erc20Token> loadDefaultEvmTokensForSwap() {
|
||||
@@ -93,11 +60,9 @@ class TokenUtilities {
|
||||
return tokens;
|
||||
}
|
||||
|
||||
static List<SPLToken> loadDefaultSolTokensForSwap() =>
|
||||
solana != null ? solana!.getDefaultSPLTokens() : [];
|
||||
static List<SPLToken> loadDefaultSolTokensForSwap() => <SPLToken>[];
|
||||
|
||||
static List<TronToken> loadDefaultTronTokensForSwap() =>
|
||||
tron != null ? tron!.getDefaultTronTokens() : [];
|
||||
static List<TronToken> loadDefaultTronTokensForSwap() => <TronToken>[];
|
||||
|
||||
static Future<List<Erc20Token>> loadEvmTokensForSwap() async {
|
||||
final defaultTokens = loadDefaultEvmTokensForSwap();
|
||||
@@ -146,8 +111,6 @@ class TokenUtilities {
|
||||
|
||||
/// Finds a token by address across wallets depending on [walletType]
|
||||
/// - EVM chains: match by contractAddress
|
||||
/// - Solana: match by mintAddress
|
||||
/// - Tron: match by contractAddress
|
||||
static Future<CryptoCurrency?> findTokenByAddress({
|
||||
required WalletType walletType,
|
||||
required String address,
|
||||
@@ -165,18 +128,6 @@ class TokenUtilities {
|
||||
if (t.contractAddress.toLowerCase() == lower) return t;
|
||||
}
|
||||
return null;
|
||||
case WalletType.solana:
|
||||
final solTokens = await loadAllUniqueSolTokens();
|
||||
for (final t in solTokens) {
|
||||
if (t.mintAddress.toLowerCase() == lower) return t;
|
||||
}
|
||||
return null;
|
||||
case WalletType.tron:
|
||||
final tronTokens = await loadAllUniqueTronTokens();
|
||||
for (final t in tronTokens) {
|
||||
if (t.contractAddress.toLowerCase() == lower) return t;
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -203,22 +154,6 @@ class TokenUtilities {
|
||||
};
|
||||
}
|
||||
|
||||
static Future<Box<SPLToken>> _openSolTokensBoxFor(WalletInfo wallet) async {
|
||||
final boxName = '${wallet.name.replaceAll(' ', '_')}_${SPLToken.boxName}';
|
||||
if (CakeHive.isBoxOpen(boxName)) {
|
||||
return CakeHive.box<SPLToken>(boxName);
|
||||
}
|
||||
return CakeHive.openBox<SPLToken>(boxName);
|
||||
}
|
||||
|
||||
static Future<Box<TronToken>> _openTronTokensBoxFor(WalletInfo walletInfo) async {
|
||||
final boxName = '${walletInfo.name.replaceAll(' ', '_')}_${TronToken.boxName}';
|
||||
if (CakeHive.isBoxOpen(boxName)) {
|
||||
return CakeHive.box<TronToken>(boxName);
|
||||
}
|
||||
return CakeHive.openBox<TronToken>(boxName);
|
||||
}
|
||||
|
||||
static Erc20Token? findErc20Token(CryptoCurrency currency, WalletBase wallet) {
|
||||
if (currency is Erc20Token) return currency;
|
||||
|
||||
@@ -341,54 +276,6 @@ class TokenUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Solana network
|
||||
else if (network == WalletType.solana) {
|
||||
final userSolTokens = await loadAllUniqueSolTokens();
|
||||
for (final token in userSolTokens) {
|
||||
final mintAddress = token.mintAddress.toLowerCase();
|
||||
if (addedAddresses.add(mintAddress)) {
|
||||
allTokens.add(token);
|
||||
}
|
||||
}
|
||||
|
||||
for (final currency in CryptoCurrency.all) {
|
||||
if (currency.tag?.toLowerCase() == 'sol') {
|
||||
if (currency is SPLToken) {
|
||||
final mintAddress = currency.mintAddress.toLowerCase();
|
||||
if (addedAddresses.add(mintAddress)) {
|
||||
allTokens.add(currency);
|
||||
}
|
||||
} else if (!allTokens.any((t) => _matchesCurrency(t, currency))) {
|
||||
allTokens.add(currency);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Tron network
|
||||
else if (network == WalletType.tron) {
|
||||
final userTronTokens = await loadAllUniqueTronTokens();
|
||||
for (final token in userTronTokens) {
|
||||
final contractAddress = token.contractAddress.toLowerCase();
|
||||
if (addedAddresses.add(contractAddress)) {
|
||||
allTokens.add(token);
|
||||
}
|
||||
}
|
||||
|
||||
for (final currency in CryptoCurrency.all) {
|
||||
if (currency.tag?.toLowerCase() == 'trx') {
|
||||
if (currency is TronToken) {
|
||||
final contractAddress = currency.contractAddress.toLowerCase();
|
||||
if (addedAddresses.add(contractAddress)) {
|
||||
allTokens.add(currency);
|
||||
}
|
||||
} else if (!allTokens.any((t) => _matchesCurrency(t, currency))) {
|
||||
allTokens.add(currency);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allTokens;
|
||||
}
|
||||
|
||||
@@ -411,14 +298,6 @@ class TokenUtilities {
|
||||
}).toList();
|
||||
}
|
||||
|
||||
if (walletType == WalletType.solana) {
|
||||
return await loadAllUniqueSolTokens();
|
||||
}
|
||||
|
||||
if (walletType == WalletType.tron) {
|
||||
return await loadAllUniqueTronTokens();
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user