Use personal_sign instead of eth_sign for message signing with JsonRpcSigner; added _legacySignMessage for legacy support (#1542, #1840).
This commit is contained in:
parent
cb43a99405
commit
8947fd405e
@ -249,6 +249,13 @@ export class JsonRpcSigner extends Signer implements TypedDataSigner {
|
||||
const data = ((typeof(message) === "string") ? toUtf8Bytes(message): message);
|
||||
const address = await this.getAddress();
|
||||
|
||||
return await this.provider.send("personal_sign", [ hexlify(data), address.toLowerCase() ]);
|
||||
}
|
||||
|
||||
async _legacySignMessage(message: Bytes | string): Promise<string> {
|
||||
const data = ((typeof(message) === "string") ? toUtf8Bytes(message): message);
|
||||
const address = await this.getAddress();
|
||||
|
||||
// https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign
|
||||
return await this.provider.send("eth_sign", [ address.toLowerCase(), hexlify(data) ]);
|
||||
}
|
||||
@ -611,7 +618,6 @@ export class JsonRpcProvider extends BaseProvider {
|
||||
super._stopEvent(event);
|
||||
}
|
||||
|
||||
|
||||
// Convert an ethers.js transaction into a JSON-RPC transaction
|
||||
// - gasLimit => gas
|
||||
// - All values hexlified
|
||||
|
@ -30,14 +30,6 @@ function buildWeb3LegacyFetcher(provider: ExternalProvider, sendFunc: Web3Legacy
|
||||
const fetcher = "Web3LegacyFetcher";
|
||||
|
||||
return function(method: string, params: Array<any>): Promise<any> {
|
||||
|
||||
// Metamask complains about eth_sign (and on some versions hangs)
|
||||
if (method == "eth_sign" && (provider.isMetaMask || provider.isStatus)) {
|
||||
// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
|
||||
method = "personal_sign";
|
||||
params = [ params[1], params[0] ];
|
||||
}
|
||||
|
||||
const request = {
|
||||
method: method,
|
||||
params: params,
|
||||
@ -92,13 +84,6 @@ function buildEip1193Fetcher(provider: ExternalProvider): JsonRpcFetchFunc {
|
||||
return function(method: string, params: Array<any>): Promise<any> {
|
||||
if (params == null) { params = [ ]; }
|
||||
|
||||
// Metamask complains about eth_sign (and on some versions hangs)
|
||||
if (method == "eth_sign" && (provider.isMetaMask || provider.isStatus)) {
|
||||
// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
|
||||
method = "personal_sign";
|
||||
params = [ params[1], params[0] ];
|
||||
}
|
||||
|
||||
const request = { method, params };
|
||||
|
||||
this.emit("debug", {
|
||||
|
Loading…
Reference in New Issue
Block a user