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







                                                      

              
                        
                                                 
      
                                                                 
                                                                           






                                                                       
                    



                      
#!/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);
});