From 367c36b4d5c2d57d98c9ec058854274517846bb3 Mon Sep 17 00:00:00 2001 From: cyan Date: Mon, 25 Nov 2024 17:00:37 +0100 Subject: [PATCH 1/9] fix sed (#1829) --- scripts/android/inject_app_details.sh | 12 ++++++------ scripts/universal_sed.sh | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/android/inject_app_details.sh b/scripts/android/inject_app_details.sh index 737ebbb88..9a8b12d9c 100755 --- a/scripts/android/inject_app_details.sh +++ b/scripts/android/inject_app_details.sh @@ -6,10 +6,10 @@ if [ -z "$APP_ANDROID_TYPE" ]; then fi cd ../.. -set -x -universal_sed "0,/version:/{s/version:.*/version: ${APP_ANDROID_VERSION}+${APP_ANDROID_BUILD_NUMBER}/}" ./pubspec.yaml -universal_sed "0,/version:/{s/__APP_PACKAGE__/${APP_ANDROID_PACKAGE}/}" ./android/app/src/main/AndroidManifest.xml -universal_sed "0,/__APP_SCHEME__/s/__APP_SCHEME__/${APP_ANDROID_SCHEME}/" ./android/app/src/main/AndroidManifest.xml -universal_sed "0,/version:/{s/__versionCode__/${APP_ANDROID_BUILD_NUMBER}/}" ./android/app/src/main/AndroidManifest.xml -universal_sed "0,/version:/{s/__versionName__/${APP_ANDROID_VERSION}/}" ./android/app/src/main/AndroidManifest.xml +universal_sed "0,/version:/ {s/version:.*/version: ${APP_ANDROID_VERSION}+${APP_ANDROID_BUILD_NUMBER}/;}" ./pubspec.yaml +universal_sed "0,/version:/ {s/__APP_PACKAGE__/${APP_ANDROID_PACKAGE}/;}" ./android/app/src/main/AndroidManifest.xml +universal_sed "0,/__APP_SCHEME__/ {s/__APP_SCHEME__/${APP_ANDROID_SCHEME}/;}" ./android/app/src/main/AndroidManifest.xml +universal_sed "0,/version:/ {s/__versionCode__/${APP_ANDROID_BUILD_NUMBER}/;}" ./android/app/src/main/AndroidManifest.xml +universal_sed "0,/version:/ {s/__versionName__/${APP_ANDROID_VERSION}/;}" ./android/app/src/main/AndroidManifest.xml + cd scripts/android diff --git a/scripts/universal_sed.sh b/scripts/universal_sed.sh index 8c0e3d9a4..d8a95684e 100644 --- a/scripts/universal_sed.sh +++ b/scripts/universal_sed.sh @@ -13,7 +13,6 @@ universal_sed() { local file=$2 if [[ "$SED_TYPE" == "GNU" ]]; then - pwd sed -i "$expression" "$file" else sed -i '' "$expression" "$file" From 59e8550e4e194b54dd828ff7064fede3b4224c84 Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Mon, 25 Nov 2024 18:26:41 +0200 Subject: [PATCH 2/9] Generic fixes (#1823) * add timeout for mempool fee api and make it only in bitcoin * disable Monero Ledger for desktop * handle onramper tag issue * better handle main actions UI * make service status scrollable with a better UI * fix stupid race condition * minor handling * update btc fee api update our xmr node to use ssl * manually add supported unstoppable domains for now * change bitcoin default node code enhancement * revert debugging code [skip ci] * minor enhancements [skip ci] * increase sync indicator size [skip ci] * fix selecting USA country not triggering the reaction * fix scrolling on cake features page [skip ci] --- assets/bitcoin_electrum_server_list.yml | 3 - assets/node_list.yml | 1 + cw_bitcoin/lib/electrum_wallet.dart | 7 +- cw_monero/lib/api/wallet_manager.dart | 14 +- lib/buy/onramper/onramper_buy_provider.dart | 8 +- lib/entities/default_settings_migration.dart | 70 ++++++++-- lib/entities/main_actions.dart | 4 +- lib/entities/parse_address_from_domain.dart | 91 +++++++++--- lib/main.dart | 3 +- lib/reactions/on_current_wallet_change.dart | 2 + lib/src/screens/dashboard/dashboard_page.dart | 46 ++++--- .../dashboard/pages/cake_features_page.dart | 130 ++++++++---------- .../widgets/sync_indicator_icon.dart | 2 +- lib/src/widgets/blockchain_height_widget.dart | 12 +- lib/src/widgets/services_updates_widget.dart | 10 +- lib/store/app_store.dart | 4 +- .../cake_pay_cards_list_view_model.dart | 6 +- res/values/strings_fr.arb | 2 +- scripts/macos/app_env.sh | 8 +- 19 files changed, 271 insertions(+), 152 deletions(-) diff --git a/assets/bitcoin_electrum_server_list.yml b/assets/bitcoin_electrum_server_list.yml index 20a28cd24..83da6a0b2 100644 --- a/assets/bitcoin_electrum_server_list.yml +++ b/assets/bitcoin_electrum_server_list.yml @@ -1,6 +1,3 @@ -- - uri: electrum.cakewallet.com:50002 - useSSL: true - uri: btc-electrum.cakewallet.com:50002 useSSL: true diff --git a/assets/node_list.yml b/assets/node_list.yml index 6191129b3..49cc00a94 100644 --- a/assets/node_list.yml +++ b/assets/node_list.yml @@ -2,6 +2,7 @@ uri: xmr-node.cakewallet.com:18081 is_default: true trusted: true + useSSL: true - uri: cakexmrl7bonq7ovjka5kuwuyd3f7qnkz6z6s6dmsy3uckwra7bvggyd.onion:18081 is_default: false diff --git a/cw_bitcoin/lib/electrum_wallet.dart b/cw_bitcoin/lib/electrum_wallet.dart index e58fad00f..73f7e09f5 100644 --- a/cw_bitcoin/lib/electrum_wallet.dart +++ b/cw_bitcoin/lib/electrum_wallet.dart @@ -486,10 +486,11 @@ abstract class ElectrumWalletBase @action Future updateFeeRates() async { - if (await checkIfMempoolAPIIsEnabled()) { + if (await checkIfMempoolAPIIsEnabled() && type == WalletType.bitcoin) { try { - final response = - await http.get(Uri.parse("http://mempool.cakewallet.com:8999/api/v1/fees/recommended")); + final response = await http + .get(Uri.parse("https://mempool.cakewallet.com/api/v1/fees/recommended")) + .timeout(Duration(seconds: 5)); final result = json.decode(response.body) as Map; final slowFee = (result['economyFee'] as num?)?.toInt() ?? 0; diff --git a/cw_monero/lib/api/wallet_manager.dart b/cw_monero/lib/api/wallet_manager.dart index 7f9dbd8fa..d10f7e25a 100644 --- a/cw_monero/lib/api/wallet_manager.dart +++ b/cw_monero/lib/api/wallet_manager.dart @@ -286,8 +286,18 @@ Future loadWallet( /// 0: Software Wallet /// 1: Ledger /// 2: Trezor - final deviceType = monero.WalletManager_queryWalletDevice(wmPtr, - keysFileName: "$path.keys", password: password, kdfRounds: 1); + late final deviceType; + + if (Platform.isAndroid || Platform.isIOS) { + deviceType = monero.WalletManager_queryWalletDevice( + wmPtr, + keysFileName: "$path.keys", + password: password, + kdfRounds: 1, + ); + } else { + deviceType = 0; + } if (deviceType == 1) { final dummyWPtr = wptr ?? diff --git a/lib/buy/onramper/onramper_buy_provider.dart b/lib/buy/onramper/onramper_buy_provider.dart index dade41d43..e4bf38275 100644 --- a/lib/buy/onramper/onramper_buy_provider.dart +++ b/lib/buy/onramper/onramper_buy_provider.dart @@ -251,8 +251,12 @@ class OnRamperBuyProvider extends BuyProvider { return tag; case 'POL': return 'POLYGON'; - default: - return CryptoCurrency.fromString(tag).fullName ?? tag; + default: + try { + return CryptoCurrency.fromString(tag).fullName!; + } catch (_) { + return tag; + } } } diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index f873314c0..9e0e3457d 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -260,10 +260,22 @@ Future defaultSettingsMigration( updateBtcElectrumNodeToUseSSL(nodes, sharedPreferences); break; case 43: - _updateCakeXmrNode(nodes); + await _updateCakeXmrNode(nodes); _deselectExchangeProvider(sharedPreferences, "THORChain"); _deselectExchangeProvider(sharedPreferences, "SimpleSwap"); break; + case 44: + await _updateCakeXmrNode(nodes); + await _changeDefaultNode( + nodes: nodes, + sharedPreferences: sharedPreferences, + type: WalletType.bitcoin, + newDefaultUri: newCakeWalletBitcoinUri, + currentNodePreferenceKey: PreferencesKey.currentBitcoinElectrumSererIdKey, + useSSL: true, + oldUri: 'cakewallet.com', + ); + break; default: break; @@ -279,17 +291,54 @@ Future defaultSettingsMigration( await sharedPreferences.setInt(PreferencesKey.currentDefaultSettingsMigrationVersion, version); } -void _updateCakeXmrNode(Box nodes) { +/// generic function for changing any wallet default node +/// instead of making a new function for each change +Future _changeDefaultNode({ + required Box nodes, + required SharedPreferences sharedPreferences, + required WalletType type, + required String newDefaultUri, + required String currentNodePreferenceKey, + required bool useSSL, + required String oldUri, // leave empty if you want to force replace the node regardless of the user's current node +}) async { + final currentNodeId = sharedPreferences.getInt(currentNodePreferenceKey); + final currentNode = nodes.values.firstWhere((node) => node.key == currentNodeId); + final shouldReplace = currentNode.uriRaw.contains(oldUri); + + if (shouldReplace) { + var newNodeId = + nodes.values.firstWhereOrNull((element) => element.uriRaw == newDefaultUri)?.key; + + // new node doesn't exist, then add it + if (newNodeId == null) { + final newNode = Node( + uri: newDefaultUri, + type: type, + useSSL: useSSL, + ); + + await nodes.add(newNode); + newNodeId = newNode.key; + } + + await sharedPreferences.setInt(currentNodePreferenceKey, newNodeId as int); + } +} + +Future _updateCakeXmrNode(Box nodes) async { final node = nodes.values.firstWhereOrNull((element) => element.uriRaw == newCakeWalletMoneroUri); - if (node != null && !node.trusted) { + if (node != null) { node.trusted = true; - node.save(); + node.useSSL = true; + await node.save(); } } void updateBtcElectrumNodeToUseSSL(Box nodes, SharedPreferences sharedPreferences) { - final btcElectrumNode = nodes.values.firstWhereOrNull((element) => element.uriRaw == newCakeWalletBitcoinUri); + final btcElectrumNode = + nodes.values.firstWhereOrNull((element) => element.uriRaw == newCakeWalletBitcoinUri); if (btcElectrumNode != null) { btcElectrumNode.useSSL = true; @@ -538,7 +587,6 @@ Node? getBitcoinCashDefaultElectrumServer({required Box nodes}) { } Node getMoneroDefaultNode({required Box nodes}) { - final timeZone = DateTime.now().timeZoneOffset.inHours; var nodeUri = newCakeWalletMoneroUri; try { @@ -858,7 +906,8 @@ Future changeDefaultMoneroNode( } }); - final newCakeWalletNode = Node(uri: newCakeWalletMoneroUri, type: WalletType.monero, trusted: true); + final newCakeWalletNode = + Node(uri: newCakeWalletMoneroUri, type: WalletType.monero, trusted: true); await nodeSource.add(newCakeWalletNode); @@ -897,7 +946,7 @@ Future updateBtcNanoWalletInfos(Box walletsInfoSource) async { Future changeDefaultNanoNode( Box nodeSource, SharedPreferences sharedPreferences) async { const oldNanoNodeUriPattern = 'rpc.nano.to'; - final currentNanoNodeId = sharedPreferences.getInt(PreferencesKey.currentNodeIdKey); + final currentNanoNodeId = sharedPreferences.getInt(PreferencesKey.currentNanoNodeIdKey); final currentNanoNode = nodeSource.values.firstWhere((node) => node.key == currentNanoNodeId); final newCakeWalletNode = Node( @@ -909,7 +958,8 @@ Future changeDefaultNanoNode( await nodeSource.add(newCakeWalletNode); if (currentNanoNode.uri.toString().contains(oldNanoNodeUriPattern)) { - await sharedPreferences.setInt(PreferencesKey.currentNodeIdKey, newCakeWalletNode.key as int); + await sharedPreferences.setInt( + PreferencesKey.currentNanoNodeIdKey, newCakeWalletNode.key as int); } } @@ -924,7 +974,7 @@ Future changeDefaultBitcoinNode( currentBitcoinNode.uri.toString().contains(cakeWalletBitcoinNodeUriPattern); final newCakeWalletBitcoinNode = - Node(uri: newCakeWalletBitcoinUri, type: WalletType.bitcoin, useSSL: false); + Node(uri: newCakeWalletBitcoinUri, type: WalletType.bitcoin, useSSL: true); if (!nodeSource.values.any((element) => element.uriRaw == newCakeWalletBitcoinUri)) { await nodeSource.add(newCakeWalletBitcoinNode); diff --git a/lib/entities/main_actions.dart b/lib/entities/main_actions.dart index 94be0d2b7..29c161c5f 100644 --- a/lib/entities/main_actions.dart +++ b/lib/entities/main_actions.dart @@ -1,7 +1,5 @@ import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/routes.dart'; -import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; -import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:flutter/material.dart'; @@ -68,7 +66,7 @@ class MainActions { static MainActions tradeAction = MainActions._( - name: (context) => '${S.of(context).buy} / ${S.of(context).sell}', + name: (context) => '${S.of(context).buy}/${S.of(context).sell}', image: 'assets/images/buy_sell.png', isEnabled: (viewModel) => viewModel.isEnabledTradeAction, canShow: (viewModel) => viewModel.hasTradeAction, diff --git a/lib/entities/parse_address_from_domain.dart b/lib/entities/parse_address_from_domain.dart index 11ba4724c..42ab19b31 100644 --- a/lib/entities/parse_address_from_domain.dart +++ b/lib/entities/parse_address_from_domain.dart @@ -26,23 +26,80 @@ class AddressResolver { final SettingsStore settingsStore; static const unstoppableDomains = [ - 'crypto', - 'zil', - 'x', - 'wallet', - 'bitcoin', - '888', - 'nft', - 'dao', - 'blockchain', - 'polygon', - 'klever', - 'hi', - 'kresus', - 'anime', - 'manga', - 'binanceus', - 'xmr', + "888", + "altimist", + "anime", + "austin", + "bald", + "benji", + "bet", + "binanceus", + "bitcoin", + "bitget", + "blockchain", + "ca", + "chomp", + "clay", + "co", + "com", + "crypto", + "dao", + "dfz", + "digital", + "dream", + "eth", + "ethermail", + "farms", + "fun", + "go", + "group", + "hi", + "host", + "info", + "io", + "klever", + "kresus", + "kryptic", + "lfg", + "life", + "live", + "ltd", + "manga", + "metropolis", + "moon", + "mumu", + "net", + "nft", + "online", + "org", + "pog", + "polygon", + "press", + "pro", + "propykeys", + "pudgy", + "pw", + "raiin", + "secret", + "site", + "smobler", + "space", + "stepn", + "store", + "tball", + "tech", + "ubu", + "uno", + "unstoppable", + "wallet", + "website", + "wifi", + "witg", + "wrkx", + "x", + "xmr", + "xyz", + "zil", ]; static String? extractAddressByType({required String raw, required CryptoCurrency type}) { diff --git a/lib/main.dart b/lib/main.dart index 51fab4dd1..d67fda098 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -16,7 +16,6 @@ import 'package:cake_wallet/exchange/exchange_template.dart'; import 'package:cake_wallet/exchange/trade.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/locales/locale.dart'; -import 'package:cake_wallet/monero/monero.dart'; import 'package:cake_wallet/reactions/bootstrap.dart'; import 'package:cake_wallet/router.dart' as Router; import 'package:cake_wallet/routes.dart'; @@ -204,7 +203,7 @@ Future initializeAppConfigs() async { transactionDescriptions: transactionDescriptions, secureStorage: secureStorage, anonpayInvoiceInfo: anonpayInvoiceInfo, - initialMigrationVersion: 43, + initialMigrationVersion: 44, ); } diff --git a/lib/reactions/on_current_wallet_change.dart b/lib/reactions/on_current_wallet_change.dart index d7e6f90c0..b804ff14e 100644 --- a/lib/reactions/on_current_wallet_change.dart +++ b/lib/reactions/on_current_wallet_change.dart @@ -63,6 +63,8 @@ void startCurrentWalletChangeReaction( startWalletSyncStatusChangeReaction(wallet, fiatConversionStore); startCheckConnectionReaction(wallet, settingsStore); + await Future.delayed(Duration.zero); + if (wallet.type == WalletType.monero || wallet.type == WalletType.wownero || wallet.type == WalletType.bitcoin || diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 9c012d518..cabf73b21 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -291,32 +291,34 @@ class _DashboardPageView extends BasePage { children: MainActions.all .where((element) => element.canShow?.call(dashboardViewModel) ?? true) .map( - (action) => Semantics( - button: true, - enabled: (action.isEnabled?.call(dashboardViewModel) ?? true), - child: ActionButton( - key: ValueKey( - 'dashboard_page_${action.name(context)}_action_button_key'), - image: Image.asset( - action.image, - height: 24, - width: 24, - color: action.isEnabled?.call(dashboardViewModel) ?? true - ? Theme.of(context) - .extension()! - .mainActionsIconColor + (action) => Expanded( + child: Semantics( + button: true, + enabled: (action.isEnabled?.call(dashboardViewModel) ?? true), + child: ActionButton( + key: ValueKey( + 'dashboard_page_${action.name(context)}_action_button_key'), + image: Image.asset( + action.image, + height: 24, + width: 24, + color: action.isEnabled?.call(dashboardViewModel) ?? true + ? Theme.of(context) + .extension()! + .mainActionsIconColor + : Theme.of(context) + .extension()! + .labelTextColor, + ), + title: action.name(context), + onClick: () async => + await action.onTap(context, dashboardViewModel), + textColor: action.isEnabled?.call(dashboardViewModel) ?? true + ? null : Theme.of(context) .extension()! .labelTextColor, ), - title: action.name(context), - onClick: () async => - await action.onTap(context, dashboardViewModel), - textColor: action.isEnabled?.call(dashboardViewModel) ?? true - ? null - : Theme.of(context) - .extension()! - .labelTextColor, ), ), ) diff --git a/lib/src/screens/dashboard/pages/cake_features_page.dart b/lib/src/screens/dashboard/pages/cake_features_page.dart index 37bc3a55f..775cb6c3f 100644 --- a/lib/src/screens/dashboard/pages/cake_features_page.dart +++ b/lib/src/screens/dashboard/pages/cake_features_page.dart @@ -10,91 +10,81 @@ import 'package:cake_wallet/view_model/dashboard/cake_features_view_model.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'package:flutter_svg/flutter_svg.dart'; class CakeFeaturesPage extends StatelessWidget { CakeFeaturesPage({required this.dashboardViewModel, required this.cakeFeaturesViewModel}); final DashboardViewModel dashboardViewModel; final CakeFeaturesViewModel cakeFeaturesViewModel; - final _scrollController = ScrollController(); @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 10.0), - child: RawScrollbar( - thumbColor: Colors.white.withOpacity(0.15), - radius: Radius.circular(20), - thumbVisibility: true, - thickness: 2, - controller: _scrollController, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox(height: 50), - Text( - 'Cake ${S.of(context).features}', - style: TextStyle( - fontSize: 24, - fontWeight: FontWeight.w500, - color: Theme.of(context).extension()!.pageTitleTextColor, - ), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height: 50), + Text( + 'Cake ${S.of(context).features}', + style: TextStyle( + fontSize: 24, + fontWeight: FontWeight.w500, + color: Theme.of(context).extension()!.pageTitleTextColor, ), - Expanded( - child: ListView( - controller: _scrollController, - children: [ - SizedBox(height: 20), - DashBoardRoundedCardWidget( - onTap: () => _navigatorToGiftCardsPage(context), - title: 'Cake Pay', - subTitle: S.of(context).cake_pay_subtitle, - image: Image.asset( - 'assets/images/cards.png', - height: 100, - width: 115, - fit: BoxFit.cover, - ), + ), + Expanded( + child: ListView( + children: [ + SizedBox(height: 20), + DashBoardRoundedCardWidget( + onTap: () => _navigatorToGiftCardsPage(context), + title: 'Cake Pay', + subTitle: S.of(context).cake_pay_subtitle, + image: Image.asset( + 'assets/images/cards.png', + height: 100, + width: 115, + fit: BoxFit.cover, ), - SizedBox(height: 10), - DashBoardRoundedCardWidget( - onTap: () => _launchUrl("cake.nano-gpt.com"), - title: "NanoGPT", - subTitle: S.of(context).nanogpt_subtitle, - image: Image.asset( - 'assets/images/nanogpt.png', - height: 80, - width: 80, - fit: BoxFit.cover, - ), + ), + SizedBox(height: 10), + DashBoardRoundedCardWidget( + onTap: () => _launchUrl("cake.nano-gpt.com"), + title: "NanoGPT", + subTitle: S.of(context).nanogpt_subtitle, + image: Image.asset( + 'assets/images/nanogpt.png', + height: 80, + width: 80, + fit: BoxFit.cover, ), - SizedBox(height: 10), - Observer( - builder: (context) { - if (!dashboardViewModel.hasSignMessages) { - return const SizedBox(); - } - return DashBoardRoundedCardWidget( - onTap: () => Navigator.of(context).pushNamed(Routes.signPage), - title: S.current.sign_verify_message, - subTitle: S.current.sign_verify_message_sub, - icon: Icon( - Icons.speaker_notes_rounded, - color: - Theme.of(context).extension()!.pageTitleTextColor, - size: 75, - ), - ); - }, - ), - ], - ), + ), + SizedBox(height: 10), + Observer( + builder: (context) { + if (!dashboardViewModel.hasSignMessages) { + return const SizedBox(); + } + return DashBoardRoundedCardWidget( + onTap: () => Navigator.of(context).pushNamed(Routes.signPage), + title: S.current.sign_verify_message, + subTitle: S.current.sign_verify_message_sub, + icon: Icon( + Icons.speaker_notes_rounded, + color: + Theme.of(context).extension()!.pageTitleTextColor, + size: 75, + ), + ); + }, + ), + ], ), - ], - ), + ), + ], ), ), ); diff --git a/lib/src/screens/dashboard/widgets/sync_indicator_icon.dart b/lib/src/screens/dashboard/widgets/sync_indicator_icon.dart index 21133a438..aca3231ec 100644 --- a/lib/src/screens/dashboard/widgets/sync_indicator_icon.dart +++ b/lib/src/screens/dashboard/widgets/sync_indicator_icon.dart @@ -8,7 +8,7 @@ class SyncIndicatorIcon extends StatelessWidget { {this.boolMode = true, this.isSynced = false, this.value = waiting, - this.size = 4.0}); + this.size = 6.0}); final bool boolMode; final bool isSynced; diff --git a/lib/src/widgets/blockchain_height_widget.dart b/lib/src/widgets/blockchain_height_widget.dart index 1c6b6da02..650ee684d 100644 --- a/lib/src/widgets/blockchain_height_widget.dart +++ b/lib/src/widgets/blockchain_height_widget.dart @@ -191,11 +191,13 @@ class BlockchainHeightState extends State { height = wownero!.getHeightByDate(date: date); } } - setState(() { - dateController.text = DateFormat('yyyy-MM-dd').format(date); - restoreHeightController.text = '$height'; - _changeHeight(height); - }); + if (mounted) { + setState(() { + dateController.text = DateFormat('yyyy-MM-dd').format(date); + restoreHeightController.text = '$height'; + _changeHeight(height); + }); + } } } diff --git a/lib/src/widgets/services_updates_widget.dart b/lib/src/widgets/services_updates_widget.dart index 1787b7118..17f231303 100644 --- a/lib/src/widgets/services_updates_widget.dart +++ b/lib/src/widgets/services_updates_widget.dart @@ -92,15 +92,17 @@ class _ServicesUpdatesWidgetState extends State { ); } return Padding( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 20), - child: Stack( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: Column( children: [ - body, + Expanded(child: body), Align( alignment: Alignment.bottomCenter, child: Padding( padding: EdgeInsets.symmetric( - horizontal: MediaQuery.of(context).size.width / 8), + horizontal: MediaQuery.of(context).size.width / 8, + vertical: 20, + ), child: PrimaryImageButton( onPressed: () { try { diff --git a/lib/store/app_store.dart b/lib/store/app_store.dart index 24d5dc6a4..ff3ba0535 100644 --- a/lib/store/app_store.dart +++ b/lib/store/app_store.dart @@ -50,8 +50,8 @@ abstract class AppStoreBase with Store { getIt.get().create(); await getIt.get().init(); } - await getIt.get().setString(PreferencesKey.currentWalletName, wallet.name); - await getIt + getIt.get().setString(PreferencesKey.currentWalletName, wallet.name); + getIt .get() .setInt(PreferencesKey.currentWalletType, serializeToInt(wallet.type)); } diff --git a/lib/view_model/cake_pay/cake_pay_cards_list_view_model.dart b/lib/view_model/cake_pay/cake_pay_cards_list_view_model.dart index 8585da9da..442bd51b4 100644 --- a/lib/view_model/cake_pay/cake_pay_cards_list_view_model.dart +++ b/lib/view_model/cake_pay/cake_pay_cards_list_view_model.dart @@ -204,7 +204,11 @@ abstract class CakePayCardsListViewModelBase with Store { } @action - void setSelectedCountry(Country country) => settingsStore.selectedCakePayCountry = country; + void setSelectedCountry(Country country) { + // just so it triggers the reaction even when selecting the default country + settingsStore.selectedCakePayCountry = null; + settingsStore.selectedCakePayCountry = country; + } @action void togglePrepaidCards() => displayPrepaidCards = !displayPrepaidCards; diff --git a/res/values/strings_fr.arb b/res/values/strings_fr.arb index 549ec5275..741adc472 100644 --- a/res/values/strings_fr.arb +++ b/res/values/strings_fr.arb @@ -919,7 +919,7 @@ "wallet_seed_legacy": "Graine de portefeuille hérité", "wallet_store_monero_wallet": "Portefeuille (Wallet) Monero", "walletConnect": "WalletConnect", - "wallets": "Portefeuilles (Wallets)", + "wallets": "Portefeuilles", "warning": "Avertissement", "welcome": "Bienvenue sur", "welcome_to_cakepay": "Bienvenue sur Cake Pay !", diff --git a/scripts/macos/app_env.sh b/scripts/macos/app_env.sh index 8f3b68ab5..930a1e5ed 100755 --- a/scripts/macos/app_env.sh +++ b/scripts/macos/app_env.sh @@ -16,13 +16,13 @@ if [ -n "$1" ]; then fi MONERO_COM_NAME="Monero.com" -MONERO_COM_VERSION="1.8.0" -MONERO_COM_BUILD_NUMBER=36 +MONERO_COM_VERSION="1.8.1" +MONERO_COM_BUILD_NUMBER=37 MONERO_COM_BUNDLE_ID="com.cakewallet.monero" CAKEWALLET_NAME="Cake Wallet" -CAKEWALLET_VERSION="1.14.0" -CAKEWALLET_BUILD_NUMBER=95 +CAKEWALLET_VERSION="1.14.1" +CAKEWALLET_BUILD_NUMBER=96 CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet" if ! [[ " ${TYPES[*]} " =~ " ${APP_MACOS_TYPE} " ]]; then From 8ceaa013ebfd6edb00b80d6fb46dc74f8e1e1ab7 Mon Sep 17 00:00:00 2001 From: cyan Date: Mon, 25 Nov 2024 19:55:05 +0100 Subject: [PATCH 3/9] Fix sed (again) (#1830) * fix sed * 0, -> 1, so it doesn't silently error out * remve hardcoded CONFIG_ARGS --- scripts/android/inject_app_details.sh | 10 +++++----- scripts/ios/app_config.sh | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/android/inject_app_details.sh b/scripts/android/inject_app_details.sh index 9a8b12d9c..2e50ea31b 100755 --- a/scripts/android/inject_app_details.sh +++ b/scripts/android/inject_app_details.sh @@ -6,10 +6,10 @@ if [ -z "$APP_ANDROID_TYPE" ]; then fi cd ../.. -universal_sed "0,/version:/ {s/version:.*/version: ${APP_ANDROID_VERSION}+${APP_ANDROID_BUILD_NUMBER}/;}" ./pubspec.yaml -universal_sed "0,/version:/ {s/__APP_PACKAGE__/${APP_ANDROID_PACKAGE}/;}" ./android/app/src/main/AndroidManifest.xml -universal_sed "0,/__APP_SCHEME__/ {s/__APP_SCHEME__/${APP_ANDROID_SCHEME}/;}" ./android/app/src/main/AndroidManifest.xml -universal_sed "0,/version:/ {s/__versionCode__/${APP_ANDROID_BUILD_NUMBER}/;}" ./android/app/src/main/AndroidManifest.xml -universal_sed "0,/version:/ {s/__versionName__/${APP_ANDROID_VERSION}/;}" ./android/app/src/main/AndroidManifest.xml +universal_sed "1,/version:/ {s/version:.*/version: ${APP_ANDROID_VERSION}+${APP_ANDROID_BUILD_NUMBER}/;}" ./pubspec.yaml +universal_sed "1,/version:/ {s/__APP_PACKAGE__/${APP_ANDROID_PACKAGE}/;}" ./android/app/src/main/AndroidManifest.xml +universal_sed "1,/__APP_SCHEME__/ {s/__APP_SCHEME__/${APP_ANDROID_SCHEME}/;}" ./android/app/src/main/AndroidManifest.xml +universal_sed "1,/version:/ {s/__versionCode__/${APP_ANDROID_BUILD_NUMBER}/;}" ./android/app/src/main/AndroidManifest.xml +universal_sed "1,/version:/ {s/__versionName__/${APP_ANDROID_VERSION}/;}" ./android/app/src/main/AndroidManifest.xml cd scripts/android diff --git a/scripts/ios/app_config.sh b/scripts/ios/app_config.sh index 8b217dc54..396ccd7f0 100755 --- a/scripts/ios/app_config.sh +++ b/scripts/ios/app_config.sh @@ -43,7 +43,6 @@ case $APP_IOS_TYPE in CONFIG_ARGS="--haven" ;; esac -CONFIG_ARGS="--monero --ethereum --polygon --nano --solana --tron --wownero" cp -rf pubspec_description.yaml pubspec.yaml flutter pub get From 83cfc7dd703c04613c6b83f2a9234a3c98229660 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Mon, 25 Nov 2024 21:05:36 +0200 Subject: [PATCH 4/9] fix building with haven --- cw_haven/android/build.gradle | 18 +++++++++++++++--- cw_shared_external/android/build.gradle | 15 ++++++++++++++- linux/flutter/generated_plugins.cmake | 1 + macos/Flutter/GeneratedPluginRegistrant.swift | 2 ++ pubspec_base.yaml | 2 +- scripts/android/inject_app_details.sh | 2 +- windows/flutter/generated_plugins.cmake | 1 + 7 files changed, 35 insertions(+), 6 deletions(-) diff --git a/cw_haven/android/build.gradle b/cw_haven/android/build.gradle index d29c31d4e..8eb728a67 100644 --- a/cw_haven/android/build.gradle +++ b/cw_haven/android/build.gradle @@ -2,14 +2,14 @@ group 'com.cakewallet.cw_haven' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.7.10' + ext.kotlin_version = '2.0.21' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.3.0' + classpath 'com.android.tools.build:gradle:8.7.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -25,8 +25,20 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 28 + compileSdkVersion 33 + if (project.android.hasProperty("namespace")) { + namespace 'com.cakewallet.cw_haven' + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = '17' + } sourceSets { main.java.srcDirs += 'src/main/kotlin' } diff --git a/cw_shared_external/android/build.gradle b/cw_shared_external/android/build.gradle index 64b550364..8d2b1b13d 100644 --- a/cw_shared_external/android/build.gradle +++ b/cw_shared_external/android/build.gradle @@ -25,7 +25,20 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 30 + compileSdkVersion 33 + + if (project.android.hasProperty("namespace")) { + namespace 'com.cakewallet.cw_shared_external' + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = '17' + } sourceSets { main.java.srcDirs += 'src/main/kotlin' diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 4b9eb3b2d..f52be7481 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -10,6 +10,7 @@ list(APPEND FLUTTER_PLUGIN_LIST ) list(APPEND FLUTTER_FFI_PLUGIN_LIST + sp_scanner ) set(PLUGIN_BUNDLED_LIBRARIES) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 52b44e53e..42b9fa84c 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -6,6 +6,7 @@ import FlutterMacOS import Foundation import connectivity_plus +import cw_mweb import device_info_plus import devicelocale import fast_scanner @@ -23,6 +24,7 @@ import wakelock_plus func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) + CwMwebPlugin.register(with: registry.registrar(forPlugin: "CwMwebPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) DevicelocalePlugin.register(with: registry.registrar(forPlugin: "DevicelocalePlugin")) MobileScannerPlugin.register(with: registry.registrar(forPlugin: "MobileScannerPlugin")) diff --git a/pubspec_base.yaml b/pubspec_base.yaml index 39fe953d0..221f1d9bf 100644 --- a/pubspec_base.yaml +++ b/pubspec_base.yaml @@ -26,7 +26,7 @@ dependencies: share_plus: ^10.0.0 # date_range_picker: ^1.0.6 #https://api.flutter.dev/flutter/material/showDateRangePicker.html - dio: ^4.0.6 + dio: ^5.7.0 hive: ^2.2.3 hive_flutter: ^1.1.0 local_auth_android: ^1.0.46 diff --git a/scripts/android/inject_app_details.sh b/scripts/android/inject_app_details.sh index 2e50ea31b..7b0d74798 100755 --- a/scripts/android/inject_app_details.sh +++ b/scripts/android/inject_app_details.sh @@ -6,10 +6,10 @@ if [ -z "$APP_ANDROID_TYPE" ]; then fi cd ../.. +set -x universal_sed "1,/version:/ {s/version:.*/version: ${APP_ANDROID_VERSION}+${APP_ANDROID_BUILD_NUMBER}/;}" ./pubspec.yaml universal_sed "1,/version:/ {s/__APP_PACKAGE__/${APP_ANDROID_PACKAGE}/;}" ./android/app/src/main/AndroidManifest.xml universal_sed "1,/__APP_SCHEME__/ {s/__APP_SCHEME__/${APP_ANDROID_SCHEME}/;}" ./android/app/src/main/AndroidManifest.xml universal_sed "1,/version:/ {s/__versionCode__/${APP_ANDROID_BUILD_NUMBER}/;}" ./android/app/src/main/AndroidManifest.xml universal_sed "1,/version:/ {s/__versionName__/${APP_ANDROID_VERSION}/;}" ./android/app/src/main/AndroidManifest.xml - cd scripts/android diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index f8f89611c..e0f2c11c0 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -14,6 +14,7 @@ list(APPEND FLUTTER_PLUGIN_LIST ) list(APPEND FLUTTER_FFI_PLUGIN_LIST + sp_scanner ) set(PLUGIN_BUNDLED_LIBRARIES) From 09bc186feadd5ad3048060a38757a9cb5f33b94a Mon Sep 17 00:00:00 2001 From: cyan Date: Tue, 26 Nov 2024 14:40:26 +0100 Subject: [PATCH 5/9] Cw 835 investigate failed to get earliest block height when sending monero (#1827) * update flutter to 3.24.3 * bump flutter to 3.24.4, fix all android issues (i hope) * update uni_links path * update sensitive_clipboard * update dependencies * update fast_scanner * update the ref * Update how_to_add_new_wallet_type.md [skip ci] * Update how_to_add_new_wallet_type.md [skip ci] * Update how_to_add_new_wallet_type.md [skip ci] * Update how_to_add_new_wallet_type.md [skip ci] * CW-835: Fix failed to get earlist block height when sending monero --------- Co-authored-by: Omar Hatem --- cw_monero/lib/api/transaction_history.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cw_monero/lib/api/transaction_history.dart b/cw_monero/lib/api/transaction_history.dart index f55545801..a00a6b206 100644 --- a/cw_monero/lib/api/transaction_history.dart +++ b/cw_monero/lib/api/transaction_history.dart @@ -91,12 +91,19 @@ Future createTransactionSync( List preferredInputs = const []}) async { final amt = amount == null ? 0 : monero.Wallet_amountFromString(amount); - + + final waddr = wptr!.address; + + // force reconnection in case the os killed the connection? + // fixes failed to get block height error. + Isolate.run(() async { + monero.Wallet_synchronized(Pointer.fromAddress(waddr)); + }); + final address_ = address.toNativeUtf8(); final paymentId_ = paymentId.toNativeUtf8(); final preferredInputs_ = preferredInputs.join(monero.defaultSeparatorStr).toNativeUtf8(); - final waddr = wptr!.address; final addraddr = address_.address; final paymentIdAddr = paymentId_.address; final preferredInputsAddr = preferredInputs_.address; From 738731d3e51ede6b40ad11ab9893d5e0ee86f664 Mon Sep 17 00:00:00 2001 From: cyan Date: Tue, 26 Nov 2024 14:43:56 +0100 Subject: [PATCH 6/9] CW-826 Fix missing tx keys in monero (#1828) * CW-826 Fix missing tx keys in monero * force store wallet * don't return error string --- cw_monero/lib/api/transaction_history.dart | 13 ++----------- cw_monero/lib/api/wallet.dart | 5 +++-- cw_monero/lib/pending_monero_transaction.dart | 2 ++ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/cw_monero/lib/api/transaction_history.dart b/cw_monero/lib/api/transaction_history.dart index a00a6b206..662eb1bb5 100644 --- a/cw_monero/lib/api/transaction_history.dart +++ b/cw_monero/lib/api/transaction_history.dart @@ -17,7 +17,7 @@ String getTxKey(String txId) { final status = monero.Wallet_status(wptr!); if (status != 0) { final error = monero.Wallet_errorString(wptr!); - return txId+"_"+error; + return ""; } return txKey; } @@ -364,16 +364,7 @@ class Transaction { confirmations = monero.TransactionInfo_confirmations(txInfo), fee = monero.TransactionInfo_fee(txInfo), description = monero.TransactionInfo_description(txInfo), - key = getTxKey(txInfo); - - static String getTxKey(monero.TransactionInfo txInfo) { - final txKey = monero.Wallet_getTxKey(wptr!, txid: monero.TransactionInfo_hash(txInfo)); - final status = monero.Wallet_status(wptr!); - if (status != 0) { - return ""; - } - return txKey; - } + key = getTxKey(monero.TransactionInfo_hash(txInfo)); Transaction.dummy({ required this.displayLabel, diff --git a/cw_monero/lib/api/wallet.dart b/cw_monero/lib/api/wallet.dart index 928fd7ef1..70c610418 100644 --- a/cw_monero/lib/api/wallet.dart +++ b/cw_monero/lib/api/wallet.dart @@ -150,14 +150,15 @@ final storeMutex = Mutex(); int lastStorePointer = 0; int lastStoreHeight = 0; -void storeSync() async { +void storeSync({bool force = false}) async { final addr = wptr!.address; final synchronized = await Isolate.run(() { return monero.Wallet_synchronized(Pointer.fromAddress(addr)); }); if (lastStorePointer == wptr!.address && lastStoreHeight + 5000 > monero.Wallet_blockChainHeight(wptr!) && - !synchronized) { + !synchronized && + !force) { return; } lastStorePointer = wptr!.address; diff --git a/cw_monero/lib/pending_monero_transaction.dart b/cw_monero/lib/pending_monero_transaction.dart index eb714eeb3..1c01a60dc 100644 --- a/cw_monero/lib/pending_monero_transaction.dart +++ b/cw_monero/lib/pending_monero_transaction.dart @@ -6,6 +6,7 @@ import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/amount_converter.dart'; import 'package:cw_core/pending_transaction.dart'; +import 'package:cw_monero/api/wallet.dart'; class DoubleSpendException implements Exception { DoubleSpendException(); @@ -53,6 +54,7 @@ class PendingMoneroTransaction with PendingTransaction { rethrow; } + storeSync(force: true); } @override From eff6616981cd2fe453e0322e5d8e05f30ab6b4c0 Mon Sep 17 00:00:00 2001 From: Seth For Privacy <40500387+sethforprivacy@users.noreply.github.com> Date: Tue, 26 Nov 2024 09:56:00 -0500 Subject: [PATCH 7/9] Migrate to new self-hosted mempool.space instance (#1820) Co-authored-by: Omar Hatem --- cw_bitcoin/lib/electrum_wallet.dart | 4 ++-- cw_core/lib/get_height_by_date.dart | 2 +- lib/view_model/transaction_details_view_model.dart | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cw_bitcoin/lib/electrum_wallet.dart b/cw_bitcoin/lib/electrum_wallet.dart index 73f7e09f5..c29df3c4a 100644 --- a/cw_bitcoin/lib/electrum_wallet.dart +++ b/cw_bitcoin/lib/electrum_wallet.dart @@ -1707,7 +1707,7 @@ abstract class ElectrumWalletBase try { final blockHash = await http.get( Uri.parse( - "http://mempool.cakewallet.com:8999/api/v1/block-height/$height", + "https://mempool.cakewallet.com/api/v1/block-height/$height", ), ); @@ -1716,7 +1716,7 @@ abstract class ElectrumWalletBase jsonDecode(blockHash.body) != null) { final blockResponse = await http.get( Uri.parse( - "http://mempool.cakewallet.com:8999/api/v1/block/${blockHash.body}", + "https://mempool.cakewallet.com/api/v1/block/${blockHash.body}", ), ); if (blockResponse.statusCode == 200 && diff --git a/cw_core/lib/get_height_by_date.dart b/cw_core/lib/get_height_by_date.dart index 2b0b77a89..7929d7cbd 100644 --- a/cw_core/lib/get_height_by_date.dart +++ b/cw_core/lib/get_height_by_date.dart @@ -270,7 +270,7 @@ const bitcoinDates = { Future getBitcoinHeightByDateAPI({required DateTime date}) async { final response = await http.get( Uri.parse( - "http://mempool.cakewallet.com:8999/api/v1/mining/blocks/timestamp/${(date.millisecondsSinceEpoch / 1000).round()}", + "https://mempool.cakewallet.com/api/v1/mining/blocks/timestamp/${(date.millisecondsSinceEpoch / 1000).round()}", ), ); diff --git a/lib/view_model/transaction_details_view_model.dart b/lib/view_model/transaction_details_view_model.dart index a189ebe6c..e675acf17 100644 --- a/lib/view_model/transaction_details_view_model.dart +++ b/lib/view_model/transaction_details_view_model.dart @@ -159,7 +159,7 @@ abstract class TransactionDetailsViewModelBase with Store { case WalletType.monero: return 'https://monero.com/tx/${txId}'; case WalletType.bitcoin: - return 'https://mempool.space/${wallet.isTestnet ? "testnet/" : ""}tx/${txId}'; + return 'https://mempool.cakewallet.com/${wallet.isTestnet ? "testnet/" : ""}tx/${txId}'; case WalletType.litecoin: return 'https://blockchair.com/litecoin/transaction/${txId}'; case WalletType.bitcoinCash: From 765ae877126a71b580c09bbf9c329f03c96e1f5d Mon Sep 17 00:00:00 2001 From: cyan Date: Tue, 26 Nov 2024 15:59:22 +0100 Subject: [PATCH 8/9] Automatically upgrade non-SSL nodes to SSL if they fail (#1757) * Automatically upgrade non-SSL nodes to SSL if they fail * another ssl catch * [skip ci] pr fixes --- cw_core/lib/node.dart | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/cw_core/lib/node.dart b/cw_core/lib/node.dart index 1094b6402..18d2ffc44 100644 --- a/cw_core/lib/node.dart +++ b/cw_core/lib/node.dart @@ -203,9 +203,30 @@ class Node extends HiveObject with Keyable { headers: {'Content-Type': 'application/json'}, body: json.encode(body), ); - client.close(); + if (( + response.body.contains("400 Bad Request") // Some other generic error + || response.body.contains("plain HTTP request was sent to HTTPS port") // Cloudflare + || response.headers["location"] != null // Generic reverse proxy + || response.body.contains("301 Moved Permanently") // Poorly configured generic reverse proxy + ) && !(useSSL??false) + ) { + + final oldUseSSL = useSSL; + useSSL = true; + try { + final ret = await requestMoneroNode(); + if (ret == true) { + await save(); + return ret; + } + useSSL = oldUseSSL; + } catch (e) { + useSSL = oldUseSSL; + } + } + final resBody = json.decode(response.body) as Map; return !(resBody['result']['offline'] as bool); } catch (_) { From 9706243c81d4c6d0888846a09c5ef5874c5cd53f Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Wed, 27 Nov 2024 02:20:08 +0200 Subject: [PATCH 9/9] change default tron node to nowNodes if not already --- lib/entities/default_settings_migration.dart | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index 9e0e3457d..7f0679625 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -273,7 +273,19 @@ Future defaultSettingsMigration( newDefaultUri: newCakeWalletBitcoinUri, currentNodePreferenceKey: PreferencesKey.currentBitcoinElectrumSererIdKey, useSSL: true, - oldUri: 'cakewallet.com', + oldUri: ['cakewallet.com'], + ); + _changeDefaultNode( + nodes: nodes, + sharedPreferences: sharedPreferences, + type: WalletType.tron, + newDefaultUri: tronDefaultNodeUri, + currentNodePreferenceKey: PreferencesKey.currentTronNodeIdKey, + useSSL: true, + oldUri: [ + 'tron-rpc.publicnode.com:443', + 'api.trongrid.io', + ], ); break; @@ -300,11 +312,11 @@ Future _changeDefaultNode({ required String newDefaultUri, required String currentNodePreferenceKey, required bool useSSL, - required String oldUri, // leave empty if you want to force replace the node regardless of the user's current node + required List oldUri, // leave empty if you want to force replace the node regardless of the user's current node }) async { final currentNodeId = sharedPreferences.getInt(currentNodePreferenceKey); final currentNode = nodes.values.firstWhere((node) => node.key == currentNodeId); - final shouldReplace = currentNode.uriRaw.contains(oldUri); + final shouldReplace = oldUri.any((e) => currentNode.uriRaw.contains(e)); if (shouldReplace) { var newNodeId =