From 7d0720b21d0492951e508614384bef77808d591c Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Thu, 23 May 2024 19:43:05 +0300 Subject: [PATCH] Generic enhancements (#1464) * Fix wallet not considering seed length for Tron, Polygon and Solana * Change Trocador to be prioritized if same rate [skip ci] --- lib/core/wallet_creation_service.dart | 21 ++++++++++++++++++- .../exchange/exchange_view_model.dart | 4 ++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/core/wallet_creation_service.dart b/lib/core/wallet_creation_service.dart index a55e9ee3f..1fa50a6be 100644 --- a/lib/core/wallet_creation_service.dart +++ b/lib/core/wallet_creation_service.dart @@ -58,7 +58,7 @@ class WalletCreationService { checkIfExists(credentials.name); final password = generateWalletPassword(); credentials.password = password; - if (type == WalletType.bitcoinCash || type == WalletType.ethereum) { + if (_hasSeedPhraseLengthOption) { credentials.seedPhraseLength = settingsStore.seedPhraseLength.value; } await keyService.saveWalletPassword(password: password, walletName: credentials.name); @@ -72,6 +72,25 @@ class WalletCreationService { return wallet; } + bool get _hasSeedPhraseLengthOption { + switch (type) { + case WalletType.ethereum: + case WalletType.bitcoinCash: + case WalletType.polygon: + case WalletType.solana: + case WalletType.tron: + return true; + case WalletType.monero: + case WalletType.none: + case WalletType.bitcoin: + case WalletType.litecoin: + case WalletType.haven: + case WalletType.nano: + case WalletType.banano: + return false; + } + } + Future restoreFromKeys(WalletCredentials credentials, {bool? isTestnet}) async { checkIfExists(credentials.name); final password = generateWalletPassword(); diff --git a/lib/view_model/exchange/exchange_view_model.dart b/lib/view_model/exchange/exchange_view_model.dart index 1560a4be0..5e0443bf8 100644 --- a/lib/view_model/exchange/exchange_view_model.dart +++ b/lib/view_model/exchange/exchange_view_model.dart @@ -154,11 +154,11 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with ChangeNowExchangeProvider(settingsStore: _settingsStore), SideShiftExchangeProvider(), SimpleSwapExchangeProvider(), - TrocadorExchangeProvider( - useTorOnly: _useTorOnly, providerStates: _settingsStore.trocadorProviderStates), ThorChainExchangeProvider(tradesStore: trades), if (FeatureFlag.isExolixEnabled) ExolixExchangeProvider(), QuantexExchangeProvider(), + TrocadorExchangeProvider( + useTorOnly: _useTorOnly, providerStates: _settingsStore.trocadorProviderStates), ]; @observable