-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
dafab10
commit e04c7f4
Showing
17 changed files
with
371 additions
and
71 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
(ns status-im.contexts.settings.wallet.data-store) | ||
|
||
(defn extract-keypair-name | ||
[db key-uids-set] | ||
(when (= (count key-uids-set) 1) | ||
(let [key-uid (first key-uids-set) | ||
keypairs (get-in db [:wallet :keypairs])] | ||
(->> (filter #(= (:key-uid %) key-uid) keypairs) | ||
first | ||
:name)))) | ||
|
||
(defn update-keypair | ||
[keypairs key-uid update-fn] | ||
(mapcat (fn [keypair] | ||
(if (= (keypair :key-uid) key-uid) | ||
(if-let [updated (update-fn keypair)] | ||
[updated] | ||
[]) | ||
[keypair])) | ||
keypairs)) | ||
|
||
(defn make-accounts-fully-operable | ||
[accounts key-uids-set] | ||
(reduce-kv | ||
(fn [acc k account] | ||
(if (and (contains? key-uids-set (:key-uid account)) | ||
(= (keyword (:operable account)) :no)) | ||
(assoc acc k (assoc account :operable :fully)) | ||
(assoc acc k account))) | ||
{} | ||
accounts)) | ||
|
||
(defn- make-keypairs-accounts-fully-operable | ||
[accounts] | ||
(map (fn [account] | ||
(assoc account :operable :fully)) | ||
accounts)) | ||
|
||
(defn make-keypairs-fully-operable | ||
[keypairs key-uids-set] | ||
(map (fn [keypair] | ||
(if (contains? key-uids-set (:key-uid keypair)) | ||
(update keypair | ||
:accounts | ||
make-keypairs-accounts-fully-operable) | ||
keypair)) | ||
keypairs)) |
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,38 @@ | ||
(ns status-im.contexts.settings.wallet.effects | ||
(:require [native-module.core :as native-module] | ||
[promesa.core :as promesa] | ||
[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 (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 (transforms/clj->json {: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 #(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
Oops, something went wrong.