devutils 😕
This commit is contained in:
		@@ -1,6 +1,5 @@
 | 
				
			|||||||
import { BaseContract } from '@0x/base-contract';
 | 
					import { BaseContract } from '@0x/base-contract';
 | 
				
			||||||
import { constants, expect, TokenBalances } from '@0x/contracts-test-utils';
 | 
					import { constants, expect, TokenBalances } from '@0x/contracts-test-utils';
 | 
				
			||||||
import { BigNumber } from '@0x/utils';
 | 
					 | 
				
			||||||
import * as _ from 'lodash';
 | 
					import * as _ from 'lodash';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { TokenAddresses, TokenContractsByName, TokenOwnersByName } from './types';
 | 
					import { TokenAddresses, TokenContractsByName, TokenOwnersByName } from './types';
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,6 +6,7 @@ import {
 | 
				
			|||||||
    MultiAssetProxyContract,
 | 
					    MultiAssetProxyContract,
 | 
				
			||||||
    StaticCallProxyContract,
 | 
					    StaticCallProxyContract,
 | 
				
			||||||
} from '@0x/contracts-asset-proxy';
 | 
					} from '@0x/contracts-asset-proxy';
 | 
				
			||||||
 | 
					import { DevUtilsContract } from '@0x/contracts-dev-utils';
 | 
				
			||||||
import { artifacts as ERC1155Artifacts, ERC1155MintableContract } from '@0x/contracts-erc1155';
 | 
					import { artifacts as ERC1155Artifacts, ERC1155MintableContract } from '@0x/contracts-erc1155';
 | 
				
			||||||
import { artifacts as ERC20Artifacts, DummyERC20TokenContract, WETH9Contract } from '@0x/contracts-erc20';
 | 
					import { artifacts as ERC20Artifacts, DummyERC20TokenContract, WETH9Contract } from '@0x/contracts-erc20';
 | 
				
			||||||
import { artifacts as ERC721Artifacts, DummyERC721TokenContract } from '@0x/contracts-erc721';
 | 
					import { artifacts as ERC721Artifacts, DummyERC721TokenContract } from '@0x/contracts-erc721';
 | 
				
			||||||
@@ -191,7 +192,19 @@ export class DeploymentManager {
 | 
				
			|||||||
            staking.stakingProxy,
 | 
					            staking.stakingProxy,
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return new DeploymentManager(assetProxies, governor, exchange, staking, tokens, chainId, accounts, txDefaults);
 | 
					        const devUtils = new DevUtilsContract(constants.NULL_ADDRESS, environment.provider);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return new DeploymentManager(
 | 
				
			||||||
 | 
					            assetProxies,
 | 
				
			||||||
 | 
					            governor,
 | 
				
			||||||
 | 
					            exchange,
 | 
				
			||||||
 | 
					            staking,
 | 
				
			||||||
 | 
					            tokens,
 | 
				
			||||||
 | 
					            chainId,
 | 
				
			||||||
 | 
					            accounts,
 | 
				
			||||||
 | 
					            txDefaults,
 | 
				
			||||||
 | 
					            devUtils,
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -480,6 +493,7 @@ export class DeploymentManager {
 | 
				
			|||||||
        public chainId: number,
 | 
					        public chainId: number,
 | 
				
			||||||
        public accounts: string[],
 | 
					        public accounts: string[],
 | 
				
			||||||
        public txDefaults: Partial<TxData>,
 | 
					        public txDefaults: Partial<TxData>,
 | 
				
			||||||
 | 
					        public devUtils: DevUtilsContract,
 | 
				
			||||||
    ) {}
 | 
					    ) {}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
// tslint:disable:max-file-line-count
 | 
					// tslint:disable:max-file-line-count
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,6 @@
 | 
				
			|||||||
import { BlockchainBalanceStore, LocalBalanceStore } from '@0x/contracts-exchange';
 | 
					import { BlockchainBalanceStore, LocalBalanceStore } from '@0x/contracts-exchange';
 | 
				
			||||||
import { GlobalStakeByStatus, OwnerStakeByStatus, StakeStatus, StoredBalance } from '@0x/contracts-staking';
 | 
					import { GlobalStakeByStatus, OwnerStakeByStatus, StakeStatus, StoredBalance } from '@0x/contracts-staking';
 | 
				
			||||||
import { expect } from '@0x/contracts-test-utils';
 | 
					import { expect } from '@0x/contracts-test-utils';
 | 
				
			||||||
import { assetDataUtils } from '@0x/order-utils';
 | 
					 | 
				
			||||||
import { BigNumber, logUtils } from '@0x/utils';
 | 
					import { BigNumber, logUtils } from '@0x/utils';
 | 
				
			||||||
import { TxData } from 'ethereum-types';
 | 
					import { TxData } from 'ethereum-types';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -31,17 +30,16 @@ export function validStakeAssertion(
 | 
				
			|||||||
    ownerStake: OwnerStakeByStatus,
 | 
					    ownerStake: OwnerStakeByStatus,
 | 
				
			||||||
): FunctionAssertion<LocalBalanceStore> {
 | 
					): FunctionAssertion<LocalBalanceStore> {
 | 
				
			||||||
    const { stakingWrapper, zrxVault } = deployment.staking;
 | 
					    const { stakingWrapper, zrxVault } = deployment.staking;
 | 
				
			||||||
    const { zrx } = deployment.tokens;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return new FunctionAssertion(stakingWrapper.stake, {
 | 
					    return new FunctionAssertion(stakingWrapper.stake, {
 | 
				
			||||||
        before: async (amount: BigNumber, txData: Partial<TxData>) => {
 | 
					        before: async (amount: BigNumber, txData: Partial<TxData>) => {
 | 
				
			||||||
            // Simulates the transfer of ZRX from staker to vault
 | 
					            // Simulates the transfer of ZRX from staker to vault
 | 
				
			||||||
            const expectedBalances = LocalBalanceStore.create(balanceStore);
 | 
					            const expectedBalances = LocalBalanceStore.create(deployment.devUtils, balanceStore);
 | 
				
			||||||
            expectedBalances.transferAsset(
 | 
					            await expectedBalances.transferAssetAsync(
 | 
				
			||||||
                txData.from as string,
 | 
					                txData.from as string,
 | 
				
			||||||
                zrxVault.address,
 | 
					                zrxVault.address,
 | 
				
			||||||
                amount,
 | 
					                amount,
 | 
				
			||||||
                assetDataUtils.encodeERC20AssetData(zrx.address),
 | 
					                await deployment.devUtils.encodeERC20AssetData.callAsync(deployment.tokens.zrx.address),
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
            return expectedBalances;
 | 
					            return expectedBalances;
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,6 @@
 | 
				
			|||||||
import { BlockchainBalanceStore, LocalBalanceStore } from '@0x/contracts-exchange';
 | 
					import { BlockchainBalanceStore, LocalBalanceStore } from '@0x/contracts-exchange';
 | 
				
			||||||
import { GlobalStakeByStatus, OwnerStakeByStatus, StakeStatus, StoredBalance } from '@0x/contracts-staking';
 | 
					import { GlobalStakeByStatus, OwnerStakeByStatus, StakeStatus, StoredBalance } from '@0x/contracts-staking';
 | 
				
			||||||
import { expect } from '@0x/contracts-test-utils';
 | 
					import { expect } from '@0x/contracts-test-utils';
 | 
				
			||||||
import { assetDataUtils } from '@0x/order-utils';
 | 
					 | 
				
			||||||
import { BigNumber, logUtils } from '@0x/utils';
 | 
					import { BigNumber, logUtils } from '@0x/utils';
 | 
				
			||||||
import { TxData } from 'ethereum-types';
 | 
					import { TxData } from 'ethereum-types';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -31,17 +30,16 @@ export function validUnstakeAssertion(
 | 
				
			|||||||
    ownerStake: OwnerStakeByStatus,
 | 
					    ownerStake: OwnerStakeByStatus,
 | 
				
			||||||
): FunctionAssertion<LocalBalanceStore> {
 | 
					): FunctionAssertion<LocalBalanceStore> {
 | 
				
			||||||
    const { stakingWrapper, zrxVault } = deployment.staking;
 | 
					    const { stakingWrapper, zrxVault } = deployment.staking;
 | 
				
			||||||
    const { zrx } = deployment.tokens;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return new FunctionAssertion(stakingWrapper.unstake, {
 | 
					    return new FunctionAssertion(stakingWrapper.unstake, {
 | 
				
			||||||
        before: async (amount: BigNumber, txData: Partial<TxData>) => {
 | 
					        before: async (amount: BigNumber, txData: Partial<TxData>) => {
 | 
				
			||||||
            // Simulates the transfer of ZRX from vault to staker
 | 
					            // Simulates the transfer of ZRX from vault to staker
 | 
				
			||||||
            const expectedBalances = LocalBalanceStore.create(balanceStore);
 | 
					            const expectedBalances = LocalBalanceStore.create(deployment.devUtils, balanceStore);
 | 
				
			||||||
            expectedBalances.transferAsset(
 | 
					            await expectedBalances.transferAssetAsync(
 | 
				
			||||||
                zrxVault.address,
 | 
					                zrxVault.address,
 | 
				
			||||||
                txData.from as string,
 | 
					                txData.from as string,
 | 
				
			||||||
                amount,
 | 
					                amount,
 | 
				
			||||||
                assetDataUtils.encodeERC20AssetData(zrx.address),
 | 
					                await deployment.devUtils.encodeERC20AssetData.callAsync(deployment.tokens.zrx.address),
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
            return expectedBalances;
 | 
					            return expectedBalances;
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user