Fix outdated comments and make verifyingContractAddress a required part of the 0x tx schema

This commit is contained in:
Amir Bandeali 2019-02-04 09:48:11 -08:00
parent 8246dec843
commit eac254f925
3 changed files with 11 additions and 7 deletions

View File

@ -6,6 +6,6 @@
"signerAddress": { "$ref": "/addressSchema" },
"salt": { "$ref": "/wholeNumberSchema" }
},
"required": ["data", "salt", "signerAddress"],
"required": ["verifyingContractAddress", "data", "salt", "signerAddress"],
"type": "object"
}

View File

@ -4,6 +4,7 @@ import { signTypedDataUtils } from '@0x/utils';
import * as _ from 'lodash';
import { assert } from './assert';
import { constants } from './constants';
import { eip712Utils } from './eip712_utils';
const INVALID_TAKER_FORMAT = 'instance.takerAddress is not of a type(s) string';
@ -34,8 +35,9 @@ export const orderHashUtils = {
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';
const errMsg = `Order taker must be of type string. If you want anyone to be able to fill an order - pass ${
constants.NULL_ADDRESS
}`;
throw new Error(errMsg);
}
throw error;
@ -55,8 +57,9 @@ export const orderHashUtils = {
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';
const errMsg = `Order taker must be of type string. If you want anyone to be able to fill an order - pass ${
constants.NULL_ADDRESS
}`;
throw new Error(errMsg);
}
throw error;

View File

@ -54,8 +54,9 @@ describe('Order hashing', () => {
...order,
takerAddress: (null as any) as string,
};
const expectedErrorMessage =
'Order taker must be of type string. If you want anyone to be able to fill an order - pass ZeroEx.NULL_ADDRESS';
const expectedErrorMessage = `Order taker must be of type string. If you want anyone to be able to fill an order - pass ${
constants.NULL_ADDRESS
}`;
expect(() => orderHashUtils.getOrderHashHex(orderWithInvalidtakerFormat)).to.throw(expectedErrorMessage);
});
});