Massage the migrations to match contract-addresses
This commit is contained in:
parent
379a31ece6
commit
2705bcce15
@ -5,18 +5,21 @@
|
|||||||
"node": ">=6.12"
|
"node": ">=6.12"
|
||||||
},
|
},
|
||||||
"description": "0x smart contract migrations",
|
"description": "0x smart contract migrations",
|
||||||
"main": "lib/index.js",
|
"main": "lib/src/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc -b",
|
"build": "tsc -b",
|
||||||
"build:ci": "yarn build",
|
"build:ci": "yarn build",
|
||||||
"clean": "shx rm -rf lib ${npm_package_config_snapshot_name} ${npm_package_config_snapshot_name}-*.zip",
|
"clean": "shx rm -rf lib ${npm_package_config_snapshot_name} ${npm_package_config_snapshot_name}-*.zip",
|
||||||
"lint": "tslint --format stylish --project .",
|
"lint": "tslint --format stylish --project .",
|
||||||
"fix": "tslint --fix --format stylish --project .",
|
"fix": "tslint --fix --format stylish --project .",
|
||||||
|
"test": "yarn run_mocha",
|
||||||
|
"test:circleci": "yarn test",
|
||||||
|
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --bail --timeout 30000 --exit",
|
||||||
"migrate:v2": "run-s build script:migrate:v2",
|
"migrate:v2": "run-s build script:migrate:v2",
|
||||||
"migrate:v2:snapshot": "run-s build script:migrate:v2:snapshot",
|
"migrate:v2:snapshot": "run-s build script:migrate:v2:snapshot",
|
||||||
"script:migrate:v2": "node ./lib/migrate.js",
|
"script:migrate:v2": "node ./lib/src/migrate.js",
|
||||||
"script:migrate:v2:snapshot": "node ./lib/migrate_snapshot.js",
|
"script:migrate:v2:snapshot": "node ./lib/src/migrate_snapshot.js",
|
||||||
"diff_docs": "git diff --exit-code ./docs",
|
"diff_docs": "git diff --exit-code ./docs",
|
||||||
"s3:sync_md_docs": "aws s3 sync ./docs s3://docs-markdown/${npm_package_name}/v${npm_package_version} --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers",
|
"s3:sync_md_docs": "aws s3 sync ./docs s3://docs-markdown/${npm_package_name}/v${npm_package_version} --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers",
|
||||||
"docs:md": "ts-doc-gen --sourceDir='$PROJECT_FILES' --output=$MD_FILE_DIR --fileExtension=mdx --tsconfig=./typedoc-tsconfig.json",
|
"docs:md": "ts-doc-gen --sourceDir='$PROJECT_FILES' --output=$MD_FILE_DIR --fileExtension=mdx --tsconfig=./typedoc-tsconfig.json",
|
||||||
@ -48,6 +51,9 @@
|
|||||||
"make-promises-safe": "^1.1.0",
|
"make-promises-safe": "^1.1.0",
|
||||||
"npm-run-all": "^4.1.2",
|
"npm-run-all": "^4.1.2",
|
||||||
"shx": "^0.2.2",
|
"shx": "^0.2.2",
|
||||||
|
"dirty-chai": "^2.0.1",
|
||||||
|
"mocha": "^6.2.0",
|
||||||
|
"chai": "^4.0.1",
|
||||||
"tslint": "5.11.0",
|
"tslint": "5.11.0",
|
||||||
"typedoc": "^0.15.0",
|
"typedoc": "^0.15.0",
|
||||||
"typescript": "3.0.1",
|
"typescript": "3.0.1",
|
||||||
|
@ -12,7 +12,7 @@ import { runMigrationsAsync } from './migration';
|
|||||||
let providerConfigs;
|
let providerConfigs;
|
||||||
let provider: Web3ProviderEngine;
|
let provider: Web3ProviderEngine;
|
||||||
let txDefaults;
|
let txDefaults;
|
||||||
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
const packageJsonPath = path.join(__dirname, '../..', 'package.json');
|
||||||
const packageJsonString = fs.readFileSync(packageJsonPath, 'utf8');
|
const packageJsonString = fs.readFileSync(packageJsonPath, 'utf8');
|
||||||
const packageJson = JSON.parse(packageJsonString);
|
const packageJson = JSON.parse(packageJsonString);
|
||||||
if (packageJson.config === undefined || packageJson.config.snapshot_name === undefined) {
|
if (packageJson.config === undefined || packageJson.config.snapshot_name === undefined) {
|
||||||
|
@ -176,10 +176,19 @@ export async function runMigrationsAsync(
|
|||||||
await exchange.registerAssetProxy(multiAssetProxy.address).awaitTransactionSuccessAsync(txDefaults);
|
await exchange.registerAssetProxy(multiAssetProxy.address).awaitTransactionSuccessAsync(txDefaults);
|
||||||
await exchange.registerAssetProxy(staticCallProxy.address).awaitTransactionSuccessAsync(txDefaults);
|
await exchange.registerAssetProxy(staticCallProxy.address).awaitTransactionSuccessAsync(txDefaults);
|
||||||
|
|
||||||
|
// Forwarder
|
||||||
|
const forwarder = await ForwarderContract.deployFrom0xArtifactAsync(
|
||||||
|
artifacts.Forwarder,
|
||||||
|
provider,
|
||||||
|
txDefaults,
|
||||||
|
artifacts,
|
||||||
|
exchange.address,
|
||||||
|
encodeERC20AssetData(etherToken.address),
|
||||||
|
);
|
||||||
// Fake the above transactions so our nonce increases and we result with the same addresses
|
// Fake the above transactions so our nonce increases and we result with the same addresses
|
||||||
// while AssetProxyOwner is disabled (TODO: @dekz remove)
|
// while AssetProxyOwner is disabled (TODO: @dekz remove)
|
||||||
const dummyTransactionCount = 8;
|
const dummyTransactionCount = 7;
|
||||||
for (let index = 0; index < dummyTransactionCount; index++) {
|
for (let index = 0; index <= dummyTransactionCount; index++) {
|
||||||
await web3Wrapper.sendTransactionAsync({ to: txDefaults.from, from: txDefaults.from, value: new BigNumber(0) });
|
await web3Wrapper.sendTransactionAsync({ to: txDefaults.from, from: txDefaults.from, value: new BigNumber(0) });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +247,6 @@ export async function runMigrationsAsync(
|
|||||||
zrxProxy,
|
zrxProxy,
|
||||||
zrxToken.address,
|
zrxToken.address,
|
||||||
);
|
);
|
||||||
await erc20Proxy.addAuthorizedAddress(zrxVault.address).awaitTransactionSuccessAsync(txDefaults);
|
|
||||||
|
|
||||||
// Note we use TestStakingContract as the deployed bytecode of a StakingContract
|
// Note we use TestStakingContract as the deployed bytecode of a StakingContract
|
||||||
// has the tokens hardcoded
|
// has the tokens hardcoded
|
||||||
@ -259,6 +267,8 @@ export async function runMigrationsAsync(
|
|||||||
stakingLogic.address,
|
stakingLogic.address,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await erc20Proxy.addAuthorizedAddress(zrxVault.address).awaitTransactionSuccessAsync(txDefaults);
|
||||||
|
|
||||||
// Reference the Proxy as the StakingContract for setup
|
// Reference the Proxy as the StakingContract for setup
|
||||||
const stakingDel = await new TestStakingContract(stakingProxy.address, provider, txDefaults);
|
const stakingDel = await new TestStakingContract(stakingProxy.address, provider, txDefaults);
|
||||||
await stakingProxy.addAuthorizedAddress(txDefaults.from).awaitTransactionSuccessAsync(txDefaults);
|
await stakingProxy.addAuthorizedAddress(txDefaults.from).awaitTransactionSuccessAsync(txDefaults);
|
||||||
@ -271,16 +281,6 @@ export async function runMigrationsAsync(
|
|||||||
await stakingLogic.addAuthorizedAddress(txDefaults.from).awaitTransactionSuccessAsync(txDefaults);
|
await stakingLogic.addAuthorizedAddress(txDefaults.from).awaitTransactionSuccessAsync(txDefaults);
|
||||||
await stakingLogic.addExchangeAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults);
|
await stakingLogic.addExchangeAddress(exchange.address).awaitTransactionSuccessAsync(txDefaults);
|
||||||
|
|
||||||
// Forwarder
|
|
||||||
const forwarder = await ForwarderContract.deployFrom0xArtifactAsync(
|
|
||||||
artifacts.Forwarder,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
artifacts,
|
|
||||||
exchange.address,
|
|
||||||
encodeERC20AssetData(etherToken.address),
|
|
||||||
);
|
|
||||||
|
|
||||||
const contractAddresses = {
|
const contractAddresses = {
|
||||||
erc20Proxy: erc20Proxy.address,
|
erc20Proxy: erc20Proxy.address,
|
||||||
erc721Proxy: erc721Proxy.address,
|
erc721Proxy: erc721Proxy.address,
|
||||||
@ -299,14 +299,13 @@ export async function runMigrationsAsync(
|
|||||||
multiAssetProxy: multiAssetProxy.address,
|
multiAssetProxy: multiAssetProxy.address,
|
||||||
staticCallProxy: staticCallProxy.address,
|
staticCallProxy: staticCallProxy.address,
|
||||||
devUtils: devUtils.address,
|
devUtils: devUtils.address,
|
||||||
exchangeV2: constants.NULL_ADDRESS,
|
exchangeV2: exchange.address,
|
||||||
zrxVault: zrxVault.address,
|
zrxVault: zrxVault.address,
|
||||||
staking: stakingLogic.address,
|
staking: stakingLogic.address,
|
||||||
stakingProxy: stakingProxy.address,
|
stakingProxy: stakingProxy.address,
|
||||||
uniswapBridge: constants.NULL_ADDRESS,
|
uniswapBridge: constants.NULL_ADDRESS,
|
||||||
eth2DaiBridge: constants.NULL_ADDRESS,
|
eth2DaiBridge: constants.NULL_ADDRESS,
|
||||||
};
|
};
|
||||||
|
|
||||||
return contractAddresses;
|
return contractAddresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
packages/migrations/test/snapshot_addresses_test.ts
Normal file
24
packages/migrations/test/snapshot_addresses_test.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { ChainId, getContractAddressesForChainOrThrow } from '@0x/contract-addresses';
|
||||||
|
import { devConstants, web3Factory } from '@0x/dev-utils';
|
||||||
|
import * as chai from 'chai';
|
||||||
|
import * as dirtyChai from 'dirty-chai';
|
||||||
|
import 'mocha';
|
||||||
|
|
||||||
|
import { runMigrationsAsync } from '../src/migration';
|
||||||
|
|
||||||
|
chai.use(dirtyChai);
|
||||||
|
|
||||||
|
const expect = chai.expect;
|
||||||
|
|
||||||
|
describe('addresses', () => {
|
||||||
|
it('should contain the same addresses as contract-addresses', async () => {
|
||||||
|
const providerConfigs = { shouldUseInProcessGanache: true };
|
||||||
|
const provider = web3Factory.getRpcProvider(providerConfigs);
|
||||||
|
const txDefaults = {
|
||||||
|
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
||||||
|
};
|
||||||
|
const migrationAddresses = await runMigrationsAsync(provider, txDefaults);
|
||||||
|
const expectedAddresses = getContractAddressesForChainOrThrow(ChainId.Ganache);
|
||||||
|
expect(migrationAddresses).to.include(expectedAddresses);
|
||||||
|
});
|
||||||
|
});
|
@ -2,7 +2,7 @@
|
|||||||
"extends": "../../tsconfig",
|
"extends": "../../tsconfig",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "lib",
|
"outDir": "lib",
|
||||||
"rootDir": "src"
|
"rootDir": "."
|
||||||
},
|
},
|
||||||
"include": ["src/**/*"]
|
"include": ["src/**/*", "test/**/*"]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user