diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-10-10 09:25:14 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-10-10 09:25:14 +0800 |
commit | 2bd8cbb80cadc922ca13582a1f15d63815118205 (patch) | |
tree | f81ae5e91e720fe228d83b0e8af0fc676f35b7c5 /packages/web3-wrapper/src | |
parent | 941448d65cc42870a93e0430158bfd7ab52fd2cd (diff) | |
parent | afb34da72978b5272cfb5a235498e483c72556bc (diff) | |
download | dexon-sol-tools-2bd8cbb80cadc922ca13582a1f15d63815118205.tar dexon-sol-tools-2bd8cbb80cadc922ca13582a1f15d63815118205.tar.gz dexon-sol-tools-2bd8cbb80cadc922ca13582a1f15d63815118205.tar.bz2 dexon-sol-tools-2bd8cbb80cadc922ca13582a1f15d63815118205.tar.lz dexon-sol-tools-2bd8cbb80cadc922ca13582a1f15d63815118205.tar.xz dexon-sol-tools-2bd8cbb80cadc922ca13582a1f15d63815118205.tar.zst dexon-sol-tools-2bd8cbb80cadc922ca13582a1f15d63815118205.zip |
Merge branch 'development' of https://github.com/0xProject/0x-monorepo into feature/instant/redux-styles-container
Diffstat (limited to 'packages/web3-wrapper/src')
-rw-r--r-- | packages/web3-wrapper/src/index.ts | 1 | ||||
-rw-r--r-- | packages/web3-wrapper/src/web3_wrapper.ts | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/packages/web3-wrapper/src/index.ts b/packages/web3-wrapper/src/index.ts index 7cdd25e55..9bef06fd4 100644 --- a/packages/web3-wrapper/src/index.ts +++ b/packages/web3-wrapper/src/index.ts @@ -30,6 +30,7 @@ export { OpCode, TxDataPayable, JSONRPCResponsePayload, + JSONRPCResponseError, RawLogEntry, DecodedLogEntryEvent, LogWithDecodedArgs, 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; } |