diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-10-03 07:13:16 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-10-03 07:13:16 +0800 |
commit | 343b922ec11a6108caaf3095e59be0e56d45ee4a (patch) | |
tree | ad38a124853c4cd153f5a290a0dc461447f8c799 | |
parent | 6deb027bdf4e57f8918fd2413f0fdc55311508d3 (diff) | |
parent | f1ecb8c5cb28a0a7ca6f7ad2ff11194091df62a4 (diff) | |
download | dexon-sol-tools-343b922ec11a6108caaf3095e59be0e56d45ee4a.tar dexon-sol-tools-343b922ec11a6108caaf3095e59be0e56d45ee4a.tar.gz dexon-sol-tools-343b922ec11a6108caaf3095e59be0e56d45ee4a.tar.bz2 dexon-sol-tools-343b922ec11a6108caaf3095e59be0e56d45ee4a.tar.lz dexon-sol-tools-343b922ec11a6108caaf3095e59be0e56d45ee4a.tar.xz dexon-sol-tools-343b922ec11a6108caaf3095e59be0e56d45ee4a.tar.zst dexon-sol-tools-343b922ec11a6108caaf3095e59be0e56d45ee4a.zip |
Merge branch 'development' into feature/asset-buyer/improve-asset-buyer-manager
* development: (178 commits)
Change cache key back to repo from repo-built
Change the lint command back
Merge build & install
Remove deps cache all together
Cache all nested node_modules directories
Explicitly specify yarn cache folder
Ignore linter issues
Fix linter issue
Separate deps and built caches
Build tslint rules before running linter
Cache yarn cache directory without node modules
Run linter before prettier as it fails more often
Add yarn cache path
Split CI install and build steps
Move bundle-size out of static tests and don't wait for a build with static tests
Introduce a build:ci command that doesn't build webpack bundles
Measure only one bundle size as they're the same
Fix linter errors
Fix no_website CI builds
Check bundle size on CI
...
197 files changed, 3860 insertions, 1205 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml index 537b19348..f288a46e6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,29 +11,17 @@ jobs: steps: - checkout - run: echo 'export PATH=$HOME/CIRCLE_PROJECT_REPONAME/node_modules/.bin:$PATH' >> $BASH_ENV - - restore_cache: - name: Restore Yarn Package Cache - keys: - - yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }} - - yarn-packages-{{ .Branch }} - - yarn-packages-master - - yarn-packages- - run: name: install-yarn command: sudo npm install --global yarn@1.9.4 - run: name: yarn command: yarn --frozen-lockfile install || yarn --frozen-lockfile install - - save_cache: - name: Save Yarn Package Cache - key: yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }} - paths: - - node_modules/ - run: > if [ -z "$(git diff --name-only development packages/website)" ]; then - yarn build --exclude website + yarn build:ci:no_website else - yarn build + yarn build:ci fi - save_cache: key: repo-{{ .Environment.CIRCLE_SHA1 }} @@ -100,6 +88,7 @@ jobs: - run: yarn wsrun test:circleci @0xproject/order-watcher - run: yarn wsrun test:circleci @0xproject/sol-compiler - run: yarn wsrun test:circleci @0xproject/sol-cov + - run: yarn wsrun test:circleci @0xproject/sol-doc - run: yarn wsrun test:circleci @0xproject/sra-report - run: yarn wsrun test:circleci @0xproject/subproviders - run: yarn wsrun test:circleci @0xproject/web3-wrapper @@ -153,6 +142,10 @@ jobs: paths: - ~/repo/packages/sol-cov/coverage/lcov.info - save_cache: + key: coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }} + paths: + - ~/repo/packages/sol-doc/coverage/lcov.info + - save_cache: key: coverage-sra-report-{{ .Environment.CIRCLE_SHA1 }} paths: - ~/repo/packages/sra-report/coverage/lcov.info @@ -172,8 +165,10 @@ jobs: - restore_cache: keys: - repo-{{ .Environment.CIRCLE_SHA1 }} - - run: yarn prettier:ci - run: yarn lerna run lint + - run: yarn prettier:ci + - run: cd packages/0x.js && yarn build:umd:prod + - run: yarn bundlesize submit-coverage: docker: - image: circleci/node:9 @@ -220,6 +215,9 @@ jobs: - coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: keys: + - coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }} + - restore_cache: + keys: - coverage-sra-report-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: keys: diff --git a/package.json b/package.json index 04ca89fd1..5b2a7b200 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,9 @@ "wsrun": "wsrun", "lerna": "lerna", "build": "wsrun build $PKG --fast-exit -r --stages", + "build:ci": "wsrun build:ci $PKG --fast-exit -r --stages", "build:no_website": "wsrun build $PKG --fast-exit -r --stages --exclude @0xproject/website", + "build:ci:no_website": "wsrun build:ci $PKG --fast-exit -r --stages --exclude @0xproject/website", "build:monorepo_scripts": "PKG=@0xproject/monorepo-scripts yarn build", "build:ts": "tsc -b", "watch:ts": "tsc -b -w", @@ -35,16 +37,22 @@ "test": "wsrun test $PKG --fast-exit --serial --exclude-missing", "generate_doc": "node ./packages/monorepo-scripts/lib/doc_generate_and_upload.js", "test:generate_docs:circleci": "for i in ${npm_package_config_packagesWithDocPages}; do yarn generate_doc --package $i --shouldUpload false --isStaging true || break -1; done;", - "lint": "wsrun lint $PKG --fast-exit --parallel --exclude-missing", - "comment:postinstall": "HACK: For some reason `yarn` is not setting up symlinks properly for order-utils. We temporarily set them manually. Remove this after V2 refactor is complete." + "bundlesize": "bundlesize", + "lint": "wsrun lint $PKG --fast-exit --parallel --exclude-missing" }, "config": { "mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic", "packagesWithDocPages": "0x.js connect json-schemas subproviders web3-wrapper contract-wrappers order-utils order-watcher sol-compiler sol-cov ethereum-types" }, + "bundlesize": [ + { + "path": "packages/0x.js/_bundles/index.min.js" + } + ], "devDependencies": { "@0x-lerna-fork/lerna": "3.0.0-beta.25", "async-child-process": "^1.1.1", + "bundlesize": "^0.17.0", "coveralls": "^3.0.0", "ganache-cli": "6.1.3", "lcov-result-merger": "^3.0.0", @@ -54,8 +62,5 @@ "source-map-support": "^0.5.6", "typescript": "3.0.1", "wsrun": "^2.2.0" - }, - "resolutions": { - "ethers": "0xproject/ethers.js#eip-838-reasons" } } diff --git a/packages/0x.js/.npmignore b/packages/0x.js/.npmignore index 6a3eb57bd..d7ee80c97 100644 --- a/packages/0x.js/.npmignore +++ b/packages/0x.js/.npmignore @@ -4,7 +4,6 @@ webpack.config.js yarn-error.log test/ /src/ -/_bundles/ /contract_templates/ /generated_docs/ /scripts/ diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json index 38966a0b7..81a128c4c 100644 --- a/packages/0x.js/CHANGELOG.json +++ b/packages/0x.js/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "1.0.8", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.0.7", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.0.6", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.0.5", "changes": [ diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md index d881cd825..eb5813c59 100644 --- a/packages/0x.js/CHANGELOG.md +++ b/packages/0x.js/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.8 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.7 - _September 28, 2018_ + + * Dependencies updated + +## v1.0.6 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.5 - _September 25, 2018_ * Dependencies updated diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index d53571dbf..c89a3e613 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -1,6 +1,6 @@ { "name": "0x.js", - "version": "1.0.5", + "version": "1.0.7", "engines": { "node": ">=6.12" }, @@ -16,6 +16,7 @@ "types": "lib/index.d.ts", "scripts": { "build": "yarn build:all", + "build:ci": "yarn build:commonjs", "build:all": "run-p build:umd:prod build:commonjs", "lint": "tslint --project . --exclude **/src/generated_contract_wrappers/**/*", "test:circleci": "run-s test:coverage", @@ -41,10 +42,10 @@ }, "license": "Apache-2.0", "devDependencies": { - "@0xproject/abi-gen": "^1.0.10", - "@0xproject/dev-utils": "^1.0.9", - "@0xproject/migrations": "^1.0.11", - "@0xproject/monorepo-scripts": "^1.0.9", + "@0xproject/abi-gen": "^1.0.12", + "@0xproject/dev-utils": "^1.0.11", + "@0xproject/migrations": "^1.0.13", + "@0xproject/monorepo-scripts": "^1.0.10", "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", @@ -73,18 +74,18 @@ "webpack": "^3.1.0" }, "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/base-contract": "^2.0.4", - "@0xproject/contract-wrappers": "^1.0.5", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/order-watcher": "^1.0.5", - "@0xproject/subproviders": "^2.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", - "ethereum-types": "^1.0.7", - "ethers": "3.0.22", + "@0xproject/assert": "^1.0.12", + "@0xproject/base-contract": "^3.0.0", + "@0xproject/contract-wrappers": "^2.0.1", + "@0xproject/order-utils": "^1.0.6", + "@0xproject/order-watcher": "^2.1.0", + "@0xproject/subproviders": "^2.0.6", + "@0xproject/types": "^1.1.2", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", + "ethereum-types": "^1.0.9", + "ethers": "4.0.0-beta.14", "lodash": "^4.17.5", "web3-provider-engine": "14.0.6" }, diff --git a/packages/abi-gen/CHANGELOG.json b/packages/abi-gen/CHANGELOG.json index 18aed8716..ab2423e88 100644 --- a/packages/abi-gen/CHANGELOG.json +++ b/packages/abi-gen/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "1.0.13", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.0.12", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.0.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.0.10", "changes": [ diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md index 99fc44f0c..5f72e257d 100644 --- a/packages/abi-gen/CHANGELOG.md +++ b/packages/abi-gen/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.13 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.12 - _September 28, 2018_ + + * Dependencies updated + +## v1.0.11 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.10 - _September 25, 2018_ * Dependencies updated diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json index 1fb697299..fd239ca21 100644 --- a/packages/abi-gen/package.json +++ b/packages/abi-gen/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/abi-gen", - "version": "1.0.10", + "version": "1.0.12", "engines": { "node": ">=6.12" }, @@ -11,6 +11,7 @@ "lint": "tslint --project .", "clean": "shx rm -rf lib", "build": "tsc -b", + "build:ci": "yarn build", "test": "yarn run_mocha", "run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --bail --exit", "test:circleci": "yarn test:coverage", @@ -30,10 +31,10 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md", "dependencies": { - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", "chalk": "^2.3.0", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.9", "glob": "^7.1.2", "handlebars": "^4.0.11", "lodash": "^4.17.5", diff --git a/packages/assert/CHANGELOG.json b/packages/assert/CHANGELOG.json index 851ba6c04..0efcc3ac3 100644 --- a/packages/assert/CHANGELOG.json +++ b/packages/assert/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "1.0.13", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.0.12", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.0.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.0.10", "changes": [ diff --git a/packages/assert/CHANGELOG.md b/packages/assert/CHANGELOG.md index 26760306e..910904730 100644 --- a/packages/assert/CHANGELOG.md +++ b/packages/assert/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.13 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.12 - _September 28, 2018_ + + * Dependencies updated + +## v1.0.11 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.10 - _September 25, 2018_ * Dependencies updated diff --git a/packages/assert/package.json b/packages/assert/package.json index ee510d14f..b536d31f4 100644 --- a/packages/assert/package.json +++ b/packages/assert/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/assert", - "version": "1.0.10", + "version": "1.0.12", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build": "tsc -b", + "build:ci": "yarn build", "clean": "shx rm -rf lib test_temp", "lint": "tslint --project .", "run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit", @@ -44,9 +45,9 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", + "@0xproject/json-schemas": "^1.0.5", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", "lodash": "^4.17.5", "valid-url": "^1.0.9" }, diff --git a/packages/asset-buyer/CHANGELOG.json b/packages/asset-buyer/CHANGELOG.json index ff11aa126..8c2c7a8d2 100644 --- a/packages/asset-buyer/CHANGELOG.json +++ b/packages/asset-buyer/CHANGELOG.json @@ -3,12 +3,39 @@ "version": "2.0.0", "changes": [ { - "note": "Rename StandardRelayerAPIAssetBuyerManager to AssetBuyerManager and other API improvements.", + "note": "Expand AssetBuyer to work with multiple assets at once", "pr": 1086 } ] }, { + "timestamp": 1538475601, + "version": "1.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.0.0", "changes": [ diff --git a/packages/asset-buyer/CHANGELOG.md b/packages/asset-buyer/CHANGELOG.md index b27795d18..6f125fa1a 100644 --- a/packages/asset-buyer/CHANGELOG.md +++ b/packages/asset-buyer/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.3 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.2 - _September 28, 2018_ + + * Dependencies updated + +## v1.0.1 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.0 - _September 25, 2018_ * Dependencies updated diff --git a/packages/asset-buyer/package.json b/packages/asset-buyer/package.json index 20f095f61..dacfbf730 100644 --- a/packages/asset-buyer/package.json +++ b/packages/asset-buyer/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/asset-buyer", - "version": "1.0.0", + "version": "1.0.2", "engines": { "node": ">=6.12" }, @@ -18,6 +18,7 @@ "run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit", "clean": "shx rm -rf lib test_temp scripts", "build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", + "build:ci": "yarn build", "manual:postpublish": "yarn build; node ./scripts/postpublish.js" }, "config": { @@ -36,17 +37,17 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/asset-buyer/README.md", "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/connect": "^2.0.3", - "@0xproject/contract-wrappers": "^1.0.5", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/subproviders": "^2.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", - "ethereum-types": "^1.0.6", + "@0xproject/assert": "^1.0.12", + "@0xproject/connect": "^3.0.0", + "@0xproject/contract-wrappers": "^2.0.1", + "@0xproject/json-schemas": "^1.0.5", + "@0xproject/order-utils": "^1.0.6", + "@0xproject/subproviders": "^2.0.6", + "@0xproject/types": "^1.1.2", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", + "ethereum-types": "^1.0.9", "lodash": "^4.17.10" }, "devDependencies": { diff --git a/packages/base-contract/CHANGELOG.json b/packages/base-contract/CHANGELOG.json index 5f94afa43..92680729f 100644 --- a/packages/base-contract/CHANGELOG.json +++ b/packages/base-contract/CHANGELOG.json @@ -1,5 +1,37 @@ [ { + "timestamp": 1538475601, + "version": "3.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "version": "3.0.0", + "changes": [ + { + "note": "Change the way we detect BN to work with the newest ethers.js", + "pr": 1069 + }, + { + "note": "Add baseContract._throwIfRevertWithReasonCallResult", + "pr": 1069 + } + ], + "timestamp": 1538157789 + }, + { + "timestamp": 1537907159, + "version": "2.0.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "2.0.4", "changes": [ diff --git a/packages/base-contract/CHANGELOG.md b/packages/base-contract/CHANGELOG.md index b3f3b5619..90d7f3bc2 100644 --- a/packages/base-contract/CHANGELOG.md +++ b/packages/base-contract/CHANGELOG.md @@ -5,6 +5,19 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.1 - _October 2, 2018_ + + * Dependencies updated + +## v3.0.0 - _September 28, 2018_ + + * Change the way we detect BN to work with the newest ethers.js (#1069) + * Add baseContract._throwIfRevertWithReasonCallResult (#1069) + +## v2.0.5 - _September 25, 2018_ + + * Dependencies updated + ## v2.0.4 - _September 25, 2018_ * Dependencies updated diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json index cd7f29114..e95a753e6 100644 --- a/packages/base-contract/package.json +++ b/packages/base-contract/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/base-contract", - "version": "2.0.4", + "version": "3.0.0", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build": "tsc -b", + "build:ci": "yarn build", "clean": "shx rm -rf lib", "test": "yarn run_mocha", "rebuild_and_test": "run-s clean build test", @@ -40,11 +41,11 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", - "ethereum-types": "^1.0.7", - "ethers": "3.0.22", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", + "ethereum-types": "^1.0.9", + "ethers": "4.0.0-beta.14", "lodash": "^4.17.5" }, "publishConfig": { diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts index 12f974445..981e6fca6 100644 --- a/packages/base-contract/src/index.ts +++ b/packages/base-contract/src/index.ts @@ -20,6 +20,11 @@ export interface EthersInterfaceByFunctionSignature { [key: string]: ethers.Interface; } +const REVERT_ERROR_SELECTOR = '08c379a0'; +const REVERT_ERROR_SELECTOR_OFFSET = 2; +const REVERT_ERROR_SELECTOR_BYTES_LENGTH = 4; +const REVERT_ERROR_SELECTOR_END = REVERT_ERROR_SELECTOR_OFFSET + REVERT_ERROR_SELECTOR_BYTES_LENGTH * 2; + export class BaseContract { protected _ethersInterfacesByFunctionSignature: EthersInterfaceByFunctionSignature; protected _web3Wrapper: Web3Wrapper; @@ -61,7 +66,7 @@ export class BaseContract { } } protected static _bnToBigNumber(_type: string, value: any): any { - return _.isObject(value) && value._bn ? new BigNumber(value.toString()) : value; + return _.isObject(value) && value._hex ? new BigNumber(value.toString()) : value; } protected static async _applyDefaultsToTxDataAsync<T extends Partial<TxData | TxDataPayable>>( txData: T, @@ -82,15 +87,24 @@ export class BaseContract { } return txDataWithDefaults; } + protected static _throwIfRevertWithReasonCallResult(rawCallResult: string): void { + if (rawCallResult.slice(REVERT_ERROR_SELECTOR_OFFSET, REVERT_ERROR_SELECTOR_END) === REVERT_ERROR_SELECTOR) { + const revertReason = ethers.utils.defaultAbiCoder.decode( + ['string'], + ethers.utils.hexDataSlice(rawCallResult, REVERT_ERROR_SELECTOR_BYTES_LENGTH), + ); + throw new Error(revertReason); + } + } // Throws if the given arguments cannot be safely/correctly encoded based on // the given inputAbi. An argument may not be considered safely encodeable // if it overflows the corresponding Solidity type, there is a bug in the // encoder, or the encoder performs unsafe type coercion. public static strictArgumentEncodingCheck(inputAbi: DataItem[], args: any[]): void { - const coder = ethers.utils.AbiCoder.defaultCoder; + const coder = new ethers.AbiCoder(); const params = abiUtils.parseEthersParams(inputAbi); - const rawEncoded = coder.encode(params.names, params.types, args); - const rawDecoded = coder.decode(params.names, params.types, rawEncoded); + const rawEncoded = coder.encode(inputAbi, args); + const rawDecoded = coder.decode(inputAbi, rawEncoded); for (let i = 0; i < rawDecoded.length; i++) { const original = args[i]; const decoded = rawDecoded[i]; diff --git a/packages/connect/CHANGELOG.json b/packages/connect/CHANGELOG.json index d4c501eb1..2b42f1654 100644 --- a/packages/connect/CHANGELOG.json +++ b/packages/connect/CHANGELOG.json @@ -1,5 +1,33 @@ [ { + "timestamp": 1538475601, + "version": "3.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "version": "3.0.0", + "changes": [ + { + "note": "Change /order_config request to a POST instead of GET", + "pr": 1091 + } + ], + "timestamp": 1538157789 + }, + { + "timestamp": 1537907159, + "version": "2.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "2.0.3", "changes": [ { diff --git a/packages/connect/CHANGELOG.md b/packages/connect/CHANGELOG.md index 2c2483cb6..564a91685 100644 --- a/packages/connect/CHANGELOG.md +++ b/packages/connect/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.1 - _October 2, 2018_ + + * Dependencies updated + +## v3.0.0 - _September 28, 2018_ + + * Change /order_config request to a POST instead of GET (#1091) + +## v2.0.4 - _September 25, 2018_ + + * Dependencies updated + ## v2.0.3 - _September 25, 2018_ * Import SRA-related types from @0xproject/types (#1085) diff --git a/packages/connect/package.json b/packages/connect/package.json index 075089fd2..c8f53d526 100644 --- a/packages/connect/package.json +++ b/packages/connect/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/connect", - "version": "2.0.3", + "version": "3.0.0", "engines": { "node": ">=6.12" }, @@ -16,6 +16,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build": "tsc -b", + "build:ci": "yarn build", "clean": "shx rm -rf lib test_temp generated_docs", "copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures", "lint": "tslint --project .", @@ -43,12 +44,12 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md", "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", + "@0xproject/assert": "^1.0.12", + "@0xproject/json-schemas": "^1.0.5", + "@0xproject/order-utils": "^1.0.6", + "@0xproject/types": "^1.1.2", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", "lodash": "^4.17.5", "query-string": "^5.0.1", "sinon": "^4.0.0", diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts index 8a68d6c23..bbd0d2042 100644 --- a/packages/connect/src/http_client.ts +++ b/packages/connect/src/http_client.ts @@ -149,7 +149,7 @@ export class HttpClient implements Client { params: requestOpts, payload: request, }; - const responseJson = await this._requestAsync('/order_config', HttpRequestType.Get, httpRequestOpts); + const responseJson = await this._requestAsync('/order_config', HttpRequestType.Post, httpRequestOpts); const fees = relayerResponseJsonParsers.parseOrderConfigResponseJson(responseJson); return fees; } diff --git a/packages/connect/test/http_client_test.ts b/packages/connect/test/http_client_test.ts index 83b77021a..e9fc9372e 100644 --- a/packages/connect/test/http_client_test.ts +++ b/packages/connect/test/http_client_test.ts @@ -148,12 +148,12 @@ describe('HttpClient', () => { }; const url = `${relayUrl}/order_config`; it('gets order config', async () => { - fetchMock.get(url, orderConfigResponseJSON); + fetchMock.post(url, orderConfigResponseJSON); const fees = await relayerClient.getOrderConfigAsync(request); expect(fees).to.be.deep.equal(orderConfigResponse); }); it('does not mutate input', async () => { - fetchMock.get(url, orderConfigResponseJSON); + fetchMock.post(url, orderConfigResponseJSON); const makerAssetAmountBefore = request.makerAssetAmount; const takerAssetAmountBefore = request.takerAssetAmount; const expirationTimeSecondsBefore = request.expirationTimeSeconds; @@ -163,7 +163,7 @@ describe('HttpClient', () => { expect(expirationTimeSecondsBefore).to.be.deep.equal(request.expirationTimeSeconds); }); it('throws an error for invalid JSON response', async () => { - fetchMock.get(url, { test: 'dummy' }); + fetchMock.post(url, { test: 'dummy' }); expect(relayerClient.getOrderConfigAsync(request)).to.be.rejected(); }); }); diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index 65aaf15c7..ffb15c43a 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -1,7 +1,7 @@ [ { - "timestamp": 1537875740, - "version": "1.0.5", + "timestamp": 1538475601, + "version": "2.0.2", "changes": [ { "note": "Dependencies updated" @@ -9,8 +9,8 @@ ] }, { - "timestamp": 1537541580, - "version": "1.0.4", + "timestamp": 1538157789, + "version": "2.0.1", "changes": [ { "note": "Dependencies updated" @@ -18,6 +18,40 @@ ] }, { + "version": "2.0.0", + "changes": [ + { + "note": + "Fixes dropped events in subscriptions by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too.", + "pr": 1080 + }, + { + "note": + "Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it", + "pr": 1080 + } + ], + "timestamp": 1537907159 + }, + { + "version": "1.0.5", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1537875740 + }, + { + "version": "1.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1537541580 + }, + { "version": "1.0.3", "changes": [ { diff --git a/packages/contract-wrappers/CHANGELOG.md b/packages/contract-wrappers/CHANGELOG.md index 98de9c7f2..217347d1f 100644 --- a/packages/contract-wrappers/CHANGELOG.md +++ b/packages/contract-wrappers/CHANGELOG.md @@ -5,6 +5,19 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.2 - _October 2, 2018_ + + * Dependencies updated + +## v2.0.1 - _September 28, 2018_ + + * Dependencies updated + +## v2.0.0 - _September 25, 2018_ + + * Fixes dropped events in subscriptions by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too. (#1080) + * Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it (#1080) + ## v1.0.5 - _September 25, 2018_ * Dependencies updated diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index 544d667c6..22dd6521c 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/contract-wrappers", - "version": "1.0.5", + "version": "2.0.1", "description": "Smart TS wrappers for 0x smart contracts", "keywords": [ "0xproject", @@ -12,6 +12,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build": "yarn pre_build && tsc -b", + "build:ci": "yarn build", "pre_build": "run-s update_artifacts generate_contract_wrappers copy_artifacts", "generate_contract_wrappers": "abi-gen --abis 'src/artifacts/@(Exchange|DummyERC20Token|DummyERC721Token|ZRXToken|ERC20Token|ERC721Token|WETH9|ERC20Proxy|ERC721Proxy|Forwarder|OrderValidator).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers", "lint": "tslint --project . --exclude **/src/contract_wrappers/**/* --exclude **/lib/**/*", @@ -41,10 +42,10 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0xproject/abi-gen": "^1.0.10", - "@0xproject/dev-utils": "^1.0.9", - "@0xproject/migrations": "^1.0.11", - "@0xproject/subproviders": "^2.0.4", + "@0xproject/abi-gen": "^1.0.12", + "@0xproject/dev-utils": "^1.0.11", + "@0xproject/migrations": "^1.0.13", + "@0xproject/subproviders": "^2.0.6", "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", @@ -72,19 +73,19 @@ "web3-provider-engine": "14.0.6" }, "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/base-contract": "^2.0.4", - "@0xproject/fill-scenarios": "^1.0.4", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", - "ethereum-types": "^1.0.7", - "ethereumjs-blockstream": "5.0.0", + "@0xproject/assert": "^1.0.12", + "@0xproject/base-contract": "^3.0.0", + "@0xproject/fill-scenarios": "^1.0.6", + "@0xproject/json-schemas": "^1.0.5", + "@0xproject/order-utils": "^1.0.6", + "@0xproject/types": "^1.1.2", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", + "ethereum-types": "^1.0.9", + "ethereumjs-blockstream": "6.0.0", "ethereumjs-util": "^5.1.1", - "ethers": "3.0.22", + "ethers": "4.0.0-beta.14", "js-sha3": "^0.7.0", "lodash": "^4.17.5", "uuid": "^3.1.0" diff --git a/packages/contract-wrappers/src/contract_wrappers.ts b/packages/contract-wrappers/src/contract_wrappers.ts index 4272cc943..89402029b 100644 --- a/packages/contract-wrappers/src/contract_wrappers.ts +++ b/packages/contract-wrappers/src/contract_wrappers.ts @@ -58,7 +58,7 @@ export class ContractWrappers { */ public orderValidator: OrderValidatorWrapper; - private _web3Wrapper: Web3Wrapper; + private readonly _web3Wrapper: Web3Wrapper; /** * Instantiates a new ContractWrappers instance. * @param provider The Provider instance you would like the 0x.js library to use for interacting with diff --git a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts index 19a882712..f7a89e3be 100644 --- a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts @@ -1,14 +1,14 @@ import { AbiDecoder, intervalUtils, logUtils } from '@0xproject/utils'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import { marshaller, Web3Wrapper } from '@0xproject/web3-wrapper'; import { BlockParamLiteral, - BlockWithoutTransactionData, ContractAbi, ContractArtifact, FilterObject, LogEntry, LogWithDecodedArgs, RawLog, + RawLogEntry, } from 'ethereum-types'; import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream'; import * as _ from 'lodash'; @@ -158,7 +158,8 @@ export abstract class ContractWrapper { return addressIfExists; } } - private _onLogStateChanged<ArgsType extends ContractEventArgs>(isRemoved: boolean, log: LogEntry): void { + private _onLogStateChanged<ArgsType extends ContractEventArgs>(isRemoved: boolean, rawLog: RawLogEntry): void { + const log: LogEntry = marshaller.unmarshalLog(rawLog); _.forEach(this._filters, (filter: FilterObject, filterToken: string) => { if (filterUtils.matchesFilter(log, filter)) { const decodedLog = this._tryToDecodeLogOrNoop(log) as LogWithDecodedArgs<ArgsType>; @@ -175,8 +176,8 @@ export abstract class ContractWrapper { throw new Error(ContractWrappersError.SubscriptionAlreadyPresent); } this._blockAndLogStreamerIfExists = new BlockAndLogStreamer( - this._getBlockOrNullAsync.bind(this), - this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper), + this._blockstreamGetBlockOrNullAsync.bind(this), + this._blockstreamGetLogsAsync.bind(this), ContractWrapper._onBlockAndLogStreamerError.bind(this, isVerbose), ); const catchAllLogFilter = {}; @@ -196,12 +197,30 @@ export abstract class ContractWrapper { ); } // This method only exists in order to comply with the expected interface of Blockstream's constructor - private async _getBlockOrNullAsync(): Promise<BlockWithoutTransactionData | null> { - const blockIfExists = await this._web3Wrapper.getBlockIfExistsAsync.bind(this._web3Wrapper); - if (_.isUndefined(blockIfExists)) { - return null; - } - return blockIfExists; + private async _blockstreamGetBlockOrNullAsync(hash: string): Promise<Block | null> { + const shouldIncludeTransactionData = false; + const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync<Block | null>({ + method: 'eth_getBlockByHash', + params: [hash, shouldIncludeTransactionData], + }); + return blockOrNull; + } + // This method only exists in order to comply with the expected interface of Blockstream's constructor + private async _blockstreamGetLatestBlockOrNullAsync(): Promise<Block | null> { + const shouldIncludeTransactionData = false; + const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync<Block | null>({ + method: 'eth_getBlockByNumber', + params: [BlockParamLiteral.Latest, shouldIncludeTransactionData], + }); + return blockOrNull; + } + // This method only exists in order to comply with the expected interface of Blockstream's constructor + private async _blockstreamGetLogsAsync(filterOptions: FilterObject): Promise<RawLogEntry[]> { + const logs = await this._web3Wrapper.sendRawPayloadAsync<RawLogEntry[]>({ + method: 'eth_getLogs', + params: [filterOptions], + }); + return logs as RawLogEntry[]; } // HACK: This should be a package-scoped method (which doesn't exist in TS) // We don't want this method available in the public interface for all classes @@ -221,14 +240,14 @@ export abstract class ContractWrapper { delete this._blockAndLogStreamerIfExists; } private async _reconcileBlockAsync(): Promise<void> { - const latestBlockIfExists = await this._web3Wrapper.getBlockIfExistsAsync(BlockParamLiteral.Latest); - if (_.isUndefined(latestBlockIfExists)) { + const latestBlockOrNull = await this._blockstreamGetLatestBlockOrNullAsync(); + if (_.isNull(latestBlockOrNull)) { return; // noop } // We need to coerce to Block type cause Web3.Block includes types for mempool blocks if (!_.isUndefined(this._blockAndLogStreamerIfExists)) { // If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined - await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockIfExists as any) as Block); + await this._blockAndLogStreamerIfExists.reconcileNewBlock(latestBlockOrNull); } } } diff --git a/packages/contract-wrappers/src/fetchers/order_filled_cancelled_fetcher.ts b/packages/contract-wrappers/src/fetchers/order_filled_cancelled_fetcher.ts index ba6f5fb5e..7a252aed3 100644 --- a/packages/contract-wrappers/src/fetchers/order_filled_cancelled_fetcher.ts +++ b/packages/contract-wrappers/src/fetchers/order_filled_cancelled_fetcher.ts @@ -3,7 +3,6 @@ import { AbstractOrderFilledCancelledFetcher } from '@0xproject/order-utils'; import { BigNumber } from '@0xproject/utils'; import { BlockParamLiteral } from 'ethereum-types'; -import { ERC20TokenWrapper } from '../contract_wrappers/erc20_token_wrapper'; import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper'; export class OrderFilledCancelledFetcher implements AbstractOrderFilledCancelledFetcher { diff --git a/packages/contract-wrappers/src/utils/assert.ts b/packages/contract-wrappers/src/utils/assert.ts index bed833b8f..30726c546 100644 --- a/packages/contract-wrappers/src/utils/assert.ts +++ b/packages/contract-wrappers/src/utils/assert.ts @@ -1,7 +1,7 @@ import { assert as sharedAssert } from '@0xproject/assert'; // HACK: We need those two unused imports because they're actually used by sharedAssert which gets injected here import { Schema } from '@0xproject/json-schemas'; // tslint:disable-line:no-unused-variable -import { signatureUtils, assetDataUtils } from '@0xproject/order-utils'; +import { assetDataUtils, signatureUtils } from '@0xproject/order-utils'; import { Order } from '@0xproject/types'; // tslint:disable-line:no-unused-variable import { BigNumber } from '@0xproject/utils'; // tslint:disable-line:no-unused-variable import { Web3Wrapper } from '@0xproject/web3-wrapper'; diff --git a/packages/contract-wrappers/src/utils/decorators.ts b/packages/contract-wrappers/src/utils/decorators.ts index d6bf6ec1e..e17246015 100644 --- a/packages/contract-wrappers/src/utils/decorators.ts +++ b/packages/contract-wrappers/src/utils/decorators.ts @@ -1,4 +1,3 @@ -import { RevertReason } from '@0xproject/types'; import * as _ from 'lodash'; import { AsyncMethod, ContractWrappersError, SyncMethod } from '../types'; @@ -46,7 +45,7 @@ const asyncErrorHandlerFactory = (errorTransformer: ErrorTransformer) => { // tslint:disable-next-line:only-arrow-functions descriptor.value = async function(...args: any[]): Promise<any> { try { - const result = await originalMethod.apply(this, args); + const result = await originalMethod.apply(this, args); // tslint:disable-line:no-invalid-this return result; } catch (error) { const transformedError = errorTransformer(error); @@ -73,7 +72,7 @@ const syncErrorHandlerFactory = (errorTransformer: ErrorTransformer) => { // tslint:disable-next-line:only-arrow-functions descriptor.value = function(...args: any[]): any { try { - const result = originalMethod.apply(this, args); + const result = originalMethod.apply(this, args); // tslint:disable-line:no-invalid-this return result; } catch (error) { const transformedError = errorTransformer(error); diff --git a/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts b/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts index 279f2a796..a7c4a238f 100644 --- a/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts +++ b/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts @@ -34,7 +34,7 @@ const ERR_MSG_MAPPING = { }; export class ExchangeTransferSimulator { - private _store: AbstractBalanceAndProxyAllowanceLazyStore; + private readonly _store: AbstractBalanceAndProxyAllowanceLazyStore; private static _throwValidationError( failureReason: FailureReason, tradeSide: TradeSide, diff --git a/packages/contract-wrappers/src/utils/filter_utils.ts b/packages/contract-wrappers/src/utils/filter_utils.ts index 0e73987f7..c05be062c 100644 --- a/packages/contract-wrappers/src/utils/filter_utils.ts +++ b/packages/contract-wrappers/src/utils/filter_utils.ts @@ -1,4 +1,4 @@ -import { ConstructorAbi, ContractAbi, EventAbi, FallbackAbi, FilterObject, LogEntry, MethodAbi } from 'ethereum-types'; +import { ContractAbi, EventAbi, FilterObject, LogEntry } from 'ethereum-types'; import * as ethUtil from 'ethereumjs-util'; import * as jsSHA3 from 'js-sha3'; import * as _ from 'lodash'; diff --git a/packages/contract-wrappers/src/utils/transaction_encoder.ts b/packages/contract-wrappers/src/utils/transaction_encoder.ts index 8821079dc..87cbb43fd 100644 --- a/packages/contract-wrappers/src/utils/transaction_encoder.ts +++ b/packages/contract-wrappers/src/utils/transaction_encoder.ts @@ -23,7 +23,7 @@ const EIP712_ZEROEX_TRANSACTION_SCHEMA: EIP712Schema = { * can submit this to the blockchain. The Exchange context executes as if UserA had directly submitted this transaction. */ export class TransactionEncoder { - private _exchangeInstance: ExchangeContract; + private readonly _exchangeInstance: ExchangeContract; constructor(exchangeInstance: ExchangeContract) { this._exchangeInstance = exchangeInstance; } diff --git a/packages/contract-wrappers/test/calldata_optimization_utils_test.ts b/packages/contract-wrappers/test/calldata_optimization_utils_test.ts index a3abb8503..94e55bffa 100644 --- a/packages/contract-wrappers/test/calldata_optimization_utils_test.ts +++ b/packages/contract-wrappers/test/calldata_optimization_utils_test.ts @@ -3,7 +3,6 @@ import * as chai from 'chai'; import * as _ from 'lodash'; import 'mocha'; -import { assert } from '../src/utils/assert'; import { calldataOptimizationUtils } from '../src/utils/calldata_optimization_utils'; import { constants } from '../src/utils/constants'; diff --git a/packages/contract-wrappers/test/erc721_wrapper_test.ts b/packages/contract-wrappers/test/erc721_wrapper_test.ts index ab6ff0984..10bac6086 100644 --- a/packages/contract-wrappers/test/erc721_wrapper_test.ts +++ b/packages/contract-wrappers/test/erc721_wrapper_test.ts @@ -229,11 +229,17 @@ describe('ERC721Wrapper', () => { it('should set the proxy approval', async () => { const tokenId = await tokenUtils.mintDummyERC721Async(tokenAddress, ownerAddress); - const approvalBeforeSet = await contractWrappers.erc721Token.isProxyApprovedAsync(tokenAddress, tokenId); - expect(approvalBeforeSet).to.be.false(); + const isProxyApprovedBeforeSet = await contractWrappers.erc721Token.isProxyApprovedAsync( + tokenAddress, + tokenId, + ); + expect(isProxyApprovedBeforeSet).to.be.false(); await contractWrappers.erc721Token.setProxyApprovalAsync(tokenAddress, tokenId); - const approvalAfterSet = await contractWrappers.erc721Token.isProxyApprovedAsync(tokenAddress, tokenId); - expect(approvalAfterSet).to.be.true(); + const isProxyApprovedAfterSet = await contractWrappers.erc721Token.isProxyApprovedAsync( + tokenAddress, + tokenId, + ); + expect(isProxyApprovedAfterSet).to.be.true(); }); }); describe('#subscribe', () => { @@ -357,7 +363,6 @@ describe('ERC721Wrapper', () => { ); contractWrappers.erc721Token.unsubscribe(subscriptionToken); - const tokenId = await tokenUtils.mintDummyERC721Async(tokenAddress, ownerAddress); const isApproved = true; await web3Wrapper.awaitTransactionSuccessAsync( await contractWrappers.erc721Token.setApprovalForAllAsync( @@ -373,15 +378,11 @@ describe('ERC721Wrapper', () => { }); }); describe('#getLogsAsync', () => { - let tokenTransferProxyAddress: string; const blockRange: BlockRange = { fromBlock: 0, toBlock: BlockParamLiteral.Latest, }; let txHash: string; - before(() => { - tokenTransferProxyAddress = contractWrappers.erc721Proxy.getContractAddress(); - }); it('should get logs with decoded args emitted by ApprovalForAll', async () => { const isApprovedForAll = true; txHash = await contractWrappers.erc721Token.setApprovalForAllAsync( diff --git a/packages/contract-wrappers/test/ether_token_wrapper_test.ts b/packages/contract-wrappers/test/ether_token_wrapper_test.ts index c15b8c016..c48fc224f 100644 --- a/packages/contract-wrappers/test/ether_token_wrapper_test.ts +++ b/packages/contract-wrappers/test/ether_token_wrapper_test.ts @@ -344,7 +344,7 @@ describe('EtherTokenWrapper', () => { etherTokenAddress = tokenUtils.getWethTokenAddress(); erc20ProxyAddress = contractWrappers.erc20Proxy.getContractAddress(); // Start the block range after all migrations to avoid unexpected logs - const currentBlock = await web3Wrapper.getBlockNumberAsync(); + const currentBlock: number = await web3Wrapper.getBlockNumberAsync(); const fromBlock = currentBlock + 1; blockRange = { fromBlock, diff --git a/packages/contract-wrappers/test/forwarder_wrapper_test.ts b/packages/contract-wrappers/test/forwarder_wrapper_test.ts index a969807b2..f77b47337 100644 --- a/packages/contract-wrappers/test/forwarder_wrapper_test.ts +++ b/packages/contract-wrappers/test/forwarder_wrapper_test.ts @@ -1,14 +1,12 @@ -import { BlockchainLifecycle, callbackErrorReporter } from '@0xproject/dev-utils'; +import { BlockchainLifecycle } from '@0xproject/dev-utils'; import { FillScenarios } from '@0xproject/fill-scenarios'; -import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils'; -import { DoneCallback, SignedOrder } from '@0xproject/types'; +import { assetDataUtils } from '@0xproject/order-utils'; +import { SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; -import { BlockParamLiteral } from 'ethereum-types'; import 'mocha'; -import { ContractWrappers, ExchangeCancelEventArgs, ExchangeEvents, ExchangeFillEventArgs, OrderStatus } from '../src'; -import { DecodedLogEvent } from '../src/types'; +import { ContractWrappers, OrderStatus } from '../src'; import { chaiSetup } from './utils/chai_setup'; import { constants } from './utils/constants'; diff --git a/packages/contract-wrappers/test/order_validator_wrapper_test.ts b/packages/contract-wrappers/test/order_validator_wrapper_test.ts index 2fdb00a71..baac3eeee 100644 --- a/packages/contract-wrappers/test/order_validator_wrapper_test.ts +++ b/packages/contract-wrappers/test/order_validator_wrapper_test.ts @@ -1,15 +1,14 @@ -import { BlockchainLifecycle, callbackErrorReporter } from '@0xproject/dev-utils'; +import { BlockchainLifecycle } from '@0xproject/dev-utils'; import { FillScenarios } from '@0xproject/fill-scenarios'; -import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils'; -import { DoneCallback, SignedOrder } from '@0xproject/types'; +import { assetDataUtils } from '@0xproject/order-utils'; +import { SignedOrder } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; -import { BlockParamLiteral } from 'ethereum-types'; import * as _ from 'lodash'; import 'mocha'; -import { ContractWrappers, ExchangeCancelEventArgs, ExchangeEvents, ExchangeFillEventArgs, OrderStatus } from '../src'; -import { DecodedLogEvent, OrderInfo, TraderInfo } from '../src/types'; +import { ContractWrappers, OrderStatus } from '../src'; +import { OrderInfo, TraderInfo } from '../src/types'; import { chaiSetup } from './utils/chai_setup'; import { constants } from './utils/constants'; @@ -26,7 +25,6 @@ describe('OrderValidator', () => { blockPollingIntervalMs: 0, }; const fillableAmount = new BigNumber(5); - const partialFillAmount = new BigNumber(2); let contractWrappers: ContractWrappers; let fillScenarios: FillScenarios; let exchangeContractAddress: string; diff --git a/packages/contract-wrappers/test/revert_validation_test.ts b/packages/contract-wrappers/test/revert_validation_test.ts new file mode 100644 index 000000000..da011c1d7 --- /dev/null +++ b/packages/contract-wrappers/test/revert_validation_test.ts @@ -0,0 +1,122 @@ +import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils'; +import { FillScenarios } from '@0xproject/fill-scenarios'; +import { runV2MigrationsAsync } from '@0xproject/migrations'; +import { assetDataUtils } from '@0xproject/order-utils'; +import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as chai from 'chai'; +import 'mocha'; + +import { ContractWrappers } from '../src'; + +import { chaiSetup } from './utils/chai_setup'; +import { constants } from './utils/constants'; +import { tokenUtils } from './utils/token_utils'; + +chaiSetup.configure(); +const expect = chai.expect; + +describe('Revert Validation ExchangeWrapper', () => { + let contractWrappers: ContractWrappers; + let userAddresses: string[]; + let zrxTokenAddress: string; + let fillScenarios: FillScenarios; + let exchangeContractAddress: string; + let makerTokenAddress: string; + let takerTokenAddress: string; + let coinbase: string; + let makerAddress: string; + let anotherMakerAddress: string; + let takerAddress: string; + let makerAssetData: string; + let takerAssetData: string; + let feeRecipient: string; + let txHash: string; + let blockchainLifecycle: BlockchainLifecycle; + let web3Wrapper: Web3Wrapper; + const fillableAmount = new BigNumber(5); + const takerTokenFillAmount = new BigNumber(5); + let signedOrder: SignedOrder; + const config = { + networkId: constants.TESTRPC_NETWORK_ID, + blockPollingIntervalMs: 0, + }; + before(async () => { + // vmErrorsOnRPCResponse is useful for quick feedback and testing during development + // but is not the default behaviour in production. Here we ensure our failure cases + // are handled in an environment which behaves similar to production + const provider = web3Factory.getRpcProvider({ + shouldUseInProcessGanache: true, + shouldThrowErrorsOnGanacheRPCResponse: false, + }); + web3Wrapper = new Web3Wrapper(provider); + blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); + const txDefaults = { + gas: devConstants.GAS_LIMIT, + from: devConstants.TESTRPC_FIRST_ADDRESS, + }; + const artifactsDir = `src/artifacts`; + // Re-deploy the artifacts in this provider, rather than in the default provider exposed in + // the beforeAll hook. This is due to the fact that the default provider enabled vmErrorsOnRPCResponse + // and we are explicity testing with vmErrorsOnRPCResponse disabled. + await runV2MigrationsAsync(provider, artifactsDir, txDefaults); + await blockchainLifecycle.startAsync(); + contractWrappers = new ContractWrappers(provider, config); + exchangeContractAddress = contractWrappers.exchange.getContractAddress(); + userAddresses = await web3Wrapper.getAvailableAddressesAsync(); + zrxTokenAddress = tokenUtils.getProtocolTokenAddress(); + fillScenarios = new FillScenarios( + provider, + userAddresses, + zrxTokenAddress, + exchangeContractAddress, + contractWrappers.erc20Proxy.getContractAddress(), + contractWrappers.erc721Proxy.getContractAddress(), + ); + [coinbase, makerAddress, takerAddress, feeRecipient, anotherMakerAddress] = userAddresses; + [makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses(); + [makerAssetData, takerAssetData] = [ + assetDataUtils.encodeERC20AssetData(makerTokenAddress), + assetDataUtils.encodeERC20AssetData(takerTokenAddress), + ]; + signedOrder = await fillScenarios.createFillableSignedOrderAsync( + makerAssetData, + takerAssetData, + makerAddress, + takerAddress, + fillableAmount, + ); + }); + after(async () => { + await blockchainLifecycle.revertAsync(); + }); + beforeEach(async () => { + await blockchainLifecycle.startAsync(); + }); + afterEach(async () => { + await blockchainLifecycle.revertAsync(); + }); + describe('#fillOrderAsync', () => { + it('should throw the revert reason when shouldValidate is true and a fill would revert', async () => { + // Create a scenario where the fill will revert + const makerTokenBalance = await contractWrappers.erc20Token.getBalanceAsync( + makerTokenAddress, + makerAddress, + ); + // Transfer all of the tokens from maker to create a failure scenario + txHash = await contractWrappers.erc20Token.transferAsync( + makerTokenAddress, + makerAddress, + takerAddress, + makerTokenBalance, + ); + await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS); + expect( + contractWrappers.exchange.fillOrderAsync(signedOrder, takerTokenFillAmount, takerAddress, { + shouldValidate: true, + }), + ).to.be.rejectedWith('TRANSFER_FAILED'); + }); + }); +}); diff --git a/packages/contract-wrappers/test/subscription_test.ts b/packages/contract-wrappers/test/subscription_test.ts index 68ef7225e..6ec7519fe 100644 --- a/packages/contract-wrappers/test/subscription_test.ts +++ b/packages/contract-wrappers/test/subscription_test.ts @@ -1,6 +1,5 @@ -import { BlockchainLifecycle, callbackErrorReporter } from '@0xproject/dev-utils'; +import { BlockchainLifecycle } from '@0xproject/dev-utils'; import { DoneCallback } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; import * as _ from 'lodash'; import 'mocha'; import * as Sinon from 'sinon'; @@ -18,17 +17,11 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); describe('SubscriptionTest', () => { let contractWrappers: ContractWrappers; - let userAddresses: string[]; - let coinbase: string; - let addressWithoutFunds: string; const config = { networkId: constants.TESTRPC_NETWORK_ID, }; before(async () => { contractWrappers = new ContractWrappers(provider, config); - userAddresses = await web3Wrapper.getAvailableAddressesAsync(); - coinbase = userAddresses[0]; - addressWithoutFunds = userAddresses[1]; }); beforeEach(async () => { await blockchainLifecycle.startAsync(); @@ -39,7 +32,6 @@ describe('SubscriptionTest', () => { describe('#subscribe', () => { const indexFilterValues = {}; let tokenAddress: string; - const allowanceAmount = new BigNumber(42); let stubs: Sinon.SinonStub[] = []; before(() => { const tokenAddresses = tokenUtils.getDummyERC20TokenAddresses(); @@ -53,7 +45,7 @@ describe('SubscriptionTest', () => { it('Should allow unsubscribeAll to be called successfully after an error', (done: DoneCallback) => { (async () => { const callback = (err: Error | null, _logEvent?: DecodedLogEvent<ERC20TokenApprovalEventArgs>) => - _.noop; + _.noop.bind(_); contractWrappers.erc20Token.subscribe( tokenAddress, ERC20TokenEvents.Approval, diff --git a/packages/contract-wrappers/test/transaction_encoder_test.ts b/packages/contract-wrappers/test/transaction_encoder_test.ts index e76c5b12d..a397e43a8 100644 --- a/packages/contract-wrappers/test/transaction_encoder_test.ts +++ b/packages/contract-wrappers/test/transaction_encoder_test.ts @@ -1,6 +1,6 @@ import { BlockchainLifecycle } from '@0xproject/dev-utils'; import { FillScenarios } from '@0xproject/fill-scenarios'; -import { assetDataUtils, signatureUtils, generatePseudoRandomSalt, orderHashUtils } from '@0xproject/order-utils'; +import { assetDataUtils, generatePseudoRandomSalt, orderHashUtils, signatureUtils } from '@0xproject/order-utils'; import { SignedOrder, SignerType } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import 'mocha'; diff --git a/packages/contract_templates/contract.handlebars b/packages/contract_templates/contract.handlebars index 466893aa7..9ae39f44f 100644 --- a/packages/contract_templates/contract.handlebars +++ b/packages/contract_templates/contract.handlebars @@ -65,10 +65,12 @@ export class {{contractName}}Contract extends BaseContract { [{{> params inputs=ctor.inputs}}], BaseContract._bigNumberToString, ); - const txData = ethers.Contract.getDeployTransaction(bytecode, abi, {{> params inputs=ctor.inputs}}); + const iface = new ethers.Interface(abi); + const deployInfo = iface.deployFunction; + const txData = deployInfo.encode(bytecode, [{{> params inputs=ctor.inputs}}]); const web3Wrapper = new Web3Wrapper(provider); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - txData, + {data: txData}, txDefaults, web3Wrapper.estimateGasAsync.bind(web3Wrapper), ); diff --git a/packages/contract_templates/partials/callAsync.handlebars b/packages/contract_templates/partials/callAsync.handlebars index 94752691d..ddbbe7508 100644 --- a/packages/contract_templates/partials/callAsync.handlebars +++ b/packages/contract_templates/partials/callAsync.handlebars @@ -8,10 +8,8 @@ async callAsync( const inputAbi = self._lookupAbi(functionSignature).inputs; [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self)); BaseContract.strictArgumentEncodingCheck(inputAbi, [{{> params inputs=inputs}}]); - const ethersFunction = self._lookupEthersInterface(functionSignature).functions.{{this.name}}( - {{> params inputs=inputs}} - ) as ethers.CallDescription; - const encodedData = ethersFunction.data; + const ethersFunction = self._lookupEthersInterface(functionSignature).functions.{{this.name}}; + const encodedData = ethersFunction.encode([{{> params inputs=inputs}}]); const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -21,7 +19,8 @@ async callAsync( self._web3Wrapper.getContractDefaults(), ); const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); - let resultArray = ethersFunction.parse(rawCallResult); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + let resultArray = ethersFunction.decode(rawCallResult); const outputAbi = (_.find(self.abi, {name: '{{this.name}}'}) as MethodAbi).outputs; resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this)); resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this)); diff --git a/packages/contract_templates/partials/tx.handlebars b/packages/contract_templates/partials/tx.handlebars index 4340d662e..b39156583 100644 --- a/packages/contract_templates/partials/tx.handlebars +++ b/packages/contract_templates/partials/tx.handlebars @@ -12,9 +12,7 @@ public {{this.tsName}} = { const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs; [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString.bind(self)); BaseContract.strictArgumentEncodingCheck(inputAbi, [{{> params inputs=inputs}}]); - const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}( - {{> params inputs=inputs}} - ).data; + const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}.encode([{{> params inputs=inputs}}]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -37,9 +35,7 @@ public {{this.tsName}} = { const self = this as any as {{contractName}}Contract; const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs; [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString); - const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}( - {{> params inputs=inputs}} - ).data; + const encodedData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}.encode([{{> params inputs=inputs}}]); const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( { to: self.address, @@ -57,9 +53,7 @@ public {{this.tsName}} = { const self = this as any as {{contractName}}Contract; const inputAbi = self._lookupAbi('{{this.functionSignature}}').inputs; [{{> params inputs=inputs}}] = BaseContract._formatABIDataItemList(inputAbi, [{{> params inputs=inputs}}], BaseContract._bigNumberToString); - const abiEncodedTransactionData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}( - {{> params inputs=inputs}} - ).data; + const abiEncodedTransactionData = self._lookupEthersInterface('{{this.functionSignature}}').functions.{{this.name}}.encode([{{> params inputs=inputs}}]); return abiEncodedTransactionData; }, {{> callAsync}} diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 6a7a7c208..6d4534eac 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "contracts", - "version": "2.1.46", + "version": "2.1.48", "engines": { "node": ">=6.12" }, @@ -12,6 +12,7 @@ }, "scripts": { "build": "yarn pre_build && tsc -b", + "build:ci": "yarn build", "pre_build": "run-s compile copy_artifacts generate_contract_wrappers", "copy_artifacts": "copyfiles -u 4 '../migrations/artifacts/development/**/*' ./lib/artifacts;", "test": "yarn run_mocha", @@ -45,11 +46,11 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md", "devDependencies": { - "@0xproject/abi-gen": "^1.0.10", - "@0xproject/dev-utils": "^1.0.9", - "@0xproject/sol-compiler": "^1.1.4", - "@0xproject/sol-cov": "^2.1.4", - "@0xproject/subproviders": "^2.0.4", + "@0xproject/abi-gen": "^1.0.12", + "@0xproject/dev-utils": "^1.0.11", + "@0xproject/sol-compiler": "^1.1.6", + "@0xproject/sol-cov": "^2.1.6", + "@0xproject/subproviders": "^2.0.6", "@0xproject/tslint-config": "^1.0.7", "@types/bn.js": "^4.11.0", "@types/ethereumjs-abi": "^0.6.0", @@ -72,18 +73,18 @@ "yargs": "^10.0.3" }, "dependencies": { - "@0xproject/base-contract": "^2.0.4", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/base-contract": "^3.0.0", + "@0xproject/order-utils": "^1.0.6", + "@0xproject/types": "^1.1.2", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", "@types/js-combinatorics": "^0.5.29", "bn.js": "^4.11.8", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.9", "ethereumjs-abi": "0.6.5", "ethereumjs-util": "^5.1.1", - "ethers": "3.0.22", + "ethers": "4.0.0-beta.14", "js-combinatorics": "^0.5.3", "lodash": "^4.17.5" } diff --git a/packages/dev-utils/CHANGELOG.json b/packages/dev-utils/CHANGELOG.json index bd4f280ba..e825c012a 100644 --- a/packages/dev-utils/CHANGELOG.json +++ b/packages/dev-utils/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "1.0.12", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.0.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.0.10", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.0.9", "changes": [ diff --git a/packages/dev-utils/CHANGELOG.md b/packages/dev-utils/CHANGELOG.md index a362330c2..4598c8e5b 100644 --- a/packages/dev-utils/CHANGELOG.md +++ b/packages/dev-utils/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.12 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.11 - _September 28, 2018_ + + * Dependencies updated + +## v1.0.10 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.9 - _September 25, 2018_ * Dependencies updated diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json index c45581e45..c0f6107b3 100644 --- a/packages/dev-utils/package.json +++ b/packages/dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/dev-utils", - "version": "1.0.9", + "version": "1.0.11", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build": "tsc -b", + "build:ci": "yarn build", "test": "yarn run_mocha", "rebuild_and_test": "run-s clean build test", "test:circleci": "yarn test:coverage", @@ -42,12 +43,12 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/subproviders": "^2.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", - "ethereum-types": "^1.0.7", + "@0xproject/subproviders": "^2.0.6", + "@0xproject/types": "^1.1.2", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", + "ethereum-types": "^1.0.9", "lodash": "^4.17.5" }, "publishConfig": { diff --git a/packages/dev-utils/src/web3_factory.ts b/packages/dev-utils/src/web3_factory.ts index 8e713fa68..7c86d3df4 100644 --- a/packages/dev-utils/src/web3_factory.ts +++ b/packages/dev-utils/src/web3_factory.ts @@ -14,6 +14,7 @@ import { env, EnvVars } from './env'; export interface Web3Config { hasAddresses?: boolean; // default: true shouldUseInProcessGanache?: boolean; // default: false + shouldThrowErrorsOnGanacheRPCResponse?: boolean; // default: true rpcUrl?: string; // default: localhost:8545 shouldUseFakeGasEstimate?: boolean; // default: true } @@ -41,15 +42,19 @@ export const web3Factory = { if (!_.isUndefined(config.rpcUrl)) { throw new Error('Cannot use both GanacheSubrovider and RPCSubprovider'); } + const shouldThrowErrorsOnGanacheRPCResponse = + _.isUndefined(config.shouldThrowErrorsOnGanacheRPCResponse) || + config.shouldThrowErrorsOnGanacheRPCResponse; provider.addProvider( new GanacheSubprovider({ + vmErrorsOnRPCResponse: shouldThrowErrorsOnGanacheRPCResponse, gasLimit: constants.GAS_LIMIT, logger, verbose: env.parseBoolean(EnvVars.VerboseGanache), port: 8545, network_id: 50, mnemonic: 'concert load couple harbor equip island argue ramp clarify fence smart topic', - }), + } as any), // TODO remove any once types are merged in DefinitelyTyped ); } else { provider.addProvider(new RPCSubprovider(config.rpcUrl || constants.RPC_URL)); diff --git a/packages/ethereum-types/CHANGELOG.json b/packages/ethereum-types/CHANGELOG.json index 20d33ea38..0552bb184 100644 --- a/packages/ethereum-types/CHANGELOG.json +++ b/packages/ethereum-types/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "1.0.10", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.0.9", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.0.8", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537541580, "version": "1.0.7", "changes": [ diff --git a/packages/ethereum-types/CHANGELOG.md b/packages/ethereum-types/CHANGELOG.md index 0de27c2fb..0ce074916 100644 --- a/packages/ethereum-types/CHANGELOG.md +++ b/packages/ethereum-types/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.10 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.9 - _September 28, 2018_ + + * Dependencies updated + +## v1.0.8 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.7 - _September 21, 2018_ * Dependencies updated diff --git a/packages/ethereum-types/package.json b/packages/ethereum-types/package.json index c1abfb79b..d52f39a2d 100644 --- a/packages/ethereum-types/package.json +++ b/packages/ethereum-types/package.json @@ -1,6 +1,6 @@ { "name": "ethereum-types", - "version": "1.0.7", + "version": "1.0.10", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "types": "lib/index.d.ts", "scripts": { "build": "tsc -b", + "build:ci": "yarn build", "clean": "shx rm -rf lib generated_docs", "lint": "tslint --project .", "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES" diff --git a/packages/ethereum-types/src/index.ts b/packages/ethereum-types/src/index.ts index 8f8f4b7e6..7e8b9de3e 100644 --- a/packages/ethereum-types/src/index.ts +++ b/packages/ethereum-types/src/index.ts @@ -181,6 +181,7 @@ export interface CallData extends CallTxDataBase { export interface FilterObject { fromBlock?: number | string; toBlock?: number | string; + blockHash?: string; address?: string; topics?: LogTopic[]; } @@ -324,9 +325,59 @@ export interface ContractNetworkData { constructorArgs: string; } +export type ParamDescription = string; + export interface StandardContractOutput { abi: ContractAbi; evm: EvmOutput; + devdoc?: DevdocOutput; +} + +export interface StandardOutput { + errors: SolcError[]; + sources: { + [fileName: string]: { + id: number; + ast?: object; + legacyAST?: object; + }; + }; + contracts: { + [fileName: string]: { + [contractName: string]: StandardContractOutput; + }; + }; +} + +export type ErrorType = + | 'JSONError' + | 'IOError' + | 'ParserError' + | 'DocstringParsingError' + | 'SyntaxError' + | 'DeclarationError' + | 'TypeError' + | 'UnimplementedFeatureError' + | 'InternalCompilerError' + | 'Exception' + | 'CompilerError' + | 'FatalError' + | 'Warning'; +export type ErrorSeverity = 'error' | 'warning'; + +export interface SolcError { + sourceLocation?: SourceLocation; + type: ErrorType; + component: 'general' | 'ewasm'; + severity: ErrorSeverity; + message: string; + formattedMessage?: string; +} + +export interface SourceLocation { + file: string; + start: number; + end: number; } export interface EvmOutput { @@ -339,6 +390,20 @@ export interface EvmBytecodeOutput { sourceMap: string; } +export interface DevdocOutput { + title: string; + author: string; + methods: { + [signature: string]: { + details: string; + params: { + [name: string]: ParamDescription; + }; + return?: string; + }; + }; +} + export interface ContractVersionData { compiler: CompilerOpts; sources: { @@ -432,4 +497,4 @@ export interface CompilerOptions { compilerSettings?: CompilerSettings; contracts?: string[] | '*'; solcVersion?: string; -} +} // tslint:disable-line:max-file-line-count diff --git a/packages/fill-scenarios/CHANGELOG.json b/packages/fill-scenarios/CHANGELOG.json index 3023a43c5..dca21f447 100644 --- a/packages/fill-scenarios/CHANGELOG.json +++ b/packages/fill-scenarios/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "1.0.7", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.0.6", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.0.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.0.4", "changes": [ diff --git a/packages/fill-scenarios/CHANGELOG.md b/packages/fill-scenarios/CHANGELOG.md index 4fb3f3c54..585a31027 100644 --- a/packages/fill-scenarios/CHANGELOG.md +++ b/packages/fill-scenarios/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.7 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.6 - _September 28, 2018_ + + * Dependencies updated + +## v1.0.5 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.4 - _September 25, 2018_ * Dependencies updated diff --git a/packages/fill-scenarios/package.json b/packages/fill-scenarios/package.json index 857ec496f..54c2f90da 100644 --- a/packages/fill-scenarios/package.json +++ b/packages/fill-scenarios/package.json @@ -1,11 +1,12 @@ { "name": "@0xproject/fill-scenarios", - "version": "1.0.4", + "version": "1.0.6", "description": "0x order fill scenario generator", "main": "lib/index.js", "types": "lib/index.d.ts", "scripts": { "build": "yarn pre_build && tsc -b", + "build:ci": "yarn build", "pre_build": "run-s update_artifacts generate_contract_wrappers", "update_artifacts": "for i in ${npm_package_config_contracts}; do copyfiles -u 4 ../migrations/artifacts/2.0.0-trimmed/$i.json lib/artifacts; done;", "generate_contract_wrappers": "abi-gen --abis 'lib/artifacts/@(Exchange|DummyERC20Token|DummyERC721Token).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/generated_contract_wrappers --backend ethers", @@ -26,7 +27,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/fill-scenarios/README.md", "devDependencies": { - "@0xproject/abi-gen": "^1.0.10", + "@0xproject/abi-gen": "^1.0.12", "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "4.14.104", "copyfiles": "^2.0.0", @@ -37,14 +38,14 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/base-contract": "^2.0.4", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", - "ethereum-types": "^1.0.7", - "ethers": "3.0.22", + "@0xproject/base-contract": "^3.0.0", + "@0xproject/order-utils": "^1.0.6", + "@0xproject/types": "^1.1.2", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", + "ethereum-types": "^1.0.9", + "ethers": "4.0.0-beta.14", "lodash": "^4.17.5" }, "publishConfig": { diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json index afe8c6f55..b9f6b08dd 100644 --- a/packages/json-schemas/CHANGELOG.json +++ b/packages/json-schemas/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "1.0.6", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.0.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.0.3", "changes": [ diff --git a/packages/json-schemas/CHANGELOG.md b/packages/json-schemas/CHANGELOG.md index dc9a69a3c..7bfd02c9b 100644 --- a/packages/json-schemas/CHANGELOG.md +++ b/packages/json-schemas/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.6 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.5 - _September 28, 2018_ + + * Dependencies updated + +## v1.0.4 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.3 - _September 25, 2018_ * Dependencies updated diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json index 7dfdb1066..dc3e97a86 100644 --- a/packages/json-schemas/package.json +++ b/packages/json-schemas/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/json-schemas", - "version": "1.0.3", + "version": "1.0.6", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build": "tsc -b", + "build:ci": "yarn build", "lint": "tslint --project .", "test": "yarn run_mocha", "rebuild_and_test": "run-s clean build test", @@ -38,14 +39,14 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md", "dependencies": { - "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/typescript-typings": "^3.0.0", "@types/node": "*", "jsonschema": "^1.2.0", "lodash.values": "^4.3.0" }, "devDependencies": { "@0xproject/tslint-config": "^1.0.7", - "@0xproject/utils": "^1.0.10", + "@0xproject/utils": "^2.0.0", "@types/lodash.foreach": "^4.5.3", "@types/lodash.values": "^4.3.3", "@types/mocha": "^2.2.42", diff --git a/packages/metacoin/package.json b/packages/metacoin/package.json index 924408d53..d7c5aadec 100644 --- a/packages/metacoin/package.json +++ b/packages/metacoin/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/metacoin", - "version": "0.0.20", + "version": "0.0.22", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "scripts": { "lint": "tslint --project . --exclude **/src/contract_wrappers/**/*", "build": "yarn pre_build && tsc -b", + "build:ci": "yarn build", "pre_build": "run-s compile generate_contract_wrappers copy_artifacts", "clean": "shx rm -rf lib artifacts src/contract_wrappers", "copy_artifacts": "copyfiles './artifacts/**/*' './contracts/**/*' ./lib", @@ -28,25 +29,25 @@ "author": "", "license": "Apache-2.0", "dependencies": { - "@0xproject/abi-gen": "^1.0.10", - "@0xproject/base-contract": "^2.0.4", - "@0xproject/sol-cov": "^2.1.4", - "@0xproject/subproviders": "^2.0.4", + "@0xproject/abi-gen": "^1.0.12", + "@0xproject/base-contract": "^3.0.0", + "@0xproject/sol-cov": "^2.1.6", + "@0xproject/subproviders": "^2.0.6", "@0xproject/tslint-config": "^1.0.7", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/types": "^1.1.2", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", "@types/mocha": "^5.2.2", "copyfiles": "^2.0.0", - "ethereum-types": "^1.0.7", - "ethers": "3.0.22", + "ethereum-types": "^1.0.9", + "ethers": "4.0.0-beta.14", "lodash": "^4.17.5", "run-s": "^0.0.0" }, "devDependencies": { - "@0xproject/dev-utils": "^1.0.9", - "@0xproject/sol-compiler": "^1.1.4", + "@0xproject/dev-utils": "^1.0.11", + "@0xproject/sol-compiler": "^1.1.6", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", "chai-bignumber": "^2.0.1", diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json index 1c8418818..772fc6cac 100644 --- a/packages/migrations/CHANGELOG.json +++ b/packages/migrations/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "1.0.14", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.0.13", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.0.12", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.0.11", "changes": [ diff --git a/packages/migrations/CHANGELOG.md b/packages/migrations/CHANGELOG.md index 80038bebb..78b6ae149 100644 --- a/packages/migrations/CHANGELOG.md +++ b/packages/migrations/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.14 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.13 - _September 28, 2018_ + + * Dependencies updated + +## v1.0.12 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.11 - _September 25, 2018_ * Dependencies updated diff --git a/packages/migrations/package.json b/packages/migrations/package.json index f44a254ed..896570cd4 100644 --- a/packages/migrations/package.json +++ b/packages/migrations/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/migrations", - "version": "1.0.11", + "version": "1.0.13", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "types": "lib/index.d.ts", "scripts": { "build": "yarn pre_build && tsc -b", + "build:ci": "yarn build", "pre_build": "run-s copy_artifacts generate_contract_wrappers", "copy_artifacts": "copyfiles 'artifacts/**/*' ./lib", "clean": "shx rm -rf lib src/1.0.0/contract_wrappers src/2.0.0-testnet/contract_wrappers src/2.0.0/contract_wrappers artifacts/development", @@ -30,10 +31,10 @@ }, "license": "Apache-2.0", "devDependencies": { - "@0xproject/abi-gen": "^1.0.10", - "@0xproject/dev-utils": "^1.0.9", + "@0xproject/abi-gen": "^1.0.12", + "@0xproject/dev-utils": "^1.0.11", "@0xproject/tslint-config": "^1.0.7", - "@0xproject/types": "^1.1.0", + "@0xproject/types": "^1.1.2", "@types/yargs": "^10.0.0", "copyfiles": "^2.0.0", "make-promises-safe": "^1.1.0", @@ -44,16 +45,16 @@ "yargs": "^10.0.3" }, "dependencies": { - "@0xproject/base-contract": "^2.0.4", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/sol-compiler": "^1.1.4", - "@0xproject/subproviders": "^2.0.4", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/base-contract": "^3.0.0", + "@0xproject/order-utils": "^1.0.6", + "@0xproject/sol-compiler": "^1.1.6", + "@0xproject/subproviders": "^2.0.6", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", "@ledgerhq/hw-app-eth": "^4.3.0", - "ethereum-types": "^1.0.7", - "ethers": "3.0.22", + "ethereum-types": "^1.0.9", + "ethers": "4.0.0-beta.14", "lodash": "^4.17.5" }, "optionalDependencies": { diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index e776569b1..ba4c4fead 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@0xproject/monorepo-scripts", - "version": "1.0.9", + "version": "1.0.10", "engines": { "node": ">=6.12" }, @@ -10,6 +10,7 @@ "types": "lib/index.d.ts", "scripts": { "build": "tsc -b", + "build:ci": "yarn build", "lint": "tslint --project .", "clean": "shx rm -rf lib", "test:publish": "run-s build script:publish", diff --git a/packages/monorepo-scripts/src/publish_release_notes.ts b/packages/monorepo-scripts/src/publish_release_notes.ts index a9bc8fe75..6090498e0 100644 --- a/packages/monorepo-scripts/src/publish_release_notes.ts +++ b/packages/monorepo-scripts/src/publish_release_notes.ts @@ -1,3 +1,4 @@ +import * as _ from 'lodash'; import * as yargs from 'yargs'; import { publishReleaseNotesAsync } from './utils/github_release_utils'; @@ -9,14 +10,25 @@ const args = yargs type: 'boolean', demandOption: true, }) - .example('$0 --isDryRun true', 'Full usage example').argv; + .option('packages', { + describe: + 'Space-separated list of packages to generated release notes for. If not supplied, it does all `Lerna updated` packages.', + type: 'string', + }) + .example('$0 --isDryRun true --packages "0x.js @0xproject/web3-wrapper"', 'Full usage example').argv; (async () => { const isDryRun = args.isDryRun; - const shouldIncludePrivate = false; - const allUpdatedPackages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate); + let packages; + if (_.isUndefined(args.packages)) { + const shouldIncludePrivate = false; + packages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate); + } else { + const packageNames = args.packages.split(' '); + packages = await utils.getPackagesByNameAsync(packageNames); + } - await publishReleaseNotesAsync(allUpdatedPackages, isDryRun); + await publishReleaseNotesAsync(packages, isDryRun); process.exit(0); })().catch(err => { utils.log(err); diff --git a/packages/monorepo-scripts/src/utils/utils.ts b/packages/monorepo-scripts/src/utils/utils.ts index 2ce36942c..5e2e877c7 100644 --- a/packages/monorepo-scripts/src/utils/utils.ts +++ b/packages/monorepo-scripts/src/utils/utils.ts @@ -54,6 +54,13 @@ export const utils = { } return packages; }, + async getPackagesByNameAsync(packageNames: string[]): Promise<Package[]> { + const allPackages = utils.getPackages(constants.monorepoRootPath); + const updatedPackages = _.filter(allPackages, pkg => { + return _.includes(packageNames, pkg.packageJson.name); + }); + return updatedPackages; + }, async getUpdatedPackagesAsync(shouldIncludePrivate: boolean): Promise<Package[]> { const updatedPublicPackages = await utils.getLernaUpdatedPackagesAsync(shouldIncludePrivate); const updatedPackageNames = _.map(updatedPublicPackages, pkg => pkg.name); diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json index d6742df2e..b6c284908 100644 --- a/packages/order-utils/CHANGELOG.json +++ b/packages/order-utils/CHANGELOG.json @@ -1,5 +1,34 @@ [ { + "timestamp": 1538475601, + "version": "1.0.7", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "version": "1.0.6", + "changes": [ + { + "note": + "Add signerAddress normalization to `isValidECSignature` to avoid `invalid address recovery` error if caller supplies a checksummed address", + "pr": 1096 + } + ], + "timestamp": 1538157789 + }, + { + "timestamp": 1537907159, + "version": "1.0.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.0.4", "changes": [ diff --git a/packages/order-utils/CHANGELOG.md b/packages/order-utils/CHANGELOG.md index 67e5a54a6..747c988a2 100644 --- a/packages/order-utils/CHANGELOG.md +++ b/packages/order-utils/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.7 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.6 - _September 28, 2018_ + + * Add signerAddress normalization to `isValidECSignature` to avoid `invalid address recovery` error if caller supplies a checksummed address (#1096) + +## v1.0.5 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.4 - _September 25, 2018_ * Dependencies updated diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json index 167d32608..9fefdba5e 100644 --- a/packages/order-utils/package.json +++ b/packages/order-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/order-utils", - "version": "1.0.4", + "version": "1.0.6", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build": "yarn pre_build && tsc -b", + "build:ci": "yarn build", "pre_build": "run-s update_artifacts generate_contract_wrappers", "generate_contract_wrappers": "abi-gen --abis 'lib/src/artifacts/@(Exchange|IWallet|IValidator|DummyERC20Token|ERC20Proxy|ERC20Token).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/generated_contract_wrappers --backend ethers", "update_artifacts": "for i in ${npm_package_config_contracts_v2}; do copyfiles -u 4 ../migrations/artifacts/2.0.0-trimmed/$i.json lib/src/artifacts; done;", @@ -38,7 +39,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/order-utils/README.md", "devDependencies": { - "@0xproject/dev-utils": "^1.0.9", + "@0xproject/dev-utils": "^1.0.11", "@0xproject/tslint-config": "^1.0.7", "@types/bn.js": "^4.11.0", "@types/lodash": "4.14.104", @@ -57,19 +58,19 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/base-contract": "^2.0.4", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/assert": "^1.0.12", + "@0xproject/base-contract": "^3.0.0", + "@0xproject/json-schemas": "^1.0.5", + "@0xproject/types": "^1.1.2", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", "@types/node": "*", "bn.js": "^4.11.8", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.9", "ethereumjs-abi": "0.6.5", "ethereumjs-util": "^5.1.1", - "ethers": "3.0.22", + "ethers": "4.0.0-beta.14", "lodash": "^4.17.5" }, "publishConfig": { diff --git a/packages/order-utils/src/order_state_utils.ts b/packages/order-utils/src/order_state_utils.ts index 8398776aa..9b21ef6e9 100644 --- a/packages/order-utils/src/order_state_utils.ts +++ b/packages/order-utils/src/order_state_utils.ts @@ -114,7 +114,7 @@ export class OrderStateUtils { * @return State relevant to the signedOrder, as well as whether the signedOrder is "valid". * Validity is defined as a non-zero amount of the order can still be filled. */ - public async getOpenOrderStateAsync(signedOrder: SignedOrder): Promise<OrderState> { + public async getOpenOrderStateAsync(signedOrder: SignedOrder, transactionHash?: string): Promise<OrderState> { const orderRelevantState = await this.getOpenOrderRelevantStateAsync(signedOrder); const orderHash = orderHashUtils.getOrderHashHex(signedOrder); const isOrderCancelled = await this._orderFilledCancelledFetcher.isOrderCancelledAsync(orderHash); @@ -134,6 +134,7 @@ export class OrderStateUtils { isValid: true, orderHash, orderRelevantState, + transactionHash, }; return orderState; } else { @@ -141,6 +142,7 @@ export class OrderStateUtils { isValid: false, orderHash, error: orderValidationResult.error, + transactionHash, }; return orderState; } diff --git a/packages/order-utils/src/signature_utils.ts b/packages/order-utils/src/signature_utils.ts index c0c9e71a7..3b656d3fc 100644 --- a/packages/order-utils/src/signature_utils.ts +++ b/packages/order-utils/src/signature_utils.ts @@ -174,6 +174,7 @@ export const signatureUtils = { assert.isHexString('data', data); assert.doesConformToSchema('signature', signature, schemas.ecSignatureSchema); assert.isETHAddressHex('signerAddress', signerAddress); + const normalizedSignerAddress = signerAddress.toLowerCase(); const msgHashBuff = ethUtil.toBuffer(data); try { @@ -184,7 +185,8 @@ export const signatureUtils = { ethUtil.toBuffer(signature.s), ); const retrievedAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey)); - return retrievedAddress === signerAddress; + const normalizedRetrievedAddress = retrievedAddress.toLowerCase(); + return normalizedRetrievedAddress === normalizedSignerAddress; } catch (err) { return false; } diff --git a/packages/order-utils/test/order_state_utils_test.ts b/packages/order-utils/test/order_state_utils_test.ts index 91ef23b69..ea88027ae 100644 --- a/packages/order-utils/test/order_state_utils_test.ts +++ b/packages/order-utils/test/order_state_utils_test.ts @@ -120,5 +120,25 @@ describe('OrderStateUtils', () => { const orderState = await orderStateUtils.getOpenOrderStateAsync(signedOrder); expect(orderState.isValid).to.eq(false); }); + it('should include the transactionHash in orderState if supplied in method invocation', async () => { + const makerAssetAmount = new BigNumber(10); + const takerAssetAmount = new BigNumber(10000000000000000); + const takerBalance = takerAssetAmount; + const orderFilledAmount = new BigNumber(0); + const mockBalanceFetcher = buildMockBalanceFetcher(takerBalance); + const mockOrderFilledFetcher = buildMockOrderFilledFetcher(orderFilledAmount); + const [signedOrder] = testOrderFactory.generateTestSignedOrders( + { + makerAssetAmount, + takerAssetAmount, + }, + 1, + ); + + const orderStateUtils = new OrderStateUtils(mockBalanceFetcher, mockOrderFilledFetcher); + const transactionHash = '0xdeadbeef'; + const orderState = await orderStateUtils.getOpenOrderStateAsync(signedOrder, transactionHash); + expect(orderState.transactionHash).to.eq(transactionHash); + }); }); }); diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json index d4b0e6607..f26bf4ca4 100644 --- a/packages/order-watcher/CHANGELOG.json +++ b/packages/order-watcher/CHANGELOG.json @@ -1,7 +1,7 @@ [ { - "timestamp": 1537875740, - "version": "1.0.5", + "timestamp": 1538475601, + "version": "2.1.1", "changes": [ { "note": "Dependencies updated" @@ -9,13 +9,53 @@ ] }, { - "timestamp": 1537541580, + "version": "2.1.0", + "changes": [ + { + "note": "Export ExpirationWatcher", + "pr": 1097 + } + ], + "timestamp": 1538157789 + }, + { + "version": "2.0.0", + "changes": [ + { + "note": + "Fixes dropped events issue by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too.", + "pr": 1080 + }, + { + "note": + "Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it", + "pr": 1080 + }, + { + "note": + "Add `transactionHash` to `OrderState` emitted by `OrderWatcher` subscriptions if the order's state change originated from a transaction.", + "pr": 1087 + } + ], + "timestamp": 1537907159 + }, + { + "version": "1.0.5", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1537875740 + }, + { "version": "1.0.4", "changes": [ { "note": "Dependencies updated" } - ] + ], + "timestamp": 1537541580 }, { "version": "1.0.3", diff --git a/packages/order-watcher/CHANGELOG.md b/packages/order-watcher/CHANGELOG.md index d179b2e1a..7bc74cf2a 100644 --- a/packages/order-watcher/CHANGELOG.md +++ b/packages/order-watcher/CHANGELOG.md @@ -5,6 +5,20 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.1.1 - _October 2, 2018_ + + * Dependencies updated + +## v2.1.0 - _September 28, 2018_ + + * Export ExpirationWatcher (#1097) + +## v2.0.0 - _September 25, 2018_ + + * Fixes dropped events issue by fetching logs by blockHash instead of blockNumber. Support for fetching by blockHash was added in Geth > v1.8.13 and Parity > v2.1.0. Infura works too. (#1080) + * Fix misunderstanding about blockstream interface callbacks and pass the raw JSON RPC responses to it (#1080) + * Add `transactionHash` to `OrderState` emitted by `OrderWatcher` subscriptions if the order's state change originated from a transaction. (#1087) + ## v1.0.5 - _September 25, 2018_ * Dependencies updated diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json index d383211a8..9f57dd6fd 100644 --- a/packages/order-watcher/package.json +++ b/packages/order-watcher/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/order-watcher", - "version": "1.0.5", + "version": "2.1.0", "description": "An order watcher daemon that watches for order validity", "keywords": [ "0x", @@ -13,6 +13,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build": "yarn pre_build && tsc -b", + "build:ci": "yarn build", "pre_build": "run-s update_artifacts copy_artifacts generate_contract_wrappers", "lint": "tslint --project . --exclude **/src/generated_contract_wrappers/**/*", "generate_contract_wrappers": "abi-gen --abis 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/generated_contract_wrappers --backend ethers", @@ -42,9 +43,9 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0xproject/abi-gen": "^1.0.10", - "@0xproject/dev-utils": "^1.0.9", - "@0xproject/migrations": "^1.0.11", + "@0xproject/abi-gen": "^1.0.12", + "@0xproject/dev-utils": "^1.0.11", + "@0xproject/migrations": "^1.0.13", "@0xproject/tslint-config": "^1.0.7", "@types/bintrees": "^1.0.2", "@types/lodash": "4.14.104", @@ -70,20 +71,20 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/base-contract": "^2.0.4", - "@0xproject/contract-wrappers": "^1.0.5", - "@0xproject/fill-scenarios": "^1.0.4", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/assert": "^1.0.12", + "@0xproject/base-contract": "^3.0.0", + "@0xproject/contract-wrappers": "^2.0.1", + "@0xproject/fill-scenarios": "^1.0.6", + "@0xproject/json-schemas": "^1.0.5", + "@0xproject/order-utils": "^1.0.6", + "@0xproject/types": "^1.1.2", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", "bintrees": "^1.0.2", - "ethereum-types": "^1.0.7", - "ethereumjs-blockstream": "5.0.0", - "ethers": "3.0.22", + "ethereum-types": "^1.0.9", + "ethereumjs-blockstream": "6.0.0", + "ethers": "4.0.0-beta.14", "lodash": "^4.17.5" }, "publishConfig": { diff --git a/packages/order-watcher/src/index.ts b/packages/order-watcher/src/index.ts index 8efca6217..d7ad4fba7 100644 --- a/packages/order-watcher/src/index.ts +++ b/packages/order-watcher/src/index.ts @@ -1,4 +1,5 @@ export { OrderWatcher } from './order_watcher/order_watcher'; +export { ExpirationWatcher } from './order_watcher/expiration_watcher'; export { OrderStateValid, diff --git a/packages/order-watcher/src/order_watcher/event_watcher.ts b/packages/order-watcher/src/order_watcher/event_watcher.ts index eca235e26..9ea301815 100644 --- a/packages/order-watcher/src/order_watcher/event_watcher.ts +++ b/packages/order-watcher/src/order_watcher/event_watcher.ts @@ -1,6 +1,6 @@ import { intervalUtils, logUtils } from '@0xproject/utils'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; -import { BlockParamLiteral, BlockWithoutTransactionData, LogEntry, Provider } from 'ethereum-types'; +import { marshaller, Web3Wrapper } from '@0xproject/web3-wrapper'; +import { BlockParamLiteral, FilterObject, LogEntry, Provider, RawLogEntry } from 'ethereum-types'; import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream'; import * as _ from 'lodash'; @@ -20,7 +20,6 @@ enum LogEventState { */ export class EventWatcher { private readonly _web3Wrapper: Web3Wrapper; - private readonly _stateLayer: BlockParamLiteral; private readonly _isVerbose: boolean; private _blockAndLogStreamerIfExists: BlockAndLogStreamer<Block, Log> | undefined; private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer; @@ -35,7 +34,6 @@ export class EventWatcher { ) { this._isVerbose = isVerbose; this._web3Wrapper = new Web3Wrapper(provider); - this._stateLayer = stateLayer; this._pollingIntervalMs = _.isUndefined(pollingIntervalIfExistsMs) ? DEFAULT_EVENT_POLLING_INTERVAL_MS : pollingIntervalIfExistsMs; @@ -62,8 +60,8 @@ export class EventWatcher { throw new Error(OrderWatcherError.SubscriptionAlreadyPresent); } this._blockAndLogStreamerIfExists = new BlockAndLogStreamer( - this._getBlockOrNullAsync.bind(this), - this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper), + this._blockstreamGetBlockOrNullAsync.bind(this), + this._blockstreamGetLogsAsync.bind(this), this._onBlockAndLogStreamerError.bind(this), ); const catchAllLogFilter = {}; @@ -83,12 +81,30 @@ export class EventWatcher { ); } // This method only exists in order to comply with the expected interface of Blockstream's constructor - private async _getBlockOrNullAsync(): Promise<BlockWithoutTransactionData | null> { - const blockIfExists = await this._web3Wrapper.getBlockIfExistsAsync.bind(this._web3Wrapper); - if (_.isUndefined(blockIfExists)) { - return null; - } - return blockIfExists; + private async _blockstreamGetBlockOrNullAsync(hash: string): Promise<Block | null> { + const shouldIncludeTransactionData = false; + const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync<Block | null>({ + method: 'eth_getBlockByHash', + params: [hash, shouldIncludeTransactionData], + }); + return blockOrNull; + } + // This method only exists in order to comply with the expected interface of Blockstream's constructor + private async _blockstreamGetLatestBlockOrNullAsync(): Promise<Block | null> { + const shouldIncludeTransactionData = false; + const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync<Block | null>({ + method: 'eth_getBlockByNumber', + params: [BlockParamLiteral.Latest, shouldIncludeTransactionData], + }); + return blockOrNull; + } + // This method only exists in order to comply with the expected interface of Blockstream's constructor + private async _blockstreamGetLogsAsync(filterOptions: FilterObject): Promise<RawLogEntry[]> { + const logs = await this._web3Wrapper.sendRawPayloadAsync<RawLogEntry[]>({ + method: 'eth_getLogs', + params: [filterOptions], + }); + return logs as RawLogEntry[]; } private _stopBlockAndLogStream(): void { if (_.isUndefined(this._blockAndLogStreamerIfExists)) { @@ -103,19 +119,20 @@ export class EventWatcher { private async _onLogStateChangedAsync( callback: EventWatcherCallback, isRemoved: boolean, - log: LogEntry, + rawLog: RawLogEntry, ): Promise<void> { + const log: LogEntry = marshaller.unmarshalLog(rawLog); await this._emitDifferencesAsync(log, isRemoved ? LogEventState.Removed : LogEventState.Added, callback); } private async _reconcileBlockAsync(): Promise<void> { - const latestBlockIfExists = await this._web3Wrapper.getBlockIfExistsAsync(this._stateLayer); - if (_.isUndefined(latestBlockIfExists)) { + const latestBlockOrNull = await this._blockstreamGetLatestBlockOrNullAsync(); + if (_.isNull(latestBlockOrNull)) { return; // noop } // We need to coerce to Block type cause Web3.Block includes types for mempool blocks if (!_.isUndefined(this._blockAndLogStreamerIfExists)) { // If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined - await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockIfExists as any) as Block); + await this._blockAndLogStreamerIfExists.reconcileNewBlock(latestBlockOrNull); } } private async _emitDifferencesAsync( diff --git a/packages/order-watcher/src/order_watcher/order_watcher.ts b/packages/order-watcher/src/order_watcher/order_watcher.ts index cab2efa4b..f9a63efe3 100644 --- a/packages/order-watcher/src/order_watcher/order_watcher.ts +++ b/packages/order-watcher/src/order_watcher/order_watcher.ts @@ -275,6 +275,7 @@ export class OrderWatcher { return; // noop } const decodedLog = (maybeDecodedLog as any) as LogWithDecodedArgs<ContractEventArgs>; + const transactionHash = decodedLog.transactionHash; switch (decodedLog.event) { case ERC20TokenEvents.Approval: case ERC721TokenEvents.Approval: { @@ -290,7 +291,7 @@ export class OrderWatcher { args._owner, tokenAssetData, ); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } else { // ERC721 @@ -303,7 +304,7 @@ export class OrderWatcher { args._owner, tokenAssetData, ); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } } @@ -322,7 +323,7 @@ export class OrderWatcher { args._from, tokenAssetData, ); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } else { // ERC721 @@ -336,7 +337,7 @@ export class OrderWatcher { args._from, tokenAssetData, ); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } } @@ -350,7 +351,7 @@ export class OrderWatcher { args._owner, tokenAddress, ); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } case WETH9Events.Deposit: { @@ -363,7 +364,7 @@ export class OrderWatcher { args._owner, tokenAssetData, ); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } case WETH9Events.Withdrawal: { @@ -376,7 +377,7 @@ export class OrderWatcher { args._owner, tokenAssetData, ); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } case ExchangeEvents.Fill: { @@ -387,7 +388,7 @@ export class OrderWatcher { const orderHash = args.orderHash; const isOrderWatched = !_.isUndefined(this._orderByOrderHash[orderHash]); if (isOrderWatched) { - await this._emitRevalidateOrdersAsync([orderHash]); + await this._emitRevalidateOrdersAsync([orderHash], transactionHash); } break; } @@ -399,7 +400,7 @@ export class OrderWatcher { const orderHash = args.orderHash; const isOrderWatched = !_.isUndefined(this._orderByOrderHash[orderHash]); if (isOrderWatched) { - await this._emitRevalidateOrdersAsync([orderHash]); + await this._emitRevalidateOrdersAsync([orderHash], transactionHash); } break; } @@ -410,7 +411,7 @@ export class OrderWatcher { this._orderFilledCancelledLazyStore.deleteAllIsCancelled(); // Revalidate orders const orderHashes = this._dependentOrderHashesTracker.getDependentOrderHashesByMaker(args.makerAddress); - await this._emitRevalidateOrdersAsync(orderHashes); + await this._emitRevalidateOrdersAsync(orderHashes, transactionHash); break; } @@ -418,12 +419,12 @@ export class OrderWatcher { throw errorUtils.spawnSwitchErr('decodedLog.event', decodedLog.event); } } - private async _emitRevalidateOrdersAsync(orderHashes: string[]): Promise<void> { + private async _emitRevalidateOrdersAsync(orderHashes: string[], transactionHash?: string): Promise<void> { for (const orderHash of orderHashes) { const signedOrder = this._orderByOrderHash[orderHash]; // Most of these calls will never reach the network because the data is fetched from stores // and only updated when cache is invalidated - const orderState = await this._orderStateUtils.getOpenOrderStateAsync(signedOrder); + const orderState = await this._orderStateUtils.getOpenOrderStateAsync(signedOrder, transactionHash); if (_.isUndefined(this._callbackIfExists)) { break; // Unsubscribe was called } diff --git a/packages/order-watcher/test/order_watcher_test.ts b/packages/order-watcher/test/order_watcher_test.ts index 38bfde7ef..60d9069e8 100644 --- a/packages/order-watcher/test/order_watcher_test.ts +++ b/packages/order-watcher/test/order_watcher_test.ts @@ -250,6 +250,32 @@ describe('OrderWatcher', () => { await contractWrappers.exchange.fillOrderAsync(signedOrder, fillableAmount, takerAddress); })().catch(done); }); + it('should include transactionHash in emitted orderStateInvalid when watched order fully filled', (done: DoneCallback) => { + (async () => { + signedOrder = await fillScenarios.createFillableSignedOrderAsync( + makerAssetData, + takerAssetData, + makerAddress, + takerAddress, + fillableAmount, + ); + await orderWatcher.addOrderAsync(signedOrder); + + let transactionHash: string; + const callback = callbackErrorReporter.reportNodeCallbackErrors(done)((orderState: OrderState) => { + expect(orderState.isValid).to.be.false(); + const invalidOrderState = orderState as OrderStateInvalid; + expect(invalidOrderState.transactionHash).to.be.equal(transactionHash); + }); + orderWatcher.subscribe(callback); + + transactionHash = await contractWrappers.exchange.fillOrderAsync( + signedOrder, + fillableAmount, + takerAddress, + ); + })().catch(done); + }); it('should emit orderStateValid when watched order partially filled', (done: DoneCallback) => { (async () => { signedOrder = await fillScenarios.createFillableSignedOrderAsync( diff --git a/packages/react-docs/CHANGELOG.json b/packages/react-docs/CHANGELOG.json index 4e3dfed99..3fa89b0bc 100644 --- a/packages/react-docs/CHANGELOG.json +++ b/packages/react-docs/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "1.0.13", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.0.12", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.0.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.0.10", "changes": [ diff --git a/packages/react-docs/CHANGELOG.md b/packages/react-docs/CHANGELOG.md index ca96d479d..48cd4d654 100644 --- a/packages/react-docs/CHANGELOG.md +++ b/packages/react-docs/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.13 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.12 - _September 28, 2018_ + + * Dependencies updated + +## v1.0.11 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.10 - _September 25, 2018_ * Dependencies updated diff --git a/packages/react-docs/README.md b/packages/react-docs/README.md index 5d56207de..51e949967 100644 --- a/packages/react-docs/README.md +++ b/packages/react-docs/README.md @@ -2,7 +2,7 @@ #### WARNING: Alpha software. Expect things to break when trying to use. -A full-page React component for rendering beautiful documentation for Solidity and Typescript code generated with [TypeDoc](http://typedoc.org/) or [Doxity](https://github.com/0xproject/doxity). +A full-page React component for rendering beautiful documentation for Solidity and Typescript code generated with [TypeDoc](http://typedoc.org/) or [sol-doc](https://github.com/0xProject/0x-monorepo/tree/development/packages/sol-doc). <div style="text-align: center;"> <img src="https://s3.eu-west-2.amazonaws.com/0x-wiki-images/screenshot.png" style="padding-bottom: 20px; padding-top: 20px;" width="80%" /> @@ -47,7 +47,7 @@ Feel free to contribute to these improvements! * Allow user to pass in styling for all major elements similar to [Material-UI](http://www.material-ui.com/). * Allow user to define an alternative font and have it change everywhere. -* Add source links to Solidity docs (currently unsupported by Doxity). +* Add source links to Solidity docs (currently unsupported by solc, which underlies sol-doc). ## Contributing diff --git a/packages/react-docs/package.json b/packages/react-docs/package.json index d933489b7..0379e9e2f 100644 --- a/packages/react-docs/package.json +++ b/packages/react-docs/package.json @@ -1,15 +1,16 @@ { "name": "@0xproject/react-docs", - "version": "1.0.10", + "version": "1.0.12", "engines": { "node": ">=6.12" }, - "description": "React documentation component for rendering TypeDoc & Doxity generated JSON", + "description": "React documentation component for rendering TypeDoc & sol-doc generated JSON", "main": "lib/index.js", "types": "lib/index.d.ts", "scripts": { "lint": "tslint --project .", "build": "tsc -b", + "build:ci": "yarn build", "clean": "shx rm -rf lib" }, "author": "Fabio Berger", @@ -23,7 +24,7 @@ "url": "https://github.com/0xProject/0x-monorepo.git" }, "devDependencies": { - "@0xproject/dev-utils": "^1.0.9", + "@0xproject/dev-utils": "^1.0.11", "@0xproject/tslint-config": "^1.0.7", "@types/compare-versions": "^3.0.0", "copyfiles": "^2.0.0", @@ -33,8 +34,9 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/react-shared": "^1.0.11", - "@0xproject/utils": "^1.0.10", + "@0xproject/react-shared": "^1.0.13", + "@0xproject/types": "^1.1.2", + "@0xproject/utils": "^2.0.0", "@types/lodash": "4.14.104", "@types/material-ui": "^0.20.0", "@types/node": "*", diff --git a/packages/react-docs/src/components/custom_enum.tsx b/packages/react-docs/src/components/custom_enum.tsx index c4252d9e2..fa7c43146 100644 --- a/packages/react-docs/src/components/custom_enum.tsx +++ b/packages/react-docs/src/components/custom_enum.tsx @@ -2,7 +2,7 @@ import { logUtils } from '@0xproject/utils'; import * as _ from 'lodash'; import * as React from 'react'; -import { CustomType } from '../types'; +import { CustomType } from '@0xproject/types'; const STRING_ENUM_CODE_PREFIX = ' strEnum('; diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx index 9d9b5141a..a23111297 100644 --- a/packages/react-docs/src/components/documentation.tsx +++ b/packages/react-docs/src/components/documentation.tsx @@ -9,24 +9,23 @@ import { Styles, utils as sharedUtils, } from '@0xproject/react-shared'; -import * as _ from 'lodash'; -import CircularProgress from 'material-ui/CircularProgress'; -import * as React from 'react'; -import * as semver from 'semver'; - -import { DocsInfo } from '../docs_info'; import { - AddressByContractName, DocAgnosticFormat, Event, ExternalExportToLink, Property, SolidityMethod, - SupportedDocJson, TypeDefinitionByName, TypescriptFunction, TypescriptMethod, -} from '../types'; +} from '@0xproject/types'; +import * as _ from 'lodash'; +import CircularProgress from 'material-ui/CircularProgress'; +import * as React from 'react'; +import * as semver from 'semver'; + +import { DocsInfo } from '../docs_info'; +import { AddressByContractName, SupportedDocJson } from '../types'; import { constants } from '../utils/constants'; import { Badge } from './badge'; @@ -219,11 +218,11 @@ export class Documentation extends React.Component<DocumentationProps, Documenta _.isEmpty(docSection.events); const sortedTypes = _.sortBy(docSection.types, 'name'); - const typeDefs = _.map(sortedTypes, customType => { + const typeDefs = _.map(sortedTypes, (customType, i) => { return ( <TypeDefinition sectionName={sectionName} - key={`type-${customType.name}`} + key={`type-${customType.name}-${i}`} customType={customType} docsInfo={this.props.docsInfo} typeDefinitionByName={typeDefinitionByName} @@ -330,7 +329,7 @@ export class Documentation extends React.Component<DocumentationProps, Documenta return <div>{externalExports}</div>; } private _renderNetworkBadgesIfExists(sectionName: string): React.ReactNode { - if (this.props.docsInfo.type !== SupportedDocJson.Doxity) { + if (this.props.docsInfo.type !== SupportedDocJson.SolDoc) { return null; } @@ -354,7 +353,7 @@ export class Documentation extends React.Component<DocumentationProps, Documenta key={`badge-${networkName}-${sectionName}`} href={linkIfExists} target="_blank" - style={{ color: colors.white, textDecoration: 'none' }} + style={{ color: colors.white, textDecoration: 'none', marginTop: 8 }} > <Badge title={networkName} backgroundColor={networkNameToColor[networkName]} /> </a> diff --git a/packages/react-docs/src/components/event_definition.tsx b/packages/react-docs/src/components/event_definition.tsx index 6cb80c6b0..37236275b 100644 --- a/packages/react-docs/src/components/event_definition.tsx +++ b/packages/react-docs/src/components/event_definition.tsx @@ -1,9 +1,9 @@ import { AnchorTitle, colors, HeaderSizes } from '@0xproject/react-shared'; +import { Event, EventArg } from '@0xproject/types'; import * as _ from 'lodash'; import * as React from 'react'; import { DocsInfo } from '../docs_info'; -import { Event, EventArg } from '../types'; import { Type } from './type'; diff --git a/packages/react-docs/src/components/interface.tsx b/packages/react-docs/src/components/interface.tsx index 93b10e96d..cad7d6c46 100644 --- a/packages/react-docs/src/components/interface.tsx +++ b/packages/react-docs/src/components/interface.tsx @@ -1,8 +1,9 @@ import * as _ from 'lodash'; import * as React from 'react'; +import { CustomType, TypeDefinitionByName } from '@0xproject/types'; + import { DocsInfo } from '../docs_info'; -import { CustomType, TypeDefinitionByName } from '../types'; import { Signature } from './signature'; import { Type } from './type'; @@ -19,9 +20,9 @@ export interface InterfaceProps { export const Interface: React.SFC<InterfaceProps> = (props: InterfaceProps): any => { const type = props.type; - const properties = _.map(type.children, property => { + const properties = _.map(type.children, (property, i) => { return ( - <span key={`property-${property.name}-${property.type}-${type.name}`}> + <span key={`property-${property.name}-${property.type}-${type.name}-${i}`}> {property.name}:{' '} {property.type && !_.isUndefined(property.type.method) ? ( <Signature diff --git a/packages/react-docs/src/components/property_block.tsx b/packages/react-docs/src/components/property_block.tsx index f181e21d2..8434e8682 100644 --- a/packages/react-docs/src/components/property_block.tsx +++ b/packages/react-docs/src/components/property_block.tsx @@ -1,8 +1,8 @@ import { AnchorTitle, HeaderSizes } from '@0xproject/react-shared'; +import { Property, TypeDefinitionByName } from '@0xproject/types'; import * as React from 'react'; import { DocsInfo } from '../docs_info'; -import { Property, TypeDefinitionByName } from '../types'; import { constants } from '../utils/constants'; import { Comment } from './comment'; diff --git a/packages/react-docs/src/components/signature.tsx b/packages/react-docs/src/components/signature.tsx index bf9c8be24..1f3dd0ee8 100644 --- a/packages/react-docs/src/components/signature.tsx +++ b/packages/react-docs/src/components/signature.tsx @@ -1,8 +1,9 @@ import * as _ from 'lodash'; import * as React from 'react'; +import { Parameter, Type as TypeDef, TypeDefinitionByName, TypeParameter } from '@0xproject/types'; + import { DocsInfo } from '../docs_info'; -import { Parameter, Type as TypeDef, TypeDefinitionByName, TypeParameter } from '../types'; import { Type } from './type'; @@ -18,12 +19,14 @@ export interface SignatureProps { callPath?: string; docsInfo: DocsInfo; isInPopover: boolean; + isFallback?: boolean; } const defaultProps = { shouldHideMethodName: false, shouldUseArrowSyntax: false, callPath: '', + isFallback: false, }; export const Signature: React.SFC<SignatureProps> = (props: SignatureProps) => { @@ -33,6 +36,7 @@ export const Signature: React.SFC<SignatureProps> = (props: SignatureProps) => { props.docsInfo, sectionName, props.isInPopover, + props.name, props.typeDefinitionByName, ); const paramStringArray: any[] = []; @@ -74,7 +78,7 @@ export const Signature: React.SFC<SignatureProps> = (props: SignatureProps) => { return ( <span style={{ fontSize: 15 }}> {props.callPath} - {methodName} + {props.isFallback ? '' : methodName} {typeParameterIfExists}({hasMoreThenTwoParams && <br />} {paramStringArray}) {props.returnType && ( @@ -100,9 +104,10 @@ function renderParameters( docsInfo: DocsInfo, sectionName: string, isInPopover: boolean, + name: string, typeDefinitionByName?: TypeDefinitionByName, ): React.ReactNode[] { - const params = _.map(parameters, (p: Parameter) => { + const params = _.map(parameters, (p: Parameter, i: number) => { const isOptional = p.isOptional; const hasDefaultValue = !_.isUndefined(p.defaultValue); const type = ( @@ -115,9 +120,14 @@ function renderParameters( /> ); return ( - <span key={`param-${p.type}-${p.name}`}> - {p.name} - {isOptional && '?'}: {type} + <span key={`param-${JSON.stringify(p.type)}-${name}-${i}`}> + {!_.isEmpty(p.name) && ( + <span> + {p.name} + {isOptional && '?'}:{' '} + </span> + )} + {type} {hasDefaultValue && ` = ${p.defaultValue}`} </span> ); @@ -134,14 +144,19 @@ function renderTypeParameter( ): React.ReactNode { const typeParam = ( <span> - {`<${typeParameter.name} extends `} - <Type - type={typeParameter.type} - sectionName={sectionName} - typeDefinitionByName={typeDefinitionByName} - docsInfo={docsInfo} - isInPopover={isInPopover} - /> + {`<${typeParameter.name}`} + {!_.isUndefined(typeParameter.type) && ( + <span> + {' extends '} + <Type + type={typeParameter.type} + sectionName={sectionName} + typeDefinitionByName={typeDefinitionByName} + docsInfo={docsInfo} + isInPopover={isInPopover} + /> + </span> + )} {`>`} </span> ); diff --git a/packages/react-docs/src/components/signature_block.tsx b/packages/react-docs/src/components/signature_block.tsx index 05145dc23..5ec82983a 100644 --- a/packages/react-docs/src/components/signature_block.tsx +++ b/packages/react-docs/src/components/signature_block.tsx @@ -1,9 +1,15 @@ import { AnchorTitle, colors, HeaderSizes, Styles } from '@0xproject/react-shared'; +import { + Parameter, + SolidityMethod, + TypeDefinitionByName, + TypescriptFunction, + TypescriptMethod, +} from '@0xproject/types'; import * as _ from 'lodash'; import * as React from 'react'; import { DocsInfo } from '../docs_info'; -import { Parameter, SolidityMethod, TypeDefinitionByName, TypescriptFunction, TypescriptMethod } from '../types'; import { constants } from '../utils/constants'; import { Comment } from './comment'; @@ -26,7 +32,6 @@ export interface SignatureBlockState { const styles: Styles = { chip: { fontSize: 13, - backgroundColor: colors.lightBlueA700, color: colors.white, height: 11, borderRadius: 14, @@ -44,6 +49,8 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu public render(): React.ReactNode { const method = this.props.method; + const isFallback = (method as SolidityMethod).isFallback; + const hasExclusivelyNamedParams = !_.isUndefined(_.find(method.parameters, p => !_.isEmpty(p.name))); return ( <div id={`${this.props.sectionName}-${method.name}`} @@ -57,10 +64,11 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu {(method as TypescriptMethod).isStatic && this._renderChip('Static')} {(method as SolidityMethod).isConstant && this._renderChip('Constant')} {(method as SolidityMethod).isPayable && this._renderChip('Payable')} + {isFallback && this._renderChip('Fallback', colors.lightGreenA700)} <div style={{ lineHeight: 1.3 }}> <AnchorTitle headerSize={HeaderSizes.H3} - title={method.name} + title={isFallback ? '' : method.name} id={`${this.props.sectionName}-${method.name}`} shouldShowAnchor={this.state.shouldShowAnchor} /> @@ -78,6 +86,7 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu typeDefinitionByName={this.props.typeDefinitionByName} docsInfo={this.props.docsInfo} isInPopover={false} + isFallback={isFallback} /> </code> {(method as TypescriptMethod).source && ( @@ -89,12 +98,13 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu )} {method.comment && <Comment comment={method.comment} className="py2" />} {method.parameters && - !_.isEmpty(method.parameters) && ( + !_.isEmpty(method.parameters) && + hasExclusivelyNamedParams && ( <div> <h4 className="pb1 thin" style={{ borderBottom: '1px solid #e1e8ed' }}> ARGUMENTS </h4> - {this._renderParameterDescriptions(method.parameters)} + {this._renderParameterDescriptions(method.parameters, method.name)} </div> )} {method.returnComment && ( @@ -108,19 +118,19 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu </div> ); } - private _renderChip(text: string): React.ReactNode { + private _renderChip(text: string, backgroundColor: string = colors.lightBlueA700): React.ReactNode { return ( - <div className="p1 mr1" style={styles.chip}> + <div className="p1 mr1" style={{ ...styles.chip, backgroundColor }}> {text} </div> ); } - private _renderParameterDescriptions(parameters: Parameter[]): React.ReactNode { - const descriptions = _.map(parameters, parameter => { + private _renderParameterDescriptions(parameters: Parameter[], name: string): React.ReactNode { + const descriptions = _.map(parameters, (parameter: Parameter, i: number) => { const isOptional = parameter.isOptional; return ( <div - key={`param-description-${parameter.name}`} + key={`param-description-${parameter.name}-${name}-${i}`} className="flex pb1 mb2" style={{ borderBottom: '1px solid #f0f4f7' }} > diff --git a/packages/react-docs/src/components/source_link.tsx b/packages/react-docs/src/components/source_link.tsx index c60435ea6..3096ad8d5 100644 --- a/packages/react-docs/src/components/source_link.tsx +++ b/packages/react-docs/src/components/source_link.tsx @@ -1,8 +1,7 @@ import { colors } from '@0xproject/react-shared'; +import { Source } from '@0xproject/types'; import * as React from 'react'; -import { Source } from '../types'; - export interface SourceLinkProps { source: Source; sourceUrl: string; diff --git a/packages/react-docs/src/components/type.tsx b/packages/react-docs/src/components/type.tsx index 5f7601ce1..5c018f5dd 100644 --- a/packages/react-docs/src/components/type.tsx +++ b/packages/react-docs/src/components/type.tsx @@ -1,4 +1,5 @@ import { colors, constants as sharedConstants, utils as sharedUtils } from '@0xproject/react-shared'; +import { Type as TypeDef, TypeDefinitionByName, TypeDocTypes } from '@0xproject/types'; import { errorUtils } from '@0xproject/utils'; import * as _ from 'lodash'; import * as React from 'react'; @@ -6,13 +7,12 @@ import { Link as ScrollLink } from 'react-scroll'; import * as ReactTooltip from 'react-tooltip'; import { DocsInfo } from '../docs_info'; -import { Type as TypeDef, TypeDefinitionByName, TypeDocTypes } from '../types'; -import { constants } from '../utils/constants'; import { Signature } from './signature'; import { TypeDefinition } from './type_definition'; const basicJsTypes = ['string', 'number', 'undefined', 'null', 'boolean']; +const basicSolidityTypes = ['bytes', 'bytes4', 'bytes32', 'uint8', 'uint256', 'address']; const defaultProps = {}; @@ -80,7 +80,7 @@ export const Type: React.SFC<TypeProps> = (props: TypeProps): any => { case TypeDocTypes.Array: typeName = type.elementType.name; - if (_.includes(basicJsTypes, typeName)) { + if (_.includes(basicJsTypes, typeName) || _.includes(basicSolidityTypes, typeName)) { typeNameColor = colors.orange; } break; @@ -168,10 +168,10 @@ export const Type: React.SFC<TypeProps> = (props: TypeProps): any => { break; case TypeDocTypes.Tuple: - const tupleTypes = _.map(type.tupleElements, t => { + const tupleTypes = _.map(type.tupleElements, (t, i) => { return ( <Type - key={`type-tuple-${t.name}-${t.typeDocType}`} + key={`type-tuple-${t.name}-${t.typeDocType}-${i}`} type={t} sectionName={props.sectionName} typeDefinitionByName={props.typeDefinitionByName} @@ -221,7 +221,7 @@ export const Type: React.SFC<TypeProps> = (props: TypeProps): any => { const id = Math.random().toString(); const typeDefinitionAnchorId = isExportedClassReference ? props.type.name - : `${constants.TYPES_SECTION_NAME}-${typeName}`; + : `${props.docsInfo.typeSectionName}-${typeName}`; typeName = ( <ScrollLink to={typeDefinitionAnchorId} diff --git a/packages/react-docs/src/components/type_definition.tsx b/packages/react-docs/src/components/type_definition.tsx index 8d1f88490..9a3e50a1b 100644 --- a/packages/react-docs/src/components/type_definition.tsx +++ b/packages/react-docs/src/components/type_definition.tsx @@ -1,10 +1,11 @@ import { AnchorTitle, colors, HeaderSizes } from '@0xproject/react-shared'; +import { CustomType, CustomTypeChild, TypeDefinitionByName, TypeDocTypes } from '@0xproject/types'; import { errorUtils } from '@0xproject/utils'; import * as _ from 'lodash'; import * as React from 'react'; import { DocsInfo } from '../docs_info'; -import { CustomType, CustomTypeChild, KindString, TypeDefinitionByName, TypeDocTypes } from '../types'; +import { KindString, SupportedDocJson } from '../types'; import { constants } from '../utils/constants'; import { Comment } from './comment'; @@ -45,7 +46,7 @@ export class TypeDefinition extends React.Component<TypeDefinitionProps, TypeDef let codeSnippet: React.ReactNode; switch (customType.kindString) { case KindString.Interface: - typePrefix = 'Interface'; + typePrefix = this.props.docsInfo.type === SupportedDocJson.SolDoc ? 'Struct' : 'Interface'; codeSnippet = ( <Interface type={customType} diff --git a/packages/react-docs/src/docs_info.ts b/packages/react-docs/src/docs_info.ts index dec44458d..092a8c266 100644 --- a/packages/react-docs/src/docs_info.ts +++ b/packages/react-docs/src/docs_info.ts @@ -1,20 +1,15 @@ import { MenuSubsectionsBySection } from '@0xproject/react-shared'; +import { DocAgnosticFormat, TypeDefinitionByName } from '@0xproject/types'; import * as _ from 'lodash'; import { ContractsByVersionByNetworkId, - DocAgnosticFormat, DocsInfoConfig, DocsMenu, - DoxityDocObj, - GeneratedDocJson, SectionNameToMarkdownByVersion, SectionsMap, SupportedDocJson, - TypeDefinitionByName, } from './types'; -import { doxityUtils } from './utils/doxity_utils'; -import { TypeDocUtils } from './utils/typedoc_utils'; export class DocsInfo { public id: string; @@ -23,6 +18,7 @@ export class DocsInfo { public packageName: string; public packageUrl: string; public menu: DocsMenu; + public typeSectionName: string; public sections: SectionsMap; public sectionNameToMarkdownByVersion: SectionNameToMarkdownByVersion; public contractsByVersionByNetworkId?: ContractsByVersionByNetworkId; @@ -33,6 +29,7 @@ export class DocsInfo { this.displayName = config.displayName; this.packageName = config.packageName; this.packageUrl = config.packageUrl; + this.typeSectionName = config.type === SupportedDocJson.SolDoc ? 'structs' : 'types'; this.sections = config.markdownSections; this.sectionNameToMarkdownByVersion = config.sectionNameToMarkdownByVersion; this.contractsByVersionByNetworkId = config.contractsByVersionByNetworkId; @@ -58,7 +55,7 @@ export class DocsInfo { _.isEmpty(docSection.properties) && _.isEmpty(docSection.events); - if (!_.isUndefined(this.sections.types) && sectionName === this.sections.types) { + if (sectionName === this.typeSectionName) { const sortedTypesNames = _.sortBy(docSection.types, 'name'); const typeNames = _.map(sortedTypesNames, t => t.name); menuSubsectionsBySection[sectionName] = typeNames; @@ -87,20 +84,12 @@ export class DocsInfo { return menuSubsectionsBySection; } public getTypeDefinitionsByName(docAgnosticFormat: DocAgnosticFormat): { [name: string]: TypeDefinitionByName } { - if (_.isUndefined(this.sections.types)) { + if (_.isUndefined(docAgnosticFormat[this.typeSectionName])) { return {}; } - const typeDocSection = docAgnosticFormat[this.sections.types]; - const typeDefinitionByName = _.keyBy(typeDocSection.types, 'name') as any; + const section = docAgnosticFormat[this.typeSectionName]; + const typeDefinitionByName = _.keyBy(section.types, 'name') as any; return typeDefinitionByName; } - public convertToDocAgnosticFormat(docObj: DoxityDocObj | GeneratedDocJson): DocAgnosticFormat { - if (this.type === SupportedDocJson.Doxity) { - return doxityUtils.convertToDocAgnosticFormat(docObj as DoxityDocObj); - } else { - const typeDocUtils = new TypeDocUtils(docObj as GeneratedDocJson, this); - return typeDocUtils.convertToDocAgnosticFormat(); - } - } } diff --git a/packages/react-docs/src/index.ts b/packages/react-docs/src/index.ts index e4424f679..f9382940c 100644 --- a/packages/react-docs/src/index.ts +++ b/packages/react-docs/src/index.ts @@ -1,3 +1,5 @@ +export { DocAgnosticFormat, GeneratedDocJson } from '@0xproject/types'; + // Exported to give users of this library added flexibility if they want to build // a docs page from scratch using the individual components. export { Badge } from './components/badge'; @@ -12,17 +14,10 @@ export { Signature } from './components/signature'; export { SourceLink } from './components/source_link'; export { TypeDefinition } from './components/type_definition'; export { Type } from './components/type'; +export { TypeDocUtils } from './utils/typedoc_utils'; export { DocsInfo } from './docs_info'; -export { - DocsInfoConfig, - DocAgnosticFormat, - DoxityDocObj, - DocsMenu, - SupportedDocJson, - TypeDocNode, - GeneratedDocJson, -} from './types'; +export { DocsInfoConfig, DocsMenu, SupportedDocJson } from './types'; export { constants } from './utils/constants'; diff --git a/packages/react-docs/src/types.ts b/packages/react-docs/src/types.ts index f9cb5e26a..153448513 100644 --- a/packages/react-docs/src/types.ts +++ b/packages/react-docs/src/types.ts @@ -22,72 +22,6 @@ export interface SectionsMap { [sectionName: string]: string; } -export interface TypeDocType { - type: TypeDocTypes; - value: string; - name: string; - types: TypeDocType[]; - typeArguments?: TypeDocType[]; - declaration: TypeDocNode; - elementType?: TypeDocType; - indexSignature?: TypeDocNode; - elements?: TupleElement[]; -} - -export interface TupleElement { - type: string; - name: string; -} - -export interface TypeDocFlags { - isStatic?: boolean; - isOptional?: boolean; - isPublic?: boolean; - isExported?: boolean; -} - -export interface TypeDocGroup { - title: string; - children: number[]; -} - -export interface TypeDocNode { - id?: number; - name?: string; - kind?: string; - defaultValue?: string; - kindString?: string; - type?: TypeDocType; - fileName?: string; - line?: number; - comment?: TypeDocNode; - text?: string; - shortText?: string; - returns?: string; - declaration: TypeDocNode; - flags?: TypeDocFlags; - indexSignature?: TypeDocNode; - signatures?: TypeDocNode[]; - parameters?: TypeDocNode[]; - typeParameter?: TypeDocNode[]; - sources?: TypeDocNode[]; - children?: TypeDocNode[]; - groups?: TypeDocGroup[]; -} - -export enum TypeDocTypes { - Intrinsic = 'intrinsic', - Reference = 'reference', - Array = 'array', - StringLiteral = 'stringLiteral', - Reflection = 'reflection', - Union = 'union', - TypeParameter = 'typeParameter', - Intersection = 'intersection', - Tuple = 'tuple', - Unknown = 'unknown', -} - // Exception: We don't make the values uppercase because these KindString's need to // match up those returned by TypeDoc export enum KindString { @@ -103,141 +37,8 @@ export enum KindString { Class = 'Class', } -export interface DocAgnosticFormat { - [sectionName: string]: DocSection; -} - -export interface DocSection { - comment: string; - constructors: Array<TypescriptMethod | SolidityMethod>; - methods: Array<TypescriptMethod | SolidityMethod>; - properties: Property[]; - types: CustomType[]; - functions: TypescriptFunction[]; - events?: Event[]; - externalExportToLink?: ExternalExportToLink; -} - -export interface TypescriptMethod extends BaseMethod { - source?: Source; - isStatic?: boolean; - typeParameter?: TypeParameter; -} - -export interface TypescriptFunction extends BaseFunction { - source?: Source; - typeParameter?: TypeParameter; - callPath: string; -} - -export interface SolidityMethod extends BaseMethod { - isConstant?: boolean; - isPayable?: boolean; -} - -export interface Source { - fileName: string; - line: number; -} - -export interface Parameter { - name: string; - comment: string; - isOptional: boolean; - type: Type; - defaultValue?: string; -} - -export interface TypeParameter { - name: string; - type: Type; -} - -export interface Type { - name: string; - typeDocType: TypeDocTypes; - value?: string; - isExportedClassReference?: boolean; - typeArguments?: Type[]; - elementType?: ElementType; - types?: Type[]; - method?: TypescriptMethod; - indexSignature?: IndexSignature; - externalLink?: string; - tupleElements?: Type[]; -} - -export interface ElementType { - name: string; - typeDocType: TypeDocTypes; -} - -export interface IndexSignature { - keyName: string; - keyType: Type; - valueName: string; -} - -export interface CustomType { - name: string; - kindString: string; - type?: Type; - method?: TypescriptMethod; - indexSignature?: IndexSignature; - defaultValue?: string; - comment?: string; - children?: CustomTypeChild[]; -} - -export interface CustomTypeChild { - name: string; - type?: Type; - defaultValue?: string; -} - -export interface Event { - name: string; - eventArgs: EventArg[]; -} - -export interface EventArg { - isIndexed: boolean; - name: string; - type: Type; -} - -export interface Property { - name: string; - type: Type; - source?: Source; - comment?: string; - callPath?: string; -} - -export interface BaseMethod { - isConstructor: boolean; - name: string; - returnComment?: string | undefined; - callPath: string; - parameters: Parameter[]; - returnType: Type; - comment?: string; -} - -export interface BaseFunction { - name: string; - returnComment?: string | undefined; - parameters: Parameter[]; - returnType: Type; - comment?: string; -} - -export interface TypeDefinitionByName { - [typeName: string]: CustomType; -} - export enum SupportedDocJson { - Doxity = 'DOXITY', + SolDoc = 'SOL_DOC', TypeDoc = 'TYPEDOC', } @@ -249,40 +50,6 @@ export interface ContractsByVersionByNetworkId { }; } -export interface DoxityDocObj { - [contractName: string]: DoxityContractObj; -} - -export interface DoxityContractObj { - title: string; - fileName: string; - name: string; - abiDocs: DoxityAbiDoc[]; -} - -export interface DoxityAbiDoc { - constant: boolean; - inputs: DoxityInput[]; - name: string; - outputs: DoxityOutput[]; - payable: boolean; - type: string; - details?: string; - return?: string; -} - -export interface DoxityOutput { - name: string; - type: string; -} - -export interface DoxityInput { - name: string; - type: string; - description: string; - indexed?: boolean; -} - export interface AddressByContractName { [contractName: string]: string; } @@ -297,28 +64,3 @@ export enum AbiTypes { Function = 'function', Event = 'event', } - -export interface ExportNameToTypedocNames { - [exportName: string]: string[]; -} - -export interface ExternalTypeToLink { - [externalTypeName: string]: string; -} - -export interface ExternalExportToLink { - [externalExport: string]: string; -} - -export interface Metadata { - exportPathToTypedocNames: ExportNameToTypedocNames; - exportPathOrder: string[]; - externalTypeToLink: ExternalTypeToLink; - externalExportToLink: ExternalExportToLink; -} - -export interface GeneratedDocJson { - version: string; - metadata: Metadata; - typedocJson: TypeDocNode; -} diff --git a/packages/react-docs/src/utils/constants.ts b/packages/react-docs/src/utils/constants.ts index 0b08f2c3e..b5b6cc00d 100644 --- a/packages/react-docs/src/utils/constants.ts +++ b/packages/react-docs/src/utils/constants.ts @@ -4,7 +4,7 @@ export const constants = { TYPES_SECTION_NAME: 'types', EXTERNAL_EXPORTS_SECTION_NAME: 'external exports', TYPE_TO_SYNTAX: { - [SupportedDocJson.Doxity]: 'solidity', + [SupportedDocJson.SolDoc]: 'solidity', [SupportedDocJson.TypeDoc]: 'typescript', } as { [supportedDocType: string]: string }, }; diff --git a/packages/react-docs/src/utils/doxity_utils.ts b/packages/react-docs/src/utils/doxity_utils.ts deleted file mode 100644 index 6815daa0c..000000000 --- a/packages/react-docs/src/utils/doxity_utils.ts +++ /dev/null @@ -1,176 +0,0 @@ -import * as _ from 'lodash'; - -import { - AbiTypes, - DocAgnosticFormat, - DocSection, - DoxityAbiDoc, - DoxityContractObj, - DoxityDocObj, - DoxityInput, - EventArg, - Parameter, - Property, - SolidityMethod, - Type, - TypeDocTypes, -} from '../types'; - -export const doxityUtils = { - convertToDocAgnosticFormat(doxityDocObj: DoxityDocObj): DocAgnosticFormat { - const docAgnosticFormat: DocAgnosticFormat = {}; - _.each(doxityDocObj, (doxityContractObj: DoxityContractObj, contractName: string) => { - const doxityConstructor = _.find(doxityContractObj.abiDocs, (abiDoc: DoxityAbiDoc) => { - return abiDoc.type === AbiTypes.Constructor; - }); - const constructors = []; - if (!_.isUndefined(doxityConstructor)) { - const constructor = { - isConstructor: true, - name: doxityContractObj.name, - comment: doxityConstructor.details, - returnComment: doxityConstructor.return, - callPath: '', - parameters: doxityUtils._convertParameters(doxityConstructor.inputs), - returnType: doxityUtils._convertType(doxityContractObj.name), - }; - constructors.push(constructor); - } - - const doxityMethods: DoxityAbiDoc[] = _.filter<DoxityAbiDoc>( - doxityContractObj.abiDocs, - (abiDoc: DoxityAbiDoc) => { - return doxityUtils._isMethod(abiDoc); - }, - ); - const methods: SolidityMethod[] = _.map<DoxityAbiDoc, SolidityMethod>( - doxityMethods, - (doxityMethod: DoxityAbiDoc) => { - const outputs = !_.isUndefined(doxityMethod.outputs) ? doxityMethod.outputs : []; - let returnTypeIfExists: Type; - if (outputs.length === 0) { - // no-op. It's already undefined - } else if (outputs.length === 1) { - const outputsType = outputs[0].type; - returnTypeIfExists = doxityUtils._convertType(outputsType); - } else { - const outputsType = `[${_.map(outputs, output => output.type).join(', ')}]`; - returnTypeIfExists = doxityUtils._convertType(outputsType); - } - // For ZRXToken, we want to convert it to zrxToken, rather then simply zRXToken - const callPath = - contractName !== 'ZRXToken' - ? `${contractName[0].toLowerCase()}${contractName.slice(1)}.` - : `${contractName.slice(0, 3).toLowerCase()}${contractName.slice(3)}.`; - const method = { - isConstructor: false, - isConstant: doxityMethod.constant, - isPayable: doxityMethod.payable, - name: doxityMethod.name, - comment: doxityMethod.details, - returnComment: doxityMethod.return, - callPath, - parameters: doxityUtils._convertParameters(doxityMethod.inputs), - returnType: returnTypeIfExists, - }; - return method; - }, - ); - - const doxityProperties: DoxityAbiDoc[] = _.filter<DoxityAbiDoc>( - doxityContractObj.abiDocs, - (abiDoc: DoxityAbiDoc) => { - return doxityUtils._isProperty(abiDoc); - }, - ); - const properties = _.map<DoxityAbiDoc, Property>(doxityProperties, (doxityProperty: DoxityAbiDoc) => { - // We assume that none of our functions return more then a single return value - let typeName = doxityProperty.outputs[0].type; - if (!_.isEmpty(doxityProperty.inputs)) { - // Properties never have more then a single input - typeName = `(${doxityProperty.inputs[0].type} => ${typeName})`; - } - const property = { - name: doxityProperty.name, - type: doxityUtils._convertType(typeName), - comment: doxityProperty.details, - }; - return property; - }); - - const doxityEvents = _.filter( - doxityContractObj.abiDocs, - (abiDoc: DoxityAbiDoc) => abiDoc.type === AbiTypes.Event, - ); - const events = _.map(doxityEvents, doxityEvent => { - const event = { - name: doxityEvent.name, - eventArgs: doxityUtils._convertEventArgs(doxityEvent.inputs), - }; - return event; - }); - - const docSection: DocSection = { - comment: doxityContractObj.title, - constructors, - methods, - properties, - types: [], - functions: [], - events, - }; - docAgnosticFormat[contractName] = docSection; - }); - return docAgnosticFormat; - }, - _convertParameters(inputs: DoxityInput[]): Parameter[] { - const parameters = _.map(inputs, input => { - const parameter = { - name: input.name, - comment: input.description, - isOptional: false, - type: doxityUtils._convertType(input.type), - }; - return parameter; - }); - return parameters; - }, - _convertType(typeName: string): Type { - const type = { - name: typeName, - typeDocType: TypeDocTypes.Intrinsic, - }; - return type; - }, - _isMethod(abiDoc: DoxityAbiDoc): boolean { - if (abiDoc.type !== AbiTypes.Function) { - return false; - } - const hasInputs = !_.isEmpty(abiDoc.inputs); - const hasNamedOutputIfExists = !hasInputs || !_.isEmpty(abiDoc.inputs[0].name); - const isNameAllCaps = abiDoc.name === abiDoc.name.toUpperCase(); - const isMethod = hasNamedOutputIfExists && !isNameAllCaps; - return isMethod; - }, - _isProperty(abiDoc: DoxityAbiDoc): boolean { - if (abiDoc.type !== AbiTypes.Function) { - return false; - } - const hasInputs = !_.isEmpty(abiDoc.inputs); - const hasNamedOutputIfExists = !hasInputs || !_.isEmpty(abiDoc.inputs[0].name); - const isNameAllCaps = abiDoc.name === abiDoc.name.toUpperCase(); - const isProperty = !hasNamedOutputIfExists || isNameAllCaps; - return isProperty; - }, - _convertEventArgs(inputs: DoxityInput[]): EventArg[] { - const eventArgs = _.map(inputs, input => { - const eventArg = { - isIndexed: input.indexed, - name: input.name, - type: doxityUtils._convertType(input.type), - }; - return eventArg; - }); - return eventArgs; - }, -}; diff --git a/packages/react-docs/src/utils/typedoc_utils.ts b/packages/react-docs/src/utils/typedoc_utils.ts index f44945369..19605d497 100644 --- a/packages/react-docs/src/utils/typedoc_utils.ts +++ b/packages/react-docs/src/utils/typedoc_utils.ts @@ -1,7 +1,3 @@ -import { errorUtils } from '@0xproject/utils'; -import * as _ from 'lodash'; - -import { DocsInfo } from '../docs_info'; import { CustomType, CustomTypeChild, @@ -11,7 +7,6 @@ import { ExternalTypeToLink, GeneratedDocJson, IndexSignature, - KindString, Parameter, Property, Type, @@ -21,7 +16,12 @@ import { TypeParameter, TypescriptFunction, TypescriptMethod, -} from '../types'; +} from '@0xproject/types'; +import { errorUtils } from '@0xproject/utils'; +import * as _ from 'lodash'; + +import { DocsInfo } from '../docs_info'; +import { KindString } from '../types'; import { constants } from './constants'; @@ -419,7 +419,10 @@ export class TypeDocUtils { return func; } private _convertTypeParameter(entity: TypeDocNode, sectionName: string): TypeParameter { - const type = this._convertType(entity.type, sectionName); + let type; + if (!_.isUndefined(entity.type)) { + type = this._convertType(entity.type, sectionName); + } const parameter = { name: entity.name, type, @@ -468,6 +471,8 @@ export class TypeDocUtils { methodIfExists = this._convertMethod(entity.declaration, isConstructor, sectionName); } else if (entity.type === TypeDocTypes.Tuple) { tupleElementsIfExists = _.map(entity.elements, el => { + // the following line is required due to an open tslint issue, https://github.com/palantir/tslint/issues/3540 + // tslint:disable-next-line:no-unnecessary-type-assertion return { name: el.name, typeDocType: el.type as TypeDocTypes }; }); } diff --git a/packages/react-shared/CHANGELOG.json b/packages/react-shared/CHANGELOG.json index 96e2a92f9..1a01527e3 100644 --- a/packages/react-shared/CHANGELOG.json +++ b/packages/react-shared/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "1.0.14", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.0.13", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.0.12", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.0.11", "changes": [ diff --git a/packages/react-shared/CHANGELOG.md b/packages/react-shared/CHANGELOG.md index 09f6066cd..e26a2916e 100644 --- a/packages/react-shared/CHANGELOG.md +++ b/packages/react-shared/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.14 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.13 - _September 28, 2018_ + + * Dependencies updated + +## v1.0.12 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.11 - _September 25, 2018_ * Dependencies updated diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json index 9154c2bb6..95bf849ad 100644 --- a/packages/react-shared/package.json +++ b/packages/react-shared/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/react-shared", - "version": "1.0.11", + "version": "1.0.14", "engines": { "node": ">=6.12" }, @@ -10,6 +10,7 @@ "scripts": { "lint": "tslint --project .", "build": "tsc", + "build:ci": "yarn build", "watch_without_deps": "tsc -w", "clean": "shx rm -rf lib" }, @@ -24,7 +25,7 @@ "url": "https://github.com/0xProject/0x-monorepo.git" }, "devDependencies": { - "@0xproject/dev-utils": "^1.0.9", + "@0xproject/dev-utils": "^1.0.11", "@0xproject/tslint-config": "^1.0.7", "copyfiles": "^2.0.0", "make-promises-safe": "^1.1.0", diff --git a/packages/sol-compiler/CHANGELOG.json b/packages/sol-compiler/CHANGELOG.json index af6897b40..836c34e5f 100644 --- a/packages/sol-compiler/CHANGELOG.json +++ b/packages/sol-compiler/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "1.1.7", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.1.6", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.1.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.1.4", "changes": [ diff --git a/packages/sol-compiler/CHANGELOG.md b/packages/sol-compiler/CHANGELOG.md index 02058b378..21cfaa879 100644 --- a/packages/sol-compiler/CHANGELOG.md +++ b/packages/sol-compiler/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.1.7 - _October 2, 2018_ + + * Dependencies updated + +## v1.1.6 - _September 28, 2018_ + + * Dependencies updated + +## v1.1.5 - _September 25, 2018_ + + * Dependencies updated + ## v1.1.4 - _September 25, 2018_ * Dependencies updated diff --git a/packages/sol-compiler/package.json b/packages/sol-compiler/package.json index 841e2960c..d7e9653e0 100644 --- a/packages/sol-compiler/package.json +++ b/packages/sol-compiler/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sol-compiler", - "version": "1.1.4", + "version": "1.1.6", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build": "yarn pre_build && tsc -b", + "build:ci": "yarn build", "pre_build": "run-s update_contract_fixtures", "update_contract_fixtures": "copyfiles 'test/fixtures/contracts/**/*' ./lib", "test": "yarn run_mocha", @@ -41,7 +42,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-compiler/README.md", "devDependencies": { - "@0xproject/dev-utils": "^1.0.9", + "@0xproject/dev-utils": "^1.0.11", "@0xproject/tslint-config": "^1.0.7", "@types/mkdirp": "^0.5.2", "@types/require-from-string": "^1.2.0", @@ -64,16 +65,16 @@ "zeppelin-solidity": "1.8.0" }, "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/sol-resolver": "^1.0.10", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/assert": "^1.0.12", + "@0xproject/json-schemas": "^1.0.5", + "@0xproject/sol-resolver": "^1.0.12", + "@0xproject/types": "^1.1.2", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", "@types/yargs": "^11.0.0", "chalk": "^2.3.0", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.9", "ethereumjs-util": "^5.1.1", "lodash": "^4.17.5", "mkdirp": "^0.5.1", diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts index 7c76f3e52..a29367485 100644 --- a/packages/sol-compiler/src/compiler.ts +++ b/packages/sol-compiler/src/compiler.ts @@ -10,7 +10,7 @@ import { } from '@0xproject/sol-resolver'; import { fetchAsync, logUtils } from '@0xproject/utils'; import chalk from 'chalk'; -import { CompilerOptions, ContractArtifact, ContractVersionData } from 'ethereum-types'; +import { CompilerOptions, ContractArtifact, ContractVersionData, StandardOutput } from 'ethereum-types'; import * as ethUtil from 'ethereumjs-util'; import * as fs from 'fs'; import * as _ from 'lodash'; @@ -94,7 +94,7 @@ export class Compiler { if (await fsWrapper.doesFileExistAsync(compilerBinFilename)) { solcjs = (await fsWrapper.readFileAsync(compilerBinFilename)).toString(); } else { - logUtils.log(`Downloading ${fullSolcVersion}...`); + logUtils.warn(`Downloading ${fullSolcVersion}...`); const url = `${constants.BASE_COMPILER_URL}${fullSolcVersion}`; const response = await fetchAsync(url); const SUCCESS_STATUS = 200; @@ -110,6 +110,21 @@ export class Compiler { const solcInstance = solc.setupMethods(requireFromString(solcjs, compilerBinFilename)); return { solcInstance, fullSolcVersion }; } + private static _addHexPrefixToContractBytecode(compiledContract: solc.StandardContractOutput): void { + if (!_.isUndefined(compiledContract.evm)) { + if (!_.isUndefined(compiledContract.evm.bytecode) && !_.isUndefined(compiledContract.evm.bytecode.object)) { + compiledContract.evm.bytecode.object = ethUtil.addHexPrefix(compiledContract.evm.bytecode.object); + } + if ( + !_.isUndefined(compiledContract.evm.deployedBytecode) && + !_.isUndefined(compiledContract.evm.deployedBytecode.object) + ) { + compiledContract.evm.deployedBytecode.object = ethUtil.addHexPrefix( + compiledContract.evm.deployedBytecode.object, + ); + } + } + } /** * Instantiates a new instance of the Compiler class. * @param opts Optional compiler options @@ -144,22 +159,40 @@ export class Compiler { public async compileAsync(): Promise<void> { await createDirIfDoesNotExistAsync(this._artifactsDir); await createDirIfDoesNotExistAsync(SOLC_BIN_DIR); - let contractNamesToCompile: string[] = []; + await this._compileContractsAsync(this._getContractNamesToCompile(), true); + } + /** + * Compiles Solidity files specified during instantiation, and returns the + * compiler output given by solc. Return value is an array of outputs: + * Solidity modules are batched together by version required, and each + * element of the returned array corresponds to a compiler version, and + * each element contains the output for all of the modules compiled with + * that version. + */ + public async getCompilerOutputsAsync(): Promise<StandardOutput[]> { + const promisedOutputs = this._compileContractsAsync(this._getContractNamesToCompile(), false); + return promisedOutputs; + } + private _getContractNamesToCompile(): string[] { + let contractNamesToCompile; if (this._specifiedContracts === ALL_CONTRACTS_IDENTIFIER) { const allContracts = this._nameResolver.getAll(); contractNamesToCompile = _.map(allContracts, contractSource => path.basename(contractSource.path, constants.SOLIDITY_FILE_EXTENSION), ); } else { - contractNamesToCompile = this._specifiedContracts; + contractNamesToCompile = this._specifiedContracts.map(specifiedContract => + path.basename(specifiedContract, constants.SOLIDITY_FILE_EXTENSION), + ); } - await this._compileContractsAsync(contractNamesToCompile); + return contractNamesToCompile; } /** - * Compiles contract and saves artifact to artifactsDir. + * Compiles contracts, and, if `shouldPersist` is true, saves artifacts to artifactsDir. * @param fileName Name of contract with '.sol' extension. + * @return an array of compiler outputs, where each element corresponds to a different version of solc-js. */ - private async _compileContractsAsync(contractNames: string[]): Promise<void> { + private async _compileContractsAsync(contractNames: string[], shouldPersist: boolean): Promise<StandardOutput[]> { // batch input contracts together based on the version of the compiler that they require. const versionToInputs: VersionToInputs = {}; @@ -200,10 +233,12 @@ export class Compiler { versionToInputs[solcVersion].contractsToCompile.push(contractSource.path); } + const compilerOutputs: StandardOutput[] = []; + const solcVersions = _.keys(versionToInputs); for (const solcVersion of solcVersions) { const input = versionToInputs[solcVersion]; - logUtils.log( + logUtils.warn( `Compiling ${input.contractsToCompile.length} contracts (${ input.contractsToCompile }) with Solidity v${solcVersion}...`, @@ -212,18 +247,34 @@ export class Compiler { const { solcInstance, fullSolcVersion } = await Compiler._getSolcAsync(solcVersion); const compilerOutput = this._compile(solcInstance, input.standardInput); + compilerOutputs.push(compilerOutput); for (const contractPath of input.contractsToCompile) { - await this._verifyAndPersistCompiledContractAsync( - contractPath, - contractPathToData[contractPath].currentArtifactIfExists, - contractPathToData[contractPath].sourceTreeHashHex, - contractPathToData[contractPath].contractName, - fullSolcVersion, - compilerOutput, - ); + const contractName = contractPathToData[contractPath].contractName; + + const compiledContract = compilerOutput.contracts[contractPath][contractName]; + if (_.isUndefined(compiledContract)) { + throw new Error( + `Contract ${contractName} not found in ${contractPath}. Please make sure your contract has the same name as it's file name`, + ); + } + + Compiler._addHexPrefixToContractBytecode(compiledContract); + + if (shouldPersist) { + await this._persistCompiledContractAsync( + contractPath, + contractPathToData[contractPath].currentArtifactIfExists, + contractPathToData[contractPath].sourceTreeHashHex, + contractName, + fullSolcVersion, + compilerOutput, + ); + } } } + + return compilerOutputs; } private _shouldCompile(contractData: ContractData): boolean { if (_.isUndefined(contractData.currentArtifactIfExists)) { @@ -236,7 +287,7 @@ export class Compiler { return !isUserOnLatestVersion || didCompilerSettingsChange || didSourceChange; } } - private async _verifyAndPersistCompiledContractAsync( + private async _persistCompiledContractAsync( contractPath: string, currentArtifactIfExists: ContractArtifact | void, sourceTreeHashHex: string, @@ -244,32 +295,13 @@ export class Compiler { fullSolcVersion: string, compilerOutput: solc.StandardOutput, ): Promise<void> { - const compiledData = compilerOutput.contracts[contractPath][contractName]; - if (_.isUndefined(compiledData)) { - throw new Error( - `Contract ${contractName} not found in ${contractPath}. Please make sure your contract has the same name as it's file name`, - ); - } - if (!_.isUndefined(compiledData.evm)) { - if (!_.isUndefined(compiledData.evm.bytecode) && !_.isUndefined(compiledData.evm.bytecode.object)) { - compiledData.evm.bytecode.object = ethUtil.addHexPrefix(compiledData.evm.bytecode.object); - } - if ( - !_.isUndefined(compiledData.evm.deployedBytecode) && - !_.isUndefined(compiledData.evm.deployedBytecode.object) - ) { - compiledData.evm.deployedBytecode.object = ethUtil.addHexPrefix( - compiledData.evm.deployedBytecode.object, - ); - } - } - + const compiledContract = compilerOutput.contracts[contractPath][contractName]; const sourceCodes = _.mapValues( compilerOutput.sources, (_1, sourceFilePath) => this._resolver.resolve(sourceFilePath).source, ); const contractVersion: ContractVersionData = { - compilerOutput: compiledData, + compilerOutput: compiledContract, sources: compilerOutput.sources, sourceCodes, sourceTreeHashHex, @@ -299,7 +331,7 @@ export class Compiler { const artifactString = utils.stringifyWithFormatting(newArtifact); const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`; await fsWrapper.writeFileAsync(currentArtifactPath, artifactString); - logUtils.log(`${contractName} artifact saved!`); + logUtils.warn(`${contractName} artifact saved!`); } private _compile(solcInstance: solc.SolcInstance, standardInput: solc.StandardInput): solc.StandardOutput { const compiled: solc.StandardOutput = JSON.parse( @@ -315,13 +347,13 @@ export class Compiler { if (!_.isEmpty(errors)) { errors.forEach(error => { const normalizedErrMsg = getNormalizedErrMsg(error.formattedMessage || error.message); - logUtils.log(chalk.red(normalizedErrMsg)); + logUtils.warn(chalk.red(normalizedErrMsg)); }); throw new Error('Compilation errors encountered'); } else { warnings.forEach(warning => { const normalizedWarningMsg = getNormalizedErrMsg(warning.formattedMessage || warning.message); - logUtils.log(chalk.yellow(normalizedWarningMsg)); + logUtils.warn(chalk.yellow(normalizedWarningMsg)); }); } } diff --git a/packages/sol-compiler/src/index.ts b/packages/sol-compiler/src/index.ts index f8c2b577a..d8a60666f 100644 --- a/packages/sol-compiler/src/index.ts +++ b/packages/sol-compiler/src/index.ts @@ -1,8 +1,29 @@ export { Compiler } from './compiler'; export { + AbiDefinition, CompilerOptions, CompilerSettings, + DataItem, + DevdocOutput, + ErrorSeverity, + ErrorType, + EventAbi, + EventParameter, + EvmBytecodeOutput, + EvmOutput, + FallbackAbi, + FunctionAbi, + MethodAbi, + ConstructorAbi, + ConstructorStateMutability, + ContractAbi, OutputField, CompilerSettingsMetadata, OptimizerSettings, + ParamDescription, + SolcError, + StandardContractOutput, + StandardOutput, + StateMutability, + SourceLocation, } from 'ethereum-types'; diff --git a/packages/sol-compiler/src/utils/compiler.ts b/packages/sol-compiler/src/utils/compiler.ts index c918ed1f3..c153beb0f 100644 --- a/packages/sol-compiler/src/utils/compiler.ts +++ b/packages/sol-compiler/src/utils/compiler.ts @@ -26,7 +26,7 @@ export async function getContractArtifactIfExistsAsync( contractArtifact = JSON.parse(contractArtifactString); return contractArtifact; } catch (err) { - logUtils.log(`Artifact for ${contractName} does not exist`); + logUtils.warn(`Artifact for ${contractName} does not exist`); return undefined; } } @@ -37,7 +37,7 @@ export async function getContractArtifactIfExistsAsync( */ export async function createDirIfDoesNotExistAsync(dirPath: string): Promise<void> { if (!fsWrapper.doesPathExistSync(dirPath)) { - logUtils.log(`Creating directory at ${dirPath}...`); + logUtils.warn(`Creating directory at ${dirPath}...`); await fsWrapper.mkdirpAsync(dirPath); } } diff --git a/packages/sol-cov/CHANGELOG.json b/packages/sol-cov/CHANGELOG.json index ef009b586..334492760 100644 --- a/packages/sol-cov/CHANGELOG.json +++ b/packages/sol-cov/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "2.1.7", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "2.1.6", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "2.1.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "2.1.4", "changes": [ diff --git a/packages/sol-cov/CHANGELOG.md b/packages/sol-cov/CHANGELOG.md index 5dddb1c4d..5c1e61c1f 100644 --- a/packages/sol-cov/CHANGELOG.md +++ b/packages/sol-cov/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.1.7 - _October 2, 2018_ + + * Dependencies updated + +## v2.1.6 - _September 28, 2018_ + + * Dependencies updated + +## v2.1.5 - _September 25, 2018_ + + * Dependencies updated + ## v2.1.4 - _September 25, 2018_ * Dependencies updated diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 63b8f06d5..4711c9770 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sol-cov", - "version": "2.1.4", + "version": "2.1.6", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build": "yarn pre_build && tsc -b", + "build:ci": "yarn build", "pre_build": "run-s copy_test_fixtures", "lint": "tslint --project .", "test": "run-s compile_test run_mocha", @@ -41,13 +42,13 @@ }, "homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md", "dependencies": { - "@0xproject/dev-utils": "^1.0.9", - "@0xproject/sol-compiler": "^1.1.4", - "@0xproject/subproviders": "^2.0.4", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", - "ethereum-types": "^1.0.7", + "@0xproject/dev-utils": "^1.0.11", + "@0xproject/sol-compiler": "^1.1.6", + "@0xproject/subproviders": "^2.0.6", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", + "ethereum-types": "^1.0.9", "ethereumjs-util": "^5.1.1", "glob": "^7.1.2", "istanbul": "^0.4.5", diff --git a/packages/sol-doc/CHANGELOG.json b/packages/sol-doc/CHANGELOG.json new file mode 100644 index 000000000..9d3f4bcde --- /dev/null +++ b/packages/sol-doc/CHANGELOG.json @@ -0,0 +1,30 @@ +[ + { + "timestamp": 1538475601, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "version": "1.0.0", + "changes": [ + { + "note": + "Utility to generate documentation for Solidity smart contracts, outputting a format compliant with @0xproject/types.DocAgnosticFormat", + "pr": 1004 + } + ] + } +] diff --git a/packages/sol-doc/CHANGELOG.md b/packages/sol-doc/CHANGELOG.md new file mode 100644 index 000000000..9f16fb108 --- /dev/null +++ b/packages/sol-doc/CHANGELOG.md @@ -0,0 +1,18 @@ +<!-- +changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly. +Edit the package's CHANGELOG.json file only. +--> + +CHANGELOG + +## v1.0.2 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.1 - _September 28, 2018_ + + * Dependencies updated + +## v1.0.0 - _Invalid date_ + + * Utility to generate documentation for Solidity smart contracts, outputting a format compliant with @0xproject/types.DocAgnosticFormat (#1004) diff --git a/packages/sol-doc/bin/sol-doc.js b/packages/sol-doc/bin/sol-doc.js new file mode 100755 index 000000000..35c9ae735 --- /dev/null +++ b/packages/sol-doc/bin/sol-doc.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +require('../lib/src/cli.js'); diff --git a/packages/sol-doc/coverage/.gitkeep b/packages/sol-doc/coverage/.gitkeep new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/packages/sol-doc/coverage/.gitkeep diff --git a/packages/sol-doc/package.json b/packages/sol-doc/package.json new file mode 100644 index 000000000..0b0c7c963 --- /dev/null +++ b/packages/sol-doc/package.json @@ -0,0 +1,51 @@ +{ + "name": "@0xproject/sol-doc", + "version": "1.0.1", + "description": "Solidity documentation generator", + "main": "lib/src/index.js", + "types": "lib/src/index.d.js", + "scripts": { + "build": "tsc", + "build:ci": "yarn build", + "test": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --timeout 6000 --exit", + "test:circleci": "yarn test:coverage", + "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", + "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", + "lint": "tslint --project . --format stylish", + "clean": "shx rm -rf lib", + "generate-v1-protocol-docs": "(cd ../contracts/src/1.0.0; node ../../../../node_modules/.bin/sol-doc --contracts-dir . --contracts Exchange/Exchange_v1.sol TokenRegistry/TokenRegistry.sol TokenTransferProxy/TokenTransferProxy_v1.sol) > v1.0.0.json", + "generate-v2-protocol-docs": "(cd ../contracts/src/2.0.0; node ../../../../node_modules/.bin/sol-doc --contracts-dir . --contracts Exchange/Exchange.sol AssetProxy/ERC20Proxy.sol AssetProxy/ERC721Proxy.sol OrderValidator/OrderValidator.sol Forwarder/Forwarder.sol AssetProxyOwner/AssetProxyOwner.sol) > v2.0.0.json", + "deploy-v2-protocol-docs": "aws --profile 0xproject s3 cp --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json v2.0.0.json s3://staging-doc-jsons/contracts/", + "deploy-v1-protocol-docs": "aws --profile 0xproject s3 cp --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json v1.0.0.json s3://staging-doc-jsons/contracts/" + }, + "bin": { + "sol-doc": "bin/sol-doc.js" + }, + "repository": "https://github.com/0xProject/0x-monorepo.git", + "author": "F. Eugene Aumson", + "license": "Apache-2.0", + "dependencies": { + "@0xproject/sol-compiler": "^1.1.6", + "@0xproject/types": "^1.1.2", + "@0xproject/utils": "^2.0.0", + "ethereum-types": "^1.0.9", + "ethereumjs-util": "^5.1.1", + "lodash": "^4.17.10", + "yargs": "^12.0.2" + }, + "devDependencies": { + "@0xproject/tslint-config": "^1.0.7", + "chai": "^4.1.2", + "chai-as-promised": "^7.1.0", + "chai-bignumber": "^2.0.2", + "dirty-chai": "^2.0.1", + "make-promises-safe": "^1.1.0", + "mocha": "^5.2.0", + "shx": "^0.2.2", + "source-map-support": "^0.5.0", + "tslint": "5.11.0" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/sol-doc/src/cli.ts b/packages/sol-doc/src/cli.ts new file mode 100644 index 000000000..a1847e868 --- /dev/null +++ b/packages/sol-doc/src/cli.ts @@ -0,0 +1,41 @@ +import 'source-map-support/register'; +import * as yargs from 'yargs'; + +import { logUtils } from '@0xproject/utils'; + +import { SolDoc } from './sol_doc'; + +const JSON_TAB_WIDTH = 4; + +(async () => { + const argv = yargs + .option('contracts-dir', { + type: 'string', + description: 'path of contracts directory to compile', + }) + .option('contracts', { + type: 'string', + description: 'comma separated list of contracts to compile', + }) + .demandOption('contracts-dir') + .array('contracts') + .help().argv; + // Unfortunately, the only way to currently retrieve the declared structs within Solidity contracts + // is to tease them out of the params/return values included in the ABI. These structures do + // not include the structs actual name, so we need a mapping to assign the proper name to a + // struct. If the name is not in this mapping, the structs name will default to the param/return value + // name (which mostly coincide). + const customTypeHashToName: { [hash: string]: string } = { + '52d4a768701076c7bac06e386e430883975eb398732eccba797fd09dd064a60e': 'Order', + '46f7e8c4d144d11a72ce5338458ea37b933500d7a65e740cbca6d16e350eaa48': 'FillResults', + c22239cf0d29df1e6cf1be54f21692a8c0b3a48b9367540d4ffff4608b331ce9: 'OrderInfo', + c21e9ff31a30941c22e1cb43752114bb467c34dea58947f98966c9030fc8e4a9: 'TraderInfo', + '6de3264a1040e027d4bdd29c71e963028238ac4ef060541078a7aced44a4d46f': 'MatchedFillResults', + }; + const solDoc = new SolDoc(); + const doc = await solDoc.generateSolDocAsync(argv.contractsDir, argv.contracts, customTypeHashToName); + process.stdout.write(JSON.stringify(doc, null, JSON_TAB_WIDTH)); +})().catch(err => { + logUtils.warn(err); + process.exit(1); +}); diff --git a/packages/sol-doc/src/index.ts b/packages/sol-doc/src/index.ts new file mode 100644 index 000000000..521668cc8 --- /dev/null +++ b/packages/sol-doc/src/index.ts @@ -0,0 +1 @@ +export { SolDoc } from './sol_doc'; diff --git a/packages/sol-doc/src/sol_doc.ts b/packages/sol-doc/src/sol_doc.ts new file mode 100644 index 000000000..138882c92 --- /dev/null +++ b/packages/sol-doc/src/sol_doc.ts @@ -0,0 +1,500 @@ +import * as path from 'path'; + +import { + AbiDefinition, + ConstructorAbi, + DataItem, + DevdocOutput, + EventAbi, + EventParameter, + FallbackAbi, + MethodAbi, + StandardContractOutput, +} from 'ethereum-types'; +import ethUtil = require('ethereumjs-util'); +import * as _ from 'lodash'; + +import { Compiler, CompilerOptions } from '@0xproject/sol-compiler'; +import { + CustomType, + CustomTypeChild, + DocAgnosticFormat, + DocSection, + Event, + EventArg, + ObjectMap, + Parameter, + SolidityMethod, + Type, + TypeDocTypes, +} from '@0xproject/types'; + +export class SolDoc { + private _customTypeHashToName: ObjectMap<string> | undefined; + private static _genEventDoc(abiDefinition: EventAbi): Event { + const eventDoc: Event = { + name: abiDefinition.name, + eventArgs: SolDoc._genEventArgsDoc(abiDefinition.inputs), + }; + return eventDoc; + } + private static _devdocMethodDetailsIfExist( + methodSignature: string, + devdocIfExists: DevdocOutput | undefined, + ): string | undefined { + let details; + if (!_.isUndefined(devdocIfExists)) { + const devdocMethodsIfExist = devdocIfExists.methods; + if (!_.isUndefined(devdocMethodsIfExist)) { + const devdocMethodIfExists = devdocMethodsIfExist[methodSignature]; + if (!_.isUndefined(devdocMethodIfExists)) { + const devdocMethodDetailsIfExist = devdocMethodIfExists.details; + if (!_.isUndefined(devdocMethodDetailsIfExist)) { + details = devdocMethodDetailsIfExist; + } + } + } + } + return details; + } + private static _genFallbackDoc( + abiDefinition: FallbackAbi, + devdocIfExists: DevdocOutput | undefined, + ): SolidityMethod { + const methodSignature = `()`; + const comment = SolDoc._devdocMethodDetailsIfExist(methodSignature, devdocIfExists); + + const returnComment = + _.isUndefined(devdocIfExists) || _.isUndefined(devdocIfExists.methods[methodSignature]) + ? undefined + : devdocIfExists.methods[methodSignature].return; + + const methodDoc: SolidityMethod = { + isConstructor: false, + name: 'fallback', + callPath: '', + parameters: [], + returnType: { name: 'void', typeDocType: TypeDocTypes.Intrinsic }, + returnComment, + isConstant: true, + isPayable: abiDefinition.payable, + isFallback: true, + comment: _.isEmpty(comment) + ? 'The fallback function. It is executed on a call to the contract if none of the other functions match the given public identifier (or if no data was supplied at all).' + : comment, + }; + return methodDoc; + } + private static _genEventArgsDoc(args: EventParameter[]): EventArg[] { + const eventArgsDoc: EventArg[] = []; + + for (const arg of args) { + const name = arg.name; + + const type: Type = { + name: arg.type, + typeDocType: TypeDocTypes.Intrinsic, + }; + + const eventArgDoc: EventArg = { + isIndexed: arg.indexed, + name, + type, + }; + + eventArgsDoc.push(eventArgDoc); + } + return eventArgsDoc; + } + private static _dedupStructs(customTypes: CustomType[]): CustomType[] { + const uniqueCustomTypes: CustomType[] = []; + const seenTypes: { [hash: string]: boolean } = {}; + _.each(customTypes, customType => { + const hash = SolDoc._generateCustomTypeHash(customType); + if (!seenTypes[hash]) { + uniqueCustomTypes.push(customType); + seenTypes[hash] = true; + } + }); + return uniqueCustomTypes; + } + private static _capitalize(text: string): string { + return `${text.charAt(0).toUpperCase()}${text.slice(1)}`; + } + private static _generateCustomTypeHash(customType: CustomType): string { + const customTypeWithoutName = _.cloneDeep(customType); + delete customTypeWithoutName.name; + const customTypeWithoutNameStr = JSON.stringify(customTypeWithoutName); + const hash = ethUtil.sha256(customTypeWithoutNameStr).toString('hex'); + return hash; + } + private static _makeCompilerOptions(contractsDir: string, contractsToCompile?: string[]): CompilerOptions { + const compilerOptions: CompilerOptions = { + contractsDir, + contracts: '*', + compilerSettings: { + outputSelection: { + ['*']: { + ['*']: ['abi', 'devdoc'], + }, + }, + }, + }; + + const shouldOverrideCatchAllContractsConfig = + !_.isUndefined(contractsToCompile) && contractsToCompile.length > 0; + if (shouldOverrideCatchAllContractsConfig) { + compilerOptions.contracts = contractsToCompile; + } + + return compilerOptions; + } + /** + * Invoke the Solidity compiler and transform its ABI and devdoc outputs into a + * JSON format easily consumed by documentation rendering tools. + * @param contractsToDocument list of contracts for which to generate doc objects + * @param contractsDir the directory in which to find the `contractsToCompile` as well as their dependencies. + * @return doc object for use with documentation generation tools. + */ + public async generateSolDocAsync( + contractsDir: string, + contractsToDocument?: string[], + customTypeHashToName?: ObjectMap<string>, + ): Promise<DocAgnosticFormat> { + this._customTypeHashToName = customTypeHashToName; + const docWithDependencies: DocAgnosticFormat = {}; + const compilerOptions = SolDoc._makeCompilerOptions(contractsDir, contractsToDocument); + const compiler = new Compiler(compilerOptions); + const compilerOutputs = await compiler.getCompilerOutputsAsync(); + let structs: CustomType[] = []; + for (const compilerOutput of compilerOutputs) { + const contractFileNames = _.keys(compilerOutput.contracts); + for (const contractFileName of contractFileNames) { + const contractNameToOutput = compilerOutput.contracts[contractFileName]; + + const contractNames = _.keys(contractNameToOutput); + for (const contractName of contractNames) { + const compiledContract = contractNameToOutput[contractName]; + if (_.isUndefined(compiledContract.abi)) { + throw new Error('compiled contract did not contain ABI output'); + } + docWithDependencies[contractName] = this._genDocSection(compiledContract, contractName); + structs = [...structs, ...this._extractStructs(compiledContract)]; + } + } + } + structs = SolDoc._dedupStructs(structs); + structs = this._overwriteStructNames(structs); + + let doc: DocAgnosticFormat = {}; + if (_.isUndefined(contractsToDocument) || contractsToDocument.length === 0) { + doc = docWithDependencies; + } else { + for (const contractToDocument of contractsToDocument) { + const contractBasename = path.basename(contractToDocument); + const contractName = + contractBasename.lastIndexOf('.sol') === -1 + ? contractBasename + : contractBasename.substring(0, contractBasename.lastIndexOf('.sol')); + doc[contractName] = docWithDependencies[contractName]; + } + } + + if (structs.length > 0) { + doc.structs = { + comment: '', + constructors: [], + methods: [], + properties: [], + types: structs, + functions: [], + events: [], + }; + } + + delete this._customTypeHashToName; // Clean up instance state + return doc; + } + private _getCustomTypeFromDataItem(inputOrOutput: DataItem): CustomType { + const customType: CustomType = { + name: _.capitalize(inputOrOutput.name), + kindString: 'Interface', + children: [], + }; + _.each(inputOrOutput.components, (component: DataItem) => { + const childType = this._getTypeFromDataItem(component); + const customTypeChild = { + name: component.name, + type: childType, + }; + // (fabio): Not sure why this type casting is necessary. Seems TS doesn't + // deduce that `customType.children` cannot be undefined anymore after being + // set to `[]` above. + (customType.children as CustomTypeChild[]).push(customTypeChild); + }); + return customType; + } + private _getNameFromDataItemIfExists(dataItem: DataItem): string | undefined { + if (_.isUndefined(dataItem.components)) { + return undefined; + } + const customType = this._getCustomTypeFromDataItem(dataItem); + const hash = SolDoc._generateCustomTypeHash(customType); + if (_.isUndefined(this._customTypeHashToName) || _.isUndefined(this._customTypeHashToName[hash])) { + return undefined; + } + return this._customTypeHashToName[hash]; + } + private _getTypeFromDataItem(dataItem: DataItem): Type { + const typeDocType = !_.isUndefined(dataItem.components) ? TypeDocTypes.Reference : TypeDocTypes.Intrinsic; + let typeName: string; + if (typeDocType === TypeDocTypes.Reference) { + const nameIfExists = this._getNameFromDataItemIfExists(dataItem); + typeName = _.isUndefined(nameIfExists) ? SolDoc._capitalize(dataItem.name) : nameIfExists; + } else { + typeName = dataItem.type; + } + + const isArrayType = _.endsWith(dataItem.type, '[]'); + let type: Type; + if (isArrayType) { + // tslint:disable-next-line:custom-no-magic-numbers + typeName = typeDocType === TypeDocTypes.Intrinsic ? typeName.slice(0, -2) : typeName; + type = { + elementType: { name: typeName, typeDocType }, + typeDocType: TypeDocTypes.Array, + name: '', + }; + } else { + type = { name: typeName, typeDocType }; + } + return type; + } + private _overwriteStructNames(customTypes: CustomType[]): CustomType[] { + if (_.isUndefined(this._customTypeHashToName)) { + return customTypes; + } + const localCustomTypes = _.cloneDeep(customTypes); + _.each(localCustomTypes, (customType, i) => { + const hash = SolDoc._generateCustomTypeHash(customType); + if (!_.isUndefined(this._customTypeHashToName) && !_.isUndefined(this._customTypeHashToName[hash])) { + localCustomTypes[i].name = this._customTypeHashToName[hash]; + } + }); + return localCustomTypes; + } + private _extractStructs(compiledContract: StandardContractOutput): CustomType[] { + let customTypes: CustomType[] = []; + for (const abiDefinition of compiledContract.abi) { + let types: CustomType[] = []; + switch (abiDefinition.type) { + case 'constructor': { + types = this._getStructsAsCustomTypes(abiDefinition); + break; + } + case 'function': { + types = this._getStructsAsCustomTypes(abiDefinition); + break; + } + case 'event': + case 'fallback': + // No types exist + break; + default: + throw new Error( + `unknown and unsupported AbiDefinition type '${(abiDefinition as AbiDefinition).type}'`, // tslint:disable-line:no-unnecessary-type-assertion + ); + } + customTypes = [...customTypes, ...types]; + } + return customTypes; + } + private _genDocSection(compiledContract: StandardContractOutput, contractName: string): DocSection { + const docSection: DocSection = { + comment: _.isUndefined(compiledContract.devdoc) ? '' : compiledContract.devdoc.title, + constructors: [], + methods: [], + properties: [], + types: [], + functions: [], + events: [], + }; + + for (const abiDefinition of compiledContract.abi) { + switch (abiDefinition.type) { + case 'constructor': + docSection.constructors.push( + this._genConstructorDoc(contractName, abiDefinition, compiledContract.devdoc), + ); + break; + case 'event': + (docSection.events as Event[]).push(SolDoc._genEventDoc(abiDefinition)); + // note that we're not sending devdoc to this._genEventDoc(). + // that's because the type of the events array doesn't have any fields for documentation! + break; + case 'function': + docSection.methods.push(this._genMethodDoc(abiDefinition, compiledContract.devdoc)); + break; + case 'fallback': + docSection.methods.push(SolDoc._genFallbackDoc(abiDefinition, compiledContract.devdoc)); + break; + default: + throw new Error( + `unknown and unsupported AbiDefinition type '${(abiDefinition as AbiDefinition).type}'`, // tslint:disable-line:no-unnecessary-type-assertion + ); + } + } + + return docSection; + } + private _genConstructorDoc( + contractName: string, + abiDefinition: ConstructorAbi, + devdocIfExists: DevdocOutput | undefined, + ): SolidityMethod { + const { parameters, methodSignature } = this._genMethodParamsDoc('', abiDefinition.inputs, devdocIfExists); + + const comment = SolDoc._devdocMethodDetailsIfExist(methodSignature, devdocIfExists); + + const constructorDoc: SolidityMethod = { + isConstructor: true, + name: contractName, + callPath: '', + parameters, + returnType: { name: contractName, typeDocType: TypeDocTypes.Reference }, // sad we have to specify this + isConstant: false, + isPayable: abiDefinition.payable, + comment, + }; + + return constructorDoc; + } + private _genMethodDoc(abiDefinition: MethodAbi, devdocIfExists: DevdocOutput | undefined): SolidityMethod { + const name = abiDefinition.name; + const { parameters, methodSignature } = this._genMethodParamsDoc(name, abiDefinition.inputs, devdocIfExists); + const devDocComment = SolDoc._devdocMethodDetailsIfExist(methodSignature, devdocIfExists); + const returnType = this._genMethodReturnTypeDoc(abiDefinition.outputs); + const returnComment = + _.isUndefined(devdocIfExists) || _.isUndefined(devdocIfExists.methods[methodSignature]) + ? undefined + : devdocIfExists.methods[methodSignature].return; + + const hasNoNamedParameters = _.isUndefined(_.find(parameters, p => !_.isEmpty(p.name))); + const isGeneratedGetter = hasNoNamedParameters; + const comment = + _.isEmpty(devDocComment) && isGeneratedGetter + ? `This is an auto-generated accessor method of the '${name}' contract instance variable.` + : devDocComment; + const methodDoc: SolidityMethod = { + isConstructor: false, + name, + callPath: '', + parameters, + returnType, + returnComment, + isConstant: abiDefinition.constant, + isPayable: abiDefinition.payable, + comment, + }; + return methodDoc; + } + /** + * Extract documentation for each method parameter from @param params. + */ + private _genMethodParamsDoc( + name: string, + abiParams: DataItem[], + devdocIfExists: DevdocOutput | undefined, + ): { parameters: Parameter[]; methodSignature: string } { + const parameters: Parameter[] = []; + for (const abiParam of abiParams) { + const type = this._getTypeFromDataItem(abiParam); + + const parameter: Parameter = { + name: abiParam.name, + comment: '<No comment>', + isOptional: false, // Unsupported in Solidity, until resolution of https://github.com/ethereum/solidity/issues/232 + type, + }; + parameters.push(parameter); + } + + const methodSignature = `${name}(${abiParams + .map(abiParam => { + if (!_.startsWith(abiParam.type, 'tuple')) { + return abiParam.type; + } else { + // Need to expand tuples: + // E.g: fillOrder(tuple,uint256,bytes) -> fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes) + const isArray = _.endsWith(abiParam.type, '[]'); + const expandedTypes = _.map(abiParam.components, c => c.type); + const type = `(${expandedTypes.join(',')})${isArray ? '[]' : ''}`; + return type; + } + }) + .join(',')})`; + + if (!_.isUndefined(devdocIfExists)) { + const devdocMethodIfExists = devdocIfExists.methods[methodSignature]; + if (!_.isUndefined(devdocMethodIfExists)) { + const devdocParamsIfExist = devdocMethodIfExists.params; + if (!_.isUndefined(devdocParamsIfExist)) { + for (const parameter of parameters) { + parameter.comment = devdocParamsIfExist[parameter.name]; + } + } + } + } + + return { parameters, methodSignature }; + } + private _genMethodReturnTypeDoc(outputs: DataItem[]): Type { + let type: Type; + if (outputs.length > 1) { + type = { + name: '', + typeDocType: TypeDocTypes.Tuple, + tupleElements: [], + }; + for (const output of outputs) { + const tupleType = this._getTypeFromDataItem(output); + (type.tupleElements as Type[]).push(tupleType); + } + return type; + } else if (outputs.length === 1) { + const output = outputs[0]; + type = this._getTypeFromDataItem(output); + } else { + type = { + name: 'void', + typeDocType: TypeDocTypes.Intrinsic, + }; + } + return type; + } + private _getStructsAsCustomTypes(abiDefinition: AbiDefinition): CustomType[] { + const customTypes: CustomType[] = []; + // We cast to `any` here because we do not know yet if this type of abiDefinition contains + // an `input` key + if (!_.isUndefined((abiDefinition as any).inputs)) { + const methodOrConstructorAbi = abiDefinition as MethodAbi | ConstructorAbi; + _.each(methodOrConstructorAbi.inputs, input => { + if (!_.isUndefined(input.components)) { + const customType = this._getCustomTypeFromDataItem(input); + customTypes.push(customType); + } + }); + } + if (!_.isUndefined((abiDefinition as any).outputs)) { + const methodAbi = abiDefinition as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion + _.each(methodAbi.outputs, output => { + if (!_.isUndefined(output.components)) { + const customType = this._getCustomTypeFromDataItem(output); + customTypes.push(customType); + } + }); + } + return customTypes; + } +} +// tslint:disable:max-file-line-count diff --git a/packages/sol-doc/test/fixtures/contracts/MultipleReturnValues.sol b/packages/sol-doc/test/fixtures/contracts/MultipleReturnValues.sol new file mode 100644 index 000000000..1e898622c --- /dev/null +++ b/packages/sol-doc/test/fixtures/contracts/MultipleReturnValues.sol @@ -0,0 +1,7 @@ +pragma solidity ^0.4.24; + +contract MultipleReturnValues { + function methodWithMultipleReturnValues() public pure returns(int, int) { + return (0, 0); + } +} diff --git a/packages/sol-doc/test/fixtures/contracts/NatspecEverything.sol b/packages/sol-doc/test/fixtures/contracts/NatspecEverything.sol new file mode 100644 index 000000000..c6ad3db81 --- /dev/null +++ b/packages/sol-doc/test/fixtures/contracts/NatspecEverything.sol @@ -0,0 +1,40 @@ +pragma solidity ^0.4.24; + +/// @title Contract Title +/// @dev This is a very long documentation comment at the contract level. +/// It actually spans multiple lines, too. +contract NatspecEverything { + int d; + + /// @dev Constructor @dev + /// @param p Constructor @param + constructor(int p) public { d = p; } + + /// @notice publicMethod @notice + /// @dev publicMethod @dev + /// @param p publicMethod @param + /// @return publicMethod @return + function publicMethod(int p) public pure returns(int r) { return p; } + + /// @dev Fallback @dev + function () public {} + + /// @notice externalMethod @notice + /// @dev externalMethod @dev + /// @param p externalMethod @param + /// @return externalMethod @return + function externalMethod(int p) external pure returns(int r) { return p; } + + /// @dev Here is a really long developer documentation comment, which spans + /// multiple lines, for the purposes of making sure that broken lines are + /// consolidated into one devdoc comment. + function methodWithLongDevdoc(int p) public pure returns(int) { return p; } + + /// @dev AnEvent @dev + /// @param p on this event is an integer. + event AnEvent(int p); + + /// @dev methodWithSolhintDirective @dev + // solhint-disable no-empty-blocks + function methodWithSolhintDirective() public pure {} +} diff --git a/packages/sol-doc/test/fixtures/contracts/StructParamAndReturn.sol b/packages/sol-doc/test/fixtures/contracts/StructParamAndReturn.sol new file mode 100644 index 000000000..b9a7ccdbc --- /dev/null +++ b/packages/sol-doc/test/fixtures/contracts/StructParamAndReturn.sol @@ -0,0 +1,18 @@ +pragma solidity 0.4.24; +pragma experimental ABIEncoderV2; + + +contract StructParamAndReturn { + + struct Stuff { + address anAddress; + uint256 aNumber; + } + + /// @dev DEV_COMMENT + /// @param stuff STUFF_COMMENT + /// @return RETURN_COMMENT + function methodWithStructParamAndReturn(Stuff stuff) public pure returns(Stuff) { + return stuff; + } +} diff --git a/packages/sol-doc/test/fixtures/contracts/TokenTransferProxy.sol b/packages/sol-doc/test/fixtures/contracts/TokenTransferProxy.sol new file mode 100644 index 000000000..44570d459 --- /dev/null +++ b/packages/sol-doc/test/fixtures/contracts/TokenTransferProxy.sol @@ -0,0 +1,115 @@ +/* + + Copyright 2018 ZeroEx Intl. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +pragma solidity ^0.4.14; + +import { Ownable } from "zeppelin-solidity/contracts/ownership/Ownable.sol"; +import { ERC20 as Token } from "zeppelin-solidity/contracts/token/ERC20/ERC20.sol"; + +/// @title TokenTransferProxy - Transfers tokens on behalf of contracts that have been approved via decentralized governance. +/// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com> +contract TokenTransferProxy is Ownable { + + /// @dev Only authorized addresses can invoke functions with this modifier. + modifier onlyAuthorized { + require(authorized[msg.sender]); + _; + } + + modifier targetAuthorized(address target) { + require(authorized[target]); + _; + } + + modifier targetNotAuthorized(address target) { + require(!authorized[target]); + _; + } + + mapping (address => bool) public authorized; + address[] public authorities; + + event LogAuthorizedAddressAdded(address indexed target, address indexed caller); + event LogAuthorizedAddressRemoved(address indexed target, address indexed caller); + + /* + * Public functions + */ + + /// @dev Authorizes an address. + /// @param target Address to authorize. + function addAuthorizedAddress(address target) + public + onlyOwner + targetNotAuthorized(target) + { + authorized[target] = true; + authorities.push(target); + LogAuthorizedAddressAdded(target, msg.sender); + } + + /// @dev Removes authorizion of an address. + /// @param target Address to remove authorization from. + function removeAuthorizedAddress(address target) + public + onlyOwner + targetAuthorized(target) + { + delete authorized[target]; + for (uint i = 0; i < authorities.length; i++) { + if (authorities[i] == target) { + authorities[i] = authorities[authorities.length - 1]; + authorities.length -= 1; + break; + } + } + LogAuthorizedAddressRemoved(target, msg.sender); + } + + /// @dev Calls into ERC20 Token contract, invoking transferFrom. + /// @param token Address of token to transfer. + /// @param from Address to transfer token from. + /// @param to Address to transfer token to. + /// @param value Amount of token to transfer. + /// @return Success of transfer. + function transferFrom( + address token, + address from, + address to, + uint value) + public + onlyAuthorized + returns (bool) + { + return Token(token).transferFrom(from, to, value); + } + + /* + * Public constant functions + */ + + /// @dev Gets all authorized addresses. + /// @return Array of authorized addresses. + function getAuthorizedAddresses() + public + constant + returns (address[]) + { + return authorities; + } +} diff --git a/packages/sol-doc/test/fixtures/contracts/TokenTransferProxyNoDevdoc.sol b/packages/sol-doc/test/fixtures/contracts/TokenTransferProxyNoDevdoc.sol new file mode 100644 index 000000000..cc45a79e9 --- /dev/null +++ b/packages/sol-doc/test/fixtures/contracts/TokenTransferProxyNoDevdoc.sol @@ -0,0 +1,100 @@ +/* + + Copyright 2018 ZeroEx Intl. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ + +pragma solidity ^0.4.14; + +import { Ownable } from "zeppelin-solidity/contracts/ownership/Ownable.sol"; +import { ERC20 as Token } from "zeppelin-solidity/contracts/token/ERC20/ERC20.sol"; + +contract TokenTransferProxyNoDevdoc is Ownable { + + modifier onlyAuthorized { + require(authorized[msg.sender]); + _; + } + + modifier targetAuthorized(address target) { + require(authorized[target]); + _; + } + + modifier targetNotAuthorized(address target) { + require(!authorized[target]); + _; + } + + mapping (address => bool) public authorized; + address[] public authorities; + + event LogAuthorizedAddressAdded(address indexed target, address indexed caller); + event LogAuthorizedAddressRemoved(address indexed target, address indexed caller); + + /* + * Public functions + */ + + function addAuthorizedAddress(address target) + public + onlyOwner + targetNotAuthorized(target) + { + authorized[target] = true; + authorities.push(target); + LogAuthorizedAddressAdded(target, msg.sender); + } + + function removeAuthorizedAddress(address target) + public + onlyOwner + targetAuthorized(target) + { + delete authorized[target]; + for (uint i = 0; i < authorities.length; i++) { + if (authorities[i] == target) { + authorities[i] = authorities[authorities.length - 1]; + authorities.length -= 1; + break; + } + } + LogAuthorizedAddressRemoved(target, msg.sender); + } + + function transferFrom( + address token, + address from, + address to, + uint value) + public + onlyAuthorized + returns (bool) + { + return Token(token).transferFrom(from, to, value); + } + + /* + * Public constant functions + */ + + function getAuthorizedAddresses() + public + constant + returns (address[]) + { + return authorities; + } +} diff --git a/packages/sol-doc/test/solidity_doc_generator_test.ts b/packages/sol-doc/test/solidity_doc_generator_test.ts new file mode 100644 index 000000000..f166fb143 --- /dev/null +++ b/packages/sol-doc/test/solidity_doc_generator_test.ts @@ -0,0 +1,273 @@ +import * as _ from 'lodash'; + +import * as chai from 'chai'; +import 'mocha'; + +import { DocAgnosticFormat, Event, SolidityMethod } from '@0xproject/types'; + +import { SolDoc } from '../src/sol_doc'; + +import { chaiSetup } from './util/chai_setup'; + +chaiSetup.configure(); +const expect = chai.expect; +const solDoc = new SolDoc(); + +describe('#SolidityDocGenerator', () => { + it('should generate a doc object that matches the devdoc-free TokenTransferProxy fixture', async () => { + const doc = await solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, [ + 'TokenTransferProxyNoDevdoc', + ]); + expect(doc).to.not.be.undefined(); + + verifyTokenTransferProxyABIIsDocumented(doc, 'TokenTransferProxyNoDevdoc'); + }); + const docPromises: Array<Promise<DocAgnosticFormat>> = [ + solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`), + solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, []), + ]; + docPromises.forEach(docPromise => { + it('should generate a doc object that matches the TokenTransferProxy fixture with its dependencies', async () => { + const doc = await docPromise; + expect(doc).to.not.be.undefined(); + + verifyTokenTransferProxyAndDepsABIsAreDocumented(doc, 'TokenTransferProxy'); + + let addAuthorizedAddressMethod: SolidityMethod | undefined; + for (const method of doc.TokenTransferProxy.methods) { + if (method.name === 'addAuthorizedAddress') { + addAuthorizedAddressMethod = method; + } + } + const tokenTransferProxyAddAuthorizedAddressComment = 'Authorizes an address.'; + expect((addAuthorizedAddressMethod as SolidityMethod).comment).to.equal( + tokenTransferProxyAddAuthorizedAddressComment, + ); + + const expectedParamComment = 'Address to authorize.'; + expect((addAuthorizedAddressMethod as SolidityMethod).parameters[0].comment).to.equal(expectedParamComment); + }); + }); + it('should generate a doc object that matches the TokenTransferProxy fixture', async () => { + const doc: DocAgnosticFormat = await solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, [ + 'TokenTransferProxy', + ]); + verifyTokenTransferProxyABIIsDocumented(doc, 'TokenTransferProxy'); + }); + describe('when processing all the permutations of devdoc stuff that we use in our contracts', () => { + let doc: DocAgnosticFormat; + before(async () => { + doc = await solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, ['NatspecEverything']); + expect(doc).to.not.be.undefined(); + expect(doc.NatspecEverything).to.not.be.undefined(); + }); + it('should emit the contract @title as its comment', () => { + expect(doc.NatspecEverything.comment).to.equal('Contract Title'); + }); + describe('should emit public method documentation for', () => { + let methodDoc: SolidityMethod; + before(() => { + // tslint:disable-next-line:no-unnecessary-type-assertion + methodDoc = doc.NatspecEverything.methods.find(method => { + return method.name === 'publicMethod'; + }) as SolidityMethod; + if (_.isUndefined(methodDoc)) { + throw new Error('publicMethod not found'); + } + }); + it('method name', () => { + expect(methodDoc.name).to.equal('publicMethod'); + }); + it('method comment', () => { + expect(methodDoc.comment).to.equal('publicMethod @dev'); + }); + it('parameter name', () => { + expect(methodDoc.parameters[0].name).to.equal('p'); + }); + it('parameter comment', () => { + expect(methodDoc.parameters[0].comment).to.equal('publicMethod @param'); + }); + it('return type', () => { + expect(methodDoc.returnType.name).to.equal('int256'); + }); + it('return comment', () => { + expect(methodDoc.returnComment).to.equal('publicMethod @return'); + }); + }); + describe('should emit external method documentation for', () => { + let methodDoc: SolidityMethod; + before(() => { + // tslint:disable-next-line:no-unnecessary-type-assertion + methodDoc = doc.NatspecEverything.methods.find(method => { + return method.name === 'externalMethod'; + }) as SolidityMethod; + if (_.isUndefined(methodDoc)) { + throw new Error('externalMethod not found'); + } + }); + it('method name', () => { + expect(methodDoc.name).to.equal('externalMethod'); + }); + it('method comment', () => { + expect(methodDoc.comment).to.equal('externalMethod @dev'); + }); + it('parameter name', () => { + expect(methodDoc.parameters[0].name).to.equal('p'); + }); + it('parameter comment', () => { + expect(methodDoc.parameters[0].comment).to.equal('externalMethod @param'); + }); + it('return type', () => { + expect(methodDoc.returnType.name).to.equal('int256'); + }); + it('return comment', () => { + expect(methodDoc.returnComment).to.equal('externalMethod @return'); + }); + }); + it('should not truncate a multi-line devdoc comment', () => { + // tslint:disable-next-line:no-unnecessary-type-assertion + const methodDoc: SolidityMethod = doc.NatspecEverything.methods.find(method => { + return method.name === 'methodWithLongDevdoc'; + }) as SolidityMethod; + if (_.isUndefined(methodDoc)) { + throw new Error('methodWithLongDevdoc not found'); + } + expect(methodDoc.comment).to.equal( + 'Here is a really long developer documentation comment, which spans multiple lines, for the purposes of making sure that broken lines are consolidated into one devdoc comment.', + ); + }); + describe('should emit event documentation for', () => { + let eventDoc: Event; + before(() => { + eventDoc = (doc.NatspecEverything.events as Event[])[0]; + }); + it('event name', () => { + expect(eventDoc.name).to.equal('AnEvent'); + }); + it('parameter name', () => { + expect(eventDoc.eventArgs[0].name).to.equal('p'); + }); + }); + it('should not let solhint directives obscure natspec content', () => { + // tslint:disable-next-line:no-unnecessary-type-assertion + const methodDoc: SolidityMethod = doc.NatspecEverything.methods.find(method => { + return method.name === 'methodWithSolhintDirective'; + }) as SolidityMethod; + if (_.isUndefined(methodDoc)) { + throw new Error('methodWithSolhintDirective not found'); + } + expect(methodDoc.comment).to.equal('methodWithSolhintDirective @dev'); + }); + }); + it('should document a method that returns multiple values', async () => { + const doc = await solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, [ + 'MultipleReturnValues', + ]); + expect(doc.MultipleReturnValues).to.not.be.undefined(); + expect(doc.MultipleReturnValues.methods).to.not.be.undefined(); + let methodWithMultipleReturnValues: SolidityMethod | undefined; + for (const method of doc.MultipleReturnValues.methods) { + if (method.name === 'methodWithMultipleReturnValues') { + methodWithMultipleReturnValues = method; + } + } + if (_.isUndefined(methodWithMultipleReturnValues)) { + throw new Error('method should not be undefined'); + } + const returnType = methodWithMultipleReturnValues.returnType; + expect(returnType.typeDocType).to.equal('tuple'); + if (_.isUndefined(returnType.tupleElements)) { + throw new Error('returnType.tupleElements should not be undefined'); + } + expect(returnType.tupleElements.length).to.equal(2); + }); + it('should document a method that has a struct param and return value', async () => { + const doc = await solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, [ + 'StructParamAndReturn', + ]); + expect(doc.StructParamAndReturn).to.not.be.undefined(); + expect(doc.StructParamAndReturn.methods).to.not.be.undefined(); + let methodWithStructParamAndReturn: SolidityMethod | undefined; + for (const method of doc.StructParamAndReturn.methods) { + if (method.name === 'methodWithStructParamAndReturn') { + methodWithStructParamAndReturn = method; + } + } + if (_.isUndefined(methodWithStructParamAndReturn)) { + throw new Error('method should not be undefined'); + } + /** + * Solc maps devDoc comments to methods using a method signature. If we incorrectly + * generate the methodSignatures, the devDoc comments won't be correctly associated + * with their methods and they won't show up in the output. By checking that the comments + * are included for a method with structs as params/returns, we are sure that the methodSignature + * generation is correct for this case. + */ + expect(methodWithStructParamAndReturn.comment).to.be.equal('DEV_COMMENT'); + expect(methodWithStructParamAndReturn.returnComment).to.be.equal('RETURN_COMMENT'); + expect(methodWithStructParamAndReturn.parameters[0].comment).to.be.equal('STUFF_COMMENT'); + }); + it('should document the structs included in a contract', async () => { + const doc = await solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, [ + 'StructParamAndReturn', + ]); + expect(doc.structs).to.not.be.undefined(); + expect(doc.structs.types.length).to.be.equal(1); + }); +}); + +function verifyTokenTransferProxyABIIsDocumented(doc: DocAgnosticFormat, contractName: string): void { + expect(doc[contractName]).to.not.be.undefined(); + expect(doc[contractName].constructors).to.not.be.undefined(); + const tokenTransferProxyConstructorCount = 0; + const tokenTransferProxyMethodCount = 8; + const tokenTransferProxyEventCount = 3; + expect(doc[contractName].constructors.length).to.equal(tokenTransferProxyConstructorCount); + expect(doc[contractName].methods.length).to.equal(tokenTransferProxyMethodCount); + const events = doc[contractName].events; + if (_.isUndefined(events)) { + throw new Error('events should never be undefined'); + } + expect(events.length).to.equal(tokenTransferProxyEventCount); +} + +function verifyTokenTransferProxyAndDepsABIsAreDocumented(doc: DocAgnosticFormat, contractName: string): void { + verifyTokenTransferProxyABIIsDocumented(doc, contractName); + + expect(doc.ERC20).to.not.be.undefined(); + expect(doc.ERC20.constructors).to.not.be.undefined(); + expect(doc.ERC20.methods).to.not.be.undefined(); + const erc20ConstructorCount = 0; + const erc20MethodCount = 6; + const erc20EventCount = 2; + expect(doc.ERC20.constructors.length).to.equal(erc20ConstructorCount); + expect(doc.ERC20.methods.length).to.equal(erc20MethodCount); + if (_.isUndefined(doc.ERC20.events)) { + throw new Error('events should never be undefined'); + } + expect(doc.ERC20.events.length).to.equal(erc20EventCount); + + expect(doc.ERC20Basic).to.not.be.undefined(); + expect(doc.ERC20Basic.constructors).to.not.be.undefined(); + expect(doc.ERC20Basic.methods).to.not.be.undefined(); + const erc20BasicConstructorCount = 0; + const erc20BasicMethodCount = 3; + const erc20BasicEventCount = 1; + expect(doc.ERC20Basic.constructors.length).to.equal(erc20BasicConstructorCount); + expect(doc.ERC20Basic.methods.length).to.equal(erc20BasicMethodCount); + if (_.isUndefined(doc.ERC20Basic.events)) { + throw new Error('events should never be undefined'); + } + expect(doc.ERC20Basic.events.length).to.equal(erc20BasicEventCount); + + let addAuthorizedAddressMethod: SolidityMethod | undefined; + for (const method of doc[contractName].methods) { + if (method.name === 'addAuthorizedAddress') { + addAuthorizedAddressMethod = method; + } + } + expect( + addAuthorizedAddressMethod, + `method addAuthorizedAddress not found in ${JSON.stringify(doc[contractName].methods)}`, + ).to.not.be.undefined(); +} diff --git a/packages/sol-doc/test/util/chai_setup.ts b/packages/sol-doc/test/util/chai_setup.ts new file mode 100644 index 000000000..1a8733093 --- /dev/null +++ b/packages/sol-doc/test/util/chai_setup.ts @@ -0,0 +1,13 @@ +import * as chai from 'chai'; +import chaiAsPromised = require('chai-as-promised'); +import ChaiBigNumber = require('chai-bignumber'); +import * as dirtyChai from 'dirty-chai'; + +export const chaiSetup = { + configure(): void { + chai.config.includeStack = true; + chai.use(ChaiBigNumber()); + chai.use(dirtyChai); + chai.use(chaiAsPromised); + }, +}; diff --git a/packages/sol-doc/tsconfig.json b/packages/sol-doc/tsconfig.json new file mode 100644 index 000000000..2ee711adc --- /dev/null +++ b/packages/sol-doc/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": "." + }, + "include": ["./src/**/*", "./test/**/*"] +} diff --git a/packages/sol-doc/tslint.json b/packages/sol-doc/tslint.json new file mode 100644 index 000000000..ffaefe83a --- /dev/null +++ b/packages/sol-doc/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": ["@0xproject/tslint-config"] +} diff --git a/packages/sol-resolver/CHANGELOG.json b/packages/sol-resolver/CHANGELOG.json index ee439c2d0..6b0df115b 100644 --- a/packages/sol-resolver/CHANGELOG.json +++ b/packages/sol-resolver/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "1.0.13", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.0.12", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.0.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.0.10", "changes": [ diff --git a/packages/sol-resolver/CHANGELOG.md b/packages/sol-resolver/CHANGELOG.md index 53354f4ef..22c378c92 100644 --- a/packages/sol-resolver/CHANGELOG.md +++ b/packages/sol-resolver/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.13 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.12 - _September 28, 2018_ + + * Dependencies updated + +## v1.0.11 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.10 - _September 25, 2018_ * Dependencies updated diff --git a/packages/sol-resolver/package.json b/packages/sol-resolver/package.json index caf7df3aa..a91abaf42 100644 --- a/packages/sol-resolver/package.json +++ b/packages/sol-resolver/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sol-resolver", - "version": "1.0.10", + "version": "1.0.13", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "types": "lib/index.d.ts", "scripts": { "build": "tsc -b", + "build:ci": "yarn build", "clean": "shx rm -rf lib", "lint": "tslint --project ." }, @@ -30,8 +31,8 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/types": "^1.1.2", + "@0xproject/typescript-typings": "^3.0.0", "lodash": "^4.17.5" }, "publishConfig": { diff --git a/packages/sra-report/CHANGELOG.json b/packages/sra-report/CHANGELOG.json index 006965b01..7b23b1889 100644 --- a/packages/sra-report/CHANGELOG.json +++ b/packages/sra-report/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "1.0.13", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.0.12", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.0.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.0.10", "changes": [ diff --git a/packages/sra-report/CHANGELOG.md b/packages/sra-report/CHANGELOG.md index 298ea66ec..ca2b884bd 100644 --- a/packages/sra-report/CHANGELOG.md +++ b/packages/sra-report/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.13 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.12 - _September 28, 2018_ + + * Dependencies updated + +## v1.0.11 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.10 - _September 25, 2018_ * Dependencies updated diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json index c916765e2..0b6f9896b 100644 --- a/packages/sra-report/package.json +++ b/packages/sra-report/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sra-report", - "version": "1.0.10", + "version": "1.0.12", "engines": { "node": ">=6.12" }, @@ -10,6 +10,7 @@ "scripts": { "clean": "shx rm -rf lib", "build": "tsc -b", + "build:ci": "yarn build", "lint": "tslint --project .", "test:circleci": "yarn test:coverage", "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", @@ -33,13 +34,13 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-report/README.md", "dependencies": { - "@0xproject/assert": "^1.0.10", + "@0xproject/assert": "^1.0.12", "@0xproject/connect": "1.0.4", "@0xproject/json-schemas": "^0.8.3", "@0xproject/order-utils": "^0.0.9", "@0xproject/types": "^0.8.2", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", "chalk": "^2.3.0", "lodash": "^4.17.5", "newman": "^3.9.3", diff --git a/packages/sra-spec/CHANGELOG.json b/packages/sra-spec/CHANGELOG.json index a4a1fe8ff..0af03193a 100644 --- a/packages/sra-spec/CHANGELOG.json +++ b/packages/sra-spec/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "1.0.6", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.0.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.0.3", "changes": [ diff --git a/packages/sra-spec/CHANGELOG.md b/packages/sra-spec/CHANGELOG.md index e279d517f..67790563e 100644 --- a/packages/sra-spec/CHANGELOG.md +++ b/packages/sra-spec/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.6 - _October 2, 2018_ + + * Dependencies updated + +## v1.0.5 - _September 28, 2018_ + + * Dependencies updated + +## v1.0.4 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.3 - _September 25, 2018_ * Dependencies updated diff --git a/packages/sra-spec/package.json b/packages/sra-spec/package.json index 0c5131848..5b4bc821e 100644 --- a/packages/sra-spec/package.json +++ b/packages/sra-spec/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/sra-spec", - "version": "1.0.3", + "version": "1.0.5", "engines": { "node": ">=6.12" }, @@ -9,7 +9,7 @@ "types": "lib/src/index.d.ts", "scripts": { "serve": "redoc-cli serve lib/api.json --watch", - "watch_without_deps": "run-p build-json:watch serve", + "watch_without_deps": "run-p build:watch serve", "lint": "tslint --project .", "test": "swagger-cli validate lib/api.json", "rebuild_and_test": "run-s clean build test", @@ -18,8 +18,9 @@ "test:circleci": "yarn test:coverage", "clean": "shx rm -rf lib", "build": "tsc -b && yarn copy_md_files && yarn build-json", + "build:ci": "yarn build", "build-json": "node ./lib/build_scripts/buildJson", - "build-json:watch": "chokidar 'src/**/*' -c 'yarn build-json' ", + "build:watch": "chokidar 'src/**/*' -c 'yarn build' ", "copy_md_files": "copyfiles -u 2 './src/md/**/*.md' ./lib/src/md", "deploy-site": "discharge deploy" }, @@ -34,7 +35,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/sra-spec/README.md", "dependencies": { - "@0xproject/json-schemas": "^1.0.3" + "@0xproject/json-schemas": "^1.0.5" }, "devDependencies": { "@0xproject/tslint-config": "^1.0.7", diff --git a/packages/sra-spec/src/api.ts b/packages/sra-spec/src/api.ts index f80d343d8..7cecb0369 100644 --- a/packages/sra-spec/src/api.ts +++ b/packages/sra-spec/src/api.ts @@ -249,7 +249,7 @@ export const api: OpenApiSpec = { }, }, '/v2/order_config': { - get: { + post: { description: `Relayers have full discretion over the orders that they are willing to host on their orderbooks (e.g what fees they charge, etc...). In order for traders to discover their requirements programmatically, they can send an incomplete order to this endpoint and receive the missing fields, specifc to that order. This gives relayers a large amount of flexibility to tailor fees to unique traders, trading pairs and volume amounts. Submit a partial order and receive information required to complete the order: \`senderAddress\`, \`feeRecipientAddress\`, \`makerFee\`, \`takerFee\`. `, operationId: 'getOrderConfig', parameters: generateParameters([], false), diff --git a/packages/sra-spec/src/examples/relayerApiAssetDataPairsResponse.ts b/packages/sra-spec/src/examples/relayerApiAssetDataPairsResponse.ts index 9eead5239..3ab7b29c0 100644 --- a/packages/sra-spec/src/examples/relayerApiAssetDataPairsResponse.ts +++ b/packages/sra-spec/src/examples/relayerApiAssetDataPairsResponse.ts @@ -8,13 +8,14 @@ export const relayerApiAssetDataPairsResponse = { minAmount: '0', maxAmount: '10000000000000000000', precision: 5, - assetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', + assetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', }, assetDataB: { minAmount: '0', - maxAmount: '50000000000000000000', + maxAmount: '1', precision: 5, - assetData: '0x0257179264389b814a946f3e92105513705ca6b990', + assetData: + '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063', }, }, ], diff --git a/packages/sra-spec/src/examples/relayerApiOrder.ts b/packages/sra-spec/src/examples/relayerApiOrder.ts index 31181d677..e3ae66dc3 100644 --- a/packages/sra-spec/src/examples/relayerApiOrder.ts +++ b/packages/sra-spec/src/examples/relayerApiOrder.ts @@ -5,13 +5,14 @@ export const relayerApiOrder = { feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da', senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', makerAssetAmount: '10000000000000000', - takerAssetAmount: '20000000000000000', + takerAssetAmount: '1', makerFee: '100000000000000', takerFee: '200000000000000', expirationTimeSeconds: '1532560590', salt: '1532559225', - makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', - takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990', + makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', + takerAssetData: + '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063', exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', }, diff --git a/packages/sra-spec/src/examples/relayerApiOrderConfigPayload.ts b/packages/sra-spec/src/examples/relayerApiOrderConfigPayload.ts index 5251d5b4d..cca68b84d 100644 --- a/packages/sra-spec/src/examples/relayerApiOrderConfigPayload.ts +++ b/packages/sra-spec/src/examples/relayerApiOrderConfigPayload.ts @@ -2,9 +2,10 @@ export const relayerApiOrderConfigPayload = { makerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b', takerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', makerAssetAmount: '10000000000000000', - takerAssetAmount: '20000000000000000', - makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', - takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990', + takerAssetAmount: '1', + makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', + takerAssetData: + '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063', exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', expirationTimeSeconds: '1532560590', }; diff --git a/packages/sra-spec/src/examples/relayerApiOrderbookResponse.ts b/packages/sra-spec/src/examples/relayerApiOrderbookResponse.ts index 40c09eff9..7f0772649 100644 --- a/packages/sra-spec/src/examples/relayerApiOrderbookResponse.ts +++ b/packages/sra-spec/src/examples/relayerApiOrderbookResponse.ts @@ -11,13 +11,14 @@ export const relayerApiOrderbookResponse = { feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da', senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', makerAssetAmount: '10000000000000000', - takerAssetAmount: '20000000000000000', + takerAssetAmount: '1', makerFee: '100000000000000', takerFee: '200000000000000', expirationTimeSeconds: '1532560590', salt: '1532559225', - makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', - takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990', + makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', + takerAssetData: + '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063', exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', }, @@ -37,13 +38,14 @@ export const relayerApiOrderbookResponse = { feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da', senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', makerAssetAmount: '20000000000000000', - takerAssetAmount: '10000000000000000', + takerAssetAmount: '1', makerFee: '200000000000000', takerFee: '100000000000000', expirationTimeSeconds: '1532560590', salt: '1532559225', - makerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990', - takerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', + makerAssetData: + '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063', + takerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', signature: '0x013842a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b3518891', }, diff --git a/packages/sra-spec/src/examples/relayerApiOrdersResponse.ts b/packages/sra-spec/src/examples/relayerApiOrdersResponse.ts index ac16e7e34..eb66b8e81 100644 --- a/packages/sra-spec/src/examples/relayerApiOrdersResponse.ts +++ b/packages/sra-spec/src/examples/relayerApiOrdersResponse.ts @@ -10,13 +10,14 @@ export const relayerApiOrdersResponse = { feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da', senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32', makerAssetAmount: '10000000000000000', - takerAssetAmount: '20000000000000000', + takerAssetAmount: '1', makerFee: '100000000000000', takerFee: '200000000000000', expirationTimeSeconds: '1532560590', salt: '1532559225', - makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', - takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990', + makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', + takerAssetData: + '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063', exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', }, diff --git a/packages/sra-spec/src/examples/signedOrder.ts b/packages/sra-spec/src/examples/signedOrder.ts index 440566027..8513c398f 100644 --- a/packages/sra-spec/src/examples/signedOrder.ts +++ b/packages/sra-spec/src/examples/signedOrder.ts @@ -9,8 +9,9 @@ export const signedOrder = { takerFee: '200000000000000', expirationTimeSeconds: '1532560590', salt: '1532559225', - makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d', - takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990', + makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', + takerAssetData: + '0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063', exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093', signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', }; diff --git a/packages/sra-spec/src/md/introduction.md b/packages/sra-spec/src/md/introduction.md index 6f733c9ab..f27186f41 100644 --- a/packages/sra-spec/src/md/introduction.md +++ b/packages/sra-spec/src/md/introduction.md @@ -180,7 +180,7 @@ The identifier for the Proxy uses a similar scheme to [ABI function selectors](h ```js // ERC20 Proxy ID 0xf47261b0 bytes4(keccak256('ERC20Token(address)')); -// ERC721 Proxy ID 0x08e937fa +// ERC721 Proxy ID 0x02571792 bytes4(keccak256('ERC721Token(address,uint256)')); ``` @@ -192,10 +192,10 @@ For example, encoding the ERC20 token contract (address: 0x1dc4c1cefef38a777b15a 0xf47261b00000000000000000000000001dc4c1cefef38a777b15aa20260a54e584b16c48 ``` -Encoding the ERC721 token contract (address: `0x371b13d97f4bf77d724e78c16b7dc74099f40e84`), token id (id: `99`, which hex encoded is `0x63`) and the ERC721 Transfer Proxy (id: 0x08e937fa) would be: +Encoding the ERC721 token contract (address: `0x371b13d97f4bf77d724e78c16b7dc74099f40e84`), token id (id: `99`, which hex encoded is `0x63`) and the ERC721 Transfer Proxy (id: 0x02571792) would be: ```bash -0x08e937fa000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063 +0x02571792000000000000000000000000371b13d97f4bf77d724e78c16b7dc74099f40e840000000000000000000000000000000000000000000000000000000000000063 ``` For more information see [the Asset Proxy](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md#erc20proxy) section of the v2 spec and the [Ethereum ABI Spec](https://solidity.readthedocs.io/en/develop/abi-spec.html). diff --git a/packages/subproviders/CHANGELOG.json b/packages/subproviders/CHANGELOG.json index 8b6b87d2a..8ded2d2d4 100644 --- a/packages/subproviders/CHANGELOG.json +++ b/packages/subproviders/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "2.0.7", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "2.0.6", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "2.0.5", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "2.0.4", "changes": [ diff --git a/packages/subproviders/CHANGELOG.md b/packages/subproviders/CHANGELOG.md index 708a94b21..ca8f767c7 100644 --- a/packages/subproviders/CHANGELOG.md +++ b/packages/subproviders/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.7 - _October 2, 2018_ + + * Dependencies updated + +## v2.0.6 - _September 28, 2018_ + + * Dependencies updated + +## v2.0.5 - _September 25, 2018_ + + * Dependencies updated + ## v2.0.4 - _September 25, 2018_ * Dependencies updated diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json index 6740a0743..f9063228f 100644 --- a/packages/subproviders/package.json +++ b/packages/subproviders/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/subproviders", - "version": "2.0.4", + "version": "2.0.6", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "license": "Apache-2.0", "scripts": { "build": "tsc -b", + "build:ci": "yarn build", "clean": "shx rm -rf lib generated_docs", "lint": "tslint --project .", "run_mocha_unit": "mocha --require source-map-support/register --require make-promises-safe lib/test/unit/**/*_test.js --timeout 10000 --bail --exit", @@ -28,11 +29,11 @@ } }, "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/assert": "^1.0.12", + "@0xproject/types": "^1.1.2", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", "@ledgerhq/hw-app-eth": "^4.3.0", "@ledgerhq/hw-transport-u2f": "^4.3.0", "@types/eth-lightwallet": "^3.0.0", @@ -41,7 +42,7 @@ "bip39": "^2.5.0", "bn.js": "^4.11.8", "eth-lightwallet": "^3.0.1", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.9", "ethereumjs-tx": "^1.3.5", "ethereumjs-util": "^5.1.1", "ganache-core": "0xProject/ganache-core#monorepo-dep", diff --git a/packages/testnet-faucets/package.json b/packages/testnet-faucets/package.json index cfac1b018..33f557538 100644 --- a/packages/testnet-faucets/package.json +++ b/packages/testnet-faucets/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@0xproject/testnet-faucets", - "version": "1.0.48", + "version": "1.0.50", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "main": "server.js", "scripts": { "build": "node ../../node_modules/gulp/bin/gulp.js build", + "build:ci": "yarn build", "dev": "node ../../node_modules/gulp/bin/gulp.js run", "start": "node ./server/server.js", "lint": "tslint --project .", @@ -17,13 +18,13 @@ "author": "Fabio Berger", "license": "Apache-2.0", "dependencies": { - "0x.js": "^1.0.5", - "@0xproject/subproviders": "^2.0.4", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "0x.js": "^1.0.7", + "@0xproject/subproviders": "^2.0.6", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", "body-parser": "^1.17.1", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.9", "ethereumjs-tx": "^1.3.5", "ethereumjs-util": "^5.1.1", "express": "^4.15.2", diff --git a/packages/testnet-faucets/src/ts/handler.ts b/packages/testnet-faucets/src/ts/handler.ts index 82e9a9494..e73eb1744 100644 --- a/packages/testnet-faucets/src/ts/handler.ts +++ b/packages/testnet-faucets/src/ts/handler.ts @@ -158,6 +158,7 @@ export class Handler { if (_.isUndefined(takerTokenIfExists)) { throw new Error(`Unsupported asset type: ${takerTokenSymbol}`); } + const makerAssetAmount = Web3Wrapper.toBaseUnitAmount(ASSET_AMOUNT, makerTokenIfExists.decimals); const takerAssetAmount = Web3Wrapper.toBaseUnitAmount(ASSET_AMOUNT, takerTokenIfExists.decimals); const makerAssetData = assetDataUtils.encodeERC20AssetData(makerTokenIfExists.address); diff --git a/packages/tslint-config/package.json b/packages/tslint-config/package.json index 4b0694012..91596d32a 100644 --- a/packages/tslint-config/package.json +++ b/packages/tslint-config/package.json @@ -8,6 +8,7 @@ "main": "tslint.json", "scripts": { "build": "tsc -b", + "build:ci": "yarn build", "clean": "shx rm -rf lib", "lint": "tslint --project ." }, diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json index f9479f789..abf62c19d 100644 --- a/packages/types/CHANGELOG.json +++ b/packages/types/CHANGELOG.json @@ -1,5 +1,32 @@ [ { + "timestamp": 1538475601, + "version": "1.1.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "1.1.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "1.1.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "1.1.0", "changes": [ { diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index 9841aa301..a207a2c0c 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.1.3 - _October 2, 2018_ + + * Dependencies updated + +## v1.1.2 - _September 28, 2018_ + + * Dependencies updated + +## v1.1.1 - _September 25, 2018_ + + * Dependencies updated + ## v1.1.0 - _September 25, 2018_ * Add ObjectMap type (#1037) diff --git a/packages/types/package.json b/packages/types/package.json index f78368198..2901b067c 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/types", - "version": "1.1.0", + "version": "1.1.3", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "types": "lib/index.d.ts", "scripts": { "build": "tsc -b", + "build:ci": "yarn build", "clean": "shx rm -rf lib", "lint": "tslint --project ." }, @@ -32,7 +33,7 @@ "dependencies": { "@types/node": "*", "bignumber.js": "~4.1.0", - "ethereum-types": "^1.0.7" + "ethereum-types": "^1.0.9" }, "publishConfig": { "access": "public" diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index d27060ee5..3ae0536d5 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -1,3 +1,5 @@ +// tslint:disable:max-file-line-count + import { BigNumber } from 'bignumber.js'; import { ContractAbi } from 'ethereum-types'; @@ -111,12 +113,14 @@ export interface OrderStateValid { isValid: true; orderHash: string; orderRelevantState: OrderRelevantState; + transactionHash?: string; } export interface OrderStateInvalid { isValid: false; orderHash: string; error: ExchangeContractErrs; + transactionHash?: string; } export type OrderState = OrderStateValid | OrderStateInvalid; @@ -371,3 +375,227 @@ export interface PagedRequestOpts { page?: number; perPage?: number; } + +export interface TypeDocType { + type: TypeDocTypes; + value: string; + name: string; + types: TypeDocType[]; + typeArguments?: TypeDocType[]; + declaration: TypeDocNode; + elementType?: TypeDocType; + indexSignature?: TypeDocNode; + elements?: TupleElement[]; +} + +export interface TupleElement { + type: string; + name: string; +} + +export interface TypeDocNode { + id?: number; + name?: string; + kind?: string; + defaultValue?: string; + kindString?: string; + type?: TypeDocType; + fileName?: string; + line?: number; + comment?: TypeDocNode; + text?: string; + shortText?: string; + returns?: string; + declaration: TypeDocNode; + flags?: TypeDocFlags; + indexSignature?: TypeDocNode; + signatures?: TypeDocNode[]; + parameters?: TypeDocNode[]; + typeParameter?: TypeDocNode[]; + sources?: TypeDocNode[]; + children?: TypeDocNode[]; + groups?: TypeDocGroup[]; +} + +export interface TypeDocFlags { + isStatic?: boolean; + isOptional?: boolean; + isPublic?: boolean; + isExported?: boolean; +} + +export interface TypeDocGroup { + title: string; + children: number[]; +} + +export enum TypeDocTypes { + Intrinsic = 'intrinsic', + Reference = 'reference', + Array = 'array', + StringLiteral = 'stringLiteral', + Reflection = 'reflection', + Union = 'union', + TypeParameter = 'typeParameter', + Intersection = 'intersection', + Tuple = 'tuple', + Unknown = 'unknown', +} + +export interface CustomTypeChild { + name: string; + type?: Type; + defaultValue?: string; +} + +export interface Event { + name: string; + eventArgs: EventArg[]; +} + +export interface EventArg { + isIndexed: boolean; + name: string; + type: Type; +} + +export interface Property { + name: string; + type: Type; + source?: Source; + comment?: string; + callPath?: string; +} + +export interface BaseMethod { + isConstructor: boolean; + name: string; + returnComment?: string | undefined; + callPath: string; + parameters: Parameter[]; + returnType: Type; + comment?: string; +} + +export interface BaseFunction { + name: string; + returnComment?: string | undefined; + parameters: Parameter[]; + returnType: Type; + comment?: string; +} + +export interface TypeDefinitionByName { + [typeName: string]: CustomType; +} + +export interface DocAgnosticFormat { + [sectionName: string]: DocSection; +} + +export interface DocSection { + comment: string; + constructors: Array<TypescriptMethod | SolidityMethod>; + methods: Array<TypescriptMethod | SolidityMethod>; + properties: Property[]; + types: CustomType[]; + functions: TypescriptFunction[]; + events?: Event[]; + externalExportToLink?: ExternalExportToLink; +} + +export interface TypescriptMethod extends BaseMethod { + source?: Source; + isStatic?: boolean; + typeParameter?: TypeParameter; +} + +export interface TypescriptFunction extends BaseFunction { + source?: Source; + typeParameter?: TypeParameter; + callPath: string; +} + +export interface SolidityMethod extends BaseMethod { + isConstant?: boolean; + isPayable?: boolean; + isFallback?: boolean; +} + +export interface Source { + fileName: string; + line: number; +} + +export interface Parameter { + name: string; + comment: string; + isOptional: boolean; + type: Type; + defaultValue?: string; +} + +export interface TypeParameter { + name: string; + type: Type; +} + +export interface Type { + name: string; + typeDocType: TypeDocTypes; + value?: string; + isExportedClassReference?: boolean; + typeArguments?: Type[]; + elementType?: ElementType; + types?: Type[]; + method?: TypescriptMethod; + indexSignature?: IndexSignature; + externalLink?: string; + tupleElements?: Type[]; +} + +export interface ElementType { + name: string; + typeDocType: TypeDocTypes; +} + +export interface IndexSignature { + keyName: string; + keyType: Type; + valueName: string; +} + +export interface CustomType { + name: string; + kindString: string; + type?: Type; + method?: TypescriptMethod; + indexSignature?: IndexSignature; + defaultValue?: string; + comment?: string; + children?: CustomTypeChild[]; +} +export interface GeneratedDocJson { + version: string; + metadata: Metadata; + typedocJson: TypeDocNode; +} + +export interface ExportNameToTypedocNames { + [exportName: string]: string[]; +} + +export interface ExternalTypeToLink { + [externalTypeName: string]: string; +} + +export interface ExternalExportToLink { + [externalExport: string]: string; +} + +export interface Metadata { + exportPathToTypedocNames: ExportNameToTypedocNames; + exportPathOrder: string[]; + externalTypeToLink: ExternalTypeToLink; + externalExportToLink: ExternalExportToLink; +} diff --git a/packages/typescript-typings/CHANGELOG.json b/packages/typescript-typings/CHANGELOG.json index f0b1a6c40..c3ee81bde 100644 --- a/packages/typescript-typings/CHANGELOG.json +++ b/packages/typescript-typings/CHANGELOG.json @@ -1,5 +1,33 @@ [ { + "timestamp": 1538475601, + "version": "3.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "version": "3.0.0", + "changes": [ + { + "note": "Remove types for ethers.js", + "pr": "1069" + } + ], + "timestamp": 1538157789 + }, + { + "timestamp": 1537907159, + "version": "2.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537541580, "version": "2.0.1", "changes": [ diff --git a/packages/typescript-typings/CHANGELOG.md b/packages/typescript-typings/CHANGELOG.md index 67e86bb82..ea9e4d441 100644 --- a/packages/typescript-typings/CHANGELOG.md +++ b/packages/typescript-typings/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.1 - _October 2, 2018_ + + * Dependencies updated + +## v3.0.0 - _September 28, 2018_ + + * Remove types for ethers.js (#1069) + +## v2.0.2 - _September 25, 2018_ + + * Dependencies updated + ## v2.0.1 - _September 21, 2018_ * Dependencies updated diff --git a/packages/typescript-typings/package.json b/packages/typescript-typings/package.json index 6f8b7e256..07ac730ff 100644 --- a/packages/typescript-typings/package.json +++ b/packages/typescript-typings/package.json @@ -1,12 +1,13 @@ { "name": "@0xproject/typescript-typings", - "version": "2.0.1", + "version": "3.0.1", "engines": { "node": ">=6.12" }, "description": "0x project typescript type definitions", "scripts": { "build": "tsc -b", + "build:ci": "yarn build", "clean": "shx rm -rf lib" }, "repository": { @@ -26,7 +27,7 @@ "@types/bn.js": "^4.11.0", "@types/react": "*", "bignumber.js": "~4.1.0", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.9", "popper.js": "1.14.3" }, "devDependencies": { diff --git a/packages/typescript-typings/types/ethers/index.d.ts b/packages/typescript-typings/types/ethers/index.d.ts deleted file mode 100644 index 875563ba2..000000000 --- a/packages/typescript-typings/types/ethers/index.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -declare module 'ethers' { - import { TxData } from 'ethereum-types'; - - export interface TransactionDescription { - name: string; - signature: string; - sighash: string; - data: string; - } - export interface CallDescription extends TransactionDescription { - parse: (...args: any[]) => any; - } - export interface FunctionDescription { - (...params: any[]): TransactionDescription | CallDescription; - inputs: { names: string[]; types: string[] }; - outputs: { names: string[]; types: string[] }; - type: string; - } - export interface EventDescription { - parse: (...args: any[]) => any; - inputs: { names: string[]; types: string[] }; - signature: string; - topics: string[]; - } - export class Interface { - public functions: { [functionName: string]: FunctionDescription }; - public events: { [eventName: string]: EventDescription }; - constructor(abi: any); - } - export class Contract { - public static getDeployTransaction(bytecode: string, abi: any, ...args: any[]): Partial<TxData>; - constructor(address: string, abi: any, provider: any); - } - const enum errors { - INVALID_ARGUMENT = 'INVALID_ARGUMENT', - } - - export type ParamName = null | string | NestedParamName; - - export interface NestedParamName { - name: string | null; - names: ParamName[]; - } - - export const utils: { - AbiCoder: { - defaultCoder: AbiCoder; - }; - }; - - export interface AbiCoder { - encode: (names: ParamName[] | string[], types: string[] | any[], args: any[] | undefined) => string; - decode: (names: ParamName[] | string[], types: string[] | string, data: string | undefined) => any; - } -} diff --git a/packages/typescript-typings/types/solc/index.d.ts b/packages/typescript-typings/types/solc/index.d.ts index 571bae101..f4c05cd7c 100644 --- a/packages/typescript-typings/types/solc/index.d.ts +++ b/packages/typescript-typings/types/solc/index.d.ts @@ -1,4 +1,6 @@ declare module 'solc' { + export { ErrorType, ErrorSeverity, SolcError, StandardContractOutput, StandardOutput } from 'ethereum-types'; + import { SolcError } from 'ethereum-types'; export interface ContractCompilationResult { srcmap: string; srcmapRuntime: string; @@ -87,62 +89,6 @@ declare module 'solc' { }; settings: CompilerSettings; } - export type ErrorType = - | 'JSONError' - | 'IOError' - | 'ParserError' - | 'DocstringParsingError' - | 'SyntaxError' - | 'DeclarationError' - | 'TypeError' - | 'UnimplementedFeatureError' - | 'InternalCompilerError' - | 'Exception' - | 'CompilerError' - | 'FatalError' - | 'Warning'; - export type ErrorSeverity = 'error' | 'warning'; - export interface Error { - sourceLocation?: { - file: string; - start: number; - end: number; - }; - type: ErrorType; - component: 'general' | 'ewasm'; - severity: ErrorSeverity; - message: string; - formattedMessage?: string; - } - import { ContractAbi } from 'ethereum-types'; - export interface StandardContractOutput { - abi: ContractAbi; - evm: { - bytecode: { - object: string; - sourceMap: string; - }; - deployedBytecode: { - object: string; - sourceMap: string; - }; - }; - } - export interface StandardOutput { - errors: Error[]; - sources: { - [fileName: string]: { - id: number; - ast?: object; - legacyAST?: object; - }; - }; - contracts: { - [fileName: string]: { - [contractName: string]: StandardContractOutput; - }; - }; - } export interface SolcInstance { compile( sources: InputSources, @@ -151,6 +97,9 @@ declare module 'solc' { ): CompilationResult; compileStandardWrapper(input: string, findImports: (importPath: string) => ImportContents): string; } - export function loadRemoteVersion(versionName: string, cb: (err: Error | null, res?: SolcInstance) => void): void; + export function loadRemoteVersion( + versionName: string, + cb: (err: SolcError | null, res?: SolcInstance) => void, + ): void; export function setupMethods(solcBin: any): SolcInstance; } diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json index 1536c1960..b666ee829 100644 --- a/packages/utils/CHANGELOG.json +++ b/packages/utils/CHANGELOG.json @@ -1,5 +1,33 @@ [ { + "timestamp": 1538475601, + "version": "2.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "version": "2.0.0", + "changes": [ + { + "note": "Make abi_decoder compatible with ethers ^4.0.0", + "pr": 1069 + } + ], + "timestamp": 1538157789 + }, + { + "timestamp": 1537907159, + "version": "1.0.11", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "timestamp": 1537875740, "version": "1.0.10", "changes": [ diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index ff26a0900..c62e414f8 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v2.0.1 - _October 2, 2018_ + + * Dependencies updated + +## v2.0.0 - _September 28, 2018_ + + * Make abi_decoder compatible with ethers ^4.0.0 (#1069) + +## v1.0.11 - _September 25, 2018_ + + * Dependencies updated + ## v1.0.10 - _September 25, 2018_ * Dependencies updated diff --git a/packages/utils/package.json b/packages/utils/package.json index 77d11c41c..d2ed67554 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/utils", - "version": "1.0.10", + "version": "2.0.1", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build": "tsc -b", + "build:ci": "yarn build", "clean": "shx rm -rf lib", "lint": "tslint --project .", "test": "yarn run_mocha", @@ -41,15 +42,15 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/types": "^1.1.2", + "@0xproject/typescript-typings": "^3.0.0", "@types/node": "*", "abortcontroller-polyfill": "^1.1.9", "bignumber.js": "~4.1.0", "detect-node": "2.0.3", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.9", "ethereumjs-util": "^5.1.1", - "ethers": "3.0.22", + "ethers": "4.0.0-beta.14", "isomorphic-fetch": "^2.2.1", "js-sha3": "^0.7.0", "lodash": "^4.17.5" diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts index 265eb105e..ea8c91d10 100644 --- a/packages/utils/src/abi_decoder.ts +++ b/packages/utils/src/abi_decoder.ts @@ -47,7 +47,7 @@ export class AbiDecoder { let decodedData: any[]; try { - decodedData = ethersInterface.events[event.name].parse(log.data); + decodedData = ethersInterface.events[event.name].decode(log.data); } catch (error) { if (error.code === ethers.errors.INVALID_ARGUMENT) { // Because we index events by Method ID, and Method IDs are derived from the method @@ -99,7 +99,7 @@ export class AbiDecoder { const ethersInterface = new ethers.Interface(abiArray); _.map(abiArray, (abi: AbiDefinition) => { if (abi.type === AbiType.Event) { - const topic = ethersInterface.events[abi.name].topics[0]; + const topic = ethersInterface.events[abi.name].topic; const numIndexedArgs = _.reduce(abi.inputs, (sum, input) => (input.indexed ? sum + 1 : sum), 0); this._methodIds[topic] = { ...this._methodIds[topic], diff --git a/packages/utils/src/abi_utils.ts b/packages/utils/src/abi_utils.ts index c9b70966c..598ea5fcc 100644 --- a/packages/utils/src/abi_utils.ts +++ b/packages/utils/src/abi_utils.ts @@ -1,14 +1,19 @@ import { AbiDefinition, AbiType, ContractAbi, DataItem, MethodAbi } from 'ethereum-types'; -import * as ethers from 'ethers'; import * as _ from 'lodash'; import { BigNumber } from './configured_bignumber'; +type ParamName = null | string | NestedParamName; +interface NestedParamName { + name: string | null; + names: ParamName[]; +} + // Note(albrow): This function is unexported in ethers.js. Copying it here for // now. // Source: https://github.com/ethers-io/ethers.js/blob/884593ab76004a808bf8097e9753fb5f8dcc3067/contracts/interface.js#L30 -function parseEthersParams(params: DataItem[]): { names: ethers.ParamName[]; types: string[] } { - const names: ethers.ParamName[] = []; +function parseEthersParams(params: DataItem[]): { names: ParamName[]; types: string[] } { + const names: ParamName[] = []; const types: string[] = []; params.forEach((param: DataItem) => { @@ -37,7 +42,7 @@ function parseEthersParams(params: DataItem[]): { names: ethers.ParamName[]; typ // returns true if x is equal to y and false otherwise. Performs some minimal // type conversion and data massaging for x and y, depending on type. name and // type should typically be derived from parseEthersParams. -function isAbiDataEqual(name: ethers.ParamName, type: string, x: any, y: any): boolean { +function isAbiDataEqual(name: ParamName, type: string, x: any, y: any): boolean { if (_.isUndefined(x) && _.isUndefined(y)) { return true; } else if (_.isUndefined(x) && !_.isUndefined(y)) { @@ -89,7 +94,7 @@ function isAbiDataEqual(name: ethers.ParamName, type: string, x: any, y: any): b // const nestedName = _.isString(name.names[i]) ? (name.names[i] as string) - : ((name.names[i] as ethers.NestedParamName).name as string); + : ((name.names[i] as NestedParamName).name as string); if (!isAbiDataEqual(name.names[i], types[i], x[nestedName], y[nestedName])) { return false; } diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json index b1ea2fe2e..7261dd474 100644 --- a/packages/web3-wrapper/CHANGELOG.json +++ b/packages/web3-wrapper/CHANGELOG.json @@ -1,11 +1,43 @@ [ { + "timestamp": 1538475601, + "version": "3.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1538157789, + "version": "3.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { + "timestamp": 1537907159, + "version": "3.0.1", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, + { "version": "3.0.0", "changes": [ { "note": "Rename `getBlockAsync` to `getBlockIfExistsAsync` and rather then throw if the requested block wasn't found, return undefined.", "pr": 1082 + }, + { + "note": + "Expose `sendRawPayloadAsync` so one can easily extend `Web3Wrapper` with their own custom JSON RPC calls", + "pr": 1080 } ], "timestamp": 1537875740 diff --git a/packages/web3-wrapper/CHANGELOG.md b/packages/web3-wrapper/CHANGELOG.md index cafbe1340..05e6a998b 100644 --- a/packages/web3-wrapper/CHANGELOG.md +++ b/packages/web3-wrapper/CHANGELOG.md @@ -5,9 +5,22 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v3.0.3 - _October 2, 2018_ + + * Dependencies updated + +## v3.0.2 - _September 28, 2018_ + + * Dependencies updated + +## v3.0.1 - _September 25, 2018_ + + * Dependencies updated + ## v3.0.0 - _September 25, 2018_ * Rename `getBlockAsync` to `getBlockIfExistsAsync` and rather then throw if the requested block wasn't found, return undefined. (#1082) + * Expose `sendRawPayloadAsync` so one can easily extend `Web3Wrapper` with their own custom JSON RPC calls (#1080) ## v2.0.3 - _September 21, 2018_ diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json index f895296e9..5b5c0ec5b 100644 --- a/packages/web3-wrapper/package.json +++ b/packages/web3-wrapper/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/web3-wrapper", - "version": "3.0.0", + "version": "3.0.2", "engines": { "node": ">=6.12" }, @@ -9,6 +9,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build": "tsc -b", + "build:ci": "yarn build", "clean": "shx rm -rf lib generated_docs", "lint": "tslint --project .", "test": "yarn run_mocha", @@ -53,13 +54,13 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/assert": "^1.0.10", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "ethereum-types": "^1.0.7", + "@0xproject/assert": "^1.0.12", + "@0xproject/json-schemas": "^1.0.5", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "ethereum-types": "^1.0.9", "ethereumjs-util": "^5.1.1", - "ethers": "3.0.22", + "ethers": "4.0.0-beta.14", "lodash": "^4.17.5" }, "publishConfig": { diff --git a/packages/web3-wrapper/src/utils.ts b/packages/web3-wrapper/src/utils.ts index 01605dc9a..0b568aac5 100644 --- a/packages/web3-wrapper/src/utils.ts +++ b/packages/web3-wrapper/src/utils.ts @@ -37,7 +37,7 @@ export const utils = { const hexBase = 16; const valueHex = valueBigNumber.toString(hexBase); - return valueBigNumber.lessThan(0) ? '-0x' + valueHex.substr(1) : '0x' + valueHex; + return valueBigNumber.lessThan(0) ? `-0x${valueHex.substr(1)}` : `0x${valueHex}`; }, numberToHex(value: number): string { if (!isFinite(value) && !utils.isHexStrict(value)) { @@ -48,7 +48,7 @@ export const utils = { const hexBase = 16; const result = valueBigNumber.toString(hexBase); - return valueBigNumber.lt(0) ? '-0x' + result.substr(1) : '0x' + result; + return valueBigNumber.lt(0) ? `-0x${result.substr(1)}` : `0x${result}`; }, isHexStrict(hex: string | number): boolean { return ( diff --git a/packages/web3-wrapper/src/web3_wrapper.ts b/packages/web3-wrapper/src/web3_wrapper.ts index dc634a57f..d52c1cb6e 100644 --- a/packages/web3-wrapper/src/web3_wrapper.ts +++ b/packages/web3-wrapper/src/web3_wrapper.ts @@ -193,7 +193,7 @@ export class Web3Wrapper { * @returns Ethereum node's version string */ public async getNodeVersionAsync(): Promise<string> { - const nodeVersion = await this._sendRawPayloadAsync<string>({ method: 'web3_clientVersion' }); + const nodeVersion = await this.sendRawPayloadAsync<string>({ method: 'web3_clientVersion' }); return nodeVersion; } /** @@ -201,7 +201,7 @@ export class Web3Wrapper { * @returns The network id */ public async getNetworkIdAsync(): Promise<number> { - const networkIdStr = await this._sendRawPayloadAsync<string>({ method: 'net_version' }); + const networkIdStr = await this.sendRawPayloadAsync<string>({ method: 'net_version' }); const networkId = _.parseInt(networkIdStr); return networkId; } @@ -212,7 +212,7 @@ export class Web3Wrapper { */ public async getTransactionReceiptAsync(txHash: string): Promise<TransactionReceipt> { assert.isHexString('txHash', txHash); - const transactionReceipt = await this._sendRawPayloadAsync<TransactionReceipt>({ + const transactionReceipt = await this.sendRawPayloadAsync<TransactionReceipt>({ method: 'eth_getTransactionReceipt', params: [txHash], }); @@ -228,7 +228,7 @@ export class Web3Wrapper { */ public async getTransactionByHashAsync(txHash: string): Promise<Transaction> { assert.isHexString('txHash', txHash); - const transaction = await this._sendRawPayloadAsync<Transaction>({ + const transaction = await this.sendRawPayloadAsync<Transaction>({ method: 'eth_getTransactionByHash', params: [txHash], }); @@ -247,7 +247,7 @@ export class Web3Wrapper { } const marshalledDefaultBlock = marshaller.marshalBlockParam(defaultBlock); const encodedOwner = marshaller.marshalAddress(owner); - const balanceInWei = await this._sendRawPayloadAsync<string>({ + const balanceInWei = await this.sendRawPayloadAsync<string>({ method: 'eth_getBalance', params: [encodedOwner, marshalledDefaultBlock], }); @@ -279,7 +279,7 @@ export class Web3Wrapper { } const marshalledDefaultBlock = marshaller.marshalBlockParam(defaultBlock); const encodedAddress = marshaller.marshalAddress(address); - const code = await this._sendRawPayloadAsync<string>({ + const code = await this.sendRawPayloadAsync<string>({ method: 'eth_getCode', params: [encodedAddress, marshalledDefaultBlock], }); @@ -293,7 +293,7 @@ export class Web3Wrapper { */ public async getTransactionTraceAsync(txHash: string, traceParams: TraceParams): Promise<TransactionTrace> { assert.isHexString('txHash', txHash); - const trace = await this._sendRawPayloadAsync<TransactionTrace>({ + const trace = await this.sendRawPayloadAsync<TransactionTrace>({ method: 'debug_traceTransaction', params: [txHash, traceParams], }); @@ -308,7 +308,7 @@ export class Web3Wrapper { public async signMessageAsync(address: string, message: string): Promise<string> { assert.isETHAddressHex('address', address); assert.isString('message', message); // TODO: Should this be stricter? Hex string? - const signData = await this._sendRawPayloadAsync<string>({ + const signData = await this.sendRawPayloadAsync<string>({ method: 'eth_sign', params: [address, message], }); @@ -319,7 +319,7 @@ export class Web3Wrapper { * @returns Block number */ public async getBlockNumberAsync(): Promise<number> { - const blockNumberHex = await this._sendRawPayloadAsync<string>({ + const blockNumberHex = await this.sendRawPayloadAsync<string>({ method: 'eth_blockNumber', params: [], }); @@ -339,7 +339,7 @@ export class Web3Wrapper { const encodedBlockParam = marshaller.marshalBlockParam(blockParam); const method = utils.isHexStrict(blockParam) ? 'eth_getBlockByHash' : 'eth_getBlockByNumber'; const shouldIncludeTransactionData = false; - const blockWithoutTransactionDataWithHexValuesOrNull = await this._sendRawPayloadAsync< + const blockWithoutTransactionDataWithHexValuesOrNull = await this.sendRawPayloadAsync< BlockWithoutTransactionDataRPC >({ method, @@ -366,7 +366,7 @@ export class Web3Wrapper { } const method = utils.isHexStrict(blockParam) ? 'eth_getBlockByHash' : 'eth_getBlockByNumber'; const shouldIncludeTransactionData = true; - const blockWithTransactionDataWithHexValues = await this._sendRawPayloadAsync<BlockWithTransactionDataRPC>({ + const blockWithTransactionDataWithHexValues = await this.sendRawPayloadAsync<BlockWithTransactionDataRPC>({ method, params: [encodedBlockParam, shouldIncludeTransactionData], }); @@ -393,7 +393,7 @@ export class Web3Wrapper { * @returns Available user addresses */ public async getAvailableAddressesAsync(): Promise<string[]> { - const addresses = await this._sendRawPayloadAsync<string>({ + const addresses = await this.sendRawPayloadAsync<string>({ method: 'eth_accounts', params: [], }); @@ -405,7 +405,7 @@ export class Web3Wrapper { * @returns The snapshot id. This can be used to revert to this snapshot */ public async takeSnapshotAsync(): Promise<number> { - const snapshotId = Number(await this._sendRawPayloadAsync<string>({ method: 'evm_snapshot', params: [] })); + const snapshotId = Number(await this.sendRawPayloadAsync<string>({ method: 'evm_snapshot', params: [] })); return snapshotId; } /** @@ -415,14 +415,14 @@ export class Web3Wrapper { */ public async revertSnapshotAsync(snapshotId: number): Promise<boolean> { assert.isNumber('snapshotId', snapshotId); - const didRevert = await this._sendRawPayloadAsync<boolean>({ method: 'evm_revert', params: [snapshotId] }); + const didRevert = await this.sendRawPayloadAsync<boolean>({ method: 'evm_revert', params: [snapshotId] }); return didRevert; } /** * Mine a block on a TestRPC/Ganache local node */ public async mineBlockAsync(): Promise<void> { - await this._sendRawPayloadAsync<string>({ method: 'evm_mine', params: [] }); + await this.sendRawPayloadAsync<string>({ method: 'evm_mine', params: [] }); } /** * Increase the next blocks timestamp on TestRPC/Ganache or Geth local node. @@ -434,9 +434,9 @@ export class Web3Wrapper { // Detect Geth vs. Ganache and use appropriate endpoint. const version = await this.getNodeVersionAsync(); if (_.includes(version, uniqueVersionIds.geth)) { - return this._sendRawPayloadAsync<number>({ method: 'debug_increaseTime', params: [timeDelta] }); + return this.sendRawPayloadAsync<number>({ method: 'debug_increaseTime', params: [timeDelta] }); } else if (_.includes(version, uniqueVersionIds.ganache)) { - return this._sendRawPayloadAsync<number>({ method: 'evm_increaseTime', params: [timeDelta] }); + return this.sendRawPayloadAsync<number>({ method: 'evm_increaseTime', params: [timeDelta] }); } else { throw new Error(`Unknown client version: ${version}`); } @@ -447,6 +447,12 @@ export class Web3Wrapper { * @returns The corresponding log entries */ public async getLogsAsync(filter: FilterObject): Promise<LogEntry[]> { + if (!_.isUndefined(filter.blockHash) && (!_.isUndefined(filter.fromBlock) || !_.isUndefined(filter.toBlock))) { + throw new Error( + `Cannot specify 'blockHash' as well as 'fromBlock'/'toBlock' in the filter supplied to 'getLogsAsync'`, + ); + } + let fromBlock = filter.fromBlock; if (_.isNumber(fromBlock)) { fromBlock = utils.numberToHex(fromBlock); @@ -464,7 +470,7 @@ export class Web3Wrapper { method: 'eth_getLogs', params: [serializedFilter], }; - const rawLogs = await this._sendRawPayloadAsync<RawLogEntry[]>(payload); + const rawLogs = await this.sendRawPayloadAsync<RawLogEntry[]>(payload); const formattedLogs = _.map(rawLogs, marshaller.unmarshalLog.bind(marshaller)); return formattedLogs; } @@ -480,7 +486,7 @@ export class Web3Wrapper { schemas.jsNumber, ]); const txDataHex = marshaller.marshalTxData(txData); - const gasHex = await this._sendRawPayloadAsync<string>({ method: 'eth_estimateGas', params: [txDataHex] }); + const gasHex = await this.sendRawPayloadAsync<string>({ method: 'eth_estimateGas', params: [txDataHex] }); const gas = utils.convertHexToNumber(gasHex); return gas; } @@ -501,7 +507,7 @@ export class Web3Wrapper { } const marshalledDefaultBlock = marshaller.marshalBlockParam(defaultBlock); const callDataHex = marshaller.marshalCallData(callData); - const rawCallResult = await this._sendRawPayloadAsync<string>({ + const rawCallResult = await this.sendRawPayloadAsync<string>({ method: 'eth_call', params: [callDataHex, marshalledDefaultBlock], }); @@ -522,7 +528,7 @@ export class Web3Wrapper { schemas.jsNumber, ]); const txDataHex = marshaller.marshalTxData(txData); - const txHash = await this._sendRawPayloadAsync<string>({ method: 'eth_sendTransaction', params: [txDataHex] }); + const txHash = await this.sendRawPayloadAsync<string>({ method: 'eth_sendTransaction', params: [txDataHex] }); return txHash; } /** @@ -632,7 +638,24 @@ export class Web3Wrapper { */ public async setHeadAsync(blockNumber: number): Promise<void> { assert.isNumber('blockNumber', blockNumber); - await this._sendRawPayloadAsync<void>({ method: 'debug_setHead', params: [utils.numberToHex(blockNumber)] }); + await this.sendRawPayloadAsync<void>({ method: 'debug_setHead', params: [utils.numberToHex(blockNumber)] }); + } + /** + * Sends a raw Ethereum JSON RPC payload and returns the response's `result` key + * @param payload A partial JSON RPC payload. No need to include version, id, params (if none needed) + * @return The contents nested under the result key of the response body + */ + public async sendRawPayloadAsync<A>(payload: Partial<JSONRPCRequestPayload>): Promise<A> { + const sendAsync = this._provider.sendAsync.bind(this._provider); + const payloadWithDefaults = { + id: this._jsonRpcRequestId++, + params: [], + jsonrpc: '2.0', + ...payload, + }; + const response = await promisify<JSONRPCResponsePayload>(sendAsync)(payloadWithDefaults); + const result = response.result; + return result; } /** * Returns either NodeType.Geth or NodeType.Ganache depending on the type of @@ -648,16 +671,4 @@ export class Web3Wrapper { throw new Error(`Unknown client version: ${version}`); } } - private async _sendRawPayloadAsync<A>(payload: Partial<JSONRPCRequestPayload>): Promise<A> { - const sendAsync = this._provider.sendAsync.bind(this._provider); - const payloadWithDefaults = { - id: this._jsonRpcRequestId++, - params: [], - jsonrpc: '2.0', - ...payload, - }; - const response = await promisify<JSONRPCResponsePayload>(sendAsync)(payloadWithDefaults); - const result = response.result; - return result; - } } // tslint:disable-line:max-file-line-count diff --git a/packages/website/md/docs/connect/2.0.0/introduction.md b/packages/website/md/docs/connect/2.0.0/introduction.md index de7ece7ae..8e251b327 100644 --- a/packages/website/md/docs/connect/2.0.0/introduction.md +++ b/packages/website/md/docs/connect/2.0.0/introduction.md @@ -1,3 +1 @@ -<b>**NOTE:** Release candidate versions are meant to work with V2 of the Standard Relayer API. To interact with V1, select a 1.X version of connect.</b> - Welcome to the [0x Connect](https://github.com/0xProject/0x-monorepo/tree/development/packages/connect) documentation! 0x Connect is a Javascript library that makes it easy to interact with relayers that conform to the [Standard Relayer API](https://github.com/0xProject/standard-relayer-api). Functionality includes getting supported asset pairs from a relayer, getting orders filtered by different attributes, getting individual orders specified by order hash, getting orderbooks for specific asset pairs, getting fee information, and submitting orders. diff --git a/packages/website/md/docs/contract_wrappers/introduction.md b/packages/website/md/docs/contract_wrappers/introduction.md index 74254bdad..ccc81b373 100644 --- a/packages/website/md/docs/contract_wrappers/introduction.md +++ b/packages/website/md/docs/contract_wrappers/introduction.md @@ -1,3 +1 @@ -<b>**NOTE:** Release candidate versions are meant to work with V2 of 0x protocol. To interact with V1, select a 0.X version.</b> - Welcome to the [Contract-wrappers](https://github.com/0xProject/0x-monorepo/tree/development/packages/contract-wrappers) documentation! Contract-wrappers is a library for interacting with the Ethereum smart contracts that make up the 0x protocol. With it, you can easily send transactions and make calls to the 0x smart contracts as well as any token adhering to the token standards supported by the protocol (currently ERC20 & ERC721). diff --git a/packages/website/md/docs/json_schemas/1.0.0/introduction.md b/packages/website/md/docs/json_schemas/1.0.0/introduction.md index cc777b1a8..a27f4b521 100644 --- a/packages/website/md/docs/json_schemas/1.0.0/introduction.md +++ b/packages/website/md/docs/json_schemas/1.0.0/introduction.md @@ -1,5 +1,3 @@ -<b>**NOTE:** Release candidate versions are meant to work with V2 of 0x protocol. To interact with V1, select a 0.X version.</b> - Welcome to the [@0xproject/json-schemas](https://github.com/0xProject/0x-monorepo/tree/development/packages/json-schemas) documentation! This package provides JSON schemas for validating 0x Protocol & Standard Relayer API data structures. It provides both the raw JSON schemas and a schema validator class to interact with them from a JS project. If you are not using a Javascript-based language for your project, you can copy-paste the JSON schemas within this package and use them together with a [JSON Schema](http://json-schema.org/) implementation in your [language of choice](http://json-schema.org/implementations.html) (e.g Python, Haskell, Go, C, C++, Rust, Ruby, Scala, etc...). diff --git a/packages/website/md/docs/smart_contracts/1.0.0/introduction.md b/packages/website/md/docs/smart_contracts/1.0.0/introduction.md index 566a573b6..79a8f00fd 100644 --- a/packages/website/md/docs/smart_contracts/1.0.0/introduction.md +++ b/packages/website/md/docs/smart_contracts/1.0.0/introduction.md @@ -1,8 +1 @@ -Welcome to the [0x smart contracts](https://github.com/0xProject/contracts) documentation! This documentation is intended for dApp developers who want to integrate 0x exchange functionality directly into their own smart contracts. - -### Helpful wiki articles: - -* [Overview of 0x protocol architecture](https://0xproject.com/wiki#Architecture) -* [0x smart contract interactions](https://0xproject.com/wiki#Contract-Interactions) -* [Deployed smart contract addresses](https://0xproject.com/wiki#Deployed-Addresses) -* [0x protocol message format](https://0xproject.com/wiki#Message-Format) +Welcome to the [0x smart contracts](https://github.com/0xProject/0x-monorepo/tree/development/packages/contracts) documentation! This documentation is intended for dApp developers who want to integrate 0x exchange functionality directly into their own smart contracts. diff --git a/packages/website/md/docs/smart_contracts/2.0.0/introduction.md b/packages/website/md/docs/smart_contracts/2.0.0/introduction.md new file mode 100644 index 000000000..4aa31db3d --- /dev/null +++ b/packages/website/md/docs/smart_contracts/2.0.0/introduction.md @@ -0,0 +1,6 @@ +Welcome to the [0x smart contracts](https://github.com/0xProject/0x-monorepo/tree/development/packages/contracts) documentation! This documentation is intended for dApp developers who want to integrate 0x exchange functionality directly into their own smart contracts. + +### Helpful wiki articles: + +* [Deployed smart contract addresses](https://0xproject.com/wiki#Deployed-Addresses) +* [0x Protocol Specification](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md) diff --git a/packages/website/package.json b/packages/website/package.json index 67b2fb4ec..8c115d8a0 100644 --- a/packages/website/package.json +++ b/packages/website/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/website", - "version": "0.0.51", + "version": "0.0.53", "engines": { "node": ">=6.12" }, @@ -8,6 +8,7 @@ "description": "Website and 0x portal dapp", "scripts": { "build": "NODE_ENV=production node --max_old_space_size=8192 ../../node_modules/.bin/webpack", + "build:ci": "yarn build", "clean": "shx rm -f public/bundle*", "lint": "tslint --project . 'ts/**/*.ts' 'ts/**/*.tsx'", "watch_without_deps": "webpack-dev-server --content-base public --https", @@ -19,22 +20,22 @@ "license": "Apache-2.0", "dependencies": { "0x.js": "^0.38.6", - "@0xproject/contract-wrappers": "^1.0.5", - "@0xproject/json-schemas": "^1.0.3", - "@0xproject/order-utils": "^1.0.4", - "@0xproject/react-docs": "^1.0.10", - "@0xproject/react-shared": "^1.0.11", - "@0xproject/subproviders": "^2.0.4", - "@0xproject/types": "^1.1.0", - "@0xproject/typescript-typings": "^2.0.1", - "@0xproject/utils": "^1.0.10", - "@0xproject/web3-wrapper": "^3.0.0", + "@0xproject/contract-wrappers": "^2.0.1", + "@0xproject/json-schemas": "^1.0.5", + "@0xproject/order-utils": "^1.0.6", + "@0xproject/react-docs": "^1.0.12", + "@0xproject/react-shared": "^1.0.13", + "@0xproject/subproviders": "^2.0.6", + "@0xproject/types": "^1.1.2", + "@0xproject/typescript-typings": "^3.0.0", + "@0xproject/utils": "^2.0.0", + "@0xproject/web3-wrapper": "^3.0.2", "accounting": "^0.4.1", "basscss": "^8.0.3", "blockies": "^0.0.2", "bowser": "^1.9.3", "deep-equal": "^1.0.1", - "ethereum-types": "^1.0.7", + "ethereum-types": "^1.0.9", "ethereumjs-util": "^5.1.1", "find-versions": "^2.0.0", "jsonschema": "^1.2.0", diff --git a/packages/website/public/images/coinbase_wallet_logo.png b/packages/website/public/images/coinbase_wallet_logo.png Binary files differnew file mode 100644 index 000000000..04c1b7290 --- /dev/null +++ b/packages/website/public/images/coinbase_wallet_logo.png diff --git a/packages/website/public/images/team/jason.png b/packages/website/public/images/team/jason.png Binary files differnew file mode 100644 index 000000000..a39522252 --- /dev/null +++ b/packages/website/public/images/team/jason.png diff --git a/packages/website/public/images/team/rahul.png b/packages/website/public/images/team/rahul.png Binary files differnew file mode 100644 index 000000000..b63cc12b1 --- /dev/null +++ b/packages/website/public/images/team/rahul.png diff --git a/packages/website/public/images/team/weijie.png b/packages/website/public/images/team/weijie.png Binary files differnew file mode 100644 index 000000000..69fd51794 --- /dev/null +++ b/packages/website/public/images/team/weijie.png diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts index 632a63016..c420bbf3a 100644 --- a/packages/website/ts/blockchain.ts +++ b/packages/website/ts/blockchain.ts @@ -66,7 +66,7 @@ const providerToName: { [provider: string]: string } = { [Providers.Metamask]: constants.PROVIDER_NAME_METAMASK, [Providers.Parity]: constants.PROVIDER_NAME_PARITY_SIGNER, [Providers.Mist]: constants.PROVIDER_NAME_MIST, - [Providers.Toshi]: constants.PROVIDER_NAME_TOSHI, + [Providers.CoinbaseWallet]: constants.PROVIDER_NAME_COINBASE_WALLET, [Providers.Cipher]: constants.PROVIDER_NAME_CIPHER, }; diff --git a/packages/website/ts/components/onboarding/install_wallet_onboarding_step.tsx b/packages/website/ts/components/onboarding/install_wallet_onboarding_step.tsx index d618c8318..1035d4ad9 100644 --- a/packages/website/ts/components/onboarding/install_wallet_onboarding_step.tsx +++ b/packages/website/ts/components/onboarding/install_wallet_onboarding_step.tsx @@ -12,7 +12,7 @@ export const InstallWalletOnboardingStep: React.StatelessComponent<InstallWallet const followupText = isOnMobile ? `Please revisit this site in your mobile dApp browser to continue!` : `Please refresh the page once you've done this to continue!`; - const downloadText = isOnMobile ? 'Get the Toshi Wallet' : 'Get the MetaMask extension'; + const downloadText = isOnMobile ? 'Get Coinbase Wallet' : 'Get the MetaMask extension'; return ( <div className="flex items-center flex-column"> <Text>First, you need to connect to a wallet. This will be used across all 0x relayers and dApps.</Text> @@ -21,7 +21,7 @@ export const InstallWalletOnboardingStep: React.StatelessComponent<InstallWallet height="50px" width="50px" borderRadius="22%" - src={isOnMobile ? '/images/toshi_logo.jpg' : '/images/metamask_icon.png'} + src={isOnMobile ? '/images/coinbase_wallet_logo.png' : '/images/metamask_icon.png'} /> <Container marginLeft="10px"> <a href={downloadLink} target="_blank"> diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx index b8d7ceea9..b42954f60 100644 --- a/packages/website/ts/components/portal/portal.tsx +++ b/packages/website/ts/components/portal/portal.tsx @@ -545,7 +545,7 @@ export class Portal extends React.Component<PortalProps, PortalState> { <Section header={!isMobile && <TextHeader labelText="0x Relayers" />} body={ - <Container className="flex flex-column items-center"> + <Container className="flex flex-column"> {isMobile && ( <Container marginTop="20px" marginBottom="20px"> {this._renderStartOnboarding()} diff --git a/packages/website/ts/components/relayer_index/relayer_index.tsx b/packages/website/ts/components/relayer_index/relayer_index.tsx index 4aea1bbbb..91dbeb27a 100644 --- a/packages/website/ts/components/relayer_index/relayer_index.tsx +++ b/packages/website/ts/components/relayer_index/relayer_index.tsx @@ -56,7 +56,11 @@ export class RelayerIndex extends React.Component<RelayerIndexProps, RelayerInde </div> ); } else { - const numberOfColumns = this._numberOfColumnsForScreenWidth(this.props.screenWidth); + const numberOfRelayers = this.state.relayerInfos.length; + const numberOfColumns = Math.min( + numberOfRelayers, + this._numberOfColumnsForScreenWidth(this.props.screenWidth), + ); return ( <GridList cellHeight={CELL_HEIGHT} diff --git a/packages/website/ts/components/top_bar/top_bar.tsx b/packages/website/ts/components/top_bar/top_bar.tsx index bb61e4fb9..7cf3c6ecb 100644 --- a/packages/website/ts/components/top_bar/top_bar.tsx +++ b/packages/website/ts/components/top_bar/top_bar.tsx @@ -136,7 +136,7 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> { <Link key="subMenuItem-smartContracts" to={WebsitePaths.SmartContracts} className="text-decoration-none"> <MenuItem style={{ fontSize: styles.menuItem.fontSize }} - primaryText={this.props.translate.get(Key.SmartContract, Deco.CapWords)} + primaryText={this.props.translate.get(Key.SmartContracts, Deco.CapWords)} /> </Link>, <Link key="subMenuItem-0xconnect" to={WebsitePaths.Connect} className="text-decoration-none"> diff --git a/packages/website/ts/components/wallet/body_overlay.tsx b/packages/website/ts/components/wallet/body_overlay.tsx index 26359d0d2..3795f0eaa 100644 --- a/packages/website/ts/components/wallet/body_overlay.tsx +++ b/packages/website/ts/components/wallet/body_overlay.tsx @@ -13,7 +13,7 @@ import { AccountState, ProviderType } from 'ts/types'; import { utils } from 'ts/utils/utils'; const METAMASK_IMG_SRC = '/images/metamask_icon.png'; -const TOSHI_IMG_SRC = '/images/toshi_logo.jpg'; +const COINBASE_WALLET_IMG_SRC = '/images/coinbase_wallet_logo.png'; export interface BodyOverlayProps { dispatcher: Dispatcher; @@ -116,8 +116,8 @@ const UseDifferentWallet = (props: UseDifferentWallet) => { const GetWalletCallToAction = () => { const [downloadLink, isOnMobile] = utils.getBestWalletDownloadLinkAndIsMobile(); - const imageUrl = isOnMobile ? TOSHI_IMG_SRC : METAMASK_IMG_SRC; - const text = isOnMobile ? 'Get Toshi Wallet' : 'Get MetaMask Wallet'; + const imageUrl = isOnMobile ? COINBASE_WALLET_IMG_SRC : METAMASK_IMG_SRC; + const text = isOnMobile ? 'Get Coinbase Wallet' : 'Get MetaMask Wallet'; return ( <a href={downloadLink} target="_blank" style={{ textDecoration: 'none' }}> <Island diff --git a/packages/website/ts/containers/smart_contracts_documentation.ts b/packages/website/ts/containers/smart_contracts_documentation.ts index 4f4479c83..05b2a50c3 100644 --- a/packages/website/ts/containers/smart_contracts_documentation.ts +++ b/packages/website/ts/containers/smart_contracts_documentation.ts @@ -11,55 +11,82 @@ import { Translate } from 'ts/utils/translate'; /* tslint:disable:no-var-requires */ const IntroMarkdownV1 = require('md/docs/smart_contracts/1.0.0/introduction'); +const IntroMarkdownV2 = require('md/docs/smart_contracts/2.0.0/introduction'); /* tslint:enable:no-var-requires */ const docsInfoConfig: DocsInfoConfig = { id: DocPackages.SmartContracts, packageName: 'contracts', - type: SupportedDocJson.Doxity, + type: SupportedDocJson.SolDoc, displayName: '0x Smart Contracts', packageUrl: 'https://github.com/0xProject/contracts', markdownMenu: { introduction: [Sections.Introduction], - contracts: [Sections.Exchange, Sections.TokenRegistry, Sections.ZRXToken, Sections.TokenTransferProxy], }, sectionNameToMarkdownByVersion: { '0.0.1': { [Sections.Introduction]: IntroMarkdownV1, }, + '2.0.0': { + [Sections.Introduction]: IntroMarkdownV2, + }, }, markdownSections: { Introduction: Sections.Introduction, - Exchange: Sections.Exchange, - TokenTransferProxy: Sections.TokenTransferProxy, - TokenRegistry: Sections.TokenRegistry, - ZRXToken: Sections.ZRXToken, }, contractsByVersionByNetworkId: { '1.0.0': { [Networks.Mainnet]: { - [Sections.Exchange]: '0x12459c951127e0c374ff9105dda097662a027093', - [Sections.TokenTransferProxy]: '0x8da0d80f5007ef1e431dd2127178d224e32c2ef4', - [Sections.ZRXToken]: '0xe41d2489571d322189246dafa5ebde1f4699f498', - [Sections.TokenRegistry]: '0x926a74c5c36adf004c87399e65f75628b0f98d2c', + Exchange_v1: '0x12459c951127e0c374ff9105dda097662a027093', + TokenTransferProxy_v1: '0x8da0d80f5007ef1e431dd2127178d224e32c2ef4', + TokenRegistry: '0x926a74c5c36adf004c87399e65f75628b0f98d2c', }, [Networks.Ropsten]: { - [Sections.Exchange]: '0x479cc461fecd078f766ecc58533d6f69580cf3ac', - [Sections.TokenTransferProxy]: '0x4e9aad8184de8833365fea970cd9149372fdf1e6', - [Sections.ZRXToken]: '0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d', - [Sections.TokenRegistry]: '0x6b1a50f0bb5a7995444bd3877b22dc89c62843ed', + Exchange_v1: '0x479cc461fecd078f766ecc58533d6f69580cf3ac', + TokenTransferProxy_v1: '0x4e9aad8184de8833365fea970cd9149372fdf1e6', + TokenRegistry: '0x6b1a50f0bb5a7995444bd3877b22dc89c62843ed', }, [Networks.Kovan]: { - [Sections.Exchange]: '0x90fe2af704b34e0224bf2299c838e04d4dcf1364', - [Sections.TokenTransferProxy]: '0x087Eed4Bc1ee3DE49BeFbd66C662B434B15d49d4', - [Sections.ZRXToken]: '0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570', - [Sections.TokenRegistry]: '0xf18e504561f4347bea557f3d4558f559dddbae7f', + Exchange_v1: '0x90fe2af704b34e0224bf2299c838e04d4dcf1364', + TokenTransferProxy_v1: '0x087Eed4Bc1ee3DE49BeFbd66C662B434B15d49d4', + TokenRegistry: '0xf18e504561f4347bea557f3d4558f559dddbae7f', }, [Networks.Rinkeby]: { - [Sections.Exchange]: '0x1d16ef40fac01cec8adac2ac49427b9384192c05', - [Sections.TokenTransferProxy]: '0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d', - [Sections.ZRXToken]: '0x00f58d6d585f84b2d7267940cede30ce2fe6eae8', - [Sections.TokenRegistry]: '0x4e9aad8184de8833365fea970cd9149372fdf1e6', + Exchange_v1: '0x1d16ef40fac01cec8adac2ac49427b9384192c05', + TokenTransferProxy_v1: '0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d', + TokenRegistry: '0x4e9aad8184de8833365fea970cd9149372fdf1e6', + }, + }, + '2.0.0': { + [Networks.Mainnet]: { + AssetProxyOwner: '0x17992e4ffb22730138e4b62aaa6367fa9d3699a6', + ERC20Proxy: '0x2240dab907db71e64d3e0dba4800c83b5c502d4e', + ERC721Proxy: '0x208e41fb445f1bb1b6780d58356e81405f3e6127', + Exchange: '0x4f833a24e1f95d70f028921e27040ca56e09ab0b', + Forwarder: '0x7afc2d5107af94c462a194d2c21b5bdd238709d6', + OrderValidator: '0x9463e518dea6810309563c81d5266c1b1d149138', + WETH9: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + ZRXToken: '0xe41d2489571d322189246dafa5ebde1f4699f498', + }, + [Networks.Ropsten]: { + AssetProxyOwner: '0xf5fa5b5fed2727a0e44ac67f6772e97977aa358b', + ERC20Proxy: '0xb1408f4c245a23c31b98d2c626777d4c0d766caa', + ERC721Proxy: '0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4', + Exchange: '0x4530c0483a1633c7a1c97d2c53721caff2caaaaf', + Forwarder: '0x3983e204b12b3c02fb0638caf2cd406a62e0ead3', + OrderValidator: '0x90431a90516ab49af23a0530e04e8c7836e7122f', + WETH9: '0xc778417e063141139fce010982780140aa0cd5ab', + ZRXToken: '0xff67881f8d12f372d91baae9752eb3631ff0ed00', + }, + [Networks.Kovan]: { + AssetProxyOwner: '0x2c824d2882baa668e0d5202b1e7f2922278703f8', + ERC20Proxy: '0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e', + ERC721Proxy: '0x2a9127c745688a165106c11cd4d647d2220af821', + Exchange: '0x35dd2932454449b14cee11a94d3674a936d5d7b2', + Forwarder: '0xd85e2fa7e7e252b27b01bf0d65c946959d2f45b8', + OrderValidator: '0xb389da3d204b412df2f75c6afb3d0a7ce0bc283d', + WETH9: '0xd0a1e359811322d97991e03f863a0c30c2cf029c', + ZRXToken: '0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa', }, }, }, diff --git a/packages/website/ts/pages/about/about.tsx b/packages/website/ts/pages/about/about.tsx index 42237bec3..037647161 100644 --- a/packages/website/ts/pages/about/about.tsx +++ b/packages/website/ts/pages/about/about.tsx @@ -194,7 +194,7 @@ const teamRow6: ProfileInfo[] = [ const teamRow7: ProfileInfo[] = [ { name: 'Clay Robbins', - title: 'Business Development Lead', + title: 'Ecosystem Development Lead', description: `Growth & Business Development. Previously product and partnerships at Square. Economics at Dartmouth College.`, image: 'images/team/clay.png', linkedIn: 'https://www.linkedin.com/in/robbinsclay/', @@ -216,6 +216,30 @@ const teamRow7: ProfileInfo[] = [ }, ]; +const teamRow8: ProfileInfo[] = [ + { + name: 'Weijie Wu', + title: 'Research Fellow', + description: `Researching decentralized governance. Previously Researcher at Huawei and Assistant Professor at Shanghai Jiao Tong University. PhD in Computer Science at The Chinese University of Hong Kong.`, + image: 'images/team/weijie.png', + linkedIn: 'https://www.linkedin.com/in/weijiewu/', + }, + { + name: 'Rahul Singireddy', + title: 'Relayer Success Manager', + description: `Previously community at Zeppelin, growth at Dharma, and cryptocurrency contributor at Forbes. Symbolic Systems at Stanford.`, + image: 'images/team/rahul.png', + linkedIn: 'https://www.linkedin.com/in/rahul-singireddy-3037908a/', + }, + { + name: 'Jason Somensatto', + title: 'Strategic Legal Counsel', + description: `Legal. Previously head of blockchain and crypto practice at Orrick. JD from George Washington University and undergrad at UVA.`, + image: 'images/team/jason.png', + linkedIn: 'https://www.linkedin.com/in/jasonsomensatto/', + }, +]; + const advisors1: ProfileInfo[] = [ { name: 'Fred Ehrsam', @@ -323,6 +347,7 @@ export class About extends React.Component<AboutProps, AboutState> { <div className="clearfix">{this._renderProfiles(teamRow5)}</div> <div className="clearfix">{this._renderProfiles(teamRow6)}</div> <div className="clearfix">{this._renderProfiles(teamRow7)}</div> + <div className="clearfix">{this._renderProfiles(teamRow8)}</div> </div> <div className="pt3 pb2"> <div diff --git a/packages/website/ts/pages/documentation/doc_page.tsx b/packages/website/ts/pages/documentation/doc_page.tsx index 9c144b93f..87a806b2b 100644 --- a/packages/website/ts/pages/documentation/doc_page.tsx +++ b/packages/website/ts/pages/documentation/doc_page.tsx @@ -1,4 +1,11 @@ -import { DocAgnosticFormat, DocsInfo, Documentation } from '@0xproject/react-docs'; +import { + DocAgnosticFormat, + DocsInfo, + Documentation, + GeneratedDocJson, + SupportedDocJson, + TypeDocUtils, +} from '@0xproject/react-docs'; import findVersions = require('find-versions'); import * as _ from 'lodash'; import * as React from 'react'; @@ -128,7 +135,22 @@ export class DocPage extends React.Component<DocPageProps, DocPageState> { const versionFilePathToFetch = versionToFilePath[versionToFetch]; const versionDocObj = await docUtils.getJSONDocFileAsync(versionFilePathToFetch, docBucketRoot); - const docAgnosticFormat = this.props.docsInfo.convertToDocAgnosticFormat(versionDocObj); + let docAgnosticFormat; + if (this.props.docsInfo.type === SupportedDocJson.TypeDoc) { + docAgnosticFormat = new TypeDocUtils( + versionDocObj as GeneratedDocJson, + this.props.docsInfo, + ).convertToDocAgnosticFormat(); + } else if (this.props.docsInfo.type === SupportedDocJson.SolDoc) { + // documenting solidity. + docAgnosticFormat = versionDocObj as DocAgnosticFormat; + // HACK: need to modify docsInfo like convertToDocAgnosticFormat() would do + this.props.docsInfo.menu.Contracts = []; + _.each(docAgnosticFormat, (_docObj, sectionName) => { + this.props.docsInfo.sections[sectionName] = sectionName; + this.props.docsInfo.menu.Contracts.push(sectionName); + }); + } if (!this._isUnmounted) { this.setState({ diff --git a/packages/website/ts/pages/landing/landing.tsx b/packages/website/ts/pages/landing/landing.tsx index 211be7bf2..388e83d51 100644 --- a/packages/website/ts/pages/landing/landing.tsx +++ b/packages/website/ts/pages/landing/landing.tsx @@ -37,8 +37,8 @@ interface Project { } const THROTTLE_TIMEOUT = 100; -const WHATS_NEW_TITLE = '18 ideas for 0x relayers in 2018'; -const WHATS_NEW_URL = 'https://blog.0xproject.com/18-ideas-for-0x-relayers-in-2018-80a1498b955f'; +const WHATS_NEW_TITLE = '0x Protocol v2 is Live!'; +const WHATS_NEW_URL = 'https://blog.0xproject.com/0x-protocol-v2-0-is-live-183aac180149'; const TITLE_STYLE: React.CSSProperties = { fontFamily: 'Roboto Mono', color: colors.grey, diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts index 3c6d3df4d..4ec45c46e 100644 --- a/packages/website/ts/types.ts +++ b/packages/website/ts/types.ts @@ -491,7 +491,7 @@ export enum Providers { Parity = 'PARITY', Metamask = 'METAMASK', Mist = 'MIST', - Toshi = 'TOSHI', + CoinbaseWallet = 'COINBASE_WALLET', Cipher = 'CIPHER', } diff --git a/packages/website/ts/utils/constants.ts b/packages/website/ts/utils/constants.ts index 23d419907..18a4d8100 100644 --- a/packages/website/ts/utils/constants.ts +++ b/packages/website/ts/utils/constants.ts @@ -31,7 +31,7 @@ export const constants = { PROVIDER_NAME_PARITY_SIGNER: 'Parity Signer', PROVIDER_NAME_MIST: 'Mist', PROVIDER_NAME_CIPHER: 'Cipher Browser', - PROVIDER_NAME_TOSHI: 'Toshi', + PROVIDER_NAME_COINBASE_WALLET: 'Coinbase Wallet', PROVIDER_NAME_GENERIC: 'Injected Web3', PROVIDER_NAME_PUBLIC: '0x Public', ROLLBAR_ACCESS_TOKEN: '32c39bfa4bb6440faedc1612a9c13d28', @@ -76,8 +76,8 @@ export const constants = { URL_GITHUB_WIKI: 'https://github.com/0xProject/wiki', URL_METAMASK_CHROME_STORE: 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn', URL_METAMASK_FIREFOX_STORE: 'https://addons.mozilla.org/en-US/firefox/addon/ether-metamask/', - URL_TOSHI_IOS_APP_STORE: 'https://itunes.apple.com/us/app/toshi-ethereum-wallet/id1278383455?mt=8', - URL_TOSHI_ANDROID_APP_STORE: 'https://play.google.com/store/apps/details?id=org.toshi&hl=en_US', + URL_COINBASE_WALLET_IOS_APP_STORE: 'https://itunes.apple.com/us/app/coinbase-wallet/id1278383455?mt=8', + URL_COINBASE_WALLET_ANDROID_APP_STORE: 'https://play.google.com/store/apps/details?id=org.toshi&hl=en', URL_METAMASK_HOMEPAGE: 'https://metamask.io/', URL_METAMASK_OPERA_STORE: 'https://addons.opera.com/en/extensions/details/metamask/', URL_MIST_DOWNLOAD: 'https://github.com/ethereum/mist/releases', diff --git a/packages/website/ts/utils/doc_utils.ts b/packages/website/ts/utils/doc_utils.ts index e313648bd..0e1d9ea6e 100644 --- a/packages/website/ts/utils/doc_utils.ts +++ b/packages/website/ts/utils/doc_utils.ts @@ -1,4 +1,4 @@ -import { DoxityDocObj, GeneratedDocJson } from '@0xproject/react-docs'; +import { DocAgnosticFormat, GeneratedDocJson } from '@0xproject/react-docs'; import { fetchAsync, logUtils } from '@0xproject/utils'; import * as _ from 'lodash'; import { S3FileObject, VersionToFilePath } from 'ts/types'; @@ -70,7 +70,7 @@ export const docUtils = { }); return versionFilePaths; }, - async getJSONDocFileAsync(filePath: string, s3DocJsonRoot: string): Promise<GeneratedDocJson | DoxityDocObj> { + async getJSONDocFileAsync(filePath: string, s3DocJsonRoot: string): Promise<GeneratedDocJson | DocAgnosticFormat> { const endpoint = `${s3DocJsonRoot}/${filePath}`; const response = await fetchAsync(endpoint); if (response.status !== 200) { diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts index b45e37aeb..d083e0ffc 100644 --- a/packages/website/ts/utils/utils.ts +++ b/packages/website/ts/utils/utils.ts @@ -323,7 +323,7 @@ export const utils = { } else if ((provider as any).isMetaMask) { parsedProviderName = Providers.Metamask; } else if (!_.isUndefined(_.get(window, 'SOFA'))) { - parsedProviderName = Providers.Toshi; + parsedProviderName = Providers.CoinbaseWallet; } else if (!_.isUndefined(_.get(window, '__CIPHER__'))) { parsedProviderName = Providers.Cipher; } @@ -453,14 +453,14 @@ export const utils = { if (isOnMobile) { switch (operatingSystem) { case OperatingSystemType.Android: - downloadLink = constants.URL_TOSHI_ANDROID_APP_STORE; + downloadLink = constants.URL_COINBASE_WALLET_ANDROID_APP_STORE; break; case OperatingSystemType.iOS: - downloadLink = constants.URL_TOSHI_IOS_APP_STORE; + downloadLink = constants.URL_COINBASE_WALLET_IOS_APP_STORE; break; default: - // Toshi is only supported on these mobile OSes - just default to iOS - downloadLink = constants.URL_TOSHI_IOS_APP_STORE; + // Coinbase wallet is only supported on these mobile OSes - just default to iOS + downloadLink = constants.URL_COINBASE_WALLET_IOS_APP_STORE; } } else { switch (browserType) { @@ -676,6 +676,16 @@ ethereum-types "^1.0.5" popper.js "1.14.3" +"@0xproject/typescript-typings@^2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@0xproject/typescript-typings/-/typescript-typings-2.0.2.tgz#1812f64e341f1d24c09b8b5a951cbde0e5fff9c2" + dependencies: + "@types/bn.js" "^4.11.0" + "@types/react" "*" + bignumber.js "~4.1.0" + ethereum-types "^1.0.8" + popper.js "1.14.3" + "@0xproject/utils@^0.7.3": version "0.7.3" resolved "https://registry.yarnpkg.com/@0xproject/utils/-/utils-0.7.3.tgz#ffa7c6da9bf0dd3e13694f185dcfc48a8981ff05" @@ -690,6 +700,23 @@ lodash "4.17.10" web3 "0.20.6" +"@0xproject/utils@^1.0.4": + version "1.0.11" + resolved "https://registry.yarnpkg.com/@0xproject/utils/-/utils-1.0.11.tgz#5b53e7d9d4dbe68e219049218c9db04e97c37429" + dependencies: + "@0xproject/types" "^1.1.1" + "@0xproject/typescript-typings" "^2.0.2" + "@types/node" "*" + abortcontroller-polyfill "^1.1.9" + bignumber.js "~4.1.0" + detect-node "2.0.3" + ethereum-types "^1.0.8" + ethereumjs-util "^5.1.1" + ethers "3.0.22" + isomorphic-fetch "^2.2.1" + js-sha3 "^0.7.0" + lodash "^4.17.5" + "@0xproject/web3-wrapper@^0.7.3": version "0.7.3" resolved "https://registry.yarnpkg.com/@0xproject/web3-wrapper/-/web3-wrapper-0.7.3.tgz#9bd50b034b92fd505b6766b6e225f014b6d08b08" @@ -1071,6 +1098,10 @@ version "9.6.0" resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.0.tgz#d3480ee666df9784b1001a1872a2f6ccefb6c2d7" +"@types/node@^10.3.2": + version "10.9.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.9.4.tgz#0f4cb2dc7c1de6096055357f70179043c33e9897" + "@types/node@^10.5.3": version "10.5.7" resolved "https://registry.npmjs.org/@types/node/-/node-10.5.7.tgz#960d9feb3ade2233bcc9843c918d740b4f78a7cf" @@ -1358,7 +1389,7 @@ aes-js@3.0.0: aes-js@^3.1.1: version "3.1.1" - resolved "https://registry.npmjs.org/aes-js/-/aes-js-3.1.1.tgz#89fd1f94ae51b4c72d62466adc1a7323ff52f072" + resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.1.1.tgz#89fd1f94ae51b4c72d62466adc1a7323ff52f072" ajv-keywords@^2.1.0: version "2.1.1" @@ -1449,7 +1480,7 @@ ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" -ansi-styles@^3.2.0, ansi-styles@^3.2.1: +ansi-styles@^3.1.0, ansi-styles@^3.2.0, ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" dependencies: @@ -1776,6 +1807,19 @@ aws4@^1.8.0: version "1.8.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f" +axios@0.15.3: + version "0.15.3" + resolved "http://registry.npmjs.org/axios/-/axios-0.15.3.tgz#2c9d638b2e191a08ea1d6cc988eadd6ba5bdc053" + dependencies: + follow-redirects "1.0.0" + +axios@^0.17.0: + version "0.17.1" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.17.1.tgz#2d8e3e5d0bdbd7327f91bc814f5c57660f81824d" + dependencies: + follow-redirects "^1.2.5" + is-buffer "^1.1.5" + babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" @@ -2755,6 +2799,13 @@ brorand@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" +brotli-size@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/brotli-size/-/brotli-size-0.0.1.tgz#8c1aeea01cd22f359b048951185bd539ff0c829f" + dependencies: + duplexer "^0.1.1" + iltorb "^1.0.9" + browser-stdout@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" @@ -2847,7 +2898,7 @@ bs58@^2.0.1: bs58check@^2.1.2: version "2.1.2" - resolved "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc" + resolved "https://registry.yarnpkg.com/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc" dependencies: bs58 "^4.0.0" create-hash "^1.1.0" @@ -2928,11 +2979,26 @@ builtins@^1.0.3: version "1.0.3" resolved "http://registry.yarnpkg.com/builtins/-/builtins-1.0.3.tgz#cb94faeb61c8696451db36534e1422f94f0aee88" +bundlesize@^0.17.0: + version "0.17.0" + resolved "https://registry.yarnpkg.com/bundlesize/-/bundlesize-0.17.0.tgz#212ae5731ab0554d2acd509d23e1de18640b2008" + dependencies: + axios "^0.17.0" + brotli-size "0.0.1" + bytes "^3.0.0" + ci-env "^1.4.0" + commander "^2.11.0" + github-build "^1.2.0" + glob "^7.1.2" + gzip-size "^4.0.0" + prettycli "^1.4.3" + read-pkg-up "^3.0.0" + byline@^5.0.0: version "5.0.0" resolved "http://registry.yarnpkg.com/byline/-/byline-5.0.0.tgz#741c5216468eadc457b03410118ad77de8c1ddb1" -bytes@3.0.0: +bytes@3.0.0, bytes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" @@ -3125,6 +3191,14 @@ chain-function@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/chain-function/-/chain-function-1.0.0.tgz#0d4ab37e7e18ead0bdc47b920764118ce58733dc" +chalk@2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e" + dependencies: + ansi-styles "^3.1.0" + escape-string-regexp "^1.0.5" + supports-color "^4.0.0" + chalk@2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.2.tgz#250dc96b07491bfd601e648d66ddf5f60c7a5c65" @@ -3272,6 +3346,10 @@ chownr@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.0.1.tgz#e2a75042a9551908bebd25b8523d5f9769d79181" +ci-env@^1.4.0: + version "1.6.1" + resolved "https://registry.yarnpkg.com/ci-env/-/ci-env-1.6.1.tgz#3e3ef4fc528a2825397f912cfa30cde17ec364cc" + ci-info@^1.0.0: version "1.1.3" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.1.3.tgz#710193264bb05c77b8c90d02f5aaf22216a667b2" @@ -3556,6 +3634,10 @@ commander@2.15.1, commander@^2.12.1, commander@^2.8.1: version "2.15.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" +commander@^2.11.0: + version "2.18.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.18.0.tgz#2bf063ddee7c7891176981a2cc798e5754bc6970" + commander@^2.7.1: version "2.17.1" resolved "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" @@ -4173,7 +4255,7 @@ debug@2.6.9, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.6, debug@^2.6. dependencies: ms "2.0.0" -debug@3.1.0, debug@^3.1.0: +debug@3.1.0, debug@=3.1.0, debug@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" dependencies: @@ -4466,6 +4548,10 @@ detect-indent@^5.0.0: version "5.0.0" resolved "http://registry.yarnpkg.com/detect-indent/-/detect-indent-5.0.0.tgz#3871cc0a6a002e8c3e5b3cf7f336264675f06b9d" +detect-libc@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-0.2.0.tgz#47fdf567348a17ec25fcbf0b9e446348a76f9fb5" + detect-libc@^1.0.2, detect-libc@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" @@ -5203,6 +5289,14 @@ ethereumjs-blockstream@5.0.0: source-map-support "0.5.6" uuid "3.2.1" +ethereumjs-blockstream@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/ethereumjs-blockstream/-/ethereumjs-blockstream-6.0.0.tgz#79d726d1f358935eb65195e91d40344c31e87eff" + dependencies: + immutable "3.8.2" + source-map-support "0.5.6" + uuid "3.2.1" + ethereumjs-tx@0xProject/ethereumjs-tx#fake-tx-include-signature-by-default: version "1.3.4" resolved "https://codeload.github.com/0xProject/ethereumjs-tx/tar.gz/29d1153889c389591f74b2401da8a0c6ad40f9a7" @@ -5285,7 +5379,7 @@ ethereumjs-vm@^2.0.2, ethereumjs-vm@^2.1.0, ethereumjs-vm@^2.3.4: ethereumjs-wallet@~0.6.0: version "0.6.2" - resolved "https://registry.npmjs.org/ethereumjs-wallet/-/ethereumjs-wallet-0.6.2.tgz#67244b6af3e8113b53d709124b25477b64aeccda" + resolved "https://registry.yarnpkg.com/ethereumjs-wallet/-/ethereumjs-wallet-0.6.2.tgz#67244b6af3e8113b53d709124b25477b64aeccda" dependencies: aes-js "^3.1.1" bs58check "^2.1.2" @@ -5296,9 +5390,9 @@ ethereumjs-wallet@~0.6.0: utf8 "^3.0.0" uuid "^3.3.2" -ethers@0xproject/ethers.js#eip-838-reasons, ethers@3.0.22: - version "3.0.18" - resolved "https://codeload.github.com/0xproject/ethers.js/tar.gz/b91342bd200d142af0165d6befddf783c8ae8447" +ethers@3.0.22: + version "3.0.22" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-3.0.22.tgz#7fab1ea16521705837aa43c15831877b2716b436" dependencies: aes-js "3.0.0" bn.js "^4.4.0" @@ -5311,6 +5405,21 @@ ethers@0xproject/ethers.js#eip-838-reasons, ethers@3.0.22: uuid "2.0.1" xmlhttprequest "1.8.0" +ethers@4.0.0-beta.14: + version "4.0.0-beta.14" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-4.0.0-beta.14.tgz#76aa9257b9c93a7604ff4dc11f2a445d07f6459d" + dependencies: + "@types/node" "^10.3.2" + aes-js "3.0.0" + bn.js "^4.4.0" + elliptic "6.3.3" + hash.js "1.1.3" + js-sha3 "0.5.7" + scrypt-js "2.0.3" + setimmediate "1.0.4" + uuid "2.0.1" + xmlhttprequest "1.8.0" + ethjs-abi@0.1.8: version "0.1.8" resolved "https://registry.yarnpkg.com/ethjs-abi/-/ethjs-abi-0.1.8.tgz#cd288583ed628cdfadaf8adefa3ba1dbcbca6c18" @@ -5841,6 +5950,18 @@ flush-write-stream@^1.0.0, flush-write-stream@^1.0.2: inherits "^2.0.1" readable-stream "^2.0.4" +follow-redirects@1.0.0: + version "1.0.0" + resolved "http://registry.npmjs.org/follow-redirects/-/follow-redirects-1.0.0.tgz#8e34298cbd2e176f254effec75a1c78cc849fd37" + dependencies: + debug "^2.2.0" + +follow-redirects@^1.2.5: + version "1.5.8" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.8.tgz#1dbfe13e45ad969f813e86c00e5296f525c885a1" + dependencies: + debug "=3.1.0" + for-each@^0.3.2, for-each@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.2.tgz#2c40450b9348e97f281322593ba96704b9abd4d4" @@ -6205,6 +6326,12 @@ gitconfiglocal@^1.0.0: dependencies: ini "^1.3.2" +github-build@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/github-build/-/github-build-1.2.0.tgz#b0bdb705ae4088218577e863c1a301030211051f" + dependencies: + axios "0.15.3" + github-from-package@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce" @@ -6571,6 +6698,13 @@ gulplog@^1.0.0: dependencies: glogg "^1.0.0" +gzip-size@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-4.1.0.tgz#8ae096257eabe7d69c45be2b67c448124ffb517c" + dependencies: + duplexer "^0.1.1" + pify "^3.0.0" + handle-thing@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-1.2.5.tgz#fd7aad726bf1a5fd16dfc29b2f7a6601d27139c4" @@ -6710,7 +6844,7 @@ hash-base@^3.0.0: inherits "^2.0.1" safe-buffer "^5.0.1" -hash.js@^1.0.0, hash.js@^1.0.3: +hash.js@1.1.3, hash.js@^1.0.0, hash.js@^1.0.3: version "1.1.3" resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.3.tgz#340dedbe6290187151c1ea1d777a3448935df846" dependencies: @@ -6744,7 +6878,7 @@ hdkey@^0.7.1: hdkey@^1.0.0: version "1.1.0" - resolved "https://registry.npmjs.org/hdkey/-/hdkey-1.1.0.tgz#e74e7b01d2c47f797fa65d1d839adb7a44639f29" + resolved "https://registry.yarnpkg.com/hdkey/-/hdkey-1.1.0.tgz#e74e7b01d2c47f797fa65d1d839adb7a44639f29" dependencies: coinstring "^2.0.0" safe-buffer "^5.1.1" @@ -7013,6 +7147,15 @@ ignore@^3.3.5: version "3.3.7" resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.7.tgz#612289bfb3c220e186a58118618d5be8c1bab021" +iltorb@^1.0.9: + version "1.3.10" + resolved "https://registry.yarnpkg.com/iltorb/-/iltorb-1.3.10.tgz#a0d9e4e7d52bf510741442236cbe0cc4230fc9f8" + dependencies: + detect-libc "^0.2.0" + nan "^2.6.2" + node-gyp "^3.6.2" + prebuild-install "^2.3.0" + image-size@~0.5.0: version "0.5.5" resolved "https://registry.yarnpkg.com/image-size/-/image-size-0.5.5.tgz#09dfd4ab9d20e29eb1c3e80b8990378df9e3cb9c" @@ -7202,6 +7345,10 @@ invert-kv@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" +invert-kv@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02" + ip@^1.1.0, ip@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a" @@ -8109,6 +8256,12 @@ lcid@^1.0.0: dependencies: invert-kv "^1.0.0" +lcid@^2.0.0: + version "2.0.0" + resolved "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz#6ef5d2df60e52f82eb228a4c373e8d1f397253cf" + dependencies: + invert-kv "^2.0.0" + lcov-parse@^0.0.10: version "0.0.10" resolved "https://registry.yarnpkg.com/lcov-parse/-/lcov-parse-0.0.10.tgz#1b0b8ff9ac9c7889250582b70b71315d9da6d9a3" @@ -8767,6 +8920,12 @@ make-promises-safe@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/make-promises-safe/-/make-promises-safe-1.1.0.tgz#b4d28c61ef8ad5502f38dbb3a0ee89627f76ad61" +map-age-cleaner@^0.1.1: + version "0.1.2" + resolved "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.2.tgz#098fb15538fd3dbe461f12745b0ca8568d4e3f74" + dependencies: + p-defer "^1.0.0" + map-cache@^0.2.0, map-cache@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" @@ -8876,6 +9035,14 @@ mem@^1.1.0: dependencies: mimic-fn "^1.0.0" +mem@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/mem/-/mem-4.0.0.tgz#6437690d9471678f6cc83659c00cbafcd6b0cdaf" + dependencies: + map-age-cleaner "^0.1.1" + mimic-fn "^1.0.0" + p-is-promise "^1.1.0" + memdown@^1.0.0: version "1.4.1" resolved "https://registry.yarnpkg.com/memdown/-/memdown-1.4.1.tgz#b4e4e192174664ffbae41361aa500f3119efe215" @@ -10021,6 +10188,14 @@ os-locale@^2.0.0: lcid "^1.0.0" mem "^1.1.0" +os-locale@^3.0.0: + version "3.0.1" + resolved "https://registry.npmjs.org/os-locale/-/os-locale-3.0.1.tgz#3b014fbf01d87f60a1e5348d80fe870dc82c4620" + dependencies: + execa "^0.10.0" + lcid "^2.0.0" + mem "^4.0.0" + os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1, os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -10040,6 +10215,10 @@ p-cancelable@^0.4.0: version "0.4.1" resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-0.4.1.tgz#35f363d67d52081c8d9585e37bcceb7e0bbcb2a0" +p-defer@^1.0.0: + version "1.0.0" + resolved "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" + p-each-series@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-each-series/-/p-each-series-1.0.0.tgz#930f3d12dd1f50e7434457a22cd6f04ac6ad7f71" @@ -10785,7 +10964,7 @@ postman-url-encoder@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/postman-url-encoder/-/postman-url-encoder-1.0.1.tgz#a094a42e9415ff0bbfdce0eaa8e6011d449ee83c" -prebuild-install@^2.2.2: +prebuild-install@^2.2.2, prebuild-install@^2.3.0: version "2.5.3" resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.5.3.tgz#9f65f242782d370296353710e9bc843490c19f69" dependencies: @@ -10857,6 +11036,12 @@ pretty-ms@3.1.0: parse-ms "^1.0.0" plur "^2.1.2" +prettycli@^1.4.3: + version "1.4.3" + resolved "https://registry.yarnpkg.com/prettycli/-/prettycli-1.4.3.tgz#b28ec2aad9de07ae1fd75ef294fb54cbdee07ed5" + dependencies: + chalk "2.1.0" + prismjs@^1.15.0: version "1.15.0" resolved "https://registry.npmjs.org/prismjs/-/prismjs-1.15.0.tgz#8801d332e472091ba8def94976c8877ad60398d9" @@ -13206,7 +13391,7 @@ supports-color@^3.1.0, supports-color@^3.1.2, supports-color@^3.2.3: dependencies: has-flag "^1.0.0" -supports-color@^4.2.1: +supports-color@^4.0.0, supports-color@^4.2.1: version "4.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.5.0.tgz#be7a0de484dec5c5cddf8b3d59125044912f635b" dependencies: @@ -14244,7 +14429,7 @@ utf8@^2.1.1: utf8@^3.0.0: version "3.0.0" - resolved "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1" + resolved "https://registry.yarnpkg.com/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1" util-deprecate@~1.0.1: version "1.0.2" @@ -15377,6 +15562,23 @@ yargs@^12.0.1: y18n "^3.2.1 || ^4.0.0" yargs-parser "^10.1.0" +yargs@^12.0.2: + version "12.0.2" + resolved "https://registry.npmjs.org/yargs/-/yargs-12.0.2.tgz#fe58234369392af33ecbef53819171eff0f5aadc" + dependencies: + cliui "^4.0.0" + decamelize "^2.0.0" + find-up "^3.0.0" + get-caller-file "^1.0.1" + os-locale "^3.0.0" + require-directory "^2.1.1" + require-main-filename "^1.0.1" + set-blocking "^2.0.0" + string-width "^2.0.0" + which-module "^2.0.0" + y18n "^3.2.1 || ^4.0.0" + yargs-parser "^10.1.0" + yargs@^3.7.2: version "3.32.0" resolved "https://registry.npmjs.org/yargs/-/yargs-3.32.0.tgz#03088e9ebf9e756b69751611d2a5ef591482c995" |