[keycard] Fix assets message signature

This commit is contained in:
Roman Volosovskyi 2020-07-02 18:06:06 +03:00
parent 16742baecd
commit 3fe1d6e3eb
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
1 changed files with 9 additions and 6 deletions

View File

@ -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)]