Fixes
This commit is contained in:
parent
6f1605aea4
commit
330deb2f14
|
@ -36,6 +36,12 @@
|
|||
"wallet"
|
||||
{:fx [[:dispatch [:wallet/signal-received event-js]]]}
|
||||
|
||||
"wallet.sign.transactions"
|
||||
{:fx [[:dispatch
|
||||
[:standard-auth/authorize-with-keycard
|
||||
{:on-complete #(rf/dispatch [:keycard/sign-hash %
|
||||
(first (transforms/js->clj event-js))])}]]]}
|
||||
|
||||
"wallet.suggested.routes"
|
||||
{:fx [[:dispatch [:wallet/handle-suggested-routes (transforms/js->clj event-js)]]]}
|
||||
|
||||
|
|
|
@ -116,6 +116,7 @@
|
|||
:on-close #(rf/dispatch [:standard-auth/reset-login-password])
|
||||
:content (fn []
|
||||
[keycard.pin/auth {:on-complete on-complete}])}]]]})
|
||||
|
||||
(rf/reg-event-fx :standard-auth/authorize-with-keycard authorize-with-keycard)
|
||||
|
||||
(defn authorize-with-password
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
status-im.contexts.keycard.nfc.events
|
||||
status-im.contexts.keycard.nfc.sheets.events
|
||||
status-im.contexts.keycard.pin.events
|
||||
status-im.contexts.keycard.sign.events
|
||||
[status-im.contexts.keycard.utils :as keycard.utils]
|
||||
utils.datetime))
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
(ns status-im.contexts.keycard.sign.events
|
||||
(:require [utils.address]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn get-signature-map
|
||||
[tx-hash signature]
|
||||
{tx-hash {:r (subs signature 0 64)
|
||||
:s (subs signature 64 128)
|
||||
:v (subs signature 128 130)}})
|
||||
|
||||
(rf/reg-event-fx :keycard/sign
|
||||
(fn [_ [data]]
|
||||
{:effects.keycard/sign data}))
|
||||
|
||||
(rf/reg-event-fx :keycard/sign-hash
|
||||
(fn [{:keys [db]} [pin-text tx-hash]]
|
||||
(let [current-address (get-in db [:wallet :current-viewing-account-address])
|
||||
path (get-in db [:wallet :accounts current-address :path])
|
||||
key-uid (get-in db [:profile/profile :key-uid])]
|
||||
{:fx [[:dispatch
|
||||
[:keycard/connect
|
||||
{:key-uid key-uid
|
||||
:on-success
|
||||
(fn []
|
||||
(rf/dispatch
|
||||
[:keycard/sign
|
||||
{:pin pin-text
|
||||
:path path
|
||||
:hash (utils.address/naked-address tx-hash)
|
||||
:on-success (fn [signature]
|
||||
(rf/dispatch [:keycard/disconnect])
|
||||
(rf/dispatch [:wallet/proceed-with-transactions-signatures
|
||||
(get-signature-map tx-hash signature)]))
|
||||
:on-failure #(rf/dispatch [:keycard/on-action-with-pin-error %])}]))}]]]})))
|
|
@ -109,7 +109,8 @@
|
|||
[hashes address password]
|
||||
(-> (promesa/all
|
||||
(for [h hashes]
|
||||
(wallet-rpc/sign-message h address password)))
|
||||
{:message h
|
||||
:signature (wallet-rpc/sign-message h address password)}))
|
||||
(promesa/catch (fn [err]
|
||||
(throw (ex-info "Failed to sign transaction hashes"
|
||||
{:error err
|
||||
|
|
|
@ -56,6 +56,4 @@
|
|||
message
|
||||
address
|
||||
password)
|
||||
(promesa/then (fn [s]
|
||||
{:message message
|
||||
:signature (utils.hex/normalize-hex s)}))))
|
||||
(promesa/then utils.hex/normalize-hex)))
|
||||
|
|
Loading…
Reference in New Issue