12
import 'package:cake_wallet/entities/seed_phrase_length.dart';
13
import 'package:cake_wallet/entities/seed_type.dart';
14
import 'package:cake_wallet/entities/sort_balance_types.dart';
15
+import 'package:cake_wallet/polygon/polygon.dart';
16
import 'package:cake_wallet/exchange/provider/trocador_exchange_provider.dart';
17
import 'package:cake_wallet/view_model/settings/sync_mode.dart';
18
import 'package:cake_wallet/utils/device_info.dart';
89
required this.sortBalanceBy,
90
required this.pinNativeTokenAtTop,
91
required this.useEtherscan,
92
+ required this.usePolygonScan,
93
required this.defaultNanoRep,
94
required this.defaultBananoRep,
95
required this.lookupsTwitter,
103
TransactionPriority? initialHavenTransactionPriority,
104
TransactionPriority? initialLitecoinTransactionPriority,
105
TransactionPriority? initialEthereumTransactionPriority,
106
+ TransactionPriority? initialPolygonTransactionPriority,
107
TransactionPriority? initialBitcoinCashTransactionPriority})
108
: nodes = ObservableMap<WalletType, Node>.of(nodes),
109
powNodes = ObservableMap<WalletType, Node>.of(powNodes),
168
priority[WalletType.ethereum] = initialEthereumTransactionPriority;
169
}
170
171
+ if (initialPolygonTransactionPriority != null) {
172
+ priority[WalletType.polygon] = initialPolygonTransactionPriority;
173
+ }
174
+
175
if (initialBitcoinCashTransactionPriority != null) {
176
priority[WalletType.bitcoinCash] = initialBitcoinCashTransactionPriority;
177
}
209
case WalletType.bitcoinCash:
210
key = PreferencesKey.bitcoinCashTransactionPriority;
211
break;
212
+ case WalletType.polygon:
213
+ key = PreferencesKey.polygonTransactionPriority;
214
+ break;
215
default:
216
key = null;
217
}
255
256
reaction(
257
(_) => moneroSeedType,
248
- (SeedType moneroSeedType) => sharedPreferences.setInt(
249
- PreferencesKey.moneroSeedType, moneroSeedType.raw));
258
+ (SeedType moneroSeedType) =>
259
+ sharedPreferences.setInt(PreferencesKey.moneroSeedType, moneroSeedType.raw));
260
261
reaction(
262
(_) => fiatApiMode,
352
sharedPreferences.setString(PreferencesKey.currentLanguageCode, languageCode));
353
354
reaction(
345
- (_) => seedPhraseLength,
346
- (SeedPhraseLength seedPhraseWordCount) =>
347
- sharedPreferences.setInt(PreferencesKey.currentSeedPhraseLength, seedPhraseWordCount.value));
355
+ (_) => seedPhraseLength,
356
+ (SeedPhraseLength seedPhraseWordCount) => sharedPreferences.setInt(
357
+ PreferencesKey.currentSeedPhraseLength, seedPhraseWordCount.value));
358
359
reaction(
360
(_) => pinTimeOutDuration,
398
(bool useEtherscan) =>
399
_sharedPreferences.setBool(PreferencesKey.useEtherscan, useEtherscan));
400
401
+ reaction(
402
+ (_) => usePolygonScan,
403
+ (bool usePolygonScan) =>
404
+ _sharedPreferences.setBool(PreferencesKey.usePolygonScan, usePolygonScan));
405
+
406
reaction((_) => defaultNanoRep,
407
(String nanoRep) => _sharedPreferences.setString(PreferencesKey.defaultNanoRep, nanoRep));
408
411
(String bananoRep) =>
412
_sharedPreferences.setString(PreferencesKey.defaultBananoRep, bananoRep));
413
reaction(
399
- (_) => lookupsTwitter,
400
- (bool looksUpTwitter) =>
414
+ (_) => lookupsTwitter,
415
+ (bool looksUpTwitter) =>
416
_sharedPreferences.setBool(PreferencesKey.lookupsTwitter, looksUpTwitter));
417
418
reaction(
404
- (_) => lookupsMastodon,
405
- (bool looksUpMastodon) =>
419
+ (_) => lookupsMastodon,
420
+ (bool looksUpMastodon) =>
421
_sharedPreferences.setBool(PreferencesKey.lookupsMastodon, looksUpMastodon));
422
423
reaction(
409
- (_) => lookupsYatService,
410
- (bool looksUpYatService) =>
424
+ (_) => lookupsYatService,
425
+ (bool looksUpYatService) =>
426
_sharedPreferences.setBool(PreferencesKey.lookupsYatService, looksUpYatService));
427
428
reaction(
414
- (_) => lookupsUnstoppableDomains,
415
- (bool looksUpUnstoppableDomains) =>
416
- _sharedPreferences.setBool(PreferencesKey.lookupsUnstoppableDomains, looksUpUnstoppableDomains));
429
+ (_) => lookupsUnstoppableDomains,
430
+ (bool looksUpUnstoppableDomains) => _sharedPreferences.setBool(
431
+ PreferencesKey.lookupsUnstoppableDomains, looksUpUnstoppableDomains));
432
433
reaction(
419
- (_) => lookupsOpenAlias,
420
- (bool looksUpOpenAlias) =>
434
+ (_) => lookupsOpenAlias,
435
+ (bool looksUpOpenAlias) =>
436
_sharedPreferences.setBool(PreferencesKey.lookupsOpenAlias, looksUpOpenAlias));
437
423
- reaction(
424
- (_) => lookupsENS,
425
- (bool looksUpENS) =>
426
- _sharedPreferences.setBool(PreferencesKey.lookupsENS, looksUpENS));
438
+ reaction((_) => lookupsENS,
439
+ (bool looksUpENS) => _sharedPreferences.setBool(PreferencesKey.lookupsENS, looksUpENS));
440
441
this.nodes.observe((change) {
442
if (change.newValue != null && change.key != null) {
575
@observable
576
bool useEtherscan;
577
578
+ @observable
579
+ bool usePolygonScan;
580
+
581
@observable
582
String defaultNanoRep;
583
667
TransactionPriority? havenTransactionPriority;
668
TransactionPriority? litecoinTransactionPriority;
669
TransactionPriority? ethereumTransactionPriority;
670
+ TransactionPriority? polygonTransactionPriority;
671
TransactionPriority? bitcoinCashTransactionPriority;
672
673
if (sharedPreferences.getInt(PreferencesKey.havenTransactionPriority) != null) {
679
sharedPreferences.getInt(PreferencesKey.litecoinTransactionPriority)!);
680
}
681
if (sharedPreferences.getInt(PreferencesKey.ethereumTransactionPriority) != null) {
665
- ethereumTransactionPriority = bitcoin?.deserializeLitecoinTransactionPriority(
682
+ ethereumTransactionPriority = ethereum?.deserializeEthereumTransactionPriority(
683
sharedPreferences.getInt(PreferencesKey.ethereumTransactionPriority)!);
684
}
685
+ if (sharedPreferences.getInt(PreferencesKey.polygonTransactionPriority) != null) {
686
+ polygonTransactionPriority = polygon?.deserializePolygonTransactionPriority(
687
+ sharedPreferences.getInt(PreferencesKey.polygonTransactionPriority)!);
688
+ }
689
if (sharedPreferences.getInt(PreferencesKey.bitcoinCashTransactionPriority) != null) {
690
bitcoinCashTransactionPriority = bitcoinCash?.deserializeBitcoinCashTransactionPriority(
691
sharedPreferences.getInt(PreferencesKey.bitcoinCashTransactionPriority)!);
697
litecoinTransactionPriority ??= bitcoin?.getLitecoinTransactionPriorityMedium();
698
ethereumTransactionPriority ??= ethereum?.getDefaultTransactionPriority();
699
bitcoinCashTransactionPriority ??= bitcoinCash?.getDefaultTransactionPriority();
700
+ polygonTransactionPriority ??= polygon?.getDefaultTransactionPriority();
701
702
final currentBalanceDisplayMode = BalanceDisplayMode.deserialize(
703
raw: sharedPreferences.getInt(PreferencesKey.currentBalanceDisplayModeKey)!);
771
final pinNativeTokenAtTop =
772
sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop) ?? true;
773
final useEtherscan = sharedPreferences.getBool(PreferencesKey.useEtherscan) ?? true;
774
+ final usePolygonScan = sharedPreferences.getBool(PreferencesKey.usePolygonScan) ?? true;
775
final defaultNanoRep = sharedPreferences.getString(PreferencesKey.defaultNanoRep) ?? "";
776
final defaultBananoRep = sharedPreferences.getString(PreferencesKey.defaultBananoRep) ?? "";
777
final lookupsTwitter = sharedPreferences.getBool(PreferencesKey.lookupsTwitter) ?? true;
778
final lookupsMastodon = sharedPreferences.getBool(PreferencesKey.lookupsMastodon) ?? true;
779
final lookupsYatService = sharedPreferences.getBool(PreferencesKey.lookupsYatService) ?? true;
757
- final lookupsUnstoppableDomains = sharedPreferences.getBool(PreferencesKey.lookupsUnstoppableDomains) ?? true;
780
+ final lookupsUnstoppableDomains =
781
+ sharedPreferences.getBool(PreferencesKey.lookupsUnstoppableDomains) ?? true;
782
final lookupsOpenAlias = sharedPreferences.getBool(PreferencesKey.lookupsOpenAlias) ?? true;
783
final lookupsENS = sharedPreferences.getBool(PreferencesKey.lookupsENS) ?? true;
784
798
sharedPreferences.getInt(PreferencesKey.currentBitcoinCashNodeIdKey);
799
final havenNodeId = sharedPreferences.getInt(PreferencesKey.currentHavenNodeIdKey);
800
final ethereumNodeId = sharedPreferences.getInt(PreferencesKey.currentEthereumNodeIdKey);
801
+ final polygonNodeId = sharedPreferences.getInt(PreferencesKey.currentPolygonNodeIdKey);
802
final nanoNodeId = sharedPreferences.getInt(PreferencesKey.currentNanoNodeIdKey);
803
final nanoPowNodeId = sharedPreferences.getInt(PreferencesKey.currentNanoPowNodeIdKey);
804
final moneroNode = nodeSource.get(nodeId);
806
final litecoinElectrumServer = nodeSource.get(litecoinElectrumServerId);
807
final havenNode = nodeSource.get(havenNodeId);
808
final ethereumNode = nodeSource.get(ethereumNodeId);
809
+ final polygonNode = nodeSource.get(polygonNodeId);
810
final bitcoinCashElectrumServer = nodeSource.get(bitcoinCashElectrumServerId);
811
final nanoNode = nodeSource.get(nanoNodeId);
812
final nanoPowNode = powNodeSource.get(nanoPowNodeId);
850
nodes[WalletType.ethereum] = ethereumNode;
851
}
852
853
+ if (polygonNode != null) {
854
+ nodes[WalletType.polygon] = polygonNode;
855
+ }
856
+
857
if (bitcoinCashElectrumServer != null) {
858
nodes[WalletType.bitcoinCash] = bitcoinCashElectrumServer;
859
}
871
});
872
final savedSyncAll = sharedPreferences.getBool(PreferencesKey.syncAllKey) ?? true;
873
844
- return SettingsStore(
845
- sharedPreferences: sharedPreferences,
846
- initialShouldShowMarketPlaceInDashboard: shouldShowMarketPlaceInDashboard,
847
- nodes: nodes,
848
- powNodes: powNodes,
849
- appVersion: packageInfo.version,
850
- deviceName: deviceName,
851
- isBitcoinBuyEnabled: isBitcoinBuyEnabled,
852
- initialFiatCurrency: currentFiatCurrency,
853
- initialBalanceDisplayMode: currentBalanceDisplayMode,
854
- initialSaveRecipientAddress: shouldSaveRecipientAddress,
855
- initialAutoGenerateSubaddressStatus: autoGenerateSubaddressStatus,
856
- initialMoneroSeedType: moneroSeedType,
874
+ return SettingsStore(
875
+ sharedPreferences: sharedPreferences,
876
+ initialShouldShowMarketPlaceInDashboard: shouldShowMarketPlaceInDashboard,
877
+ nodes: nodes,
878
+ powNodes: powNodes,
879
+ appVersion: packageInfo.version,
880
+ deviceName: deviceName,
881
+ isBitcoinBuyEnabled: isBitcoinBuyEnabled,
882
+ initialFiatCurrency: currentFiatCurrency,
883
+ initialBalanceDisplayMode: currentBalanceDisplayMode,
884
+ initialSaveRecipientAddress: shouldSaveRecipientAddress,
885
+ initialAutoGenerateSubaddressStatus: autoGenerateSubaddressStatus,
886
+ initialMoneroSeedType: moneroSeedType,
887
initialAppSecure: isAppSecure,
888
initialDisableBuy: disableBuy,
889
initialDisableSell: disableSell,
899
actionlistDisplayMode: actionListDisplayMode,
900
initialPinLength: pinLength,
901
pinTimeOutDuration: pinCodeTimeOutDuration,
872
- seedPhraseLength: seedPhraseWordCount,initialLanguageCode: savedLanguageCode,
902
+ seedPhraseLength: seedPhraseWordCount,
903
+ initialLanguageCode: savedLanguageCode,
904
sortBalanceBy: sortBalanceBy,
905
pinNativeTokenAtTop: pinNativeTokenAtTop,
906
useEtherscan: useEtherscan,
907
+ usePolygonScan: usePolygonScan,
908
defaultNanoRep: defaultNanoRep,
877
- defaultBananoRep: defaultBananoRep,
878
- lookupsTwitter: lookupsTwitter,
879
- lookupsMastodon: lookupsMastodon,
880
- lookupsYatService: lookupsYatService,
881
- lookupsUnstoppableDomains: lookupsUnstoppableDomains,
882
- lookupsOpenAlias: lookupsOpenAlias,
883
- lookupsENS: lookupsENS,
884
- initialMoneroTransactionPriority: moneroTransactionPriority,
909
+ defaultBananoRep: defaultBananoRep,
910
+ lookupsTwitter: lookupsTwitter,
911
+ lookupsMastodon: lookupsMastodon,
912
+ lookupsYatService: lookupsYatService,
913
+ lookupsUnstoppableDomains: lookupsUnstoppableDomains,
914
+ lookupsOpenAlias: lookupsOpenAlias,
915
+ lookupsENS: lookupsENS,
916
+ initialMoneroTransactionPriority: moneroTransactionPriority,
917
initialBitcoinTransactionPriority: bitcoinTransactionPriority,
918
initialHavenTransactionPriority: havenTransactionPriority,
919
initialLitecoinTransactionPriority: litecoinTransactionPriority,
920
initialBitcoinCashTransactionPriority: bitcoinCashTransactionPriority,
889
- initialShouldRequireTOTP2FAForAccessingWallet: shouldRequireTOTP2FAForAccessingWallet,
890
- initialShouldRequireTOTP2FAForSendsToContact: shouldRequireTOTP2FAForSendsToContact,
891
- initialShouldRequireTOTP2FAForSendsToNonContact: shouldRequireTOTP2FAForSendsToNonContact,
892
- initialShouldRequireTOTP2FAForSendsToInternalWallets:
893
- shouldRequireTOTP2FAForSendsToInternalWallets,
894
- initialShouldRequireTOTP2FAForExchangesToInternalWallets:
895
- shouldRequireTOTP2FAForExchangesToInternalWallets,
921
+ initialShouldRequireTOTP2FAForAccessingWallet: shouldRequireTOTP2FAForAccessingWallet,
922
+ initialShouldRequireTOTP2FAForSendsToContact: shouldRequireTOTP2FAForSendsToContact,
923
+ initialShouldRequireTOTP2FAForSendsToNonContact: shouldRequireTOTP2FAForSendsToNonContact,
924
+ initialShouldRequireTOTP2FAForSendsToInternalWallets:
925
+ shouldRequireTOTP2FAForSendsToInternalWallets,
926
+ initialShouldRequireTOTP2FAForExchangesToInternalWallets:
927
+ shouldRequireTOTP2FAForExchangesToInternalWallets,
928
initialShouldRequireTOTP2FAForExchangesToExternalWallets:
929
shouldRequireTOTP2FAForExchangesToExternalWallets,
898
- initialShouldRequireTOTP2FAForAddingContacts: shouldRequireTOTP2FAForAddingContacts,
899
- initialShouldRequireTOTP2FAForCreatingNewWallets: shouldRequireTOTP2FAForCreatingNewWallets,
900
- initialShouldRequireTOTP2FAForAllSecurityAndBackupSettings:
901
- shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
902
- initialEthereumTransactionPriority: ethereumTransactionPriority,
903
- backgroundTasks: backgroundTasks,
904
- initialSyncMode: savedSyncMode,
905
- initialSyncAll: savedSyncAll,
906
- shouldShowYatPopup: shouldShowYatPopup);
907
- }
930
+ initialShouldRequireTOTP2FAForAddingContacts: shouldRequireTOTP2FAForAddingContacts,
931
+ initialShouldRequireTOTP2FAForCreatingNewWallets: shouldRequireTOTP2FAForCreatingNewWallets,
932
+ initialShouldRequireTOTP2FAForAllSecurityAndBackupSettings:
933
+ shouldRequireTOTP2FAForAllSecurityAndBackupSettings,
934
+ initialEthereumTransactionPriority: ethereumTransactionPriority,
935
+ initialPolygonTransactionPriority: polygonTransactionPriority,
936
+ backgroundTasks: backgroundTasks,
937
+ initialSyncMode: savedSyncMode,
938
+ initialSyncAll: savedSyncAll,
939
+ shouldShowYatPopup: shouldShowYatPopup);
940
+ }
941
942
Future<void> reload({required Box<Node> nodeSource}) async {
943
final sharedPreferences = await getIt.getAsync<SharedPreferences>();
967
sharedPreferences.getInt(PreferencesKey.ethereumTransactionPriority)!) ??
968
priority[WalletType.ethereum]!;
969
}
970
+ if (sharedPreferences.getInt(PreferencesKey.polygonTransactionPriority) != null) {
971
+ priority[WalletType.polygon] = polygon?.deserializePolygonTransactionPriority(
972
+ sharedPreferences.getInt(PreferencesKey.polygonTransactionPriority)!) ??
973
+ priority[WalletType.polygon]!;
974
+ }
975
if (sharedPreferences.getInt(PreferencesKey.bitcoinCashTransactionPriority) != null) {
976
priority[WalletType.bitcoinCash] = bitcoinCash?.deserializeBitcoinCashTransactionPriority(
977
sharedPreferences.getInt(PreferencesKey.bitcoinCashTransactionPriority)!) ??
1065
.values[sharedPreferences.getInt(PreferencesKey.sortBalanceBy) ?? sortBalanceBy.index];
1066
pinNativeTokenAtTop = sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop) ?? true;
1067
useEtherscan = sharedPreferences.getBool(PreferencesKey.useEtherscan) ?? true;
1068
+ usePolygonScan = sharedPreferences.getBool(PreferencesKey.usePolygonScan) ?? true;
1069
defaultNanoRep = sharedPreferences.getString(PreferencesKey.defaultNanoRep) ?? "";
1070
defaultBananoRep = sharedPreferences.getString(PreferencesKey.defaultBananoRep) ?? "";
1071
lookupsTwitter = sharedPreferences.getBool(PreferencesKey.lookupsTwitter) ?? true;
1072
lookupsMastodon = sharedPreferences.getBool(PreferencesKey.lookupsMastodon) ?? true;
1073
lookupsYatService = sharedPreferences.getBool(PreferencesKey.lookupsYatService) ?? true;
1035
- lookupsUnstoppableDomains = sharedPreferences.getBool(PreferencesKey.lookupsUnstoppableDomains) ?? true;
1074
+ lookupsUnstoppableDomains =
1075
+ sharedPreferences.getBool(PreferencesKey.lookupsUnstoppableDomains) ?? true;
1076
lookupsOpenAlias = sharedPreferences.getBool(PreferencesKey.lookupsOpenAlias) ?? true;
1077
lookupsENS = sharedPreferences.getBool(PreferencesKey.lookupsENS) ?? true;
1078
1085
sharedPreferences.getInt(PreferencesKey.currentBitcoinCashNodeIdKey);
1086
final havenNodeId = sharedPreferences.getInt(PreferencesKey.currentHavenNodeIdKey);
1087
final ethereumNodeId = sharedPreferences.getInt(PreferencesKey.currentEthereumNodeIdKey);
1088
+ final polygonNodeId = sharedPreferences.getInt(PreferencesKey.currentPolygonNodeIdKey);
1089
final nanoNodeId = sharedPreferences.getInt(PreferencesKey.currentNanoNodeIdKey);
1090
final nanoPowNodeId = sharedPreferences.getInt(PreferencesKey.currentNanoNodeIdKey);
1091
final moneroNode = nodeSource.get(nodeId);
1093
final litecoinElectrumServer = nodeSource.get(litecoinElectrumServerId);
1094
final havenNode = nodeSource.get(havenNodeId);
1095
final ethereumNode = nodeSource.get(ethereumNodeId);
1096
+ final polygonNode = nodeSource.get(polygonNodeId);
1097
final bitcoinCashNode = nodeSource.get(bitcoinCashElectrumServerId);
1098
final nanoNode = nodeSource.get(nanoNodeId);
1099
1117
nodes[WalletType.ethereum] = ethereumNode;
1118
}
1119
1120
+ if (polygonNode != null) {
1121
+ nodes[WalletType.polygon] = polygonNode;
1122
+ }
1123
+
1124
if (bitcoinCashNode != null) {
1125
nodes[WalletType.bitcoinCash] = bitcoinCashNode;
1126
}
1156
case WalletType.nano:
1157
await _sharedPreferences.setInt(PreferencesKey.currentNanoNodeIdKey, node.key as int);
1158
break;
1159
+ case WalletType.polygon:
1160
+ await _sharedPreferences.setInt(PreferencesKey.currentPolygonNodeIdKey, node.key as int);
1161
+ break;
1162
default:
1163
break;
1164
}
1190
trocadorProviderStates[providerName] = state;
1191
}
1192
1144
-
1193
static Future<String?> _getDeviceName() async {
1194
String? deviceName = '';
1195
final deviceInfoPlugin = DeviceInfoPlugin();