From adcfaa2e80389f69e196b602955cee858a1eb40f Mon Sep 17 00:00:00 2001 From: Jacob Evans Date: Mon, 1 Oct 2018 20:37:13 +1000 Subject: Expose eth_signTypedData functionality for order signing --- packages/web3-wrapper/src/web3_wrapper.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'packages/web3-wrapper') diff --git a/packages/web3-wrapper/src/web3_wrapper.ts b/packages/web3-wrapper/src/web3_wrapper.ts index d52c1cb6e..df6879a48 100644 --- a/packages/web3-wrapper/src/web3_wrapper.ts +++ b/packages/web3-wrapper/src/web3_wrapper.ts @@ -314,6 +314,21 @@ export class Web3Wrapper { }); return signData; } + /** + * Sign an EIP712 typed data message with a specific address's private key (`eth_signTypedData`) + * @param address Address of signer + * @param typedData Typed data message to sign + * @returns Signature string (might be VRS or RSV depending on the Signer) + */ + public async signTypedDataAsync(address: string, typedData: object): Promise { + assert.isETHAddressHex('address', address); + assert.doesConformToSchema('typedData', typedData, schemas.eip712TypedData); + const signData = await this.sendRawPayloadAsync({ + method: 'eth_signTypedData', + params: [address, typedData], + }); + return signData; + } /** * Fetches the latest block number * @returns Block number -- cgit v1.2.3