Update ZeroExTransactionSchema
This commit is contained in:
parent
9552676783
commit
1ada679663
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "/zeroExTransactionSchema",
|
"id": "/zeroExTransactionSchema",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"verifyingContractAddress": { "$ref": "/addressSchema" },
|
||||||
"data": { "$ref": "/hexSchema" },
|
"data": { "$ref": "/hexSchema" },
|
||||||
"signerAddress": { "$ref": "/addressSchema" },
|
"signerAddress": { "$ref": "/addressSchema" },
|
||||||
"salt": { "$ref": "/wholeNumberSchema" }
|
"salt": { "$ref": "/wholeNumberSchema" }
|
||||||
|
@ -63,11 +63,8 @@ export const eip712Utils = {
|
|||||||
* @param exchangeAddress The address of the exchange contract
|
* @param exchangeAddress The address of the exchange contract
|
||||||
* @return A typed data object
|
* @return A typed data object
|
||||||
*/
|
*/
|
||||||
createZeroExTransactionTypedData: (
|
createZeroExTransactionTypedData: (zeroExTransaction: ZeroExTransaction): EIP712TypedData => {
|
||||||
zeroExTransaction: ZeroExTransaction,
|
assert.isETHAddressHex('verifyingContractAddress', zeroExTransaction.verifyingContractAddress);
|
||||||
exchangeAddress: string,
|
|
||||||
): EIP712TypedData => {
|
|
||||||
assert.isETHAddressHex('exchangeAddress', exchangeAddress);
|
|
||||||
assert.doesConformToSchema('zeroExTransaction', zeroExTransaction, schemas.zeroExTransactionSchema);
|
assert.doesConformToSchema('zeroExTransaction', zeroExTransaction, schemas.zeroExTransactionSchema);
|
||||||
const normalizedTransaction = _.mapValues(zeroExTransaction, value => {
|
const normalizedTransaction = _.mapValues(zeroExTransaction, value => {
|
||||||
return !_.isString(value) ? value.toString() : value;
|
return !_.isString(value) ? value.toString() : value;
|
||||||
@ -76,7 +73,7 @@ export const eip712Utils = {
|
|||||||
constants.EIP712_ZEROEX_TRANSACTION_SCHEMA.name,
|
constants.EIP712_ZEROEX_TRANSACTION_SCHEMA.name,
|
||||||
{ ZeroExTransaction: constants.EIP712_ZEROEX_TRANSACTION_SCHEMA.parameters },
|
{ ZeroExTransaction: constants.EIP712_ZEROEX_TRANSACTION_SCHEMA.parameters },
|
||||||
normalizedTransaction,
|
normalizedTransaction,
|
||||||
exchangeAddress,
|
zeroExTransaction.verifyingContractAddress,
|
||||||
);
|
);
|
||||||
return typedData;
|
return typedData;
|
||||||
},
|
},
|
||||||
|
@ -29,14 +29,12 @@ describe('EIP712 Utils', () => {
|
|||||||
});
|
});
|
||||||
describe('createTypedData', () => {
|
describe('createTypedData', () => {
|
||||||
it('adds in the EIP712DomainSeparator', () => {
|
it('adds in the EIP712DomainSeparator', () => {
|
||||||
const typedData = eip712Utils.createZeroExTransactionTypedData(
|
const typedData = eip712Utils.createZeroExTransactionTypedData({
|
||||||
{
|
salt: new BigNumber('0'),
|
||||||
salt: new BigNumber('0'),
|
data: constants.NULL_BYTES,
|
||||||
data: constants.NULL_BYTES,
|
signerAddress: constants.NULL_ADDRESS,
|
||||||
signerAddress: constants.NULL_ADDRESS,
|
verifyingContractAddress: constants.NULL_ADDRESS,
|
||||||
},
|
});
|
||||||
constants.NULL_ADDRESS,
|
|
||||||
);
|
|
||||||
expect(typedData.primaryType).to.eq(constants.EIP712_ZEROEX_TRANSACTION_SCHEMA.name);
|
expect(typedData.primaryType).to.eq(constants.EIP712_ZEROEX_TRANSACTION_SCHEMA.name);
|
||||||
expect(typedData.types.EIP712Domain).to.not.be.undefined();
|
expect(typedData.types.EIP712Domain).to.not.be.undefined();
|
||||||
});
|
});
|
||||||
|
@ -45,11 +45,16 @@ export interface SignedOrder extends Order {
|
|||||||
* ZeroExTransaction for use with 0x Exchange executeTransaction
|
* ZeroExTransaction for use with 0x Exchange executeTransaction
|
||||||
*/
|
*/
|
||||||
export interface ZeroExTransaction {
|
export interface ZeroExTransaction {
|
||||||
|
verifyingContractAddress: string;
|
||||||
salt: BigNumber;
|
salt: BigNumber;
|
||||||
signerAddress: string;
|
signerAddress: string;
|
||||||
data: string;
|
data: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SignedZeroExTransaction extends ZeroExTransaction {
|
||||||
|
signature: string;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Elliptic Curve signature
|
* Elliptic Curve signature
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user