Skip to content

Improve eth_sign compatibility #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dist/trust-min.js
Git LFS file not shown
15 changes: 14 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ProviderRpcError from "./error";
import Utils from "./utils";
import IdMapping from "./id_mapping";
import { EventEmitter } from "events";
import isUtf8 from 'isutf8';

class TrustWeb3Provider extends EventEmitter {
constructor(config) {
Expand Down Expand Up @@ -200,7 +201,19 @@ class TrustWeb3Provider extends EventEmitter {
}

eth_sign(payload) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have duplicates with eth_ prefix for all sign call

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signPersonalMessage => add eth msg prefix
signMessage => sign directly

this.postMessage("signMessage", payload.id, {data: payload.params[1]});
const data = payload.params[1];
var buffer;
if ((typeof (data) === "string")) {
buffer = Utils.hexToBuffer(data);
} else {
buffer = Buffer.from(data);
}
const hex = buffer.toString('hex');
if (isUtf8(buffer)) {
this.postMessage("signPersonalMessage", payload.id, {data: hex});
} else {
this.postMessage("signMessage", payload.id, {data: hex});
}
}

personal_sign(payload) {
Expand Down
231 changes: 220 additions & 11 deletions src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading