Skip to content

Commit

Permalink
[#19946] fix: reviewer feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen-ghafouri committed May 17, 2024
1 parent 8e6d7ba commit b25216b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions modules/react-native-status/ios/RCTStatus/NetworkManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
32 changes: 14 additions & 18 deletions src/status_im/contexts/settings/wallet/events.cljs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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}
Expand Down

0 comments on commit b25216b

Please sign in to comment.