From 15a90af5be75806e26f589f0a3f3687c0fb1c672 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Mon, 19 Oct 2020 01:17:36 -0400 Subject: [PATCH] Fix signTypedData call for JsonRpcSigner (#687). --- packages/providers/src.ts/json-rpc-provider.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/providers/src.ts/json-rpc-provider.ts b/packages/providers/src.ts/json-rpc-provider.ts index 89b6486233..4c3948a4f9 100644 --- a/packages/providers/src.ts/json-rpc-provider.ts +++ b/packages/providers/src.ts/json-rpc-provider.ts @@ -218,17 +218,20 @@ export class JsonRpcSigner extends Signer implements TypedDataSigner { return this.provider.resolveName(name); }); + const address = await this.getAddress(); + return await this.provider.send("eth_signTypedData_v4", [ - _TypedDataEncoder.getPayload(populated.domain, types, populated.value) + address.toLowerCase(), + JSON.stringify(_TypedDataEncoder.getPayload(populated.domain, types, populated.value)) ]); } - unlock(password: string): Promise { + async unlock(password: string): Promise { const provider = this.provider; - return this.getAddress().then(function(address) { - return provider.send("personal_unlockAccount", [ address.toLowerCase(), password, null ]); - }); + const address = await this.getAddress(); + + return provider.send("personal_unlockAccount", [ address.toLowerCase(), password, null ]); } }