From 156ea8cd99192f187269f0f9d2574a7aa29023e9 Mon Sep 17 00:00:00 2001 From: Alex Ruzenhack Date: Thu, 15 Aug 2024 23:40:42 +0100 Subject: [PATCH 1/2] refactor: replace network identification logic by the lib method --- package-lock.json | 19 +++++++++++-------- src/sagas/networkSettings.js | 16 ++-------------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7bd731fa0..b2fa08760 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@fortawesome/free-solid-svg-icons": "6.4.0", "@fortawesome/react-native-fontawesome": "0.2.7", "@hathor/unleash-client": "0.1.0", - "@hathor/wallet-lib": "1.8.0", + "@hathor/wallet-lib": "1.9.0", "@notifee/react-native": "5.7.0", "@react-native-async-storage/async-storage": "1.19.0", "@react-native-firebase/app": "16.7.0", @@ -2550,10 +2550,12 @@ } }, "node_modules/@hathor/wallet-lib": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@hathor/wallet-lib/-/wallet-lib-1.8.0.tgz", - "integrity": "sha512-G1kLlxZ4Ev3S7hPiq/y9wUl4ns4pndOvuK37q+xqdxieZKCl2/O7lXiiHVOgRN9xOntL/TR66n2UZPpe0p29zQ==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@hathor/wallet-lib/-/wallet-lib-1.9.0.tgz", + "integrity": "sha512-8m6sr/PObnRoCsmalV2AqKO+tMPyzI/Lw/eJ0KgtaZSn7drBeFlDRhYyEilxpFqq9BCzvx18i8tXAudFoW2OUQ==", + "license": "MIT", "dependencies": { + "abstract-level": "1.0.4", "axios": "1.7.2", "bitcore-lib": "8.25.10", "bitcore-mnemonic": "8.25.10", @@ -2563,7 +2565,7 @@ "level": "8.0.1", "lodash": "4.17.21", "long": "5.2.3", - "ws": "8.17.0" + "ws": "8.17.1" }, "engines": { "node": ">=20.0.0", @@ -2599,9 +2601,10 @@ "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==" }, "node_modules/@hathor/wallet-lib/node_modules/ws": { - "version": "8.17.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.0.tgz", - "integrity": "sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", + "license": "MIT", "engines": { "node": ">=10.0.0" }, diff --git a/src/sagas/networkSettings.js b/src/sagas/networkSettings.js index 6b9b7bced..69dcd53dc 100644 --- a/src/sagas/networkSettings.js +++ b/src/sagas/networkSettings.js @@ -1,5 +1,5 @@ import { all, takeEvery, put, call, race, delay, select } from 'redux-saga/effects'; -import { config } from '@hathor/wallet-lib'; +import { config, helpersUtils } from '@hathor/wallet-lib'; import { isEmpty } from 'lodash'; import { t } from 'ttag'; import { @@ -22,7 +22,6 @@ import { STAGE_DEV_PRIVNET, STAGE_TESTNET, WALLET_SERVICE_REQUEST_TIMEOUT, - NETWORK_PRIVATENET, } from '../constants'; import { getFullnodeNetwork, @@ -154,7 +153,6 @@ export function* updateNetworkSettings(action) { // - walletServiceUrl has precedence // - nodeUrl as fallback let potentialNetwork; - let network; if (useWalletService && !isEmpty(walletServiceUrl)) { log.debug('Configuring wallet-service on custom network settings.'); config.setWalletServiceBaseUrl(walletServiceUrl); @@ -194,17 +192,7 @@ export function* updateNetworkSettings(action) { return; } - // Validates the potential network and set the network accordingly - if (potentialNetwork === NETWORK_MAINNET) { - network = NETWORK_MAINNET; - } else if (potentialNetwork.includes(NETWORK_TESTNET)) { - network = NETWORK_TESTNET; - } else if (potentialNetwork.includes(NETWORK_PRIVATENET)) { - network = NETWORK_PRIVATENET; - } else { - yield put(networkSettingsUpdateFailure()); - return; - } + const network = helpersUtils.getNetworkFromFullNodeNetwork(potentialNetwork); let stage; if (network === NETWORK_MAINNET) { From 9f6364d64e21848d8f16d36861b1bb45df0c7286 Mon Sep 17 00:00:00 2001 From: Alex Ruzenhack Date: Mon, 19 Aug 2024 17:17:39 +0100 Subject: [PATCH 2/2] chore: upgrade hathor-wallet-lib to v1.9.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 860be7e8d..fc695b30a 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@fortawesome/free-solid-svg-icons": "6.4.0", "@fortawesome/react-native-fontawesome": "0.2.7", "@hathor/unleash-client": "0.1.0", - "@hathor/wallet-lib": "1.8.0", + "@hathor/wallet-lib": "1.9.0", "@notifee/react-native": "5.7.0", "@react-native-async-storage/async-storage": "1.19.0", "@react-native-firebase/app": "16.7.0",