From f1d070ed82632e14dc6303947479efb07c961da4 Mon Sep 17 00:00:00 2001 From: andrey Date: Wed, 4 Nov 2020 11:34:06 +0100 Subject: [PATCH] [#11333] personal_sign method does not work in status Signed-off-by: andrey --- src/status_im/browser/core.cljs | 11 +++++++++-- src/status_im/ethereum/core.cljs | 9 ++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/status_im/browser/core.cljs b/src/status_im/browser/core.cljs index cbf91cea7f..cbdd177539 100644 --- a/src/status_im/browser/core.cljs +++ b/src/status_im/browser/core.cljs @@ -314,6 +314,13 @@ :id (int id) :result result}}}) +(defn normalize-message + "NOTE (andrey) there is no spec for this, so this implementation just to be compatible with MM" + [message] + (if (ethereum/hex-to-utf8 message) + message + (ethereum/utf8-to-hex message))) + (defn normalize-sign-message-params "NOTE (andrey) we need this function, because params may be mixed up" [params] @@ -321,9 +328,9 @@ (when (and (string? first-param) (string? second-param)) (cond (ethereum/address? first-param) - [first-param second-param] + [first-param (normalize-message second-param)] (ethereum/address? second-param) - [second-param first-param])))) + [second-param (normalize-message first-param)])))) (fx/defn send-to-bridge [cofx message] diff --git a/src/status_im/ethereum/core.cljs b/src/status_im/ethereum/core.cljs index 3f97af209d..92a506deb2 100644 --- a/src/status_im/ethereum/core.cljs +++ b/src/status_im/ethereum/core.cljs @@ -137,12 +137,7 @@ (when normalized-key (subs (sha3 normalized-key) 26)))) -(def 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" + "Converts a hexstring to UTF8 text." [data] - (if (= bytes32-length (count (normalized-hex data))) - data ; Assume it's a bytes32 - (hex-to-utf8 data))) + (hex-to-utf8 data))