Reformat the whole codebase with 100 line width (#3403)

This commit is contained in:
Omar Hatem
2026-07-15 01:20:33 +03:00
committed by GitHub
parent 1241b28bec
commit 16ddc0837a
801 changed files with 17517 additions and 17091 deletions
@@ -1,13 +1,11 @@
enum AutoGenerateSubaddressStatus {
initialized(1),
enabled(2),
enum AutoGenerateSubaddressStatus {
initialized(1),
enabled(2),
disabled(3);
const AutoGenerateSubaddressStatus(this.value);
final int value;
static AutoGenerateSubaddressStatus deserialize({required int raw}) =>
static AutoGenerateSubaddressStatus deserialize({required int raw}) =>
AutoGenerateSubaddressStatus.values.firstWhere((e) => e.value == raw);
}
}
+3 -6
View File
@@ -11,12 +11,9 @@ class BalanceDisplayMode extends EnumerableItem<int> with Serializable<int> {
BalanceDisplayMode.displayableBalance,
];
static const fullBalance = BalanceDisplayMode(raw: 0, title: 'Full Balance');
static const availableBalance =
BalanceDisplayMode(raw: 1, title: 'Available Balance');
static const hiddenBalance =
BalanceDisplayMode(raw: 2, title: 'Hidden Balance');
static const displayableBalance =
BalanceDisplayMode(raw: 3, title: 'Displayable Balance');
static const availableBalance = BalanceDisplayMode(raw: 1, title: 'Available Balance');
static const hiddenBalance = BalanceDisplayMode(raw: 2, title: 'Hidden Balance');
static const displayableBalance = BalanceDisplayMode(raw: 3, title: 'Displayable Balance');
static BalanceDisplayMode deserialize({required int raw}) {
switch (raw) {
+1 -1
View File
@@ -27,4 +27,4 @@ class BiometricAuth {
return canAuthenticate;
}
}
}
@@ -9,8 +9,7 @@ class BitcoinAmountDisplayMode extends EnumerableItem<int> with Serializable<int
BitcoinAmountDisplayMode.satoshiForLightning,
BitcoinAmountDisplayMode.bitcoin,
];
static const satoshiForLightning =
BitcoinAmountDisplayMode(raw: 0, title: 'sats (LN)');
static const satoshiForLightning = BitcoinAmountDisplayMode(raw: 0, title: 'sats (LN)');
static const bitcoin = BitcoinAmountDisplayMode(raw: 1, title: 'BTC');
static const satoshi = BitcoinAmountDisplayMode(raw: 2, title: 'sats');
+2 -2
View File
@@ -16,7 +16,7 @@ String calculateFiatAmount({double? price, String? cryptoAmount, bool raw = fals
return '0.00';
}
if(raw) {
if (raw) {
return result.toStringAsFixed(2);
}
@@ -48,7 +48,7 @@ String formatWithCommas(String? number) {
(Match match) => ',',
);
if(decimalPart.length == 1) {
if (decimalPart.length == 1) {
decimalPart = "${decimalPart}0";
}
+1 -1
View File
@@ -12,4 +12,4 @@ String calculateFiatAmountRaw({required double cryptoAmount, double? price}) {
}
return result > 0.01 ? formatWithCommas(result.toStringAsFixed(2)) : '< 0.01';
}
}
+6 -1
View File
@@ -7,7 +7,12 @@ part 'contact.part.dart';
// @HiveType(typeId: Contact.typeId)
class Contact extends HiveObject with Keyable {
Contact({required this.name, required this.address, CryptoCurrency? type, DateTime? lastChange, this.displayName = ""})
Contact(
{required this.name,
required this.address,
CryptoCurrency? type,
DateTime? lastChange,
this.displayName = ""})
: lastChange = lastChange ?? DateTime.now() {
if (type != null) {
raw = type.raw;
+1 -3
View File
@@ -46,7 +46,5 @@ class ContactAdapter extends TypeAdapter<Contact> {
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ContactAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
other is ContactAdapter && runtimeType == other.runtimeType && typeId == other.typeId;
}
+1 -1
View File
@@ -10,4 +10,4 @@ abstract class ContactBase {
String displayName;
CryptoCurrency type;
}
}
+4 -3
View File
@@ -11,7 +11,8 @@ class Country extends EnumerableItem<String> with Serializable<String> {
static List<Country> get all => _all.values.toList();
static List<Country> get allForCakePay => _all.values
.where((element) => element.countryCode != 'EU' && element.countryCode != 'AQ').toList();
.where((element) => element.countryCode != 'EU' && element.countryCode != 'AQ')
.toList();
static const afghanistan = Country(code: 'afg', countryCode: 'AF', fullName: "Afghanistan");
static const andorra = Country(code: 'and', countryCode: 'AD', fullName: "Andorra");
@@ -366,9 +367,9 @@ class Country extends EnumerableItem<String> with Serializable<String> {
return _all.values.firstWhereOrNull((element) => element.raw == countryCode.toLowerCase());
}
static Country? fromCountryCode(String countryCode) {
return _all.values.firstWhereOrNull((element) => element.countryCode == countryCode.toUpperCase());
return _all.values
.firstWhereOrNull((element) => element.countryCode == countryCode.toUpperCase());
}
@override
+15 -18
View File
@@ -283,7 +283,7 @@ Future<void> defaultSettingsMigration(
// await insecureStorageMigration(secureStorage: secureStorage, sharedPreferences: sharedPreferences);
break;
case 27:
await addWalletNodeList( type: WalletType.solana);
await addWalletNodeList(type: WalletType.solana);
await _changeDefaultNode(
sharedPreferences: sharedPreferences,
type: WalletType.solana,
@@ -516,7 +516,7 @@ Future<void> defaultSettingsMigration(
currentNodePreferenceKey: PreferencesKey.currentBaseNodeIdKey,
);
break;
case 53:
case 53:
await addWalletNodeList(type: WalletType.arbitrum);
await _changeDefaultNode(
sharedPreferences: sharedPreferences,
@@ -662,13 +662,13 @@ Future<void> _changeDefaultNode({
shouldReplace = true;
} else {
final currentNode = nodes.firstWhereOrNull((node) => node.id == currentNodeId);
shouldReplace = currentNode == null || (oldUri?.any((e) => currentNode!.uriRaw.contains(e)) ?? true);
shouldReplace =
currentNode == null || (oldUri?.any((e) => currentNode!.uriRaw.contains(e)) ?? true);
}
if (shouldReplace) {
newDefaultUri ??= (await getDefaultNodeFromFiles(type)).uriRaw;
var newNodeId =
nodes.firstWhereOrNull((element) => element.uriRaw == newDefaultUri)?.id;
var newNodeId = nodes.firstWhereOrNull((element) => element.uriRaw == newDefaultUri)?.id;
// new node doesn't exist, then add it
if (newNodeId == null) {
@@ -734,8 +734,7 @@ Future<void> updateNanoNodeList() async {
}
// update the nautilus node:
final nautilusNode =
nodes.firstWhereOrNull((element) => element.uriRaw == "node.perish.co");
final nautilusNode = nodes.firstWhereOrNull((element) => element.uriRaw == "node.perish.co");
if (nautilusNode != null) {
nautilusNode.uriRaw = "node.nautilus.io";
nautilusNode.path = "/api";
@@ -855,9 +854,9 @@ Future<void> validateBitcoinSavedTransactionPriority(SharedPreferences sharedPre
Future<void> replaceNodesMigration() async {
final replaceNodes = <String, Node>{
'eu-node.cakewallet.io:18081':
Node(uri: 'xmr-node-eu.cakewallet.com:18081', type: WalletType.monero),
Node(uri: 'xmr-node-eu.cakewallet.com:18081', type: WalletType.monero),
'node.cakewallet.io:18081':
Node(uri: 'xmr-node-usa-east.cakewallet.com:18081', type: WalletType.monero),
Node(uri: 'xmr-node-usa-east.cakewallet.com:18081', type: WalletType.monero),
'node.xmr.ru:13666': Node(uri: 'node.monero.net:18081', type: WalletType.monero)
};
@@ -874,11 +873,10 @@ Future<void> replaceNodesMigration() async {
});
}
Future<Node?> getBitcoinTestnetDefaultElectrumServer()async {
Future<Node?> getBitcoinTestnetDefaultElectrumServer() async {
final nodes = await Node.getAll();
return nodes
.firstWhereOrNull((Node node) => node.uriRaw == publicBitcoinTestnetElectrumUri) ??
return nodes.firstWhereOrNull((Node node) => node.uriRaw == publicBitcoinTestnetElectrumUri) ??
nodes.firstWhereOrNull((node) => node.type == WalletType.bitcoin);
}
@@ -1086,8 +1084,8 @@ Future<void> resetBitcoinElectrumServer(SharedPreferences sharedPreferences) asy
sharedPreferences.getInt(PreferencesKey.currentBitcoinElectrumSererIdKey);
final oldElectrumServer = nodeSource
.firstWhereOrNull((node) => node.uri.toString().contains('electrumx.cakewallet.com'));
var cakeWalletNode = nodeSource
.firstWhereOrNull((node) => node.uriRaw.toString() == cakeWalletBitcoinElectrumUri);
var cakeWalletNode =
nodeSource.firstWhereOrNull((node) => node.uriRaw.toString() == cakeWalletBitcoinElectrumUri);
if (cakeWalletNode == null) {
cakeWalletNode = Node(
@@ -1147,8 +1145,7 @@ Future<void> addWalletNodeList({required WalletType type}) async {
}
}
Future<void> removeMoneroWorld(
{required SharedPreferences sharedPreferences}) async {
Future<void> removeMoneroWorld({required SharedPreferences sharedPreferences}) async {
final nodes = await Node.getAll();
const cakeWalletMoneroNodeUriPattern = '.moneroworld.com';
final currentMoneroNodeId = sharedPreferences.getInt(PreferencesKey.currentNodeIdKey);
@@ -1218,14 +1215,13 @@ Future<void> migrateExistingNodesToUseAutoSwitching() async {
final powNodes = await Node.getAllPow();
for(var node in powNodes) {
for (var node in powNodes) {
if (listOfDefaultNodesWithAutoSwitching.contains(node.uriRaw)) {
node.isEnabledForAutoSwitching = true;
node.isPow = true;
await node.save();
}
}
}
Future<void> _addXautTokenToExistingEthereumWallets() async {
@@ -1264,6 +1260,7 @@ Future<void> _addXautTokenToExistingEthereumWallets() async {
printV('Error in XAUT migration: $e');
}
}
Future<void> _addXaut0TokenToExistingSolanaWallets() async {
try {
final xaut0Token = SPLToken(
+4 -4
View File
@@ -16,11 +16,11 @@ extension Emoji on String {
bool _hasOnlyEmojis() {
final parsedText = this.replaceAll(' ', '');
if(parsedText.isEmpty) return false;
for (final c in Characters(parsedText))
if (!REGEX_EMOJI.hasMatch(c)) return false;
if (parsedText.isEmpty) return false;
for (final c in Characters(parsedText)) if (!REGEX_EMOJI.hasMatch(c)) return false;
return true;
}
/// Returns true if the given text contains only emojis.
/// Returns true if the given text contains only emojis.
bool get hasOnlyEmojis => _hasOnlyEmojis();
}
@@ -54,7 +54,9 @@ class EVMTransactionErrorFeesHandler {
// Pattern 2: "balance X, queued cost Y, tx cost Z, overshot W" format (most specific)
ErrorPattern(
name: 'balance_queued_txcost_overshot',
regex: RegExp(r'balance\s+(\d+),\s*queued\s+cost\s+(\d+),\s*tx\s+cost\s+(\d+),\s*overshot\s+(\d+)', caseSensitive: false),
regex: RegExp(
r'balance\s+(\d+),\s*queued\s+cost\s+(\d+),\s*tx\s+cost\s+(\d+),\s*overshot\s+(\d+)',
caseSensitive: false),
extractor: (match) => {
'balance': match.group(1)!,
'txCost': match.group(3)!, // Skip queued cost, use tx cost
@@ -70,7 +72,8 @@ class EVMTransactionErrorFeesHandler {
// Pattern 3: "balance X, tx cost Y, overshot Z" format
ErrorPattern(
name: 'balance_txcost_overshot',
regex: RegExp(r'balance\s+(\d+),\s*tx\s+cost\s+(\d+),\s*overshot\s+(\d+)', caseSensitive: false),
regex: RegExp(r'balance\s+(\d+),\s*tx\s+cost\s+(\d+),\s*overshot\s+(\d+)',
caseSensitive: false),
extractor: (match) => {
'balance': match.group(1)!,
'txCost': match.group(2)!,
@@ -86,7 +89,8 @@ class EVMTransactionErrorFeesHandler {
// Pattern 4: Individual field matching (legacy fallback)
ErrorPattern(
name: 'individual_fields',
regex: RegExp(r'balance\s+(\d+).*tx\s+cost\s+(\d+).*overshot\s+(\d+)', caseSensitive: false),
regex:
RegExp(r'balance\s+(\d+).*tx\s+cost\s+(\d+).*overshot\s+(\d+)', caseSensitive: false),
extractor: (match) => {
'balance': match.group(1)!,
'txCost': match.group(2)!,
@@ -102,7 +106,8 @@ class EVMTransactionErrorFeesHandler {
// Pattern 5: Generic "insufficient funds for gas * price + value" (least specific - must be last)
ErrorPattern(
name: 'generic_insufficient_funds',
regex: RegExp(r'insufficient\s+funds\s+for\s+gas\s*\*\s*price\s*\+\s*value', caseSensitive: false),
regex: RegExp(r'insufficient\s+funds\s+for\s+gas\s*\*\s*price\s*\+\s*value',
caseSensitive: false),
extractor: (match) => {
'balance': '0', // We don't have specific values, so use 0
'txCost': '0',
@@ -142,9 +147,8 @@ class EVMTransactionErrorFeesHandler {
final txCostWei = BigInt.parse(values['txCostWei']!);
final overshotWei = BigInt.parse(values['overshotWei']!);
final isGenericError = balanceWei == BigInt.zero &&
txCostWei == BigInt.zero &&
overshotWei == BigInt.zero;
final isGenericError =
balanceWei == BigInt.zero && txCostWei == BigInt.zero && overshotWei == BigInt.zero;
if (isGenericError) {
return genericInsufficientFunds();
+1 -1
View File
@@ -36,4 +36,4 @@ class ExchangeApiMode extends EnumerableItem<int> with Serializable<int> {
return '';
}
}
}
}
+20 -10
View File
@@ -85,15 +85,18 @@ class FiatCurrency extends EnumerableItem<String> with Serializable<String> impl
static const eur = FiatCurrency(symbol: 'EUR', countryCode: "eur", fullName: "Euro");
static const gbp = FiatCurrency(symbol: 'GBP', countryCode: "gbr", fullName: "Pound Sterling");
static const ghs = FiatCurrency(symbol: 'GHS', countryCode: "gha", fullName: "Ghanaian Cedi");
static const gtq = FiatCurrency(symbol: 'GTQ', countryCode: "gtm", fullName: "Guatemalan Quetzal");
static const gtq =
FiatCurrency(symbol: 'GTQ', countryCode: "gtm", fullName: "Guatemalan Quetzal");
static const hkd = FiatCurrency(symbol: 'HKD', countryCode: "hkg", fullName: "Hong Kong Dollar");
static const hrk = FiatCurrency(symbol: 'HRK', countryCode: "hrv", fullName: "Croatian Kuna");
static const huf = FiatCurrency(symbol: 'HUF', countryCode: "hun", fullName: "Hungarian Forint");
static const idr = FiatCurrency(symbol: 'IDR', countryCode: "idn", fullName: "Indonesian Rupiah");
static const ils = FiatCurrency(symbol: 'ILS', countryCode: "isr", fullName: "Israeli New Shekel");
static const ils =
FiatCurrency(symbol: 'ILS', countryCode: "isr", fullName: "Israeli New Shekel");
static const inr = FiatCurrency(symbol: 'INR', countryCode: "ind", fullName: "Indian Rupee");
static const irr = FiatCurrency(symbol: 'IRR', countryCode: "irn", fullName: "Iranian Rial");
static const isk = FiatCurrency(symbol: 'ISK', countryCode: "isl", fullName: "Icelandic Krona Króna");
static const isk =
FiatCurrency(symbol: 'ISK', countryCode: "isl", fullName: "Icelandic Krona Króna");
static const jpy = FiatCurrency(symbol: 'JPY', countryCode: "jpn", fullName: "Japanese Yen");
static const krw = FiatCurrency(symbol: 'KRW', countryCode: "kor", fullName: "South Korean Won");
static const mad = FiatCurrency(symbol: 'MAD', countryCode: "mar", fullName: "Moroccan Dirham");
@@ -101,22 +104,29 @@ class FiatCurrency extends EnumerableItem<String> with Serializable<String> impl
static const myr = FiatCurrency(symbol: 'MYR', countryCode: "mys", fullName: "Malaysian Ringgit");
static const ngn = FiatCurrency(symbol: 'NGN', countryCode: "nga", fullName: "Nigerian Naira");
static const nok = FiatCurrency(symbol: 'NOK', countryCode: "nor", fullName: "Norwegian Krone");
static const nzd = FiatCurrency(symbol: 'NZD', countryCode: "nzl", fullName: "New Zealand Dollar");
static const nzd =
FiatCurrency(symbol: 'NZD', countryCode: "nzl", fullName: "New Zealand Dollar");
static const php = FiatCurrency(symbol: 'PHP', countryCode: "phl", fullName: "Philippine Peso");
static const pkr = FiatCurrency(symbol: 'PKR', countryCode: "pak", fullName: "Pakistani Rupee");
static const pln = FiatCurrency(symbol: 'PLN', countryCode: "pol", fullName: "Poland Zloty złoty");
static const pln =
FiatCurrency(symbol: 'PLN', countryCode: "pol", fullName: "Poland Zloty złoty");
static const ron = FiatCurrency(symbol: 'RON', countryCode: "rou", fullName: "Romanian Leu");
static const rub = FiatCurrency(symbol: 'RUB', countryCode: "rus", fullName: "Russian Ruble");
static const sar = FiatCurrency(symbol: 'SAR', countryCode: "sau", fullName: "Saudi Riyal");
static const sek = FiatCurrency(symbol: 'SEK', countryCode: "swe", fullName: "Swedish Krona");
static const sgd = FiatCurrency(symbol: 'SGD', countryCode: "sgp", fullName: "Singapore Dollar");
static const thb = FiatCurrency(symbol: 'THB', countryCode: "tha", fullName: "New Thaiwan Dollar");
static const thb =
FiatCurrency(symbol: 'THB', countryCode: "tha", fullName: "New Thaiwan Dollar");
static const twd = FiatCurrency(symbol: 'TWD', countryCode: "twn", fullName: "Thai Baht");
static const uah = FiatCurrency(symbol: 'UAH', countryCode: "ukr", fullName: "Ukrainian Hryvnia");
static const usd = FiatCurrency(symbol: 'USD', countryCode: "usa", fullName: "United States Dollar");
static const vef = FiatCurrency(symbol: 'VEF', countryCode: "ven", fullName: "Venezuelan Bolivar Bolívar");
static const vnd = FiatCurrency(symbol: 'VND', countryCode: "vnm", fullName: "Vietnamese Dong đồng");
static const zar = FiatCurrency(symbol: 'ZAR', countryCode: "saf", fullName: "South African Rand");
static const usd =
FiatCurrency(symbol: 'USD', countryCode: "usa", fullName: "United States Dollar");
static const vef =
FiatCurrency(symbol: 'VEF', countryCode: "ven", fullName: "Venezuelan Bolivar Bolívar");
static const vnd =
FiatCurrency(symbol: 'VND', countryCode: "vnm", fullName: "Vietnamese Dong đồng");
static const zar =
FiatCurrency(symbol: 'ZAR', countryCode: "saf", fullName: "South African Rand");
static const tur = FiatCurrency(symbol: 'TRY', countryCode: "tur", fullName: "Turkish Lira");
static const kes = FiatCurrency(symbol: 'KES', countryCode: "ken", fullName: "Kenyan Shillings");
+3 -3
View File
@@ -1,10 +1,10 @@
import 'calculate_fiat_amount.dart';
String formatAmount(String amount) {
if ((!amount.contains('.'))&&(!amount.contains(','))) {
if ((!amount.contains('.')) && (!amount.contains(','))) {
return formatWithCommas(amount + '.00');
} else if ((amount.endsWith('.'))||(amount.endsWith(','))) {
} else if ((amount.endsWith('.')) || (amount.endsWith(','))) {
return formatWithCommas(amount + '00');
}
return formatWithCommas(amount);
}
}
@@ -5,11 +5,8 @@ import 'package:cw_core/wallet_type.dart';
import 'package:shared_preferences/shared_preferences.dart';
Future<bool> requireHardwareWalletConnection() async {
final name = getIt
.get<SharedPreferences>()
.getString(PreferencesKey.currentWalletName);
final typeRaw =
getIt.get<SharedPreferences>().getInt(PreferencesKey.currentWalletType);
final name = getIt.get<SharedPreferences>().getString(PreferencesKey.currentWalletName);
final typeRaw = getIt.get<SharedPreferences>().getInt(PreferencesKey.currentWalletType);
if (typeRaw == null) {
return false;
+1 -3
View File
@@ -38,7 +38,5 @@ class HavenSeedStoreAdapter extends TypeAdapter<HavenSeedStore> {
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HavenSeedStoreAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
other is HavenSeedStoreAdapter && runtimeType == other.runtimeType && typeId == other.typeId;
}
+6 -12
View File
@@ -3,23 +3,17 @@ import 'dart:typed_data';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
const platform =
const MethodChannel('com.cakewallet.cakewallet/legacy_wallet_migration');
const platform = const MethodChannel('com.cakewallet.cakewallet/legacy_wallet_migration');
Future<String> decrypt(Uint8List bytes,
{required String key, required String salt}) async =>
(await platform
.invokeMethod<String>('decrypt', {'bytes': bytes, 'key': key, 'salt': salt}))!;
Future<String> decrypt(Uint8List bytes, {required String key, required String salt}) async =>
(await platform.invokeMethod<String>('decrypt', {'bytes': bytes, 'key': key, 'salt': salt}))!;
Future<dynamic> readUserDefaults(String key, {required String type}) async =>
await platform
.invokeMethod<dynamic>('read_user_defaults', {'key': key, 'type': type});
await platform.invokeMethod<dynamic>('read_user_defaults', {'key': key, 'type': type});
Future<String?> getString(String key) async =>
await readUserDefaults(key, type: 'string') as String?;
Future<bool?> getBool(String key) async =>
await readUserDefaults(key, type: 'bool') as bool?;
Future<bool?> getBool(String key) async => await readUserDefaults(key, type: 'bool') as bool?;
Future<int?> getInt(String key) async =>
await readUserDefaults(key, type: 'int') as int?;
Future<int?> getInt(String key) async => await readUserDefaults(key, type: 'int') as int?;
@@ -15,7 +15,7 @@ abstract class ListItem {
final bool isLastInSection;
BorderRadius get radius => BorderRadius.vertical(
top: Radius.circular(isFirstInSection ? 16 : 0),
bottom: Radius.circular(isLastInSection ? 16 : 0),
);
top: Radius.circular(isFirstInSection ? 16 : 0),
bottom: Radius.circular(isLastInSection ? 16 : 0),
);
}
@@ -13,4 +13,4 @@ class ListItemSelector extends ListItem {
final String? trailingText;
final VoidCallback onTap;
final List<String> options;
}
}
@@ -2,21 +2,18 @@ import 'package:cake_wallet/entities/new_ui_entities/list_item/list_item.dart';
import 'package:flutter/material.dart';
class ListItemTextField extends ListItem {
const ListItemTextField({
required super.keyValue,
required super.label,
this.initialValue,
this.validator,
this.onChanged,
this.onFieldSubmitted,
this.focusNode
});
const ListItemTextField(
{required super.keyValue,
required super.label,
this.initialValue,
this.validator,
this.onChanged,
this.onFieldSubmitted,
this.focusNode});
final String? initialValue;
final FormFieldValidator<String>? validator;
final ValueChanged<String>? onChanged;
final ValueChanged<String>? onFieldSubmitted;
final FocusNode? focusNode;
}
+12 -11
View File
@@ -31,19 +31,21 @@ const Map<WalletType, String> powNodePreferenceKeys = {
WalletType.nano: PreferencesKey.currentNanoPowNodeIdKey
};
Future<void> checkNodeForWalletType(SharedPreferences sharedPreferences, SettingsStore settingsStore, WalletType type, bool isPow) async {
Future<void> checkNodeForWalletType(SharedPreferences sharedPreferences,
SettingsStore settingsStore, WalletType type, bool isPow) async {
final preferenceKey = isPow ? powNodePreferenceKeys[type] : nodePreferenceKeys[type];
if(preferenceKey == null) {
if (preferenceKey == null) {
return;
}
final currentId = await sharedPreferences.getInt(preferenceKey);
final nodes = isPow ? await Node.getAllForWalletTypePow(type) : await Node.getAllForWalletType(type);
final currentNode = nodes.firstWhereOrNull((item)=>item.id == currentId);
final nodes =
isPow ? await Node.getAllForWalletTypePow(type) : await Node.getAllForWalletType(type);
final currentNode = nodes.firstWhereOrNull((item) => item.id == currentId);
if(currentNode == null) {
if (currentNode == null) {
final newNode = (isPow
? await Node.getDefaultPowForWalletType(type)
: await Node.getDefaultForWalletType(type)) ??
@@ -54,16 +56,15 @@ Future<void> checkNodeForWalletType(SharedPreferences sharedPreferences, Setting
} else {
settingsStore.nodes[type] = currentNode;
}
}
Future<void> checkCurrentNodes(SharedPreferences sharedPreferences, SettingsStore settingsStore) async {
for(final walletType in nodePreferenceKeys.keys) {
Future<void> checkCurrentNodes(
SharedPreferences sharedPreferences, SettingsStore settingsStore) async {
for (final walletType in nodePreferenceKeys.keys) {
await checkNodeForWalletType(sharedPreferences, settingsStore, walletType, false);
}
for(final walletType in powNodePreferenceKeys.keys) {
for (final walletType in powNodePreferenceKeys.keys) {
await checkNodeForWalletType(sharedPreferences, settingsStore, walletType, true);
}
}
}
+1
View File
@@ -0,0 +1 @@
+1 -1
View File
@@ -11,7 +11,7 @@ enum PinCodeRequiredDuration {
final int value;
static PinCodeRequiredDuration deserialize({required int raw}) =>
static PinCodeRequiredDuration deserialize({required int raw}) =>
PinCodeRequiredDuration.values.firstWhere((e) => e.value == raw);
@override
+2 -1
View File
@@ -137,7 +137,8 @@ class PreferencesKey {
static const walletConnectPairingTopicsList = 'wallet_connect_pairing_topics_list';
static String walletConnectPairingTopicsListForWallet(String publicKey) =>
'${PreferencesKey.walletConnectPairingTopicsList}_${publicKey}';
static String backgroundSyncLastTrigger(String walletId) => 'background_sync_last_trigger_${walletId}';
static String backgroundSyncLastTrigger(String walletId) =>
'background_sync_last_trigger_${walletId}';
static const backgroundSyncNotificationsEnabled = 'background_sync_notifications_enabled';
static const enableAutomaticNodeSwitching = 'enable_automatic_node_switching';
static const syncStatusDisplayMode = 'sync_status_display_mode';
+13 -13
View File
@@ -47,20 +47,20 @@ extension ProviderTypeName on ProviderType {
class ProvidersHelper {
static List<ProviderType> getAvailableBuyProviderTypes() => [
ProviderType.robinhood,
ProviderType.dfx,
ProviderType.onramper,
ProviderType.moonpay,
ProviderType.kriptonim
];
ProviderType.robinhood,
ProviderType.dfx,
ProviderType.onramper,
ProviderType.moonpay,
ProviderType.kriptonim
];
static List<ProviderType> getAvailableSellProviderTypes() => [
// ProviderType.robinhood, // ToDo: (Konsti) Enable once fixed in Exchange Helper, but still waiting for new Docs
ProviderType.dfx,
ProviderType.onramper,
ProviderType.moonpay,
ProviderType.kriptonim
];
// ProviderType.robinhood, // ToDo: (Konsti) Enable once fixed in Exchange Helper, but still waiting for new Docs
ProviderType.dfx,
ProviderType.onramper,
ProviderType.moonpay,
ProviderType.kriptonim
];
static BuyProvider getProviderByType(ProviderType type) {
switch (type) {
@@ -76,6 +76,6 @@ class ProvidersHelper {
return getIt.get<MeldBuyProvider>();
case ProviderType.kriptonim:
return getIt.get<KryptonimBuyProvider>();
}
}
}
}
+2 -1
View File
@@ -14,7 +14,8 @@ import 'package:ur/ur_decoder.dart';
var isQrScannerShown = false;
Future<String?> presentQRScanner(BuildContext context, {bool showHelp = false, bool showManualInput = true, bool useModal = false}) async {
Future<String?> presentQRScanner(BuildContext context,
{bool showHelp = false, bool showManualInput = true, bool useModal = false}) async {
isQrScannerShown = true;
try {
final result = useModal
+1 -1
View File
@@ -5,7 +5,7 @@ class QrViewData {
required this.data,
this.embeddedImagePath,
});
final int? version;
final String? heroTag;
final String data;
+1 -2
View File
@@ -1,4 +1,3 @@
enum SeedPhraseLength {
twelveWords(12),
twentyFourWords(24);
@@ -22,4 +21,4 @@ enum SeedPhraseLength {
}
return label;
}
}
}
+2 -1
View File
@@ -12,7 +12,8 @@ class MoneroSeedType extends EnumerableItem<int> with Serializable<int> {
static const defaultSeedType = polyseed;
static const legacy = MoneroSeedType(raw: 0, title: 'Legacy (25 words)', shortTitle: "Legacy");
static const polyseed = MoneroSeedType(raw: 1, title: 'Polyseed (16 words)', shortTitle: "Polyseed");
static const polyseed =
MoneroSeedType(raw: 1, title: 'Polyseed (16 words)', shortTitle: "Polyseed");
static const wowneroSeed = MoneroSeedType(raw: 2, title: 'Wownero');
static const bip39 = MoneroSeedType(raw: 3, title: 'BIP39 (12 words)', shortTitle: "BIP39");
+1 -2
View File
@@ -28,8 +28,7 @@ class ServicesResponse {
ServicesResponse(this.servicesStatus, this.hasUpdates, this.currentSha);
factory ServicesResponse.fromJson(
Map<String, dynamic> json, bool hasUpdates, String currentSha) {
factory ServicesResponse.fromJson(Map<String, dynamic> json, bool hasUpdates, String currentSha) {
return ServicesResponse(
(json['notices'] as List? ?? [])
.map((e) => ServiceStatus.fromJson(e as Map<String, dynamic>))
+1 -1
View File
@@ -16,4 +16,4 @@ enum SortBalanceBy {
return S.current.alphabetical;
}
}
}
}
+1 -3
View File
@@ -56,7 +56,5 @@ class TemplateAdapter extends TypeAdapter<Template> {
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is TemplateAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
other is TemplateAdapter && runtimeType == other.runtimeType && typeId == other.typeId;
}
@@ -1 +1 @@
abstract class TransactionCreationCredentials {}
abstract class TransactionCreationCredentials {}
+7 -6
View File
@@ -5,7 +5,8 @@ part 'transaction_description.part.dart';
// @HiveType(typeId: TransactionDescription.typeId)
class TransactionDescription extends HiveObject {
TransactionDescription({required this.id, this.recipientAddress, this.transactionNote, this.transactionKey});
TransactionDescription(
{required this.id, this.recipientAddress, this.transactionNote, this.transactionKey});
static const typeId = TRANSACTION_TYPE_ID;
static const boxName = 'TransactionDescriptions';
@@ -26,11 +27,11 @@ class TransactionDescription extends HiveObject {
String get note => transactionNote ?? '';
Map<String, dynamic> toJson() => {
'id': id,
'recipientAddress': recipientAddress,
'transactionNote': transactionNote,
'transactionKey': transactionKey,
};
'id': id,
'recipientAddress': recipientAddress,
'transactionNote': transactionNote,
'transactionKey': transactionKey,
};
factory TransactionDescription.fromJson(Map<String, dynamic> json) {
return TransactionDescription(
@@ -6,8 +6,7 @@ part of 'transaction_description.dart';
// TypeAdapterGenerator
// **************************************************************************
class TransactionDescriptionAdapter
extends TypeAdapter<TransactionDescription> {
class TransactionDescriptionAdapter extends TypeAdapter<TransactionDescription> {
@override
final int typeId = 2;
+1 -2
View File
@@ -2,8 +2,7 @@ import 'package:mobx/mobx.dart';
import 'package:cw_core/transaction_info.dart';
abstract class TransactionHistory {
TransactionHistory()
: transactions = Observable<List<TransactionInfo>>([]);
TransactionHistory() : transactions = Observable<List<TransactionInfo>>([]);
Observable<List<TransactionInfo>> transactions;
Future<List<TransactionInfo>> getAll();
+2 -2
View File
@@ -2,7 +2,7 @@ import 'package:cw_core/wallet_type.dart';
class WalletDescription {
WalletDescription({required this.name, required this.type});
final String name;
final WalletType type;
}
}
+4 -4
View File
@@ -165,11 +165,11 @@ class WalletManager {
String? getGroupName(WalletInfo walletInfo) {
try {
final groupKey = _resolveGroupKey(walletInfo);
final group = walletGroups.firstWhere((g) => g.groupKey == groupKey);
return group.groupName;
final groupKey = _resolveGroupKey(walletInfo);
final group = walletGroups.firstWhere((g) => g.groupKey == groupKey);
return group.groupName;
} catch (_) {
return null;
return null;
}
}
}
+1 -3
View File
@@ -43,8 +43,7 @@ class NFTAssetModel {
name: json['name'] as String?,
symbol: json['symbol'] as String?,
normalizedMetadata: json['normalized_metadata'] != null
? new NormalizedMetadata.fromJson(
json['normalized_metadata'] as Map<String, dynamic>)
? new NormalizedMetadata.fromJson(json['normalized_metadata'] as Map<String, dynamic>)
: null,
);
}
@@ -66,7 +65,6 @@ class NormalizedMetadata {
description: json['description'] as String?,
image: json['image'] as String?,
);
}
String? get imageUrl {