Skip to content

Commit

Permalink
[#21836] Relative derivation paths are not supported by keycard
Browse files Browse the repository at this point in the history
  • Loading branch information
flexsurfer committed Jan 7, 2025
1 parent 813c60f commit df21f5f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/status_im/contexts/wallet/account/tabs/about/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down Expand Up @@ -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}])]))
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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))
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit df21f5f

Please sign in to comment.