From b25216be42b914cf3641414f241e283ceedc83c5 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Fri, 17 May 2024 22:10:03 +0300 Subject: [PATCH] [#19946] fix: reviewer feedbacks --- .../status/ethereum/module/NetworkManager.kt | 5 +++ .../ios/RCTStatus/NetworkManager.m | 6 ++++ .../contexts/settings/wallet/events.cljs | 32 ++++++++----------- .../keypairs_and_accounts/actions/view.cljs | 1 - .../encrypted_qr/view.cljs | 9 +++--- 5 files changed, 30 insertions(+), 23 deletions(-) diff --git a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/NetworkManager.kt b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/NetworkManager.kt index 6682901a9b2b..cc23f1dc8d1d 100644 --- a/modules/react-native-status/android/src/main/java/im/status/ethereum/module/NetworkManager.kt +++ b/modules/react-native-status/android/src/main/java/im/status/ethereum/module/NetworkManager.kt @@ -78,6 +78,11 @@ class NetworkManager(private val reactContext: ReactApplicationContext) : ReactC @ReactMethod fun getConnectionStringForExportingKeypairsKeystores(configJSON: String, callback: Callback) { val jsonConfig = JSONObject(configJSON) + val senderConfig = jsonConfig.getJSONObject("senderConfig") + val keyUID = senderConfig.getString("keyUID") + val keyStorePath = utils.getKeyStorePath(keyUID) + senderConfig.put("keystorePath", keyStorePath) + utils.executeRunnableStatusGoMethod( { Statusgo.getConnectionStringForExportingKeypairsKeystores(jsonConfig.toString()) }, callback) diff --git a/modules/react-native-status/ios/RCTStatus/NetworkManager.m b/modules/react-native-status/ios/RCTStatus/NetworkManager.m index 8cabdf6677bc..a3d10fca1bc7 100644 --- a/modules/react-native-status/ios/RCTStatus/NetworkManager.m +++ b/modules/react-native-status/ios/RCTStatus/NetworkManager.m @@ -112,6 +112,12 @@ @implementation NetworkManager NSData *configData = [configJSON dataUsingEncoding:NSUTF8StringEncoding]; NSError *error; NSMutableDictionary *configDict = [NSJSONSerialization JSONObjectWithData:configData options:NSJSONReadingMutableContainers error:&error]; + NSMutableDictionary *senderConfig = configDict[@"senderConfig"]; + NSString *keyUID = senderConfig[@"keyUID"]; + NSURL *multiaccountKeystoreDir = [Utils getKeyStoreDirForKeyUID:keyUID]; + NSString *keystoreDir = multiaccountKeystoreDir.path; + + [senderConfig setValue:keystoreDir forKey:@"keystorePath"]; NSString *modifiedConfigJSON = [Utils jsonStringWithPrettyPrint:NO fromDictionary:configDict]; NSString *result = StatusgoGetConnectionStringForExportingKeypairsKeystores(modifiedConfigJSON); diff --git a/src/status_im/contexts/settings/wallet/events.cljs b/src/status_im/contexts/settings/wallet/events.cljs index fc4e1723e8a1..08b171eb1316 100644 --- a/src/status_im/contexts/settings/wallet/events.cljs +++ b/src/status_im/contexts/settings/wallet/events.cljs @@ -1,12 +1,12 @@ (ns status-im.contexts.settings.wallet.events (:require - [clojure.string :as string] [native-module.core :as native-module] [status-im.contexts.syncing.utils :as sync-utils] [taoensso.timbre :as log] [utils.i18n :as i18n] [utils.re-frame :as rf] - [utils.security.core :as security])) + [utils.security.core :as security] + [utils.transforms :as transforms])) (rf/reg-event-fx :wallet/rename-keypair-success @@ -35,25 +35,21 @@ (rf/reg-event-fx :wallet/rename-keypair rename-keypair) -(defn key-pair-export-connection-string +(defn get-key-pair-export-connection [{:keys [db]} [{:keys [sha3-pwd keypair-key-uid callback]}]] - (let [error (get-in db [:profile/login :error]) + (let [key-uid (get-in db [:profile/profile :key-uid]) + config-map (transforms/clj->json {:senderConfig {:loggedInKeyUid key-uid + :keystorePath "" + :keypairsToExport [keypair-key-uid] + :password (security/safe-unmask-data + sha3-pwd)} + :serverConfig {:timeout 0}}) handle-connection (fn [response] - (println response) (when (sync-utils/valid-connection-string? response) (callback response) (rf/dispatch [:hide-bottom-sheet])))] - (when-not (and error (string/blank? error)) - (let [key-uid (get-in db [:profile/profile :key-uid]) - config-map (.stringify js/JSON - (clj->js {:senderConfig {:loggedInKeyUid key-uid - :keystorePath (native-module/keystore-dir) - :keypairsToExport [keypair-key-uid] - :password (security/safe-unmask-data - sha3-pwd)} - :serverConfig {:timeout 0}}))] - (native-module/get-connection-string-for-exporting-keypairs-keystores - config-map - handle-connection))))) + (native-module/get-connection-string-for-exporting-keypairs-keystores + config-map + handle-connection))) -(rf/reg-event-fx :wallet/get-key-pair-export-connection key-pair-export-connection-string) +(rf/reg-event-fx :wallet/get-key-pair-export-connection get-key-pair-export-connection) diff --git a/src/status_im/contexts/settings/wallet/keypairs_and_accounts/actions/view.cljs b/src/status_im/contexts/settings/wallet/keypairs_and_accounts/actions/view.cljs index f61f044d1956..1222dfc6bb30 100644 --- a/src/status_im/contexts/settings/wallet/keypairs_and_accounts/actions/view.cljs +++ b/src/status_im/contexts/settings/wallet/keypairs_and_accounts/actions/view.cljs @@ -14,7 +14,6 @@ (defn view [props data] (let [has-paired-device (rf/sub [:pairing/has-paired-devices])] - (println has-paired-device) [:<> [quo/drawer-top props] [quo/action-drawer diff --git a/src/status_im/contexts/settings/wallet/keypairs_and_accounts/encrypted_qr/view.cljs b/src/status_im/contexts/settings/wallet/keypairs_and_accounts/encrypted_qr/view.cljs index 4989b0cd79b0..a54d4ff3406f 100644 --- a/src/status_im/contexts/settings/wallet/keypairs_and_accounts/encrypted_qr/view.cljs +++ b/src/status_im/contexts/settings/wallet/keypairs_and_accounts/encrypted_qr/view.cljs @@ -20,6 +20,7 @@ (let [{:keys [key-uid]} (rf/sub [:get-screen-params]) {:keys [customization-color]} (rf/sub [:profile/profile-with-image]) [code set-code] (rn/use-state nil) + valid-connection-string? (rn/use-memo #(sync-utils/valid-connection-string? code) [code]) validate-and-set-code (rn/use-callback (fn [connection-string] (when (sync-utils/valid-connection-string? connection-string) @@ -47,7 +48,7 @@ :style {:color colors/white}} (i18n/label :t/encrypted-key-pairs)]] [rn/view {:style style/qr-container} - (if (sync-utils/valid-connection-string? code) + (if valid-connection-string? [qr-codes/qr-code {:url code}] [rn/view {:style {:flex-direction :row}} [rn/image @@ -56,7 +57,7 @@ :background-color colors/white-opa-70 :border-radius 12 :aspect-ratio 1}}]]) - (when (sync-utils/valid-connection-string? code) + (when valid-connection-string? [rn/view {:style style/valid-cs-container} [rn/view {:style style/sub-text-container} [quo/text @@ -80,7 +81,7 @@ :container-style {:margin-top 12} :icon-left :i/copy} (i18n/label :t/copy-qr)]]) - (when-not (sync-utils/valid-connection-string? code) + (when-not valid-connection-string? [rn/view {:style style/standard-auth} [standard-auth/slide-button {:blur? true @@ -90,7 +91,7 @@ :on-auth-success on-auth-success :auth-button-label (i18n/label :t/reveal-qr-code) :auth-button-icon-left :i/reveal}]])]] - (when-not (sync-utils/valid-connection-string? code) + (when-not valid-connection-string? [quo/text {:size :paragraph-2 :style style/warning-text}