2023-05-17 14:43:23 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
2021-12-24 12:37:24 +00:00
|
|
|
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
2023-10-12 22:50:16 +00:00
|
|
|
import 'package:cake_wallet/bitcoin_cash/bitcoin_cash.dart';
|
2023-08-29 16:11:51 +00:00
|
|
|
import 'package:cake_wallet/entities/auto_generate_subaddress_status.dart';
|
2024-01-01 13:05:37 +00:00
|
|
|
import 'package:cake_wallet/entities/provider_types.dart';
|
2023-08-04 13:49:26 +00:00
|
|
|
import 'package:cake_wallet/entities/cake_2fa_preset_options.dart';
|
2023-08-04 17:55:56 +00:00
|
|
|
import 'package:cake_wallet/entities/background_tasks.dart';
|
2023-03-01 21:44:15 +00:00
|
|
|
import 'package:cake_wallet/entities/exchange_api_mode.dart';
|
2022-11-22 20:52:28 +00:00
|
|
|
import 'package:cake_wallet/entities/pin_code_required_duration.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/entities/preferences_key.dart';
|
2024-01-23 00:30:16 +00:00
|
|
|
import 'package:cake_wallet/entities/secret_store_key.dart';
|
2023-11-17 13:45:42 +00:00
|
|
|
import 'package:cake_wallet/entities/seed_phrase_length.dart';
|
2023-11-25 00:37:12 +00:00
|
|
|
import 'package:cake_wallet/entities/seed_type.dart';
|
2023-08-04 17:01:49 +00:00
|
|
|
import 'package:cake_wallet/entities/sort_balance_types.dart';
|
2023-12-13 21:58:43 +00:00
|
|
|
import 'package:cake_wallet/entities/wallet_list_order_types.dart';
|
2023-12-02 02:26:43 +00:00
|
|
|
import 'package:cake_wallet/polygon/polygon.dart';
|
2023-11-16 23:23:34 +00:00
|
|
|
import 'package:cake_wallet/exchange/provider/trocador_exchange_provider.dart';
|
2023-08-04 17:55:56 +00:00
|
|
|
import 'package:cake_wallet/view_model/settings/sync_mode.dart';
|
2023-05-26 18:13:22 +00:00
|
|
|
import 'package:cake_wallet/utils/device_info.dart';
|
2023-08-04 17:01:49 +00:00
|
|
|
import 'package:cake_wallet/ethereum/ethereum.dart';
|
2024-02-23 18:49:21 +00:00
|
|
|
import 'package:cake_wallet/wallet_type_utils.dart';
|
2021-12-24 12:37:24 +00:00
|
|
|
import 'package:cw_core/transaction_priority.dart';
|
2020-12-15 19:43:50 +00:00
|
|
|
import 'package:cake_wallet/themes/theme_base.dart';
|
|
|
|
import 'package:cake_wallet/themes/theme_list.dart';
|
2023-05-17 14:43:23 +00:00
|
|
|
import 'package:device_info_plus/device_info_plus.dart';
|
2020-09-28 15:47:43 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-01-23 00:30:16 +00:00
|
|
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
2020-07-06 20:09:03 +00:00
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
import 'package:mobx/mobx.dart';
|
|
|
|
import 'package:package_info/package_info.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/di.dart';
|
2021-12-24 12:37:24 +00:00
|
|
|
import 'package:cw_core/wallet_type.dart';
|
2020-07-06 20:09:03 +00:00
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
2020-09-28 15:47:43 +00:00
|
|
|
import 'package:cake_wallet/entities/language_service.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/entities/balance_display_mode.dart';
|
|
|
|
import 'package:cake_wallet/entities/fiat_currency.dart';
|
2021-12-24 12:37:24 +00:00
|
|
|
import 'package:cw_core/node.dart';
|
|
|
|
import 'package:cake_wallet/monero/monero.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/entities/action_list_display_mode.dart';
|
2022-12-06 23:38:36 +00:00
|
|
|
import 'package:cake_wallet/entities/fiat_api_mode.dart';
|
2023-04-20 09:59:59 +00:00
|
|
|
import 'package:cw_core/set_app_secure_native.dart';
|
2024-01-26 22:51:21 +00:00
|
|
|
|
2020-07-06 20:09:03 +00:00
|
|
|
part 'settings_store.g.dart';
|
|
|
|
|
|
|
|
class SettingsStore = SettingsStoreBase with _$SettingsStore;
|
|
|
|
|
|
|
|
abstract class SettingsStoreBase with Store {
|
|
|
|
SettingsStoreBase(
|
2024-01-23 00:30:16 +00:00
|
|
|
{required FlutterSecureStorage secureStorage,
|
|
|
|
required BackgroundTasks backgroundTasks,
|
2023-08-04 17:55:56 +00:00
|
|
|
required SharedPreferences sharedPreferences,
|
2023-04-16 13:45:35 +00:00
|
|
|
required bool initialShouldShowMarketPlaceInDashboard,
|
2022-10-12 17:09:57 +00:00
|
|
|
required FiatCurrency initialFiatCurrency,
|
|
|
|
required BalanceDisplayMode initialBalanceDisplayMode,
|
|
|
|
required bool initialSaveRecipientAddress,
|
2023-08-29 16:11:51 +00:00
|
|
|
required AutoGenerateSubaddressStatus initialAutoGenerateSubaddressStatus,
|
2023-11-25 00:37:12 +00:00
|
|
|
required SeedType initialMoneroSeedType,
|
2023-04-20 09:59:59 +00:00
|
|
|
required bool initialAppSecure,
|
2023-05-15 12:26:56 +00:00
|
|
|
required bool initialDisableBuy,
|
|
|
|
required bool initialDisableSell,
|
2024-03-25 18:28:45 +00:00
|
|
|
required bool initialDisableBulletin,
|
2023-12-13 21:58:43 +00:00
|
|
|
required WalletListOrderType initialWalletListOrder,
|
|
|
|
required bool initialWalletListAscending,
|
2022-12-06 23:38:36 +00:00
|
|
|
required FiatApiMode initialFiatMode,
|
2022-10-12 17:09:57 +00:00
|
|
|
required bool initialAllowBiometricalAuthentication,
|
2023-05-17 14:43:23 +00:00
|
|
|
required String initialTotpSecretKey,
|
|
|
|
required bool initialUseTOTP2FA,
|
|
|
|
required int initialFailedTokenTrial,
|
2023-03-01 21:44:15 +00:00
|
|
|
required ExchangeApiMode initialExchangeStatus,
|
2022-10-12 17:09:57 +00:00
|
|
|
required ThemeBase initialTheme,
|
|
|
|
required int initialPinLength,
|
|
|
|
required String initialLanguageCode,
|
2023-08-04 17:55:56 +00:00
|
|
|
required SyncMode initialSyncMode,
|
|
|
|
required bool initialSyncAll,
|
2022-10-12 17:09:57 +00:00
|
|
|
// required String initialCurrentLocale,
|
|
|
|
required this.appVersion,
|
2023-05-17 14:43:23 +00:00
|
|
|
required this.deviceName,
|
2022-10-12 17:09:57 +00:00
|
|
|
required Map<WalletType, Node> nodes,
|
2023-10-05 01:09:07 +00:00
|
|
|
required Map<WalletType, Node> powNodes,
|
2022-10-12 17:09:57 +00:00
|
|
|
required this.shouldShowYatPopup,
|
|
|
|
required this.isBitcoinBuyEnabled,
|
|
|
|
required this.actionlistDisplayMode,
|
2022-11-22 20:52:28 +00:00
|
|
|
required this.pinTimeOutDuration,
|
2023-11-17 13:45:42 +00:00
|
|
|
required this.seedPhraseLength,
|
2023-08-04 13:49:26 +00:00
|
|
|
required Cake2FAPresetsOptions initialCake2FAPresetOptions,
|
|
|
|
required bool initialShouldRequireTOTP2FAForAccessingWallet,
|
|
|
|
required bool initialShouldRequireTOTP2FAForSendsToContact,
|
|
|
|
required bool initialShouldRequireTOTP2FAForSendsToNonContact,
|
|
|
|
required bool initialShouldRequireTOTP2FAForSendsToInternalWallets,
|
|
|
|
required bool initialShouldRequireTOTP2FAForExchangesToInternalWallets,
|
2023-11-02 18:17:52 +00:00
|
|
|
required bool initialShouldRequireTOTP2FAForExchangesToExternalWallets,
|
2023-08-04 13:49:26 +00:00
|
|
|
required bool initialShouldRequireTOTP2FAForAddingContacts,
|
|
|
|
required bool initialShouldRequireTOTP2FAForCreatingNewWallets,
|
|
|
|
required bool initialShouldRequireTOTP2FAForAllSecurityAndBackupSettings,
|
2023-08-04 17:01:49 +00:00
|
|
|
required this.sortBalanceBy,
|
|
|
|
required this.pinNativeTokenAtTop,
|
|
|
|
required this.useEtherscan,
|
2023-12-02 02:26:43 +00:00
|
|
|
required this.usePolygonScan,
|
2023-11-17 18:35:46 +00:00
|
|
|
required this.defaultNanoRep,
|
|
|
|
required this.defaultBananoRep,
|
2023-11-03 19:23:11 +00:00
|
|
|
required this.lookupsTwitter,
|
|
|
|
required this.lookupsMastodon,
|
|
|
|
required this.lookupsYatService,
|
|
|
|
required this.lookupsUnstoppableDomains,
|
|
|
|
required this.lookupsOpenAlias,
|
|
|
|
required this.lookupsENS,
|
2022-10-12 17:09:57 +00:00
|
|
|
TransactionPriority? initialBitcoinTransactionPriority,
|
2022-12-08 15:23:17 +00:00
|
|
|
TransactionPriority? initialMoneroTransactionPriority,
|
|
|
|
TransactionPriority? initialHavenTransactionPriority,
|
2023-08-04 17:01:49 +00:00
|
|
|
TransactionPriority? initialLitecoinTransactionPriority,
|
2023-10-12 22:50:16 +00:00
|
|
|
TransactionPriority? initialEthereumTransactionPriority,
|
2023-12-02 02:26:43 +00:00
|
|
|
TransactionPriority? initialPolygonTransactionPriority,
|
2023-10-12 22:50:16 +00:00
|
|
|
TransactionPriority? initialBitcoinCashTransactionPriority})
|
2023-05-17 14:43:23 +00:00
|
|
|
: nodes = ObservableMap<WalletType, Node>.of(nodes),
|
2023-10-05 01:09:07 +00:00
|
|
|
powNodes = ObservableMap<WalletType, Node>.of(powNodes),
|
2024-01-23 00:30:16 +00:00
|
|
|
_secureStorage = secureStorage,
|
2023-05-17 14:43:23 +00:00
|
|
|
_sharedPreferences = sharedPreferences,
|
2023-08-04 17:55:56 +00:00
|
|
|
_backgroundTasks = backgroundTasks,
|
2023-05-17 14:43:23 +00:00
|
|
|
fiatCurrency = initialFiatCurrency,
|
|
|
|
balanceDisplayMode = initialBalanceDisplayMode,
|
|
|
|
shouldSaveRecipientAddress = initialSaveRecipientAddress,
|
2023-08-29 16:11:51 +00:00
|
|
|
autoGenerateSubaddressStatus = initialAutoGenerateSubaddressStatus,
|
2023-11-25 00:37:12 +00:00
|
|
|
moneroSeedType = initialMoneroSeedType,
|
2023-05-17 14:43:23 +00:00
|
|
|
fiatApiMode = initialFiatMode,
|
|
|
|
allowBiometricalAuthentication = initialAllowBiometricalAuthentication,
|
2023-08-04 13:49:26 +00:00
|
|
|
selectedCake2FAPreset = initialCake2FAPresetOptions,
|
2023-05-17 14:43:23 +00:00
|
|
|
totpSecretKey = initialTotpSecretKey,
|
|
|
|
useTOTP2FA = initialUseTOTP2FA,
|
|
|
|
numberOfFailedTokenTrials = initialFailedTokenTrial,
|
2023-04-20 09:59:59 +00:00
|
|
|
isAppSecure = initialAppSecure,
|
2023-05-17 14:43:23 +00:00
|
|
|
disableBuy = initialDisableBuy,
|
|
|
|
disableSell = initialDisableSell,
|
2024-03-25 18:28:45 +00:00
|
|
|
disableBulletin = initialDisableBulletin,
|
2023-12-13 21:58:43 +00:00
|
|
|
walletListOrder = initialWalletListOrder,
|
|
|
|
walletListAscending = initialWalletListAscending,
|
2023-04-16 13:45:35 +00:00
|
|
|
shouldShowMarketPlaceInDashboard = initialShouldShowMarketPlaceInDashboard,
|
2023-05-17 14:43:23 +00:00
|
|
|
exchangeStatus = initialExchangeStatus,
|
|
|
|
currentTheme = initialTheme,
|
|
|
|
pinCodeLength = initialPinLength,
|
|
|
|
languageCode = initialLanguageCode,
|
2023-08-04 13:49:26 +00:00
|
|
|
shouldRequireTOTP2FAForAccessingWallet = initialShouldRequireTOTP2FAForAccessingWallet,
|
|
|
|
shouldRequireTOTP2FAForSendsToContact = initialShouldRequireTOTP2FAForSendsToContact,
|
|
|
|
shouldRequireTOTP2FAForSendsToNonContact = initialShouldRequireTOTP2FAForSendsToNonContact,
|
|
|
|
shouldRequireTOTP2FAForSendsToInternalWallets =
|
|
|
|
initialShouldRequireTOTP2FAForSendsToInternalWallets,
|
|
|
|
shouldRequireTOTP2FAForExchangesToInternalWallets =
|
|
|
|
initialShouldRequireTOTP2FAForExchangesToInternalWallets,
|
2023-11-02 18:17:52 +00:00
|
|
|
shouldRequireTOTP2FAForExchangesToExternalWallets =
|
|
|
|
initialShouldRequireTOTP2FAForExchangesToExternalWallets,
|
2023-08-04 13:49:26 +00:00
|
|
|
shouldRequireTOTP2FAForAddingContacts = initialShouldRequireTOTP2FAForAddingContacts,
|
|
|
|
shouldRequireTOTP2FAForCreatingNewWallets =
|
|
|
|
initialShouldRequireTOTP2FAForCreatingNewWallets,
|
|
|
|
shouldRequireTOTP2FAForAllSecurityAndBackupSettings =
|
|
|
|
initialShouldRequireTOTP2FAForAllSecurityAndBackupSettings,
|
2023-08-04 17:55:56 +00:00
|
|
|
currentSyncMode = initialSyncMode,
|
|
|
|
currentSyncAll = initialSyncAll,
|
2023-12-28 19:20:59 +00:00
|
|
|
priority = ObservableMap<WalletType, TransactionPriority>(),
|
2024-01-01 13:05:37 +00:00
|
|
|
defaultBuyProviders = ObservableMap<WalletType, ProviderType>(),
|
|
|
|
defaultSellProviders = ObservableMap<WalletType, ProviderType>() {
|
2022-10-12 17:09:57 +00:00
|
|
|
//this.nodes = ObservableMap<WalletType, Node>.of(nodes);
|
|
|
|
|
|
|
|
if (initialMoneroTransactionPriority != null) {
|
2023-05-17 14:43:23 +00:00
|
|
|
priority[WalletType.monero] = initialMoneroTransactionPriority;
|
2022-10-12 17:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (initialBitcoinTransactionPriority != null) {
|
2023-05-17 14:43:23 +00:00
|
|
|
priority[WalletType.bitcoin] = initialBitcoinTransactionPriority;
|
2022-10-12 17:09:57 +00:00
|
|
|
}
|
2020-09-10 14:51:59 +00:00
|
|
|
|
2022-12-08 15:23:17 +00:00
|
|
|
if (initialHavenTransactionPriority != null) {
|
2023-05-17 14:43:23 +00:00
|
|
|
priority[WalletType.haven] = initialHavenTransactionPriority;
|
2022-12-08 15:23:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (initialLitecoinTransactionPriority != null) {
|
2023-05-17 14:43:23 +00:00
|
|
|
priority[WalletType.litecoin] = initialLitecoinTransactionPriority;
|
2022-12-08 15:23:17 +00:00
|
|
|
}
|
|
|
|
|
2023-08-04 17:01:49 +00:00
|
|
|
if (initialEthereumTransactionPriority != null) {
|
|
|
|
priority[WalletType.ethereum] = initialEthereumTransactionPriority;
|
|
|
|
}
|
|
|
|
|
2023-12-02 02:26:43 +00:00
|
|
|
if (initialPolygonTransactionPriority != null) {
|
|
|
|
priority[WalletType.polygon] = initialPolygonTransactionPriority;
|
|
|
|
}
|
|
|
|
|
2023-10-12 22:50:16 +00:00
|
|
|
if (initialBitcoinCashTransactionPriority != null) {
|
|
|
|
priority[WalletType.bitcoinCash] = initialBitcoinCashTransactionPriority;
|
|
|
|
}
|
|
|
|
|
2023-11-16 23:23:34 +00:00
|
|
|
initializeTrocadorProviderStates();
|
|
|
|
|
2023-12-08 14:05:52 +00:00
|
|
|
WalletType.values.forEach((walletType) {
|
2023-12-28 19:20:59 +00:00
|
|
|
final key = 'buyProvider_${walletType.toString()}';
|
|
|
|
final providerId = sharedPreferences.getString(key);
|
|
|
|
if (providerId != null) {
|
2024-01-23 00:30:16 +00:00
|
|
|
defaultBuyProviders[walletType] = ProviderType.values.firstWhere(
|
|
|
|
(provider) => provider.id == providerId,
|
|
|
|
orElse: () => ProviderType.askEachTime);
|
2023-12-28 19:20:59 +00:00
|
|
|
} else {
|
2024-01-01 13:05:37 +00:00
|
|
|
defaultBuyProviders[walletType] = ProviderType.askEachTime;
|
2023-12-28 19:20:59 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
WalletType.values.forEach((walletType) {
|
|
|
|
final key = 'sellProvider_${walletType.toString()}';
|
|
|
|
final providerId = sharedPreferences.getString(key);
|
|
|
|
if (providerId != null) {
|
2024-01-23 00:30:16 +00:00
|
|
|
defaultSellProviders[walletType] = ProviderType.values.firstWhere(
|
|
|
|
(provider) => provider.id == providerId,
|
|
|
|
orElse: () => ProviderType.askEachTime);
|
2023-12-28 19:20:59 +00:00
|
|
|
} else {
|
2024-01-01 13:05:37 +00:00
|
|
|
defaultSellProviders[walletType] = ProviderType.askEachTime;
|
2023-12-28 19:20:59 +00:00
|
|
|
}
|
2023-12-08 14:05:52 +00:00
|
|
|
});
|
|
|
|
|
2020-09-28 19:02:30 +00:00
|
|
|
reaction(
|
|
|
|
(_) => fiatCurrency,
|
|
|
|
(FiatCurrency fiatCurrency) => sharedPreferences.setString(
|
|
|
|
PreferencesKey.currentFiatCurrencyKey, fiatCurrency.serialize()));
|
|
|
|
|
2021-10-04 13:03:35 +00:00
|
|
|
reaction(
|
|
|
|
(_) => shouldShowYatPopup,
|
2023-05-17 14:43:23 +00:00
|
|
|
(bool shouldShowYatPopup) =>
|
|
|
|
sharedPreferences.setBool(PreferencesKey.shouldShowYatPopup, shouldShowYatPopup));
|
2021-10-04 13:03:35 +00:00
|
|
|
|
2023-12-28 19:20:59 +00:00
|
|
|
defaultBuyProviders.observe((change) {
|
|
|
|
final String key = 'buyProvider_${change.key.toString()}';
|
|
|
|
if (change.newValue != null) {
|
|
|
|
sharedPreferences.setString(key, change.newValue!.id);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
defaultSellProviders.observe((change) {
|
|
|
|
final String key = 'sellProvider_${change.key.toString()}';
|
|
|
|
if (change.newValue != null) {
|
|
|
|
sharedPreferences.setString(key, change.newValue!.id);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-01-27 13:51:51 +00:00
|
|
|
priority.observe((change) {
|
2022-12-08 15:23:17 +00:00
|
|
|
final String? key;
|
|
|
|
switch (change.key) {
|
|
|
|
case WalletType.monero:
|
|
|
|
key = PreferencesKey.moneroTransactionPriority;
|
|
|
|
break;
|
|
|
|
case WalletType.bitcoin:
|
|
|
|
key = PreferencesKey.bitcoinTransactionPriority;
|
|
|
|
break;
|
|
|
|
case WalletType.litecoin:
|
|
|
|
key = PreferencesKey.litecoinTransactionPriority;
|
|
|
|
break;
|
|
|
|
case WalletType.haven:
|
|
|
|
key = PreferencesKey.havenTransactionPriority;
|
|
|
|
break;
|
2023-08-04 17:01:49 +00:00
|
|
|
case WalletType.ethereum:
|
|
|
|
key = PreferencesKey.ethereumTransactionPriority;
|
|
|
|
break;
|
2023-10-12 22:50:16 +00:00
|
|
|
case WalletType.bitcoinCash:
|
|
|
|
key = PreferencesKey.bitcoinCashTransactionPriority;
|
|
|
|
break;
|
2023-12-02 02:26:43 +00:00
|
|
|
case WalletType.polygon:
|
|
|
|
key = PreferencesKey.polygonTransactionPriority;
|
|
|
|
break;
|
2022-12-08 15:23:17 +00:00
|
|
|
default:
|
|
|
|
key = null;
|
|
|
|
}
|
2021-01-27 13:51:51 +00:00
|
|
|
|
2022-12-08 15:23:17 +00:00
|
|
|
if (change.newValue != null && key != null) {
|
2022-10-12 17:09:57 +00:00
|
|
|
sharedPreferences.setInt(key, change.newValue!.serialize());
|
|
|
|
}
|
2021-01-27 13:51:51 +00:00
|
|
|
});
|
2020-09-28 19:02:30 +00:00
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => shouldSaveRecipientAddress,
|
|
|
|
(bool shouldSaveRecipientAddress) => sharedPreferences.setBool(
|
2023-05-17 14:43:23 +00:00
|
|
|
PreferencesKey.shouldSaveRecipientAddressKey, shouldSaveRecipientAddress));
|
2020-09-28 19:02:30 +00:00
|
|
|
|
2023-05-26 18:13:22 +00:00
|
|
|
if (DeviceInfo.instance.isMobile) {
|
|
|
|
setIsAppSecureNative(isAppSecure);
|
2023-05-17 15:34:41 +00:00
|
|
|
|
2023-05-26 18:13:22 +00:00
|
|
|
reaction((_) => isAppSecure, (bool isAppSecure) {
|
|
|
|
sharedPreferences.setBool(PreferencesKey.isAppSecureKey, isAppSecure);
|
2023-04-20 09:59:59 +00:00
|
|
|
setIsAppSecureNative(isAppSecure);
|
2023-05-26 18:13:22 +00:00
|
|
|
});
|
|
|
|
}
|
2023-04-20 09:59:59 +00:00
|
|
|
|
2023-07-11 16:07:46 +00:00
|
|
|
reaction((_) => disableBuy,
|
|
|
|
(bool disableBuy) => sharedPreferences.setBool(PreferencesKey.disableBuyKey, disableBuy));
|
2023-05-15 12:26:56 +00:00
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => disableSell,
|
2023-07-11 16:07:46 +00:00
|
|
|
(bool disableSell) =>
|
|
|
|
sharedPreferences.setBool(PreferencesKey.disableSellKey, disableSell));
|
2023-05-15 12:26:56 +00:00
|
|
|
|
2024-03-25 18:28:45 +00:00
|
|
|
reaction(
|
|
|
|
(_) => disableBulletin,
|
|
|
|
(bool disableBulletin) =>
|
|
|
|
sharedPreferences.setBool(PreferencesKey.disableBulletinKey, disableBulletin));
|
|
|
|
|
2023-12-13 21:58:43 +00:00
|
|
|
reaction(
|
|
|
|
(_) => walletListOrder,
|
|
|
|
(WalletListOrderType walletListOrder) =>
|
|
|
|
sharedPreferences.setInt(PreferencesKey.walletListOrder, walletListOrder.index));
|
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => walletListAscending,
|
|
|
|
(bool walletListAscending) =>
|
|
|
|
sharedPreferences.setBool(PreferencesKey.walletListAscending, walletListAscending));
|
|
|
|
|
2023-08-29 16:11:51 +00:00
|
|
|
reaction(
|
|
|
|
(_) => autoGenerateSubaddressStatus,
|
|
|
|
(AutoGenerateSubaddressStatus autoGenerateSubaddressStatus) => sharedPreferences.setInt(
|
|
|
|
PreferencesKey.autoGenerateSubaddressStatusKey, autoGenerateSubaddressStatus.value));
|
|
|
|
|
2023-11-25 00:37:12 +00:00
|
|
|
reaction(
|
|
|
|
(_) => moneroSeedType,
|
2023-12-02 02:26:43 +00:00
|
|
|
(SeedType moneroSeedType) =>
|
|
|
|
sharedPreferences.setInt(PreferencesKey.moneroSeedType, moneroSeedType.raw));
|
2023-11-25 00:37:12 +00:00
|
|
|
|
2022-11-04 11:58:04 +00:00
|
|
|
reaction(
|
2023-05-17 14:43:23 +00:00
|
|
|
(_) => fiatApiMode,
|
|
|
|
(FiatApiMode mode) =>
|
|
|
|
sharedPreferences.setInt(PreferencesKey.currentFiatApiModeKey, mode.serialize()));
|
2022-11-04 11:58:04 +00:00
|
|
|
|
2023-05-17 14:43:23 +00:00
|
|
|
reaction((_) => currentTheme,
|
|
|
|
(ThemeBase theme) => sharedPreferences.setInt(PreferencesKey.currentTheme, theme.raw));
|
2020-09-28 19:02:30 +00:00
|
|
|
|
2023-05-17 14:43:23 +00:00
|
|
|
reaction(
|
|
|
|
(_) => numberOfFailedTokenTrials,
|
|
|
|
(int failedTokenTrail) =>
|
|
|
|
sharedPreferences.setInt(PreferencesKey.failedTotpTokenTrials, failedTokenTrail));
|
|
|
|
|
2023-04-16 13:45:35 +00:00
|
|
|
reaction(
|
|
|
|
(_) => shouldShowMarketPlaceInDashboard,
|
|
|
|
(bool value) =>
|
|
|
|
sharedPreferences.setBool(PreferencesKey.shouldShowMarketPlaceInDashboard, value));
|
|
|
|
|
2023-05-17 14:43:23 +00:00
|
|
|
reaction((_) => pinCodeLength,
|
|
|
|
(int pinLength) => sharedPreferences.setInt(PreferencesKey.currentPinLength, pinLength));
|
2020-09-26 19:17:31 +00:00
|
|
|
|
2020-09-28 19:02:30 +00:00
|
|
|
reaction(
|
|
|
|
(_) => languageCode,
|
2023-05-17 14:43:23 +00:00
|
|
|
(String languageCode) =>
|
|
|
|
sharedPreferences.setString(PreferencesKey.currentLanguageCode, languageCode));
|
2020-12-15 16:29:10 +00:00
|
|
|
|
2023-11-17 13:45:42 +00:00
|
|
|
reaction(
|
2023-12-02 02:26:43 +00:00
|
|
|
(_) => seedPhraseLength,
|
|
|
|
(SeedPhraseLength seedPhraseWordCount) => sharedPreferences.setInt(
|
|
|
|
PreferencesKey.currentSeedPhraseLength, seedPhraseWordCount.value));
|
2023-11-17 13:45:42 +00:00
|
|
|
|
2021-01-15 17:41:30 +00:00
|
|
|
reaction(
|
|
|
|
(_) => balanceDisplayMode,
|
|
|
|
(BalanceDisplayMode mode) => sharedPreferences.setInt(
|
|
|
|
PreferencesKey.currentBalanceDisplayModeKey, mode.serialize()));
|
2020-12-18 19:42:00 +00:00
|
|
|
|
2023-08-04 17:55:56 +00:00
|
|
|
reaction((_) => currentSyncMode, (SyncMode syncMode) {
|
|
|
|
sharedPreferences.setInt(PreferencesKey.syncModeKey, syncMode.type.index);
|
|
|
|
|
|
|
|
_backgroundTasks.registerSyncTask(changeExisting: true);
|
|
|
|
});
|
|
|
|
|
|
|
|
reaction((_) => currentSyncAll, (bool syncAll) {
|
|
|
|
sharedPreferences.setBool(PreferencesKey.syncAllKey, syncAll);
|
|
|
|
|
|
|
|
_backgroundTasks.registerSyncTask(changeExisting: true);
|
|
|
|
});
|
|
|
|
|
2022-12-08 19:14:42 +00:00
|
|
|
reaction(
|
2023-05-17 14:43:23 +00:00
|
|
|
(_) => exchangeStatus,
|
|
|
|
(ExchangeApiMode mode) =>
|
|
|
|
sharedPreferences.setInt(PreferencesKey.exchangeStatusKey, mode.serialize()));
|
|
|
|
|
2023-08-04 17:01:49 +00:00
|
|
|
reaction(
|
|
|
|
(_) => sortBalanceBy,
|
|
|
|
(SortBalanceBy sortBalanceBy) =>
|
|
|
|
_sharedPreferences.setInt(PreferencesKey.sortBalanceBy, sortBalanceBy.index));
|
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => pinNativeTokenAtTop,
|
|
|
|
(bool pinNativeTokenAtTop) =>
|
|
|
|
_sharedPreferences.setBool(PreferencesKey.pinNativeTokenAtTop, pinNativeTokenAtTop));
|
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => useEtherscan,
|
|
|
|
(bool useEtherscan) =>
|
|
|
|
_sharedPreferences.setBool(PreferencesKey.useEtherscan, useEtherscan));
|
|
|
|
|
2023-12-02 02:26:43 +00:00
|
|
|
reaction(
|
|
|
|
(_) => usePolygonScan,
|
|
|
|
(bool usePolygonScan) =>
|
|
|
|
_sharedPreferences.setBool(PreferencesKey.usePolygonScan, usePolygonScan));
|
|
|
|
|
2023-11-17 18:35:46 +00:00
|
|
|
reaction((_) => defaultNanoRep,
|
|
|
|
(String nanoRep) => _sharedPreferences.setString(PreferencesKey.defaultNanoRep, nanoRep));
|
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => defaultBananoRep,
|
|
|
|
(String bananoRep) =>
|
|
|
|
_sharedPreferences.setString(PreferencesKey.defaultBananoRep, bananoRep));
|
2023-11-03 19:23:11 +00:00
|
|
|
reaction(
|
2023-12-02 02:26:43 +00:00
|
|
|
(_) => lookupsTwitter,
|
|
|
|
(bool looksUpTwitter) =>
|
2023-11-03 19:23:11 +00:00
|
|
|
_sharedPreferences.setBool(PreferencesKey.lookupsTwitter, looksUpTwitter));
|
|
|
|
|
|
|
|
reaction(
|
2023-12-02 02:26:43 +00:00
|
|
|
(_) => lookupsMastodon,
|
|
|
|
(bool looksUpMastodon) =>
|
2023-11-03 19:23:11 +00:00
|
|
|
_sharedPreferences.setBool(PreferencesKey.lookupsMastodon, looksUpMastodon));
|
|
|
|
|
|
|
|
reaction(
|
2023-12-02 02:26:43 +00:00
|
|
|
(_) => lookupsYatService,
|
|
|
|
(bool looksUpYatService) =>
|
2023-11-03 19:23:11 +00:00
|
|
|
_sharedPreferences.setBool(PreferencesKey.lookupsYatService, looksUpYatService));
|
|
|
|
|
|
|
|
reaction(
|
2023-12-02 02:26:43 +00:00
|
|
|
(_) => lookupsUnstoppableDomains,
|
|
|
|
(bool looksUpUnstoppableDomains) => _sharedPreferences.setBool(
|
|
|
|
PreferencesKey.lookupsUnstoppableDomains, looksUpUnstoppableDomains));
|
2023-11-03 19:23:11 +00:00
|
|
|
|
|
|
|
reaction(
|
2023-12-02 02:26:43 +00:00
|
|
|
(_) => lookupsOpenAlias,
|
|
|
|
(bool looksUpOpenAlias) =>
|
2023-11-03 19:23:11 +00:00
|
|
|
_sharedPreferences.setBool(PreferencesKey.lookupsOpenAlias, looksUpOpenAlias));
|
|
|
|
|
2023-12-02 02:26:43 +00:00
|
|
|
reaction((_) => lookupsENS,
|
|
|
|
(bool looksUpENS) => _sharedPreferences.setBool(PreferencesKey.lookupsENS, looksUpENS));
|
2023-11-03 19:23:11 +00:00
|
|
|
|
2024-01-23 00:30:16 +00:00
|
|
|
// secure storage keys:
|
|
|
|
reaction(
|
|
|
|
(_) => allowBiometricalAuthentication,
|
|
|
|
(bool biometricalAuthentication) => secureStorage.write(
|
|
|
|
key: SecureKey.allowBiometricalAuthenticationKey,
|
|
|
|
value: biometricalAuthentication.toString()));
|
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => selectedCake2FAPreset,
|
|
|
|
(Cake2FAPresetsOptions selectedCake2FAPreset) => secureStorage.write(
|
|
|
|
key: SecureKey.selectedCake2FAPreset,
|
|
|
|
value: selectedCake2FAPreset.serialize().toString()));
|
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => shouldRequireTOTP2FAForAccessingWallet,
|
|
|
|
(bool requireTOTP2FAForAccessingWallet) => secureStorage.write(
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForAccessingWallet,
|
|
|
|
value: requireTOTP2FAForAccessingWallet.toString()));
|
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => shouldRequireTOTP2FAForSendsToContact,
|
|
|
|
(bool requireTOTP2FAForSendsToContact) => secureStorage.write(
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForSendsToContact,
|
|
|
|
value: requireTOTP2FAForSendsToContact.toString()));
|
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => shouldRequireTOTP2FAForSendsToNonContact,
|
|
|
|
(bool requireTOTP2FAForSendsToNonContact) => secureStorage.write(
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForSendsToNonContact,
|
|
|
|
value: requireTOTP2FAForSendsToNonContact.toString()));
|
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => shouldRequireTOTP2FAForSendsToInternalWallets,
|
|
|
|
(bool requireTOTP2FAForSendsToInternalWallets) => secureStorage.write(
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForSendsToInternalWallets,
|
|
|
|
value: requireTOTP2FAForSendsToInternalWallets.toString()));
|
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => shouldRequireTOTP2FAForExchangesToInternalWallets,
|
|
|
|
(bool requireTOTP2FAForExchangesToInternalWallets) => secureStorage.write(
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForExchangesToInternalWallets,
|
|
|
|
value: requireTOTP2FAForExchangesToInternalWallets.toString()));
|
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => shouldRequireTOTP2FAForExchangesToExternalWallets,
|
|
|
|
(bool requireTOTP2FAForExchangesToExternalWallets) => secureStorage.write(
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForExchangesToExternalWallets,
|
|
|
|
value: requireTOTP2FAForExchangesToExternalWallets.toString()));
|
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => shouldRequireTOTP2FAForAddingContacts,
|
|
|
|
(bool requireTOTP2FAForAddingContacts) => secureStorage.write(
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForAddingContacts,
|
|
|
|
value: requireTOTP2FAForAddingContacts.toString()));
|
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => shouldRequireTOTP2FAForCreatingNewWallets,
|
|
|
|
(bool requireTOTP2FAForCreatingNewWallets) => secureStorage.write(
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForCreatingNewWallets,
|
|
|
|
value: requireTOTP2FAForCreatingNewWallets.toString()));
|
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
|
|
|
|
(bool requireTOTP2FAForAllSecurityAndBackupSettings) => secureStorage.write(
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
|
|
|
|
value: requireTOTP2FAForAllSecurityAndBackupSettings.toString()));
|
|
|
|
|
|
|
|
reaction((_) => useTOTP2FA,
|
|
|
|
(bool use) => secureStorage.write(key: SecureKey.useTOTP2FA, value: use.toString()));
|
|
|
|
|
|
|
|
reaction((_) => totpSecretKey,
|
|
|
|
(String totpKey) => secureStorage.write(key: SecureKey.totpSecretKey, value: totpKey));
|
|
|
|
|
|
|
|
reaction(
|
|
|
|
(_) => pinTimeOutDuration,
|
|
|
|
(PinCodeRequiredDuration pinCodeInterval) => secureStorage.write(
|
|
|
|
key: SecureKey.pinTimeOutDuration, value: pinCodeInterval.value.toString()));
|
|
|
|
|
2023-05-17 14:43:23 +00:00
|
|
|
this.nodes.observe((change) {
|
|
|
|
if (change.newValue != null && change.key != null) {
|
|
|
|
_saveCurrentNode(change.newValue!, change.key!);
|
|
|
|
}
|
|
|
|
});
|
2023-10-05 01:09:07 +00:00
|
|
|
|
|
|
|
this.powNodes.observe((change) {
|
|
|
|
if (change.newValue != null && change.key != null) {
|
|
|
|
_saveCurrentPowNode(change.newValue!, change.key!);
|
|
|
|
}
|
|
|
|
});
|
2020-07-06 20:09:03 +00:00
|
|
|
}
|
|
|
|
|
2020-09-21 11:50:26 +00:00
|
|
|
static const defaultPinLength = 4;
|
|
|
|
static const defaultActionsMode = 11;
|
2022-12-13 15:19:31 +00:00
|
|
|
static const defaultPinCodeTimeOutDuration = PinCodeRequiredDuration.tenminutes;
|
2023-08-29 16:11:51 +00:00
|
|
|
static const defaultAutoGenerateSubaddressStatus = AutoGenerateSubaddressStatus.initialized;
|
2023-11-17 13:45:42 +00:00
|
|
|
static const defaultSeedPhraseLength = SeedPhraseLength.twelveWords;
|
2023-11-25 00:37:12 +00:00
|
|
|
static const defaultMoneroSeedType = SeedType.defaultSeedType;
|
2020-07-06 20:09:03 +00:00
|
|
|
|
|
|
|
@observable
|
|
|
|
FiatCurrency fiatCurrency;
|
|
|
|
|
2021-10-04 13:03:35 +00:00
|
|
|
@observable
|
|
|
|
bool shouldShowYatPopup;
|
|
|
|
|
2023-04-16 13:45:35 +00:00
|
|
|
@observable
|
|
|
|
bool shouldShowMarketPlaceInDashboard;
|
|
|
|
|
2020-07-06 20:09:03 +00:00
|
|
|
@observable
|
|
|
|
ObservableList<ActionListDisplayMode> actionlistDisplayMode;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
BalanceDisplayMode balanceDisplayMode;
|
|
|
|
|
|
|
|
@observable
|
2022-12-06 23:38:36 +00:00
|
|
|
FiatApiMode fiatApiMode;
|
2020-07-06 20:09:03 +00:00
|
|
|
|
|
|
|
@observable
|
|
|
|
bool shouldSaveRecipientAddress;
|
|
|
|
|
2023-08-29 16:11:51 +00:00
|
|
|
@observable
|
|
|
|
AutoGenerateSubaddressStatus autoGenerateSubaddressStatus;
|
|
|
|
|
2023-11-25 00:37:12 +00:00
|
|
|
@observable
|
|
|
|
SeedType moneroSeedType;
|
|
|
|
|
2023-04-20 09:59:59 +00:00
|
|
|
@observable
|
|
|
|
bool isAppSecure;
|
|
|
|
|
2023-05-15 12:26:56 +00:00
|
|
|
@observable
|
|
|
|
bool disableBuy;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool disableSell;
|
|
|
|
|
2024-03-25 18:28:45 +00:00
|
|
|
@observable
|
|
|
|
bool disableBulletin;
|
|
|
|
|
2023-12-13 21:58:43 +00:00
|
|
|
@observable
|
|
|
|
WalletListOrderType walletListOrder;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool walletListAscending;
|
|
|
|
|
2020-07-06 20:09:03 +00:00
|
|
|
@observable
|
|
|
|
bool allowBiometricalAuthentication;
|
|
|
|
|
2023-08-04 13:49:26 +00:00
|
|
|
@observable
|
|
|
|
bool shouldRequireTOTP2FAForAccessingWallet;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool shouldRequireTOTP2FAForSendsToContact;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool shouldRequireTOTP2FAForSendsToNonContact;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool shouldRequireTOTP2FAForSendsToInternalWallets;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool shouldRequireTOTP2FAForExchangesToInternalWallets;
|
|
|
|
|
2023-11-02 18:17:52 +00:00
|
|
|
@observable
|
|
|
|
bool shouldRequireTOTP2FAForExchangesToExternalWallets;
|
|
|
|
|
2023-08-04 13:49:26 +00:00
|
|
|
@observable
|
|
|
|
Cake2FAPresetsOptions selectedCake2FAPreset;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool shouldRequireTOTP2FAForAddingContacts;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool shouldRequireTOTP2FAForCreatingNewWallets;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool shouldRequireTOTP2FAForAllSecurityAndBackupSettings;
|
|
|
|
|
2023-05-17 14:43:23 +00:00
|
|
|
@observable
|
2023-09-28 18:40:15 +00:00
|
|
|
bool useTOTP2FA;
|
2023-05-17 14:43:23 +00:00
|
|
|
|
|
|
|
@observable
|
2023-09-28 18:40:15 +00:00
|
|
|
String totpSecretKey;
|
2023-05-17 14:43:23 +00:00
|
|
|
|
|
|
|
@observable
|
|
|
|
int numberOfFailedTokenTrials;
|
|
|
|
|
2022-11-22 02:18:18 +00:00
|
|
|
@observable
|
2023-03-01 21:44:15 +00:00
|
|
|
ExchangeApiMode exchangeStatus;
|
2022-11-22 02:18:18 +00:00
|
|
|
|
2020-07-06 20:09:03 +00:00
|
|
|
@observable
|
2020-12-15 19:30:16 +00:00
|
|
|
ThemeBase currentTheme;
|
2020-07-06 20:09:03 +00:00
|
|
|
|
|
|
|
@observable
|
2020-09-21 11:50:26 +00:00
|
|
|
int pinCodeLength;
|
2020-07-06 20:09:03 +00:00
|
|
|
|
2022-11-22 20:52:28 +00:00
|
|
|
@observable
|
|
|
|
PinCodeRequiredDuration pinTimeOutDuration;
|
|
|
|
|
2023-11-17 13:45:42 +00:00
|
|
|
@observable
|
|
|
|
SeedPhraseLength seedPhraseLength;
|
|
|
|
|
2020-09-28 15:47:43 +00:00
|
|
|
@computed
|
2020-12-10 17:53:40 +00:00
|
|
|
ThemeData get theme => currentTheme.themeData;
|
2020-07-06 20:09:03 +00:00
|
|
|
|
2020-09-28 15:47:43 +00:00
|
|
|
@observable
|
|
|
|
String languageCode;
|
2020-07-06 20:09:03 +00:00
|
|
|
|
2021-01-27 13:51:51 +00:00
|
|
|
@observable
|
|
|
|
ObservableMap<WalletType, TransactionPriority> priority;
|
|
|
|
|
2023-11-16 23:23:34 +00:00
|
|
|
@observable
|
|
|
|
ObservableMap<String, bool> trocadorProviderStates = ObservableMap<String, bool>();
|
|
|
|
|
2023-12-08 14:05:52 +00:00
|
|
|
@observable
|
2024-01-01 13:05:37 +00:00
|
|
|
ObservableMap<WalletType, ProviderType> defaultBuyProviders;
|
2023-12-28 19:20:59 +00:00
|
|
|
|
|
|
|
@observable
|
2024-01-01 13:05:37 +00:00
|
|
|
ObservableMap<WalletType, ProviderType> defaultSellProviders;
|
2023-12-08 14:05:52 +00:00
|
|
|
|
2023-08-04 17:01:49 +00:00
|
|
|
@observable
|
|
|
|
SortBalanceBy sortBalanceBy;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool pinNativeTokenAtTop;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool useEtherscan;
|
|
|
|
|
2023-12-02 02:26:43 +00:00
|
|
|
@observable
|
|
|
|
bool usePolygonScan;
|
|
|
|
|
2023-11-17 18:35:46 +00:00
|
|
|
@observable
|
|
|
|
String defaultNanoRep;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
String defaultBananoRep;
|
|
|
|
|
2023-11-03 19:23:11 +00:00
|
|
|
@observable
|
|
|
|
bool lookupsTwitter;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool lookupsMastodon;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool lookupsYatService;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool lookupsUnstoppableDomains;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool lookupsOpenAlias;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool lookupsENS;
|
|
|
|
|
2023-08-04 17:55:56 +00:00
|
|
|
@observable
|
|
|
|
SyncMode currentSyncMode;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool currentSyncAll;
|
|
|
|
|
2020-07-06 20:09:03 +00:00
|
|
|
String appVersion;
|
|
|
|
|
2023-05-17 14:43:23 +00:00
|
|
|
String deviceName;
|
|
|
|
|
2024-01-23 00:30:16 +00:00
|
|
|
final FlutterSecureStorage _secureStorage;
|
2023-08-04 17:55:56 +00:00
|
|
|
final SharedPreferences _sharedPreferences;
|
|
|
|
final BackgroundTasks _backgroundTasks;
|
2020-07-06 20:09:03 +00:00
|
|
|
|
2020-09-07 15:13:39 +00:00
|
|
|
ObservableMap<WalletType, Node> nodes;
|
2023-10-05 01:09:07 +00:00
|
|
|
ObservableMap<WalletType, Node> powNodes;
|
2020-08-27 16:54:34 +00:00
|
|
|
|
2022-10-12 17:09:57 +00:00
|
|
|
Node getCurrentNode(WalletType walletType) {
|
|
|
|
final node = nodes[walletType];
|
|
|
|
|
|
|
|
if (node == null) {
|
2023-05-17 14:43:23 +00:00
|
|
|
throw Exception('No node found for wallet type: ${walletType.toString()}');
|
2022-10-12 17:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
2020-08-27 16:54:34 +00:00
|
|
|
|
2023-10-05 01:09:07 +00:00
|
|
|
Node getCurrentPowNode(WalletType walletType) {
|
|
|
|
final node = powNodes[walletType];
|
|
|
|
|
|
|
|
if (node == null) {
|
|
|
|
throw Exception('No pow node found for wallet type: ${walletType.toString()}');
|
|
|
|
}
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2021-03-16 13:20:46 +00:00
|
|
|
bool isBitcoinBuyEnabled;
|
|
|
|
|
2021-06-04 10:30:59 +00:00
|
|
|
bool get shouldShowReceiveWarning =>
|
2023-05-17 14:43:23 +00:00
|
|
|
_sharedPreferences.getBool(PreferencesKey.shouldShowReceiveWarning) ?? true;
|
2021-06-04 10:30:59 +00:00
|
|
|
|
|
|
|
Future<void> setShouldShowReceiveWarning(bool value) async =>
|
2023-05-17 14:43:23 +00:00
|
|
|
_sharedPreferences.setBool(PreferencesKey.shouldShowReceiveWarning, value);
|
2021-06-04 10:30:59 +00:00
|
|
|
|
2020-07-06 20:09:03 +00:00
|
|
|
static Future<SettingsStore> load(
|
2022-10-12 17:09:57 +00:00
|
|
|
{required Box<Node> nodeSource,
|
2023-10-05 01:09:07 +00:00
|
|
|
required Box<Node> powNodeSource,
|
2022-10-12 17:09:57 +00:00
|
|
|
required bool isBitcoinBuyEnabled,
|
2020-07-06 20:09:03 +00:00
|
|
|
FiatCurrency initialFiatCurrency = FiatCurrency.usd,
|
2023-04-14 04:39:08 +00:00
|
|
|
BalanceDisplayMode initialBalanceDisplayMode = BalanceDisplayMode.availableBalance,
|
|
|
|
ThemeBase? initialTheme}) async {
|
2020-07-06 20:09:03 +00:00
|
|
|
final sharedPreferences = await getIt.getAsync<SharedPreferences>();
|
2024-01-23 00:30:16 +00:00
|
|
|
final secureStorage = await getIt.get<FlutterSecureStorage>();
|
2023-08-04 17:55:56 +00:00
|
|
|
final backgroundTasks = getIt.get<BackgroundTasks>();
|
2023-05-17 14:43:23 +00:00
|
|
|
final currentFiatCurrency = FiatCurrency.deserialize(
|
|
|
|
raw: sharedPreferences.getString(PreferencesKey.currentFiatCurrencyKey)!);
|
2022-12-08 15:23:17 +00:00
|
|
|
|
2023-05-17 14:43:23 +00:00
|
|
|
TransactionPriority? moneroTransactionPriority = monero?.deserializeMoneroTransactionPriority(
|
|
|
|
raw: sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority)!);
|
2022-12-08 15:23:17 +00:00
|
|
|
TransactionPriority? bitcoinTransactionPriority =
|
2023-11-17 18:35:46 +00:00
|
|
|
bitcoin?.deserializeBitcoinTransactionPriority(
|
|
|
|
sharedPreferences.getInt(PreferencesKey.bitcoinTransactionPriority)!);
|
2022-12-08 15:23:17 +00:00
|
|
|
|
|
|
|
TransactionPriority? havenTransactionPriority;
|
|
|
|
TransactionPriority? litecoinTransactionPriority;
|
2023-08-04 17:01:49 +00:00
|
|
|
TransactionPriority? ethereumTransactionPriority;
|
2023-12-02 02:26:43 +00:00
|
|
|
TransactionPriority? polygonTransactionPriority;
|
2023-10-12 22:50:16 +00:00
|
|
|
TransactionPriority? bitcoinCashTransactionPriority;
|
2022-12-08 15:23:17 +00:00
|
|
|
|
|
|
|
if (sharedPreferences.getInt(PreferencesKey.havenTransactionPriority) != null) {
|
|
|
|
havenTransactionPriority = monero?.deserializeMoneroTransactionPriority(
|
|
|
|
raw: sharedPreferences.getInt(PreferencesKey.havenTransactionPriority)!);
|
|
|
|
}
|
|
|
|
if (sharedPreferences.getInt(PreferencesKey.litecoinTransactionPriority) != null) {
|
|
|
|
litecoinTransactionPriority = bitcoin?.deserializeLitecoinTransactionPriority(
|
|
|
|
sharedPreferences.getInt(PreferencesKey.litecoinTransactionPriority)!);
|
|
|
|
}
|
2023-08-04 17:01:49 +00:00
|
|
|
if (sharedPreferences.getInt(PreferencesKey.ethereumTransactionPriority) != null) {
|
2023-12-02 02:26:43 +00:00
|
|
|
ethereumTransactionPriority = ethereum?.deserializeEthereumTransactionPriority(
|
2023-08-04 17:01:49 +00:00
|
|
|
sharedPreferences.getInt(PreferencesKey.ethereumTransactionPriority)!);
|
|
|
|
}
|
2023-12-02 02:26:43 +00:00
|
|
|
if (sharedPreferences.getInt(PreferencesKey.polygonTransactionPriority) != null) {
|
|
|
|
polygonTransactionPriority = polygon?.deserializePolygonTransactionPriority(
|
|
|
|
sharedPreferences.getInt(PreferencesKey.polygonTransactionPriority)!);
|
|
|
|
}
|
2023-10-12 22:50:16 +00:00
|
|
|
if (sharedPreferences.getInt(PreferencesKey.bitcoinCashTransactionPriority) != null) {
|
|
|
|
bitcoinCashTransactionPriority = bitcoinCash?.deserializeBitcoinCashTransactionPriority(
|
|
|
|
sharedPreferences.getInt(PreferencesKey.bitcoinCashTransactionPriority)!);
|
|
|
|
}
|
2022-12-08 15:23:17 +00:00
|
|
|
|
|
|
|
moneroTransactionPriority ??= monero?.getDefaultTransactionPriority();
|
|
|
|
bitcoinTransactionPriority ??= bitcoin?.getMediumTransactionPriority();
|
|
|
|
havenTransactionPriority ??= monero?.getDefaultTransactionPriority();
|
|
|
|
litecoinTransactionPriority ??= bitcoin?.getLitecoinTransactionPriorityMedium();
|
2023-08-04 17:01:49 +00:00
|
|
|
ethereumTransactionPriority ??= ethereum?.getDefaultTransactionPriority();
|
2023-10-12 22:50:16 +00:00
|
|
|
bitcoinCashTransactionPriority ??= bitcoinCash?.getDefaultTransactionPriority();
|
2023-12-02 02:26:43 +00:00
|
|
|
polygonTransactionPriority ??= polygon?.getDefaultTransactionPriority();
|
2022-12-08 15:23:17 +00:00
|
|
|
|
2020-07-06 20:09:03 +00:00
|
|
|
final currentBalanceDisplayMode = BalanceDisplayMode.deserialize(
|
2023-05-17 14:43:23 +00:00
|
|
|
raw: sharedPreferences.getInt(PreferencesKey.currentBalanceDisplayModeKey)!);
|
2022-10-12 17:09:57 +00:00
|
|
|
// FIX-ME: Check for which default value we should have here
|
2020-07-06 20:09:03 +00:00
|
|
|
final shouldSaveRecipientAddress =
|
2022-10-12 17:09:57 +00:00
|
|
|
sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey) ?? false;
|
2023-07-11 16:07:46 +00:00
|
|
|
final isAppSecure = sharedPreferences.getBool(PreferencesKey.isAppSecureKey) ?? false;
|
|
|
|
final disableBuy = sharedPreferences.getBool(PreferencesKey.disableBuyKey) ?? false;
|
|
|
|
final disableSell = sharedPreferences.getBool(PreferencesKey.disableSellKey) ?? false;
|
2024-03-25 18:28:45 +00:00
|
|
|
final disableBulletin = sharedPreferences.getBool(PreferencesKey.disableBulletinKey) ?? false;
|
2023-12-13 21:58:43 +00:00
|
|
|
final walletListOrder =
|
|
|
|
WalletListOrderType.values[sharedPreferences.getInt(PreferencesKey.walletListOrder) ?? 0];
|
|
|
|
final walletListAscending =
|
|
|
|
sharedPreferences.getBool(PreferencesKey.walletListAscending) ?? true;
|
2022-12-06 23:38:36 +00:00
|
|
|
final currentFiatApiMode = FiatApiMode.deserialize(
|
2023-05-17 14:43:23 +00:00
|
|
|
raw: sharedPreferences.getInt(PreferencesKey.currentFiatApiModeKey) ??
|
|
|
|
FiatApiMode.enabled.raw);
|
|
|
|
final tokenTrialNumber = sharedPreferences.getInt(PreferencesKey.failedTotpTokenTrials) ?? 0;
|
2023-04-16 13:45:35 +00:00
|
|
|
final shouldShowMarketPlaceInDashboard =
|
|
|
|
sharedPreferences.getBool(PreferencesKey.shouldShowMarketPlaceInDashboard) ?? true;
|
2023-03-01 21:44:15 +00:00
|
|
|
final exchangeStatus = ExchangeApiMode.deserialize(
|
2023-05-17 14:43:23 +00:00
|
|
|
raw: sharedPreferences.getInt(PreferencesKey.exchangeStatusKey) ??
|
|
|
|
ExchangeApiMode.enabled.raw);
|
2024-03-04 17:32:10 +00:00
|
|
|
final bool isNewInstall = sharedPreferences.getBool(PreferencesKey.isNewInstall) ?? true;
|
|
|
|
final int defaultTheme;
|
|
|
|
if (isNewInstall) {
|
|
|
|
defaultTheme = isMoneroOnly ? ThemeList.moneroDarkTheme.raw : ThemeList.brightTheme.raw;
|
|
|
|
} else {
|
|
|
|
defaultTheme = ThemeType.bright.index;
|
|
|
|
}
|
2023-05-17 14:43:23 +00:00
|
|
|
final savedTheme = initialTheme ??
|
|
|
|
ThemeList.deserialize(
|
2024-03-04 17:32:10 +00:00
|
|
|
raw: sharedPreferences.getInt(PreferencesKey.currentTheme) ?? defaultTheme);
|
2020-07-06 20:09:03 +00:00
|
|
|
final actionListDisplayMode = ObservableList<ActionListDisplayMode>();
|
|
|
|
actionListDisplayMode.addAll(deserializeActionlistDisplayModes(
|
2023-05-17 14:43:23 +00:00
|
|
|
sharedPreferences.getInt(PreferencesKey.displayActionListModeKey) ?? defaultActionsMode));
|
2020-11-09 23:14:47 +00:00
|
|
|
var pinLength = sharedPreferences.getInt(PreferencesKey.currentPinLength);
|
2023-08-04 17:01:49 +00:00
|
|
|
final sortBalanceBy =
|
2023-11-17 18:35:46 +00:00
|
|
|
SortBalanceBy.values[sharedPreferences.getInt(PreferencesKey.sortBalanceBy) ?? 0];
|
2023-08-04 17:01:49 +00:00
|
|
|
final pinNativeTokenAtTop =
|
|
|
|
sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop) ?? true;
|
2024-01-23 00:30:16 +00:00
|
|
|
final seedPhraseCount = sharedPreferences.getInt(PreferencesKey.currentSeedPhraseLength);
|
|
|
|
final seedPhraseWordCount = seedPhraseCount != null
|
|
|
|
? SeedPhraseLength.deserialize(raw: seedPhraseCount)
|
|
|
|
: defaultSeedPhraseLength;
|
2023-10-03 14:56:10 +00:00
|
|
|
final useEtherscan = sharedPreferences.getBool(PreferencesKey.useEtherscan) ?? true;
|
2023-12-02 02:26:43 +00:00
|
|
|
final usePolygonScan = sharedPreferences.getBool(PreferencesKey.usePolygonScan) ?? true;
|
2023-11-17 18:35:46 +00:00
|
|
|
final defaultNanoRep = sharedPreferences.getString(PreferencesKey.defaultNanoRep) ?? "";
|
|
|
|
final defaultBananoRep = sharedPreferences.getString(PreferencesKey.defaultBananoRep) ?? "";
|
2023-11-03 19:23:11 +00:00
|
|
|
final lookupsTwitter = sharedPreferences.getBool(PreferencesKey.lookupsTwitter) ?? true;
|
|
|
|
final lookupsMastodon = sharedPreferences.getBool(PreferencesKey.lookupsMastodon) ?? true;
|
|
|
|
final lookupsYatService = sharedPreferences.getBool(PreferencesKey.lookupsYatService) ?? true;
|
2023-12-02 02:26:43 +00:00
|
|
|
final lookupsUnstoppableDomains =
|
|
|
|
sharedPreferences.getBool(PreferencesKey.lookupsUnstoppableDomains) ?? true;
|
2023-11-03 19:23:11 +00:00
|
|
|
final lookupsOpenAlias = sharedPreferences.getBool(PreferencesKey.lookupsOpenAlias) ?? true;
|
|
|
|
final lookupsENS = sharedPreferences.getBool(PreferencesKey.lookupsENS) ?? true;
|
2023-04-20 09:59:59 +00:00
|
|
|
|
2020-11-09 23:14:47 +00:00
|
|
|
// If no value
|
|
|
|
if (pinLength == null || pinLength == 0) {
|
|
|
|
pinLength = defaultPinLength;
|
|
|
|
}
|
|
|
|
|
2023-05-17 14:43:23 +00:00
|
|
|
final savedLanguageCode = sharedPreferences.getString(PreferencesKey.currentLanguageCode) ??
|
|
|
|
await LanguageService.localeDetection();
|
2020-09-21 11:50:26 +00:00
|
|
|
final nodeId = sharedPreferences.getInt(PreferencesKey.currentNodeIdKey);
|
2023-05-17 14:43:23 +00:00
|
|
|
final bitcoinElectrumServerId =
|
2023-11-17 18:35:46 +00:00
|
|
|
sharedPreferences.getInt(PreferencesKey.currentBitcoinElectrumSererIdKey);
|
2023-05-17 14:43:23 +00:00
|
|
|
final litecoinElectrumServerId =
|
2023-11-17 18:35:46 +00:00
|
|
|
sharedPreferences.getInt(PreferencesKey.currentLitecoinElectrumSererIdKey);
|
2023-10-12 22:50:16 +00:00
|
|
|
final bitcoinCashElectrumServerId =
|
2023-11-17 18:35:46 +00:00
|
|
|
sharedPreferences.getInt(PreferencesKey.currentBitcoinCashNodeIdKey);
|
2023-05-17 14:43:23 +00:00
|
|
|
final havenNodeId = sharedPreferences.getInt(PreferencesKey.currentHavenNodeIdKey);
|
2023-08-04 17:01:49 +00:00
|
|
|
final ethereumNodeId = sharedPreferences.getInt(PreferencesKey.currentEthereumNodeIdKey);
|
2023-12-02 02:26:43 +00:00
|
|
|
final polygonNodeId = sharedPreferences.getInt(PreferencesKey.currentPolygonNodeIdKey);
|
2023-10-05 01:09:07 +00:00
|
|
|
final nanoNodeId = sharedPreferences.getInt(PreferencesKey.currentNanoNodeIdKey);
|
|
|
|
final nanoPowNodeId = sharedPreferences.getInt(PreferencesKey.currentNanoPowNodeIdKey);
|
CW-555-Add-Solana-Wallet (#1272)
* chore: Create cw_solana package and clean up files
* feat: Add Solana Wallet - Create, Restore form seed, restore from Key, Restore from QR, Send, Receive, transaction history, spl tokens
* fix: Make transactions file specific to solana only for solana transactions
* chore: Revert inject app details script
* fix: Fix issue with node and switch current node to main beta instead of testnet
* fix: Fix merge conflicts and adjust migration version
* fix: Fetch spl token error
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
* fix: Diplay and activate spl tokens bug
* fix: Review and fixes
* fix: reverted formatting for cryptocurrency class
* fix: Review comments, split sending flow into signing and sending separately, fix issues
* fix: Revert throwing unimplenented error
* chore: Fix comment
* chore: Fix comment
* fix: Errors in flow
* Update provider_types.dart [skip ci]
* fix: Issues with solana wallet
* Update solana_wallet.dart [skip ci]
* fix: Review comments
* fix: Date time config
* fix: Revert bash script for app details
* fix: Error with balance, displaying fees, fixing sent or received identifier bug, displaying token symbol with token transaction item in transactions list
* fix: Issues with address validation when sending spl tokens and walletconnect initial setup
* fix: Issues with sending, fetching transactions history, almost wrapping up walletconnect
* fix: Adjust imports that would affect monerocom building successfully
* fix: Refine transaction direction and continue work on walletconnect
* feat: Display SPL token transfers in the transaction history and finally settle the transaction direction
* fix: Delay in transactions history dispaly, show native token transactions first, then process spl token transactions
* feat: Switch node and revert solana chain id to previous id
* fix: Remove print statement
* fix: Remove await for transactions, fetch all transaction histories instantly and adjust solana send success message
* chore: Code refactoring and streamlined wallet type check for solana send success message
* fix: Make timeout error for node silent and add spl token images
---------
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-02-23 13:39:19 +00:00
|
|
|
final solanaNodeId = sharedPreferences.getInt(PreferencesKey.currentSolanaNodeIdKey);
|
2020-08-27 16:54:34 +00:00
|
|
|
final moneroNode = nodeSource.get(nodeId);
|
|
|
|
final bitcoinElectrumServer = nodeSource.get(bitcoinElectrumServerId);
|
2021-05-07 07:36:38 +00:00
|
|
|
final litecoinElectrumServer = nodeSource.get(litecoinElectrumServerId);
|
2022-03-30 15:57:04 +00:00
|
|
|
final havenNode = nodeSource.get(havenNodeId);
|
2023-08-04 17:01:49 +00:00
|
|
|
final ethereumNode = nodeSource.get(ethereumNodeId);
|
2023-12-02 02:26:43 +00:00
|
|
|
final polygonNode = nodeSource.get(polygonNodeId);
|
2023-10-12 22:50:16 +00:00
|
|
|
final bitcoinCashElectrumServer = nodeSource.get(bitcoinCashElectrumServerId);
|
2023-10-05 01:09:07 +00:00
|
|
|
final nanoNode = nodeSource.get(nanoNodeId);
|
|
|
|
final nanoPowNode = powNodeSource.get(nanoPowNodeId);
|
CW-555-Add-Solana-Wallet (#1272)
* chore: Create cw_solana package and clean up files
* feat: Add Solana Wallet - Create, Restore form seed, restore from Key, Restore from QR, Send, Receive, transaction history, spl tokens
* fix: Make transactions file specific to solana only for solana transactions
* chore: Revert inject app details script
* fix: Fix issue with node and switch current node to main beta instead of testnet
* fix: Fix merge conflicts and adjust migration version
* fix: Fetch spl token error
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
* fix: Diplay and activate spl tokens bug
* fix: Review and fixes
* fix: reverted formatting for cryptocurrency class
* fix: Review comments, split sending flow into signing and sending separately, fix issues
* fix: Revert throwing unimplenented error
* chore: Fix comment
* chore: Fix comment
* fix: Errors in flow
* Update provider_types.dart [skip ci]
* fix: Issues with solana wallet
* Update solana_wallet.dart [skip ci]
* fix: Review comments
* fix: Date time config
* fix: Revert bash script for app details
* fix: Error with balance, displaying fees, fixing sent or received identifier bug, displaying token symbol with token transaction item in transactions list
* fix: Issues with address validation when sending spl tokens and walletconnect initial setup
* fix: Issues with sending, fetching transactions history, almost wrapping up walletconnect
* fix: Adjust imports that would affect monerocom building successfully
* fix: Refine transaction direction and continue work on walletconnect
* feat: Display SPL token transfers in the transaction history and finally settle the transaction direction
* fix: Delay in transactions history dispaly, show native token transactions first, then process spl token transactions
* feat: Switch node and revert solana chain id to previous id
* fix: Remove print statement
* fix: Remove await for transactions, fetch all transaction histories instantly and adjust solana send success message
* chore: Code refactoring and streamlined wallet type check for solana send success message
* fix: Make timeout error for node silent and add spl token images
---------
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-02-23 13:39:19 +00:00
|
|
|
final solanaNode = nodeSource.get(solanaNodeId);
|
2020-07-06 20:09:03 +00:00
|
|
|
final packageInfo = await PackageInfo.fromPlatform();
|
2023-05-17 14:43:23 +00:00
|
|
|
final deviceName = await _getDeviceName() ?? '';
|
|
|
|
final shouldShowYatPopup = sharedPreferences.getBool(PreferencesKey.shouldShowYatPopup) ?? true;
|
2023-11-25 00:37:12 +00:00
|
|
|
|
2023-08-29 16:11:51 +00:00
|
|
|
final generateSubaddresses =
|
2023-11-17 18:35:46 +00:00
|
|
|
sharedPreferences.getInt(PreferencesKey.autoGenerateSubaddressStatusKey);
|
2020-07-06 20:09:03 +00:00
|
|
|
|
2023-08-29 16:11:51 +00:00
|
|
|
final autoGenerateSubaddressStatus = generateSubaddresses != null
|
|
|
|
? AutoGenerateSubaddressStatus.deserialize(raw: generateSubaddresses)
|
|
|
|
: defaultAutoGenerateSubaddressStatus;
|
2023-11-25 00:37:12 +00:00
|
|
|
|
|
|
|
final _moneroSeedType = sharedPreferences.getInt(PreferencesKey.moneroSeedType);
|
|
|
|
|
|
|
|
final moneroSeedType = _moneroSeedType != null
|
|
|
|
? SeedType.deserialize(raw: _moneroSeedType)
|
|
|
|
: defaultMoneroSeedType;
|
|
|
|
|
2022-10-12 17:09:57 +00:00
|
|
|
final nodes = <WalletType, Node>{};
|
2023-10-05 01:09:07 +00:00
|
|
|
final powNodes = <WalletType, Node>{};
|
2022-10-12 17:09:57 +00:00
|
|
|
|
|
|
|
if (moneroNode != null) {
|
2023-05-17 14:43:23 +00:00
|
|
|
nodes[WalletType.monero] = moneroNode;
|
2022-10-12 17:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bitcoinElectrumServer != null) {
|
2023-05-17 14:43:23 +00:00
|
|
|
nodes[WalletType.bitcoin] = bitcoinElectrumServer;
|
2022-10-12 17:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (litecoinElectrumServer != null) {
|
2023-05-17 14:43:23 +00:00
|
|
|
nodes[WalletType.litecoin] = litecoinElectrumServer;
|
2022-10-12 17:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (havenNode != null) {
|
2023-05-17 14:43:23 +00:00
|
|
|
nodes[WalletType.haven] = havenNode;
|
2022-10-12 17:09:57 +00:00
|
|
|
}
|
2022-12-08 15:23:17 +00:00
|
|
|
|
2023-08-04 17:01:49 +00:00
|
|
|
if (ethereumNode != null) {
|
|
|
|
nodes[WalletType.ethereum] = ethereumNode;
|
|
|
|
}
|
|
|
|
|
2023-12-02 02:26:43 +00:00
|
|
|
if (polygonNode != null) {
|
|
|
|
nodes[WalletType.polygon] = polygonNode;
|
|
|
|
}
|
|
|
|
|
2023-10-12 22:50:16 +00:00
|
|
|
if (bitcoinCashElectrumServer != null) {
|
|
|
|
nodes[WalletType.bitcoinCash] = bitcoinCashElectrumServer;
|
|
|
|
}
|
|
|
|
|
2023-10-05 01:09:07 +00:00
|
|
|
if (nanoNode != null) {
|
|
|
|
nodes[WalletType.nano] = nanoNode;
|
|
|
|
}
|
2023-10-12 22:50:16 +00:00
|
|
|
|
2023-10-05 01:09:07 +00:00
|
|
|
if (nanoPowNode != null) {
|
|
|
|
powNodes[WalletType.nano] = nanoPowNode;
|
|
|
|
}
|
|
|
|
|
CW-555-Add-Solana-Wallet (#1272)
* chore: Create cw_solana package and clean up files
* feat: Add Solana Wallet - Create, Restore form seed, restore from Key, Restore from QR, Send, Receive, transaction history, spl tokens
* fix: Make transactions file specific to solana only for solana transactions
* chore: Revert inject app details script
* fix: Fix issue with node and switch current node to main beta instead of testnet
* fix: Fix merge conflicts and adjust migration version
* fix: Fetch spl token error
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
* fix: Diplay and activate spl tokens bug
* fix: Review and fixes
* fix: reverted formatting for cryptocurrency class
* fix: Review comments, split sending flow into signing and sending separately, fix issues
* fix: Revert throwing unimplenented error
* chore: Fix comment
* chore: Fix comment
* fix: Errors in flow
* Update provider_types.dart [skip ci]
* fix: Issues with solana wallet
* Update solana_wallet.dart [skip ci]
* fix: Review comments
* fix: Date time config
* fix: Revert bash script for app details
* fix: Error with balance, displaying fees, fixing sent or received identifier bug, displaying token symbol with token transaction item in transactions list
* fix: Issues with address validation when sending spl tokens and walletconnect initial setup
* fix: Issues with sending, fetching transactions history, almost wrapping up walletconnect
* fix: Adjust imports that would affect monerocom building successfully
* fix: Refine transaction direction and continue work on walletconnect
* feat: Display SPL token transfers in the transaction history and finally settle the transaction direction
* fix: Delay in transactions history dispaly, show native token transactions first, then process spl token transactions
* feat: Switch node and revert solana chain id to previous id
* fix: Remove print statement
* fix: Remove await for transactions, fetch all transaction histories instantly and adjust solana send success message
* chore: Code refactoring and streamlined wallet type check for solana send success message
* fix: Make timeout error for node silent and add spl token images
---------
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-02-23 13:39:19 +00:00
|
|
|
if (solanaNode != null) {
|
|
|
|
nodes[WalletType.solana] = solanaNode;
|
|
|
|
}
|
|
|
|
|
2023-11-17 18:35:46 +00:00
|
|
|
final savedSyncMode = SyncMode.all.firstWhere((element) {
|
2023-12-09 01:37:39 +00:00
|
|
|
return element.type.index == (sharedPreferences.getInt(PreferencesKey.syncModeKey) ?? 0);
|
2023-11-17 18:35:46 +00:00
|
|
|
});
|
|
|
|
final savedSyncAll = sharedPreferences.getBool(PreferencesKey.syncAllKey) ?? true;
|
2023-10-12 22:50:16 +00:00
|
|
|
|
2024-01-23 00:30:16 +00:00
|
|
|
// migrated to secure:
|
|
|
|
final timeOutDuration = await SecureKey.getInt(
|
|
|
|
secureStorage: secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.pinTimeOutDuration,
|
|
|
|
);
|
|
|
|
|
|
|
|
final pinCodeTimeOutDuration = timeOutDuration != null
|
|
|
|
? PinCodeRequiredDuration.deserialize(raw: timeOutDuration)
|
|
|
|
: defaultPinCodeTimeOutDuration;
|
|
|
|
|
|
|
|
final allowBiometricalAuthentication = await SecureKey.getBool(
|
|
|
|
secureStorage: secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
2024-01-30 17:57:47 +00:00
|
|
|
key: SecureKey.allowBiometricalAuthenticationKey,
|
2024-01-23 00:30:16 +00:00
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
|
|
|
|
final selectedCake2FAPreset = Cake2FAPresetsOptions.deserialize(
|
|
|
|
raw: await SecureKey.getInt(
|
|
|
|
secureStorage: secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.selectedCake2FAPreset,
|
|
|
|
) ??
|
|
|
|
Cake2FAPresetsOptions.normal.raw);
|
|
|
|
|
|
|
|
final shouldRequireTOTP2FAForAccessingWallet = await SecureKey.getBool(
|
|
|
|
secureStorage: secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForAccessingWallet,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
final shouldRequireTOTP2FAForSendsToContact = await SecureKey.getBool(
|
|
|
|
secureStorage: secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForSendsToContact,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
final shouldRequireTOTP2FAForSendsToNonContact = await SecureKey.getBool(
|
|
|
|
secureStorage: secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForSendsToNonContact,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
final shouldRequireTOTP2FAForSendsToInternalWallets = await SecureKey.getBool(
|
|
|
|
secureStorage: secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForSendsToInternalWallets,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
final shouldRequireTOTP2FAForExchangesToInternalWallets = await SecureKey.getBool(
|
|
|
|
secureStorage: secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForExchangesToInternalWallets,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
final shouldRequireTOTP2FAForExchangesToExternalWallets = await SecureKey.getBool(
|
|
|
|
secureStorage: secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForExchangesToExternalWallets,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
final shouldRequireTOTP2FAForAddingContacts = await SecureKey.getBool(
|
|
|
|
secureStorage: secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForAddingContacts,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
final shouldRequireTOTP2FAForCreatingNewWallets = await SecureKey.getBool(
|
|
|
|
secureStorage: secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForCreatingNewWallets,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
final shouldRequireTOTP2FAForAllSecurityAndBackupSettings = await SecureKey.getBool(
|
|
|
|
secureStorage: secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
final useTOTP2FA = await SecureKey.getBool(
|
|
|
|
secureStorage: secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.useTOTP2FA,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
final totpSecretKey = await SecureKey.getString(
|
|
|
|
secureStorage: secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
2024-01-27 03:08:53 +00:00
|
|
|
key: SecureKey.totpSecretKey,
|
2024-01-23 00:30:16 +00:00
|
|
|
) ??
|
|
|
|
'';
|
|
|
|
|
2023-12-02 02:26:43 +00:00
|
|
|
return SettingsStore(
|
2024-01-23 00:30:16 +00:00
|
|
|
secureStorage: secureStorage,
|
2023-12-02 02:26:43 +00:00
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
initialShouldShowMarketPlaceInDashboard: shouldShowMarketPlaceInDashboard,
|
|
|
|
nodes: nodes,
|
|
|
|
powNodes: powNodes,
|
|
|
|
appVersion: packageInfo.version,
|
|
|
|
deviceName: deviceName,
|
|
|
|
isBitcoinBuyEnabled: isBitcoinBuyEnabled,
|
|
|
|
initialFiatCurrency: currentFiatCurrency,
|
|
|
|
initialBalanceDisplayMode: currentBalanceDisplayMode,
|
|
|
|
initialSaveRecipientAddress: shouldSaveRecipientAddress,
|
|
|
|
initialAutoGenerateSubaddressStatus: autoGenerateSubaddressStatus,
|
|
|
|
initialMoneroSeedType: moneroSeedType,
|
2023-11-25 00:37:12 +00:00
|
|
|
initialAppSecure: isAppSecure,
|
|
|
|
initialDisableBuy: disableBuy,
|
|
|
|
initialDisableSell: disableSell,
|
2024-03-25 18:28:45 +00:00
|
|
|
initialDisableBulletin: disableBulletin,
|
2023-12-13 21:58:43 +00:00
|
|
|
initialWalletListOrder: walletListOrder,
|
|
|
|
initialWalletListAscending: walletListAscending,
|
2023-11-25 00:37:12 +00:00
|
|
|
initialFiatMode: currentFiatApiMode,
|
|
|
|
initialAllowBiometricalAuthentication: allowBiometricalAuthentication,
|
|
|
|
initialCake2FAPresetOptions: selectedCake2FAPreset,
|
|
|
|
initialUseTOTP2FA: useTOTP2FA,
|
|
|
|
initialTotpSecretKey: totpSecretKey,
|
|
|
|
initialFailedTokenTrial: tokenTrialNumber,
|
|
|
|
initialExchangeStatus: exchangeStatus,
|
|
|
|
initialTheme: savedTheme,
|
|
|
|
actionlistDisplayMode: actionListDisplayMode,
|
|
|
|
initialPinLength: pinLength,
|
|
|
|
pinTimeOutDuration: pinCodeTimeOutDuration,
|
2023-12-02 02:26:43 +00:00
|
|
|
seedPhraseLength: seedPhraseWordCount,
|
|
|
|
initialLanguageCode: savedLanguageCode,
|
2023-11-25 00:37:12 +00:00
|
|
|
sortBalanceBy: sortBalanceBy,
|
|
|
|
pinNativeTokenAtTop: pinNativeTokenAtTop,
|
|
|
|
useEtherscan: useEtherscan,
|
2023-12-02 02:26:43 +00:00
|
|
|
usePolygonScan: usePolygonScan,
|
2023-11-25 00:37:12 +00:00
|
|
|
defaultNanoRep: defaultNanoRep,
|
2023-12-02 02:26:43 +00:00
|
|
|
defaultBananoRep: defaultBananoRep,
|
|
|
|
lookupsTwitter: lookupsTwitter,
|
|
|
|
lookupsMastodon: lookupsMastodon,
|
|
|
|
lookupsYatService: lookupsYatService,
|
|
|
|
lookupsUnstoppableDomains: lookupsUnstoppableDomains,
|
|
|
|
lookupsOpenAlias: lookupsOpenAlias,
|
|
|
|
lookupsENS: lookupsENS,
|
|
|
|
initialMoneroTransactionPriority: moneroTransactionPriority,
|
2023-11-25 00:37:12 +00:00
|
|
|
initialBitcoinTransactionPriority: bitcoinTransactionPriority,
|
|
|
|
initialHavenTransactionPriority: havenTransactionPriority,
|
|
|
|
initialLitecoinTransactionPriority: litecoinTransactionPriority,
|
|
|
|
initialBitcoinCashTransactionPriority: bitcoinCashTransactionPriority,
|
2023-12-02 02:26:43 +00:00
|
|
|
initialShouldRequireTOTP2FAForAccessingWallet: shouldRequireTOTP2FAForAccessingWallet,
|
|
|
|
initialShouldRequireTOTP2FAForSendsToContact: shouldRequireTOTP2FAForSendsToContact,
|
|
|
|
initialShouldRequireTOTP2FAForSendsToNonContact: shouldRequireTOTP2FAForSendsToNonContact,
|
|
|
|
initialShouldRequireTOTP2FAForSendsToInternalWallets:
|
|
|
|
shouldRequireTOTP2FAForSendsToInternalWallets,
|
|
|
|
initialShouldRequireTOTP2FAForExchangesToInternalWallets:
|
|
|
|
shouldRequireTOTP2FAForExchangesToInternalWallets,
|
2023-11-02 18:17:52 +00:00
|
|
|
initialShouldRequireTOTP2FAForExchangesToExternalWallets:
|
|
|
|
shouldRequireTOTP2FAForExchangesToExternalWallets,
|
2023-12-02 02:26:43 +00:00
|
|
|
initialShouldRequireTOTP2FAForAddingContacts: shouldRequireTOTP2FAForAddingContacts,
|
|
|
|
initialShouldRequireTOTP2FAForCreatingNewWallets: shouldRequireTOTP2FAForCreatingNewWallets,
|
|
|
|
initialShouldRequireTOTP2FAForAllSecurityAndBackupSettings:
|
|
|
|
shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
|
|
|
|
initialEthereumTransactionPriority: ethereumTransactionPriority,
|
|
|
|
initialPolygonTransactionPriority: polygonTransactionPriority,
|
|
|
|
backgroundTasks: backgroundTasks,
|
|
|
|
initialSyncMode: savedSyncMode,
|
|
|
|
initialSyncAll: savedSyncAll,
|
|
|
|
shouldShowYatPopup: shouldShowYatPopup);
|
|
|
|
}
|
2020-09-21 11:50:26 +00:00
|
|
|
|
2022-12-09 13:57:45 +00:00
|
|
|
Future<void> reload({required Box<Node> nodeSource}) async {
|
|
|
|
final sharedPreferences = await getIt.getAsync<SharedPreferences>();
|
|
|
|
|
|
|
|
fiatCurrency = FiatCurrency.deserialize(
|
|
|
|
raw: sharedPreferences.getString(PreferencesKey.currentFiatCurrencyKey)!);
|
|
|
|
|
|
|
|
priority[WalletType.monero] = monero?.deserializeMoneroTransactionPriority(
|
2023-11-17 18:35:46 +00:00
|
|
|
raw: sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority)!) ??
|
2022-12-09 13:57:45 +00:00
|
|
|
priority[WalletType.monero]!;
|
2022-12-09 18:36:51 +00:00
|
|
|
|
2024-01-26 22:51:21 +00:00
|
|
|
if (bitcoin != null &&
|
|
|
|
sharedPreferences.getInt(PreferencesKey.bitcoinTransactionPriority) != null) {
|
|
|
|
priority[WalletType.bitcoin] = bitcoin!.deserializeBitcoinTransactionPriority(
|
|
|
|
sharedPreferences.getInt(PreferencesKey.bitcoinTransactionPriority)!);
|
2022-12-09 18:36:51 +00:00
|
|
|
}
|
2024-01-26 22:51:21 +00:00
|
|
|
|
|
|
|
if (monero != null &&
|
|
|
|
sharedPreferences.getInt(PreferencesKey.havenTransactionPriority) != null) {
|
|
|
|
priority[WalletType.haven] = monero!.deserializeMoneroTransactionPriority(
|
|
|
|
raw: sharedPreferences.getInt(PreferencesKey.havenTransactionPriority)!);
|
2022-12-09 18:36:51 +00:00
|
|
|
}
|
2024-01-26 22:51:21 +00:00
|
|
|
if (bitcoin != null &&
|
|
|
|
sharedPreferences.getInt(PreferencesKey.litecoinTransactionPriority) != null) {
|
|
|
|
priority[WalletType.litecoin] = bitcoin!.deserializeLitecoinTransactionPriority(
|
|
|
|
sharedPreferences.getInt(PreferencesKey.litecoinTransactionPriority)!);
|
2023-08-04 17:01:49 +00:00
|
|
|
}
|
2024-01-26 22:51:21 +00:00
|
|
|
if (ethereum != null &&
|
|
|
|
sharedPreferences.getInt(PreferencesKey.ethereumTransactionPriority) != null) {
|
|
|
|
priority[WalletType.ethereum] = ethereum!.deserializeEthereumTransactionPriority(
|
|
|
|
sharedPreferences.getInt(PreferencesKey.ethereumTransactionPriority)!);
|
2023-12-02 02:26:43 +00:00
|
|
|
}
|
2024-01-26 22:51:21 +00:00
|
|
|
if (polygon != null &&
|
|
|
|
sharedPreferences.getInt(PreferencesKey.polygonTransactionPriority) != null) {
|
|
|
|
priority[WalletType.polygon] = polygon!.deserializePolygonTransactionPriority(
|
|
|
|
sharedPreferences.getInt(PreferencesKey.polygonTransactionPriority)!);
|
|
|
|
}
|
|
|
|
if (bitcoinCash != null &&
|
|
|
|
sharedPreferences.getInt(PreferencesKey.bitcoinCashTransactionPriority) != null) {
|
|
|
|
priority[WalletType.bitcoinCash] = bitcoinCash!.deserializeBitcoinCashTransactionPriority(
|
|
|
|
sharedPreferences.getInt(PreferencesKey.bitcoinCashTransactionPriority)!);
|
2023-10-12 22:50:16 +00:00
|
|
|
}
|
2022-12-09 13:57:45 +00:00
|
|
|
|
2023-08-29 16:11:51 +00:00
|
|
|
final generateSubaddresses =
|
2023-11-17 18:35:46 +00:00
|
|
|
sharedPreferences.getInt(PreferencesKey.autoGenerateSubaddressStatusKey);
|
2023-08-29 16:11:51 +00:00
|
|
|
|
|
|
|
autoGenerateSubaddressStatus = generateSubaddresses != null
|
|
|
|
? AutoGenerateSubaddressStatus.deserialize(raw: generateSubaddresses)
|
|
|
|
: defaultAutoGenerateSubaddressStatus;
|
|
|
|
|
2023-11-25 00:37:12 +00:00
|
|
|
final _moneroSeedType = sharedPreferences.getInt(PreferencesKey.moneroSeedType);
|
|
|
|
|
|
|
|
moneroSeedType = _moneroSeedType != null
|
|
|
|
? SeedType.deserialize(raw: _moneroSeedType)
|
|
|
|
: defaultMoneroSeedType;
|
|
|
|
|
2022-12-09 13:57:45 +00:00
|
|
|
balanceDisplayMode = BalanceDisplayMode.deserialize(
|
2023-05-17 14:43:23 +00:00
|
|
|
raw: sharedPreferences.getInt(PreferencesKey.currentBalanceDisplayModeKey)!);
|
2022-12-09 13:57:45 +00:00
|
|
|
shouldSaveRecipientAddress =
|
2023-05-17 14:43:23 +00:00
|
|
|
sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey) ??
|
|
|
|
shouldSaveRecipientAddress;
|
|
|
|
numberOfFailedTokenTrials =
|
|
|
|
sharedPreferences.getInt(PreferencesKey.failedTotpTokenTrials) ?? numberOfFailedTokenTrials;
|
2023-07-11 16:07:46 +00:00
|
|
|
isAppSecure = sharedPreferences.getBool(PreferencesKey.isAppSecureKey) ?? isAppSecure;
|
|
|
|
disableBuy = sharedPreferences.getBool(PreferencesKey.disableBuyKey) ?? disableBuy;
|
|
|
|
disableSell = sharedPreferences.getBool(PreferencesKey.disableSellKey) ?? disableSell;
|
2024-03-25 18:28:45 +00:00
|
|
|
disableBulletin = sharedPreferences.getBool(PreferencesKey.disableBulletinKey) ?? disableBulletin;
|
2023-12-13 21:58:43 +00:00
|
|
|
walletListOrder =
|
|
|
|
WalletListOrderType.values[sharedPreferences.getInt(PreferencesKey.walletListOrder) ?? 0];
|
|
|
|
walletListAscending = sharedPreferences.getBool(PreferencesKey.walletListAscending) ?? true;
|
2024-01-23 00:30:16 +00:00
|
|
|
|
2023-04-16 13:45:35 +00:00
|
|
|
shouldShowMarketPlaceInDashboard =
|
|
|
|
sharedPreferences.getBool(PreferencesKey.shouldShowMarketPlaceInDashboard) ??
|
|
|
|
shouldShowMarketPlaceInDashboard;
|
2023-03-01 21:44:15 +00:00
|
|
|
exchangeStatus = ExchangeApiMode.deserialize(
|
2023-05-17 14:43:23 +00:00
|
|
|
raw: sharedPreferences.getInt(PreferencesKey.exchangeStatusKey) ??
|
|
|
|
ExchangeApiMode.enabled.raw);
|
2022-12-09 13:57:45 +00:00
|
|
|
currentTheme = ThemeList.deserialize(
|
2024-03-04 17:32:10 +00:00
|
|
|
raw: sharedPreferences.getInt(PreferencesKey.currentTheme) ??
|
|
|
|
(isMoneroOnly ? ThemeList.moneroDarkTheme.raw : ThemeList.brightTheme.raw));
|
2022-12-09 13:57:45 +00:00
|
|
|
actionlistDisplayMode = ObservableList<ActionListDisplayMode>();
|
|
|
|
actionlistDisplayMode.addAll(deserializeActionlistDisplayModes(
|
2023-05-17 14:43:23 +00:00
|
|
|
sharedPreferences.getInt(PreferencesKey.displayActionListModeKey) ?? defaultActionsMode));
|
2022-12-09 13:57:45 +00:00
|
|
|
var pinLength = sharedPreferences.getInt(PreferencesKey.currentPinLength);
|
|
|
|
// If no value
|
|
|
|
if (pinLength == null || pinLength == 0) {
|
|
|
|
pinLength = pinCodeLength;
|
2022-12-07 14:41:04 +00:00
|
|
|
}
|
2022-12-09 13:57:45 +00:00
|
|
|
pinCodeLength = pinLength;
|
2022-12-07 14:41:04 +00:00
|
|
|
|
2022-12-09 13:57:45 +00:00
|
|
|
languageCode = sharedPreferences.getString(PreferencesKey.currentLanguageCode) ?? languageCode;
|
2023-05-17 14:43:23 +00:00
|
|
|
shouldShowYatPopup =
|
|
|
|
sharedPreferences.getBool(PreferencesKey.shouldShowYatPopup) ?? shouldShowYatPopup;
|
2023-08-04 17:01:49 +00:00
|
|
|
sortBalanceBy = SortBalanceBy
|
|
|
|
.values[sharedPreferences.getInt(PreferencesKey.sortBalanceBy) ?? sortBalanceBy.index];
|
|
|
|
pinNativeTokenAtTop = sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop) ?? true;
|
|
|
|
useEtherscan = sharedPreferences.getBool(PreferencesKey.useEtherscan) ?? true;
|
2023-12-02 02:26:43 +00:00
|
|
|
usePolygonScan = sharedPreferences.getBool(PreferencesKey.usePolygonScan) ?? true;
|
2023-11-17 18:35:46 +00:00
|
|
|
defaultNanoRep = sharedPreferences.getString(PreferencesKey.defaultNanoRep) ?? "";
|
|
|
|
defaultBananoRep = sharedPreferences.getString(PreferencesKey.defaultBananoRep) ?? "";
|
2023-11-03 19:23:11 +00:00
|
|
|
lookupsTwitter = sharedPreferences.getBool(PreferencesKey.lookupsTwitter) ?? true;
|
|
|
|
lookupsMastodon = sharedPreferences.getBool(PreferencesKey.lookupsMastodon) ?? true;
|
|
|
|
lookupsYatService = sharedPreferences.getBool(PreferencesKey.lookupsYatService) ?? true;
|
2023-12-02 02:26:43 +00:00
|
|
|
lookupsUnstoppableDomains =
|
|
|
|
sharedPreferences.getBool(PreferencesKey.lookupsUnstoppableDomains) ?? true;
|
2023-11-03 19:23:11 +00:00
|
|
|
lookupsOpenAlias = sharedPreferences.getBool(PreferencesKey.lookupsOpenAlias) ?? true;
|
|
|
|
lookupsENS = sharedPreferences.getBool(PreferencesKey.lookupsENS) ?? true;
|
2022-12-09 13:57:45 +00:00
|
|
|
|
|
|
|
final nodeId = sharedPreferences.getInt(PreferencesKey.currentNodeIdKey);
|
2023-05-17 14:43:23 +00:00
|
|
|
final bitcoinElectrumServerId =
|
2023-11-17 18:35:46 +00:00
|
|
|
sharedPreferences.getInt(PreferencesKey.currentBitcoinElectrumSererIdKey);
|
2023-05-17 14:43:23 +00:00
|
|
|
final litecoinElectrumServerId =
|
2023-11-17 18:35:46 +00:00
|
|
|
sharedPreferences.getInt(PreferencesKey.currentLitecoinElectrumSererIdKey);
|
2023-10-12 22:50:16 +00:00
|
|
|
final bitcoinCashElectrumServerId =
|
2023-11-17 18:35:46 +00:00
|
|
|
sharedPreferences.getInt(PreferencesKey.currentBitcoinCashNodeIdKey);
|
2023-05-17 14:43:23 +00:00
|
|
|
final havenNodeId = sharedPreferences.getInt(PreferencesKey.currentHavenNodeIdKey);
|
2023-08-04 17:01:49 +00:00
|
|
|
final ethereumNodeId = sharedPreferences.getInt(PreferencesKey.currentEthereumNodeIdKey);
|
2023-12-02 02:26:43 +00:00
|
|
|
final polygonNodeId = sharedPreferences.getInt(PreferencesKey.currentPolygonNodeIdKey);
|
2023-10-05 01:09:07 +00:00
|
|
|
final nanoNodeId = sharedPreferences.getInt(PreferencesKey.currentNanoNodeIdKey);
|
CW-555-Add-Solana-Wallet (#1272)
* chore: Create cw_solana package and clean up files
* feat: Add Solana Wallet - Create, Restore form seed, restore from Key, Restore from QR, Send, Receive, transaction history, spl tokens
* fix: Make transactions file specific to solana only for solana transactions
* chore: Revert inject app details script
* fix: Fix issue with node and switch current node to main beta instead of testnet
* fix: Fix merge conflicts and adjust migration version
* fix: Fetch spl token error
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
* fix: Diplay and activate spl tokens bug
* fix: Review and fixes
* fix: reverted formatting for cryptocurrency class
* fix: Review comments, split sending flow into signing and sending separately, fix issues
* fix: Revert throwing unimplenented error
* chore: Fix comment
* chore: Fix comment
* fix: Errors in flow
* Update provider_types.dart [skip ci]
* fix: Issues with solana wallet
* Update solana_wallet.dart [skip ci]
* fix: Review comments
* fix: Date time config
* fix: Revert bash script for app details
* fix: Error with balance, displaying fees, fixing sent or received identifier bug, displaying token symbol with token transaction item in transactions list
* fix: Issues with address validation when sending spl tokens and walletconnect initial setup
* fix: Issues with sending, fetching transactions history, almost wrapping up walletconnect
* fix: Adjust imports that would affect monerocom building successfully
* fix: Refine transaction direction and continue work on walletconnect
* feat: Display SPL token transfers in the transaction history and finally settle the transaction direction
* fix: Delay in transactions history dispaly, show native token transactions first, then process spl token transactions
* feat: Switch node and revert solana chain id to previous id
* fix: Remove print statement
* fix: Remove await for transactions, fetch all transaction histories instantly and adjust solana send success message
* chore: Code refactoring and streamlined wallet type check for solana send success message
* fix: Make timeout error for node silent and add spl token images
---------
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-02-23 13:39:19 +00:00
|
|
|
final solanaNodeId = sharedPreferences.getInt(PreferencesKey.currentSolanaNodeIdKey);
|
2022-12-09 13:57:45 +00:00
|
|
|
final moneroNode = nodeSource.get(nodeId);
|
|
|
|
final bitcoinElectrumServer = nodeSource.get(bitcoinElectrumServerId);
|
|
|
|
final litecoinElectrumServer = nodeSource.get(litecoinElectrumServerId);
|
|
|
|
final havenNode = nodeSource.get(havenNodeId);
|
2023-08-04 17:01:49 +00:00
|
|
|
final ethereumNode = nodeSource.get(ethereumNodeId);
|
2023-12-02 02:26:43 +00:00
|
|
|
final polygonNode = nodeSource.get(polygonNodeId);
|
2023-10-12 22:50:16 +00:00
|
|
|
final bitcoinCashNode = nodeSource.get(bitcoinCashElectrumServerId);
|
2023-10-05 01:09:07 +00:00
|
|
|
final nanoNode = nodeSource.get(nanoNodeId);
|
CW-555-Add-Solana-Wallet (#1272)
* chore: Create cw_solana package and clean up files
* feat: Add Solana Wallet - Create, Restore form seed, restore from Key, Restore from QR, Send, Receive, transaction history, spl tokens
* fix: Make transactions file specific to solana only for solana transactions
* chore: Revert inject app details script
* fix: Fix issue with node and switch current node to main beta instead of testnet
* fix: Fix merge conflicts and adjust migration version
* fix: Fetch spl token error
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
* fix: Diplay and activate spl tokens bug
* fix: Review and fixes
* fix: reverted formatting for cryptocurrency class
* fix: Review comments, split sending flow into signing and sending separately, fix issues
* fix: Revert throwing unimplenented error
* chore: Fix comment
* chore: Fix comment
* fix: Errors in flow
* Update provider_types.dart [skip ci]
* fix: Issues with solana wallet
* Update solana_wallet.dart [skip ci]
* fix: Review comments
* fix: Date time config
* fix: Revert bash script for app details
* fix: Error with balance, displaying fees, fixing sent or received identifier bug, displaying token symbol with token transaction item in transactions list
* fix: Issues with address validation when sending spl tokens and walletconnect initial setup
* fix: Issues with sending, fetching transactions history, almost wrapping up walletconnect
* fix: Adjust imports that would affect monerocom building successfully
* fix: Refine transaction direction and continue work on walletconnect
* feat: Display SPL token transfers in the transaction history and finally settle the transaction direction
* fix: Delay in transactions history dispaly, show native token transactions first, then process spl token transactions
* feat: Switch node and revert solana chain id to previous id
* fix: Remove print statement
* fix: Remove await for transactions, fetch all transaction histories instantly and adjust solana send success message
* chore: Code refactoring and streamlined wallet type check for solana send success message
* fix: Make timeout error for node silent and add spl token images
---------
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-02-23 13:39:19 +00:00
|
|
|
final solanaNode = nodeSource.get(solanaNodeId);
|
2022-12-09 13:57:45 +00:00
|
|
|
if (moneroNode != null) {
|
|
|
|
nodes[WalletType.monero] = moneroNode;
|
2022-12-07 14:41:04 +00:00
|
|
|
}
|
|
|
|
|
2022-12-09 13:57:45 +00:00
|
|
|
if (bitcoinElectrumServer != null) {
|
|
|
|
nodes[WalletType.bitcoin] = bitcoinElectrumServer;
|
|
|
|
}
|
2022-12-07 14:41:04 +00:00
|
|
|
|
2022-12-09 13:57:45 +00:00
|
|
|
if (litecoinElectrumServer != null) {
|
|
|
|
nodes[WalletType.litecoin] = litecoinElectrumServer;
|
|
|
|
}
|
2022-12-07 14:41:04 +00:00
|
|
|
|
2022-12-09 13:57:45 +00:00
|
|
|
if (havenNode != null) {
|
|
|
|
nodes[WalletType.haven] = havenNode;
|
|
|
|
}
|
2023-08-04 17:01:49 +00:00
|
|
|
|
|
|
|
if (ethereumNode != null) {
|
|
|
|
nodes[WalletType.ethereum] = ethereumNode;
|
|
|
|
}
|
2023-10-05 01:09:07 +00:00
|
|
|
|
2023-12-02 02:26:43 +00:00
|
|
|
if (polygonNode != null) {
|
|
|
|
nodes[WalletType.polygon] = polygonNode;
|
|
|
|
}
|
|
|
|
|
2023-10-12 22:50:16 +00:00
|
|
|
if (bitcoinCashNode != null) {
|
|
|
|
nodes[WalletType.bitcoinCash] = bitcoinCashNode;
|
|
|
|
}
|
|
|
|
|
2023-10-05 01:09:07 +00:00
|
|
|
if (nanoNode != null) {
|
|
|
|
nodes[WalletType.nano] = nanoNode;
|
|
|
|
}
|
2024-01-23 00:30:16 +00:00
|
|
|
|
CW-555-Add-Solana-Wallet (#1272)
* chore: Create cw_solana package and clean up files
* feat: Add Solana Wallet - Create, Restore form seed, restore from Key, Restore from QR, Send, Receive, transaction history, spl tokens
* fix: Make transactions file specific to solana only for solana transactions
* chore: Revert inject app details script
* fix: Fix issue with node and switch current node to main beta instead of testnet
* fix: Fix merge conflicts and adjust migration version
* fix: Fetch spl token error
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
* fix: Diplay and activate spl tokens bug
* fix: Review and fixes
* fix: reverted formatting for cryptocurrency class
* fix: Review comments, split sending flow into signing and sending separately, fix issues
* fix: Revert throwing unimplenented error
* chore: Fix comment
* chore: Fix comment
* fix: Errors in flow
* Update provider_types.dart [skip ci]
* fix: Issues with solana wallet
* Update solana_wallet.dart [skip ci]
* fix: Review comments
* fix: Date time config
* fix: Revert bash script for app details
* fix: Error with balance, displaying fees, fixing sent or received identifier bug, displaying token symbol with token transaction item in transactions list
* fix: Issues with address validation when sending spl tokens and walletconnect initial setup
* fix: Issues with sending, fetching transactions history, almost wrapping up walletconnect
* fix: Adjust imports that would affect monerocom building successfully
* fix: Refine transaction direction and continue work on walletconnect
* feat: Display SPL token transfers in the transaction history and finally settle the transaction direction
* fix: Delay in transactions history dispaly, show native token transactions first, then process spl token transactions
* feat: Switch node and revert solana chain id to previous id
* fix: Remove print statement
* fix: Remove await for transactions, fetch all transaction histories instantly and adjust solana send success message
* chore: Code refactoring and streamlined wallet type check for solana send success message
* fix: Make timeout error for node silent and add spl token images
---------
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-02-23 13:39:19 +00:00
|
|
|
if (solanaNode != null) {
|
|
|
|
nodes[WalletType.solana] = solanaNode;
|
|
|
|
}
|
|
|
|
|
2024-01-23 00:30:16 +00:00
|
|
|
// MIGRATED:
|
|
|
|
|
|
|
|
useTOTP2FA = await SecureKey.getBool(
|
|
|
|
secureStorage: _secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.useTOTP2FA,
|
|
|
|
) ??
|
|
|
|
useTOTP2FA;
|
|
|
|
|
|
|
|
totpSecretKey = await SecureKey.getString(
|
|
|
|
secureStorage: _secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
2024-01-27 03:08:53 +00:00
|
|
|
key: SecureKey.totpSecretKey,
|
2024-01-23 00:30:16 +00:00
|
|
|
) ??
|
|
|
|
totpSecretKey;
|
|
|
|
|
2024-01-30 17:57:47 +00:00
|
|
|
final timeOutDuration = await SecureKey.getInt(
|
|
|
|
secureStorage: _secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.pinTimeOutDuration,
|
|
|
|
);
|
|
|
|
|
|
|
|
pinTimeOutDuration = timeOutDuration != null
|
|
|
|
? PinCodeRequiredDuration.deserialize(raw: timeOutDuration)
|
|
|
|
: defaultPinCodeTimeOutDuration;
|
|
|
|
|
2024-01-23 00:30:16 +00:00
|
|
|
allowBiometricalAuthentication = await SecureKey.getBool(
|
|
|
|
secureStorage: _secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.allowBiometricalAuthenticationKey,
|
|
|
|
) ??
|
|
|
|
allowBiometricalAuthentication;
|
|
|
|
|
|
|
|
selectedCake2FAPreset = Cake2FAPresetsOptions.deserialize(
|
|
|
|
raw: await SecureKey.getInt(
|
|
|
|
secureStorage: _secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.selectedCake2FAPreset,
|
|
|
|
) ??
|
|
|
|
Cake2FAPresetsOptions.normal.raw);
|
|
|
|
|
|
|
|
shouldRequireTOTP2FAForAccessingWallet = await SecureKey.getBool(
|
|
|
|
secureStorage: _secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForAccessingWallet,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
shouldRequireTOTP2FAForSendsToContact = await SecureKey.getBool(
|
|
|
|
secureStorage: _secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForSendsToContact,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
|
|
|
|
shouldRequireTOTP2FAForSendsToNonContact = await SecureKey.getBool(
|
|
|
|
secureStorage: _secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForSendsToNonContact,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
shouldRequireTOTP2FAForSendsToInternalWallets = await SecureKey.getBool(
|
|
|
|
secureStorage: _secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForSendsToInternalWallets,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
shouldRequireTOTP2FAForExchangesToInternalWallets = await SecureKey.getBool(
|
|
|
|
secureStorage: _secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForExchangesToInternalWallets,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
shouldRequireTOTP2FAForExchangesToExternalWallets = await SecureKey.getBool(
|
|
|
|
secureStorage: _secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForExchangesToExternalWallets,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
shouldRequireTOTP2FAForAddingContacts = await SecureKey.getBool(
|
|
|
|
secureStorage: _secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForAddingContacts,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
shouldRequireTOTP2FAForCreatingNewWallets = await SecureKey.getBool(
|
|
|
|
secureStorage: _secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForCreatingNewWallets,
|
|
|
|
) ??
|
|
|
|
false;
|
|
|
|
shouldRequireTOTP2FAForAllSecurityAndBackupSettings = await SecureKey.getBool(
|
|
|
|
secureStorage: _secureStorage,
|
|
|
|
sharedPreferences: sharedPreferences,
|
|
|
|
key: SecureKey.shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
|
|
|
|
) ??
|
|
|
|
false;
|
2022-12-07 14:41:04 +00:00
|
|
|
}
|
2021-01-15 17:41:30 +00:00
|
|
|
|
2020-09-26 19:17:31 +00:00
|
|
|
Future<void> _saveCurrentNode(Node node, WalletType walletType) async {
|
2020-09-21 11:50:26 +00:00
|
|
|
switch (walletType) {
|
|
|
|
case WalletType.bitcoin:
|
|
|
|
await _sharedPreferences.setInt(
|
|
|
|
PreferencesKey.currentBitcoinElectrumSererIdKey, node.key as int);
|
|
|
|
break;
|
2021-05-07 07:36:38 +00:00
|
|
|
case WalletType.litecoin:
|
|
|
|
await _sharedPreferences.setInt(
|
|
|
|
PreferencesKey.currentLitecoinElectrumSererIdKey, node.key as int);
|
|
|
|
break;
|
2020-09-21 11:50:26 +00:00
|
|
|
case WalletType.monero:
|
2023-05-17 14:43:23 +00:00
|
|
|
await _sharedPreferences.setInt(PreferencesKey.currentNodeIdKey, node.key as int);
|
2020-09-21 11:50:26 +00:00
|
|
|
break;
|
2022-06-20 14:18:25 +00:00
|
|
|
case WalletType.haven:
|
2023-05-17 14:43:23 +00:00
|
|
|
await _sharedPreferences.setInt(PreferencesKey.currentHavenNodeIdKey, node.key as int);
|
2022-06-20 14:18:25 +00:00
|
|
|
break;
|
2023-08-04 17:01:49 +00:00
|
|
|
case WalletType.ethereum:
|
|
|
|
await _sharedPreferences.setInt(PreferencesKey.currentEthereumNodeIdKey, node.key as int);
|
|
|
|
break;
|
2023-10-12 22:50:16 +00:00
|
|
|
case WalletType.bitcoinCash:
|
2023-11-17 18:35:46 +00:00
|
|
|
await _sharedPreferences.setInt(
|
|
|
|
PreferencesKey.currentBitcoinCashNodeIdKey, node.key as int);
|
2023-10-12 22:50:16 +00:00
|
|
|
break;
|
2023-10-05 01:09:07 +00:00
|
|
|
case WalletType.nano:
|
|
|
|
await _sharedPreferences.setInt(PreferencesKey.currentNanoNodeIdKey, node.key as int);
|
|
|
|
break;
|
2023-12-02 02:26:43 +00:00
|
|
|
case WalletType.polygon:
|
|
|
|
await _sharedPreferences.setInt(PreferencesKey.currentPolygonNodeIdKey, node.key as int);
|
|
|
|
break;
|
CW-555-Add-Solana-Wallet (#1272)
* chore: Create cw_solana package and clean up files
* feat: Add Solana Wallet - Create, Restore form seed, restore from Key, Restore from QR, Send, Receive, transaction history, spl tokens
* fix: Make transactions file specific to solana only for solana transactions
* chore: Revert inject app details script
* fix: Fix issue with node and switch current node to main beta instead of testnet
* fix: Fix merge conflicts and adjust migration version
* fix: Fetch spl token error
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
* fix: Diplay and activate spl tokens bug
* fix: Review and fixes
* fix: reverted formatting for cryptocurrency class
* fix: Review comments, split sending flow into signing and sending separately, fix issues
* fix: Revert throwing unimplenented error
* chore: Fix comment
* chore: Fix comment
* fix: Errors in flow
* Update provider_types.dart [skip ci]
* fix: Issues with solana wallet
* Update solana_wallet.dart [skip ci]
* fix: Review comments
* fix: Date time config
* fix: Revert bash script for app details
* fix: Error with balance, displaying fees, fixing sent or received identifier bug, displaying token symbol with token transaction item in transactions list
* fix: Issues with address validation when sending spl tokens and walletconnect initial setup
* fix: Issues with sending, fetching transactions history, almost wrapping up walletconnect
* fix: Adjust imports that would affect monerocom building successfully
* fix: Refine transaction direction and continue work on walletconnect
* feat: Display SPL token transfers in the transaction history and finally settle the transaction direction
* fix: Delay in transactions history dispaly, show native token transactions first, then process spl token transactions
* feat: Switch node and revert solana chain id to previous id
* fix: Remove print statement
* fix: Remove await for transactions, fetch all transaction histories instantly and adjust solana send success message
* chore: Code refactoring and streamlined wallet type check for solana send success message
* fix: Make timeout error for node silent and add spl token images
---------
Signed-off-by: Blazebrain <davidadegoke16@gmail.com>
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-02-23 13:39:19 +00:00
|
|
|
case WalletType.solana:
|
|
|
|
await _sharedPreferences.setInt(PreferencesKey.currentSolanaNodeIdKey, node.key as int);
|
|
|
|
break;
|
2020-09-21 11:50:26 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
nodes[walletType] = node;
|
|
|
|
}
|
2023-05-17 14:43:23 +00:00
|
|
|
|
2023-10-05 01:09:07 +00:00
|
|
|
Future<void> _saveCurrentPowNode(Node node, WalletType walletType) async {
|
|
|
|
switch (walletType) {
|
|
|
|
case WalletType.nano:
|
|
|
|
await _sharedPreferences.setInt(PreferencesKey.currentNanoPowNodeIdKey, node.key as int);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
powNodes[walletType] = node;
|
|
|
|
}
|
|
|
|
|
2023-11-16 23:23:34 +00:00
|
|
|
void initializeTrocadorProviderStates() {
|
|
|
|
for (var provider in TrocadorExchangeProvider.availableProviders) {
|
|
|
|
final savedState = _sharedPreferences.getBool(provider) ?? true;
|
|
|
|
trocadorProviderStates[provider] = savedState;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void saveTrocadorProviderState(String providerName, bool state) {
|
|
|
|
_sharedPreferences.setBool(providerName, state);
|
|
|
|
trocadorProviderStates[providerName] = state;
|
|
|
|
}
|
|
|
|
|
2023-05-17 14:43:23 +00:00
|
|
|
static Future<String?> _getDeviceName() async {
|
|
|
|
String? deviceName = '';
|
|
|
|
final deviceInfoPlugin = DeviceInfoPlugin();
|
|
|
|
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
final androidInfo = await deviceInfoPlugin.androidInfo;
|
|
|
|
deviceName = '${androidInfo.brand}%20${androidInfo.manufacturer}%20${androidInfo.model}';
|
|
|
|
} else if (Platform.isIOS) {
|
|
|
|
final iosInfo = await deviceInfoPlugin.iosInfo;
|
|
|
|
deviceName = iosInfo.model;
|
|
|
|
} else if (Platform.isLinux) {
|
|
|
|
final linuxInfo = await deviceInfoPlugin.linuxInfo;
|
|
|
|
deviceName = linuxInfo.prettyName;
|
|
|
|
} else if (Platform.isMacOS) {
|
|
|
|
final macInfo = await deviceInfoPlugin.macOsInfo;
|
|
|
|
deviceName = macInfo.computerName;
|
|
|
|
} else if (Platform.isWindows) {
|
|
|
|
final windowsInfo = await deviceInfoPlugin.windowsInfo;
|
|
|
|
deviceName = windowsInfo.productName;
|
|
|
|
}
|
|
|
|
|
|
|
|
return deviceName;
|
|
|
|
}
|
2020-07-06 20:09:03 +00:00
|
|
|
}
|