@0x:contracts-integrations Moved matchOrders into integrations
				
					
				
			This commit is contained in:
		@@ -12,17 +12,9 @@ import { DevUtilsContract } from '@0x/contracts-dev-utils';
 | 
				
			|||||||
import { ERC1155Contract as ERC1155TokenContract, Erc1155Wrapper as ERC1155Wrapper } from '@0x/contracts-erc1155';
 | 
					import { ERC1155Contract as ERC1155TokenContract, Erc1155Wrapper as ERC1155Wrapper } from '@0x/contracts-erc1155';
 | 
				
			||||||
import { DummyERC20TokenContract } from '@0x/contracts-erc20';
 | 
					import { DummyERC20TokenContract } from '@0x/contracts-erc20';
 | 
				
			||||||
import { DummyERC721TokenContract } from '@0x/contracts-erc721';
 | 
					import { DummyERC721TokenContract } from '@0x/contracts-erc721';
 | 
				
			||||||
 | 
					import { artifacts as exchangeArtifacts, ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange';
 | 
				
			||||||
import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs';
 | 
					import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs';
 | 
				
			||||||
import {
 | 
					import { blockchainTests, constants, expect, OrderFactory, orderUtils } from '@0x/contracts-test-utils';
 | 
				
			||||||
    chaiSetup,
 | 
					 | 
				
			||||||
    constants,
 | 
					 | 
				
			||||||
    OrderFactory,
 | 
					 | 
				
			||||||
    orderHashUtils,
 | 
					 | 
				
			||||||
    orderUtils,
 | 
					 | 
				
			||||||
    provider,
 | 
					 | 
				
			||||||
    txDefaults,
 | 
					 | 
				
			||||||
    web3Wrapper,
 | 
					 | 
				
			||||||
} from '@0x/contracts-test-utils';
 | 
					 | 
				
			||||||
import { BlockchainLifecycle } from '@0x/dev-utils';
 | 
					import { BlockchainLifecycle } from '@0x/dev-utils';
 | 
				
			||||||
import { OrderStatus, SignedOrder } from '@0x/types';
 | 
					import { OrderStatus, SignedOrder } from '@0x/types';
 | 
				
			||||||
import { BigNumber, providerUtils } from '@0x/utils';
 | 
					import { BigNumber, providerUtils } from '@0x/utils';
 | 
				
			||||||
@@ -30,30 +22,19 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
 | 
				
			|||||||
import * as chai from 'chai';
 | 
					import * as chai from 'chai';
 | 
				
			||||||
import * as _ from 'lodash';
 | 
					import * as _ from 'lodash';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import ExchangeRevertErrors = require('../src/revert_errors');
 | 
					import { MatchOrderTester, TokenBalances } from '../utils/match_order_tester';
 | 
				
			||||||
 | 
					 | 
				
			||||||
import { ExchangeWrapper } from './utils/exchange_wrapper';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import { artifacts } from './artifacts';
 | 
					 | 
				
			||||||
import { ExchangeContract } from './wrappers';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import { MatchOrderTester, TokenBalances } from './utils/match_order_tester';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const ZERO = new BigNumber(0);
 | 
					const ZERO = new BigNumber(0);
 | 
				
			||||||
const ONE = new BigNumber(1);
 | 
					const ONE = new BigNumber(1);
 | 
				
			||||||
const TWO = new BigNumber(2);
 | 
					const TWO = new BigNumber(2);
 | 
				
			||||||
const { isRoundingErrorCeil, isRoundingErrorFloor } = LibReferenceFunctions;
 | 
					const { isRoundingErrorCeil, isRoundingErrorFloor } = LibReferenceFunctions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
 | 
					 | 
				
			||||||
chaiSetup.configure();
 | 
					 | 
				
			||||||
const expect = chai.expect;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Reduce the number of tokens to deploy to speed up tests, since we don't need
 | 
					// Reduce the number of tokens to deploy to speed up tests, since we don't need
 | 
				
			||||||
// so many.
 | 
					// so many.
 | 
				
			||||||
constants.NUM_DUMMY_ERC721_TO_DEPLOY = 1;
 | 
					constants.NUM_DUMMY_ERC721_TO_DEPLOY = 1;
 | 
				
			||||||
constants.NUM_DUMMY_ERC1155_CONTRACTS_TO_DEPLOY = 1;
 | 
					constants.NUM_DUMMY_ERC1155_CONTRACTS_TO_DEPLOY = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe('matchOrders', () => {
 | 
					blockchainTests.resets('matchOrders', env => {
 | 
				
			||||||
    let chainId: number;
 | 
					    let chainId: number;
 | 
				
			||||||
    let makerAddressLeft: string;
 | 
					    let makerAddressLeft: string;
 | 
				
			||||||
    let makerAddressRight: string;
 | 
					    let makerAddressRight: string;
 | 
				
			||||||
@@ -89,17 +70,11 @@ describe('matchOrders', () => {
 | 
				
			|||||||
    let matchOrderTester: MatchOrderTester;
 | 
					    let matchOrderTester: MatchOrderTester;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const devUtils = new DevUtilsContract(constants.NULL_ADDRESS, provider, txDefaults);
 | 
					    const devUtils = new DevUtilsContract(constants.NULL_ADDRESS, provider, txDefaults);
 | 
				
			||||||
    before(async () => {
 | 
					 | 
				
			||||||
        await blockchainLifecycle.startAsync();
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
    after(async () => {
 | 
					 | 
				
			||||||
        await blockchainLifecycle.revertAsync();
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
    before(async () => {
 | 
					    before(async () => {
 | 
				
			||||||
        // Get the chain ID.
 | 
					        // Get the chain ID.
 | 
				
			||||||
        chainId = await providerUtils.getChainIdAsync(provider);
 | 
					        chainId = await env.getChainIdAsync();
 | 
				
			||||||
        // Create accounts
 | 
					        // Create accounts
 | 
				
			||||||
        const accounts = await web3Wrapper.getAvailableAddressesAsync();
 | 
					        const accounts = await env.getAccountAddressesAsync();
 | 
				
			||||||
        const usedAddresses = ([
 | 
					        const usedAddresses = ([
 | 
				
			||||||
            owner,
 | 
					            owner,
 | 
				
			||||||
            makerAddressLeft,
 | 
					            makerAddressLeft,
 | 
				
			||||||
@@ -110,9 +85,9 @@ describe('matchOrders', () => {
 | 
				
			|||||||
        ] = accounts);
 | 
					        ] = accounts);
 | 
				
			||||||
        const addressesWithBalances = usedAddresses.slice(1);
 | 
					        const addressesWithBalances = usedAddresses.slice(1);
 | 
				
			||||||
        // Create wrappers
 | 
					        // Create wrappers
 | 
				
			||||||
        erc20Wrapper = new ERC20Wrapper(provider, addressesWithBalances, owner);
 | 
					        erc20Wrapper = new ERC20Wrapper(env.provider, addressesWithBalances, owner);
 | 
				
			||||||
        erc721Wrapper = new ERC721Wrapper(provider, addressesWithBalances, owner);
 | 
					        erc721Wrapper = new ERC721Wrapper(env.provider, addressesWithBalances, owner);
 | 
				
			||||||
        erc1155ProxyWrapper = new ERC1155ProxyWrapper(provider, addressesWithBalances, owner);
 | 
					        erc1155ProxyWrapper = new ERC1155ProxyWrapper(env.provider, addressesWithBalances, owner);
 | 
				
			||||||
        // Deploy ERC20 token & ERC20 proxy
 | 
					        // Deploy ERC20 token & ERC20 proxy
 | 
				
			||||||
        const numDummyErc20ToDeploy = 4;
 | 
					        const numDummyErc20ToDeploy = 4;
 | 
				
			||||||
        erc20Tokens = await erc20Wrapper.deployDummyTokensAsync(numDummyErc20ToDeploy, constants.DUMMY_TOKEN_DECIMALS);
 | 
					        erc20Tokens = await erc20Wrapper.deployDummyTokensAsync(numDummyErc20ToDeploy, constants.DUMMY_TOKEN_DECIMALS);
 | 
				
			||||||
@@ -130,16 +105,16 @@ describe('matchOrders', () => {
 | 
				
			|||||||
        // Deploy MultiAssetProxy.
 | 
					        // Deploy MultiAssetProxy.
 | 
				
			||||||
        const multiAssetProxyContract = await MultiAssetProxyContract.deployFrom0xArtifactAsync(
 | 
					        const multiAssetProxyContract = await MultiAssetProxyContract.deployFrom0xArtifactAsync(
 | 
				
			||||||
            assetProxyArtifacts.MultiAssetProxy,
 | 
					            assetProxyArtifacts.MultiAssetProxy,
 | 
				
			||||||
            provider,
 | 
					            env.provider,
 | 
				
			||||||
            txDefaults,
 | 
					            env.txDefaults,
 | 
				
			||||||
            {},
 | 
					            assetProxyArtifacts,
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        // Depoy exchange
 | 
					        // Depoy exchange
 | 
				
			||||||
        exchange = await ExchangeContract.deployFrom0xArtifactAsync(
 | 
					        exchange = await ExchangeContract.deployFrom0xArtifactAsync(
 | 
				
			||||||
            artifacts.Exchange,
 | 
					            exchangeArtifacts.Exchange,
 | 
				
			||||||
            provider,
 | 
					            env.provider,
 | 
				
			||||||
            txDefaults,
 | 
					            env.txDefaults,
 | 
				
			||||||
            {},
 | 
					            exchangeArtifacts,
 | 
				
			||||||
            new BigNumber(chainId),
 | 
					            new BigNumber(chainId),
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        exchangeWrapper = new ExchangeWrapper(exchange);
 | 
					        exchangeWrapper = new ExchangeWrapper(exchange);
 | 
				
			||||||
@@ -217,12 +192,7 @@ describe('matchOrders', () => {
 | 
				
			|||||||
        );
 | 
					        );
 | 
				
			||||||
        tokenBalances = await matchOrderTester.getBalancesAsync();
 | 
					        tokenBalances = await matchOrderTester.getBalancesAsync();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    beforeEach(async () => {
 | 
					
 | 
				
			||||||
        await blockchainLifecycle.startAsync();
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
    afterEach(async () => {
 | 
					 | 
				
			||||||
        await blockchainLifecycle.revertAsync();
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
    describe('matchOrders', () => {
 | 
					    describe('matchOrders', () => {
 | 
				
			||||||
        it('Should transfer correct amounts when right order is fully filled and values pass isRoundingErrorFloor but fail isRoundingErrorCeil', async () => {
 | 
					        it('Should transfer correct amounts when right order is fully filled and values pass isRoundingErrorFloor but fail isRoundingErrorCeil', async () => {
 | 
				
			||||||
            // Create orders to match
 | 
					            // Create orders to match
 | 
				
			||||||
@@ -6,8 +6,6 @@ import { BigNumber } from '@0x/utils';
 | 
				
			|||||||
import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
 | 
					import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
 | 
				
			||||||
import * as _ from 'lodash';
 | 
					import * as _ from 'lodash';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { ExchangeWrapper } from './exchange_wrapper';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const ZERO = new BigNumber(0);
 | 
					const ZERO = new BigNumber(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IndividualERC1155Holdings {
 | 
					export interface IndividualERC1155Holdings {
 | 
				
			||||||
		Reference in New Issue
	
	Block a user