From d8ad4a614a928553f6554ee589d615e3000ffe29 Mon Sep 17 00:00:00 2001 From: hewigovens <360470+hewigovens@users.noreply.github.com> Date: Sat, 17 Oct 2020 19:42:30 +0800 Subject: [PATCH] always append 0x (#106) --- dist/trust-min.js | 4 ++-- src/index.js | 4 ++-- src/utils.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/trust-min.js b/dist/trust-min.js index f885ee9c..2b9bb635 100644 --- a/dist/trust-min.js +++ b/dist/trust-min.js @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3fe80a1f5c4051e72d46485f26a79001c6007380ee60a75abf38db760712d661 -size 535220 +oid sha256:6fa92304a0135af876702ecfe6a9582ff78c65f504289fc9bccd866ceba51017 +size 535161 diff --git a/src/index.js b/src/index.js index c665c7d8..b7c6ca55 100644 --- a/src/index.js +++ b/src/index.js @@ -202,7 +202,7 @@ class TrustWeb3Provider extends EventEmitter { eth_sign(payload) { const buffer = Utils.messageToBuffer(payload.params[1]); - const hex = buffer.toString("hex"); + const hex = Utils.bufferToHex(buffer); if (isUtf8(buffer)) { this.postMessage("signPersonalMessage", payload.id, {data: hex}); } else { @@ -215,7 +215,7 @@ class TrustWeb3Provider extends EventEmitter { const buffer = Utils.messageToBuffer(message); if (buffer.length === 0) { // hex it - const hex = Buffer.from(message).toString("hex"); + const hex = Utils.bufferToHex(message); this.postMessage("signPersonalMessage", payload.id, {data: hex}); } else { this.postMessage("signPersonalMessage", payload.id, {data: message}); diff --git a/src/utils.js b/src/utils.js index 60a0293c..1c187641 100644 --- a/src/utils.js +++ b/src/utils.js @@ -51,7 +51,7 @@ class Utils { } static bufferToHex(buf) { - return Buffer.from(buf).toString("hex"); + return "0x" + Buffer.from(buf).toString("hex"); } }