aboutsummaryrefslogtreecommitdiffstats
path: root/packages/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'packages/migrations')
-rw-r--r--packages/migrations/CHANGELOG.json28
-rw-r--r--packages/migrations/CHANGELOG.md4
-rwxr-xr-xpackages/migrations/bin/0x-migrate.js2
-rw-r--r--packages/migrations/package.json34
-rw-r--r--packages/migrations/src/cli.ts38
-rw-r--r--packages/migrations/src/index.ts10
-rw-r--r--packages/migrations/src/migration.ts19
-rw-r--r--packages/migrations/typedoc-tsconfig.json7
8 files changed, 124 insertions, 18 deletions
diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json
index 5b0d58909..07031fc09 100644
--- a/packages/migrations/CHANGELOG.json
+++ b/packages/migrations/CHANGELOG.json
@@ -1,5 +1,33 @@
[
{
+ "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
+ },
+ {
+ "note": "Fund the Forwarder with ZRX for fees.",
+ "pr": 1309
+ }
+ ]
+ },
+ {
+ "version": "2.1.0",
+ "changes": [
+ {
+ "note":
+ "Export all type declarations used by the public interface, as well as the `ContractAddresses` mapping",
+ "pr": 1301
+ }
+ ],
+ "timestamp": 1542821676
+ },
+ {
"timestamp": 1542208198,
"version": "2.0.4",
"changes": [
diff --git a/packages/migrations/CHANGELOG.md b/packages/migrations/CHANGELOG.md
index 87d0b25ca..986e224b0 100644
--- a/packages/migrations/CHANGELOG.md
+++ b/packages/migrations/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v2.1.0 - _November 21, 2018_
+
+ * Export all type declarations used by the public interface, as well as the `ContractAddresses` mapping (#1301)
+
## v2.0.4 - _November 14, 2018_
* Dependencies updated
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 8eaae96ba..b006a470a 100644
--- a/packages/migrations/package.json
+++ b/packages/migrations/package.json
@@ -1,6 +1,6 @@
{
"name": "@0x/migrations",
- "version": "2.0.4",
+ "version": "2.1.0",
"engines": {
"node": ">=6.12"
},
@@ -13,32 +13,42 @@
"clean": "shx rm -rf lib",
"lint": "tslint --format stylish --project .",
"migrate:v2": "run-s build script:migrate:v2",
- "script:migrate:v2": "node ./lib/migrate.js --contracts-version 2.0.0"
+ "script:migrate:v2": "node ./lib/migrate.js",
+ "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
+ },
+ "config": {
+ "postpublish": {
+ "assets": []
+ }
+ },
+ "bin": {
+ "0x-migrate": "bin/0x-migrate.js"
},
"license": "Apache-2.0",
"devDependencies": {
- "@0x/dev-utils": "^1.0.17",
+ "@0x/dev-utils": "^1.0.18",
"@0x/tslint-config": "^1.0.10",
- "@0x/types": "^1.2.1",
+ "@0x/types": "^1.3.0",
"@types/yargs": "^10.0.0",
"make-promises-safe": "^1.1.0",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"tslint": "5.11.0",
+ "typedoc": "0.13.0",
"typescript": "3.0.1",
"yargs": "^10.0.3"
},
"dependencies": {
- "@0x/abi-gen-wrappers": "^1.0.5",
- "@0x/base-contract": "^3.0.6",
- "@0x/contract-addresses": "^1.1.0",
+ "@0x/abi-gen-wrappers": "^1.1.0",
+ "@0x/base-contract": "^3.0.7",
+ "@0x/contract-addresses": "^1.2.0",
"@0x/contract-artifacts": "^1.1.0",
- "@0x/order-utils": "^3.0.2",
- "@0x/sol-compiler": "^1.1.12",
- "@0x/subproviders": "^2.1.4",
+ "@0x/order-utils": "^3.0.3",
+ "@0x/sol-compiler": "^1.1.13",
+ "@0x/subproviders": "^2.1.5",
"@0x/typescript-typings": "^3.0.4",
- "@0x/utils": "^2.0.5",
- "@0x/web3-wrapper": "^3.1.4",
+ "@0x/utils": "^2.0.6",
+ "@0x/web3-wrapper": "^3.1.5",
"@ledgerhq/hw-app-eth": "^4.3.0",
"ethereum-types": "^1.1.2",
"ethers": "~4.0.4",
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);
+});
diff --git a/packages/migrations/src/index.ts b/packages/migrations/src/index.ts
index 8f629a24b..4f22c30b9 100644
--- a/packages/migrations/src/index.ts
+++ b/packages/migrations/src/index.ts
@@ -1 +1,11 @@
+export {
+ Provider,
+ TxData,
+ JSONRPCRequestPayload,
+ JSONRPCErrorCallback,
+ TxDataPayable,
+ JSONRPCResponsePayload,
+ JSONRPCResponseError,
+} from 'ethereum-types';
+export { ContractAddresses } from '@0x/contract-addresses';
export { runMigrationsAsync, runMigrationsOnceAsync } from './migration';
diff --git a/packages/migrations/src/migration.ts b/packages/migrations/src/migration.ts
index 86c76a54b..c684c4970 100644
--- a/packages/migrations/src/migration.ts
+++ b/packages/migrations/src/migration.ts
@@ -11,10 +11,9 @@ import { erc20TokenInfo, erc721TokenInfo } from './utils/token_info';
/**
* Creates and deploys all the contracts that are required for the latest
- * version of the 0x protocol. Custom migrations can be defined here. This will
- * be called with the CLI 'migrate:v2' command.
- * @param provider Web3 provider instance.
- * @param txDefaults Default transaction values to use when deploying contracts.
+ * version of the 0x protocol.
+ * @param provider Web3 provider instance. Your provider instance should connect to the testnet you want to deploy to.
+ * @param txDefaults Default transaction values to use when deploying contracts (e.g., specify the desired contract creator with the `from` parameter).
* @returns The addresses of the contracts that were deployed.
*/
export async function runMigrationsAsync(provider: Provider, txDefaults: Partial<TxData>): Promise<ContractAddresses> {
@@ -48,6 +47,7 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial
artifacts.Exchange,
provider,
txDefaults,
+ zrxAssetData,
);
// Multisigs
@@ -141,6 +141,13 @@ export async function runMigrationsAsync(provider: Provider, txDefaults: Partial
zrxAssetData,
);
+ // Fund the Forwarder with ZRX
+ const zrxDecimals = await zrxToken.decimals.callAsync();
+ const zrxForwarderAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(5000), zrxDecimals);
+ await web3Wrapper.awaitTransactionSuccessAsync(
+ await zrxToken.transfer.sendTransactionAsync(forwarder.address, zrxForwarderAmount, txDefaults),
+ );
+
return {
erc20Proxy: erc20Proxy.address,
erc721Proxy: erc721Proxy.address,
@@ -159,8 +166,8 @@ let _cachedContractAddresses: ContractAddresses;
* Exactly like runMigrationsAsync but will only run the migrations the first
* time it is called. Any subsequent calls will return the cached contract
* addresses.
- * @param provider Web3 provider instance.
- * @param txDefaults Default transaction values to use when deploying contracts.
+ * @param provider Web3 provider instance. Your provider instance should connect to the testnet you want to deploy to.
+ * @param txDefaults Default transaction values to use when deploying contracts (e.g., specify the desired contract creator with the `from` parameter).
* @returns The addresses of the contracts that were deployed.
*/
export async function runMigrationsOnceAsync(
diff --git a/packages/migrations/typedoc-tsconfig.json b/packages/migrations/typedoc-tsconfig.json
new file mode 100644
index 000000000..c9b0af1ae
--- /dev/null
+++ b/packages/migrations/typedoc-tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../typedoc-tsconfig",
+ "compilerOptions": {
+ "outDir": "lib"
+ },
+ "include": ["./src/**/*", "./test/**/*"]
+}