From 1bc967c6d13abceb3c7d54815dcbc8c8243c311d Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Tue, 17 Dec 2019 15:43:55 -0500 Subject: [PATCH] fix(@embark/rpc-manager): fix sign data address comparison Did not check correctly for if the account is a node account --- .../rpc-manager/src/lib/eth_signData.ts | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/packages/plugins/rpc-manager/src/lib/eth_signData.ts b/packages/plugins/rpc-manager/src/lib/eth_signData.ts index 3a380f809..3de7f26cf 100644 --- a/packages/plugins/rpc-manager/src/lib/eth_signData.ts +++ b/packages/plugins/rpc-manager/src/lib/eth_signData.ts @@ -12,18 +12,25 @@ export default class EthSignData extends RpcModifier { } private async ethSignDataRequest(params: any, callback: Callback) { - if (params.request.method === "eth_sign") { - try { - const nodeAccounts = await this.nodeAccounts; - const [fromAddr] = params.request.params; - if (!nodeAccounts.includes(fromAddr)) { - params.sendToNode = false; - } - } catch (err) { - return callback(err); - } + if (params.request.method !== "eth_sign") { + return callback(null, params); } + try { + const nodeAccounts = await this.nodeAccounts; + const [fromAddr] = params.request.params; + + const account = nodeAccounts.find(acc => ( + Web3.utils.toChecksumAddress(acc) === + Web3.utils.toChecksumAddress(fromAddr) + )); + + if (!account) { + params.sendToNode = false; + } + } catch (err) { + return callback(err); + } callback(null, params); } @@ -37,7 +44,11 @@ export default class EthSignData extends RpcModifier { const nodeAccounts = await this.nodeAccounts; 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); }