aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorFabio B <kandinsky454@protonmail.ch>2018-11-27 00:14:16 +0800
committerGitHub <noreply@github.com>2018-11-27 00:14:16 +0800
commit6d565f4bff38b12515f4d8f0e29cdc223c12d1fb (patch)
tree1be1e92305054bcc2d8ffbb23156b0f34546737d /packages
parentee86cd1dcc0cfe7783d97fa82ac3176da58863c1 (diff)
parentc6592148a725768f652ddfa8f94aa3e2c6f7f213 (diff)
downloaddexon-0x-contracts-6d565f4bff38b12515f4d8f0e29cdc223c12d1fb.tar.gz
dexon-0x-contracts-6d565f4bff38b12515f4d8f0e29cdc223c12d1fb.tar.zst
dexon-0x-contracts-6d565f4bff38b12515f4d8f0e29cdc223c12d1fb.zip
Merge pull request #1324 from 0xProject/addCommandLineInterfaceToMigrations
Add CLI interface to @0x/migrations
Diffstat (limited to 'packages')
-rw-r--r--packages/migrations/CHANGELOG.json4
-rwxr-xr-xpackages/migrations/bin/0x-migrate.js2
-rw-r--r--packages/migrations/package.json3
-rw-r--r--packages/migrations/src/cli.ts38
4 files changed, 47 insertions, 0 deletions
diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json
index f302838a2..07031fc09 100644
--- a/packages/migrations/CHANGELOG.json
+++ b/packages/migrations/CHANGELOG.json
@@ -3,6 +3,10 @@
"version": "2.2.0",
"changes": [
{
+ "note": "Add CLI `0x-migrate` for running the 0x migrations in a language-agnostic way",
+ "pr": 1324
+ },
+ {
"note": "Deploy testnet Exchange arfitact. Previously mainnet Exchange artifact was deployed.",
"pr": 1309
},
diff --git a/packages/migrations/bin/0x-migrate.js b/packages/migrations/bin/0x-migrate.js
new file mode 100755
index 000000000..59778c0fc
--- /dev/null
+++ b/packages/migrations/bin/0x-migrate.js
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+require('../lib/cli.js');
diff --git a/packages/migrations/package.json b/packages/migrations/package.json
index c1ce7050d..b006a470a 100644
--- a/packages/migrations/package.json
+++ b/packages/migrations/package.json
@@ -21,6 +21,9 @@
"assets": []
}
},
+ "bin": {
+ "0x-migrate": "bin/0x-migrate.js"
+ },
"license": "Apache-2.0",
"devDependencies": {
"@0x/dev-utils": "^1.0.18",
diff --git a/packages/migrations/src/cli.ts b/packages/migrations/src/cli.ts
new file mode 100644
index 000000000..2404e7921
--- /dev/null
+++ b/packages/migrations/src/cli.ts
@@ -0,0 +1,38 @@
+#!/usr/bin/env node
+import { RPCSubprovider, Web3ProviderEngine } from '@0x/subproviders';
+import { logUtils } from '@0x/utils';
+import * as yargs from 'yargs';
+
+import { runMigrationsAsync } from './migration';
+
+const args = yargs
+ .option('rpc-url', {
+ describe: 'Endpoint where backing Ethereum JSON RPC interface is available',
+ type: 'string',
+ demandOption: false,
+ default: 'http://localhost:8545',
+ })
+ .option('from', {
+ describe: 'Ethereum address from which to deploy the contracts',
+ type: 'string',
+ demandOption: true,
+ })
+ .example(
+ '$0 --rpc-url http://localhost:8545 --from 0x5409ed021d9299bf6814279a6a1411a7e866a631',
+ 'Full usage example',
+ ).argv;
+
+(async () => {
+ const rpcSubprovider = new RPCSubprovider(args['rpc-url']);
+ const provider = new Web3ProviderEngine();
+ provider.addProvider(rpcSubprovider);
+ provider.start();
+ const txDefaults = {
+ from: args.from,
+ };
+ await runMigrationsAsync(provider, txDefaults);
+ process.exit(0);
+})().catch(err => {
+ logUtils.log(err);
+ process.exit(1);
+});