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 ...
This commit is contained in:
@@ -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
|
||||
@@ -152,6 +141,10 @@ jobs:
|
||||
key: coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
|
||||
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:
|
||||
@@ -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
|
||||
@@ -218,6 +213,9 @@ jobs:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-sra-report-{{ .Environment.CIRCLE_SHA1 }}
|
||||
|
||||
15
package.json
15
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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ webpack.config.js
|
||||
yarn-error.log
|
||||
test/
|
||||
/src/
|
||||
/_bundles/
|
||||
/contract_templates/
|
||||
/generated_docs/
|
||||
/scripts/
|
||||
|
||||
@@ -1,4 +1,31 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
},
|
||||
|
||||
@@ -1,4 +1,31 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -1,4 +1,31 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
},
|
||||
|
||||
@@ -3,11 +3,38 @@
|
||||
"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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -1,4 +1,36 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -1,4 +1,32 @@
|
||||
[
|
||||
{
|
||||
"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": [
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1537875740,
|
||||
"version": "1.0.5",
|
||||
"timestamp": 1538475601,
|
||||
"version": "2.0.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
@@ -9,14 +9,48 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1537541580,
|
||||
"version": "1.0.4",
|
||||
"timestamp": 1538157789,
|
||||
"version": "2.0.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"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": [
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
|
||||
122
packages/contract-wrappers/test/revert_validation_test.ts
Normal file
122
packages/contract-wrappers/test/revert_validation_test.ts
Normal file
@@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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),
|
||||
);
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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}}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,31 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -1,4 +1,31 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,31 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -1,4 +1,31 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -1,4 +1,31 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,4 +1,33 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export { OrderWatcher } from './order_watcher/order_watcher';
|
||||
export { ExpirationWatcher } from './order_watcher/expiration_watcher';
|
||||
|
||||
export {
|
||||
OrderStateValid,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -1,4 +1,31 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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": "*",
|
||||
|
||||
@@ -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(';
|
||||
|
||||
|
||||
@@ -9,24 +9,23 @@ import {
|
||||
Styles,
|
||||
utils as sharedUtils,
|
||||
} from '@0xproject/react-shared';
|
||||
import {
|
||||
DocAgnosticFormat,
|
||||
Event,
|
||||
ExternalExportToLink,
|
||||
Property,
|
||||
SolidityMethod,
|
||||
TypeDefinitionByName,
|
||||
TypescriptFunction,
|
||||
TypescriptMethod,
|
||||
} 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,
|
||||
DocAgnosticFormat,
|
||||
Event,
|
||||
ExternalExportToLink,
|
||||
Property,
|
||||
SolidityMethod,
|
||||
SupportedDocJson,
|
||||
TypeDefinitionByName,
|
||||
TypescriptFunction,
|
||||
TypescriptMethod,
|
||||
} from '../types';
|
||||
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>
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
@@ -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' }}
|
||||
>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 },
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user