aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/package.json11
-rw-r--r--packages/0x.js/src/artifacts.ts14
-rw-r--r--packages/0x.js/src/compact_artifacts/DummyToken.json (renamed from packages/0x.js/src/artifacts/DummyToken.json)0
-rw-r--r--packages/0x.js/src/compact_artifacts/EtherToken.json (renamed from packages/0x.js/src/artifacts/EtherToken.json)0
-rw-r--r--packages/0x.js/src/compact_artifacts/Exchange.json (renamed from packages/0x.js/src/artifacts/Exchange.json)0
-rw-r--r--packages/0x.js/src/compact_artifacts/Token.json (renamed from packages/0x.js/src/artifacts/Token.json)0
-rw-r--r--packages/0x.js/src/compact_artifacts/TokenRegistry.json (renamed from packages/0x.js/src/artifacts/TokenRegistry.json)0
-rw-r--r--packages/0x.js/src/compact_artifacts/TokenTransferProxy.json (renamed from packages/0x.js/src/artifacts/TokenTransferProxy.json)0
-rw-r--r--packages/0x.js/src/compact_artifacts/ZRX.json (renamed from packages/0x.js/src/artifacts/ZRX.json)0
-rw-r--r--packages/0x.js/test/0x.js_test.ts5
-rw-r--r--packages/contracts/README.md11
-rw-r--r--packages/contracts/package.json6
-rw-r--r--packages/contracts/test/utils/deployer.ts2
-rw-r--r--packages/migrations/README.md69
-rw-r--r--packages/migrations/package.json36
-rw-r--r--packages/migrations/src/globals.d.ts6
-rw-r--r--packages/migrations/src/index.ts3
-rw-r--r--packages/migrations/src/migrate.ts25
-rw-r--r--packages/migrations/src/migration.ts (renamed from packages/0x.js/test/migrations/migrate.ts)4
-rw-r--r--packages/migrations/src/types.ts (renamed from packages/0x.js/test/migrations/types.ts)0
-rw-r--r--packages/migrations/src/utils/constants.ts3
-rw-r--r--packages/migrations/src/utils/token_info.ts (renamed from packages/0x.js/test/migrations/config/token_info.ts)3
-rw-r--r--packages/migrations/tsconfig.json7
-rw-r--r--packages/migrations/tslint.json3
-rw-r--r--packages/subproviders/test/integration/ledger_subprovider_test.ts2
25 files changed, 179 insertions, 31 deletions
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index 0a91343c7..961a97d84 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -15,16 +15,16 @@
"build:watch": "tsc -w",
"prebuild": "run-s clean generate_contract_wrappers",
"build": "run-p build:umd:prod build:commonjs; exit 0;",
- "generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
+ "generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/compact_artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
"test:circleci": "run-s test:coverage",
"test": "run-s clean test:commonjs",
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
- "update_contracts": "for i in ${npm_package_config_artifacts}; do copyfiles -u 4 ../contracts/src/artifacts/$i.json test/artifacts; done;",
+ "update_artifacts": "for i in ${npm_package_config_compact_artifacts}; do copyfiles -u 4 ../migrations/src/artifacts/$i.json test/artifacts; done;",
"clean": "shx rm -rf _bundles lib test_temp scripts",
"build:umd:prod": "NODE_ENV=production webpack",
- "build:commonjs": "tsc && copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
+ "build:commonjs": "tsc && yarn update_artifacts && copyfiles -u 2 './src/compact_artifacts/**/*.json' ./lib/src/compact_artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
"test:commonjs": "run-s build:commonjs run_mocha",
"run_mocha": "mocha lib/test/**/*_test.js --timeout 10000 --bail --exit",
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
@@ -33,7 +33,7 @@
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json"
},
"config": {
- "artifacts": "Exchange DummyToken ZRXToken Token WETH9 TokenTransferProxy MultiSigWallet MultiSigWalletWithTimeLock MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress MaliciousToken TokenRegistry Arbitrage EtherDelta AccountLevels",
+ "compact_artifacts": "Exchange DummyToken ZRXToken Token EtherToken TokenTransferProxy TokenRegistry",
"postpublish": {
"assets": [
"packages/0x.js/_bundles/index.js",
@@ -114,6 +114,9 @@
"uuid": "^3.1.0",
"web3": "^0.20.0"
},
+ "optionalDependencies": {
+ "@0xproject/migrations": "^0.0.1"
+ },
"publishConfig": {
"access": "public"
}
diff --git a/packages/0x.js/src/artifacts.ts b/packages/0x.js/src/artifacts.ts
index cbacd7d56..a91d9ae1f 100644
--- a/packages/0x.js/src/artifacts.ts
+++ b/packages/0x.js/src/artifacts.ts
@@ -1,10 +1,10 @@
-import * as DummyTokenArtifact from './artifacts/DummyToken.json';
-import * as EtherTokenArtifact from './artifacts/EtherToken.json';
-import * as ExchangeArtifact from './artifacts/Exchange.json';
-import * as TokenArtifact from './artifacts/Token.json';
-import * as TokenRegistryArtifact from './artifacts/TokenRegistry.json';
-import * as TokenTransferProxyArtifact from './artifacts/TokenTransferProxy.json';
-import * as ZRXArtifact from './artifacts/ZRX.json';
+import * as DummyTokenArtifact from './compact_artifacts/DummyToken.json';
+import * as EtherTokenArtifact from './compact_artifacts/EtherToken.json';
+import * as ExchangeArtifact from './compact_artifacts/Exchange.json';
+import * as TokenArtifact from './compact_artifacts/Token.json';
+import * as TokenRegistryArtifact from './compact_artifacts/TokenRegistry.json';
+import * as TokenTransferProxyArtifact from './compact_artifacts/TokenTransferProxy.json';
+import * as ZRXArtifact from './compact_artifacts/ZRX.json';
import { Artifact } from './types';
export const artifacts = {
diff --git a/packages/0x.js/src/artifacts/DummyToken.json b/packages/0x.js/src/compact_artifacts/DummyToken.json
index f64a8cd3d..f64a8cd3d 100644
--- a/packages/0x.js/src/artifacts/DummyToken.json
+++ b/packages/0x.js/src/compact_artifacts/DummyToken.json
diff --git a/packages/0x.js/src/artifacts/EtherToken.json b/packages/0x.js/src/compact_artifacts/EtherToken.json
index 26cca57cd..26cca57cd 100644
--- a/packages/0x.js/src/artifacts/EtherToken.json
+++ b/packages/0x.js/src/compact_artifacts/EtherToken.json
diff --git a/packages/0x.js/src/artifacts/Exchange.json b/packages/0x.js/src/compact_artifacts/Exchange.json
index af8db7360..af8db7360 100644
--- a/packages/0x.js/src/artifacts/Exchange.json
+++ b/packages/0x.js/src/compact_artifacts/Exchange.json
diff --git a/packages/0x.js/src/artifacts/Token.json b/packages/0x.js/src/compact_artifacts/Token.json
index 3b5a86ae0..3b5a86ae0 100644
--- a/packages/0x.js/src/artifacts/Token.json
+++ b/packages/0x.js/src/compact_artifacts/Token.json
diff --git a/packages/0x.js/src/artifacts/TokenRegistry.json b/packages/0x.js/src/compact_artifacts/TokenRegistry.json
index 0f583628c..0f583628c 100644
--- a/packages/0x.js/src/artifacts/TokenRegistry.json
+++ b/packages/0x.js/src/compact_artifacts/TokenRegistry.json
diff --git a/packages/0x.js/src/artifacts/TokenTransferProxy.json b/packages/0x.js/src/compact_artifacts/TokenTransferProxy.json
index 8cf551ddb..8cf551ddb 100644
--- a/packages/0x.js/src/artifacts/TokenTransferProxy.json
+++ b/packages/0x.js/src/compact_artifacts/TokenTransferProxy.json
diff --git a/packages/0x.js/src/artifacts/ZRX.json b/packages/0x.js/src/compact_artifacts/ZRX.json
index e40b8f268..e40b8f268 100644
--- a/packages/0x.js/src/artifacts/ZRX.json
+++ b/packages/0x.js/src/compact_artifacts/ZRX.json
diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts
index e6163d568..5720f42ce 100644
--- a/packages/0x.js/test/0x.js_test.ts
+++ b/packages/0x.js/test/0x.js_test.ts
@@ -1,5 +1,9 @@
import { Deployer } from '@0xproject/deployer';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
+// HACK: This dependency is optional since it is only available when run from within
+// the monorepo. tslint doesn't handle optional dependencies
+// tslint:disable-next-line:no-implicit-dependencies
+import { runMigrationsAsync } from '@0xproject/migrations';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
@@ -9,7 +13,6 @@ import * as Sinon from 'sinon';
import { ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, ZeroEx } from '../src';
-import { runMigrationsAsync } from './migrations/migrate';
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { deployer } from './utils/deployer';
diff --git a/packages/contracts/README.md b/packages/contracts/README.md
index 286ef019c..16e253549 100644
--- a/packages/contracts/README.md
+++ b/packages/contracts/README.md
@@ -72,17 +72,6 @@ yarn lint
### Run Tests
-Before running the tests, you will need to spin up a [TestRPC](https://www.npmjs.com/package/ethereumjs-testrpc) instance.
-
-In a separate terminal, start TestRPC (a convenience command is provided as part of the [0x.js monorepo](https://github.com/0xProject/0x-monorepo))
-
-```bash
-cd ../..
-yarn testrpc
-```
-
-Then in your main terminal run
-
```bash
yarn test
```
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index 1d393c60b..04073f4b7 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -10,13 +10,13 @@
"scripts": {
"build:watch": "tsc -w",
"prebuild": "run-s clean compile copy_artifacts generate_contract_wrappers",
- "copy_artifacts": "copyfiles './src/artifacts/**/*' ./lib",
+ "copy_artifacts": "copyfiles -u 4 '../migrations/src/artifacts/**/*' ./lib/src/artifacts;",
"build": "tsc",
"test": "run-s build run_mocha",
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
"run_mocha": "mocha 'lib/test/**/*.js' --timeout 100000 --bail --exit",
"compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846",
- "compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contracts-dir src/contracts --artifacts-dir src/artifacts",
+ "compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contracts-dir src/contracts --artifacts-dir ../migrations/src/artifacts",
"clean": "shx rm -rf ./lib",
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
"lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'",
@@ -26,7 +26,7 @@
"test:circleci": "yarn test:coverage"
},
"config": {
- "abis": "src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken|Arbitrage|EtherDelta|AccountLevels).json",
+ "abis": "../migrations/src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken|Arbitrage|EtherDelta|AccountLevels).json",
"contracts": "Exchange,DummyToken,ZRXToken,Token,WETH9,TokenTransferProxy,MultiSigWallet,MultiSigWalletWithTimeLock,MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,MaliciousToken,TokenRegistry,Arbitrage,EtherDelta,AccountLevels"
},
"repository": {
diff --git a/packages/contracts/test/utils/deployer.ts b/packages/contracts/test/utils/deployer.ts
index 45f79a2a4..2f0951475 100644
--- a/packages/contracts/test/utils/deployer.ts
+++ b/packages/contracts/test/utils/deployer.ts
@@ -8,7 +8,7 @@ import { web3 } from './web3_wrapper';
const deployerOpts = {
provider: web3.currentProvider,
- artifactsDir: path.resolve('src', 'artifacts'),
+ artifactsDir: path.resolve('lib', 'src', 'artifacts'),
networkId: constants.TESTRPC_NETWORK_ID,
defaults: {
gas: devConstants.GAS_ESTIMATE,
diff --git a/packages/migrations/README.md b/packages/migrations/README.md
new file mode 100644
index 000000000..15129ae85
--- /dev/null
+++ b/packages/migrations/README.md
@@ -0,0 +1,69 @@
+## Migrations
+
+Migrate the 0x system of smart contracts on the network of your choice using these migrations.
+
+## Contributing
+
+We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
+
+Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
+
+### Install dependencies
+
+If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
+
+```bash
+yarn config set workspaces-experimental true
+```
+
+Then install dependencies
+
+```bash
+yarn install
+```
+
+### Build
+
+If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
+
+```bash
+yarn lerna:rebuild
+```
+
+Or continuously rebuild on change:
+
+```bash
+yarn dev
+```
+
+You can also build this specific package by running the following from within its directory:
+
+```bash
+yarn build
+```
+
+or continuously rebuild on change:
+
+```bash
+yarn build:watch
+```
+
+### Clean
+
+```bash
+yarn clean
+```
+
+### Lint
+
+```bash
+yarn lint
+```
+
+### Migrate
+
+In order to migrate the 0x smart contracts to TestRPC/Ganache running at `http://localhost:8545`, run:
+
+```bash
+yarn migrate
+```
diff --git a/packages/migrations/package.json b/packages/migrations/package.json
new file mode 100644
index 000000000..65946aa71
--- /dev/null
+++ b/packages/migrations/package.json
@@ -0,0 +1,36 @@
+{
+ "private": true,
+ "name": "@0xproject/migrations",
+ "version": "0.0.1",
+ "description": "0x smart contract migrations",
+ "main": "lib/index.js",
+ "types": "lib/index.d.ts",
+ "scripts": {
+ "build:watch": "tsc -w",
+ "build": "tsc",
+ "clean": "shx rm -rf lib",
+ "lint": "tslint --project . 'src/**/*.ts'",
+ "migrate": "run-s build compile script:migrate",
+ "script:migrate": "node ./lib/migrate.js",
+ "copy_artifacts": "copyfiles 'src/artifacts/**/*' ./lib",
+ "compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contracts-dir ../contracts/src/contracts --artifacts-dir src/artifacts"
+ },
+ "config": {
+ "contracts": "Exchange,DummyToken,ZRXToken,Token,WETH9,TokenTransferProxy,MultiSigWallet,MultiSigWalletWithTimeLock,MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,MaliciousToken,TokenRegistry,Arbitrage,EtherDelta,AccountLevels"
+ },
+ "license": "Apache-2.0",
+ "devDependencies": {
+ "@0xproject/tslint-config": "^0.4.14",
+ "@0xproject/dev-utils": "^0.3.4",
+ "npm-run-all": "^4.1.2",
+ "shx": "^0.2.2",
+ "tslint": "5.8.0",
+ "typescript": "2.7.1"
+ },
+ "dependencies": {
+ "@0xproject/deployer": "^0.3.5",
+ "@0xproject/utils": "^0.5.0",
+ "@0xproject/web3-wrapper": "^0.5.0",
+ "lodash": "^4.17.4"
+ }
+}
diff --git a/packages/migrations/src/globals.d.ts b/packages/migrations/src/globals.d.ts
new file mode 100644
index 000000000..94e63a32d
--- /dev/null
+++ b/packages/migrations/src/globals.d.ts
@@ -0,0 +1,6 @@
+declare module '*.json' {
+ const json: any;
+ /* tslint:disable */
+ export default json;
+ /* tslint:enable */
+}
diff --git a/packages/migrations/src/index.ts b/packages/migrations/src/index.ts
new file mode 100644
index 000000000..2a40f36bc
--- /dev/null
+++ b/packages/migrations/src/index.ts
@@ -0,0 +1,3 @@
+import { runMigrationsAsync } from './migration';
+
+export { runMigrationsAsync };
diff --git a/packages/migrations/src/migrate.ts b/packages/migrations/src/migrate.ts
new file mode 100644
index 000000000..76dcbd847
--- /dev/null
+++ b/packages/migrations/src/migrate.ts
@@ -0,0 +1,25 @@
+#!/usr/bin/env node
+import { Deployer } from '@0xproject/deployer';
+import { devConstants } from '@0xproject/dev-utils';
+import { logUtils } from '@0xproject/utils';
+import * as path from 'path';
+
+import { runMigrationsAsync } from './migration';
+
+(async () => {
+ const deployerOpts = {
+ jsonrpcUrl: 'http://localhost:8545',
+ artifactsDir: path.resolve('src', 'artifacts'),
+ networkId: 50,
+ defaults: {
+ gas: devConstants.GAS_ESTIMATE,
+ },
+ };
+
+ const deployer = new Deployer(deployerOpts);
+
+ await runMigrationsAsync(deployer);
+})().catch(err => {
+ logUtils.log(err);
+ process.exit(1);
+});
diff --git a/packages/0x.js/test/migrations/migrate.ts b/packages/migrations/src/migration.ts
index 85fb2a34f..be899cc65 100644
--- a/packages/0x.js/test/migrations/migrate.ts
+++ b/packages/migrations/src/migration.ts
@@ -3,10 +3,10 @@ import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
-import { constants } from '../utils/constants';
+import { constants } from './utils/constants';
-import { tokenInfo } from './config/token_info';
import { ContractName } from './types';
+import { tokenInfo } from './utils/token_info';
/**
* Custom migrations should be defined in this function. This will be called with the CLI 'migrate' command.
diff --git a/packages/0x.js/test/migrations/types.ts b/packages/migrations/src/types.ts
index 1887bfd96..1887bfd96 100644
--- a/packages/0x.js/test/migrations/types.ts
+++ b/packages/migrations/src/types.ts
diff --git a/packages/migrations/src/utils/constants.ts b/packages/migrations/src/utils/constants.ts
new file mode 100644
index 000000000..8871a470d
--- /dev/null
+++ b/packages/migrations/src/utils/constants.ts
@@ -0,0 +1,3 @@
+export const constants = {
+ NULL_BYTES: '0x',
+};
diff --git a/packages/0x.js/test/migrations/config/token_info.ts b/packages/migrations/src/utils/token_info.ts
index 0d0e90917..f2ca3e8b3 100644
--- a/packages/0x.js/test/migrations/config/token_info.ts
+++ b/packages/migrations/src/utils/token_info.ts
@@ -1,6 +1,7 @@
-import { constants } from '../../utils/constants';
import { Token } from '../types';
+import { constants } from './constants';
+
export const tokenInfo: Token[] = [
{
name: 'Augur Reputation Token',
diff --git a/packages/migrations/tsconfig.json b/packages/migrations/tsconfig.json
new file mode 100644
index 000000000..f5f4b37c2
--- /dev/null
+++ b/packages/migrations/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig",
+ "compilerOptions": {
+ "outDir": "lib"
+ },
+ "include": ["src/**/*"]
+}
diff --git a/packages/migrations/tslint.json b/packages/migrations/tslint.json
new file mode 100644
index 000000000..ffaefe83a
--- /dev/null
+++ b/packages/migrations/tslint.json
@@ -0,0 +1,3 @@
+{
+ "extends": ["@0xproject/tslint-config"]
+}
diff --git a/packages/subproviders/test/integration/ledger_subprovider_test.ts b/packages/subproviders/test/integration/ledger_subprovider_test.ts
index 503618089..9e81dfac5 100644
--- a/packages/subproviders/test/integration/ledger_subprovider_test.ts
+++ b/packages/subproviders/test/integration/ledger_subprovider_test.ts
@@ -1,7 +1,7 @@
import { JSONRPCResponsePayload } from '@0xproject/types';
import { promisify } from '@0xproject/utils';
import Eth from '@ledgerhq/hw-app-eth';
-// HACK: This depdency is optional and tslint skips optional depdencies
+// HACK: This dependency is optional and tslint skips optional dependencies
// tslint:disable-next-line:no-implicit-dependencies
import TransportNodeHid from '@ledgerhq/hw-transport-node-hid';
import * as chai from 'chai';