Skip to content

Commit

Permalink
WIP: fixing keypair account gen
Browse files Browse the repository at this point in the history
  • Loading branch information
ulisesmac committed Apr 8, 2024
1 parent 3d2132b commit 55b1600
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
17 changes: 14 additions & 3 deletions src/status_im/contexts/wallet/create_account/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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}}]))
Expand All @@ -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
Expand All @@ -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
Expand Down
27 changes: 13 additions & 14 deletions src/status_im/contexts/wallet/events/accounts.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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}))}]]]}))
1 change: 1 addition & 0 deletions src/status_im/subs/wallet/wallet.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit 55b1600

Please sign in to comment.