aboutsummaryrefslogtreecommitdiffstats
path: root/packages/migrations/src
diff options
context:
space:
mode:
authorJacob Evans <dekz@dekz.net>2019-01-09 09:55:42 +0800
committerGitHub <noreply@github.com>2019-01-09 09:55:42 +0800
commitc1bf2754a8638d568685e09269155464cb216a90 (patch)
tree7840ed4161217663f9637bcfdac7a4f5bf392681 /packages/migrations/src
parentc388e6d2b80530a164598c3838274216dcdc1ba4 (diff)
parent72a56db5abc71d59f904dd0ff250474f97a52c99 (diff)
downloaddexon-sol-tools-c1bf2754a8638d568685e09269155464cb216a90.tar
dexon-sol-tools-c1bf2754a8638d568685e09269155464cb216a90.tar.gz
dexon-sol-tools-c1bf2754a8638d568685e09269155464cb216a90.tar.bz2
dexon-sol-tools-c1bf2754a8638d568685e09269155464cb216a90.tar.lz
dexon-sol-tools-c1bf2754a8638d568685e09269155464cb216a90.tar.xz
dexon-sol-tools-c1bf2754a8638d568685e09269155464cb216a90.tar.zst
dexon-sol-tools-c1bf2754a8638d568685e09269155464cb216a90.zip
Merge pull request #1439 from 0xProject/migrations/docker-image
Add Docker image and Snapshot commands for migrations
Diffstat (limited to 'packages/migrations/src')
-rw-r--r--packages/migrations/src/migrate_snapshot.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/migrations/src/migrate_snapshot.ts b/packages/migrations/src/migrate_snapshot.ts
new file mode 100644
index 000000000..13fb063da
--- /dev/null
+++ b/packages/migrations/src/migrate_snapshot.ts
@@ -0,0 +1,32 @@
+#!/usr/bin/env node
+import { devConstants, web3Factory } from '@0x/dev-utils';
+import { logUtils } from '@0x/utils';
+import { Provider } from 'ethereum-types';
+import * as fs from 'fs';
+import * as _ from 'lodash';
+import * as path from 'path';
+
+import { runMigrationsAsync } from './migration';
+
+(async () => {
+ let providerConfigs;
+ let provider: Provider;
+ let txDefaults;
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
+ const packageJsonString = fs.readFileSync(packageJsonPath, 'utf8');
+ const packageJson = JSON.parse(packageJsonString);
+ if (_.isUndefined(packageJson.config) || _.isUndefined(packageJson.config.snapshot_name)) {
+ throw new Error(`Did not find 'snapshot_name' key in package.json config`);
+ }
+
+ providerConfigs = { shouldUseInProcessGanache: true, ganacheDatabasePath: packageJson.config.snapshot_name };
+ provider = web3Factory.getRpcProvider(providerConfigs);
+ txDefaults = {
+ from: devConstants.TESTRPC_FIRST_ADDRESS,
+ };
+ await runMigrationsAsync(provider, txDefaults);
+ process.exit(0);
+})().catch(err => {
+ logUtils.log(err);
+ process.exit(1);
+});