Update contracts/test-utils to use new Order structure and domain schema.
This commit is contained in:
committed by
Amir Bandeali
parent
4aae7348d1
commit
259b463b73
@@ -14,7 +14,7 @@ export const formatters = {
|
||||
takerAssetFillAmounts,
|
||||
};
|
||||
_.forEach(signedOrders, signedOrder => {
|
||||
const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder);
|
||||
const orderWithoutExchangeAddress = orderUtils.getOrderWithoutDomain(signedOrder);
|
||||
batchFill.orders.push(orderWithoutExchangeAddress);
|
||||
batchFill.signatures.push(signedOrder.signature);
|
||||
if (takerAssetFillAmounts.length < signedOrders.length) {
|
||||
@@ -30,7 +30,7 @@ export const formatters = {
|
||||
takerAssetFillAmount,
|
||||
};
|
||||
_.forEach(signedOrders, (signedOrder, i) => {
|
||||
const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder);
|
||||
const orderWithoutExchangeAddress = orderUtils.getOrderWithoutDomain(signedOrder);
|
||||
if (i !== 0) {
|
||||
orderWithoutExchangeAddress.takerAssetData = constants.NULL_BYTES;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ export const formatters = {
|
||||
makerAssetFillAmount,
|
||||
};
|
||||
_.forEach(signedOrders, (signedOrder, i) => {
|
||||
const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder);
|
||||
const orderWithoutExchangeAddress = orderUtils.getOrderWithoutDomain(signedOrder);
|
||||
if (i !== 0) {
|
||||
orderWithoutExchangeAddress.makerAssetData = constants.NULL_BYTES;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ export const formatters = {
|
||||
orders: [],
|
||||
};
|
||||
_.forEach(signedOrders, signedOrder => {
|
||||
const orderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(signedOrder);
|
||||
const orderWithoutExchangeAddress = orderUtils.getOrderWithoutDomain(signedOrder);
|
||||
batchCancel.orders.push(orderWithoutExchangeAddress);
|
||||
});
|
||||
return batchCancel;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { OrderWithoutExchangeAddress, SignedOrder } from '@0x/types';
|
||||
import { OrderWithoutDomain, SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
|
||||
import { constants } from './constants';
|
||||
import { CancelOrder, MatchOrder } from './types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
export const orderUtils = {
|
||||
getPartialAmountFloor(numerator: BigNumber, denominator: BigNumber, target: BigNumber): BigNumber {
|
||||
@@ -14,7 +15,7 @@ export const orderUtils = {
|
||||
},
|
||||
createFill: (signedOrder: SignedOrder, takerAssetFillAmount?: BigNumber) => {
|
||||
const fill = {
|
||||
order: orderUtils.getOrderWithoutExchangeAddress(signedOrder),
|
||||
order: orderUtils.getOrderWithoutDomain(signedOrder),
|
||||
takerAssetFillAmount: takerAssetFillAmount || signedOrder.takerAssetAmount,
|
||||
signature: signedOrder.signature,
|
||||
};
|
||||
@@ -22,32 +23,18 @@ export const orderUtils = {
|
||||
},
|
||||
createCancel(signedOrder: SignedOrder, takerAssetCancelAmount?: BigNumber): CancelOrder {
|
||||
const cancel = {
|
||||
order: orderUtils.getOrderWithoutExchangeAddress(signedOrder),
|
||||
order: orderUtils.getOrderWithoutDomain(signedOrder),
|
||||
takerAssetCancelAmount: takerAssetCancelAmount || signedOrder.takerAssetAmount,
|
||||
};
|
||||
return cancel;
|
||||
},
|
||||
getOrderWithoutExchangeAddress(signedOrder: SignedOrder): OrderWithoutExchangeAddress {
|
||||
const orderStruct = {
|
||||
senderAddress: signedOrder.senderAddress,
|
||||
makerAddress: signedOrder.makerAddress,
|
||||
takerAddress: signedOrder.takerAddress,
|
||||
feeRecipientAddress: signedOrder.feeRecipientAddress,
|
||||
makerAssetAmount: signedOrder.makerAssetAmount,
|
||||
takerAssetAmount: signedOrder.takerAssetAmount,
|
||||
makerFee: signedOrder.makerFee,
|
||||
takerFee: signedOrder.takerFee,
|
||||
expirationTimeSeconds: signedOrder.expirationTimeSeconds,
|
||||
salt: signedOrder.salt,
|
||||
makerAssetData: signedOrder.makerAssetData,
|
||||
takerAssetData: signedOrder.takerAssetData,
|
||||
};
|
||||
return orderStruct;
|
||||
getOrderWithoutDomain(signedOrder: SignedOrder): OrderWithoutDomain {
|
||||
return _.omit(signedOrder, ['signature', 'domain']) as OrderWithoutDomain;
|
||||
},
|
||||
createMatchOrders(signedOrderLeft: SignedOrder, signedOrderRight: SignedOrder): MatchOrder {
|
||||
const fill = {
|
||||
left: orderUtils.getOrderWithoutExchangeAddress(signedOrderLeft),
|
||||
right: orderUtils.getOrderWithoutExchangeAddress(signedOrderRight),
|
||||
left: orderUtils.getOrderWithoutDomain(signedOrderLeft),
|
||||
right: orderUtils.getOrderWithoutDomain(signedOrderRight),
|
||||
leftSignature: signedOrderLeft.signature,
|
||||
rightSignature: signedOrderRight.signature,
|
||||
};
|
||||
|
||||
@@ -26,8 +26,10 @@ export class TransactionFactory {
|
||||
salt,
|
||||
signerAddress,
|
||||
data,
|
||||
verifyingContractAddress: this._exchangeAddress,
|
||||
chainId: this._chainId,
|
||||
domain: {
|
||||
verifyingContractAddress: this._exchangeAddress,
|
||||
chainId: this._chainId,
|
||||
},
|
||||
};
|
||||
|
||||
const transactionHashBuffer = transactionHashUtils.getTransactionHashBuffer(transaction);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { OrderWithoutExchangeAddress } from '@0x/types';
|
||||
import { OrderWithoutDomain } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { AbiDefinition } from 'ethereum-types';
|
||||
|
||||
@@ -40,25 +40,25 @@ export interface SubmissionContractEventArgs {
|
||||
}
|
||||
|
||||
export interface BatchFillOrders {
|
||||
orders: OrderWithoutExchangeAddress[];
|
||||
orders: OrderWithoutDomain[];
|
||||
signatures: string[];
|
||||
takerAssetFillAmounts: BigNumber[];
|
||||
}
|
||||
|
||||
export interface MarketSellOrders {
|
||||
orders: OrderWithoutExchangeAddress[];
|
||||
orders: OrderWithoutDomain[];
|
||||
signatures: string[];
|
||||
takerAssetFillAmount: BigNumber;
|
||||
}
|
||||
|
||||
export interface MarketBuyOrders {
|
||||
orders: OrderWithoutExchangeAddress[];
|
||||
orders: OrderWithoutDomain[];
|
||||
signatures: string[];
|
||||
makerAssetFillAmount: BigNumber;
|
||||
}
|
||||
|
||||
export interface BatchCancelOrders {
|
||||
orders: OrderWithoutExchangeAddress[];
|
||||
orders: OrderWithoutDomain[];
|
||||
}
|
||||
|
||||
export interface CancelOrdersBefore {
|
||||
@@ -159,13 +159,13 @@ export interface OrderInfo {
|
||||
}
|
||||
|
||||
export interface CancelOrder {
|
||||
order: OrderWithoutExchangeAddress;
|
||||
order: OrderWithoutDomain;
|
||||
takerAssetCancelAmount: BigNumber;
|
||||
}
|
||||
|
||||
export interface MatchOrder {
|
||||
left: OrderWithoutExchangeAddress;
|
||||
right: OrderWithoutExchangeAddress;
|
||||
left: OrderWithoutDomain;
|
||||
right: OrderWithoutDomain;
|
||||
leftSignature: string;
|
||||
rightSignature: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user