aboutsummaryrefslogblamecommitdiffstats
path: root/packages/migrations/src/migrate.ts
blob: 5f320ec781b6858d85bf4e1f25f0e7ccdd891357 (plain) (tree)
1
2
3
4
5
6
                   
                                                                 
                                            
                                          
                               
 







                                                      

              
                        
                                                 
      
                                                                 
                                                                           






                                                                       
                    



                      
#!/usr/bin/env node
import { devConstants, web3Factory } from '@0xproject/dev-utils';
import { logUtils } from '@0xproject/utils';
import { Provider } from 'ethereum-types';
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);
});