From f08ac945966c069b574c9e4dfefc4c15cdc450ed Mon Sep 17 00:00:00 2001 From: flexsurfer Date: Mon, 2 Dec 2024 14:57:03 +0100 Subject: [PATCH] [#21686] User can not sign transactions after Login/Sign up flows using Keycard (#21699) --- .../add_account/create_account/events.cljs | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/status_im/contexts/wallet/add_account/create_account/events.cljs b/src/status_im/contexts/wallet/add_account/create_account/events.cljs index 50f1e6e011..6660b768f1 100644 --- a/src/status_im/contexts/wallet/add_account/create_account/events.cljs +++ b/src/status_im/contexts/wallet/add_account/create_account/events.cljs @@ -15,11 +15,26 @@ (let [parsed-keypairs (data-store/rpc->keypairs keypairs) default-key-uid (->> parsed-keypairs (some #(when (= (:type %) :profile) %)) - :key-uid)] + :key-uid) + keycard? (get-in db [:profile/profile :keycard-pairing]) + keypair (first parsed-keypairs) + keycard (when (and keycard? (= (count parsed-keypairs) 1) (empty? (:keycards keypair))) + {:keycard-uid (get-in db [:profile/profile :keycard-instance-uid]) + :key-uid default-key-uid + :keycard-name "" + :accounts-addresses [(some #(when (:wallet %) (:address %)) + (:accounts keypair))]})] {:db (-> db - (assoc-in [:wallet :keypairs] (utils.collection/index-by :key-uid parsed-keypairs)) - (assoc-in [:wallet :ui :create-account :selected-keypair-uid] default-key-uid))})) - + (assoc-in [:wallet :keypairs] + (cond-> (utils.collection/index-by :key-uid parsed-keypairs) + keycard + (assoc-in [default-key-uid :keycards] [keycard]))) + (assoc-in [:wallet :ui :create-account :selected-keypair-uid] default-key-uid)) + ;; this is a temporary solution, should be done properly in statu-go instead + :fx [(when keycard + [:json-rpc/call + [{:method "accounts_saveOrUpdateKeycard" + :params [keycard true]}]])]})) (rf/reg-event-fx :wallet/get-keypairs-success get-keypairs-success) (defn confirm-account-origin