Skip to content

Commit

Permalink
fix: display the value to sign as a bytes32 hex string if the data is…
Browse files Browse the repository at this point in the history
… 66 chars long
  • Loading branch information
richard-ramos committed Apr 23, 2020
1 parent c805333 commit 4c26cc2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/status_im/ethereum/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,13 @@
nil)]
(when normalized-key
(subs (sha3 normalized-key) 26))))

(def ^:const bytes32-length 66) ; length of '0x' + 64 hex values. (a 32bytes value has 64 nibbles)

(defn hex->text
"Converts a hexstring to UTF8 text. If the data received is 32 bytes long,
return the value unconverted"
[data]
(if (= bytes32-length (count (normalized-hex data)))
data ; Assume it's a bytes32
(hex-to-utf8 data)))
2 changes: 1 addition & 1 deletion src/status_im/signing/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
:signing/sign {:type (cond pinless? :pinless
keycard-multiaccount? :keycard
:else :password)
:formatted-data (if typed? (types/json->clj data) (ethereum/hex-to-utf8 data))
:formatted-data (if typed? (types/json->clj data) (ethereum/hex->text data))
:keycard-step (when pinless? :connect)})}
(when pinless?
(signing.keycard/hash-message {:data data
Expand Down

0 comments on commit 4c26cc2

Please sign in to comment.