mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-03 12:24:19 +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:
@@ -56,9 +56,6 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
|
||||
case WalletType.base:
|
||||
case WalletType.arbitrum:
|
||||
case WalletType.bsc:
|
||||
case WalletType.solana:
|
||||
case WalletType.tron:
|
||||
case WalletType.zcash:
|
||||
return true;
|
||||
|
||||
case WalletType.bitcoin:
|
||||
@@ -72,9 +69,6 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
|
||||
case WalletType.monero:
|
||||
case WalletType.wownero:
|
||||
case WalletType.none:
|
||||
case WalletType.haven:
|
||||
case WalletType.zano:
|
||||
case WalletType.decred:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -100,13 +94,9 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
|
||||
WalletType.base,
|
||||
WalletType.arbitrum,
|
||||
WalletType.bsc,
|
||||
WalletType.tron,
|
||||
WalletType.solana,
|
||||
WalletType.monero,
|
||||
WalletType.wownero,
|
||||
WalletType.zano,
|
||||
WalletType.dogecoin,
|
||||
WalletType.zcash,
|
||||
].contains(type);
|
||||
|
||||
@computed
|
||||
|
||||
@@ -118,8 +118,6 @@ abstract class CakePayBuyCardViewModelBase with Store {
|
||||
];
|
||||
case WalletType.monero:
|
||||
return [CakePayPaymentMethod.XMR];
|
||||
case WalletType.zcash:
|
||||
return [CakePayPaymentMethod.ZEC];
|
||||
default:
|
||||
return const [];
|
||||
}
|
||||
@@ -148,10 +146,9 @@ abstract class CakePayBuyCardViewModelBase with Store {
|
||||
WalletType.bitcoin,
|
||||
WalletType.monero,
|
||||
WalletType.litecoin,
|
||||
WalletType.zcash,
|
||||
].contains(walletType)) {
|
||||
sendViewModel.state =
|
||||
FailureState('Unsupported wallet type, please use Bitcoin, Monero, Litecoin or Zcash.');
|
||||
FailureState('Unsupported wallet type, please use Bitcoin, Monero, or Litecoin.');
|
||||
}
|
||||
try {
|
||||
order = await _cakePayService.createOrder(
|
||||
|
||||
@@ -37,7 +37,7 @@ abstract class ContactListViewModelBase with Store {
|
||||
for (final info in walletInfos) {
|
||||
final addressInfos = await info.getAddressInfos();
|
||||
final addresses = await info.getAddresses();
|
||||
if ([WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type) &&
|
||||
if ([WalletType.monero, WalletType.wownero].contains(info.type) &&
|
||||
addressInfos.isNotEmpty) {
|
||||
for (var key in addressInfos.keys) {
|
||||
final value = addressInfos[key];
|
||||
@@ -55,7 +55,7 @@ abstract class ContactListViewModelBase with Store {
|
||||
}
|
||||
}
|
||||
} else if (addresses.isNotEmpty == true && addresses.length > 1) {
|
||||
if ([WalletType.monero, WalletType.wownero, WalletType.haven, WalletType.decred]
|
||||
if ([WalletType.monero, WalletType.wownero]
|
||||
.contains(info.type)) {
|
||||
final address = info.address;
|
||||
final name = _createName(info.name, "", key: 0);
|
||||
@@ -89,7 +89,7 @@ abstract class ContactListViewModelBase with Store {
|
||||
walletContacts.add(WalletContact(
|
||||
info.address,
|
||||
_createName(info.name, "",
|
||||
key: [WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type)
|
||||
key: [WalletType.monero, WalletType.wownero].contains(info.type)
|
||||
? 0
|
||||
: null),
|
||||
getCryptoCurrencyForWalletListItem(
|
||||
|
||||
@@ -7,9 +7,6 @@ import 'package:hash_wallet/entities/sort_balance_types.dart';
|
||||
import 'package:hash_wallet/generated/i18n.dart';
|
||||
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:hash_wallet/zano/zano.dart';
|
||||
import 'package:cw_core/crypto_amount_format.dart';
|
||||
import 'package:cw_core/transaction_history.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
@@ -122,9 +119,7 @@ abstract class BalanceViewModelBase with Store {
|
||||
bool get isFiatDisabled => settingsStore.fiatApiMode == FiatApiMode.disabled;
|
||||
|
||||
@computed
|
||||
bool get isHomeScreenSettingsEnabled =>
|
||||
isEVMCompatibleChain(wallet.type) ||
|
||||
[WalletType.solana, WalletType.tron, WalletType.zano].contains(wallet.type);
|
||||
bool get isHomeScreenSettingsEnabled => isEVMCompatibleChain(wallet.type);
|
||||
|
||||
@computed
|
||||
bool get isEVMCompatible => isEVMCompatibleChain(wallet.type);
|
||||
@@ -151,12 +146,7 @@ abstract class BalanceViewModelBase with Store {
|
||||
|
||||
final typeFormatted = walletTypeToString(wallet.type);
|
||||
|
||||
switch (wallet.type) {
|
||||
case WalletType.haven:
|
||||
return '$typeFormatted Assets';
|
||||
default:
|
||||
return typeFormatted;
|
||||
}
|
||||
return typeFormatted;
|
||||
}
|
||||
|
||||
@computed
|
||||
@@ -184,14 +174,11 @@ abstract class BalanceViewModelBase with Store {
|
||||
@computed
|
||||
String get additionalBalanceLabel {
|
||||
switch (wallet.type) {
|
||||
case WalletType.haven:
|
||||
case WalletType.ethereum:
|
||||
case WalletType.polygon:
|
||||
case WalletType.base:
|
||||
case WalletType.arbitrum:
|
||||
case WalletType.bsc:
|
||||
case WalletType.solana:
|
||||
case WalletType.tron:
|
||||
return S.current.xmr_full_balance;
|
||||
case WalletType.nano:
|
||||
case WalletType.banano:
|
||||
@@ -346,9 +333,6 @@ abstract class BalanceViewModelBase with Store {
|
||||
bool _hasAdditionalBalanceForWalletType(WalletType type) => [
|
||||
WalletType.monero,
|
||||
WalletType.wownero,
|
||||
WalletType.zano,
|
||||
WalletType.decred,
|
||||
WalletType.zcash
|
||||
].contains(type);
|
||||
|
||||
String _getFormattedCryptoAmount(CryptoCurrency cryptoCurrency, BigInt? amount) {
|
||||
@@ -383,7 +367,7 @@ abstract class BalanceViewModelBase with Store {
|
||||
if (a.asset == wallet.currency) return -1;
|
||||
}
|
||||
|
||||
final isTokenWallet = isEVMCompatibleChain(wallet.type) || wallet.type == WalletType.solana;
|
||||
final isTokenWallet = isEVMCompatibleChain(wallet.type);
|
||||
|
||||
if (isTokenWallet) {
|
||||
final aIsToken = a.asset is Erc20Token || a.asset is SPLToken;
|
||||
@@ -434,22 +418,10 @@ abstract class BalanceViewModelBase with Store {
|
||||
}
|
||||
|
||||
String? getTokenAddressBasedOnWallet(CryptoCurrency asset) {
|
||||
if (wallet.type == WalletType.tron) {
|
||||
return tron!.getTokenAddress(asset);
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.solana) {
|
||||
return solana!.getTokenAddress(asset);
|
||||
}
|
||||
|
||||
if (isEVMCompatibleChain(wallet.type) && asset is Erc20Token) {
|
||||
return evm!.getTokenAddress(asset);
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.zano) {
|
||||
return zano!.getZanoAssetAddress(asset);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -532,13 +504,6 @@ abstract class BalanceViewModelBase with Store {
|
||||
}
|
||||
|
||||
String _formatterAsset(CryptoCurrency asset) {
|
||||
final assetString = asset.toString();
|
||||
if (wallet.type == WalletType.haven &&
|
||||
asset != CryptoCurrency.xhv &&
|
||||
assetString[0].toUpperCase() == 'X') {
|
||||
return assetString.replaceFirst('X', 'x');
|
||||
}
|
||||
|
||||
return appStore.amountParsingProxy.getCryptoSymbol(asset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import 'package:hash_wallet/src/widgets/alert_with_one_action.dart';
|
||||
import 'package:hash_wallet/store/dashboard/order_filter_store.dart';
|
||||
import 'package:hash_wallet/utils/device_info.dart';
|
||||
import 'package:hash_wallet/utils/show_pop_up.dart';
|
||||
import 'package:hash_wallet/zcash/zcash.dart';
|
||||
import 'package:cw_core/transaction_direction.dart';
|
||||
import 'package:cw_core/utils/proxy_wrapper.dart';
|
||||
import 'package:hash_wallet/utils/tor.dart';
|
||||
@@ -208,8 +207,7 @@ abstract class DashboardViewModelBase with Store {
|
||||
cardDesigns = ObservableList<CardDesign>(),
|
||||
cardOrder = ObservableMap<int, int>(),
|
||||
wallet = appStore.wallet! {
|
||||
showDecredInfoCard = wallet.type == WalletType.decred &&
|
||||
(sharedPreferences.getBool(PreferencesKey.showDecredInfoCard) ?? true);
|
||||
showDecredInfoCard = false;
|
||||
|
||||
name = wallet.name;
|
||||
type = wallet.type;
|
||||
@@ -306,8 +304,7 @@ abstract class DashboardViewModelBase with Store {
|
||||
_onWalletChange(wallet);
|
||||
_checkMweb();
|
||||
loadCardDesigns();
|
||||
showDecredInfoCard = wallet?.type == WalletType.decred &&
|
||||
sharedPreferences.getBool(PreferencesKey.showDecredInfoCard) != false;
|
||||
showDecredInfoCard = false;
|
||||
|
||||
tradeMonitor.stopTradeMonitoring();
|
||||
tradeMonitor.monitorActiveTrades(wallet!.id);
|
||||
@@ -320,14 +317,12 @@ abstract class DashboardViewModelBase with Store {
|
||||
return 0;
|
||||
}
|
||||
int confirmations = 1;
|
||||
if (![WalletType.solana, WalletType.tron].contains(wallet.type)) {
|
||||
try {
|
||||
confirmations =
|
||||
appStore.wallet!.transactionHistory.transactions.values.first.confirmations +
|
||||
appStore.wallet!.transactionHistory.transactions.values.last.confirmations +
|
||||
1;
|
||||
} catch (_) {}
|
||||
}
|
||||
try {
|
||||
confirmations =
|
||||
appStore.wallet!.transactionHistory.transactions.values.first.confirmations +
|
||||
appStore.wallet!.transactionHistory.transactions.values.last.confirmations +
|
||||
1;
|
||||
} catch (_) {}
|
||||
return length * confirmations;
|
||||
}, _transactionDisposerCallback, delay: 300);
|
||||
|
||||
@@ -376,9 +371,6 @@ abstract class DashboardViewModelBase with Store {
|
||||
if ([
|
||||
WalletType.monero,
|
||||
WalletType.wownero,
|
||||
WalletType.decred,
|
||||
WalletType.zcash,
|
||||
WalletType.zano
|
||||
].contains(wallet.type)) {
|
||||
return true;
|
||||
}
|
||||
@@ -782,11 +774,7 @@ abstract class DashboardViewModelBase with Store {
|
||||
}
|
||||
|
||||
@computed
|
||||
bool get showZcashMissingFundsCard {
|
||||
if (wallet.type != WalletType.zcash) return false;
|
||||
if (!settingsStore.showZcashMissingFundsCard) return false;
|
||||
return zcash!.showMissingFundsCard(wallet);
|
||||
}
|
||||
bool get showZcashMissingFundsCard => false;
|
||||
|
||||
@computed
|
||||
bool get hasSilentPayments =>
|
||||
@@ -1064,11 +1052,6 @@ abstract class DashboardViewModelBase with Store {
|
||||
bitcoin!.setMwebEnabled(wallet, false);
|
||||
}
|
||||
|
||||
@action
|
||||
Future<void> rescanInternalChangeZcash() async {
|
||||
await zcash!.rescanInternalChange(wallet);
|
||||
}
|
||||
|
||||
@action
|
||||
void dismissZcash() {
|
||||
settingsStore.showZcashMissingFundsCard = false;
|
||||
@@ -1171,17 +1154,11 @@ abstract class DashboardViewModelBase with Store {
|
||||
case WalletType.base:
|
||||
case WalletType.arbitrum:
|
||||
case WalletType.bsc:
|
||||
case WalletType.solana:
|
||||
case WalletType.nano:
|
||||
case WalletType.banano:
|
||||
case WalletType.tron:
|
||||
case WalletType.wownero:
|
||||
case WalletType.decred:
|
||||
case WalletType.dogecoin:
|
||||
return true;
|
||||
case WalletType.zano:
|
||||
case WalletType.haven:
|
||||
case WalletType.zcash:
|
||||
case WalletType.none:
|
||||
return false;
|
||||
}
|
||||
@@ -1288,14 +1265,12 @@ abstract class DashboardViewModelBase with Store {
|
||||
return 0;
|
||||
}
|
||||
int confirmations = 1;
|
||||
if (![WalletType.solana, WalletType.tron].contains(wallet.type)) {
|
||||
try {
|
||||
confirmations =
|
||||
appStore.wallet!.transactionHistory.transactions.values.first.confirmations +
|
||||
appStore.wallet!.transactionHistory.transactions.values.last.confirmations +
|
||||
1;
|
||||
} catch (_) {}
|
||||
}
|
||||
try {
|
||||
confirmations =
|
||||
appStore.wallet!.transactionHistory.transactions.values.first.confirmations +
|
||||
appStore.wallet!.transactionHistory.transactions.values.last.confirmations +
|
||||
1;
|
||||
} catch (_) {}
|
||||
return length * confirmations;
|
||||
}, _transactionDisposerCallback, delay: 300);
|
||||
}
|
||||
@@ -1413,14 +1388,6 @@ abstract class DashboardViewModelBase with Store {
|
||||
@action
|
||||
void setSyncAll(bool value) => settingsStore.currentSyncAll = value;
|
||||
|
||||
Future<List<String>> checkForHavenWallets() async {
|
||||
final walletInfos = await WalletInfo.getAll();
|
||||
return walletInfos
|
||||
.where((element) => element.type == WalletType.haven)
|
||||
.map((e) => e.name)
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<List<String>> checkAffectedWallets() async {
|
||||
try {
|
||||
// await load file
|
||||
|
||||
@@ -6,13 +6,10 @@ import 'package:hash_wallet/entities/erc20_token_info_moralis.dart';
|
||||
import 'package:hash_wallet/entities/sort_balance_types.dart';
|
||||
import 'package:hash_wallet/evm/evm.dart';
|
||||
import 'package:hash_wallet/reactions/wallet_connect.dart';
|
||||
import 'package:hash_wallet/solana/solana.dart';
|
||||
import 'package:hash_wallet/store/settings_store.dart';
|
||||
import 'package:hash_wallet/tron/tron.dart';
|
||||
import 'package:hash_wallet/utils/token_utilities.dart';
|
||||
import 'package:cw_core/utils/proxy_wrapper.dart';
|
||||
import 'package:hash_wallet/view_model/dashboard/balance_view_model.dart';
|
||||
import 'package:hash_wallet/zano/zano.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/erc20_token.dart';
|
||||
import 'package:cw_core/utils/homoglyph_normalizer.dart';
|
||||
@@ -112,24 +109,6 @@ abstract class HomeSettingsViewModelBase with Store {
|
||||
await evm!.addErc20Token(_balanceViewModel.wallet, evmToken);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.solana) {
|
||||
final splToken = token.copyWith(enabled: true);
|
||||
await solana!.addSPLToken(
|
||||
_balanceViewModel.wallet,
|
||||
splToken,
|
||||
contractAddress,
|
||||
);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.tron) {
|
||||
final tronToken = token.copyWith(enabled: true);
|
||||
await tron!.addTronToken(_balanceViewModel.wallet, tronToken, contractAddress);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.zano) {
|
||||
await zano!.addZanoAssetById(_balanceViewModel.wallet, contractAddress);
|
||||
}
|
||||
|
||||
_updateTokensList();
|
||||
_updateFiatPrices(token);
|
||||
} catch (e) {
|
||||
@@ -145,18 +124,6 @@ abstract class HomeSettingsViewModelBase with Store {
|
||||
return evm!.isTokenAlreadyAdded(_balanceViewModel.wallet, contractAddress);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.solana) {
|
||||
return solana!.isTokenAlreadyAdded(_balanceViewModel.wallet, contractAddress);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.tron) {
|
||||
return tron!.isTokenAlreadyAdded(_balanceViewModel.wallet, contractAddress);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.zano) {
|
||||
return zano!.isTokenAlreadyAdded(_balanceViewModel.wallet, contractAddress);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -168,16 +135,6 @@ abstract class HomeSettingsViewModelBase with Store {
|
||||
await evm!.deleteErc20Token(_balanceViewModel.wallet, token as Erc20Token);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.solana) {
|
||||
await solana!.deleteSPLToken(_balanceViewModel.wallet, token);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.tron) {
|
||||
await tron!.deleteTronToken(_balanceViewModel.wallet, token);
|
||||
}
|
||||
if (_balanceViewModel.wallet.type == WalletType.zano) {
|
||||
await zano!.deleteZanoAsset(_balanceViewModel.wallet, token);
|
||||
}
|
||||
_updateTokensList();
|
||||
} finally {
|
||||
isDeletingToken = false;
|
||||
@@ -223,25 +180,15 @@ abstract class HomeSettingsViewModelBase with Store {
|
||||
case WalletType.bsc:
|
||||
defaultTokenAddresses = evm!.getDefaultTokenContractAddresses(_balanceViewModel.wallet);
|
||||
break;
|
||||
case WalletType.solana:
|
||||
defaultTokenAddresses = solana!.getDefaultTokenContractAddresses();
|
||||
break;
|
||||
case WalletType.tron:
|
||||
defaultTokenAddresses = tron!.getDefaultTokenContractAddresses();
|
||||
break;
|
||||
case WalletType.zano:
|
||||
case WalletType.banano:
|
||||
case WalletType.monero:
|
||||
case WalletType.none:
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.litecoin:
|
||||
case WalletType.haven:
|
||||
case WalletType.nano:
|
||||
case WalletType.wownero:
|
||||
case WalletType.bitcoinCash:
|
||||
case WalletType.decred:
|
||||
case WalletType.dogecoin:
|
||||
case WalletType.zcash:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -264,25 +211,15 @@ abstract class HomeSettingsViewModelBase with Store {
|
||||
case WalletType.bsc:
|
||||
defaultTokenSymbols = evm!.getDefaultTokenSymbols(_balanceViewModel.wallet);
|
||||
break;
|
||||
case WalletType.solana:
|
||||
defaultTokenSymbols = solana!.getDefaultTokenSymbols();
|
||||
break;
|
||||
case WalletType.tron:
|
||||
defaultTokenSymbols = tron!.getDefaultTokenSymbols();
|
||||
break;
|
||||
case WalletType.zano:
|
||||
case WalletType.banano:
|
||||
case WalletType.monero:
|
||||
case WalletType.none:
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.litecoin:
|
||||
case WalletType.haven:
|
||||
case WalletType.nano:
|
||||
case WalletType.wownero:
|
||||
case WalletType.bitcoinCash:
|
||||
case WalletType.decred:
|
||||
case WalletType.dogecoin:
|
||||
case WalletType.zcash:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -393,18 +330,6 @@ abstract class HomeSettingsViewModelBase with Store {
|
||||
return await evm!.getErc20Token(_balanceViewModel.wallet, contractAddress);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.solana) {
|
||||
return await solana!.getSPLToken(_balanceViewModel.wallet, contractAddress);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.tron) {
|
||||
return await tron!.getTronToken(_balanceViewModel.wallet, contractAddress);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.zano) {
|
||||
return await zano!.getZanoAsset(_balanceViewModel.wallet, contractAddress);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -429,20 +354,6 @@ abstract class HomeSettingsViewModelBase with Store {
|
||||
if (!value) evm!.removeTokenTransactionsInHistory(_balanceViewModel.wallet, token);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.solana) {
|
||||
final address = solana!.getTokenAddress(token);
|
||||
solana!.addSPLToken(_balanceViewModel.wallet, token, address);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.tron) {
|
||||
final address = tron!.getTokenAddress(token);
|
||||
tron!.addTronToken(_balanceViewModel.wallet, token, address);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.zano) {
|
||||
await zano!.changeZanoAssetAvailability(_balanceViewModel.wallet, token);
|
||||
}
|
||||
|
||||
_refreshTokensList();
|
||||
}
|
||||
|
||||
@@ -473,30 +384,6 @@ abstract class HomeSettingsViewModelBase with Store {
|
||||
.toList()
|
||||
..sort(_sortFunc));
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.solana) {
|
||||
tokens.addAll(solana!
|
||||
.getSPLTokenCurrencies(_balanceViewModel.wallet)
|
||||
.where((element) => _matchesSearchText(element))
|
||||
.toList()
|
||||
..sort(_sortFunc));
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.tron) {
|
||||
tokens.addAll(tron!
|
||||
.getTronTokenCurrencies(_balanceViewModel.wallet)
|
||||
.where((element) => _matchesSearchText(element))
|
||||
.toList()
|
||||
..sort(_sortFunc));
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.zano) {
|
||||
tokens.addAll(zano!
|
||||
.getZanoAssets(_balanceViewModel.wallet)
|
||||
.where((element) => _matchesSearchText(element))
|
||||
.toList()
|
||||
..sort(_sortFunc));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -564,23 +451,10 @@ abstract class HomeSettingsViewModelBase with Store {
|
||||
}
|
||||
|
||||
String? getTokenAddressBasedOnWallet(CryptoCurrency asset) {
|
||||
if (_balanceViewModel.wallet.type == WalletType.tron) {
|
||||
return tron!.getTokenAddress(asset);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.solana) {
|
||||
return solana!.getTokenAddress(asset);
|
||||
}
|
||||
|
||||
if (isEVMCompatibleChain(_balanceViewModel.wallet.type)) {
|
||||
return evm!.getTokenAddress(asset);
|
||||
}
|
||||
|
||||
if (_balanceViewModel.wallet.type == WalletType.zano) {
|
||||
return zano!.getZanoAssetAddress(asset);
|
||||
}
|
||||
|
||||
// We return null if it's neither Tron, EVM or Solana wallet (which is actually impossible because we only display home settings for either of these four wallets).
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,25 +65,17 @@ abstract class NFTViewModelBase with Store {
|
||||
// and used within the wallet
|
||||
// the [excludeSpam] field is a boolean that determines if spam nfts be excluded from the response.
|
||||
|
||||
Uri uri;
|
||||
if (wallet.type == WalletType.solana) {
|
||||
uri = Uri.https(
|
||||
'solana-gateway.moralis.io',
|
||||
'/account/$chainName/$walletAddress/nft',
|
||||
);
|
||||
} else {
|
||||
uri = Uri.https(
|
||||
'deep-index.moralis.io',
|
||||
'/api/v2.2/$walletAddress/nft',
|
||||
{
|
||||
"chain": chainName,
|
||||
"format": "decimal",
|
||||
"media_items": "false",
|
||||
"exclude_spam": "true",
|
||||
"normalizeMetadata": "true",
|
||||
},
|
||||
);
|
||||
}
|
||||
Uri uri = Uri.https(
|
||||
'deep-index.moralis.io',
|
||||
'/api/v2.2/$walletAddress/nft',
|
||||
{
|
||||
"chain": chainName,
|
||||
"format": "decimal",
|
||||
"media_items": "false",
|
||||
"exclude_spam": "true",
|
||||
"normalizeMetadata": "true",
|
||||
},
|
||||
);
|
||||
|
||||
try {
|
||||
if (isLoading) return;
|
||||
@@ -100,27 +92,11 @@ abstract class NFTViewModelBase with Store {
|
||||
|
||||
final decodedResponse = jsonDecode(response.body);
|
||||
|
||||
if (wallet.type == WalletType.solana) {
|
||||
final results = await Future.wait(
|
||||
(decodedResponse as List<dynamic>).map(
|
||||
(x) {
|
||||
final data = x as Map<String, dynamic>;
|
||||
final mint = data['mint'] as String? ?? '';
|
||||
return getSolanaNFTDetails(mint, chainName);
|
||||
},
|
||||
).toList(),
|
||||
);
|
||||
final result = WalletNFTsResponseModel.fromJson(decodedResponse as Map<String, dynamic>).result ?? [];
|
||||
|
||||
solanaNftAssetModels.clear();
|
||||
nftAssetByWalletModels.clear();
|
||||
|
||||
solanaNftAssetModels.addAll(results);
|
||||
} else {
|
||||
final result = WalletNFTsResponseModel.fromJson(decodedResponse as Map<String, dynamic>).result ?? [];
|
||||
|
||||
nftAssetByWalletModels.clear();
|
||||
|
||||
nftAssetByWalletModels.addAll(result);
|
||||
}
|
||||
nftAssetByWalletModels.addAll(result);
|
||||
} catch (e) {
|
||||
log(e.toString());
|
||||
bottomSheetService.queueBottomSheet(
|
||||
@@ -170,35 +146,29 @@ abstract class NFTViewModelBase with Store {
|
||||
try {
|
||||
isImportNFTLoading = true;
|
||||
|
||||
if (appStore.wallet!.type == WalletType.solana) {
|
||||
final result = await getSolanaNFTDetails(tokenAddress, chainName);
|
||||
final uri = Uri.https(
|
||||
'deep-index.moralis.io',
|
||||
'/api/v2.2/nft/$tokenAddress/$tokenId',
|
||||
{
|
||||
"chain": chainName,
|
||||
"format": "decimal",
|
||||
"media_items": "false",
|
||||
"normalizeMetadata": "true",
|
||||
},
|
||||
);
|
||||
final response = await ProxyWrapper().get(
|
||||
clearnetUri: uri,
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
"X-API-Key": secrets.moralisApiKey,
|
||||
},
|
||||
);
|
||||
|
||||
solanaNftAssetModels.add(result);
|
||||
} else {
|
||||
final uri = Uri.https(
|
||||
'deep-index.moralis.io',
|
||||
'/api/v2.2/nft/$tokenAddress/$tokenId',
|
||||
{
|
||||
"chain": chainName,
|
||||
"format": "decimal",
|
||||
"media_items": "false",
|
||||
"normalizeMetadata": "true",
|
||||
},
|
||||
);
|
||||
final response = await ProxyWrapper().get(
|
||||
clearnetUri: uri,
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
"X-API-Key": secrets.moralisApiKey,
|
||||
},
|
||||
);
|
||||
final decodedResponse = jsonDecode(response.body) as Map<String, dynamic>;
|
||||
|
||||
final decodedResponse = jsonDecode(response.body) as Map<String, dynamic>;
|
||||
final nftAsset = NFTAssetModel.fromJson(decodedResponse);
|
||||
|
||||
final nftAsset = NFTAssetModel.fromJson(decodedResponse);
|
||||
|
||||
nftAssetByWalletModels.add(nftAsset);
|
||||
}
|
||||
nftAssetByWalletModels.add(nftAsset);
|
||||
} catch (e) {
|
||||
bottomSheetService.queueBottomSheet(
|
||||
isModalDismissible: true,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:hash_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:hash_wallet/zcash/zcash.dart';
|
||||
import 'package:cw_core/receive_page_option.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
@@ -14,11 +13,7 @@ abstract class ReceiveOptionViewModelBase with Store {
|
||||
: selectedReceiveOption = initialPageOption ??
|
||||
([WalletType.bitcoin, WalletType.litecoin].contains(_wallet.type)
|
||||
? bitcoin!.getSelectedAddressType(_wallet)
|
||||
: (_wallet.type == WalletType.decred && _wallet.isTestnet)
|
||||
? ReceivePageOption.testnet
|
||||
: _wallet.type == WalletType.zcash
|
||||
? zcash!.getSelectedAddressType(_wallet)
|
||||
: ReceivePageOption.mainnet);
|
||||
: ReceivePageOption.mainnet);
|
||||
|
||||
final WalletBase _wallet;
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ abstract class SignViewModelBase with Store {
|
||||
WalletType.bitcoinCash,
|
||||
WalletType.litecoin,
|
||||
WalletType.dogecoin,
|
||||
WalletType.haven,
|
||||
].contains(wallet.type);
|
||||
|
||||
@action
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
import 'package:hash_wallet/decred/decred.dart';
|
||||
import 'package:hash_wallet/entities/balance_display_mode.dart';
|
||||
import 'package:hash_wallet/entities/fiat_currency.dart';
|
||||
import 'package:hash_wallet/evm/evm.dart';
|
||||
import 'package:hash_wallet/generated/i18n.dart';
|
||||
import 'package:hash_wallet/nano/nano.dart';
|
||||
import 'package:hash_wallet/reactions/wallet_connect.dart';
|
||||
import 'package:hash_wallet/solana/solana.dart';
|
||||
import 'package:hash_wallet/store/app_store.dart';
|
||||
import 'package:hash_wallet/tron/tron.dart';
|
||||
import 'package:hash_wallet/wownero/wownero.dart';
|
||||
import 'package:hash_wallet/zano/zano.dart';
|
||||
import 'package:hash_wallet/zcash/zcash.dart';
|
||||
import 'package:cw_core/crypto_amount_format.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/transaction_direction.dart';
|
||||
@@ -44,10 +39,7 @@ class TransactionListItem extends ActionListItem with Keyable {
|
||||
@override
|
||||
dynamic get keyIndex => transaction.id;
|
||||
|
||||
bool get hasTokens =>
|
||||
isEVMCompatibleChain(balanceViewModel.wallet.type) ||
|
||||
balanceViewModel.wallet.type == WalletType.solana ||
|
||||
balanceViewModel.wallet.type == WalletType.tron;
|
||||
bool get hasTokens => isEVMCompatibleChain(balanceViewModel.wallet.type);
|
||||
|
||||
String get formattedCryptoAmount {
|
||||
if (displayMode == BalanceDisplayMode.hiddenBalance) return '---';
|
||||
@@ -87,8 +79,6 @@ class TransactionListItem extends ActionListItem with Keyable {
|
||||
int get neededConfirmations {
|
||||
switch (balanceViewModel.wallet.type) {
|
||||
case WalletType.monero:
|
||||
case WalletType.haven:
|
||||
case WalletType.zano:
|
||||
return 10;
|
||||
case WalletType.wownero:
|
||||
return 3;
|
||||
@@ -106,8 +96,6 @@ class TransactionListItem extends ActionListItem with Keyable {
|
||||
String get formattedPendingStatus {
|
||||
switch (balanceViewModel.wallet.type) {
|
||||
case WalletType.monero:
|
||||
case WalletType.haven:
|
||||
case WalletType.zano:
|
||||
if (transaction.confirmations >= 0 && transaction.confirmations < 10) {
|
||||
return ' (${transaction.confirmations}/10)';
|
||||
}
|
||||
@@ -147,10 +135,8 @@ class TransactionListItem extends ActionListItem with Keyable {
|
||||
String get formattedStatus {
|
||||
if ([
|
||||
WalletType.monero,
|
||||
WalletType.haven,
|
||||
WalletType.wownero,
|
||||
WalletType.litecoin,
|
||||
WalletType.zano,
|
||||
].contains(balanceViewModel.wallet.type)) {
|
||||
return formattedPendingStatus;
|
||||
}
|
||||
@@ -171,16 +157,6 @@ class TransactionListItem extends ActionListItem with Keyable {
|
||||
final asset = evm!.assetOfTransaction(balanceViewModel.wallet, transaction);
|
||||
return asset;
|
||||
}
|
||||
|
||||
if (balanceViewModel.wallet.type == WalletType.solana) {
|
||||
final asset = solana!.assetOfTransaction(balanceViewModel.wallet, transaction);
|
||||
return asset;
|
||||
}
|
||||
|
||||
if (balanceViewModel.wallet.type == WalletType.tron) {
|
||||
final asset = tron!.assetOfTransaction(balanceViewModel.wallet, transaction);
|
||||
return asset;
|
||||
}
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
@@ -232,52 +208,8 @@ class TransactionListItem extends ActionListItem with Keyable {
|
||||
price: price,
|
||||
).withLocalSeperator(_appStore.settingsStore.languageCode);
|
||||
break;
|
||||
case WalletType.solana:
|
||||
final asset = solana!.assetOfTransaction(balanceViewModel.wallet, transaction);
|
||||
final price = balanceViewModel.fiatConversionStore.prices[asset];
|
||||
amount = calculateFiatAmountRaw(
|
||||
cryptoAmount: solana!.getTransactionAmountRaw(transaction),
|
||||
price: price,
|
||||
).withLocalSeperator(_appStore.settingsStore.languageCode);
|
||||
break;
|
||||
case WalletType.tron:
|
||||
final asset = tron!.assetOfTransaction(balanceViewModel.wallet, transaction);
|
||||
final price = balanceViewModel.fiatConversionStore.prices[asset];
|
||||
final cryptoAmount = tron!.getTransactionAmountRaw(transaction);
|
||||
amount = calculateFiatAmountRaw(
|
||||
cryptoAmount: cryptoAmount,
|
||||
price: price,
|
||||
).withLocalSeperator(_appStore.settingsStore.languageCode);
|
||||
break;
|
||||
case WalletType.zano:
|
||||
final asset = zano!.assetOfTransaction(balanceViewModel.wallet, transaction);
|
||||
if (asset == null) {
|
||||
amount = "0.00";
|
||||
break;
|
||||
}
|
||||
final price = balanceViewModel.fiatConversionStore.prices[asset];
|
||||
amount = calculateFiatAmountRaw(
|
||||
cryptoAmount: zano!.formatterIntAmountToDouble(
|
||||
amount: transaction.amount, currency: asset, forFee: false),
|
||||
price: price,
|
||||
).withLocalSeperator(_appStore.settingsStore.languageCode);
|
||||
break;
|
||||
case WalletType.decred:
|
||||
amount = calculateFiatAmountRaw(
|
||||
cryptoAmount: decred!.formatterDecredAmountToDouble(amount: transaction.amount),
|
||||
price: price,
|
||||
).withLocalSeperator(_appStore.settingsStore.languageCode);
|
||||
break;
|
||||
case WalletType.zcash:
|
||||
amount = calculateFiatAmountRaw(
|
||||
cryptoAmount:
|
||||
zcash!.formatterZcashAmountToDouble(amount: BigInt.from(transaction.amount)),
|
||||
price: price,
|
||||
).withLocalSeperator(_appStore.settingsStore.languageCode);
|
||||
|
||||
case WalletType.none:
|
||||
case WalletType.banano:
|
||||
case WalletType.haven:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:hash_wallet/exchange/provider/chainflip_exchange_provider.dart';
|
||||
import 'package:hash_wallet/exchange/provider/changenow_exchange_provider.dart';
|
||||
import 'package:hash_wallet/exchange/provider/exchange_provider.dart';
|
||||
import 'package:hash_wallet/exchange/provider/exolix_exchange_provider.dart';
|
||||
import 'package:hash_wallet/exchange/provider/jupiter_exchange_provider.dart';
|
||||
import 'package:hash_wallet/exchange/provider/near_Intents_exchange_provider.dart';
|
||||
import 'package:hash_wallet/exchange/provider/swapsxyz_exchange_provider.dart';
|
||||
import 'package:hash_wallet/exchange/provider/swaptrade_exchange_provider.dart';
|
||||
@@ -87,9 +86,6 @@ abstract class ExchangeTradeViewModelBase with Store {
|
||||
case ExchangeProviderDescription.swapsXyz:
|
||||
_provider = SwapsXyzExchangeProvider();
|
||||
break;
|
||||
case ExchangeProviderDescription.jupiter:
|
||||
_provider = JupiterExchangeProvider();
|
||||
break;
|
||||
case ExchangeProviderDescription.nearIntents:
|
||||
_provider = NearIntentsExchangeProvider();
|
||||
break;
|
||||
@@ -121,20 +117,13 @@ abstract class ExchangeTradeViewModelBase with Store {
|
||||
|
||||
bool isSwapsXYZCanSendFromExternal;
|
||||
|
||||
/// Providers that should hide the "send from external" button
|
||||
static const List<Type> _providersThatHideExternalSend = [
|
||||
JupiterExchangeProvider,
|
||||
];
|
||||
|
||||
/// Returns true if the current provider should hide the external send button
|
||||
bool get shouldHideExternalSendButton {
|
||||
if (_provider == null) return false;
|
||||
|
||||
if (!isSwapsXYZCanSendFromExternal) return true;
|
||||
|
||||
return _providersThatHideExternalSend.any(
|
||||
(providerType) => _provider.runtimeType == providerType,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
String get extraInfo => trade.extraId != null && trade.extraId!.isNotEmpty
|
||||
@@ -439,10 +428,6 @@ abstract class ExchangeTradeViewModelBase with Store {
|
||||
return ArbitrumURI(amount: amount, address: inputAddress);
|
||||
case WalletType.bsc:
|
||||
return BSCURI(amount: amount, address: inputAddress);
|
||||
case WalletType.solana:
|
||||
return SolanaURI(amount: amount, address: inputAddress);
|
||||
case WalletType.tron:
|
||||
return TronURI(amount: amount, address: inputAddress);
|
||||
case WalletType.monero:
|
||||
return MoneroURI(address: inputAddress, amount: amount);
|
||||
case WalletType.wownero:
|
||||
@@ -453,15 +438,8 @@ abstract class ExchangeTradeViewModelBase with Store {
|
||||
return LitecoinURI(amount: amount, address: inputAddress);
|
||||
case WalletType.nano:
|
||||
return NanoURI(amount: amount, address: inputAddress);
|
||||
case WalletType.zano:
|
||||
return ZanoURI(amount: amount, address: inputAddress);
|
||||
case WalletType.decred:
|
||||
return DecredURI(amount: amount, address: inputAddress);
|
||||
case WalletType.zcash:
|
||||
return ZcashURI(amount: amount, address: inputAddress);
|
||||
case WalletType.banano:
|
||||
case WalletType.none:
|
||||
case WalletType.haven:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import 'package:hash_wallet/exchange/exchange_trade_state.dart';
|
||||
import 'package:hash_wallet/exchange/limits.dart';
|
||||
import 'package:hash_wallet/exchange/limits_state.dart';
|
||||
import 'package:hash_wallet/exchange/provider/chainflip_exchange_provider.dart';
|
||||
import 'package:hash_wallet/exchange/provider/jupiter_exchange_provider.dart';
|
||||
import 'package:hash_wallet/exchange/provider/letsexchange_exchange_provider.dart';
|
||||
import 'package:hash_wallet/exchange/provider/changenow_exchange_provider.dart';
|
||||
import 'package:hash_wallet/exchange/provider/exchange_provider.dart';
|
||||
@@ -302,7 +301,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
||||
].contains(wallet.type);
|
||||
|
||||
bool get hideAddressAfterExchange =>
|
||||
[WalletType.monero, WalletType.wownero, WalletType.zcash].contains(wallet.type);
|
||||
[WalletType.monero, WalletType.wownero].contains(wallet.type);
|
||||
|
||||
bool _useTorOnly;
|
||||
final ExchangeTemplateStore _exchangeTemplateStore;
|
||||
@@ -1451,10 +1450,6 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
||||
depositCurrency = CryptoCurrency.doge;
|
||||
receiveCurrency = CryptoCurrency.xmr;
|
||||
break;
|
||||
case WalletType.haven:
|
||||
depositCurrency = CryptoCurrency.xhv;
|
||||
receiveCurrency = CryptoCurrency.btc;
|
||||
break;
|
||||
case WalletType.ethereum:
|
||||
depositCurrency = CryptoCurrency.eth;
|
||||
receiveCurrency = CryptoCurrency.xmr;
|
||||
@@ -1483,30 +1478,10 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
||||
depositCurrency = CryptoCurrency.bnb;
|
||||
receiveCurrency = CryptoCurrency.xmr;
|
||||
break;
|
||||
case WalletType.solana:
|
||||
depositCurrency = CryptoCurrency.sol;
|
||||
receiveCurrency = CryptoCurrency.xmr;
|
||||
break;
|
||||
case WalletType.tron:
|
||||
depositCurrency = CryptoCurrency.trx;
|
||||
receiveCurrency = CryptoCurrency.xmr;
|
||||
break;
|
||||
case WalletType.wownero:
|
||||
depositCurrency = CryptoCurrency.wow;
|
||||
receiveCurrency = CryptoCurrency.xmr;
|
||||
break;
|
||||
case WalletType.zano:
|
||||
depositCurrency = CryptoCurrency.zano;
|
||||
receiveCurrency = CryptoCurrency.xmr;
|
||||
break;
|
||||
case WalletType.decred:
|
||||
depositCurrency = CryptoCurrency.dcr;
|
||||
receiveCurrency = CryptoCurrency.xmr;
|
||||
break;
|
||||
case WalletType.zcash:
|
||||
depositCurrency = CryptoCurrency.zec;
|
||||
receiveCurrency = CryptoCurrency.xmr;
|
||||
break;
|
||||
case WalletType.none:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -111,14 +111,11 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
||||
String socksProxyAddress;
|
||||
|
||||
@computed
|
||||
bool get isReady =>
|
||||
(address.isNotEmpty) ||
|
||||
walletType == WalletType.decred; // Allow an empty address.
|
||||
bool get isReady => address.isNotEmpty;
|
||||
|
||||
bool get hasAuthCredentials =>
|
||||
walletType == WalletType.monero ||
|
||||
walletType == WalletType.wownero ||
|
||||
walletType == WalletType.haven;
|
||||
walletType == WalletType.wownero;
|
||||
|
||||
bool get hasPathSupport {
|
||||
switch (walletType) {
|
||||
@@ -127,22 +124,16 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
||||
case WalletType.base:
|
||||
case WalletType.arbitrum:
|
||||
case WalletType.bsc:
|
||||
case WalletType.solana:
|
||||
case WalletType.banano:
|
||||
case WalletType.nano:
|
||||
case WalletType.tron:
|
||||
return true;
|
||||
case WalletType.none:
|
||||
case WalletType.monero:
|
||||
case WalletType.wownero:
|
||||
case WalletType.haven:
|
||||
case WalletType.litecoin:
|
||||
case WalletType.bitcoinCash:
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.dogecoin:
|
||||
case WalletType.zano:
|
||||
case WalletType.decred:
|
||||
case WalletType.zcash:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,24 +82,6 @@ abstract class PaymentViewModelBase with Store {
|
||||
return PaymentFlowResult.currentWalletCompatible();
|
||||
}
|
||||
|
||||
if (detectedWalletType == WalletType.solana) {
|
||||
final compatibleWallets = await getWalletsByType(WalletType.solana);
|
||||
return PaymentFlowResult.solanaTokenSelection(
|
||||
detectionResult,
|
||||
compatibleWallets: compatibleWallets,
|
||||
wallet: compatibleWallets.isNotEmpty ? compatibleWallets.first : null,
|
||||
);
|
||||
}
|
||||
|
||||
if (detectedWalletType == WalletType.tron) {
|
||||
final compatibleWallets = await getWalletsByType(WalletType.tron);
|
||||
return PaymentFlowResult.tronTokenSelection(
|
||||
detectionResult,
|
||||
compatibleWallets: compatibleWallets,
|
||||
wallet: compatibleWallets.isNotEmpty ? compatibleWallets.first : null,
|
||||
);
|
||||
}
|
||||
|
||||
if (isEVMCompatibleChain(detectedWalletType!)) {
|
||||
return PaymentFlowResult.evmNetworkSelection(detectionResult);
|
||||
}
|
||||
@@ -186,34 +168,6 @@ class PaymentFlowResult {
|
||||
);
|
||||
}
|
||||
|
||||
/// Solana address detected - needs token selection
|
||||
factory PaymentFlowResult.solanaTokenSelection(
|
||||
AddressDetectionResult addressDetectionResult, {
|
||||
List<WalletInfo>? compatibleWallets,
|
||||
WalletInfo? wallet,
|
||||
}) =>
|
||||
PaymentFlowResult._(
|
||||
type: PaymentFlowType.solanaTokenSelection,
|
||||
addressDetectionResult: addressDetectionResult,
|
||||
walletType: WalletType.solana,
|
||||
wallets: compatibleWallets ?? [],
|
||||
wallet: wallet,
|
||||
);
|
||||
|
||||
/// Tron address detected - needs token selection
|
||||
factory PaymentFlowResult.tronTokenSelection(
|
||||
AddressDetectionResult addressDetectionResult, {
|
||||
List<WalletInfo>? compatibleWallets,
|
||||
WalletInfo? wallet,
|
||||
}) =>
|
||||
PaymentFlowResult._(
|
||||
type: PaymentFlowType.tronTokenSelection,
|
||||
addressDetectionResult: addressDetectionResult,
|
||||
walletType: WalletType.tron,
|
||||
wallets: compatibleWallets ?? [],
|
||||
wallet: wallet,
|
||||
);
|
||||
|
||||
/// Current wallet is compatible
|
||||
factory PaymentFlowResult.currentWalletCompatible() =>
|
||||
PaymentFlowResult._(type: PaymentFlowType.currentWalletCompatible);
|
||||
@@ -292,9 +246,7 @@ class PaymentFlowResult {
|
||||
PaymentFlowResult._(type: PaymentFlowType.incompatible, message: message);
|
||||
|
||||
CryptoCurrency? get detectedCurrency {
|
||||
if (type == PaymentFlowType.evmNetworkSelection ||
|
||||
type == PaymentFlowType.solanaTokenSelection ||
|
||||
type == PaymentFlowType.tronTokenSelection) {
|
||||
if (type == PaymentFlowType.evmNetworkSelection) {
|
||||
return addressDetectionResult?.detectedCurrency;
|
||||
}
|
||||
if (walletType != null) {
|
||||
@@ -314,8 +266,6 @@ enum PaymentFlowType {
|
||||
multipleWallets,
|
||||
noWallets,
|
||||
evmNetworkSelection,
|
||||
solanaTokenSelection,
|
||||
tronTokenSelection,
|
||||
error,
|
||||
incompatible,
|
||||
}
|
||||
|
||||
@@ -39,25 +39,12 @@ class WalletRestoreFromQRCode {
|
||||
'bitcoincash': WalletType.bitcoinCash,
|
||||
'bitcoincash-wallet': WalletType.bitcoinCash,
|
||||
'bitcoincash_wallet': WalletType.bitcoinCash,
|
||||
'solana-wallet': WalletType.solana,
|
||||
'tron': WalletType.tron,
|
||||
'tron-wallet': WalletType.tron,
|
||||
'tron_wallet': WalletType.tron,
|
||||
'wownero': WalletType.wownero,
|
||||
'wownero-wallet': WalletType.wownero,
|
||||
'wownero_wallet': WalletType.wownero,
|
||||
'zano': WalletType.zano,
|
||||
'zano-wallet': WalletType.zano,
|
||||
'zano_wallet': WalletType.zano,
|
||||
'decred': WalletType.decred,
|
||||
'decred-wallet': WalletType.decred,
|
||||
'decred_wallet': WalletType.decred,
|
||||
'dogecoin': WalletType.dogecoin,
|
||||
'dogecoin-wallet': WalletType.dogecoin,
|
||||
'dogecoin_wallet': WalletType.dogecoin,
|
||||
'zcash': WalletType.zcash,
|
||||
'zcash-wallet': WalletType.zcash,
|
||||
'zcash_wallet': WalletType.zcash,
|
||||
};
|
||||
|
||||
static WalletType? _extractWalletType(String code) {
|
||||
@@ -234,22 +221,6 @@ class WalletRestoreFromQRCode {
|
||||
return WalletRestoreMode.seed;
|
||||
}
|
||||
|
||||
if (type == WalletType.solana && credentials.containsKey('private_key')) {
|
||||
final privateKey = credentials['private_key'] as String;
|
||||
if (privateKey.isEmpty) {
|
||||
throw Exception('Unexpected restore mode: private_key');
|
||||
}
|
||||
return WalletRestoreMode.keys;
|
||||
}
|
||||
|
||||
if (type == WalletType.tron && credentials.containsKey('private_key')) {
|
||||
final privateKey = credentials['private_key'] as String;
|
||||
if (privateKey.isEmpty) {
|
||||
throw Exception('Unexpected restore mode: private_key');
|
||||
}
|
||||
return WalletRestoreMode.keys;
|
||||
}
|
||||
|
||||
if (type == WalletType.monero) {
|
||||
final codeParsed = json.decode(credentials['raw_qr'].toString());
|
||||
if (codeParsed["version"] != 0)
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import 'package:hash_wallet/bitcoin_cash/bitcoin_cash.dart';
|
||||
import 'package:hash_wallet/core/amount_parsing_proxy.dart';
|
||||
import 'package:hash_wallet/decred/decred.dart';
|
||||
import 'package:hash_wallet/dogecoin/dogecoin.dart';
|
||||
import 'package:hash_wallet/entities/priority_for_wallet_type.dart';
|
||||
import 'package:hash_wallet/core/wallet_change_listener_view_model.dart';
|
||||
import 'package:hash_wallet/evm/evm.dart';
|
||||
import 'package:hash_wallet/monero/monero.dart';
|
||||
import 'package:hash_wallet/zcash/zcash.dart';
|
||||
import 'package:hash_wallet/store/app_store.dart';
|
||||
import 'package:hash_wallet/view_model/dashboard/balance_view_model.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
@@ -85,8 +83,6 @@ abstract class FeesViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
switch (wallet.type) {
|
||||
case WalletType.monero:
|
||||
case WalletType.wownero:
|
||||
case WalletType.haven:
|
||||
case WalletType.zano:
|
||||
return transactionPriority == monero!.getMoneroTransactionPrioritySlow();
|
||||
case WalletType.bitcoin:
|
||||
return transactionPriority == bitcoin!.getBitcoinTransactionPrioritySlow();
|
||||
@@ -99,17 +95,12 @@ abstract class FeesViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
return transactionPriority == evm!.getEVMTransactionPrioritySlow();
|
||||
case WalletType.bitcoinCash:
|
||||
return transactionPriority == bitcoinCash!.getBitcoinCashTransactionPrioritySlow();
|
||||
case WalletType.decred:
|
||||
return transactionPriority == decred!.getDecredTransactionPrioritySlow();
|
||||
case WalletType.dogecoin:
|
||||
return transactionPriority == dogecoin!.getDogeCoinTransactionPrioritySlow();
|
||||
case WalletType.none:
|
||||
case WalletType.nano:
|
||||
case WalletType.banano:
|
||||
case WalletType.solana:
|
||||
case WalletType.tron:
|
||||
case WalletType.arbitrum:
|
||||
case WalletType.zcash:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -126,8 +117,6 @@ abstract class FeesViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
bool get hasFeesPriority =>
|
||||
wallet.type != WalletType.nano &&
|
||||
wallet.type != WalletType.banano &&
|
||||
wallet.type != WalletType.solana &&
|
||||
wallet.type != WalletType.tron &&
|
||||
wallet.chainId !=
|
||||
42161; // Wallet type is generic for all EVM chains, so we need to check the chainId
|
||||
|
||||
@@ -186,14 +175,9 @@ abstract class FeesViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
void setDefaultTransactionPriority() {
|
||||
switch (wallet.type) {
|
||||
case WalletType.monero:
|
||||
case WalletType.haven:
|
||||
case WalletType.wownero:
|
||||
case WalletType.zano:
|
||||
_settingsStore.setPriority(wallet.type, monero!.getMoneroTransactionPriorityAutomatic());
|
||||
break;
|
||||
case WalletType.zcash:
|
||||
_settingsStore.setPriority(wallet.type, zcash!.getZcashTransactionPriorityAutomatic());
|
||||
break;
|
||||
case WalletType.bitcoin:
|
||||
_settingsStore.setPriority(wallet.type, bitcoin!.getBitcoinTransactionPriorityMedium());
|
||||
break;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:math' show min;
|
||||
import 'package:hash_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:hash_wallet/decred/decred.dart';
|
||||
import 'package:hash_wallet/di.dart';
|
||||
import 'package:hash_wallet/entities/calculate_fiat_amount.dart';
|
||||
import 'package:hash_wallet/entities/calculate_fiat_amount_raw.dart';
|
||||
@@ -11,15 +10,11 @@ import 'package:hash_wallet/evm/evm.dart';
|
||||
import 'package:hash_wallet/generated/i18n.dart';
|
||||
import 'package:hash_wallet/monero/monero.dart';
|
||||
import 'package:hash_wallet/reactions/wallet_connect.dart';
|
||||
import 'package:hash_wallet/solana/solana.dart';
|
||||
import 'package:hash_wallet/src/screens/send/widgets/extract_address_from_parsed.dart';
|
||||
import 'package:hash_wallet/store/app_store.dart';
|
||||
import 'package:hash_wallet/store/dashboard/fiat_conversion_store.dart';
|
||||
import 'package:hash_wallet/store/settings_store.dart';
|
||||
import 'package:hash_wallet/tron/tron.dart';
|
||||
import 'package:hash_wallet/wownero/wownero.dart';
|
||||
import 'package:hash_wallet/zano/zano.dart';
|
||||
import 'package:hash_wallet/zcash/zcash.dart';
|
||||
import 'package:cw_core/balance.dart';
|
||||
import 'package:cw_core/crypto_amount_format.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
@@ -133,9 +128,6 @@ abstract class OutputBase with Store {
|
||||
case WalletType.dogecoin:
|
||||
_amount = cryptoCurrencyHandler().parseAmount(_cryptoAmount).toInt();
|
||||
break;
|
||||
case WalletType.decred:
|
||||
_amount = decred!.formatterStringDoubleToDecredAmount(_cryptoAmount);
|
||||
break;
|
||||
case WalletType.ethereum:
|
||||
case WalletType.polygon:
|
||||
case WalletType.base:
|
||||
@@ -146,19 +138,9 @@ abstract class OutputBase with Store {
|
||||
case WalletType.wownero:
|
||||
_amount = wownero!.formatterWowneroParseAmount(amount: _cryptoAmount);
|
||||
break;
|
||||
case WalletType.zano:
|
||||
_amount = zano!
|
||||
.formatterParseAmount(amount: _cryptoAmount, currency: cryptoCurrencyHandler());
|
||||
break;
|
||||
case WalletType.zcash:
|
||||
_amount = zcash!.formatterZcashParseAmount(_cryptoAmount);
|
||||
break;
|
||||
case WalletType.none:
|
||||
case WalletType.haven:
|
||||
case WalletType.nano:
|
||||
case WalletType.banano:
|
||||
case WalletType.solana:
|
||||
case WalletType.tron:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -198,7 +180,6 @@ abstract class OutputBase with Store {
|
||||
case WalletType.litecoin:
|
||||
case WalletType.bitcoinCash:
|
||||
case WalletType.dogecoin:
|
||||
case WalletType.decred:
|
||||
estimatedFee = walletTypeToCryptoCurrency(_wallet.type).formatAmount(BigInt.from(fee));
|
||||
break;
|
||||
case WalletType.bitcoin:
|
||||
@@ -215,26 +196,6 @@ abstract class OutputBase with Store {
|
||||
|
||||
estimatedFee = _appStore.amountParsingProxy.getDisplayCryptoString(fee, cryptoCurrencyHandler());
|
||||
break;
|
||||
case WalletType.solana:
|
||||
estimatedFee = solana!.getEstimateFees(_wallet).toString();
|
||||
break;
|
||||
case WalletType.zano:
|
||||
estimatedFee = zano!
|
||||
.formatterIntAmountToDouble(
|
||||
amount: fee, currency: cryptoCurrencyHandler(), forFee: true)
|
||||
.toString();
|
||||
break;
|
||||
case WalletType.tron:
|
||||
if (cryptoCurrencyHandler() == CryptoCurrency.trx) {
|
||||
estimatedFee = tron!.getTronNativeEstimatedFee(_wallet).toString();
|
||||
} else {
|
||||
estimatedFee = tron!.getTronTRC20EstimatedFee(_wallet).toString();
|
||||
}
|
||||
break;
|
||||
|
||||
case WalletType.zcash:
|
||||
estimatedFee = zcash!.formatterZcashAmountToDouble(amount: BigInt.from(fee)).toString();
|
||||
break;
|
||||
|
||||
/// EVMs
|
||||
case WalletType.ethereum:
|
||||
@@ -256,7 +217,6 @@ abstract class OutputBase with Store {
|
||||
|
||||
/// end EVMs
|
||||
|
||||
case WalletType.haven:
|
||||
case WalletType.nano:
|
||||
case WalletType.banano:
|
||||
case WalletType.none:
|
||||
@@ -274,8 +234,7 @@ abstract class OutputBase with Store {
|
||||
final _ = _wallet.syncStatus;
|
||||
|
||||
try {
|
||||
final currency = (isEVMCompatibleChain(_wallet.type) ||
|
||||
[WalletType.solana, WalletType.tron].contains(_wallet.type))
|
||||
final currency = isEVMCompatibleChain(_wallet.type)
|
||||
? _wallet.currency
|
||||
: cryptoCurrencyHandler();
|
||||
|
||||
|
||||
@@ -55,11 +55,7 @@ abstract class SendTemplateViewModelBase with Store {
|
||||
|
||||
TemplateValidator get templateValidator => TemplateValidator();
|
||||
|
||||
bool get hasMultiRecipient =>
|
||||
_wallet.type != WalletType.haven &&
|
||||
_wallet.type != WalletType.solana &&
|
||||
_wallet.type != WalletType.tron &&
|
||||
!isEVMCompatibleChain(_wallet.type);
|
||||
bool get hasMultiRecipient => !isEVMCompatibleChain(_wallet.type);
|
||||
|
||||
@computed
|
||||
CryptoCurrency get cryptoCurrency => _wallet.currency;
|
||||
@@ -106,8 +102,5 @@ abstract class SendTemplateViewModelBase with Store {
|
||||
@computed
|
||||
List<CryptoCurrency> get walletCurrencies => _wallet.balance.keys.toList();
|
||||
|
||||
bool get hasMultipleTokens =>
|
||||
isEVMCompatibleChain(_wallet.type) ||
|
||||
_wallet.type == WalletType.solana ||
|
||||
_wallet.type == WalletType.tron;
|
||||
bool get hasMultipleTokens => isEVMCompatibleChain(_wallet.type);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import 'package:hash_wallet/core/open_crypto_pay/models.dart';
|
||||
import 'package:hash_wallet/core/open_crypto_pay/open_cryptopay_service.dart';
|
||||
import 'package:hash_wallet/core/validator.dart';
|
||||
import 'package:hash_wallet/core/wallet_change_listener_view_model.dart';
|
||||
import 'package:hash_wallet/decred/decred.dart';
|
||||
import 'package:hash_wallet/entities/calculate_fiat_amount.dart';
|
||||
import 'package:hash_wallet/entities/contact.dart';
|
||||
import 'package:hash_wallet/entities/contact_record.dart';
|
||||
@@ -24,13 +23,10 @@ import 'package:hash_wallet/entities/wallet_contact.dart';
|
||||
import 'package:hash_wallet/evm/evm.dart';
|
||||
import 'package:hash_wallet/exchange/exchange_provider_description.dart';
|
||||
import 'package:hash_wallet/exchange/provider/exchange_provider.dart';
|
||||
import 'package:hash_wallet/exchange/provider/jupiter_exchange_provider.dart';
|
||||
import 'package:hash_wallet/exchange/provider/near_Intents_exchange_provider.dart';
|
||||
import 'package:hash_wallet/solana/solana.dart';
|
||||
import 'package:hash_wallet/exchange/provider/swapsxyz_exchange_provider.dart';
|
||||
import 'package:hash_wallet/exchange/provider/thorchain_exchange.provider.dart';
|
||||
import 'package:hash_wallet/exchange/trade.dart';
|
||||
import 'package:hash_wallet/exchange/trade_state.dart';
|
||||
import 'package:hash_wallet/generated/i18n.dart';
|
||||
import 'package:hash_wallet/monero/monero.dart';
|
||||
import 'package:hash_wallet/nano/nano.dart';
|
||||
@@ -39,7 +35,6 @@ import 'package:hash_wallet/routes.dart';
|
||||
import 'package:hash_wallet/store/app_store.dart';
|
||||
import 'package:hash_wallet/store/dashboard/fiat_conversion_store.dart';
|
||||
import 'package:hash_wallet/store/settings_store.dart';
|
||||
import 'package:hash_wallet/tron/tron.dart';
|
||||
import 'package:hash_wallet/utils/payment_request.dart';
|
||||
import 'package:hash_wallet/view_model/contact_list/contact_list_view_model.dart';
|
||||
import 'package:hash_wallet/view_model/dashboard/balance_view_model.dart';
|
||||
@@ -50,8 +45,6 @@ import 'package:hash_wallet/view_model/send/send_template_view_model.dart';
|
||||
import 'package:hash_wallet/view_model/send/send_view_model_state.dart';
|
||||
import 'package:hash_wallet/view_model/unspent_coins/unspent_coins_list_view_model.dart';
|
||||
import 'package:hash_wallet/wownero/wownero.dart';
|
||||
import 'package:hash_wallet/zano/zano.dart';
|
||||
import 'package:hash_wallet/zcash/zcash.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
import 'package:cw_core/erc20_token.dart';
|
||||
@@ -80,8 +73,7 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
currencies = wallet.balance.keys.toList();
|
||||
selectedCryptoCurrency =
|
||||
coinTypeToSpendFrom == UnspentCoinType.lightning ? CryptoCurrency.btcln : wallet.currency;
|
||||
hasMultipleTokens = isEVMWallet ||
|
||||
[WalletType.solana, WalletType.tron, WalletType.zano].contains(wallet.type);
|
||||
hasMultipleTokens = isEVMWallet;
|
||||
|
||||
for (final output in outputs) {
|
||||
output.updateWallet(wallet);
|
||||
@@ -112,8 +104,7 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
selectedCryptoCurrency = coinTypeToSpendFrom == UnspentCoinType.lightning
|
||||
? CryptoCurrency.btcln
|
||||
: _appStore.wallet!.currency,
|
||||
hasMultipleTokens = isEVMCompatibleChain(_appStore.wallet!.type) ||
|
||||
[WalletType.solana, WalletType.tron, WalletType.zano].contains(_appStore.wallet!.type),
|
||||
hasMultipleTokens = isEVMCompatibleChain(_appStore.wallet!.type),
|
||||
selectedChainId = _appStore.wallet!.chainId,
|
||||
outputs = ObservableList<Output>(),
|
||||
fiatFromSettings = _appStore.settingsStore.fiatCurrency,
|
||||
@@ -189,8 +180,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
bool get isBatchSending => outputs.length > 1;
|
||||
|
||||
bool get shouldDisplaySendALL {
|
||||
if (walletType == WalletType.solana) return false;
|
||||
|
||||
// if (walletType == WalletType.ethereum && selectedCryptoCurrency == CryptoCurrency.eth)
|
||||
// return false;
|
||||
|
||||
@@ -257,8 +246,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
case WalletType.base:
|
||||
case WalletType.arbitrum:
|
||||
case WalletType.bsc:
|
||||
case WalletType.tron:
|
||||
case WalletType.solana:
|
||||
case WalletType.bitcoin:
|
||||
return wallet.currency;
|
||||
default:
|
||||
@@ -335,7 +322,7 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
|
||||
@computed
|
||||
Future<String> get sendingBalance async {
|
||||
// only for electrum, monero, wownero, decred wallets atm:
|
||||
// only for electrum, monero, wownero wallets atm:
|
||||
switch (wallet.type) {
|
||||
case WalletType.bitcoin:
|
||||
if (coinTypeToSpendFrom == UnspentCoinType.lightning) return balance;
|
||||
@@ -347,7 +334,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
case WalletType.dogecoin:
|
||||
case WalletType.monero:
|
||||
case WalletType.wownero:
|
||||
case WalletType.decred:
|
||||
final sendingBalance =
|
||||
await unspentCoinsListViewModel.getSendingBalance(coinTypeToSpendFrom);
|
||||
return walletTypeToCryptoCurrency(walletType).formatAmount(BigInt.from(sendingBalance));
|
||||
@@ -394,7 +380,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
WalletType.litecoin,
|
||||
WalletType.monero,
|
||||
WalletType.wownero,
|
||||
WalletType.decred,
|
||||
WalletType.bitcoinCash,
|
||||
WalletType.dogecoin
|
||||
].contains(wallet.type) &&
|
||||
@@ -808,38 +793,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
}
|
||||
// END Swaps.xyz path
|
||||
|
||||
// Jupiter (Solana) swap path
|
||||
if (walletType == WalletType.solana && trade != null && provider is JupiterExchangeProvider) {
|
||||
final swapTransactionBase64 = trade.routerData;
|
||||
final requestId = trade.routerValue;
|
||||
if (swapTransactionBase64?.isNotEmpty == true &&
|
||||
requestId?.isNotEmpty == true &&
|
||||
solana != null) {
|
||||
try {
|
||||
final actualFee = trade.fee ?? 0.0005;
|
||||
// Fallback to estimate if not available
|
||||
final fee = actualFee > 0 ? actualFee : 0.0005;
|
||||
|
||||
final amount = double.tryParse(trade.amount) ?? 0.0;
|
||||
|
||||
pendingTransaction = await solana!.signAndPrepareJupiterSwapTransaction(
|
||||
wallet,
|
||||
swapTransactionBase64!,
|
||||
requestId!,
|
||||
trade.payoutAddress ?? '',
|
||||
amount,
|
||||
fee,
|
||||
);
|
||||
|
||||
state = ExecutedSuccessfullyState();
|
||||
return pendingTransaction;
|
||||
} catch (e, s) {
|
||||
printV('Jupiter swap error: $e\n$s');
|
||||
throw Exception('Failed to process Jupiter swap: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Regular flow
|
||||
|
||||
|
||||
@@ -990,78 +943,8 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
}
|
||||
}
|
||||
|
||||
await _updateSolanaTrade(signature: pendingTransaction!.id, isSuccess: true);
|
||||
|
||||
if (walletType == WalletType.solana) {
|
||||
Future.delayed(Duration(seconds: 1), () async {
|
||||
try {
|
||||
await solana!.pollForTransaction(
|
||||
wallet,
|
||||
pendingTransaction!.id,
|
||||
initialDelay: const Duration(seconds: 1),
|
||||
maxRetries: 5,
|
||||
);
|
||||
} catch (e) {
|
||||
printV('Failed to poll for transaction: $e');
|
||||
}
|
||||
});
|
||||
|
||||
// Update balances for currencies involved in swap
|
||||
if (_currentTrade != null) {
|
||||
Future.delayed(Duration(seconds: 2), () async {
|
||||
try {
|
||||
final tokenMints = <String>[];
|
||||
|
||||
// Extract from currency mint (skip native SOL)
|
||||
if (_currentTrade!.from != null && _currentTrade!.from != CryptoCurrency.sol) {
|
||||
try {
|
||||
final fromMint = solana!.getTokenAddress(_currentTrade!.from!);
|
||||
tokenMints.add(fromMint);
|
||||
} catch (e) {
|
||||
printV('Error getting from currency mint: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// Extract to currency mint (skip native SOL)
|
||||
if (_currentTrade!.to != null && _currentTrade!.to != CryptoCurrency.sol) {
|
||||
try {
|
||||
final toMint = solana!.getTokenAddress(_currentTrade!.to!);
|
||||
tokenMints.add(toMint);
|
||||
} catch (e) {
|
||||
printV('Error getting to currency mint: $e');
|
||||
}
|
||||
}
|
||||
|
||||
if (tokenMints.isNotEmpty) {
|
||||
solana!.updateTokenBalances(
|
||||
wallet,
|
||||
tokenMints: tokenMints,
|
||||
);
|
||||
|
||||
// Retry after a bit more time to ensure balance is updated
|
||||
Future.delayed(Duration(seconds: 2), () async {
|
||||
try {
|
||||
await solana!.updateTokenBalances(
|
||||
wallet,
|
||||
tokenMints: tokenMints,
|
||||
);
|
||||
} catch (e) {
|
||||
printV('Error retrying balance update: $e');
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
printV('Failed to update balances after send: $e');
|
||||
} finally {
|
||||
_currentTrade = null;
|
||||
_currentProvider = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Immediate transaction update for EVM chains, Tron, and Nano
|
||||
if (isEVMWallet || [WalletType.bitcoin, WalletType.solana, WalletType.tron, WalletType.nano].contains(walletType)) {
|
||||
// Immediate transaction update for EVM chains and Nano
|
||||
if (isEVMWallet || [WalletType.bitcoin, WalletType.nano].contains(walletType)) {
|
||||
Future.delayed(Duration(seconds: 4), () async {
|
||||
try {
|
||||
await Future.wait([
|
||||
@@ -1081,27 +964,10 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
await sharedPreferences.setString(PreferencesKey.backgroundSyncLastTrigger(wallet.name),
|
||||
DateTime.now().add(Duration(minutes: 1)).toIso8601String());
|
||||
} catch (e) {
|
||||
if (e is JupiterSwapFailedException) {
|
||||
await _updateSolanaTrade(signature: e.signature, isSuccess: false);
|
||||
}
|
||||
state = FailureState(translateErrorMessage(e, wallet.type, wallet.currency));
|
||||
await _updateSolanaTrade(signature: '', isSuccess: false);
|
||||
}
|
||||
}
|
||||
|
||||
/// Update Jupiter trade with relevant details after transaction is committed
|
||||
Future<void> _updateSolanaTrade({required String signature, required bool isSuccess}) async {
|
||||
if (_currentTrade == null ||
|
||||
_currentProvider?.title != 'Jupiter' ||
|
||||
walletType != WalletType.solana) return;
|
||||
|
||||
_currentTrade!.txId = signature;
|
||||
|
||||
_currentTrade!.stateRaw = isSuccess ? TradeState.completed.raw : TradeState.failed.raw;
|
||||
|
||||
await _currentTrade!.save();
|
||||
}
|
||||
|
||||
@action
|
||||
Future<void> updateWalletBalance() async => await wallet.updateBalance();
|
||||
|
||||
@@ -1147,10 +1013,7 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
![
|
||||
WalletType.nano,
|
||||
WalletType.banano,
|
||||
WalletType.solana,
|
||||
WalletType.tron,
|
||||
WalletType.arbitrum,
|
||||
WalletType.zcash,
|
||||
].contains(wallet.type)) {
|
||||
throw Exception('Priority is null for wallet type: ${wallet.type}');
|
||||
}
|
||||
@@ -1198,23 +1061,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
);
|
||||
case WalletType.nano:
|
||||
return nano!.createNanoTransactionCredentials(outputs);
|
||||
case WalletType.solana:
|
||||
return solana!
|
||||
.createSolanaTransactionCredentials(outputs, currency: selectedCryptoCurrency);
|
||||
case WalletType.tron:
|
||||
return tron!.createTronTransactionCredentials(outputs, currency: selectedCryptoCurrency);
|
||||
case WalletType.zano:
|
||||
return zano!.createZanoTransactionCredentials(
|
||||
outputs: outputs, priority: priority!, currency: selectedCryptoCurrency);
|
||||
case WalletType.decred:
|
||||
this.coinTypeToSpendFrom = UnspentCoinType.any;
|
||||
return decred!.createDecredTransactionCredentials(outputs, priority!);
|
||||
case WalletType.zcash:
|
||||
return zcash!.createZcashTransactionCredentials(
|
||||
outputs,
|
||||
currency: selectedCryptoCurrency,
|
||||
// priority: priority,
|
||||
);
|
||||
default:
|
||||
throw Exception('Unexpected wallet type: ${wallet.type} for send');
|
||||
}
|
||||
@@ -1242,11 +1088,9 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
}
|
||||
|
||||
@computed
|
||||
bool get hasMemos => [WalletType.zcash].contains(wallet.type);
|
||||
bool get hasMemos => false;
|
||||
|
||||
final Map<WalletType, int> _maxMemoLengths = {
|
||||
WalletType.zcash: 512,
|
||||
};
|
||||
final Map<WalletType, int> _maxMemoLengths = {};
|
||||
|
||||
@computed
|
||||
int get maxMemoLength => _maxMemoLengths[wallet.type] ?? 9999999;
|
||||
@@ -1366,77 +1210,7 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
) {
|
||||
String errorMessage = error.toString();
|
||||
|
||||
if (walletType == WalletType.solana) {
|
||||
if (errorMessage.contains('insufficient lamports')) {
|
||||
double solValueNeeded = 0.0;
|
||||
|
||||
// Regular expression to match the number after "need". This shows the exact lamports the user needs to perform the transaction.
|
||||
RegExp regExp = RegExp(r'need (\d+)');
|
||||
|
||||
// Find the match
|
||||
Match? match = regExp.firstMatch(errorMessage);
|
||||
|
||||
if (match != null) {
|
||||
String neededAmount = match.group(1)!;
|
||||
final lamportsNeeded = int.tryParse(neededAmount);
|
||||
|
||||
// 5000 lamport used here is the constant for sending a transaction on solana
|
||||
int lamportsPerSol = 1000000000;
|
||||
|
||||
solValueNeeded =
|
||||
lamportsNeeded != null ? ((lamportsNeeded + 5000) / lamportsPerSol) : 0.0;
|
||||
return S.current.insufficient_lamports(solValueNeeded.toString());
|
||||
} else {
|
||||
return S.current.insufficient_lamport_for_tx;
|
||||
}
|
||||
}
|
||||
|
||||
if (error is SignNativeTokenTransactionRentException) {
|
||||
return S.current.solana_sign_native_transaction_rent_exception;
|
||||
}
|
||||
|
||||
if (error is CreateAssociatedTokenAccountException) {
|
||||
return "${S.current.solana_create_associated_token_account_exception} ${S.current.added_message_for_ata_error}";
|
||||
}
|
||||
|
||||
if (error is SignSPLTokenTransactionRentException) {
|
||||
return S.current.solana_sign_spl_token_transaction_rent_exception;
|
||||
}
|
||||
|
||||
if (error is NoAssociatedTokenAccountException) {
|
||||
return S.current.solana_no_associated_token_account_exception;
|
||||
}
|
||||
|
||||
if (errorMessage.contains('found no record of a prior credit')) {
|
||||
return S.current.insufficient_funds_for_tx;
|
||||
}
|
||||
|
||||
if (errorMessage.contains('insufficient funds for rent') &&
|
||||
errorMessage.contains('Transaction simulation failed') &&
|
||||
errorMessage.contains('account_index')) {
|
||||
final accountIndexMatch = RegExp(r'account_index: (\d+)').firstMatch(errorMessage);
|
||||
if (accountIndexMatch != null) {
|
||||
return int.parse(accountIndexMatch.group(1)!) == 0
|
||||
? S.current.insufficientFundsForRentError
|
||||
: S.current.insufficientFundsForRentErrorReceiver;
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMessage.contains('invalid account data')) {
|
||||
return S.current.solana_invalid_data_message;
|
||||
}
|
||||
|
||||
if (errorMessage.contains('Blockhash not found') ||
|
||||
errorMessage.contains('BlockhashNotFound') ||
|
||||
errorMessage.contains('BlockhashMNotFound')) {
|
||||
return 'Transaction failed because its recent blockhash expired. '
|
||||
'Please retry your send; if this keeps happening, try again in '
|
||||
'a few seconds or switch to a different Solana node.';
|
||||
}
|
||||
|
||||
return errorMessage;
|
||||
}
|
||||
if (isEVMWallet || walletType == WalletType.haven) {
|
||||
if (isEVMWallet) {
|
||||
if (errorMessage.contains('gas required exceeds allowance')) {
|
||||
return S.current.gas_exceeds_allowance;
|
||||
}
|
||||
@@ -1478,16 +1252,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
if (walletType == WalletType.tron) {
|
||||
if (errorMessage.contains('balance is not sufficient')) {
|
||||
return S.current.do_not_have_enough_gas_asset(currency.toString());
|
||||
}
|
||||
|
||||
if (errorMessage.contains('Transaction expired')) {
|
||||
return S.current.tx_retry_message;
|
||||
}
|
||||
}
|
||||
|
||||
if (error is TransactionWrongBalanceException) {
|
||||
if (error.amount != null)
|
||||
return S.current
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:hash_wallet/reactions/wallet_connect.dart';
|
||||
import 'package:hash_wallet/src/widgets/alert_with_one_action.dart';
|
||||
import 'package:hash_wallet/store/app_store.dart';
|
||||
import 'package:hash_wallet/store/settings_store.dart';
|
||||
import 'package:hash_wallet/tron/tron.dart';
|
||||
import 'package:hash_wallet/utils/show_pop_up.dart';
|
||||
import 'package:hash_wallet/utils/tor.dart';
|
||||
import 'package:cw_core/balance.dart';
|
||||
@@ -96,9 +95,6 @@ abstract class ConnectionSyncViewModelBase with Store {
|
||||
@computed
|
||||
bool get useBscScan => _settingsStore.useBscScan;
|
||||
|
||||
@computed
|
||||
bool get useTronGrid => _settingsStore.useTronGrid;
|
||||
|
||||
@computed
|
||||
bool get canUseEtherscan => _wallet.chainId == 1;
|
||||
|
||||
@@ -114,9 +110,6 @@ abstract class ConnectionSyncViewModelBase with Store {
|
||||
@computed
|
||||
bool get canUseBscScan => _wallet.chainId == 56;
|
||||
|
||||
@computed
|
||||
bool get canUseTronGrid => _wallet.type == WalletType.tron;
|
||||
|
||||
@action
|
||||
void setLookupsTwitter(bool value) => _settingsStore.lookupsTwitter = value;
|
||||
|
||||
@@ -175,12 +168,6 @@ abstract class ConnectionSyncViewModelBase with Store {
|
||||
evm!.updateScanProviderUsageState(_wallet, value);
|
||||
}
|
||||
|
||||
@action
|
||||
void setUseTronGrid(bool value) {
|
||||
_settingsStore.useTronGrid = value;
|
||||
tron!.updateTronGridUsageState(_wallet, value);
|
||||
}
|
||||
|
||||
@action
|
||||
void setUseArbiScan(bool value) {
|
||||
_settingsStore.useArbiScan = value;
|
||||
|
||||
@@ -123,7 +123,7 @@ abstract class DisplaySettingsViewModelBase with Store {
|
||||
bool get showDisplayAmountsInSatoshiSetting => _appStore.wallet?.type == WalletType.bitcoin;
|
||||
|
||||
@computed
|
||||
bool get showZcashCardSetting => _appStore.wallet?.type == WalletType.zcash;
|
||||
bool get showZcashCardSetting => false;
|
||||
|
||||
@action
|
||||
void setDisplayAmountsInSatoshi(BitcoinAmountDisplayMode value) => _settingsStore.displayAmountsInSatoshi = value;
|
||||
|
||||
@@ -76,7 +76,6 @@ abstract class OtherSettingsViewModelBase with Store {
|
||||
WalletType.litecoin,
|
||||
WalletType.bitcoinCash,
|
||||
WalletType.dogecoin,
|
||||
WalletType.decred
|
||||
].contains(_wallet.type);
|
||||
|
||||
@computed
|
||||
@@ -99,8 +98,6 @@ abstract class OtherSettingsViewModelBase with Store {
|
||||
@computed
|
||||
bool get displayTransactionPriority => !(changeRepresentativeEnabled ||
|
||||
[
|
||||
WalletType.solana,
|
||||
WalletType.tron,
|
||||
WalletType.arbitrum,
|
||||
].contains(_wallet.type));
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ abstract class PrivacySettingsViewModelBase with Store {
|
||||
WalletType.litecoin,
|
||||
WalletType.bitcoinCash,
|
||||
WalletType.dogecoin,
|
||||
WalletType.decred
|
||||
].contains(_wallet.type);
|
||||
|
||||
@computed
|
||||
@@ -55,7 +54,6 @@ abstract class PrivacySettingsViewModelBase with Store {
|
||||
WalletType.litecoin,
|
||||
WalletType.monero,
|
||||
WalletType.wownero,
|
||||
WalletType.decred,
|
||||
WalletType.bitcoinCash,
|
||||
WalletType.dogecoin
|
||||
].contains(_wallet.type);
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import 'package:hash_wallet/reactions/wallet_connect.dart';
|
||||
import 'package:hash_wallet/solana/solana.dart';
|
||||
import 'package:hash_wallet/src/screens/transaction_details/address_list_item.dart';
|
||||
import 'package:hash_wallet/src/screens/transaction_details/confirmations_list_item.dart';
|
||||
import 'package:hash_wallet/store/app_store.dart';
|
||||
import 'package:hash_wallet/core/address_validator.dart';
|
||||
import 'package:hash_wallet/tron/tron.dart';
|
||||
import 'package:hash_wallet/zano/zano.dart';
|
||||
import 'package:cw_core/crypto_amount_format.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
@@ -71,8 +68,7 @@ class TxDetailRowDefinition {
|
||||
keyString: "standard_list_item_transaction_details_height_key",
|
||||
title: S.current.transaction_details_height,
|
||||
valueGetter: (vm) => vm.transactionInfo.height?.toString() ?? "",
|
||||
applicable: (vm) => !([WalletType.solana, WalletType.tron].contains(vm.wallet.type) &&
|
||||
!isLightning(vm.transactionInfo))),
|
||||
applicable: (vm) => !isLightning(vm.transactionInfo)),
|
||||
|
||||
|
||||
TxDetailRowDefinition(
|
||||
@@ -89,7 +85,7 @@ class TxDetailRowDefinition {
|
||||
title: S.current.confirmations,
|
||||
valueGetter: (vm) => "${vm.transactionInfo.confirmations}/${vm.neededConfirmations}",
|
||||
applicable: (vm) =>
|
||||
[...electrumWalletTypes, ...evmWalletTypes, WalletType.zcash, WalletType.monero]
|
||||
[...electrumWalletTypes, ...evmWalletTypes, WalletType.monero]
|
||||
.contains(vm.wallet.type) &&
|
||||
!isLightning(vm.transactionInfo),
|
||||
listItemBuilder: ConfirmationsListItem.new),
|
||||
@@ -113,8 +109,6 @@ class TxDetailRowDefinition {
|
||||
ret = (bitcoin!.getTransactionAddresses(vm.wallet, vm.transactionInfo) ?? [])
|
||||
.firstOrNull ??
|
||||
"";
|
||||
case WalletType.tron:
|
||||
ret = tron!.getTronBase58Address(vm.transactionInfo.to!, vm.wallet);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -127,7 +121,7 @@ class TxDetailRowDefinition {
|
||||
applicable: (vm) =>
|
||||
vm.showRecipientAddress &&
|
||||
(vm.transactionInfo.to != null ||
|
||||
[WalletType.monero, WalletType.tron].contains(vm.wallet.type) ||
|
||||
[WalletType.monero].contains(vm.wallet.type) ||
|
||||
vm.wallet.type == WalletType.bitcoin &&
|
||||
vm.transactionInfo.direction == TransactionDirection.incoming),
|
||||
listItemBuilder: AddressListItem.new),
|
||||
@@ -136,14 +130,7 @@ class TxDetailRowDefinition {
|
||||
TxDetailRowDefinition(
|
||||
keyString: "standard_list_item_transaction_details_source_address_key",
|
||||
title: S.current.transaction_details_source_address,
|
||||
valueGetter: (vm) {
|
||||
switch (vm.wallet.type) {
|
||||
case WalletType.tron:
|
||||
return tron!.getTronBase58Address(vm.transactionInfo.from!, vm.wallet);
|
||||
default:
|
||||
return vm.transactionInfo.from!;
|
||||
}
|
||||
},
|
||||
valueGetter: (vm) => vm.transactionInfo.from!,
|
||||
applicable: (vm) => vm.transactionInfo.from != null,
|
||||
listItemBuilder: AddressListItem.new),
|
||||
|
||||
@@ -181,30 +168,6 @@ class TxDetailRowDefinition {
|
||||
applicable: (vm) => vm.wallet.type == WalletType.nano),
|
||||
|
||||
|
||||
TxDetailRowDefinition(
|
||||
keyString: "standard_list_item_transaction_details_memo_key",
|
||||
title: S.current.memo,
|
||||
valueGetter: (vm) => vm.transactionInfo.additionalInfo['memo'] as String,
|
||||
applicable: (vm) =>
|
||||
vm.wallet.type == WalletType.zcash &&
|
||||
vm.transactionInfo.additionalInfo["memo"] != null),
|
||||
|
||||
|
||||
TxDetailRowDefinition(
|
||||
keyString: "standard_list_item_transaction_details_asset_id_key",
|
||||
title: "Asset ID",
|
||||
valueGetter: (vm) =>
|
||||
vm.transactionInfo.additionalInfo["assetId"] as String? ?? "Unknown asset id",
|
||||
applicable: (vm) => vm.wallet.type == WalletType.zano),
|
||||
|
||||
|
||||
TxDetailRowDefinition(
|
||||
keyString: "standard_list_item_transaction_details_comment_key",
|
||||
title: S.current.transaction_details_title,
|
||||
valueGetter: (vm) => vm.transactionInfo.additionalInfo['comment'] as String? ?? "",
|
||||
applicable: (vm) => vm.wallet.type == WalletType.zano),
|
||||
|
||||
|
||||
TxDetailRowDefinition(
|
||||
keyString: "standard_list_item_transaction_details_id_key",
|
||||
title: S.current.transaction_details_transaction_id,
|
||||
@@ -304,12 +267,7 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||
return evm!.assetOfTransaction(wallet, transactionInfo);
|
||||
}
|
||||
|
||||
return switch (wallet.type) {
|
||||
WalletType.solana => solana!.assetOfTransaction(wallet, transactionInfo),
|
||||
WalletType.tron => tron!.assetOfTransaction(wallet, transactionInfo),
|
||||
WalletType.zano => zano!.assetOfTransaction(wallet, transactionInfo) ?? CryptoCurrency.zano,
|
||||
_ => walletTypeToCryptoCurrency(wallet.type)
|
||||
};
|
||||
return walletTypeToCryptoCurrency(wallet.type);
|
||||
}
|
||||
|
||||
|
||||
@@ -317,8 +275,6 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||
String get formattedPendingStatus {
|
||||
switch (wallet.type) {
|
||||
case WalletType.monero:
|
||||
case WalletType.haven:
|
||||
case WalletType.zano:
|
||||
if (transactionInfo.confirmations >= 0 && transactionInfo.confirmations < 10) {
|
||||
return ' (${transactionInfo.confirmations}/10)';
|
||||
}
|
||||
@@ -358,10 +314,8 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||
String get formattedStatus {
|
||||
if ([
|
||||
WalletType.monero,
|
||||
WalletType.haven,
|
||||
WalletType.wownero,
|
||||
WalletType.litecoin,
|
||||
WalletType.zano,
|
||||
].contains(wallet.type)) {
|
||||
return formattedPendingStatus;
|
||||
}
|
||||
@@ -372,8 +326,6 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||
int get neededConfirmations {
|
||||
switch (wallet.type) {
|
||||
case WalletType.monero:
|
||||
case WalletType.haven:
|
||||
case WalletType.zano:
|
||||
return 10;
|
||||
case WalletType.wownero:
|
||||
return 3;
|
||||
@@ -423,8 +375,6 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||
: 'https://blockchair.com/litecoin/transaction/${txId}';
|
||||
case WalletType.bitcoinCash:
|
||||
return 'https://blockchair.com/bitcoin-cash/transaction/${txId}';
|
||||
case WalletType.haven:
|
||||
return 'https://explorer.havenprotocol.org/search?value=${txId}';
|
||||
case WalletType.ethereum:
|
||||
return 'https://etherscan.io/tx/${txId}';
|
||||
case WalletType.base:
|
||||
@@ -439,20 +389,10 @@ abstract class TransactionDetailsViewModelBase with Store {
|
||||
return 'https://nanexplorer.com/nano/block/${txId}';
|
||||
case WalletType.banano:
|
||||
return 'https://nanexplorer.com/banano/block/${txId}';
|
||||
case WalletType.solana:
|
||||
return 'https://solscan.io/tx/${txId}';
|
||||
case WalletType.tron:
|
||||
return 'https://tronscan.org/#/transaction/${txId}';
|
||||
case WalletType.wownero:
|
||||
return 'https://explore.wownero.com/tx/${txId}';
|
||||
case WalletType.zano:
|
||||
return 'https://explorer.zano.org/transaction/${txId}';
|
||||
case WalletType.decred:
|
||||
return 'https://${wallet.isTestnet ? "testnet" : "dcrdata"}.decred.org/tx/${txId.split(':')[0]}';
|
||||
case WalletType.dogecoin:
|
||||
return 'https://blockchair.com/dogecoin/transaction/${txId}';
|
||||
case WalletType.zcash:
|
||||
return 'https://blockchair.com/zcash/transaction/${txId}';
|
||||
case WalletType.none:
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:hash_wallet/monero/monero.dart';
|
||||
import 'package:hash_wallet/store/app_store.dart';
|
||||
import 'package:hash_wallet/store/dashboard/fiat_conversion_store.dart';
|
||||
import 'package:hash_wallet/utils/exception_handler.dart';
|
||||
import 'package:hash_wallet/decred/decred.dart';
|
||||
import 'package:hash_wallet/view_model/unspent_coins/unspent_coins_item.dart';
|
||||
import 'package:hash_wallet/wownero/wownero.dart';
|
||||
import 'package:cw_core/balance.dart';
|
||||
@@ -152,9 +151,6 @@ abstract class UnspentCoinsListViewModelBase with Store {
|
||||
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash, WalletType.dogecoin].contains(wallet.type)) {
|
||||
await bitcoin!.updateUnspents(wallet);
|
||||
}
|
||||
if (wallet.type == WalletType.decred) {
|
||||
decred!.updateUnspents(wallet);
|
||||
}
|
||||
_updateUnspentCoinsInfo();
|
||||
}
|
||||
|
||||
@@ -169,8 +165,6 @@ abstract class UnspentCoinsListViewModelBase with Store {
|
||||
case WalletType.bitcoinCash:
|
||||
case WalletType.dogecoin:
|
||||
return bitcoin!.getUnspents(wallet, coinTypeToSpendFrom: coinTypeToSpendFrom);
|
||||
case WalletType.decred:
|
||||
return decred!.getUnspents(wallet);
|
||||
default:
|
||||
return List.empty();
|
||||
}
|
||||
@@ -187,8 +181,6 @@ abstract class UnspentCoinsListViewModelBase with Store {
|
||||
case WalletType.bitcoinCash:
|
||||
case WalletType.dogecoin:
|
||||
return bitcoin!.getUnspents(wallet, coinTypeToSpendFrom: overrideCoinTypeToSpendFrom);
|
||||
case WalletType.decred:
|
||||
return decred!.getUnspents(wallet);
|
||||
default:
|
||||
return List.empty();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:mobx/mobx.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:hash_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:hash_wallet/monero/monero.dart';
|
||||
import 'package:hash_wallet/decred/decred.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
|
||||
part 'wallet_address_edit_or_create_view_model.g.dart';
|
||||
@@ -78,11 +77,6 @@ abstract class WalletAddressEditOrCreateViewModelBase with Store {
|
||||
await wallet.save();
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.decred) {
|
||||
await decred!.generateNewAddress(wallet, label);
|
||||
await wallet.save();
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.monero) {
|
||||
await monero!
|
||||
.getSubaddressList(wallet)
|
||||
@@ -115,12 +109,6 @@ abstract class WalletAddressEditOrCreateViewModelBase with Store {
|
||||
|
||||
if (isElectrum) await bitcoin!.updateAddress(wallet, _item!.address, label);
|
||||
|
||||
if (wallet.type == WalletType.decred) {
|
||||
await decred!.updateAddress(wallet, _item!.address, label);
|
||||
await wallet.save();
|
||||
return;
|
||||
}
|
||||
|
||||
final index = _item?.id;
|
||||
if (index != null) {
|
||||
if (wallet.type == WalletType.monero) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'dart:developer' as dev;
|
||||
import 'package:hash_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:hash_wallet/core/fiat_conversion_service.dart';
|
||||
import 'package:hash_wallet/core/wallet_change_listener_view_model.dart';
|
||||
import 'package:hash_wallet/decred/decred.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/fiat_currency.dart';
|
||||
@@ -13,11 +12,9 @@ import 'package:hash_wallet/generated/i18n.dart';
|
||||
import 'package:hash_wallet/monero/monero.dart';
|
||||
import 'package:hash_wallet/reactions/wallet_connect.dart';
|
||||
import 'package:hash_wallet/reactions/wallet_utils.dart';
|
||||
import 'package:hash_wallet/solana/solana.dart';
|
||||
import 'package:hash_wallet/store/app_store.dart';
|
||||
import 'package:hash_wallet/store/dashboard/fiat_conversion_store.dart';
|
||||
import 'package:hash_wallet/store/yat/yat_store.dart';
|
||||
import 'package:hash_wallet/tron/tron.dart';
|
||||
import 'package:hash_wallet/utils/list_item.dart';
|
||||
import 'package:hash_wallet/utils/qr_util.dart';
|
||||
import 'package:hash_wallet/view_model/wallet_address_list/wallet_account_list_header.dart';
|
||||
@@ -26,8 +23,6 @@ import 'package:hash_wallet/view_model/wallet_address_list/wallet_address_list_h
|
||||
import 'package:hash_wallet/view_model/wallet_address_list/wallet_address_list_item.dart';
|
||||
import 'package:hash_wallet/view_model/wallet_address_list/wallet_address_util.dart';
|
||||
import 'package:hash_wallet/wownero/wownero.dart';
|
||||
import 'package:hash_wallet/zcash/zcash.dart';
|
||||
import 'package:hash_wallet/zano/zano.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/currency.dart';
|
||||
import 'package:cw_core/currency_for_wallet_type.dart';
|
||||
@@ -62,7 +57,7 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||
_init();
|
||||
|
||||
selectedCurrency = wallet.currency;
|
||||
hasAccounts = [WalletType.monero, WalletType.wownero, WalletType.haven].contains(wallet.type);
|
||||
hasAccounts = [WalletType.monero, WalletType.wownero].contains(wallet.type);
|
||||
}
|
||||
|
||||
final FiatConversionStore fiatConversionStore;
|
||||
@@ -318,12 +313,6 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||
addressList.add(WalletAddressListItem(isPrimary: true, name: null, address: primaryAddress));
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.solana) {
|
||||
final primaryAddress = solana!.getAddress(wallet);
|
||||
|
||||
addressList.add(WalletAddressListItem(isPrimary: true, name: null, address: primaryAddress));
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.nano) {
|
||||
addressList.add(WalletAddressListItem(
|
||||
isPrimary: true,
|
||||
@@ -332,28 +321,6 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||
));
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.tron) {
|
||||
final primaryAddress = tron!.getAddress(wallet);
|
||||
|
||||
addressList.add(WalletAddressListItem(isPrimary: true, name: null, address: primaryAddress));
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.decred) {
|
||||
final addrInfos = decred!.getAddressInfos(wallet);
|
||||
addrInfos.forEach((info) {
|
||||
addressList.add(
|
||||
new WalletAddressListItem(isPrimary: false, address: info.address, name: info.label));
|
||||
});
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.zcash) {
|
||||
final addrInfos = zcash!.getAddressInfos(wallet);
|
||||
addrInfos.forEach((info) {
|
||||
addressList.add(
|
||||
new WalletAddressListItem(isPrimary: false, address: info.address, name: info.label));
|
||||
});
|
||||
}
|
||||
|
||||
for (var i = 0; i < addressList.length; i++) {
|
||||
if (!(addressList[i] is WalletAddressListItem)) continue;
|
||||
final item = addressList[i] as WalletAddressListItem;
|
||||
@@ -367,12 +334,6 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||
.contains((addressList[i] as WalletAddressListItem).address);
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.zano) {
|
||||
final primaryAddress = zano!.getAddress(wallet);
|
||||
|
||||
addressList.add(WalletAddressListItem(isPrimary: true, name: null, address: primaryAddress));
|
||||
}
|
||||
|
||||
if (searchText.isNotEmpty) {
|
||||
return ObservableList.of(addressList.where((item) {
|
||||
if (item is WalletAddressListItem) {
|
||||
@@ -445,17 +406,14 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||
bool get hasAddressList => [
|
||||
WalletType.monero,
|
||||
WalletType.wownero,
|
||||
WalletType.haven,
|
||||
WalletType.bitcoinCash,
|
||||
WalletType.bitcoin,
|
||||
WalletType.litecoin,
|
||||
WalletType.decred,
|
||||
WalletType.dogecoin,
|
||||
WalletType.zcash
|
||||
].contains(wallet.type) && !isLightning && isZCashTransparent;
|
||||
].contains(wallet.type) && !isLightning;
|
||||
|
||||
@computed
|
||||
bool get hasAddressRotation => hasAddressList && wallet.type != WalletType.zcash;
|
||||
bool get hasAddressRotation => hasAddressList;
|
||||
|
||||
@computed
|
||||
bool get isElectrumWallet => [
|
||||
@@ -513,25 +471,6 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||
}
|
||||
|
||||
switch (wallet.type) {
|
||||
case WalletType.solana:
|
||||
return [
|
||||
'assets/images/sol_icon.svg',
|
||||
'assets/images/usdc_icon.svg',
|
||||
'assets/images/usdt_wallet_icon.svg',
|
||||
'assets/images/more_tokens.svg',
|
||||
];
|
||||
case WalletType.tron:
|
||||
return [
|
||||
'assets/images/trx_icon.svg',
|
||||
'assets/images/usdc_icon.svg',
|
||||
'assets/images/usdt_wallet_icon.svg',
|
||||
'assets/images/more_tokens.svg',
|
||||
];
|
||||
case WalletType.zano:
|
||||
return [
|
||||
'assets/images/zano_icon.svg',
|
||||
'assets/images/more_tokens.svg',
|
||||
];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
@@ -559,15 +498,6 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||
@computed
|
||||
bool get isLightning => wallet.type == WalletType.bitcoin && (wallet.walletAddresses.getPaymentUri(_amount) is LightningPaymentRequest);
|
||||
|
||||
@computed
|
||||
bool get isZCashTransparent {
|
||||
if(wallet.type != WalletType.zcash) {
|
||||
return true;
|
||||
}
|
||||
receivePageOption;
|
||||
return wallet.type == WalletType.zcash && zcash!.hasSelectedTransparentAddress(wallet);
|
||||
}
|
||||
|
||||
@observable
|
||||
String receivePageOption;
|
||||
|
||||
@@ -609,9 +539,6 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||
if ([WalletType.bitcoin, WalletType.litecoin].contains(wallet.type)) {
|
||||
await bitcoin!.setAddressType(wallet, option);
|
||||
}
|
||||
if (wallet.type == WalletType.zcash) {
|
||||
await zcash!.setAddressType(wallet, option);
|
||||
}
|
||||
}
|
||||
|
||||
void _init() {
|
||||
@@ -624,7 +551,6 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||
if ([
|
||||
WalletType.monero,
|
||||
WalletType.wownero,
|
||||
WalletType.haven,
|
||||
].contains(wallet.type)) {
|
||||
_baseItems.add(WalletAccountListHeader());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:hash_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:hash_wallet/decred/decred.dart';
|
||||
import 'package:hash_wallet/monero/monero.dart';
|
||||
import 'package:hash_wallet/wownero/wownero.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
@@ -16,11 +15,6 @@ Future<void> createNewAddress(WalletBase wallet, String label) async {
|
||||
await wallet.save();
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.decred) {
|
||||
await decred!.generateNewAddress(wallet, label);
|
||||
await wallet.save();
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.monero) {
|
||||
await monero!
|
||||
.getSubaddressList(wallet)
|
||||
|
||||
@@ -118,7 +118,7 @@ abstract class WalletCreationVMBase with Store {
|
||||
path: path,
|
||||
dirPath: dirPath,
|
||||
address: '',
|
||||
showIntroCakePayCard: (!await walletCreationService.typeExists(type)) && type != WalletType.haven,
|
||||
showIntroCakePayCard: !await walletCreationService.typeExists(type),
|
||||
derivationInfoId: diId,
|
||||
hardwareWalletType: credentials.hardwareWalletType,
|
||||
);
|
||||
|
||||
@@ -4,8 +4,6 @@ import 'package:hash_wallet/monero/monero.dart';
|
||||
import 'package:hash_wallet/src/screens/transaction_details/standart_list_item.dart';
|
||||
import 'package:hash_wallet/store/app_store.dart';
|
||||
import 'package:hash_wallet/wownero/wownero.dart';
|
||||
import 'package:hash_wallet/zano/zano.dart';
|
||||
import 'package:hash_wallet/zcash/zcash.dart';
|
||||
import 'package:cw_core/transaction_direction.dart';
|
||||
import 'package:cw_core/transaction_info.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
@@ -14,7 +12,6 @@ import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:cw_monero/monero_wallet.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:hash_wallet/decred/decred.dart';
|
||||
import 'package:polyseed/polyseed.dart';
|
||||
import 'package:hash_wallet/evm/evm.dart';
|
||||
import 'package:hash_wallet/reactions/wallet_connect.dart';
|
||||
@@ -38,7 +35,6 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
});
|
||||
|
||||
if (_wallet.type == WalletType.monero ||
|
||||
_wallet.type == WalletType.haven ||
|
||||
_wallet.type == WalletType.wownero) {
|
||||
final accountTransactions = _getWalletTransactions(_wallet);
|
||||
if (accountTransactions.isNotEmpty) {
|
||||
@@ -85,7 +81,7 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
bool get isBitcoin => _wallet.type == WalletType.bitcoin;
|
||||
|
||||
// this is incomplete, needs legacy seed toggle for XMR
|
||||
bool get shouldShowHeightBox => [WalletType.bitcoin, WalletType.zcash].contains(_wallet.type);
|
||||
bool get shouldShowHeightBox => [WalletType.bitcoin].contains(_wallet.type);
|
||||
final ObservableList<StandartListItem> items;
|
||||
|
||||
@observable
|
||||
@@ -160,19 +156,11 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
case WalletType.wownero:
|
||||
keys = wownero!.getKeys(_wallet);
|
||||
break;
|
||||
case WalletType.zano:
|
||||
keys = zano!.getKeys(_wallet);
|
||||
break;
|
||||
case WalletType.zcash:
|
||||
keys = zcash!.getKeys(_wallet);
|
||||
break;
|
||||
case WalletType.ethereum:
|
||||
case WalletType.polygon:
|
||||
case WalletType.base:
|
||||
case WalletType.arbitrum:
|
||||
case WalletType.bsc:
|
||||
case WalletType.solana:
|
||||
case WalletType.tron:
|
||||
items.addAll([
|
||||
if (_wallet.privateKey != null)
|
||||
StandartListItem(
|
||||
@@ -200,12 +188,6 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
),
|
||||
]);
|
||||
break;
|
||||
case WalletType.decred:
|
||||
final pubkey = decred!.pubkey(_appStore.wallet!);
|
||||
items.addAll([
|
||||
StandartListItem(title: S.current.view_key_public, value: pubkey),
|
||||
]);
|
||||
break;
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.litecoin:
|
||||
case WalletType.bitcoinCash:
|
||||
@@ -228,7 +210,6 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
]);
|
||||
break;
|
||||
case WalletType.none:
|
||||
case WalletType.haven:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -297,8 +278,6 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
return 'bitcoin-wallet';
|
||||
case WalletType.litecoin:
|
||||
return 'litecoin-wallet';
|
||||
case WalletType.haven:
|
||||
return 'haven-wallet';
|
||||
case WalletType.ethereum:
|
||||
return 'ethereum-wallet';
|
||||
case WalletType.bitcoinCash:
|
||||
@@ -315,20 +294,10 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
return 'arbitrum-wallet';
|
||||
case WalletType.bsc:
|
||||
return 'bsc-wallet';
|
||||
case WalletType.solana:
|
||||
return 'solana-wallet';
|
||||
case WalletType.tron:
|
||||
return 'tron-wallet';
|
||||
case WalletType.wownero:
|
||||
return 'wownero-wallet';
|
||||
case WalletType.zano:
|
||||
return 'zano-wallet';
|
||||
case WalletType.decred:
|
||||
return 'decred-wallet';
|
||||
case WalletType.dogecoin:
|
||||
return 'dogecoin-wallet';
|
||||
case WalletType.zcash:
|
||||
return 'zcash-wallet';
|
||||
case WalletType.none:
|
||||
throw Exception('Unexpected wallet type: ${_wallet.type.toString()} for wallet keys');
|
||||
}
|
||||
@@ -341,9 +310,6 @@ abstract class WalletKeysViewModelBase with Store {
|
||||
if (_wallet.type == WalletType.wownero) {
|
||||
return wownero!.getRestoreHeight(_wallet)?.toString();
|
||||
}
|
||||
if (_wallet.type == WalletType.zcash) {
|
||||
return zcash!.getKeys(_wallet)["restoreHeight"]?.toString();
|
||||
}
|
||||
if (_restoreHeightByTransactions != 0)
|
||||
return getRoundedRestoreHeight(_restoreHeightByTransactions);
|
||||
if (_restoreHeight != 0) return _restoreHeight.toString();
|
||||
|
||||
@@ -75,9 +75,6 @@ abstract class WalletListViewModelBase with Store {
|
||||
|
||||
@action
|
||||
Future<void> loadWallet(WalletListItem walletItem) async {
|
||||
if (walletItem.type == WalletType.haven) {
|
||||
return;
|
||||
}
|
||||
// bool switchingToSameWalletType = walletItem.type == _appStore.wallet?.type;
|
||||
// await _appStore.wallet?.close(shouldCleanup: !switchingToSameWalletType);
|
||||
final wallet = await _walletLoadingService.load(walletItem.type, walletItem.name);
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import 'package:hash_wallet/core/new_wallet_arguments.dart';
|
||||
import 'package:hash_wallet/dogecoin/dogecoin.dart';
|
||||
import 'package:hash_wallet/evm/evm.dart';
|
||||
import 'package:hash_wallet/zano/zano.dart';
|
||||
import 'package:hash_wallet/bitcoin_cash/bitcoin_cash.dart';
|
||||
import 'package:hash_wallet/solana/solana.dart';
|
||||
import 'package:hash_wallet/tron/tron.dart';
|
||||
import 'package:hash_wallet/wownero/wownero.dart';
|
||||
import 'package:hash_wallet/zcash/zcash.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:hash_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:hash_wallet/core/wallet_creation_service.dart';
|
||||
@@ -16,7 +12,6 @@ import 'package:hash_wallet/nano/nano.dart';
|
||||
import 'package:hash_wallet/store/app_store.dart';
|
||||
import 'package:hash_wallet/view_model/seed_settings_view_model.dart';
|
||||
import 'package:hash_wallet/view_model/wallet_creation_vm.dart';
|
||||
import 'package:hash_wallet/decred/decred.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_credentials.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
@@ -44,7 +39,7 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
|
||||
String selectedMnemonicLanguage;
|
||||
|
||||
bool get hasLanguageSelector =>
|
||||
[WalletType.monero, WalletType.haven, WalletType.wownero].contains(type);
|
||||
[WalletType.monero, WalletType.wownero].contains(type);
|
||||
|
||||
bool get showLanguageSelector => newWalletArguments?.mnemonic == null && hasLanguageSelector;
|
||||
|
||||
@@ -112,20 +107,6 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
|
||||
passphrase: passphrase,
|
||||
);
|
||||
|
||||
case WalletType.solana:
|
||||
return solana!.createSolanaNewWalletCredentials(
|
||||
name: name,
|
||||
password: walletPassword,
|
||||
mnemonic: newWalletArguments!.mnemonic,
|
||||
passphrase: passphrase,
|
||||
);
|
||||
case WalletType.tron:
|
||||
return tron!.createTronNewWalletCredentials(
|
||||
name: name,
|
||||
password: walletPassword,
|
||||
mnemonic: newWalletArguments!.mnemonic,
|
||||
passphrase: passphrase,
|
||||
);
|
||||
case WalletType.wownero:
|
||||
return wownero!.createWowneroNewWalletCredentials(
|
||||
name: name,
|
||||
@@ -134,23 +115,7 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store {
|
||||
password: walletPassword,
|
||||
passphrase: passphrase,
|
||||
);
|
||||
case WalletType.zano:
|
||||
return zano!.createZanoNewWalletCredentials(
|
||||
name: name,
|
||||
password: walletPassword,
|
||||
passphrase: passphrase,
|
||||
);
|
||||
case WalletType.zcash:
|
||||
return zcash!.createZcashNewWalletCredentials(
|
||||
name: name,
|
||||
password: walletPassword,
|
||||
mnemonic: newWalletArguments!.mnemonic,
|
||||
passphrase: passphrase,
|
||||
);
|
||||
case WalletType.decred:
|
||||
return decred!.createDecredNewWalletCredentials(name: name);
|
||||
case WalletType.none:
|
||||
case WalletType.haven:
|
||||
throw Exception('Unexpected type: ${type.toString()}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,18 +8,13 @@ import 'package:hash_wallet/evm/evm.dart';
|
||||
import 'package:hash_wallet/monero/monero.dart';
|
||||
import 'package:hash_wallet/nano/nano.dart';
|
||||
import 'package:hash_wallet/reactions/wallet_connect.dart';
|
||||
import 'package:hash_wallet/solana/solana.dart';
|
||||
import 'package:hash_wallet/store/app_store.dart';
|
||||
import 'package:hash_wallet/tron/tron.dart';
|
||||
import 'package:hash_wallet/decred/decred.dart';
|
||||
import 'package:hash_wallet/utils/feature_flag.dart';
|
||||
import 'package:hash_wallet/view_model/restore/restore_mode.dart';
|
||||
import 'package:hash_wallet/view_model/restore/restore_wallet.dart';
|
||||
import 'package:hash_wallet/view_model/seed_settings_view_model.dart';
|
||||
import 'package:hash_wallet/view_model/wallet_creation_vm.dart';
|
||||
import 'package:hash_wallet/wownero/wownero.dart';
|
||||
import 'package:hash_wallet/zano/zano.dart';
|
||||
import 'package:hash_wallet/zcash/zcash.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_credentials.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
@@ -45,23 +40,17 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
||||
break;
|
||||
case WalletType.nano:
|
||||
case WalletType.banano:
|
||||
case WalletType.solana:
|
||||
case WalletType.tron:
|
||||
case WalletType.wownero:
|
||||
case WalletType.haven:
|
||||
case WalletType.ethereum:
|
||||
case WalletType.polygon:
|
||||
case WalletType.base:
|
||||
case WalletType.arbitrum:
|
||||
case WalletType.bsc:
|
||||
case WalletType.decred:
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.litecoin:
|
||||
case WalletType.zcash:
|
||||
availableModes = [WalletRestoreMode.seed, WalletRestoreMode.keys];
|
||||
break;
|
||||
case WalletType.bitcoinCash:
|
||||
case WalletType.zano:
|
||||
case WalletType.dogecoin:
|
||||
availableModes = [WalletRestoreMode.seed];
|
||||
break;
|
||||
@@ -77,14 +66,13 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
||||
}
|
||||
|
||||
static const moneroSeedMnemonicLength = 25;
|
||||
static const decredSeedMnemonicLength = 15;
|
||||
|
||||
late List<WalletRestoreMode> availableModes;
|
||||
late final bool hasSeedLanguageSelector =
|
||||
[WalletType.monero, WalletType.haven, WalletType.wownero].contains(type);
|
||||
[WalletType.monero, WalletType.wownero].contains(type);
|
||||
|
||||
late final bool hasBlockchainHeightSelector =
|
||||
[WalletType.monero, WalletType.haven, WalletType.wownero, WalletType.zcash].contains(type);
|
||||
[WalletType.monero, WalletType.wownero].contains(type);
|
||||
|
||||
late final bool hasRestoreFromPrivateKey = [
|
||||
WalletType.ethereum,
|
||||
@@ -94,13 +82,10 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
||||
WalletType.bsc,
|
||||
WalletType.nano,
|
||||
WalletType.banano,
|
||||
WalletType.solana,
|
||||
WalletType.tron,
|
||||
WalletType.zcash,
|
||||
].contains(type);
|
||||
|
||||
late final bool onlyViewKeyRestore =
|
||||
[if (FeatureFlag.hasBitcoinViewOnly) WalletType.bitcoin, WalletType.decred].contains(type);
|
||||
[if (FeatureFlag.hasBitcoinViewOnly) WalletType.bitcoin].contains(type);
|
||||
|
||||
final RestoredWallet? restoredWallet;
|
||||
final HardwareWalletType? hardwareWalletType;
|
||||
@@ -177,20 +162,6 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
||||
password: password,
|
||||
passphrase: passphrase,
|
||||
);
|
||||
case WalletType.solana:
|
||||
return solana!.createSolanaRestoreWalletFromSeedCredentials(
|
||||
name: name,
|
||||
mnemonic: seed,
|
||||
password: password,
|
||||
passphrase: passphrase,
|
||||
);
|
||||
case WalletType.tron:
|
||||
return tron!.createTronRestoreWalletFromSeedCredentials(
|
||||
name: name,
|
||||
mnemonic: seed,
|
||||
password: password,
|
||||
passphrase: passphrase,
|
||||
);
|
||||
case WalletType.wownero:
|
||||
return wownero!.createWowneroRestoreWalletFromSeedCredentials(
|
||||
name: name,
|
||||
@@ -199,30 +170,7 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
||||
passphrase: passphrase ?? '',
|
||||
height: height,
|
||||
);
|
||||
case WalletType.zano:
|
||||
return zano!.createZanoRestoreWalletFromSeedCredentials(
|
||||
name: name,
|
||||
password: password,
|
||||
height: height,
|
||||
passphrase: passphrase ?? '',
|
||||
mnemonic: seed,
|
||||
);
|
||||
case WalletType.decred:
|
||||
return decred!.createDecredRestoreWalletFromSeedCredentials(
|
||||
name: name,
|
||||
mnemonic: seed,
|
||||
password: password,
|
||||
);
|
||||
case WalletType.zcash:
|
||||
return zcash!.createZcashRestoreWalletFromSeedCredentials(
|
||||
name: name,
|
||||
mnemonic: seed,
|
||||
password: password,
|
||||
passphrase: passphrase,
|
||||
height: height,
|
||||
);
|
||||
case WalletType.none:
|
||||
case WalletType.haven:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -282,18 +230,6 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
||||
password: password,
|
||||
privateKey: options['private_key'] as String,
|
||||
);
|
||||
case WalletType.solana:
|
||||
return solana!.createSolanaRestoreWalletFromPrivateKey(
|
||||
name: name,
|
||||
password: password,
|
||||
privateKey: options['private_key'] as String,
|
||||
);
|
||||
case WalletType.tron:
|
||||
return tron!.createTronRestoreWalletFromPrivateKey(
|
||||
name: name,
|
||||
password: password,
|
||||
privateKey: options['private_key'] as String,
|
||||
);
|
||||
case WalletType.wownero:
|
||||
return wownero!.createWowneroRestoreWalletFromKeysCredentials(
|
||||
name: name,
|
||||
@@ -304,19 +240,6 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
||||
password: password,
|
||||
language: 'English',
|
||||
);
|
||||
case WalletType.decred:
|
||||
return decred!.createDecredRestoreWalletFromPubkeyCredentials(
|
||||
name: name,
|
||||
password: password,
|
||||
pubkey: viewKey!,
|
||||
);
|
||||
case WalletType.zcash:
|
||||
return zcash!.createZcashRestoreWalletFromPrivateKey(
|
||||
name: name,
|
||||
privateKey: options['private_key'] as String,
|
||||
password: password,
|
||||
height: height
|
||||
);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user