diff options
Diffstat (limited to 'packages/migrations/src')
-rw-r--r-- | packages/migrations/src/artifact_writer.ts | 26 | ||||
-rw-r--r-- | packages/migrations/src/artifacts.ts | 23 | ||||
-rw-r--r-- | packages/migrations/src/migrate.ts | 2 | ||||
-rw-r--r-- | packages/migrations/src/migration.ts | 22 |
4 files changed, 40 insertions, 33 deletions
diff --git a/packages/migrations/src/artifact_writer.ts b/packages/migrations/src/artifact_writer.ts new file mode 100644 index 000000000..2da5a09dd --- /dev/null +++ b/packages/migrations/src/artifact_writer.ts @@ -0,0 +1,26 @@ +import { BaseContract } from '@0xproject/base-contract'; +import { ContractArtifact } from '@0xproject/sol-compiler'; +import * as fs from 'fs'; +import * as path from 'path'; + +export class ArtifactWriter { + private _artifactsDir: string; + private _networkId: number; + constructor(artifactsDir: string, networkId: number) { + this._artifactsDir = artifactsDir; + this._networkId = networkId; + } + // This updates the artifact file but does not update the `artifacts` module above. It will not + // contain the saved artifact changes. + public saveArtifact(contract: BaseContract): void { + const contractName = contract.contractName; + const artifactFile = path.join(this._artifactsDir, `${contractName}.json`); + const artifact: ContractArtifact = JSON.parse(fs.readFileSync(artifactFile).toString()); + artifact.networks[this._networkId] = { + address: contract.address, + links: {}, + constructorArgs: JSON.stringify(contract.constructorArgs), + }; + fs.writeFileSync(artifactFile, JSON.stringify(artifact, null, '\t')); + } +} diff --git a/packages/migrations/src/artifacts.ts b/packages/migrations/src/artifacts.ts index f8913fe52..42eb1c33e 100644 --- a/packages/migrations/src/artifacts.ts +++ b/packages/migrations/src/artifacts.ts @@ -1,7 +1,4 @@ -import { BaseContract } from '@0xproject/base-contract'; import { ContractArtifact } from '@0xproject/sol-compiler'; -import * as fs from 'fs'; -import * as path from 'path'; import * as AccountLevels from '../artifacts/1.0.0/AccountLevels.json'; import * as Arbitrage from '../artifacts/1.0.0/Arbitrage.json'; @@ -32,23 +29,3 @@ export const artifacts = { MultiSigWalletWithTimeLock: (MultiSigWalletWithTimeLock as any) as ContractArtifact, MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress: (MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress as any) as ContractArtifact, }; - -export class ArtifactWriter { - private _artifactsDir: string; - private _networkId: number; - constructor(artifactsDir: string, networkId: number) { - this._artifactsDir = artifactsDir; - this._networkId = networkId; - } - public saveArtifact(contract: BaseContract): void { - const contractName = contract.contractName; - const artifactFile = path.join(this._artifactsDir, `${contractName}.json`); - const artifact: ContractArtifact = JSON.parse(fs.readFileSync(artifactFile).toString()); - artifact.networks[this._networkId] = { - address: contract.address, - links: {}, - constructorArgs: JSON.stringify(contract.constructorArgs), - }; - fs.writeFileSync(artifactFile, JSON.stringify(artifact, null, 2)); - } -} diff --git a/packages/migrations/src/migrate.ts b/packages/migrations/src/migrate.ts index 58d39734e..fe3daed98 100644 --- a/packages/migrations/src/migrate.ts +++ b/packages/migrations/src/migrate.ts @@ -14,7 +14,7 @@ import { runMigrationsAsync } from './migration'; const web3 = web3Factory.create(providerConfigs); const provider = web3.currentProvider; const artifactsDir = 'artifacts/1.0.0'; - await runMigrationsAsync(provider, artifactsDir, defaults); + await runMigrationsAsync(provider, artifactsDir, txDefaults); process.exit(0); })().catch(err => { logUtils.log(err); diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts index 5b49b9282..2e38b59ae 100644 --- a/packages/migrations/src/migration.ts +++ b/packages/migrations/src/migration.ts @@ -20,24 +20,28 @@ import { tokenInfo } from './utils/token_info'; * the migration should be written to run synchronously. * @param provider Web3 provider instance. * @param artifactsDir The directory with compiler artifact files. - * @param defaults Default transaction values to use when deploying contracts. + * @param txDefaults Default transaction values to use when deploying contracts. */ -export const runMigrationsAsync = async (provider: Provider, artifactsDir: string, defaults: Partial<TxData>) => { +export const runMigrationsAsync = async (provider: Provider, artifactsDir: string, txDefaults: Partial<TxData>) => { const web3Wrapper = new Web3Wrapper(provider); const networkId = await web3Wrapper.getNetworkIdAsync(); const artifactsWriter = new ArtifactWriter(artifactsDir, networkId); const tokenTransferProxy = await TokenTransferProxyContract.deployFrom0xArtifactAsync( artifacts.TokenTransferProxy, provider, - defaults, + txDefaults, ); artifactsWriter.saveArtifact(tokenTransferProxy); - const zrxToken = await ZRXTokenContract.deployFrom0xArtifactAsync(artifacts.ZRX, provider, defaults); + const zrxToken = await ZRXTokenContract.deployFrom0xArtifactAsync(artifacts.ZRX, provider, txDefaults); artifactsWriter.saveArtifact(zrxToken); - const etherToken = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.EtherToken, provider, defaults); + const etherToken = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.EtherToken, provider, txDefaults); artifactsWriter.saveArtifact(etherToken); - const tokenReg = await TokenRegistryContract.deployFrom0xArtifactAsync(artifacts.TokenRegistry, provider, defaults); + const tokenReg = await TokenRegistryContract.deployFrom0xArtifactAsync( + artifacts.TokenRegistry, + provider, + txDefaults, + ); artifactsWriter.saveArtifact(tokenReg); const accounts: string[] = await web3Wrapper.getAvailableAddressesAsync(); @@ -47,7 +51,7 @@ export const runMigrationsAsync = async (provider: Provider, artifactsDir: strin const exchange = await ExchangeContract.deployFrom0xArtifactAsync( artifacts.Exchange, provider, - defaults, + txDefaults, zrxToken.address, tokenTransferProxy.address, ); @@ -55,7 +59,7 @@ export const runMigrationsAsync = async (provider: Provider, artifactsDir: strin const multiSig = await MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressContract.deployFrom0xArtifactAsync( artifacts.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress, provider, - defaults, + txDefaults, owners, confirmationsRequired, secondsRequired, @@ -104,7 +108,7 @@ export const runMigrationsAsync = async (provider: Provider, artifactsDir: strin const dummyToken = await DummyTokenContract.deployFrom0xArtifactAsync( artifacts.DummyToken, provider, - defaults, + txDefaults, token.name, token.symbol, token.decimals, |