await settings migration

This commit is contained in:
OmarHatem 2025-01-08 05:09:45 +02:00
parent d1c45a5326
commit 55005f8b39
5 changed files with 24 additions and 14 deletions

View file

@ -70,8 +70,13 @@ Future<void> defaultSettingsMigration(
await sharedPreferences.setBool(PreferencesKey.isNewInstall, isNewInstall); await sharedPreferences.setBool(PreferencesKey.isNewInstall, isNewInstall);
final currentVersion = int currentVersion =
sharedPreferences.getInt(PreferencesKey.currentDefaultSettingsMigrationVersion) ?? 0; sharedPreferences.getInt(PreferencesKey.currentDefaultSettingsMigrationVersion) ?? 0;
// TODO: remove after v4.22.1 is live
/// for beta testers who didn't correctly get the 46 step configured
if (currentVersion == 46) {
currentVersion--;
}
if (currentVersion >= version) { if (currentVersion >= version) {
return; return;
@ -334,20 +339,20 @@ Future<void> defaultSettingsMigration(
); );
break; break;
case 46: case 46:
_fixNodesUseSSLFlag(nodes); await _fixNodesUseSSLFlag(nodes);
updateWalletTypeNodesWithNewNode( await updateWalletTypeNodesWithNewNode(
newNodeUri: 'litecoin.stackwallet.com:20063', newNodeUri: 'litecoin.stackwallet.com:20063',
nodes: nodes, nodes: nodes,
type: WalletType.litecoin, type: WalletType.litecoin,
useSSL: true, useSSL: true,
); );
updateWalletTypeNodesWithNewNode( await updateWalletTypeNodesWithNewNode(
newNodeUri: 'electrum-ltc.bysh.me:50002', newNodeUri: 'electrum-ltc.bysh.me:50002',
nodes: nodes, nodes: nodes,
type: WalletType.litecoin, type: WalletType.litecoin,
useSSL: true, useSSL: true,
); );
_changeDefaultNode( await _changeDefaultNode(
nodes: nodes, nodes: nodes,
sharedPreferences: sharedPreferences, sharedPreferences: sharedPreferences,
type: WalletType.solana, type: WalletType.solana,
@ -360,13 +365,13 @@ Future<void> defaultSettingsMigration(
'solana-rpc.publicnode.com:443', 'solana-rpc.publicnode.com:443',
], ],
); );
_updateNode( await _updateNode(
nodes: nodes, nodes: nodes,
currentUri: "ethereum.publicnode.com", currentUri: "ethereum.publicnode.com",
newUri: "ethereum-rpc.publicnode.com", newUri: "ethereum-rpc.publicnode.com",
useSSL: true, useSSL: true,
); );
_updateNode( await _updateNode(
nodes: nodes, nodes: nodes,
currentUri: "polygon-bor.publicnode.com", currentUri: "polygon-bor.publicnode.com",
newUri: "polygon-bor-rpc.publicnode.com", newUri: "polygon-bor-rpc.publicnode.com",
@ -387,13 +392,16 @@ Future<void> defaultSettingsMigration(
await sharedPreferences.setInt(PreferencesKey.currentDefaultSettingsMigrationVersion, version); await sharedPreferences.setInt(PreferencesKey.currentDefaultSettingsMigrationVersion, version);
} }
void _updateNode({ Future<void> _updateNode({
required Box<Node> nodes, required Box<Node> nodes,
required String currentUri, required String currentUri,
String? newUri, String? newUri,
bool? useSSL, bool? useSSL,
}) { }) async {
for (Node node in nodes.values) { for (Node node in nodes.values) {
print("@@@@@@@@@@@@@");
print(node.uriRaw);
print(node.uri);
if (node.uriRaw == currentUri) { if (node.uriRaw == currentUri) {
if (newUri != null) { if (newUri != null) {
node.uriRaw = newUri; node.uriRaw = newUri;
@ -401,6 +409,7 @@ void _updateNode({
if (useSSL != null) { if (useSSL != null) {
node.useSSL = useSSL; node.useSSL = useSSL;
} }
await node.save();
} }
} }
} }
@ -481,7 +490,7 @@ void _deselectExchangeProvider(SharedPreferences sharedPreferences, String provi
); );
} }
void _fixNodesUseSSLFlag(Box<Node> nodes) { Future<void> _fixNodesUseSSLFlag(Box<Node> nodes) async {
for (Node node in nodes.values) { for (Node node in nodes.values) {
switch (node.uriRaw) { switch (node.uriRaw) {
case cakeWalletLitecoinElectrumUri: case cakeWalletLitecoinElectrumUri:
@ -490,6 +499,7 @@ void _fixNodesUseSSLFlag(Box<Node> nodes) {
case newCakeWalletMoneroUri: case newCakeWalletMoneroUri:
node.useSSL = true; node.useSSL = true;
node.trusted = true; node.trusted = true;
await node.save();
} }
} }
} }

View file

@ -23,7 +23,7 @@ MONERO_COM_SCHEME="monero.com"
CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="4.22.1" CAKEWALLET_VERSION="4.22.1"
CAKEWALLET_BUILD_NUMBER=241 CAKEWALLET_BUILD_NUMBER=242
CAKEWALLET_BUNDLE_ID="com.cakewallet.cake_wallet" CAKEWALLET_BUNDLE_ID="com.cakewallet.cake_wallet"
CAKEWALLET_PACKAGE="com.cakewallet.cake_wallet" CAKEWALLET_PACKAGE="com.cakewallet.cake_wallet"
CAKEWALLET_SCHEME="cakewallet" CAKEWALLET_SCHEME="cakewallet"

View file

@ -19,7 +19,7 @@ MONERO_COM_BUNDLE_ID="com.cakewallet.monero"
CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="4.22.1" CAKEWALLET_VERSION="4.22.1"
CAKEWALLET_BUILD_NUMBER=288 CAKEWALLET_BUILD_NUMBER=289
CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet" CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"
HAVEN_NAME="Haven" HAVEN_NAME="Haven"

View file

@ -15,7 +15,7 @@ fi
CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="1.12.1" CAKEWALLET_VERSION="1.12.1"
CAKEWALLET_BUILD_NUMBER=42 CAKEWALLET_BUILD_NUMBER=43
if ! [[ " ${TYPES[*]} " =~ " ${APP_LINUX_TYPE} " ]]; then if ! [[ " ${TYPES[*]} " =~ " ${APP_LINUX_TYPE} " ]]; then
echo "Wrong app type." echo "Wrong app type."

View file

@ -22,7 +22,7 @@ MONERO_COM_BUNDLE_ID="com.cakewallet.monero"
CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="1.15.1" CAKEWALLET_VERSION="1.15.1"
CAKEWALLET_BUILD_NUMBER=100 CAKEWALLET_BUILD_NUMBER=101
CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet" CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet"
if ! [[ " ${TYPES[*]} " =~ " ${APP_MACOS_TYPE} " ]]; then if ! [[ " ${TYPES[*]} " =~ " ${APP_MACOS_TYPE} " ]]; then