diff options
author | Jacob Evans <jacob@dekz.net> | 2018-10-09 15:26:13 +0800 |
---|---|---|
committer | Jacob Evans <jacob@dekz.net> | 2018-10-09 16:01:36 +0800 |
commit | 9e8031d5e3cf94cabe07685be510397367e90413 (patch) | |
tree | 548a3918ed9eb5325db3973d76924907b142aae0 /packages/utils | |
parent | e1236a484623e9d2caab823c476175cb255ae816 (diff) | |
download | dexon-sol-tools-9e8031d5e3cf94cabe07685be510397367e90413.tar.gz dexon-sol-tools-9e8031d5e3cf94cabe07685be510397367e90413.tar.zst dexon-sol-tools-9e8031d5e3cf94cabe07685be510397367e90413.zip |
Throw and handle errors from Providers.
In web3 wrapper when a response contains an error field we throw this rather than return response.result which is often undefined.
In Signature Utils we handle the error thrown when a user rejects the signing dialogue to prevent double signing.
Exposed the ZeroExTransaction JSON schema.
In Website only use the MetamaskSubprovider if we can detect the provider is Metamask
Diffstat (limited to 'packages/utils')
-rw-r--r-- | packages/utils/src/sign_typed_data_utils.ts | 6 | ||||
-rw-r--r-- | packages/utils/test/sign_typed_data_utils_test.ts | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/packages/utils/src/sign_typed_data_utils.ts b/packages/utils/src/sign_typed_data_utils.ts index 657a59ed0..cd5bcb42f 100644 --- a/packages/utils/src/sign_typed_data_utils.ts +++ b/packages/utils/src/sign_typed_data_utils.ts @@ -6,11 +6,11 @@ import { EIP712Object, EIP712ObjectValue, EIP712TypedData, EIP712Types } from '@ export const signTypedDataUtils = { /** - * Computes the Sign Typed Data hash + * Generates the EIP712 Typed Data hash for signing * @param typedData An object that conforms to the EIP712TypedData interface - * @return A Buffer containing the hash of the sign typed data. + * @return A Buffer containing the hash of the typed data. */ - signTypedDataHash(typedData: EIP712TypedData): Buffer { + generateTypedDataHash(typedData: EIP712TypedData): Buffer { return ethUtil.sha3( Buffer.concat([ Buffer.from('1901', 'hex'), diff --git a/packages/utils/test/sign_typed_data_utils_test.ts b/packages/utils/test/sign_typed_data_utils_test.ts index e1cb4f6e1..dcba08b04 100644 --- a/packages/utils/test/sign_typed_data_utils_test.ts +++ b/packages/utils/test/sign_typed_data_utils_test.ts @@ -127,12 +127,12 @@ describe('signTypedDataUtils', () => { primaryType: 'Order', }; it('creates a hash of the test sign typed data', () => { - const hash = signTypedDataUtils.signTypedDataHash(simpleSignTypedData).toString('hex'); + const hash = signTypedDataUtils.generateTypedDataHash(simpleSignTypedData).toString('hex'); const hashHex = `0x${hash}`; expect(hashHex).to.be.eq(simpleSignTypedDataHashHex); }); it('creates a hash of the order sign typed data', () => { - const hash = signTypedDataUtils.signTypedDataHash(orderSignTypedData).toString('hex'); + const hash = signTypedDataUtils.generateTypedDataHash(orderSignTypedData).toString('hex'); const hashHex = `0x${hash}`; expect(hashHex).to.be.eq(orderSignTypedDataHashHex); }); |