[#10277] [keycard] Fix tx signing for derived accounts
This commit is contained in:
parent
4f120d99f7
commit
c9308af4d8
|
@ -490,6 +490,7 @@ var TopLevel = {
|
||||||
"showActionSheetWithOptions" : function () {},
|
"showActionSheetWithOptions" : function () {},
|
||||||
"showPicker" : function () {},
|
"showPicker" : function () {},
|
||||||
"sign" : function () {},
|
"sign" : function () {},
|
||||||
|
"signWithPath" : function () {},
|
||||||
"signGroupMembership" : function () {},
|
"signGroupMembership" : function () {},
|
||||||
"signMessage" : function () {},
|
"signMessage" : function () {},
|
||||||
"signPinless" : function () {},
|
"signPinless" : function () {},
|
||||||
|
|
|
@ -177,12 +177,17 @@
|
||||||
(catch on-failure))))
|
(catch on-failure))))
|
||||||
|
|
||||||
(defn sign
|
(defn sign
|
||||||
[{:keys [pairing pin hash on-success on-failure]}]
|
[{:keys [pairing pin path hash on-success on-failure]}]
|
||||||
(when (and pairing pin hash)
|
(when (and pairing pin hash)
|
||||||
|
(if path
|
||||||
|
(.. status-keycard
|
||||||
|
(signWithPath pairing pin path hash)
|
||||||
|
(then on-success)
|
||||||
|
(catch on-failure))
|
||||||
(.. status-keycard
|
(.. status-keycard
|
||||||
(sign pairing pin hash)
|
(sign pairing pin hash)
|
||||||
(then on-success)
|
(then on-success)
|
||||||
(catch on-failure))))
|
(catch on-failure)))))
|
||||||
|
|
||||||
(defn sign-typed-data
|
(defn sign-typed-data
|
||||||
[{:keys [hash on-success on-failure]}]
|
[{:keys [hash on-success on-failure]}]
|
||||||
|
|
|
@ -13,13 +13,21 @@
|
||||||
(fx/defn sign
|
(fx/defn sign
|
||||||
{:events [:hardwallet/sign]}
|
{:events [:hardwallet/sign]}
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
|
(log/debug "FOOOOO sign keke" (:signing/tx db))
|
||||||
(let [card-connected? (get-in db [:hardwallet :card-connected?])
|
(let [card-connected? (get-in db [:hardwallet :card-connected?])
|
||||||
pairing (common/get-pairing db)
|
pairing (common/get-pairing db)
|
||||||
multiaccount-keycard-instance-uid (get-in db [:multiaccount :keycard-instance-uid])
|
keycard-instance-uid (get-in db [:multiaccount :keycard-instance-uid])
|
||||||
instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
||||||
keycard-match? (= multiaccount-keycard-instance-uid instance-uid)
|
keycard-match? (= keycard-instance-uid instance-uid)
|
||||||
hash (get-in db [:hardwallet :hash])
|
hash (get-in db [:hardwallet :hash])
|
||||||
pin (common/vector->string (get-in db [:hardwallet :pin :sign]))]
|
pin (common/vector->string (get-in db [:hardwallet :pin :sign]))
|
||||||
|
from (get-in db [:signing/tx :from :address])
|
||||||
|
path (reduce
|
||||||
|
(fn [_ {:keys [address path]}]
|
||||||
|
(when (= from address)
|
||||||
|
(reduced path)))
|
||||||
|
nil
|
||||||
|
(:multiaccount/accounts db))]
|
||||||
(if (and card-connected?
|
(if (and card-connected?
|
||||||
keycard-match?)
|
keycard-match?)
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
|
@ -27,7 +35,8 @@
|
||||||
(assoc-in [:hardwallet :pin :status] :verifying))
|
(assoc-in [:hardwallet :pin :status] :verifying))
|
||||||
:hardwallet/sign {:hash (ethereum/naked-address hash)
|
:hardwallet/sign {:hash (ethereum/naked-address hash)
|
||||||
:pairing pairing
|
:pairing pairing
|
||||||
:pin pin}}
|
:pin pin
|
||||||
|
:path path}}
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (assoc-in db [:signing/sign :keycard-step] :signing)}
|
{:db (assoc-in db [:signing/sign :keycard-step] :signing)}
|
||||||
(common/set-on-card-connected :hardwallet/sign)
|
(common/set-on-card-connected :hardwallet/sign)
|
||||||
|
|
Loading…
Reference in New Issue