-
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
d982f3d
commit 5828db1
Showing
6 changed files
with
66 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,20 @@ | ||
(ns status-im.contexts.settings.wallet.events-test | ||
(:require | ||
[cljs.test :refer-macros [deftest is]] | ||
matcher-combinators.test | ||
[status-im.contexts.settings.wallet.events :as sut])) | ||
|
||
(def key-uid "0xfef454bb492ee4677594f8e05921c84f336fa811deb99b8d922477cc87a38b98") | ||
|
||
(deftest rename-keypair-test | ||
(let [new-keypair-name "key pair new" | ||
cofx {:db {}} | ||
expected {:fx [[:json-rpc/call | ||
[{:method "accounts_updateKeypairName" | ||
:params [key-uid new-keypair-name] | ||
:on-success [:wallet/rename-keypair-success key-uid new-keypair-name] | ||
:on-error fn?}]]]}] | ||
(is (match? expected | ||
(sut/rename-keypair cofx | ||
[{:key-uid key-uid | ||
:keypair-name new-keypair-name}]))))) |
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