aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web3-wrapper/src/web3_wrapper.ts
diff options
context:
space:
mode:
authorJacob Evans <dekz@dekz.net>2018-10-09 18:17:11 +0800
committerGitHub <noreply@github.com>2018-10-09 18:17:11 +0800
commit024bcf492ddbdceb033466aeadef220adc145332 (patch)
tree01a364d769f3eede04f4bd1e4a743784d39eea91 /packages/web3-wrapper/src/web3_wrapper.ts
parent3ac9dac4f0a6b3875b7ae0ea6dd1855743768ef2 (diff)
parent75b9e639194e98febf8e378619afef2d578cbc7e (diff)
downloaddexon-sol-tools-024bcf492ddbdceb033466aeadef220adc145332.tar
dexon-sol-tools-024bcf492ddbdceb033466aeadef220adc145332.tar.gz
dexon-sol-tools-024bcf492ddbdceb033466aeadef220adc145332.tar.bz2
dexon-sol-tools-024bcf492ddbdceb033466aeadef220adc145332.tar.lz
dexon-sol-tools-024bcf492ddbdceb033466aeadef220adc145332.tar.xz
dexon-sol-tools-024bcf492ddbdceb033466aeadef220adc145332.tar.zst
dexon-sol-tools-024bcf492ddbdceb033466aeadef220adc145332.zip
Merge pull request #1102 from 0xProject/feature/0x.js/eip712-sign-typed-data
[0x.js][order-utils][web3-wrapper] Expose eth_signTypedData functionality for order signing
Diffstat (limited to 'packages/web3-wrapper/src/web3_wrapper.ts')
-rw-r--r--packages/web3-wrapper/src/web3_wrapper.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/web3-wrapper/src/web3_wrapper.ts b/packages/web3-wrapper/src/web3_wrapper.ts
index d52c1cb6e..726246f1a 100644
--- a/packages/web3-wrapper/src/web3_wrapper.ts
+++ b/packages/web3-wrapper/src/web3_wrapper.ts
@@ -315,6 +315,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 (as RSV)
+ */
+ public async signTypedDataAsync(address: string, typedData: any): Promise<string> {
+ assert.isETHAddressHex('address', address);
+ assert.doesConformToSchema('typedData', typedData, schemas.eip712TypedDataSchema);
+ const signData = await this.sendRawPayloadAsync<string>({
+ method: 'eth_signTypedData',
+ params: [address, typedData],
+ });
+ return signData;
+ }
+ /**
* Fetches the latest block number
* @returns Block number
*/
@@ -654,6 +669,9 @@ export class Web3Wrapper {
...payload,
};
const response = await promisify<JSONRPCResponsePayload>(sendAsync)(payloadWithDefaults);
+ if (response.error) {
+ throw new Error(response.error.message);
+ }
const result = response.result;
return result;
}