diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2019-02-02 06:54:37 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2019-02-06 01:23:09 +0800 |
commit | 95526767836c81949213da7e1c44d4e02fdffc71 (patch) | |
tree | 228aab704e42349ac8d40bd7135a8e5a86c57728 /packages/order-utils/src | |
parent | 69c7c03fb34b3f21f65c40b73baa21184a296fb2 (diff) | |
download | dexon-0x-contracts-95526767836c81949213da7e1c44d4e02fdffc71.tar dexon-0x-contracts-95526767836c81949213da7e1c44d4e02fdffc71.tar.gz dexon-0x-contracts-95526767836c81949213da7e1c44d4e02fdffc71.tar.bz2 dexon-0x-contracts-95526767836c81949213da7e1c44d4e02fdffc71.tar.lz dexon-0x-contracts-95526767836c81949213da7e1c44d4e02fdffc71.tar.xz dexon-0x-contracts-95526767836c81949213da7e1c44d4e02fdffc71.tar.zst dexon-0x-contracts-95526767836c81949213da7e1c44d4e02fdffc71.zip |
Add schema validation to getOrderHashBuff
Diffstat (limited to 'packages/order-utils/src')
-rw-r--r-- | packages/order-utils/src/order_hash.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/packages/order-utils/src/order_hash.ts b/packages/order-utils/src/order_hash.ts index c8e9be71e..b15ccacf7 100644 --- a/packages/order-utils/src/order_hash.ts +++ b/packages/order-utils/src/order_hash.ts @@ -51,6 +51,17 @@ export const orderHashUtils = { * @return A Buffer containing the resulting orderHash from hashing the supplied order */ getOrderHashBuffer(order: SignedOrder | Order): Buffer { + try { + assert.doesConformToSchema('order', order, schemas.orderSchema, [schemas.hexSchema]); + } catch (error) { + if (_.includes(error.message, INVALID_TAKER_FORMAT)) { + const errMsg = + 'Order taker must be of type string. If you want anyone to be able to fill an order - pass ZeroEx.NULL_ADDRESS'; + throw new Error(errMsg); + } + throw error; + } + const typedData = eip712Utils.createOrderTypedData(order); const orderHashBuff = signTypedDataUtils.generateTypedDataHash(typedData); return orderHashBuff; |