aboutsummaryrefslogtreecommitdiffstats
path: root/packages/migrations/src/migrate.ts
blob: a6fd86e5a0549987fc4ffce31e7a2987abe706c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env node
import { devConstants, web3Factory } from '@0xproject/dev-utils';
import { logUtils } from '@0xproject/utils';
import { Provider } from 'ethereum-types';
import * as path from 'path';
import * as yargs from 'yargs';

import { runV1MigrationsAsync } from './v1/migration';
import { runV2MigrationsAsync } from './v2/migration';

enum ContractVersions {
    V1 = '1.0.0',
    V2 = '2.0.0',
}
const args = yargs.argv;

(async () => {
    const txDefaults = {
        from: devConstants.TESTRPC_FIRST_ADDRESS,
    };
    const providerConfigs = { shouldUseInProcessGanache: false };
    const provider: Provider = web3Factory.getRpcProvider(providerConfigs);
    const contractsVersion = args.contractsVersion;
    const artifactsDir = `artifacts/${contractsVersion}`;
    if (contractsVersion === ContractVersions.V1) {
        await runV1MigrationsAsync(provider, artifactsDir, txDefaults);
    } else {
        await runV2MigrationsAsync(provider, artifactsDir, txDefaults);
    }
    process.exit(0);
})().catch(err => {
    logUtils.log(err);
    process.exit(1);
});