[keycard] Fix assets message signature
This commit is contained in:
parent
16742baecd
commit
3fe1d6e3eb
|
@ -43,11 +43,18 @@
|
||||||
(when-not keycard-match?
|
(when-not keycard-match?
|
||||||
(common/show-wrong-keycard-alert card-connected?))))))
|
(common/show-wrong-keycard-alert card-connected?))))))
|
||||||
|
|
||||||
|
(defn normalize-signature [signature]
|
||||||
|
(-> signature
|
||||||
|
(clojure.string/replace-first #"00$", "1b")
|
||||||
|
(clojure.string/replace-first #"01$", "1c")
|
||||||
|
ethereum/normalized-hex))
|
||||||
|
|
||||||
(fx/defn sign-message
|
(fx/defn sign-message
|
||||||
{:events [:hardwallet/sign-message]}
|
{:events [:hardwallet/sign-message]}
|
||||||
[{:keys [db] :as cofx} params result]
|
[{:keys [db] :as cofx} params result]
|
||||||
(let [{:keys [result error]} (types/json->clj result)
|
(let [{:keys [result error]} (types/json->clj result)
|
||||||
on-success #(re-frame/dispatch [:hardwallet/on-sign-message-success params %])
|
on-success #(re-frame/dispatch [:hardwallet/on-sign-message-success params
|
||||||
|
(normalize-signature %)])
|
||||||
hash (ethereum/naked-address result)
|
hash (ethereum/naked-address result)
|
||||||
card-connected? (get-in db [:hardwallet :card-connected?])
|
card-connected? (get-in db [:hardwallet :card-connected?])
|
||||||
pairing (common/get-pairing db)
|
pairing (common/get-pairing db)
|
||||||
|
@ -159,11 +166,7 @@
|
||||||
{:events [:hardwallet.callback/on-sign-success]}
|
{:events [:hardwallet.callback/on-sign-success]}
|
||||||
[{:keys [db] :as cofx} signature]
|
[{:keys [db] :as cofx} signature]
|
||||||
(log/debug "[hardwallet] sign success: " signature)
|
(log/debug "[hardwallet] sign success: " signature)
|
||||||
(let [signature-json (types/clj->json
|
(let [signature-json (types/clj->json {:result (normalize-signature signature)})
|
||||||
{:result (-> signature
|
|
||||||
(clojure.string/replace-first #"00$", "1b")
|
|
||||||
(clojure.string/replace-first #"01$", "1c")
|
|
||||||
ethereum/normalized-hex)})
|
|
||||||
transaction (get-in db [:hardwallet :transaction])
|
transaction (get-in db [:hardwallet :transaction])
|
||||||
tx-obj (select-keys transaction [:from :to :value :gas :gasPrice :command? :chat-id :message-id])
|
tx-obj (select-keys transaction [:from :to :value :gas :gasPrice :command? :chat-id :message-id])
|
||||||
command? (:command? transaction)]
|
command? (:command? transaction)]
|
||||||
|
|
Loading…
Reference in New Issue