-
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.
[#19917] feat: integrate rename keypair rpc call
- Loading branch information
1 parent
979217e
commit d04db52
Showing
7 changed files
with
65 additions
and
8 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,32 @@ | ||
(ns status-im.contexts.settings.wallet.events | ||
(:require | ||
[taoensso.timbre :as log] | ||
[utils.i18n :as i18n] | ||
[utils.re-frame :as rf])) | ||
|
||
(rf/reg-event-fx | ||
:wallet/rename-keypair-success | ||
(fn [{:keys [db]} [key-uid name]] | ||
{:db (update-in db | ||
[:wallet :keypairs] | ||
(fn [keypairs] | ||
(map (fn [keypair] | ||
(if (= (keypair :key-uid) key-uid) | ||
(assoc keypair :name name) | ||
keypair)) | ||
keypairs))) | ||
:fx [[:dispatch [:navigate-back]] | ||
[:dispatch | ||
[:toasts/upsert | ||
{:type :positive | ||
:text (i18n/label :t/key-pair-name-updated)}]]]})) | ||
|
||
(defn rename-keypair | ||
[_ [{:keys [key-uid keypair-name]}]] | ||
{:fx [[:json-rpc/call | ||
[{:method "accounts_updateKeypairName" | ||
:params [key-uid keypair-name] | ||
:on-success [:wallet/rename-keypair-success key-uid keypair-name] | ||
:on-error #(log/info "failed to rename keypair " %)}]]]}) | ||
|
||
(rf/reg-event-fx :wallet/rename-keypair rename-keypair) |
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,17 @@ | ||
(ns status-im.contexts.settings.wallet.events-test | ||
(:require | ||
[cljs.test :refer-macros [deftest is testing]] | ||
matcher-combinators.test | ||
[status-im.contexts.settings.wallet.events :as events] | ||
[status-im.contexts.wallet.db :as db])) | ||
|
||
(deftest rename-keypair | ||
(testing "rename-keypair" | ||
(let [db {:wallet {}} | ||
expected-db {:wallet db/defaults} | ||
effects (events/rename-keypair | ||
{:db db} | ||
{:key-uid "0xfef454bb492ee4677594f8e05921c84f336fa811deb99b8d922477cc87a38b98" | ||
:keypair-name "Key pair 2"}) | ||
result-db (:db effects)] | ||
(is (match? result-db expected-db))))) |
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