Move constants and exchangeDataEncoder into test-utils package
This commit is contained in:
		@@ -9,7 +9,8 @@ import {
 | 
			
		||||
} from '@0x/contracts-exchange';
 | 
			
		||||
import {
 | 
			
		||||
    chaiSetup,
 | 
			
		||||
    constants as devConstants,
 | 
			
		||||
    constants,
 | 
			
		||||
    exchangeDataEncoder,
 | 
			
		||||
    expectTransactionFailedAsync,
 | 
			
		||||
    getLatestBlockTimestampAsync,
 | 
			
		||||
    OrderFactory,
 | 
			
		||||
@@ -25,7 +26,7 @@ import { BigNumber, providerUtils } from '@0x/utils';
 | 
			
		||||
import * as chai from 'chai';
 | 
			
		||||
import { LogWithDecodedArgs } from 'ethereum-types';
 | 
			
		||||
 | 
			
		||||
import { ApprovalFactory, artifacts, constants, CoordinatorContract, exchangeDataEncoder } from '../src';
 | 
			
		||||
import { ApprovalFactory, artifacts, CoordinatorContract } from '../src';
 | 
			
		||||
 | 
			
		||||
chaiSetup.configure();
 | 
			
		||||
const expect = chai.expect;
 | 
			
		||||
@@ -68,7 +69,7 @@ describe('Coordinator tests', () => {
 | 
			
		||||
        const numDummyErc20ToDeploy = 3;
 | 
			
		||||
        [erc20TokenA, erc20TokenB, zrxToken] = await erc20Wrapper.deployDummyTokensAsync(
 | 
			
		||||
            numDummyErc20ToDeploy,
 | 
			
		||||
            devConstants.DUMMY_TOKEN_DECIMALS,
 | 
			
		||||
            constants.DUMMY_TOKEN_DECIMALS,
 | 
			
		||||
        );
 | 
			
		||||
        await erc20Wrapper.setBalancesAndAllowancesAsync();
 | 
			
		||||
 | 
			
		||||
@@ -82,12 +83,12 @@ describe('Coordinator tests', () => {
 | 
			
		||||
 | 
			
		||||
        await web3Wrapper.awaitTransactionSuccessAsync(
 | 
			
		||||
            await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner }),
 | 
			
		||||
            devConstants.AWAIT_TRANSACTION_MINED_MS,
 | 
			
		||||
            constants.AWAIT_TRANSACTION_MINED_MS,
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        await web3Wrapper.awaitTransactionSuccessAsync(
 | 
			
		||||
            await exchange.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { from: owner }),
 | 
			
		||||
            devConstants.AWAIT_TRANSACTION_MINED_MS,
 | 
			
		||||
            constants.AWAIT_TRANSACTION_MINED_MS,
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        coordinatorContract = await CoordinatorContract.deployFrom0xArtifactAsync(
 | 
			
		||||
@@ -100,7 +101,7 @@ describe('Coordinator tests', () => {
 | 
			
		||||
 | 
			
		||||
        // Configure order defaults
 | 
			
		||||
        const defaultOrderParams = {
 | 
			
		||||
            ...devConstants.STATIC_ORDER_PARAMS,
 | 
			
		||||
            ...constants.STATIC_ORDER_PARAMS,
 | 
			
		||||
            senderAddress: coordinatorContract.address,
 | 
			
		||||
            makerAddress,
 | 
			
		||||
            feeRecipientAddress,
 | 
			
		||||
@@ -111,9 +112,9 @@ describe('Coordinator tests', () => {
 | 
			
		||||
                chainId,
 | 
			
		||||
            },
 | 
			
		||||
        };
 | 
			
		||||
        const makerPrivateKey = devConstants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
 | 
			
		||||
        const takerPrivateKey = devConstants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(takerAddress)];
 | 
			
		||||
        const feeRecipientPrivateKey = devConstants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(feeRecipientAddress)];
 | 
			
		||||
        const makerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
 | 
			
		||||
        const takerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(takerAddress)];
 | 
			
		||||
        const feeRecipientPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(feeRecipientAddress)];
 | 
			
		||||
        orderFactory = new OrderFactory(makerPrivateKey, defaultOrderParams);
 | 
			
		||||
        makerTransactionFactory = new TransactionFactory(makerPrivateKey, exchange.address, chainId);
 | 
			
		||||
        takerTransactionFactory = new TransactionFactory(takerPrivateKey, exchange.address, chainId);
 | 
			
		||||
@@ -148,7 +149,7 @@ describe('Coordinator tests', () => {
 | 
			
		||||
                        [approval.signature],
 | 
			
		||||
                        { from: takerAddress },
 | 
			
		||||
                    ),
 | 
			
		||||
                    devConstants.AWAIT_TRANSACTION_MINED_MS,
 | 
			
		||||
                    constants.AWAIT_TRANSACTION_MINED_MS,
 | 
			
		||||
                );
 | 
			
		||||
                const fillLogs = transactionReceipt.logs.filter(
 | 
			
		||||
                    log => (log as LogWithDecodedArgs<ExchangeFillEventArgs>).event === 'Fill',
 | 
			
		||||
@@ -180,7 +181,7 @@ describe('Coordinator tests', () => {
 | 
			
		||||
                        [],
 | 
			
		||||
                        { from: feeRecipientAddress },
 | 
			
		||||
                    ),
 | 
			
		||||
                    devConstants.AWAIT_TRANSACTION_MINED_MS,
 | 
			
		||||
                    constants.AWAIT_TRANSACTION_MINED_MS,
 | 
			
		||||
                );
 | 
			
		||||
                const fillLogs = transactionReceipt.logs.filter(
 | 
			
		||||
                    log => (log as LogWithDecodedArgs<ExchangeFillEventArgs>).event === 'Fill',
 | 
			
		||||
@@ -212,7 +213,7 @@ describe('Coordinator tests', () => {
 | 
			
		||||
                        [],
 | 
			
		||||
                        {
 | 
			
		||||
                            from: takerAddress,
 | 
			
		||||
                            gas: devConstants.MAX_EXECUTE_TRANSACTION_GAS,
 | 
			
		||||
                            gas: constants.MAX_EXECUTE_TRANSACTION_GAS,
 | 
			
		||||
                        },
 | 
			
		||||
                    ),
 | 
			
		||||
                    RevertReason.InvalidApprovalSignature,
 | 
			
		||||
@@ -310,9 +311,9 @@ describe('Coordinator tests', () => {
 | 
			
		||||
                        transaction.signature,
 | 
			
		||||
                        [approvalExpirationTimeSeconds],
 | 
			
		||||
                        [approval.signature],
 | 
			
		||||
                        { from: takerAddress, gas: devConstants.MAX_EXECUTE_TRANSACTION_GAS },
 | 
			
		||||
                        { from: takerAddress, gas: constants.MAX_EXECUTE_TRANSACTION_GAS },
 | 
			
		||||
                    ),
 | 
			
		||||
                    devConstants.AWAIT_TRANSACTION_MINED_MS,
 | 
			
		||||
                    constants.AWAIT_TRANSACTION_MINED_MS,
 | 
			
		||||
                );
 | 
			
		||||
                const fillLogs = transactionReceipt.logs.filter(
 | 
			
		||||
                    log => (log as LogWithDecodedArgs<ExchangeFillEventArgs>).event === 'Fill',
 | 
			
		||||
@@ -344,9 +345,9 @@ describe('Coordinator tests', () => {
 | 
			
		||||
                        transaction.signature,
 | 
			
		||||
                        [],
 | 
			
		||||
                        [],
 | 
			
		||||
                        { from: feeRecipientAddress, gas: devConstants.MAX_EXECUTE_TRANSACTION_GAS },
 | 
			
		||||
                        { from: feeRecipientAddress, gas: constants.MAX_EXECUTE_TRANSACTION_GAS },
 | 
			
		||||
                    ),
 | 
			
		||||
                    devConstants.AWAIT_TRANSACTION_MINED_MS,
 | 
			
		||||
                    constants.AWAIT_TRANSACTION_MINED_MS,
 | 
			
		||||
                );
 | 
			
		||||
                const fillLogs = transactionReceipt.logs.filter(
 | 
			
		||||
                    log => (log as LogWithDecodedArgs<ExchangeFillEventArgs>).event === 'Fill',
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,8 @@
 | 
			
		||||
import {
 | 
			
		||||
    addressUtils,
 | 
			
		||||
    chaiSetup,
 | 
			
		||||
    constants as devConstants,
 | 
			
		||||
    constants,
 | 
			
		||||
    exchangeDataEncoder,
 | 
			
		||||
    expectContractCallFailedAsync,
 | 
			
		||||
    getLatestBlockTimestampAsync,
 | 
			
		||||
    provider,
 | 
			
		||||
@@ -16,7 +17,7 @@ import { BigNumber, providerUtils } from '@0x/utils';
 | 
			
		||||
import * as chai from 'chai';
 | 
			
		||||
import * as ethUtil from 'ethereumjs-util';
 | 
			
		||||
 | 
			
		||||
import { ApprovalFactory, artifacts, constants, CoordinatorContract, exchangeDataEncoder } from '../src';
 | 
			
		||||
import { ApprovalFactory, artifacts, CoordinatorContract } from '../src';
 | 
			
		||||
 | 
			
		||||
chaiSetup.configure();
 | 
			
		||||
const expect = chai.expect;
 | 
			
		||||
@@ -53,29 +54,28 @@ describe('Mixins tests', () => {
 | 
			
		||||
        const accounts = await web3Wrapper.getAvailableAddressesAsync();
 | 
			
		||||
        [transactionSignerAddress, approvalSignerAddress1, approvalSignerAddress2] = accounts.slice(0, 3);
 | 
			
		||||
        exchangeDomain = {
 | 
			
		||||
            verifyingContractAddress: devConstants.NULL_ADDRESS,
 | 
			
		||||
            verifyingContractAddress: constants.NULL_ADDRESS,
 | 
			
		||||
            chainId,
 | 
			
		||||
        };
 | 
			
		||||
        defaultOrder = {
 | 
			
		||||
            makerAddress: devConstants.NULL_ADDRESS,
 | 
			
		||||
            takerAddress: devConstants.NULL_ADDRESS,
 | 
			
		||||
            makerAddress: constants.NULL_ADDRESS,
 | 
			
		||||
            takerAddress: constants.NULL_ADDRESS,
 | 
			
		||||
            senderAddress: mixins.address,
 | 
			
		||||
            feeRecipientAddress: approvalSignerAddress1,
 | 
			
		||||
            makerAssetData: devConstants.NULL_BYTES,
 | 
			
		||||
            takerAssetData: devConstants.NULL_BYTES,
 | 
			
		||||
            makerAssetAmount: devConstants.ZERO_AMOUNT,
 | 
			
		||||
            takerAssetAmount: devConstants.ZERO_AMOUNT,
 | 
			
		||||
            makerFee: devConstants.ZERO_AMOUNT,
 | 
			
		||||
            takerFee: devConstants.ZERO_AMOUNT,
 | 
			
		||||
            expirationTimeSeconds: devConstants.ZERO_AMOUNT,
 | 
			
		||||
            salt: devConstants.ZERO_AMOUNT,
 | 
			
		||||
            signature: devConstants.NULL_BYTES,
 | 
			
		||||
            makerAssetData: constants.NULL_BYTES,
 | 
			
		||||
            takerAssetData: constants.NULL_BYTES,
 | 
			
		||||
            makerAssetAmount: constants.ZERO_AMOUNT,
 | 
			
		||||
            takerAssetAmount: constants.ZERO_AMOUNT,
 | 
			
		||||
            makerFee: constants.ZERO_AMOUNT,
 | 
			
		||||
            takerFee: constants.ZERO_AMOUNT,
 | 
			
		||||
            expirationTimeSeconds: constants.ZERO_AMOUNT,
 | 
			
		||||
            salt: constants.ZERO_AMOUNT,
 | 
			
		||||
            signature: constants.NULL_BYTES,
 | 
			
		||||
            domain: exchangeDomain,
 | 
			
		||||
        };
 | 
			
		||||
        const transactionSignerPrivateKey =
 | 
			
		||||
            devConstants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(transactionSignerAddress)];
 | 
			
		||||
        const approvalSignerPrivateKey1 = devConstants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(approvalSignerAddress1)];
 | 
			
		||||
        const approvalSignerPrivateKey2 = devConstants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(approvalSignerAddress2)];
 | 
			
		||||
        const transactionSignerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(transactionSignerAddress)];
 | 
			
		||||
        const approvalSignerPrivateKey1 = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(approvalSignerAddress1)];
 | 
			
		||||
        const approvalSignerPrivateKey2 = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(approvalSignerAddress2)];
 | 
			
		||||
        transactionFactory = new TransactionFactory(transactionSignerPrivateKey, exchangeAddress, chainId);
 | 
			
		||||
        approvalFactory1 = new ApprovalFactory(approvalSignerPrivateKey1, mixins.address);
 | 
			
		||||
        approvalFactory2 = new ApprovalFactory(approvalSignerPrivateKey2, mixins.address);
 | 
			
		||||
@@ -89,21 +89,21 @@ describe('Mixins tests', () => {
 | 
			
		||||
 | 
			
		||||
    describe('getSignerAddress', () => {
 | 
			
		||||
        it('should return the correct address using the EthSign signature type', async () => {
 | 
			
		||||
            const data = devConstants.NULL_BYTES;
 | 
			
		||||
            const data = constants.NULL_BYTES;
 | 
			
		||||
            const transaction = transactionFactory.newSignedTransaction(data, SignatureType.EthSign);
 | 
			
		||||
            const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
 | 
			
		||||
            const signerAddress = await mixins.getSignerAddress.callAsync(transactionHash, transaction.signature);
 | 
			
		||||
            expect(transaction.signerAddress).to.eq(signerAddress);
 | 
			
		||||
        });
 | 
			
		||||
        it('should return the correct address using the EIP712 signature type', async () => {
 | 
			
		||||
            const data = devConstants.NULL_BYTES;
 | 
			
		||||
            const data = constants.NULL_BYTES;
 | 
			
		||||
            const transaction = transactionFactory.newSignedTransaction(data, SignatureType.EIP712);
 | 
			
		||||
            const transactionHash = transactionHashUtils.getTransactionHashHex(transaction);
 | 
			
		||||
            const signerAddress = await mixins.getSignerAddress.callAsync(transactionHash, transaction.signature);
 | 
			
		||||
            expect(transaction.signerAddress).to.eq(signerAddress);
 | 
			
		||||
        });
 | 
			
		||||
        it('should revert with with the Illegal signature type', async () => {
 | 
			
		||||
            const data = devConstants.NULL_BYTES;
 | 
			
		||||
            const data = constants.NULL_BYTES;
 | 
			
		||||
            const transaction = transactionFactory.newSignedTransaction(data);
 | 
			
		||||
            const illegalSignatureByte = ethUtil.toBuffer(SignatureType.Illegal).toString('hex');
 | 
			
		||||
            transaction.signature = `${transaction.signature.slice(
 | 
			
		||||
@@ -117,7 +117,7 @@ describe('Mixins tests', () => {
 | 
			
		||||
            );
 | 
			
		||||
        });
 | 
			
		||||
        it('should revert with with the Invalid signature type', async () => {
 | 
			
		||||
            const data = devConstants.NULL_BYTES;
 | 
			
		||||
            const data = constants.NULL_BYTES;
 | 
			
		||||
            const transaction = transactionFactory.newSignedTransaction(data);
 | 
			
		||||
            const invalidSignatureByte = ethUtil.toBuffer(SignatureType.Invalid).toString('hex');
 | 
			
		||||
            transaction.signature = `0x${invalidSignatureByte}`;
 | 
			
		||||
@@ -128,7 +128,7 @@ describe('Mixins tests', () => {
 | 
			
		||||
            );
 | 
			
		||||
        });
 | 
			
		||||
        it("should revert with with a signature type that doesn't exist", async () => {
 | 
			
		||||
            const data = devConstants.NULL_BYTES;
 | 
			
		||||
            const data = constants.NULL_BYTES;
 | 
			
		||||
            const transaction = transactionFactory.newSignedTransaction(data);
 | 
			
		||||
            const invalidSignatureByte = '04';
 | 
			
		||||
            transaction.signature = `${transaction.signature.slice(
 | 
			
		||||
@@ -151,7 +151,7 @@ describe('Mixins tests', () => {
 | 
			
		||||
                const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data);
 | 
			
		||||
                const decodedSignedOrders = decodedOrders.map(order => ({
 | 
			
		||||
                    ...order,
 | 
			
		||||
                    signature: devConstants.NULL_BYTES,
 | 
			
		||||
                    signature: constants.NULL_BYTES,
 | 
			
		||||
                    domain: exchangeDomain,
 | 
			
		||||
                }));
 | 
			
		||||
                expect(orders).to.deep.eq(decodedSignedOrders);
 | 
			
		||||
@@ -164,7 +164,7 @@ describe('Mixins tests', () => {
 | 
			
		||||
                const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data);
 | 
			
		||||
                const decodedSignedOrders = decodedOrders.map(order => ({
 | 
			
		||||
                    ...order,
 | 
			
		||||
                    signature: devConstants.NULL_BYTES,
 | 
			
		||||
                    signature: constants.NULL_BYTES,
 | 
			
		||||
                    domain: exchangeDomain,
 | 
			
		||||
                }));
 | 
			
		||||
                expect(orders).to.deep.eq(decodedSignedOrders);
 | 
			
		||||
@@ -177,7 +177,7 @@ describe('Mixins tests', () => {
 | 
			
		||||
                const decodedOrders = await mixins.decodeOrdersFromFillData.callAsync(data);
 | 
			
		||||
                const decodedSignedOrders = decodedOrders.map(order => ({
 | 
			
		||||
                    ...order,
 | 
			
		||||
                    signature: devConstants.NULL_BYTES,
 | 
			
		||||
                    signature: constants.NULL_BYTES,
 | 
			
		||||
                    domain: exchangeDomain,
 | 
			
		||||
                }));
 | 
			
		||||
                expect(orders).to.deep.eq(decodedSignedOrders);
 | 
			
		||||
@@ -232,7 +232,7 @@ describe('Mixins tests', () => {
 | 
			
		||||
            it(`Should be successful: function=${fnName}, caller=tx_signer, senderAddress=[null], approval_sig=[approver1], expiration=[valid]`, async () => {
 | 
			
		||||
                const order = {
 | 
			
		||||
                    ...defaultOrder,
 | 
			
		||||
                    senderAddress: devConstants.NULL_ADDRESS,
 | 
			
		||||
                    senderAddress: constants.NULL_ADDRESS,
 | 
			
		||||
                };
 | 
			
		||||
                const orders = [order];
 | 
			
		||||
                const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
 | 
			
		||||
@@ -404,7 +404,7 @@ describe('Mixins tests', () => {
 | 
			
		||||
            it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[null,null], feeRecipient=[approver1,approver1], approval_sig=[approver1], expiration=[valid]`, async () => {
 | 
			
		||||
                const orders = [defaultOrder, defaultOrder].map(order => ({
 | 
			
		||||
                    ...order,
 | 
			
		||||
                    senderAddress: devConstants.NULL_ADDRESS,
 | 
			
		||||
                    senderAddress: constants.NULL_ADDRESS,
 | 
			
		||||
                }));
 | 
			
		||||
                const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
 | 
			
		||||
                const transaction = transactionFactory.newSignedTransaction(data);
 | 
			
		||||
@@ -427,7 +427,7 @@ describe('Mixins tests', () => {
 | 
			
		||||
            it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[null,null], feeRecipient=[approver1,approver1], approval_sig=[], expiration=[]`, async () => {
 | 
			
		||||
                const orders = [defaultOrder, defaultOrder].map(order => ({
 | 
			
		||||
                    ...order,
 | 
			
		||||
                    senderAddress: devConstants.NULL_ADDRESS,
 | 
			
		||||
                    senderAddress: constants.NULL_ADDRESS,
 | 
			
		||||
                }));
 | 
			
		||||
                const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
 | 
			
		||||
                const transaction = transactionFactory.newSignedTransaction(data);
 | 
			
		||||
@@ -441,7 +441,7 @@ describe('Mixins tests', () => {
 | 
			
		||||
                );
 | 
			
		||||
            });
 | 
			
		||||
            it(`Should be successful: function=${fnName} caller=tx_signer, senderAddress=[verifier,null], feeRecipient=[approver1,approver1], approval_sig=[approver1], expiration=[valid]`, async () => {
 | 
			
		||||
                const orders = [defaultOrder, { ...defaultOrder, senderAddress: devConstants.NULL_ADDRESS }];
 | 
			
		||||
                const orders = [defaultOrder, { ...defaultOrder, senderAddress: constants.NULL_ADDRESS }];
 | 
			
		||||
                const data = exchangeDataEncoder.encodeOrdersToExchangeData(fnName, orders);
 | 
			
		||||
                const transaction = transactionFactory.newSignedTransaction(data);
 | 
			
		||||
                const currentTimestamp = await getLatestBlockTimestampAsync();
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +0,0 @@
 | 
			
		||||
import { BigNumber } from '@0x/utils';
 | 
			
		||||
 | 
			
		||||
export const constants = {
 | 
			
		||||
    SINGLE_FILL_FN_NAMES: ['fillOrder', 'fillOrKillOrder', 'fillOrderNoThrow'],
 | 
			
		||||
    BATCH_FILL_FN_NAMES: ['batchFillOrders', 'batchFillOrKillOrders', 'batchFillOrdersNoThrow'],
 | 
			
		||||
    MARKET_FILL_FN_NAMES: ['marketBuyOrders', 'marketBuyOrdersNoThrow', 'marketSellOrders', 'marketSellOrdersNoThrow'],
 | 
			
		||||
    MATCH_ORDERS: 'matchOrders',
 | 
			
		||||
    CANCEL_ORDER: 'cancelOrder',
 | 
			
		||||
    BATCH_CANCEL_ORDERS: 'batchCancelOrders',
 | 
			
		||||
    CANCEL_ORDERS_UP_TO: 'cancelOrdersUpTo',
 | 
			
		||||
    TIME_BUFFER: new BigNumber(1000),
 | 
			
		||||
};
 | 
			
		||||
@@ -1,5 +1,3 @@
 | 
			
		||||
export { hashUtils } from './hash_utils';
 | 
			
		||||
export { ApprovalFactory } from './approval_factory';
 | 
			
		||||
export { constants } from './constants';
 | 
			
		||||
export { exchangeDataEncoder } from './exchange_data_encoder';
 | 
			
		||||
export * from './types';
 | 
			
		||||
 
 | 
			
		||||
@@ -71,4 +71,12 @@ export const constants = {
 | 
			
		||||
        'SET_SIGNATURE_VALIDATOR_APPROVAL',
 | 
			
		||||
    ],
 | 
			
		||||
    KECCAK256_NULL: ethUtil.addHexPrefix(ethUtil.bufferToHex(ethUtil.SHA3_NULL)),
 | 
			
		||||
    SINGLE_FILL_FN_NAMES: ['fillOrder', 'fillOrKillOrder', 'fillOrderNoThrow'],
 | 
			
		||||
    BATCH_FILL_FN_NAMES: ['batchFillOrders', 'batchFillOrKillOrders', 'batchFillOrdersNoThrow'],
 | 
			
		||||
    MARKET_FILL_FN_NAMES: ['marketBuyOrders', 'marketBuyOrdersNoThrow', 'marketSellOrders', 'marketSellOrdersNoThrow'],
 | 
			
		||||
    MATCH_ORDERS: 'matchOrders',
 | 
			
		||||
    CANCEL_ORDER: 'cancelOrder',
 | 
			
		||||
    BATCH_CANCEL_ORDERS: 'batchCancelOrders',
 | 
			
		||||
    CANCEL_ORDERS_UP_TO: 'cancelOrdersUpTo',
 | 
			
		||||
    TIME_BUFFER: new BigNumber(1000),
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -2,10 +2,10 @@ import { IExchangeContract } from '@0x/contracts-exchange';
 | 
			
		||||
import { constants as devConstants, provider } from '@0x/contracts-test-utils';
 | 
			
		||||
import { SignedOrder } from '@0x/types';
 | 
			
		||||
 | 
			
		||||
import { constants } from './index';
 | 
			
		||||
import { constants, provider } from './index';
 | 
			
		||||
 | 
			
		||||
export const exchangeDataEncoder = {
 | 
			
		||||
    encodeOrdersToExchangeData(fnName: string, orders: SignedOrder[]): string {
 | 
			
		||||
    encodeOrdersToExchangeData(fnName: string, orders: SignedOrder[] = []): string {
 | 
			
		||||
        const exchangeInstance = new IExchangeContract(devConstants.NULL_ADDRESS, provider);
 | 
			
		||||
        let data;
 | 
			
		||||
        if (constants.SINGLE_FILL_FN_NAMES.indexOf(fnName) !== -1) {
 | 
			
		||||
@@ -38,7 +38,7 @@ export const exchangeDataEncoder = {
 | 
			
		||||
        } else if (fnName === constants.BATCH_CANCEL_ORDERS) {
 | 
			
		||||
            data = exchangeInstance.batchCancelOrders.getABIEncodedTransactionData(orders);
 | 
			
		||||
        } else if (fnName === constants.CANCEL_ORDERS_UP_TO) {
 | 
			
		||||
            data = exchangeInstance.cancelOrdersUpTo.getABIEncodedTransactionData(devConstants.ZERO_AMOUNT);
 | 
			
		||||
            data = exchangeInstance.cancelOrdersUpTo.getABIEncodedTransactionData(constants.ZERO_AMOUNT);
 | 
			
		||||
        } else {
 | 
			
		||||
            throw new Error(`Error: ${fnName} not a supported function`);
 | 
			
		||||
        }
 | 
			
		||||
@@ -28,6 +28,7 @@ export { OrderFactory } from './order_factory';
 | 
			
		||||
export { bytes32Values, testCombinatoriallyWithReferenceFuncAsync, uint256Values } from './combinatorial_utils';
 | 
			
		||||
export { TransactionFactory } from './transaction_factory';
 | 
			
		||||
export { testWithReferenceFuncAsync } from './test_with_reference';
 | 
			
		||||
export { exchangeDataEncoder } from './exchange_data_encoder';
 | 
			
		||||
export {
 | 
			
		||||
    MarketBuyOrders,
 | 
			
		||||
    MarketSellOrders,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user