-
Notifications
You must be signed in to change notification settings - Fork 982
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#20035] fix: improve tests and move effects to its own file
- Loading branch information
1 parent
cc9fb02
commit 7b9cc07
Showing
4 changed files
with
109 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
(ns status-im.contexts.settings.wallet.effects | ||
(:require [native-module.core :as native-module] | ||
[promesa.core :as promesa] | ||
[status-im.contexts.syncing.events :as syncing-events] | ||
[status-im.contexts.syncing.utils :as sync-utils] | ||
[utils.re-frame :as rf] | ||
[utils.security.core :as security] | ||
[utils.transforms :as transforms])) | ||
|
||
(rf/reg-fx :effects.connection-string/export-keypair | ||
(fn [{:keys [key-uid sha3-pwd keypair-key-uid on-success on-fail]}] | ||
(let [config-map (transforms/clj->json {:senderConfig {:loggedInKeyUid key-uid | ||
:keystorePath "" | ||
: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) | ||
(promesa/then (fn [response] | ||
(if (sync-utils/valid-connection-string? response) | ||
(on-success response) | ||
(on-fail (throw (js/Error. | ||
"generic-error: failed to get connection string")))))) | ||
(promesa/catch on-fail))))) | ||
|
||
(rf/reg-fx :effects.connection-string/import-keypair | ||
(fn [{:keys [key-uid sha3-pwd keypairs-key-uids connection-string on-success on-fail]}] | ||
(let [config-map (.stringify js/JSON | ||
(clj->js | ||
{:receiverConfig | ||
{:loggedInKeyUid key-uid | ||
:keystorePath "" | ||
:password (security/safe-unmask-data | ||
sha3-pwd) | ||
:keypairsToImport keypairs-key-uids}}))] | ||
(-> (native-module/input-connection-string-for-importing-keypairs-keystores | ||
connection-string | ||
config-map) | ||
(promesa/then (fn [res] | ||
(if-let [error (when (syncing-events/extract-error res) | ||
(str "generic-error: " res))] | ||
(on-fail error) | ||
(on-success keypairs-key-uids)))) | ||
(promesa/catch on-fail))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters