Skip to content

Commit

Permalink
always append 0x
Browse files Browse the repository at this point in the history
  • Loading branch information
hewigovens committed Oct 17, 2020
1 parent ad834d3 commit c39d7da
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dist/trust-min.js
Git LFS file not shown
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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});
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Utils {
}

static bufferToHex(buf) {
return Buffer.from(buf).toString("hex");
return "0x" + Buffer.from(buf).toString("hex");
}
}

Expand Down

0 comments on commit c39d7da

Please sign in to comment.