From 8d15d07c05142c2933e09eeac03f2dcd060f6655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Claudio=20Nale?= Date: Tue, 19 Jan 2021 19:57:13 -0300 Subject: [PATCH 1/8] Add JSON-RPC `eth_signTypedData_v4` method to Hardhat Network. --- .../hardhat-network/provider/modules/eth.ts | 39 +++++ .../internal/hardhat-network/provider/node.ts | 20 ++- .../hardhat-network/provider/modules/eth.ts | 149 +++++++++++++++++- packages/hardhat-ethers/test/index.ts | 51 ++++++ 4 files changed, 253 insertions(+), 6 deletions(-) diff --git a/packages/hardhat-core/src/internal/hardhat-network/provider/modules/eth.ts b/packages/hardhat-core/src/internal/hardhat-network/provider/modules/eth.ts index de2600abaf..a3c56ebff7 100644 --- a/packages/hardhat-core/src/internal/hardhat-network/provider/modules/eth.ts +++ b/packages/hardhat-core/src/internal/hardhat-network/provider/modules/eth.ts @@ -251,6 +251,14 @@ export class EthModule { case "eth_signTypedData": return this._signTypedDataAction(...this._signTypedDataParams(params)); + case "eth_signTypedData_v3": + throw new MethodNotSupportedError(method); + + case "eth_signTypedData_v4": + return this._signTypedDataV4Action( + ...this._signTypedDataV4Params(params) + ); + case "eth_submitHashrate": throw new MethodNotSupportedError(method); @@ -884,6 +892,7 @@ export class EthModule { // eth_signTypedData private _signTypedDataParams(params: any[]): [Buffer, any] { + // Validation of the TypedData parameter is handled by eth-sig-util return validateParams(params, rpcAddress, rpcUnknown); } @@ -894,6 +903,36 @@ export class EthModule { return this._node.signTypedData(address, typedData); } + // eth_signTypedData_v4 + + private _signTypedDataV4Params(params: any[]): [Buffer, any] { + // Validation of the TypedData parameter is handled by eth-sig-util + return validateParams(params, rpcAddress, rpcUnknown); + } + + private async _signTypedDataV4Action( + address: Buffer, + typedData: any + ): Promise { + let typedMessage: any = typedData; + + // According to the MetaMask implementation, + // the message parameter may be JSON stringified in versions later than V1 + // See https://github.com/MetaMask/metamask-extension/blob/0dfdd44ae7728ed02cbf32c564c75b74f37acf77/app/scripts/metamask-controller.js#L1736 + // In fact, ethers.js JSON stringifies the message at the time of writing. + if (typeof typedData === "string") { + try { + typedMessage = JSON.parse(typedData); + } catch (error) { + throw new InvalidInputError( + `The message parameter is an invalid JSON. Either pass a valid JSON or a plain object conforming to EIP712 TypedData schema.` + ); + } + } + + return this._node.signTypedDataV4(address, typedMessage); + } + // eth_submitHashrate // eth_submitWork diff --git a/packages/hardhat-core/src/internal/hardhat-network/provider/node.ts b/packages/hardhat-core/src/internal/hardhat-network/provider/node.ts index a9b308b87e..63619bc43a 100644 --- a/packages/hardhat-core/src/internal/hardhat-network/provider/node.ts +++ b/packages/hardhat-core/src/internal/hardhat-network/provider/node.ts @@ -6,6 +6,7 @@ import { RunBlockResult } from "@nomiclabs/ethereumjs-vm/dist/runBlock"; import { StateManager } from "@nomiclabs/ethereumjs-vm/dist/state"; import chalk from "chalk"; import debug from "debug"; +import * as ethSigUtil from "eth-sig-util"; import Common from "ethereumjs-common"; import { FakeTransaction, Transaction } from "ethereumjs-tx"; import { @@ -75,10 +76,6 @@ import { putGenesisBlock } from "./utils/putGenesisBlock"; const log = debug("hardhat:core:hardhat-network:node"); -// This library's types are wrong, they don't type check -// tslint:disable-next-line no-var-requires -const ethSigUtil = require("eth-sig-util"); - export const COINBASE_ADDRESS = toBuffer( "0xc014ba5ec014ba5ec014ba5ec014ba5ec014ba5e" ); @@ -623,9 +620,24 @@ export class HardhatNode extends EventEmitter { return ecsign(messageHash, privateKey); } + // TODO: we're currently mimicking the MetaMask implementation here. + // The EIP 712 is still a draft. It doesn't actually distinguish different versions + // of the eth_signTypedData API. + // Also, note that go-ethereum implemented this in a clef JSON-RPC API: account_signTypedData. public async signTypedData(address: Buffer, typedData: any): Promise { const privateKey = this._getLocalAccountPrivateKey(address); + return ethSigUtil.signTypedData(privateKey, { + data: typedData, + }); + } + + public async signTypedDataV4( + address: Buffer, + typedData: any + ): Promise { + const privateKey = this._getLocalAccountPrivateKey(address); + return ethSigUtil.signTypedData_v4(privateKey, { data: typedData, }); diff --git a/packages/hardhat-core/test/internal/hardhat-network/provider/modules/eth.ts b/packages/hardhat-core/test/internal/hardhat-network/provider/modules/eth.ts index e9e8fe3179..52b8898437 100644 --- a/packages/hardhat-core/test/internal/hardhat-network/provider/modules/eth.ts +++ b/packages/hardhat-core/test/internal/hardhat-network/provider/modules/eth.ts @@ -1,4 +1,5 @@ import { assert } from "chai"; +import { recoverTypedSignature, recoverTypedSignature_v4 } from "eth-sig-util"; import Common from "ethereumjs-common"; import { Transaction } from "ethereumjs-tx"; import { BN, bufferToHex, toBuffer, zeroAddress } from "ethereumjs-util"; @@ -3390,8 +3391,152 @@ describe("Eth module", function () { }); }); - describe("eth_signTypedData", async function () { - // TODO: Test this. Note that it just forwards to/from eth-sign-util + describe("eth_signTypedData", function () { + it("should sign a message", async function () { + // See https://eips.ethereum.org/EIPS/eip-712#parameters + // There's a json schema and an explanation for each field. + const typedMessage = { + domain: { + chainId: 31337, + name: "Hardhat Network test suite", + }, + message: { + name: "Translation", + start: { + x: 200, + y: 600, + }, + end: { + x: 300, + y: 350, + }, + cost: 50, + }, + primaryType: "WeightedVector", + types: { + EIP712Domain: [ + { name: "name", type: "string" }, + { name: "chainId", type: "uint256" }, + ], + WeightedVector: [ + { name: "name", type: "string" }, + { name: "start", type: "Point" }, + { name: "end", type: "Point" }, + { name: "cost", type: "uint256" }, + ], + Point: [ + { name: "x", type: "uint256" }, + { name: "y", type: "uint256" }, + ], + }, + }; + + const [address] = DEFAULT_ACCOUNTS_ADDRESSES; + + const signature = await this.provider.request({ + method: "eth_signTypedData", + params: [address, typedMessage], + }); + const signedMessage = { + data: typedMessage, + sig: signature, + }; + + const recoveredAddress = recoverTypedSignature(signedMessage as any); + assert.equal(address.toLowerCase(), recoveredAddress.toLowerCase()); + }); + }); + + describe("eth_signTypedData_v3", function () { + it("is not supported", async function () { + await assertNotSupported(this.provider, "eth_signTypedData_v3"); + }); + }); + + describe("eth_signTypedData_v4", function () { + // See https://eips.ethereum.org/EIPS/eip-712#parameters + // There's a json schema and an explanation for each field. + const typedMessage = { + domain: { + chainId: 31337, + name: "Hardhat Network test suite", + }, + message: { + name: "Translation", + start: { + x: 200, + y: 600, + }, + end: { + x: 300, + y: 350, + }, + cost: 50, + }, + primaryType: "WeightedVector", + types: { + EIP712Domain: [ + { name: "name", type: "string" }, + { name: "chainId", type: "uint256" }, + ], + WeightedVector: [ + { name: "name", type: "string" }, + { name: "start", type: "Point" }, + { name: "end", type: "Point" }, + { name: "cost", type: "uint256" }, + ], + Point: [ + { name: "x", type: "uint256" }, + { name: "y", type: "uint256" }, + ], + }, + }; + const [address] = DEFAULT_ACCOUNTS_ADDRESSES; + + it("should sign a message", async function () { + const signature = await this.provider.request({ + method: "eth_signTypedData_v4", + params: [address, typedMessage], + }); + const signedMessage = { + data: typedMessage, + sig: signature, + }; + + const recoveredAddress = recoverTypedSignature_v4( + signedMessage as any + ); + assert.equal(address.toLowerCase(), recoveredAddress.toLowerCase()); + }); + + it("should sign a message that is JSON stringified", async function () { + const signature = await this.provider.request({ + method: "eth_signTypedData_v4", + params: [address, JSON.stringify(typedMessage)], + }); + const signedMessage = { + data: typedMessage, + sig: signature, + }; + + const recoveredAddress = recoverTypedSignature_v4( + signedMessage as any + ); + assert.equal(address.toLowerCase(), recoveredAddress.toLowerCase()); + }); + + it("should fail with an invalid JSON", async function () { + try { + const signature = await this.provider.request({ + method: "eth_signTypedData_v4", + params: [address, "{an invalid JSON"], + }); + } catch (error) { + assert.include(error.message, "is an invalid JSON"); + return; + } + assert.fail("should have failed with an invalid JSON"); + }); }); describe("eth_submitHashrate", async function () { diff --git a/packages/hardhat-ethers/test/index.ts b/packages/hardhat-ethers/test/index.ts index f23a1a8304..c43ba11496 100644 --- a/packages/hardhat-ethers/test/index.ts +++ b/packages/hardhat-ethers/test/index.ts @@ -773,5 +773,56 @@ describe("Ethers plugin", function () { code = await this.env.ethers.provider.getCode(receipt.contractAddress); assert.lengthOf(code, 2); }); + + /* + it("_signTypedData integration test", async function () { + // See https://eips.ethereum.org/EIPS/eip-712#parameters + // There's a json schema and an explanation for each field. + const typedMessage = { + domain: { + chainId: 31337, + name: "Hardhat Network test suite", + }, + message: { + name: "Translation", + start: { + x: 200, + y: 600, + }, + end: { + x: 300, + y: 350, + }, + cost: 50, + }, + primaryType: "WeightedVector", + types: { + // ethers.js derives the EIP712Domain type from the domain object itself + // EIP712Domain: [ + // { name: "name", type: "string" }, + // { name: "chainId", type: "uint256" }, + // ], + WeightedVector: [ + { name: "name", type: "string" }, + { name: "start", type: "Point" }, + { name: "end", type: "Point" }, + { name: "cost", type: "uint256" }, + ], + Point: [ + { name: "x", type: "uint256" }, + { name: "y", type: "uint256" }, + ], + }, + }; + const signer = await this.env.ethers.provider.getSigner(0); + + const signature = await signer._signTypedData(typedMessage.domain, typedMessage.types, typedMessage.message); + + const byteToHex = 2; + const hexPrefix = 2; + const signatureSizeInBytes = 65 + assert.lengthOf(signature, signatureSizeInBytes * byteToHex + hexPrefix); + }); + */ }); }); From af7058459ff44d894b2a3380b7f6937ee87cc19a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Claudio=20Nale?= Date: Wed, 20 Jan 2021 00:24:00 -0300 Subject: [PATCH 2/8] Add a comment to the hardhat-ethers _signTypedData test. --- packages/hardhat-ethers/test/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/hardhat-ethers/test/index.ts b/packages/hardhat-ethers/test/index.ts index c43ba11496..54545afde5 100644 --- a/packages/hardhat-ethers/test/index.ts +++ b/packages/hardhat-ethers/test/index.ts @@ -775,6 +775,9 @@ describe("Ethers plugin", function () { }); /* + This test is commented out because it uses + Signer._signTypedData, an experimental ethers.js method + it("_signTypedData integration test", async function () { // See https://eips.ethereum.org/EIPS/eip-712#parameters // There's a json schema and an explanation for each field. From 1b9c11e45fef9cfa9c10e2b6b145fe54867d2e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Claudio=20Nale?= Date: Wed, 20 Jan 2021 12:50:12 -0300 Subject: [PATCH 3/8] Uncomment hardhat-ethers `_signTypedData` test. --- packages/hardhat-ethers/test/index.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/hardhat-ethers/test/index.ts b/packages/hardhat-ethers/test/index.ts index 54545afde5..a74eb149fa 100644 --- a/packages/hardhat-ethers/test/index.ts +++ b/packages/hardhat-ethers/test/index.ts @@ -774,10 +774,6 @@ describe("Ethers plugin", function () { assert.lengthOf(code, 2); }); - /* - This test is commented out because it uses - Signer._signTypedData, an experimental ethers.js method - it("_signTypedData integration test", async function () { // See https://eips.ethereum.org/EIPS/eip-712#parameters // There's a json schema and an explanation for each field. @@ -817,15 +813,18 @@ describe("Ethers plugin", function () { ], }, }; - const signer = await this.env.ethers.provider.getSigner(0); + const signer = this.env.ethers.provider.getSigner(0); - const signature = await signer._signTypedData(typedMessage.domain, typedMessage.types, typedMessage.message); + const signature = await signer._signTypedData( + typedMessage.domain, + typedMessage.types, + typedMessage.message + ); const byteToHex = 2; const hexPrefix = 2; - const signatureSizeInBytes = 65 + const signatureSizeInBytes = 65; assert.lengthOf(signature, signatureSizeInBytes * byteToHex + hexPrefix); }); - */ }); }); From 3ec7815278ce984ee5ae57fa16410f0b13e1a456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Claudio=20Nale?= Date: Mon, 1 Feb 2021 14:33:37 -0300 Subject: [PATCH 4/8] Remove `eth_signTypedData` JSON-RPC API. This marks it as unsupported. --- .../hardhat-network/provider/modules/eth.ts | 20 ++----- .../internal/hardhat-network/provider/node.ts | 12 ----- .../hardhat-network/provider/modules/eth.ts | 54 +------------------ 3 files changed, 7 insertions(+), 79 deletions(-) diff --git a/packages/hardhat-core/src/internal/hardhat-network/provider/modules/eth.ts b/packages/hardhat-core/src/internal/hardhat-network/provider/modules/eth.ts index a3c56ebff7..0a022e9d21 100644 --- a/packages/hardhat-core/src/internal/hardhat-network/provider/modules/eth.ts +++ b/packages/hardhat-core/src/internal/hardhat-network/provider/modules/eth.ts @@ -249,11 +249,15 @@ export class EthModule { throw new MethodNotSupportedError(method); case "eth_signTypedData": - return this._signTypedDataAction(...this._signTypedDataParams(params)); + throw new MethodNotSupportedError(method); case "eth_signTypedData_v3": throw new MethodNotSupportedError(method); + // TODO: we're currently mimicking the MetaMask implementation here. + // The EIP 712 is still a draft. It doesn't actually distinguish different versions + // of the eth_signTypedData API. + // Also, note that go-ethereum implemented this in a clef JSON-RPC API: account_signTypedData. case "eth_signTypedData_v4": return this._signTypedDataV4Action( ...this._signTypedDataV4Params(params) @@ -889,20 +893,6 @@ export class EthModule { // eth_signTransaction - // eth_signTypedData - - private _signTypedDataParams(params: any[]): [Buffer, any] { - // Validation of the TypedData parameter is handled by eth-sig-util - return validateParams(params, rpcAddress, rpcUnknown); - } - - private async _signTypedDataAction( - address: Buffer, - typedData: any - ): Promise { - return this._node.signTypedData(address, typedData); - } - // eth_signTypedData_v4 private _signTypedDataV4Params(params: any[]): [Buffer, any] { diff --git a/packages/hardhat-core/src/internal/hardhat-network/provider/node.ts b/packages/hardhat-core/src/internal/hardhat-network/provider/node.ts index 63619bc43a..3a4ea43133 100644 --- a/packages/hardhat-core/src/internal/hardhat-network/provider/node.ts +++ b/packages/hardhat-core/src/internal/hardhat-network/provider/node.ts @@ -620,18 +620,6 @@ export class HardhatNode extends EventEmitter { return ecsign(messageHash, privateKey); } - // TODO: we're currently mimicking the MetaMask implementation here. - // The EIP 712 is still a draft. It doesn't actually distinguish different versions - // of the eth_signTypedData API. - // Also, note that go-ethereum implemented this in a clef JSON-RPC API: account_signTypedData. - public async signTypedData(address: Buffer, typedData: any): Promise { - const privateKey = this._getLocalAccountPrivateKey(address); - - return ethSigUtil.signTypedData(privateKey, { - data: typedData, - }); - } - public async signTypedDataV4( address: Buffer, typedData: any diff --git a/packages/hardhat-core/test/internal/hardhat-network/provider/modules/eth.ts b/packages/hardhat-core/test/internal/hardhat-network/provider/modules/eth.ts index 52b8898437..854558c622 100644 --- a/packages/hardhat-core/test/internal/hardhat-network/provider/modules/eth.ts +++ b/packages/hardhat-core/test/internal/hardhat-network/provider/modules/eth.ts @@ -3392,58 +3392,8 @@ describe("Eth module", function () { }); describe("eth_signTypedData", function () { - it("should sign a message", async function () { - // See https://eips.ethereum.org/EIPS/eip-712#parameters - // There's a json schema and an explanation for each field. - const typedMessage = { - domain: { - chainId: 31337, - name: "Hardhat Network test suite", - }, - message: { - name: "Translation", - start: { - x: 200, - y: 600, - }, - end: { - x: 300, - y: 350, - }, - cost: 50, - }, - primaryType: "WeightedVector", - types: { - EIP712Domain: [ - { name: "name", type: "string" }, - { name: "chainId", type: "uint256" }, - ], - WeightedVector: [ - { name: "name", type: "string" }, - { name: "start", type: "Point" }, - { name: "end", type: "Point" }, - { name: "cost", type: "uint256" }, - ], - Point: [ - { name: "x", type: "uint256" }, - { name: "y", type: "uint256" }, - ], - }, - }; - - const [address] = DEFAULT_ACCOUNTS_ADDRESSES; - - const signature = await this.provider.request({ - method: "eth_signTypedData", - params: [address, typedMessage], - }); - const signedMessage = { - data: typedMessage, - sig: signature, - }; - - const recoveredAddress = recoverTypedSignature(signedMessage as any); - assert.equal(address.toLowerCase(), recoveredAddress.toLowerCase()); + it("is not supported", async function () { + await assertNotSupported(this.provider, "eth_signTypedData"); }); }); From c59e59bb65d1bc21d65f3c68c1bdd011eec119d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Claudio=20Nale?= Date: Mon, 1 Feb 2021 16:20:04 -0300 Subject: [PATCH 5/8] Add _signTypedData method to SignerWithAddress in hardhat-ethers. This restricts the type of the parameter for the creation of `SignerWithAddress` to an `ethers.provider.JsonRpcSigner` instead of an `ethers.Signer`. --- packages/hardhat-ethers/src/signers.ts | 29 ++++++++++++++++++++++++-- packages/hardhat-ethers/test/index.ts | 2 +- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/packages/hardhat-ethers/src/signers.ts b/packages/hardhat-ethers/src/signers.ts index 6ecf6df0b6..b7c0c6fa72 100644 --- a/packages/hardhat-ethers/src/signers.ts +++ b/packages/hardhat-ethers/src/signers.ts @@ -1,13 +1,30 @@ import { ethers } from "ethers"; +// This is taken from @ethersproject/abstract-signer package. +// EIP-712 Typed Data +// See: https://eips.ethereum.org/EIPS/eip-712 + +interface TypedDataDomain { + name?: string; + version?: string; + chainId?: ethers.BigNumberish; + verifyingContract?: string; + salt?: ethers.BytesLike; +} + +interface TypedDataField { + name: string; + type: string; +} + export class SignerWithAddress extends ethers.Signer { - public static async create(signer: ethers.Signer) { + public static async create(signer: ethers.providers.JsonRpcSigner) { return new SignerWithAddress(await signer.getAddress(), signer); } private constructor( public readonly address: string, - private readonly _signer: ethers.Signer + private readonly _signer: ethers.providers.JsonRpcSigner ) { super(); (this as any).provider = _signer.provider; @@ -37,6 +54,14 @@ export class SignerWithAddress extends ethers.Signer { return new SignerWithAddress(this.address, this._signer.connect(provider)); } + public _signTypedData( + domain: TypedDataDomain, + types: Record, + value: Record + ): Promise { + return this._signer._signTypedData(domain, types, value); + } + public toJSON() { return ``; } diff --git a/packages/hardhat-ethers/test/index.ts b/packages/hardhat-ethers/test/index.ts index a74eb149fa..2022bfbfb5 100644 --- a/packages/hardhat-ethers/test/index.ts +++ b/packages/hardhat-ethers/test/index.ts @@ -813,7 +813,7 @@ describe("Ethers plugin", function () { ], }, }; - const signer = this.env.ethers.provider.getSigner(0); + const [signer] = await this.env.ethers.getSigners(); const signature = await signer._signTypedData( typedMessage.domain, From f5e6e462608cd686877fc9690bd82cbe4f4ffd8f Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Mon, 8 Feb 2021 15:28:29 -0300 Subject: [PATCH 6/8] Reuse ethers' types --- packages/hardhat-ethers/src/signers.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/hardhat-ethers/src/signers.ts b/packages/hardhat-ethers/src/signers.ts index b7c0c6fa72..cc2098d36b 100644 --- a/packages/hardhat-ethers/src/signers.ts +++ b/packages/hardhat-ethers/src/signers.ts @@ -4,18 +4,12 @@ import { ethers } from "ethers"; // EIP-712 Typed Data // See: https://eips.ethereum.org/EIPS/eip-712 -interface TypedDataDomain { - name?: string; - version?: string; - chainId?: ethers.BigNumberish; - verifyingContract?: string; - salt?: ethers.BytesLike; -} +export type SignTypedDataParams = Parameters< + ethers.providers.JsonRpcSigner["_signTypedData"] +>; -interface TypedDataField { - name: string; - type: string; -} +export type TypedDataDomain = SignTypedDataParams[0]; +export type TypedDataFields = SignTypedDataParams[1]; export class SignerWithAddress extends ethers.Signer { public static async create(signer: ethers.providers.JsonRpcSigner) { @@ -56,7 +50,7 @@ export class SignerWithAddress extends ethers.Signer { public _signTypedData( domain: TypedDataDomain, - types: Record, + types: TypedDataFields, value: Record ): Promise { return this._signer._signTypedData(domain, types, value); From 45ef5353ee92e8fe5de1d3eed3b4c1f8d449aa8a Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Mon, 8 Feb 2021 15:30:01 -0300 Subject: [PATCH 7/8] Simplify the type --- packages/hardhat-ethers/src/signers.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/hardhat-ethers/src/signers.ts b/packages/hardhat-ethers/src/signers.ts index cc2098d36b..99b46f7c25 100644 --- a/packages/hardhat-ethers/src/signers.ts +++ b/packages/hardhat-ethers/src/signers.ts @@ -4,13 +4,6 @@ import { ethers } from "ethers"; // EIP-712 Typed Data // See: https://eips.ethereum.org/EIPS/eip-712 -export type SignTypedDataParams = Parameters< - ethers.providers.JsonRpcSigner["_signTypedData"] ->; - -export type TypedDataDomain = SignTypedDataParams[0]; -export type TypedDataFields = SignTypedDataParams[1]; - export class SignerWithAddress extends ethers.Signer { public static async create(signer: ethers.providers.JsonRpcSigner) { return new SignerWithAddress(await signer.getAddress(), signer); @@ -49,11 +42,9 @@ export class SignerWithAddress extends ethers.Signer { } public _signTypedData( - domain: TypedDataDomain, - types: TypedDataFields, - value: Record + ...params: Parameters ): Promise { - return this._signer._signTypedData(domain, types, value); + return this._signer._signTypedData(...params); } public toJSON() { From 51c1fc45b58319bf3157b20dce1d7c3814cd1fd5 Mon Sep 17 00:00:00 2001 From: Franco Victorio Date: Tue, 9 Feb 2021 15:24:09 -0300 Subject: [PATCH 8/8] Remove obsolete comment --- packages/hardhat-ethers/src/signers.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/hardhat-ethers/src/signers.ts b/packages/hardhat-ethers/src/signers.ts index 99b46f7c25..48294f1cb9 100644 --- a/packages/hardhat-ethers/src/signers.ts +++ b/packages/hardhat-ethers/src/signers.ts @@ -1,9 +1,5 @@ import { ethers } from "ethers"; -// This is taken from @ethersproject/abstract-signer package. -// EIP-712 Typed Data -// See: https://eips.ethereum.org/EIPS/eip-712 - export class SignerWithAddress extends ethers.Signer { public static async create(signer: ethers.providers.JsonRpcSigner) { return new SignerWithAddress(await signer.getAddress(), signer);