Skip to content

Commit

Permalink
[keycard] Fix assets message signature
Browse files Browse the repository at this point in the history
  • Loading branch information
rasom committed Jul 3, 2020
1 parent 16742ba commit 3fe1d6e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/status_im/hardwallet/sign.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,18 @@
(when-not keycard-match?
(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
{:events [:hardwallet/sign-message]}
[{:keys [db] :as cofx} params 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)
card-connected? (get-in db [:hardwallet :card-connected?])
pairing (common/get-pairing db)
Expand Down Expand Up @@ -159,11 +166,7 @@
{:events [:hardwallet.callback/on-sign-success]}
[{:keys [db] :as cofx} signature]
(log/debug "[hardwallet] sign success: " signature)
(let [signature-json (types/clj->json
{:result (-> signature
(clojure.string/replace-first #"00$", "1b")
(clojure.string/replace-first #"01$", "1c")
ethereum/normalized-hex)})
(let [signature-json (types/clj->json {:result (normalize-signature signature)})
transaction (get-in db [:hardwallet :transaction])
tx-obj (select-keys transaction [:from :to :value :gas :gasPrice :command? :chat-id :message-id])
command? (:command? transaction)]
Expand Down

0 comments on commit 3fe1d6e

Please sign in to comment.