diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2019-02-02 06:55:36 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2019-02-06 01:23:09 +0800 |
commit | 1ada6796631ad4e281423407f6eb2602a16f119e (patch) | |
tree | 68739c29fe58c5959ae8c04623d7e94a171ce0ac /packages | |
parent | 95526767836c81949213da7e1c44d4e02fdffc71 (diff) | |
download | dexon-0x-contracts-1ada6796631ad4e281423407f6eb2602a16f119e.tar.gz dexon-0x-contracts-1ada6796631ad4e281423407f6eb2602a16f119e.tar.zst dexon-0x-contracts-1ada6796631ad4e281423407f6eb2602a16f119e.zip |
Update ZeroExTransactionSchema
Diffstat (limited to 'packages')
-rw-r--r-- | packages/json-schemas/schemas/zero_ex_transaction_schema.json | 1 | ||||
-rw-r--r-- | packages/order-utils/src/eip712_utils.ts | 9 | ||||
-rw-r--r-- | packages/order-utils/test/eip712_utils_test.ts | 14 | ||||
-rw-r--r-- | packages/types/src/index.ts | 5 |
4 files changed, 15 insertions, 14 deletions
diff --git a/packages/json-schemas/schemas/zero_ex_transaction_schema.json b/packages/json-schemas/schemas/zero_ex_transaction_schema.json index 0c714f14d..726886e20 100644 --- a/packages/json-schemas/schemas/zero_ex_transaction_schema.json +++ b/packages/json-schemas/schemas/zero_ex_transaction_schema.json @@ -1,6 +1,7 @@ { "id": "/zeroExTransactionSchema", "properties": { + "verifyingContractAddress": { "$ref": "/addressSchema" }, "data": { "$ref": "/hexSchema" }, "signerAddress": { "$ref": "/addressSchema" }, "salt": { "$ref": "/wholeNumberSchema" } diff --git a/packages/order-utils/src/eip712_utils.ts b/packages/order-utils/src/eip712_utils.ts index 385fda989..646d9e301 100644 --- a/packages/order-utils/src/eip712_utils.ts +++ b/packages/order-utils/src/eip712_utils.ts @@ -63,11 +63,8 @@ export const eip712Utils = { * @param exchangeAddress The address of the exchange contract * @return A typed data object */ - createZeroExTransactionTypedData: ( - zeroExTransaction: ZeroExTransaction, - exchangeAddress: string, - ): EIP712TypedData => { - assert.isETHAddressHex('exchangeAddress', exchangeAddress); + createZeroExTransactionTypedData: (zeroExTransaction: ZeroExTransaction): EIP712TypedData => { + assert.isETHAddressHex('verifyingContractAddress', zeroExTransaction.verifyingContractAddress); assert.doesConformToSchema('zeroExTransaction', zeroExTransaction, schemas.zeroExTransactionSchema); const normalizedTransaction = _.mapValues(zeroExTransaction, value => { return !_.isString(value) ? value.toString() : value; @@ -76,7 +73,7 @@ export const eip712Utils = { constants.EIP712_ZEROEX_TRANSACTION_SCHEMA.name, { ZeroExTransaction: constants.EIP712_ZEROEX_TRANSACTION_SCHEMA.parameters }, normalizedTransaction, - exchangeAddress, + zeroExTransaction.verifyingContractAddress, ); return typedData; }, diff --git a/packages/order-utils/test/eip712_utils_test.ts b/packages/order-utils/test/eip712_utils_test.ts index a54e49958..fb9388fcc 100644 --- a/packages/order-utils/test/eip712_utils_test.ts +++ b/packages/order-utils/test/eip712_utils_test.ts @@ -29,14 +29,12 @@ describe('EIP712 Utils', () => { }); describe('createTypedData', () => { it('adds in the EIP712DomainSeparator', () => { - const typedData = eip712Utils.createZeroExTransactionTypedData( - { - salt: new BigNumber('0'), - data: constants.NULL_BYTES, - signerAddress: constants.NULL_ADDRESS, - }, - constants.NULL_ADDRESS, - ); + const typedData = eip712Utils.createZeroExTransactionTypedData({ + salt: new BigNumber('0'), + data: constants.NULL_BYTES, + signerAddress: constants.NULL_ADDRESS, + verifyingContractAddress: constants.NULL_ADDRESS, + }); expect(typedData.primaryType).to.eq(constants.EIP712_ZEROEX_TRANSACTION_SCHEMA.name); expect(typedData.types.EIP712Domain).to.not.be.undefined(); }); diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 49f788fb0..ce124e289 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -45,11 +45,16 @@ export interface SignedOrder extends Order { * ZeroExTransaction for use with 0x Exchange executeTransaction */ export interface ZeroExTransaction { + verifyingContractAddress: string; salt: BigNumber; signerAddress: string; data: string; } +export interface SignedZeroExTransaction extends ZeroExTransaction { + signature: string; +} + /** * Elliptic Curve signature */ |