fix(@embark/rpc-manager): fix sign data address comparison

Did not check correctly for if the account is a node account
This commit is contained in:
Jonathan Rainville 2019-12-17 15:43:55 -05:00 committed by Iuri Matias
parent 13312128b3
commit 1bc967c6d1
1 changed files with 22 additions and 11 deletions

View File

@ -12,18 +12,25 @@ export default class EthSignData extends RpcModifier {
} }
private async ethSignDataRequest(params: any, callback: Callback<any>) { private async ethSignDataRequest(params: any, callback: Callback<any>) {
if (params.request.method === "eth_sign") { if (params.request.method !== "eth_sign") {
return callback(null, params);
}
try { try {
const nodeAccounts = await this.nodeAccounts; const nodeAccounts = await this.nodeAccounts;
const [fromAddr] = params.request.params; const [fromAddr] = params.request.params;
if (!nodeAccounts.includes(fromAddr)) {
const account = nodeAccounts.find(acc => (
Web3.utils.toChecksumAddress(acc) ===
Web3.utils.toChecksumAddress(fromAddr)
));
if (!account) {
params.sendToNode = false; params.sendToNode = false;
} }
} catch (err) { } catch (err) {
return callback(err); return callback(err);
} }
}
callback(null, params); callback(null, params);
} }
@ -37,7 +44,11 @@ export default class EthSignData extends RpcModifier {
const nodeAccounts = await this.nodeAccounts; const nodeAccounts = await this.nodeAccounts;
const [fromAddr, data] = params.request.params; const [fromAddr, data] = params.request.params;
if (nodeAccounts.includes(fromAddr)) { const nodeAccount = nodeAccounts.find(acc => (
Web3.utils.toChecksumAddress(acc) ===
Web3.utils.toChecksumAddress(fromAddr)
));
if (nodeAccount) {
return callback(null, params); return callback(null, params);
} }