[#21836] Relative derivation paths are not supported by keycard (#21888)

This commit is contained in:
flexsurfer 2025-01-15 12:27:51 +01:00 committed by GitHub
parent 04a97faa43
commit 8687282d63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 33 additions and 24 deletions

View File

@ -7,6 +7,7 @@
[status-im.contexts.profile.utils :as profile.utils]
[status-im.contexts.shell.constants :as constants]
[status-im.contexts.wallet.account.tabs.about.style :as style]
[status-im.contexts.wallet.add-account.create-account.utils :as create-account.utils]
[status-im.contexts.wallet.common.utils :as utils]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
@ -103,5 +104,5 @@
:stored (if keypair-keycard? :on-keycard :on-device)
:profile-picture (profile.utils/photo profile)
:customization-color customization-color
:derivation-path path
:derivation-path (create-account.utils/normalize-path path)
:keypair-name keypair-name}])]))

View File

@ -1,5 +1,6 @@
(ns status-im.contexts.wallet.add-account.create-account.utils
(:require [status-im.constants :as constants]))
(:require [clojure.string :as string]
[status-im.constants :as constants]))
(defn first-derived-account
[account-data keypair-type]
@ -56,3 +57,13 @@
:derived-from address
:last-used-derivation-index 0
:accounts [account-config]}))
(defn legacy-path?
[s]
(re-matches #"m/\d+" s))
(defn normalize-path
[path]
(if (legacy-path? path)
(str constants/path-wallet-root "/" (last (string/split path "/")))
path))

View File

@ -12,6 +12,7 @@
[status-im.common.standard-authentication.core :as standard-auth]
[status-im.constants :as constants]
[status-im.contexts.wallet.add-account.create-account.style :as style]
[status-im.contexts.wallet.add-account.create-account.utils :as create-account.utils]
[status-im.contexts.wallet.common.utils :as common.utils]
[status-im.contexts.wallet.sheets.account-origin.view :as account-origin]
[status-im.feature-flags :as ff]
@ -255,11 +256,12 @@
{:on-complete
#(rf/dispatch
[:keycard/connect-derive-address-and-add-account
{:pin %
{:pin %
:derived-from-address derived-from
:key-uid key-uid
:derivation-path @derivation-path
:account-preferences preferences}])}])))
:key-uid key-uid
:derivation-path (create-account.utils/normalize-path
@derivation-path)
:account-preferences preferences}])}])))
[derived-from])]
(rn/use-effect
#(rf/dispatch

View File

@ -15,24 +15,19 @@
(defn new-account
[]
(let [keycard? (rf/sub [:keycard/keycard-profile?])]
[quo/action-drawer
[[{:icon :i/add
:accessibility-label :start-a-new-chat
:label (i18n/label :t/add-account)
:sub-label (i18n/label :t/add-account-description)
:on-press (fn []
(if keycard?
(rf/dispatch [:keycard/feature-unavailable-show
{:feature-name :wallet.new-account}])
(rf/dispatch [:navigate-to :screen/wallet.create-account])))}
(when (ff/enabled? ::ff/wallet.add-watched-address)
{:icon :i/reveal
:accessibility-label :add-a-contact
:label (i18n/label :t/add-address-to-watch)
:sub-label (i18n/label :t/add-address-to-watch-description)
:on-press #(rf/dispatch [:navigate-to :screen/wallet.add-address-to-watch])
:add-divider? true})]]]))
[quo/action-drawer
[[{:icon :i/add
:accessibility-label :start-a-new-chat
:label (i18n/label :t/add-account)
:sub-label (i18n/label :t/add-account-description)
:on-press #(rf/dispatch [:navigate-to :screen/wallet.create-account])}
(when (ff/enabled? ::ff/wallet.add-watched-address)
{:icon :i/reveal
:accessibility-label :add-a-contact
:label (i18n/label :t/add-address-to-watch)
:sub-label (i18n/label :t/add-address-to-watch-description)
:on-press #(rf/dispatch [:navigate-to :screen/wallet.add-address-to-watch])
:add-divider? true})]]])
(defn- new-account-card-data
[]