Merge pull request #2389 from 0xProject/feat/contracts/mainnet-fork
Allow mainnet fork to be used for contract tests
This commit is contained in:
commit
37d972ed9e
@ -53,6 +53,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x/abi-gen": "^5.0.1",
|
"@0x/abi-gen": "^5.0.1",
|
||||||
"@0x/contract-addresses": "^4.0.0",
|
"@0x/contract-addresses": "^4.0.0",
|
||||||
|
"@0x/contract-wrappers": "^13.1.0",
|
||||||
"@0x/contracts-coordinator": "^3.0.1",
|
"@0x/contracts-coordinator": "^3.0.1",
|
||||||
"@0x/contracts-dev-utils": "^1.0.1",
|
"@0x/contracts-dev-utils": "^1.0.1",
|
||||||
"@0x/contracts-exchange-forwarder": "^4.0.1",
|
"@0x/contracts-exchange-forwarder": "^4.0.1",
|
||||||
|
200
contracts/integrations/test/mainnet_configs_test.ts
Normal file
200
contracts/integrations/test/mainnet_configs_test.ts
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
import { ERC20ProxyContract, MultiAssetProxyContract } from '@0x/contracts-asset-proxy';
|
||||||
|
import { StakingProxyContract, ZrxVaultContract } from '@0x/contracts-staking';
|
||||||
|
import { blockchainTests, describe, expect } from '@0x/contracts-test-utils';
|
||||||
|
import { AssetProxyId } from '@0x/types';
|
||||||
|
import { BigNumber } from '@0x/utils';
|
||||||
|
|
||||||
|
import { contractAddresses, contractWrappers } from './mainnet_fork_utils';
|
||||||
|
|
||||||
|
blockchainTests.resets.fork('Mainnet configs tests', env => {
|
||||||
|
describe('Exchange', () => {
|
||||||
|
it('should be owned by the ZeroExGovernor ', async () => {
|
||||||
|
const owner = await contractWrappers.exchange.owner().callAsync();
|
||||||
|
expect(owner).to.eq(contractAddresses.zeroExGovernor);
|
||||||
|
});
|
||||||
|
it('ERC20Proxy should be registered', async () => {
|
||||||
|
const erc20Proxy = await contractWrappers.exchange.getAssetProxy(AssetProxyId.ERC20).callAsync();
|
||||||
|
expect(erc20Proxy).to.eq(contractAddresses.erc20Proxy);
|
||||||
|
});
|
||||||
|
it('ERC721Proxy should be registered', async () => {
|
||||||
|
const erc721Proxy = await contractWrappers.exchange.getAssetProxy(AssetProxyId.ERC721).callAsync();
|
||||||
|
expect(erc721Proxy).to.eq(contractAddresses.erc721Proxy);
|
||||||
|
});
|
||||||
|
it('ERC1155Proxy should be registered', async () => {
|
||||||
|
const erc1155Proxy = await contractWrappers.exchange.getAssetProxy(AssetProxyId.ERC1155).callAsync();
|
||||||
|
expect(erc1155Proxy).to.eq(contractAddresses.erc1155Proxy);
|
||||||
|
});
|
||||||
|
it('ERC20BridgeProxy should be registered', async () => {
|
||||||
|
const erc20BridgeProxy = await contractWrappers.exchange
|
||||||
|
.getAssetProxy(AssetProxyId.ERC20Bridge)
|
||||||
|
.callAsync();
|
||||||
|
expect(erc20BridgeProxy).to.eq(contractAddresses.erc20BridgeProxy);
|
||||||
|
});
|
||||||
|
it('MultiAssetProxy should be registered', async () => {
|
||||||
|
const multiAssetProxy = await contractWrappers.exchange.getAssetProxy(AssetProxyId.MultiAsset).callAsync();
|
||||||
|
expect(multiAssetProxy).to.eq(contractAddresses.multiAssetProxy);
|
||||||
|
});
|
||||||
|
it('StaticCallProxy should be registered', async () => {
|
||||||
|
const staticCallProxy = await contractWrappers.exchange.getAssetProxy(AssetProxyId.StaticCall).callAsync();
|
||||||
|
expect(staticCallProxy).to.eq(contractAddresses.staticCallProxy);
|
||||||
|
});
|
||||||
|
it('StakingProxy should be attached', async () => {
|
||||||
|
const stakingProxy = await contractWrappers.exchange.protocolFeeCollector().callAsync();
|
||||||
|
expect(stakingProxy).to.eq(contractAddresses.stakingProxy);
|
||||||
|
});
|
||||||
|
it('should have the correct protocol fee multiplier', async () => {
|
||||||
|
const protocolFeeMultiplier = await contractWrappers.exchange.protocolFeeMultiplier().callAsync();
|
||||||
|
expect(protocolFeeMultiplier).to.bignumber.eq(150000);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('ERC20Proxy', () => {
|
||||||
|
const erc20Proxy = new ERC20ProxyContract(contractAddresses.erc20Proxy, env.provider);
|
||||||
|
it('should be owned by the ZeroExGovernor ', async () => {
|
||||||
|
const owner = await erc20Proxy.owner().callAsync();
|
||||||
|
expect(owner).to.eq(contractAddresses.zeroExGovernor);
|
||||||
|
});
|
||||||
|
it('should have the correct authorized addresses', async () => {
|
||||||
|
const authorizedAddresses = await erc20Proxy.getAuthorizedAddresses().callAsync();
|
||||||
|
expect(authorizedAddresses.length).to.eq(4);
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.exchangeV2), 'ExchangeV2');
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.exchange), 'Exchange');
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.multiAssetProxy), 'MultiAssetProxy');
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.zrxVault), 'ZrxVault');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('ERC721Proxy', () => {
|
||||||
|
const erc721Proxy = new ERC20ProxyContract(contractAddresses.erc721Proxy, env.provider);
|
||||||
|
it('should be owned by the ZeroExGovernor ', async () => {
|
||||||
|
const owner = await erc721Proxy.owner().callAsync();
|
||||||
|
expect(owner).to.eq(contractAddresses.zeroExGovernor);
|
||||||
|
});
|
||||||
|
it('should have the correct authorized addresses', async () => {
|
||||||
|
const authorizedAddresses = await erc721Proxy.getAuthorizedAddresses().callAsync();
|
||||||
|
expect(authorizedAddresses.length).to.eq(3);
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.exchangeV2), 'ExchangeV2');
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.exchange), 'Exchange');
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.multiAssetProxy), 'MultiAssetProxy');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('ERC1155Proxy', () => {
|
||||||
|
const erc1155Proxy = new ERC20ProxyContract(contractAddresses.erc1155Proxy, env.provider);
|
||||||
|
it('should be owned by the ZeroExGovernor ', async () => {
|
||||||
|
const owner = await erc1155Proxy.owner().callAsync();
|
||||||
|
expect(owner).to.eq(contractAddresses.zeroExGovernor);
|
||||||
|
});
|
||||||
|
it('should have the correct authorized addresses', async () => {
|
||||||
|
const authorizedAddresses = await erc1155Proxy.getAuthorizedAddresses().callAsync();
|
||||||
|
expect(authorizedAddresses.length).to.eq(3);
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.exchangeV2), 'ExchangeV2');
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.exchange), 'Exchange');
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.multiAssetProxy), 'MultiAssetProxy');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('ERC20BridgeProxy', () => {
|
||||||
|
const erc20BridgeProxy = new ERC20ProxyContract(contractAddresses.erc20BridgeProxy, env.provider);
|
||||||
|
it('should be owned by the ZeroExGovernor ', async () => {
|
||||||
|
const owner = await erc20BridgeProxy.owner().callAsync();
|
||||||
|
expect(owner).to.eq(contractAddresses.zeroExGovernor);
|
||||||
|
});
|
||||||
|
it('should have the correct authorized addresses', async () => {
|
||||||
|
const authorizedAddresses = await erc20BridgeProxy.getAuthorizedAddresses().callAsync();
|
||||||
|
expect(authorizedAddresses.length).to.eq(2);
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.exchange), 'Exchange');
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.multiAssetProxy), 'MultiAssetProxy');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('MultiAssetProxy', () => {
|
||||||
|
const multiAssetProxy = new MultiAssetProxyContract(contractAddresses.multiAssetProxy, env.provider);
|
||||||
|
it('should be owned by the ZeroExGovernor ', async () => {
|
||||||
|
const owner = await multiAssetProxy.owner().callAsync();
|
||||||
|
expect(owner).to.eq(contractAddresses.zeroExGovernor);
|
||||||
|
});
|
||||||
|
it('should have the correct authorized addresses', async () => {
|
||||||
|
const authorizedAddresses = await multiAssetProxy.getAuthorizedAddresses().callAsync();
|
||||||
|
expect(authorizedAddresses.length).to.eq(2);
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.exchangeV2), 'ExchangeV2');
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.exchange), 'Exchange');
|
||||||
|
});
|
||||||
|
it('ERC20Proxy should be registered', async () => {
|
||||||
|
const erc20Proxy = await multiAssetProxy.getAssetProxy(AssetProxyId.ERC20).callAsync();
|
||||||
|
expect(erc20Proxy).to.eq(contractAddresses.erc20Proxy);
|
||||||
|
});
|
||||||
|
it('ERC721Proxy should be registered', async () => {
|
||||||
|
const erc721Proxy = await multiAssetProxy.getAssetProxy(AssetProxyId.ERC721).callAsync();
|
||||||
|
expect(erc721Proxy).to.eq(contractAddresses.erc721Proxy);
|
||||||
|
});
|
||||||
|
it('ERC1155Proxy should be registered', async () => {
|
||||||
|
const erc1155Proxy = await multiAssetProxy.getAssetProxy(AssetProxyId.ERC1155).callAsync();
|
||||||
|
expect(erc1155Proxy).to.eq(contractAddresses.erc1155Proxy);
|
||||||
|
});
|
||||||
|
it('ERC20BridgeProxy should be registered', async () => {
|
||||||
|
const erc20BridgeProxy = await multiAssetProxy.getAssetProxy(AssetProxyId.ERC20Bridge).callAsync();
|
||||||
|
expect(erc20BridgeProxy).to.eq(contractAddresses.erc20BridgeProxy);
|
||||||
|
});
|
||||||
|
it('StaticCallProxy should be registered', async () => {
|
||||||
|
const staticCallProxy = await multiAssetProxy.getAssetProxy(AssetProxyId.StaticCall).callAsync();
|
||||||
|
expect(staticCallProxy).to.eq(contractAddresses.staticCallProxy);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('StakingProxy', () => {
|
||||||
|
const stakingProxy = new StakingProxyContract(contractAddresses.stakingProxy, env.provider);
|
||||||
|
it('should be owned by ZeroExGovernor', async () => {
|
||||||
|
const owner = await stakingProxy.owner().callAsync();
|
||||||
|
expect(owner).to.eq(contractAddresses.zeroExGovernor);
|
||||||
|
});
|
||||||
|
it('Staking contract should be attached', async () => {
|
||||||
|
const staking = await stakingProxy.stakingContract().callAsync();
|
||||||
|
expect(staking).to.eq(contractAddresses.staking);
|
||||||
|
});
|
||||||
|
it('Exchange should be registered', async () => {
|
||||||
|
const isRegistered = await contractWrappers.staking.validExchanges(contractAddresses.exchange).callAsync();
|
||||||
|
expect(isRegistered).to.be.true();
|
||||||
|
});
|
||||||
|
it('ZrxVault should be set', async () => {
|
||||||
|
const zrxVault = await contractWrappers.staking.getZrxVault().callAsync();
|
||||||
|
expect(zrxVault).to.eq(contractAddresses.zrxVault);
|
||||||
|
});
|
||||||
|
it('WETH should be set', async () => {
|
||||||
|
const weth = await contractWrappers.staking.getWethContract().callAsync();
|
||||||
|
expect(weth).to.eq(contractAddresses.etherToken);
|
||||||
|
});
|
||||||
|
it('should have the correct authorized addresses', async () => {
|
||||||
|
const authorizedAddresses = await stakingProxy.getAuthorizedAddresses().callAsync();
|
||||||
|
expect(authorizedAddresses.length).to.eq(1);
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.zeroExGovernor), 'ZeroExGovernor');
|
||||||
|
});
|
||||||
|
it('should have the correct params set', async () => {
|
||||||
|
const params = await contractWrappers.staking.getParams().callAsync();
|
||||||
|
const epochDurationInSeconds = 10 * 24 * 60 * 60;
|
||||||
|
const rewardDelegatedStakeWeight = 10 ** 6 * 0.9;
|
||||||
|
const mimimumPoolStake = new BigNumber(10).pow(18).times(100);
|
||||||
|
const cobbDouglasAlphaNumerator = 2;
|
||||||
|
const cobbDouglasAlphaDenominator = 3;
|
||||||
|
expect(params[0]).to.bignumber.eq(epochDurationInSeconds, 'epochDurationInSeconds');
|
||||||
|
expect(params[1]).to.bignumber.eq(rewardDelegatedStakeWeight, 'rewardDelegatedStakeWeight');
|
||||||
|
expect(params[2]).to.bignumber.eq(mimimumPoolStake, 'mimimumPoolStake');
|
||||||
|
expect(params[3]).to.bignumber.eq(cobbDouglasAlphaNumerator, 'cobbDouglasAlphaNumerator');
|
||||||
|
expect(params[4]).to.bignumber.eq(cobbDouglasAlphaDenominator, 'cobbDouglasAlphaDenominator');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('ZrxVault', () => {
|
||||||
|
const zrxVault = new ZrxVaultContract(contractAddresses.zrxVault, env.provider);
|
||||||
|
it('should be owned by ZeroExGovernor', async () => {
|
||||||
|
const owner = await zrxVault.owner().callAsync();
|
||||||
|
expect(owner).to.eq(contractAddresses.zeroExGovernor);
|
||||||
|
});
|
||||||
|
it('should have the correct authorized addresses', async () => {
|
||||||
|
const authorizedAddresses = await zrxVault.getAuthorizedAddresses().callAsync();
|
||||||
|
expect(authorizedAddresses.length).to.eq(1);
|
||||||
|
expect(authorizedAddresses.includes(contractAddresses.zeroExGovernor), 'ZeroExGovernor');
|
||||||
|
});
|
||||||
|
it('ERC20Proxy should be set', async () => {
|
||||||
|
const erc20Proxy = await zrxVault.zrxAssetProxy().callAsync();
|
||||||
|
expect(erc20Proxy).to.eq(contractAddresses.erc20Proxy);
|
||||||
|
});
|
||||||
|
it('StakingProxy should be set', async () => {
|
||||||
|
const stakingProxy = await zrxVault.stakingProxyAddress().callAsync();
|
||||||
|
expect(stakingProxy).to.eq(contractAddresses.stakingProxy);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
9
contracts/integrations/test/mainnet_fork_utils.ts
Normal file
9
contracts/integrations/test/mainnet_fork_utils.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { getContractAddressesForChainOrThrow } from '@0x/contract-addresses';
|
||||||
|
import { ContractWrappers } from '@0x/contract-wrappers';
|
||||||
|
import { provider } from '@0x/contracts-test-utils';
|
||||||
|
|
||||||
|
const chainId = 1;
|
||||||
|
const contractAddresses = getContractAddressesForChainOrThrow(chainId);
|
||||||
|
const contractWrappers = new ContractWrappers(provider, { chainId, contractAddresses });
|
||||||
|
|
||||||
|
export { contractAddresses, contractWrappers };
|
@ -18,6 +18,7 @@ export type BlockchainSuiteCallback = (this: ISuiteCallbackContext, env: Blockch
|
|||||||
export type BlockchainContextDefinitionCallback<T> = (description: string, callback: BlockchainSuiteCallback) => T;
|
export type BlockchainContextDefinitionCallback<T> = (description: string, callback: BlockchainSuiteCallback) => T;
|
||||||
export interface ContextDefinition extends mocha.IContextDefinition {
|
export interface ContextDefinition extends mocha.IContextDefinition {
|
||||||
optional: ContextDefinitionCallback<ISuite | void>;
|
optional: ContextDefinitionCallback<ISuite | void>;
|
||||||
|
fork: ContextDefinitionCallback<ISuite | void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,6 +32,7 @@ interface BlockchainContextDefinitionPartial {
|
|||||||
only: BlockchainContextDefinitionCallback<ISuite>;
|
only: BlockchainContextDefinitionCallback<ISuite>;
|
||||||
skip: BlockchainContextDefinitionCallback<void>;
|
skip: BlockchainContextDefinitionCallback<void>;
|
||||||
optional: BlockchainContextDefinitionCallback<ISuite | void>;
|
optional: BlockchainContextDefinitionCallback<ISuite | void>;
|
||||||
|
fork: BlockchainContextDefinitionCallback<ISuite | void>;
|
||||||
(description: string, callback: BlockchainSuiteCallback): ISuite;
|
(description: string, callback: BlockchainSuiteCallback): ISuite;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,6 +99,10 @@ export const describe = _.assign(mochaDescribe, {
|
|||||||
const describeCall = process.env.TEST_ALL ? mochaDescribe : mochaDescribe.skip;
|
const describeCall = process.env.TEST_ALL ? mochaDescribe : mochaDescribe.skip;
|
||||||
return describeCall(description, callback);
|
return describeCall(description, callback);
|
||||||
},
|
},
|
||||||
|
fork(description: string, callback: SuiteCallback): ISuite | void {
|
||||||
|
const describeCall = process.env.FORK_RPC_URL ? mochaDescribe.only : mochaDescribe.skip;
|
||||||
|
return describeCall(description, callback);
|
||||||
|
},
|
||||||
}) as ContextDefinition;
|
}) as ContextDefinition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,6 +122,13 @@ export const blockchainTests: BlockchainContextDefinition = _.assign(
|
|||||||
optional(description: string, callback: BlockchainSuiteCallback): ISuite | void {
|
optional(description: string, callback: BlockchainSuiteCallback): ISuite | void {
|
||||||
return defineBlockchainSuite(description, callback, process.env.TEST_ALL ? describe : describe.skip);
|
return defineBlockchainSuite(description, callback, process.env.TEST_ALL ? describe : describe.skip);
|
||||||
},
|
},
|
||||||
|
fork(description: string, callback: BlockchainSuiteCallback): ISuite | void {
|
||||||
|
return defineBlockchainSuite(
|
||||||
|
description,
|
||||||
|
callback,
|
||||||
|
process.env.FORK_RPC_URL ? describe.only : describe.skip,
|
||||||
|
);
|
||||||
|
},
|
||||||
resets: _.assign(
|
resets: _.assign(
|
||||||
function(description: string, callback: BlockchainSuiteCallback): ISuite {
|
function(description: string, callback: BlockchainSuiteCallback): ISuite {
|
||||||
return defineBlockchainSuite(description, callback, function(
|
return defineBlockchainSuite(description, callback, function(
|
||||||
@ -150,6 +163,14 @@ export const blockchainTests: BlockchainContextDefinition = _.assign(
|
|||||||
return defineResetsSuite(_description, _callback, describe.optional);
|
return defineResetsSuite(_description, _callback, describe.optional);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
fork(description: string, callback: BlockchainSuiteCallback): ISuite | void {
|
||||||
|
return defineBlockchainSuite(description, callback, function(
|
||||||
|
_description: string,
|
||||||
|
_callback: SuiteCallback,
|
||||||
|
): ISuite | void {
|
||||||
|
return defineResetsSuite(_description, _callback, describe.fork);
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { devConstants, env, EnvVars, web3Factory } from '@0x/dev-utils';
|
import { devConstants, env, EnvVars, Web3Config, web3Factory } from '@0x/dev-utils';
|
||||||
import { prependSubprovider, Web3ProviderEngine } from '@0x/subproviders';
|
import { prependSubprovider, Web3ProviderEngine } from '@0x/subproviders';
|
||||||
import { logUtils } from '@0x/utils';
|
import { logUtils } from '@0x/utils';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
@ -9,47 +9,31 @@ import { coverage } from './coverage';
|
|||||||
import { profiler } from './profiler';
|
import { profiler } from './profiler';
|
||||||
import { revertTrace } from './revert_trace';
|
import { revertTrace } from './revert_trace';
|
||||||
|
|
||||||
enum ProviderType {
|
export const txDefaults = {
|
||||||
Ganache = 'ganache',
|
|
||||||
Geth = 'geth',
|
|
||||||
}
|
|
||||||
|
|
||||||
let testProvider: ProviderType;
|
|
||||||
switch (process.env.TEST_PROVIDER) {
|
|
||||||
case undefined:
|
|
||||||
testProvider = ProviderType.Ganache;
|
|
||||||
break;
|
|
||||||
case 'ganache':
|
|
||||||
testProvider = ProviderType.Ganache;
|
|
||||||
break;
|
|
||||||
case 'geth':
|
|
||||||
testProvider = ProviderType.Geth;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error(`Unknown TEST_PROVIDER: ${process.env.TEST_PROVIDER}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const ganacheTxDefaults = {
|
|
||||||
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
||||||
gas: devConstants.GAS_LIMIT,
|
gas: devConstants.GAS_LIMIT,
|
||||||
gasPrice: constants.DEFAULT_GAS_PRICE,
|
gasPrice: constants.DEFAULT_GAS_PRICE,
|
||||||
};
|
};
|
||||||
const gethTxDefaults = {
|
|
||||||
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
|
||||||
};
|
|
||||||
export const txDefaults = testProvider === ProviderType.Ganache ? ganacheTxDefaults : gethTxDefaults;
|
|
||||||
|
|
||||||
const gethConfigs = {
|
let providerConfigs: Web3Config = {
|
||||||
shouldUseInProcessGanache: false,
|
|
||||||
rpcUrl: 'http://localhost:8501',
|
|
||||||
shouldUseFakeGasEstimate: false,
|
|
||||||
};
|
|
||||||
const ganacheConfigs = {
|
|
||||||
total_accounts: constants.NUM_TEST_ACCOUNTS,
|
total_accounts: constants.NUM_TEST_ACCOUNTS,
|
||||||
shouldUseInProcessGanache: true,
|
shouldUseInProcessGanache: true,
|
||||||
shouldAllowUnlimitedContractSize: true,
|
shouldAllowUnlimitedContractSize: true,
|
||||||
};
|
};
|
||||||
const providerConfigs = testProvider === ProviderType.Ganache ? ganacheConfigs : gethConfigs;
|
|
||||||
|
if (process.env.FORK_RPC_URL !== undefined) {
|
||||||
|
providerConfigs = {
|
||||||
|
...providerConfigs,
|
||||||
|
fork: process.env.FORK_RPC_URL,
|
||||||
|
blockTime: 0,
|
||||||
|
// ZeroExGovernor signer addresses
|
||||||
|
unlocked_accounts: [
|
||||||
|
'0x257619b7155d247e43c8b6d90c8c17278ae481f0',
|
||||||
|
'0x5ee2a00f8f01d099451844af7f894f26a57fcbf2',
|
||||||
|
'0x894d623e0e0e8ed12c4a73dada999e275684a37d',
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export const provider: Web3ProviderEngine = web3Factory.getRpcProvider(providerConfigs);
|
export const provider: Web3ProviderEngine = web3Factory.getRpcProvider(providerConfigs);
|
||||||
provider.stop();
|
provider.stop();
|
||||||
|
@ -21,6 +21,9 @@ export interface Web3Config {
|
|||||||
shouldUseFakeGasEstimate?: boolean; // default: true
|
shouldUseFakeGasEstimate?: boolean; // default: true
|
||||||
ganacheDatabasePath?: string; // default: undefined, creates a tmp dir
|
ganacheDatabasePath?: string; // default: undefined, creates a tmp dir
|
||||||
shouldAllowUnlimitedContractSize?: boolean;
|
shouldAllowUnlimitedContractSize?: boolean;
|
||||||
|
fork?: string;
|
||||||
|
blockTime?: number;
|
||||||
|
unlocked_accounts?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const web3Factory = {
|
export const web3Factory = {
|
||||||
@ -73,6 +76,9 @@ export const web3Factory = {
|
|||||||
port: 8545,
|
port: 8545,
|
||||||
network_id: 50,
|
network_id: 50,
|
||||||
mnemonic: 'concert load couple harbor equip island argue ramp clarify fence smart topic',
|
mnemonic: 'concert load couple harbor equip island argue ramp clarify fence smart topic',
|
||||||
|
fork: config.fork,
|
||||||
|
blockTime: config.blockTime,
|
||||||
|
unlocked_accounts: config.unlocked_accounts,
|
||||||
} as any), // TODO remove any once types are merged in DefinitelyTyped
|
} as any), // TODO remove any once types are merged in DefinitelyTyped
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -13,6 +13,9 @@ declare module 'ganache-core' {
|
|||||||
vmErrorsOnRPCResponse?: boolean;
|
vmErrorsOnRPCResponse?: boolean;
|
||||||
db_path?: string;
|
db_path?: string;
|
||||||
total_accounts?: number;
|
total_accounts?: number;
|
||||||
|
fork?: string;
|
||||||
|
blockTime?: number;
|
||||||
|
unlocked_accounts?: string[];
|
||||||
}
|
}
|
||||||
export function provider(opts: GanacheOpts): EthereumTypes.Provider;
|
export function provider(opts: GanacheOpts): EthereumTypes.Provider;
|
||||||
}
|
}
|
||||||
|
24
yarn.lock
24
yarn.lock
@ -669,7 +669,8 @@
|
|||||||
|
|
||||||
"@0x/assert@^2.2.0-beta.2", "@0x/assert@^2.2.0-beta.3":
|
"@0x/assert@^2.2.0-beta.2", "@0x/assert@^2.2.0-beta.3":
|
||||||
version "2.2.0-beta.3"
|
version "2.2.0-beta.3"
|
||||||
resolved "https://registry.yarnpkg.com/@0x/assert/-/assert-2.2.0-beta.3.tgz#8fb95c265000532cd8dced44d44d29ca544b2bfc"
|
resolved "https://registry.npmjs.org/@0x/assert/-/assert-2.2.0-beta.3.tgz#8fb95c265000532cd8dced44d44d29ca544b2bfc"
|
||||||
|
integrity sha512-ShENc8QJU4ur/5TkRl3l7J3Yt7WaxHAbuoTRm/djcA0iwYyUVlP5yN9Ab9ua+VLizQQTNw1n+kF1mJWg5lQXuA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@0x/json-schemas" "^4.1.0-beta.3"
|
"@0x/json-schemas" "^4.1.0-beta.3"
|
||||||
"@0x/typescript-typings" "^4.4.0-beta.2"
|
"@0x/typescript-typings" "^4.4.0-beta.2"
|
||||||
@ -723,7 +724,8 @@
|
|||||||
|
|
||||||
"@0x/contract-wrappers@^12.2.0-beta.4":
|
"@0x/contract-wrappers@^12.2.0-beta.4":
|
||||||
version "12.2.0-beta.4"
|
version "12.2.0-beta.4"
|
||||||
resolved "https://registry.yarnpkg.com/@0x/contract-wrappers/-/contract-wrappers-12.2.0-beta.4.tgz#7a7301dd50c28887879df4d385e80a49e040748d"
|
resolved "https://registry.npmjs.org/@0x/contract-wrappers/-/contract-wrappers-12.2.0-beta.4.tgz#7a7301dd50c28887879df4d385e80a49e040748d"
|
||||||
|
integrity sha512-JVoYG3Rd430fZw9ogBSqeLOaJXkqp9N7g614X5/bzzuG/dSDdwXl48X02m66aGFWcNofx/iMsT4tpOZrJ2bDBg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@0x/assert" "^2.2.0-beta.3"
|
"@0x/assert" "^2.2.0-beta.3"
|
||||||
"@0x/base-contract" "^5.5.0-beta.4"
|
"@0x/base-contract" "^5.5.0-beta.4"
|
||||||
@ -790,7 +792,8 @@
|
|||||||
|
|
||||||
"@0x/json-schemas@^4.1.0-beta.2", "@0x/json-schemas@^4.1.0-beta.3":
|
"@0x/json-schemas@^4.1.0-beta.2", "@0x/json-schemas@^4.1.0-beta.3":
|
||||||
version "4.1.0-beta.3"
|
version "4.1.0-beta.3"
|
||||||
resolved "https://registry.yarnpkg.com/@0x/json-schemas/-/json-schemas-4.1.0-beta.3.tgz#af70a35691108ea162140640bae93a7fc84ca6ee"
|
resolved "https://registry.npmjs.org/@0x/json-schemas/-/json-schemas-4.1.0-beta.3.tgz#af70a35691108ea162140640bae93a7fc84ca6ee"
|
||||||
|
integrity sha512-vcgzSeaOXiUQ4KjqdLTTBHbkWnp4IE7cXbUblRy8Y0XYPQsPywhs9mtjY4lBVNmm1DDpLhreo1mwrvPS3HW5YA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@0x/typescript-typings" "^4.4.0-beta.2"
|
"@0x/typescript-typings" "^4.4.0-beta.2"
|
||||||
"@types/node" "*"
|
"@types/node" "*"
|
||||||
@ -903,7 +906,8 @@
|
|||||||
|
|
||||||
"@0x/types@^2.5.0-beta.2", "@0x/types@^2.5.0-beta.3":
|
"@0x/types@^2.5.0-beta.2", "@0x/types@^2.5.0-beta.3":
|
||||||
version "2.5.0-beta.3"
|
version "2.5.0-beta.3"
|
||||||
resolved "https://registry.yarnpkg.com/@0x/types/-/types-2.5.0-beta.3.tgz#e010e9dbf62e37e59177c1d6df8d1acf3a9ea1b4"
|
resolved "https://registry.npmjs.org/@0x/types/-/types-2.5.0-beta.3.tgz#e010e9dbf62e37e59177c1d6df8d1acf3a9ea1b4"
|
||||||
|
integrity sha512-5wJs4/EZGPcU6W5IZ87zuya9vQUPD4DchyP29bXyguGHg9dOxuUOF4WauJZExWlPCS7eivviiUHpZD9DZhni+w==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/node" "*"
|
"@types/node" "*"
|
||||||
bignumber.js "~9.0.0"
|
bignumber.js "~9.0.0"
|
||||||
@ -911,7 +915,8 @@
|
|||||||
|
|
||||||
"@0x/typescript-typings@4.4.0-beta.2", "@0x/typescript-typings@^4.4.0-beta.2":
|
"@0x/typescript-typings@4.4.0-beta.2", "@0x/typescript-typings@^4.4.0-beta.2":
|
||||||
version "4.4.0-beta.2"
|
version "4.4.0-beta.2"
|
||||||
resolved "https://registry.yarnpkg.com/@0x/typescript-typings/-/typescript-typings-4.4.0-beta.2.tgz#67c621252f162914186b8f684ac5e306206c1cf2"
|
resolved "https://registry.npmjs.org/@0x/typescript-typings/-/typescript-typings-4.4.0-beta.2.tgz#67c621252f162914186b8f684ac5e306206c1cf2"
|
||||||
|
integrity sha512-Fq2nOKvopdLMEjuPiKqomGog06bxAXGjqnodCwv9OKr11V5W1twFTUM3c1TENfHeGvcqf1aMl1hsH3fuVP61jg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/bn.js" "^4.11.0"
|
"@types/bn.js" "^4.11.0"
|
||||||
"@types/react" "*"
|
"@types/react" "*"
|
||||||
@ -967,7 +972,8 @@
|
|||||||
|
|
||||||
"@0x/utils@^4.6.0-beta.2", "@0x/utils@^4.6.0-beta.3":
|
"@0x/utils@^4.6.0-beta.2", "@0x/utils@^4.6.0-beta.3":
|
||||||
version "4.6.0-beta.3"
|
version "4.6.0-beta.3"
|
||||||
resolved "https://registry.yarnpkg.com/@0x/utils/-/utils-4.6.0-beta.3.tgz#d40278916d98c48ea05821ae4987c88f032c7bff"
|
resolved "https://registry.npmjs.org/@0x/utils/-/utils-4.6.0-beta.3.tgz#d40278916d98c48ea05821ae4987c88f032c7bff"
|
||||||
|
integrity sha512-aPIUgfhaDhwgddJAlIQJ2Ki87A60ovatBLCjareLUbsQSvFS5i3iujUBQHgFxZAv9tgl35fyg2ISEJ1YkQyubA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@0x/types" "^2.5.0-beta.3"
|
"@0x/types" "^2.5.0-beta.3"
|
||||||
"@0x/typescript-typings" "^4.4.0-beta.2"
|
"@0x/typescript-typings" "^4.4.0-beta.2"
|
||||||
@ -1014,7 +1020,8 @@
|
|||||||
|
|
||||||
"@0x/web3-wrapper@^6.1.0-beta.2", "@0x/web3-wrapper@^6.1.0-beta.3":
|
"@0x/web3-wrapper@^6.1.0-beta.2", "@0x/web3-wrapper@^6.1.0-beta.3":
|
||||||
version "6.1.0-beta.3"
|
version "6.1.0-beta.3"
|
||||||
resolved "https://registry.yarnpkg.com/@0x/web3-wrapper/-/web3-wrapper-6.1.0-beta.3.tgz#82161147e9283391e0c7cd6027c971749c5a2f77"
|
resolved "https://registry.npmjs.org/@0x/web3-wrapper/-/web3-wrapper-6.1.0-beta.3.tgz#82161147e9283391e0c7cd6027c971749c5a2f77"
|
||||||
|
integrity sha512-mc8120n8w88gICbDm8pkmC83Ul3RgE4BGsjY5BRBFefmKbv/XLeBZiWdhsaWYmkk8v4f+ZxAQ+HHTBDsRH87Og==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@0x/assert" "^2.2.0-beta.3"
|
"@0x/assert" "^2.2.0-beta.3"
|
||||||
"@0x/json-schemas" "^4.1.0-beta.3"
|
"@0x/json-schemas" "^4.1.0-beta.3"
|
||||||
@ -6754,7 +6761,8 @@ ethereum-types@^2.1.6:
|
|||||||
|
|
||||||
ethereum-types@^2.2.0-beta.2:
|
ethereum-types@^2.2.0-beta.2:
|
||||||
version "2.2.0-beta.2"
|
version "2.2.0-beta.2"
|
||||||
resolved "https://registry.yarnpkg.com/ethereum-types/-/ethereum-types-2.2.0-beta.2.tgz#0b446842474c2afacd351258ed4a2d0841f2608f"
|
resolved "https://registry.npmjs.org/ethereum-types/-/ethereum-types-2.2.0-beta.2.tgz#0b446842474c2afacd351258ed4a2d0841f2608f"
|
||||||
|
integrity sha512-5ANYHI/InHqf4Nt8oYrpvcph9/D6gi3sbM7Rlr8r0QjXb2mqocqEvOH460Zkf1robc7WDqurp9baeMy+um8kww==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/node" "*"
|
"@types/node" "*"
|
||||||
bignumber.js "~9.0.0"
|
bignumber.js "~9.0.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user