mirror of
https://github.com/status-im/status-react.git
synced 2025-01-23 17:29:08 +00:00
fix(wallet): Account derivation for added keypairs (#20536)
* Fix color of non-selected keypairs * Fix pressable area in keypairs * Make validation more robust * Make confirm button always pressable * Fix wrong sentence in errors * Solve account creation by fixing a memoized callback * Improve logging
This commit is contained in:
parent
b005eb8181
commit
3ce6a86e9b
@ -14,9 +14,7 @@
|
|||||||
[react-native.reanimated :as reanimated]))
|
[react-native.reanimated :as reanimated]))
|
||||||
|
|
||||||
(defn drag-gesture
|
(defn drag-gesture
|
||||||
[x-pos disabled? track-width sliding-complete?
|
[x-pos disabled? track-width sliding-complete? set-sliding-complete on-complete reset-fn]
|
||||||
set-sliding-complete
|
|
||||||
on-complete reset-fn]
|
|
||||||
(-> (gesture/gesture-pan)
|
(-> (gesture/gesture-pan)
|
||||||
(gesture/with-test-ID :slide-button-gestures)
|
(gesture/with-test-ID :slide-button-gestures)
|
||||||
(gesture/enabled (not disabled?))
|
(gesture/enabled (not disabled?))
|
||||||
@ -71,14 +69,16 @@
|
|||||||
(dimensions :thumb))
|
(dimensions :thumb))
|
||||||
[dimensions])
|
[dimensions])
|
||||||
custom-color (if (= type :danger) :danger customization-color)
|
custom-color (if (= type :danger) :danger customization-color)
|
||||||
gesture (rn/use-memo #(drag-gesture x-pos
|
gesture (rn/use-memo
|
||||||
|
(fn []
|
||||||
|
(drag-gesture x-pos
|
||||||
disabled?
|
disabled?
|
||||||
(dimensions :usable-track)
|
(dimensions :usable-track)
|
||||||
sliding-complete?
|
sliding-complete?
|
||||||
set-sliding-complete
|
set-sliding-complete
|
||||||
on-complete
|
on-complete
|
||||||
reset-fn)
|
reset-fn))
|
||||||
[sliding-complete? disabled?])]
|
[sliding-complete? disabled? on-complete])]
|
||||||
[gesture/gesture-detector
|
[gesture/gesture-detector
|
||||||
{:gesture gesture}
|
{:gesture gesture}
|
||||||
[reanimated/view
|
[reanimated/view
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
[{:keys [blur? customization-color theme selected? container-style]}]
|
[{:keys [blur? customization-color theme selected? container-style]}]
|
||||||
(merge {:border-radius 16
|
(merge {:border-radius 16
|
||||||
:border-width 1
|
:border-width 1
|
||||||
:border-color (if selected?
|
:padding-bottom 8
|
||||||
(if blur?
|
:border-color (cond
|
||||||
colors/white
|
(and selected? blur?) colors/white
|
||||||
(colors/resolve-color customization-color theme))
|
selected? (colors/resolve-color customization-color theme)
|
||||||
(if blur?
|
blur? colors/white-opa-5
|
||||||
colors/white-opa-5
|
:else (colors/theme-colors colors/neutral-10
|
||||||
(colors/theme-colors colors/neutral-10 colors/neutral-80 theme)))
|
colors/neutral-80
|
||||||
:padding-bottom 8}
|
theme))}
|
||||||
container-style))
|
container-style))
|
||||||
|
|
||||||
(def header-container
|
(def header-container
|
||||||
|
@ -95,11 +95,14 @@
|
|||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[{:keys [accounts action container-style selected? on-press] :as props}]
|
[{:keys [accounts action container-style selected? on-press] :as props}]
|
||||||
|
(let [theme (quo.theme/use-theme)]
|
||||||
[rn/pressable
|
[rn/pressable
|
||||||
{:style (style/container (merge props
|
{:style (style/container (assoc props
|
||||||
{:selected? selected?
|
:selected? selected?
|
||||||
:container-style container-style}))
|
:container-style container-style
|
||||||
:on-press #(when (= action :selector) (on-press))}
|
:theme theme))
|
||||||
|
:on-press #(when (= action :selector) (on-press))
|
||||||
|
:pointer-events :box-only}
|
||||||
[rn/view {:style style/header-container}
|
[rn/view {:style style/header-container}
|
||||||
[avatar props]
|
[avatar props]
|
||||||
[rn/view
|
[rn/view
|
||||||
@ -111,4 +114,4 @@
|
|||||||
{:data accounts
|
{:data accounts
|
||||||
:render-fn acc-list-card
|
:render-fn acc-list-card
|
||||||
:separator [rn/view {:style {:height 8}}]
|
:separator [rn/view {:style {:height 8}}]
|
||||||
:style {:padding-horizontal 8}}]])
|
:style {:padding-horizontal 8}}]]))
|
||||||
|
@ -124,7 +124,7 @@
|
|||||||
:on-success on-success
|
:on-success on-success
|
||||||
:on-error (fn [error]
|
:on-error (fn [error]
|
||||||
(log/error
|
(log/error
|
||||||
"Failed to resolve next path derivation path"
|
"Failed to resolve next derivation path"
|
||||||
{:event :wallet/next-derivation-path
|
{:event :wallet/next-derivation-path
|
||||||
:method "accounts_resolveSuggestedPathForKeypair"
|
:method "accounts_resolveSuggestedPathForKeypair"
|
||||||
:error error
|
:error error
|
||||||
@ -191,7 +191,7 @@
|
|||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/derive-address-and-add-account
|
:wallet/derive-address-and-add-account
|
||||||
(fn [_ [{:keys [password derived-from-address derivation-path account-preferences]}]]
|
(fn [_ [{:keys [password derived-from-address derivation-path account-preferences key-uid]}]]
|
||||||
{:fx [[:json-rpc/call
|
{:fx [[:json-rpc/call
|
||||||
[{:method "wallet_getDerivedAddresses"
|
[{:method "wallet_getDerivedAddresses"
|
||||||
:params [(security/safe-unmask-data password)
|
:params [(security/safe-unmask-data password)
|
||||||
@ -199,9 +199,10 @@
|
|||||||
[derivation-path]]
|
[derivation-path]]
|
||||||
:on-success (fn [[derived-account]]
|
:on-success (fn [[derived-account]]
|
||||||
(rf/dispatch [:wallet/add-account
|
(rf/dispatch [:wallet/add-account
|
||||||
(assoc account-preferences :password password)
|
(assoc account-preferences
|
||||||
|
:key-uid key-uid
|
||||||
|
:password password)
|
||||||
derived-account]))
|
derived-account]))
|
||||||
:on-error #(log/info "Failed to get derived addresses"
|
:on-error [:wallet/log-rpc-error
|
||||||
derived-from-address
|
{:event :wallet/derive-address-and-add-account
|
||||||
%)}]]]}))
|
:params [derived-from-address [derivation-path]]}]}]]]}))
|
||||||
|
|
||||||
|
@ -105,8 +105,7 @@
|
|||||||
[quo/bottom-actions
|
[quo/bottom-actions
|
||||||
{:actions :one-action
|
{:actions :one-action
|
||||||
:button-one-label (i18n/label :t/confirm-account-origin)
|
:button-one-label (i18n/label :t/confirm-account-origin)
|
||||||
:button-one-props {:disabled? (= selected-keypair selected-key-uid)
|
:button-one-props {:customization-color customization-color
|
||||||
:customization-color customization-color
|
|
||||||
:on-press #(rf/dispatch [:wallet/confirm-account-origin
|
:on-press #(rf/dispatch [:wallet/confirm-account-origin
|
||||||
selected-key-uid])}
|
selected-key-uid])}
|
||||||
:container-style style/bottom-action-container}]]))
|
:container-style style/bottom-action-container}]]))
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
:action-props {:on-press #(rf/dispatch [:standard-auth/authorize
|
:action-props {:on-press #(rf/dispatch [:standard-auth/authorize
|
||||||
{:on-auth-success on-auth-success
|
{:on-auth-success on-auth-success
|
||||||
:auth-button-label (i18n/label :t/continue)}])
|
:auth-button-label (i18n/label :t/continue)}])
|
||||||
|
|
||||||
:button-text (i18n/label :t/edit)
|
:button-text (i18n/label :t/edit)
|
||||||
:icon-left :i/face-id
|
:icon-left :i/face-id
|
||||||
:alignment :flex-start}
|
:alignment :flex-start}
|
||||||
@ -217,6 +216,7 @@
|
|||||||
[:wallet/derive-address-and-add-account
|
[:wallet/derive-address-and-add-account
|
||||||
{:password password
|
{:password password
|
||||||
:derived-from-address derived-from
|
:derived-from-address derived-from
|
||||||
|
:key-uid key-uid
|
||||||
:derivation-path @derivation-path
|
:derivation-path @derivation-path
|
||||||
:account-preferences preferences}])))
|
:account-preferences preferences}])))
|
||||||
[derived-from])]
|
[derived-from])]
|
||||||
@ -231,7 +231,7 @@
|
|||||||
{:account-color @account-color
|
{:account-color @account-color
|
||||||
:slide-button-props {:on-auth-success on-auth-success
|
:slide-button-props {:on-auth-success on-auth-success
|
||||||
:disabled? (or (empty? @account-name)
|
:disabled? (or (empty? @account-name)
|
||||||
(= "" @derivation-path)
|
(string/blank? @derivation-path)
|
||||||
(some? error))}}
|
(some? error))}}
|
||||||
[avatar
|
[avatar
|
||||||
{:account-color @account-color
|
{:account-color @account-color
|
||||||
|
@ -215,13 +215,12 @@
|
|||||||
[:dispatch [:wallet/clear-create-account]]]}))
|
[:dispatch [:wallet/clear-create-account]]]}))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/add-account
|
(rf/reg-event-fx :wallet/add-account
|
||||||
(fn [{:keys [db]}
|
(fn [_
|
||||||
[{:keys [password account-name emoji color type]
|
[{:keys [key-uid password account-name emoji color type]
|
||||||
:or {type :generated}}
|
:or {type :generated}}
|
||||||
{:keys [public-key address path] :as _derived-account}]]
|
{:keys [public-key address path] :as _derived-account}]]
|
||||||
(let [lowercase-address (some-> address
|
(let [lowercase-address (some-> address
|
||||||
(string/lower-case))
|
string/lower-case)
|
||||||
key-uid (get-in db [:wallet :ui :create-account :selected-keypair-uid])
|
|
||||||
account-config {:key-uid (when (= type :generated) key-uid)
|
account-config {:key-uid (when (= type :generated) key-uid)
|
||||||
:wallet false
|
:wallet false
|
||||||
:chat false
|
:chat false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user