From 55b1600345d91c66d84de6a86e7c386b2b964305 Mon Sep 17 00:00:00 2001 From: Ulises M Date: Mon, 8 Apr 2024 13:58:33 -0600 Subject: [PATCH] WIP: fixing keypair account gen --- .../contexts/wallet/create_account/view.cljs | 17 +++++++++--- .../contexts/wallet/events/accounts.cljs | 27 +++++++++---------- src/status_im/subs/wallet/wallet.cljs | 1 + 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/status_im/contexts/wallet/create_account/view.cljs b/src/status_im/contexts/wallet/create_account/view.cljs index 78936cae0e2c..c7ecc7c4ee97 100644 --- a/src/status_im/contexts/wallet/create_account/view.cljs +++ b/src/status_im/contexts/wallet/create_account/view.cljs @@ -53,7 +53,7 @@ :auth-button-label (i18n/label :t/continue)}]) (js/alert "Coming soon!")) :button-text (i18n/label :t/edit) - :icon-left :i/face-id + :icon-left :i/edit :alignment :flex-start} :description :text :description-props {:text formatted-path}}])) @@ -74,7 +74,16 @@ (let [{:keys [customization-color address]} (rf/sub [:profile/profile]) {:keys [new-keypair]} (rf/sub [:wallet/create-account]) + _ (println + "\n" + new-keypair "\n" + "-----\n") selected-keypair (rf/sub [:wallet/selected-keypair]) + _ (println "\n" + (:key-uid selected-keypair) "\n" + @derivation-path + "________\n") + primary? (rf/sub [:wallet/selected-keypair-primary?]) placeholder (i18n/label :t/default-account-placeholder) create-new-keypair-account #(rf/dispatch @@ -101,8 +110,10 @@ (:name selected-keypair)))] (rn/use-effect #(rf/dispatch - [:wallet/new-derivation-path-for-selected-keypair set-derivation-path]) - []) + [:wallet/new-derivation-path-for-selected-keypair {:on-success set-derivation-path + :keypair-uid (or (:keyUid new-keypair) + (:key-uid selected-keypair))}]) + [(:key-uid selected-keypair) (:keyUid new-keypair)]) (rn/use-unmount #(rf/dispatch [:wallet/clear-new-keypair])) [floating-button-page/view diff --git a/src/status_im/contexts/wallet/events/accounts.cljs b/src/status_im/contexts/wallet/events/accounts.cljs index 67bddf72972c..be408d028d29 100644 --- a/src/status_im/contexts/wallet/events/accounts.cljs +++ b/src/status_im/contexts/wallet/events/accounts.cljs @@ -3,17 +3,16 @@ [utils.re-frame :as rf])) (rf/reg-event-fx - :wallet/new-derivation-path-for-selected-keypair - (fn [{db :db} [on-success]] - (let [selected-keypair (-> db :wallet :keypairs :selected-keypair-uid)] - {:fx [[:json-rpc/call - [{:method "accounts_resolveSuggestedPathForKeypair" - :params [selected-keypair] - :on-success on-success - :on-error (fn [error] - (log/error - "Failed to resolve next path derivation path" - {:event :wallet/new-derivation-path-for-selected-keypair - :method "accounts_resolveSuggestedPathForKeypair" - :error error - :params selected-keypair}))}]]]}))) + :wallet/new-derivation-path + (fn [_ [{:keys [on-success keypair-uid]}]] + {:fx [[:json-rpc/call + [{:method "accounts_resolveSuggestedPathForKeypair" + :params [keypair-uid] + :on-success on-success + :on-error (fn [error] + (log/error + "Failed to resolve next path derivation path" + {:event :wallet/new-derivation-path + :method "accounts_resolveSuggestedPathForKeypair" + :error error + :params keypair-uid}))}]]]})) diff --git a/src/status_im/subs/wallet/wallet.cljs b/src/status_im/subs/wallet/wallet.cljs index 4efd60304d87..faaa7985eb44 100644 --- a/src/status_im/subs/wallet/wallet.cljs +++ b/src/status_im/subs/wallet/wallet.cljs @@ -130,6 +130,7 @@ :<- [:wallet/keypairs] :<- [:wallet/selected-keypair-uid] (fn [[keypairs selected-keypair-uid]] + (def --kps keypairs) (some #(when (= (:key-uid %) selected-keypair-uid) %) keypairs)))