-
Notifications
You must be signed in to change notification settings - Fork 983
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#20035] fix: apply suggestion and add tests
- Loading branch information
1 parent
62507bc
commit efe5550
Showing
9 changed files
with
265 additions
and
184 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
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
Oops, something went wrong.