aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-10-05 01:59:55 +0800
committerFabio Berger <me@fabioberger.com>2018-10-05 01:59:55 +0800
commit3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e (patch)
tree87bda5d41b34973960ec230dfb9320e54aea6588 /packages
parente7ab9938ce5bde17600130584fc75bc8a45f6dc5 (diff)
parent2da7626b5356f7b0ec809719f1b9da14b2969a07 (diff)
downloaddexon-sol-tools-3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e.tar
dexon-sol-tools-3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e.tar.gz
dexon-sol-tools-3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e.tar.bz2
dexon-sol-tools-3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e.tar.lz
dexon-sol-tools-3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e.tar.xz
dexon-sol-tools-3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e.tar.zst
dexon-sol-tools-3991e66a58f28dbed5e75f74ef4aaaf6bb3a4d3e.zip
merge developmemnt
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/.npmignore1
-rw-r--r--packages/0x.js/CHANGELOG.json9
-rw-r--r--packages/0x.js/CHANGELOG.md4
-rw-r--r--packages/0x.js/package.json8
-rw-r--r--packages/0x.js/webpack.config.js31
-rw-r--r--packages/abi-gen/CHANGELOG.json9
-rw-r--r--packages/abi-gen/CHANGELOG.md4
-rw-r--r--packages/abi-gen/package.json1
-rw-r--r--packages/assert/CHANGELOG.json9
-rw-r--r--packages/assert/CHANGELOG.md4
-rw-r--r--packages/assert/package.json1
-rw-r--r--packages/asset-buyer/CHANGELOG.json18
-rw-r--r--packages/asset-buyer/CHANGELOG.md4
-rw-r--r--packages/asset-buyer/README.md4
-rw-r--r--packages/asset-buyer/package.json3
-rw-r--r--packages/asset-buyer/src/asset_buyer.ts259
-rw-r--r--packages/asset-buyer/src/constants.ts24
-rw-r--r--packages/asset-buyer/src/index.ts5
-rw-r--r--packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts133
-rw-r--r--packages/asset-buyer/src/types.ts39
-rw-r--r--packages/asset-buyer/src/utils/buy_quote_calculator.ts15
-rw-r--r--packages/asset-buyer/src/utils/order_provider_response_processor.ts76
-rw-r--r--packages/base-contract/CHANGELOG.json9
-rw-r--r--packages/base-contract/CHANGELOG.md4
-rw-r--r--packages/base-contract/package.json1
-rw-r--r--packages/connect/CHANGELOG.json9
-rw-r--r--packages/connect/CHANGELOG.md4
-rw-r--r--packages/connect/package.json1
-rw-r--r--packages/contract-wrappers/CHANGELOG.json9
-rw-r--r--packages/contract-wrappers/CHANGELOG.md4
-rw-r--r--packages/contract-wrappers/package.json2
-rw-r--r--packages/contract-wrappers/src/contract_wrappers.ts2
-rw-r--r--packages/contract-wrappers/src/fetchers/order_filled_cancelled_fetcher.ts1
-rw-r--r--packages/contract-wrappers/src/utils/assert.ts2
-rw-r--r--packages/contract-wrappers/src/utils/decorators.ts5
-rw-r--r--packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts2
-rw-r--r--packages/contract-wrappers/src/utils/filter_utils.ts2
-rw-r--r--packages/contract-wrappers/src/utils/transaction_encoder.ts2
-rw-r--r--packages/contract-wrappers/test/calldata_optimization_utils_test.ts1
-rw-r--r--packages/contract-wrappers/test/erc721_wrapper_test.ts19
-rw-r--r--packages/contract-wrappers/test/ether_token_wrapper_test.ts2
-rw-r--r--packages/contract-wrappers/test/forwarder_wrapper_test.ts10
-rw-r--r--packages/contract-wrappers/test/order_validator_wrapper_test.ts12
-rw-r--r--packages/contract-wrappers/test/subscription_test.ts12
-rw-r--r--packages/contracts/package.json1
-rw-r--r--packages/dev-utils/CHANGELOG.json9
-rw-r--r--packages/dev-utils/CHANGELOG.md4
-rw-r--r--packages/dev-utils/package.json1
-rw-r--r--packages/ethereum-types/CHANGELOG.json9
-rw-r--r--packages/ethereum-types/CHANGELOG.md4
-rw-r--r--packages/ethereum-types/package.json3
-rw-r--r--packages/ethereum-types/src/index.ts2
-rw-r--r--packages/fill-scenarios/CHANGELOG.json9
-rw-r--r--packages/fill-scenarios/CHANGELOG.md4
-rw-r--r--packages/fill-scenarios/package.json1
-rw-r--r--packages/instant/.gitignore2
-rw-r--r--packages/instant/CHANGELOG.json1
-rw-r--r--packages/instant/CHANGELOG.md1
-rw-r--r--packages/instant/README.md99
-rw-r--r--packages/instant/jest.config.js10
-rw-r--r--packages/instant/package.json84
-rw-r--r--packages/instant/public/index.html20
-rw-r--r--packages/instant/src/components/zero_ex_instant.tsx5
-rw-r--r--packages/instant/src/globals.d.ts6
-rw-r--r--packages/instant/src/index.ts1
-rw-r--r--packages/instant/src/index.umd.ts10
-rw-r--r--packages/instant/test/components/zero_ex_instant.test.tsx13
-rw-r--r--packages/instant/tsconfig.json17
-rw-r--r--packages/instant/tslint.json3
-rw-r--r--packages/instant/typedoc-tsconfig.json7
-rw-r--r--packages/instant/webpack.config.js28
-rw-r--r--packages/json-schemas/CHANGELOG.json9
-rw-r--r--packages/json-schemas/CHANGELOG.md4
-rw-r--r--packages/json-schemas/package.json3
-rw-r--r--packages/metacoin/package.json1
-rw-r--r--packages/migrations/CHANGELOG.json9
-rw-r--r--packages/migrations/CHANGELOG.md4
-rw-r--r--packages/migrations/package.json1
-rw-r--r--packages/monorepo-scripts/package.json1
-rw-r--r--packages/order-utils/CHANGELOG.json9
-rw-r--r--packages/order-utils/CHANGELOG.md4
-rw-r--r--packages/order-utils/package.json1
-rw-r--r--packages/order-watcher/CHANGELOG.json9
-rw-r--r--packages/order-watcher/CHANGELOG.md4
-rw-r--r--packages/order-watcher/package.json3
-rw-r--r--packages/react-docs/CHANGELOG.json9
-rw-r--r--packages/react-docs/CHANGELOG.md4
-rw-r--r--packages/react-docs/package.json1
-rw-r--r--packages/react-docs/src/components/documentation.tsx6
-rw-r--r--packages/react-docs/src/components/interface.tsx4
-rw-r--r--packages/react-docs/src/components/signature.tsx19
-rw-r--r--packages/react-docs/src/components/signature_block.tsx22
-rw-r--r--packages/react-docs/src/components/type.tsx10
-rw-r--r--packages/react-docs/src/components/type_definition.tsx4
-rw-r--r--packages/react-docs/src/docs_info.ts10
-rw-r--r--packages/react-shared/CHANGELOG.json9
-rw-r--r--packages/react-shared/CHANGELOG.md4
-rw-r--r--packages/react-shared/package.json3
-rw-r--r--packages/sol-compiler/CHANGELOG.json9
-rw-r--r--packages/sol-compiler/CHANGELOG.md4
-rw-r--r--packages/sol-compiler/package.json1
-rw-r--r--packages/sol-compiler/src/compiler.ts87
-rw-r--r--packages/sol-cov/CHANGELOG.json9
-rw-r--r--packages/sol-cov/CHANGELOG.md4
-rw-r--r--packages/sol-cov/package.json1
-rw-r--r--packages/sol-doc/CHANGELOG.json9
-rw-r--r--packages/sol-doc/CHANGELOG.md4
-rw-r--r--packages/sol-doc/package.json4
-rw-r--r--packages/sol-doc/src/cli.ts17
-rw-r--r--packages/sol-doc/src/index.ts2
-rw-r--r--packages/sol-doc/src/sol_doc.ts500
-rw-r--r--packages/sol-doc/src/solidity_doc_generator.ts306
-rw-r--r--packages/sol-doc/test/fixtures/contracts/StructParamAndReturn.sol18
-rw-r--r--packages/sol-doc/test/solidity_doc_generator_test.ts50
-rw-r--r--packages/sol-resolver/CHANGELOG.json9
-rw-r--r--packages/sol-resolver/CHANGELOG.md4
-rw-r--r--packages/sol-resolver/package.json3
-rw-r--r--packages/sra-report/CHANGELOG.json9
-rw-r--r--packages/sra-report/CHANGELOG.md4
-rw-r--r--packages/sra-report/package.json1
-rw-r--r--packages/sra-spec/CHANGELOG.json9
-rw-r--r--packages/sra-spec/CHANGELOG.md4
-rw-r--r--packages/sra-spec/package.json1
-rw-r--r--packages/subproviders/CHANGELOG.json9
-rw-r--r--packages/subproviders/CHANGELOG.md4
-rw-r--r--packages/subproviders/package.json3
-rw-r--r--packages/testnet-faucets/package.json7
-rw-r--r--packages/tslint-config/package.json1
-rw-r--r--packages/types/CHANGELOG.json9
-rw-r--r--packages/types/CHANGELOG.md4
-rw-r--r--packages/types/package.json3
-rw-r--r--packages/types/src/index.ts1
-rw-r--r--packages/typescript-typings/CHANGELOG.json9
-rw-r--r--packages/typescript-typings/CHANGELOG.md4
-rw-r--r--packages/typescript-typings/package.json3
-rw-r--r--packages/utils/CHANGELOG.json9
-rw-r--r--packages/utils/CHANGELOG.md4
-rw-r--r--packages/utils/package.json3
-rw-r--r--packages/web3-wrapper/CHANGELOG.json9
-rw-r--r--packages/web3-wrapper/CHANGELOG.md4
-rw-r--r--packages/web3-wrapper/package.json1
-rw-r--r--packages/web3-wrapper/src/utils.ts4
-rw-r--r--packages/website/README.md2
-rw-r--r--packages/website/package.json28
-rw-r--r--packages/website/public/images/team/jason.pngbin0 -> 45572 bytes
-rw-r--r--packages/website/ts/containers/smart_contracts_documentation.ts60
-rw-r--r--packages/website/ts/index.tsx30
-rw-r--r--packages/website/ts/lazy_component.tsx2
-rw-r--r--packages/website/ts/pages/about/about.tsx7
-rw-r--r--packages/website/ts/pages/documentation/doc_page.tsx6
-rw-r--r--packages/website/webpack.config.js93
151 files changed, 1796 insertions, 889 deletions
diff --git a/packages/0x.js/.npmignore b/packages/0x.js/.npmignore
index 6a3eb57bd..d7ee80c97 100644
--- a/packages/0x.js/.npmignore
+++ b/packages/0x.js/.npmignore
@@ -4,7 +4,6 @@ webpack.config.js
yarn-error.log
test/
/src/
-/_bundles/
/contract_templates/
/generated_docs/
/scripts/
diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json
index 8a0fca264..81a128c4c 100644
--- a/packages/0x.js/CHANGELOG.json
+++ b/packages/0x.js/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.0.8",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.0.7",
"changes": [
diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md
index 5bd6dee1d..eb5813c59 100644
--- a/packages/0x.js/CHANGELOG.md
+++ b/packages/0x.js/CHANGELOG.md
@@ -5,6 +5,10 @@ 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
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index 99ae39c37..268972a4f 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -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",
@@ -51,13 +52,12 @@
"@types/node": "*",
"@types/sinon": "^2.2.2",
"@types/web3-provider-engine": "^14.0.0",
- "awesome-typescript-loader": "^3.1.3",
+ "awesome-typescript-loader": "^5.2.1",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^2.0.1",
"copyfiles": "^2.0.0",
"dirty-chai": "^2.0.1",
- "json-loader": "^0.5.4",
"make-promises-safe": "^1.1.0",
"mocha": "^4.1.0",
"npm-run-all": "^4.1.2",
@@ -69,8 +69,8 @@
"tslint": "5.11.0",
"typedoc": "0.12.0",
"typescript": "3.0.1",
- "uglifyjs-webpack-plugin": "^1.3.0",
- "webpack": "^3.1.0"
+ "uglifyjs-webpack-plugin": "^2.0.1",
+ "webpack": "^4.20.2"
},
"dependencies": {
"@0xproject/assert": "^1.0.12",
diff --git a/packages/0x.js/webpack.config.js b/packages/0x.js/webpack.config.js
index 1ad0a79ec..397faa76f 100644
--- a/packages/0x.js/webpack.config.js
+++ b/packages/0x.js/webpack.config.js
@@ -2,8 +2,7 @@
* This is to generate the umd bundle only
*/
const _ = require('lodash');
-const webpack = require('webpack');
-const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
+const TerserPlugin = require('terser-webpack-plugin');
const path = require('path');
const production = process.env.NODE_ENV === 'production';
@@ -16,6 +15,7 @@ if (production) {
module.exports = {
entry,
+ mode: 'production',
output: {
path: path.resolve(__dirname, '_bundles'),
filename: '[name].js',
@@ -27,19 +27,18 @@ module.exports = {
extensions: ['.ts', '.js', '.json'],
},
devtool: 'source-map',
- plugins: [
- // TODO: Revert to webpack bundled version with webpack v4.
- // The v3 series bundled version does not support ES6 and
- // fails to build.
- new UglifyJsPlugin({
- sourceMap: true,
- uglifyOptions: {
- mangle: {
- reserved: ['BigNumber'],
+ optimization: {
+ minimizer: [
+ new TerserPlugin({
+ sourceMap: true,
+ terserOptions: {
+ mangle: {
+ reserved: ['BigNumber'],
+ },
},
- },
- }),
- ],
+ }),
+ ],
+ },
module: {
rules: [
{
@@ -59,10 +58,6 @@ module.exports = {
],
exclude: /node_modules/,
},
- {
- test: /\.json$/,
- loader: 'json-loader',
- },
],
},
};
diff --git a/packages/abi-gen/CHANGELOG.json b/packages/abi-gen/CHANGELOG.json
index 6d6d3fa0b..ab2423e88 100644
--- a/packages/abi-gen/CHANGELOG.json
+++ b/packages/abi-gen/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.0.13",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.0.12",
"changes": [
diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md
index 7d8958893..5f72e257d 100644
--- a/packages/abi-gen/CHANGELOG.md
+++ b/packages/abi-gen/CHANGELOG.md
@@ -5,6 +5,10 @@ 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
diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json
index 94cc05728..fd239ca21 100644
--- a/packages/abi-gen/package.json
+++ b/packages/abi-gen/package.json
@@ -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",
diff --git a/packages/assert/CHANGELOG.json b/packages/assert/CHANGELOG.json
index dc510533e..0efcc3ac3 100644
--- a/packages/assert/CHANGELOG.json
+++ b/packages/assert/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.0.13",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.0.12",
"changes": [
diff --git a/packages/assert/CHANGELOG.md b/packages/assert/CHANGELOG.md
index 55b2b1c73..910904730 100644
--- a/packages/assert/CHANGELOG.md
+++ b/packages/assert/CHANGELOG.md
@@ -5,6 +5,10 @@ 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
diff --git a/packages/assert/package.json b/packages/assert/package.json
index 5392bf38a..b536d31f4 100644
--- a/packages/assert/package.json
+++ b/packages/assert/package.json
@@ -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",
diff --git a/packages/asset-buyer/CHANGELOG.json b/packages/asset-buyer/CHANGELOG.json
index aa196c265..8c2c7a8d2 100644
--- a/packages/asset-buyer/CHANGELOG.json
+++ b/packages/asset-buyer/CHANGELOG.json
@@ -1,5 +1,23 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "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": [
diff --git a/packages/asset-buyer/CHANGELOG.md b/packages/asset-buyer/CHANGELOG.md
index 9d6d973a4..6f125fa1a 100644
--- a/packages/asset-buyer/CHANGELOG.md
+++ b/packages/asset-buyer/CHANGELOG.md
@@ -5,6 +5,10 @@ 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
diff --git a/packages/asset-buyer/README.md b/packages/asset-buyer/README.md
index 5f7f26f30..81c7e1e85 100644
--- a/packages/asset-buyer/README.md
+++ b/packages/asset-buyer/README.md
@@ -1,6 +1,8 @@
## @0xproject/asset-buyer
-Convenience package for buying assets represented on the Ethereum blockchain using 0x. In its simplest form, the package helps in the usage of the [0x forwarder contract](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md), which allows users to execute [Wrapped Ether](https://weth.io/) based 0x orders without having to set allowances, wrap Ether or buy ZRX, meaning they can buy tokens with Ether alone. Given some liquidity (0x signed orders), it helps estimate the Ether cost of buying a certain asset (giving a range) and then buying that asset.
+**Warning: In Beta, has not been extensively tested.**
+
+Convenience package for buying assets represented on the Ethereum blockchain using 0x. In its simplest form, the package helps in the usage of the [0x forwarder contract](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md), which allows users to execute [Wrapped Ether](https://weth.io/) based 0x orders without having to set allowances, wrap Ether or own ZRX, meaning they can buy tokens with Ether alone. Given some liquidity (0x signed orders), it helps estimate the Ether cost of buying a certain asset (giving a range) and then buying that asset.
In its more advanced and useful form, it integrates with the [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) and takes care of sourcing liquidity for you given an SRA compliant endpoint. The final result is a library that tells you what assets are available, provides an Ether based quote for any asset desired, and allows you to buy that asset using Ether alone.
diff --git a/packages/asset-buyer/package.json b/packages/asset-buyer/package.json
index 6db75ab17..dacfbf730 100644
--- a/packages/asset-buyer/package.json
+++ b/packages/asset-buyer/package.json
@@ -4,7 +4,7 @@
"engines": {
"node": ">=6.12"
},
- "description": "Convenience package for buying assets",
+ "description": "Convenience package for discovering and buying assets with Ether.",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"scripts": {
@@ -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": {
diff --git a/packages/asset-buyer/src/asset_buyer.ts b/packages/asset-buyer/src/asset_buyer.ts
index 409e34e74..0bb757f52 100644
--- a/packages/asset-buyer/src/asset_buyer.ts
+++ b/packages/asset-buyer/src/asset_buyer.ts
@@ -1,6 +1,7 @@
import { ContractWrappers } from '@0xproject/contract-wrappers';
import { schemas } from '@0xproject/json-schemas';
import { SignedOrder } from '@0xproject/order-utils';
+import { ObjectMap } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import { Provider } from 'ethereum-types';
@@ -11,11 +12,13 @@ import { BasicOrderProvider } from './order_providers/basic_order_provider';
import { StandardRelayerAPIOrderProvider } from './order_providers/standard_relayer_api_order_provider';
import {
AssetBuyerError,
- AssetBuyerOrdersAndFillableAmounts,
+ AssetBuyerOpts,
BuyQuote,
+ BuyQuoteExecutionOpts,
BuyQuoteRequestOpts,
OrderProvider,
OrderProviderResponse,
+ OrdersAndFillableAmounts,
} from './types';
import { assert } from './utils/assert';
@@ -23,24 +26,26 @@ import { assetDataUtils } from './utils/asset_data_utils';
import { buyQuoteCalculator } from './utils/buy_quote_calculator';
import { orderProviderResponseProcessor } from './utils/order_provider_response_processor';
+interface OrdersEntry {
+ ordersAndFillableAmounts: OrdersAndFillableAmounts;
+ lastRefreshTime: number;
+}
+
export class AssetBuyer {
public readonly provider: Provider;
- public readonly assetData: string;
public readonly orderProvider: OrderProvider;
public readonly networkId: number;
public readonly orderRefreshIntervalMs: number;
public readonly expiryBufferSeconds: number;
private readonly _contractWrappers: ContractWrappers;
- private _lastRefreshTimeIfExists?: number;
- private _currentOrdersAndFillableAmountsIfExists?: AssetBuyerOrdersAndFillableAmounts;
+ // cache of orders along with the time last updated keyed by assetData
+ private readonly _ordersEntryMap: ObjectMap<OrdersEntry> = {};
/**
* Instantiates a new AssetBuyer instance given existing liquidity in the form of orders and feeOrders.
* @param provider The Provider instance you would like to use for interacting with the Ethereum network.
* @param orders A non-empty array of objects that conform to SignedOrder. All orders must have the same makerAssetData and takerAssetData (WETH).
* @param feeOrders A array of objects that conform to SignedOrder. All orders must have the same makerAssetData (ZRX) and takerAssetData (WETH). Defaults to an empty array.
- * @param networkId The ethereum network id. Defaults to 1 (mainnet).
- * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. Defaults to 10000ms (10s).
- * @param expiryBufferSeconds The number of seconds to add when calculating whether an order is expired or not. Defaults to 15s.
+ * @param options Initialization options for the AssetBuyer. See type definition for details.
*
* @return An instance of AssetBuyer
*/
@@ -48,171 +53,99 @@ export class AssetBuyer {
provider: Provider,
orders: SignedOrder[],
feeOrders: SignedOrder[] = [],
- networkId: number = constants.MAINNET_NETWORK_ID,
- orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS,
- expiryBufferSeconds: number = constants.DEFAULT_EXPIRY_BUFFER_SECONDS,
+ options: Partial<AssetBuyerOpts> = {},
): AssetBuyer {
assert.isWeb3Provider('provider', provider);
assert.doesConformToSchema('orders', orders, schemas.signedOrdersSchema);
assert.doesConformToSchema('feeOrders', feeOrders, schemas.signedOrdersSchema);
- assert.isNumber('networkId', networkId);
- assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs);
assert.areValidProvidedOrders('orders', orders);
assert.areValidProvidedOrders('feeOrders', feeOrders);
assert.assert(orders.length !== 0, `Expected orders to contain at least one order`);
- const assetData = orders[0].makerAssetData;
const orderProvider = new BasicOrderProvider(_.concat(orders, feeOrders));
- const assetBuyer = new AssetBuyer(
- provider,
- assetData,
- orderProvider,
- networkId,
- orderRefreshIntervalMs,
- expiryBufferSeconds,
- );
+ const assetBuyer = new AssetBuyer(provider, orderProvider, options);
return assetBuyer;
}
/**
- * Instantiates a new AssetBuyer instance given the desired assetData and a [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) endpoint
+ * Instantiates a new AssetBuyer instance given a [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) endpoint
* @param provider The Provider instance you would like to use for interacting with the Ethereum network.
- * @param assetData The assetData that identifies the desired asset to buy.
* @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from.
- * @param networkId The ethereum network id. Defaults to 1 (mainnet).
- * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. Defaults to 10000ms (10s).
- * @param expiryBufferSeconds The number of seconds to add when calculating whether an order is expired or not. Defaults to 15s.
+ * @param options Initialization options for the AssetBuyer. See type definition for details.
*
* @return An instance of AssetBuyer
*/
- public static getAssetBuyerForAssetData(
+ public static getAssetBuyerForStandardRelayerAPIUrl(
provider: Provider,
- assetData: string,
sraApiUrl: string,
- networkId: number = constants.MAINNET_NETWORK_ID,
- orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS,
- expiryBufferSeconds: number = constants.DEFAULT_EXPIRY_BUFFER_SECONDS,
+ options: Partial<AssetBuyerOpts> = {},
): AssetBuyer {
assert.isWeb3Provider('provider', provider);
- assert.isHexString('assetData', assetData);
assert.isWebUri('sraApiUrl', sraApiUrl);
- assert.isNumber('networkId', networkId);
- assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs);
const orderProvider = new StandardRelayerAPIOrderProvider(sraApiUrl);
- const assetBuyer = new AssetBuyer(
- provider,
- assetData,
- orderProvider,
- networkId,
- orderRefreshIntervalMs,
- expiryBufferSeconds,
- );
- return assetBuyer;
- }
- /**
- * Instantiates a new AssetBuyer instance given the desired ERC20 token address and a [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) endpoint
- * @param provider The Provider instance you would like to use for interacting with the Ethereum network.
- * @param tokenAddress The ERC20 token address that identifies the desired asset to buy.
- * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from.
- * @param networkId The ethereum network id. Defaults to 1 (mainnet).
- * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. Defaults to 10000ms (10s).
- * @param expiryBufferSeconds The number of seconds to add when calculating whether an order is expired or not. Defaults to 15s.
- * @return An instance of AssetBuyer
- */
- public static getAssetBuyerForERC20TokenAddress(
- provider: Provider,
- tokenAddress: string,
- sraApiUrl: string,
- networkId: number = constants.MAINNET_NETWORK_ID,
- orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS,
- expiryBufferSeconds: number = constants.DEFAULT_EXPIRY_BUFFER_SECONDS,
- ): AssetBuyer {
- assert.isWeb3Provider('provider', provider);
- assert.isETHAddressHex('tokenAddress', tokenAddress);
- assert.isWebUri('sraApiUrl', sraApiUrl);
- assert.isNumber('networkId', networkId);
- assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs);
- const assetData = assetDataUtils.encodeERC20AssetData(tokenAddress);
- const assetBuyer = AssetBuyer.getAssetBuyerForAssetData(
- provider,
- assetData,
- sraApiUrl,
- networkId,
- orderRefreshIntervalMs,
- expiryBufferSeconds,
- );
+ const assetBuyer = new AssetBuyer(provider, orderProvider, options);
return assetBuyer;
}
/**
* Instantiates a new AssetBuyer instance
- * @param provider The Provider instance you would like to use for interacting with the Ethereum network.
- * @param assetData The assetData of the desired asset to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
- * @param orderProvider An object that conforms to OrderProvider, see type for definition.
- * @param networkId The ethereum network id. Defaults to 1 (mainnet).
- * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. Defaults to 10000ms (10s).
- * @param expiryBufferSeconds The number of seconds to add when calculating whether an order is expired or not. Defaults to 15s.
+ * @param provider The Provider instance you would like to use for interacting with the Ethereum network.
+ * @param orderProvider An object that conforms to OrderProvider, see type for definition.
+ * @param options Initialization options for the AssetBuyer. See type definition for details.
*
* @return An instance of AssetBuyer
*/
- constructor(
- provider: Provider,
- assetData: string,
- orderProvider: OrderProvider,
- networkId: number = constants.MAINNET_NETWORK_ID,
- orderRefreshIntervalMs: number = constants.DEFAULT_ORDER_REFRESH_INTERVAL_MS,
- expiryBufferSeconds: number = constants.DEFAULT_EXPIRY_BUFFER_SECONDS,
- ) {
+ constructor(provider: Provider, orderProvider: OrderProvider, options: Partial<AssetBuyerOpts> = {}) {
+ const { networkId, orderRefreshIntervalMs, expiryBufferSeconds } = {
+ ...constants.DEFAULT_ASSET_BUYER_OPTS,
+ ...options,
+ };
assert.isWeb3Provider('provider', provider);
- assert.isString('assetData', assetData);
assert.isValidOrderProvider('orderProvider', orderProvider);
assert.isNumber('networkId', networkId);
assert.isNumber('orderRefreshIntervalMs', orderRefreshIntervalMs);
+ assert.isNumber('expiryBufferSeconds', expiryBufferSeconds);
this.provider = provider;
- this.assetData = assetData;
this.orderProvider = orderProvider;
this.networkId = networkId;
- this.expiryBufferSeconds = expiryBufferSeconds;
this.orderRefreshIntervalMs = orderRefreshIntervalMs;
+ this.expiryBufferSeconds = expiryBufferSeconds;
this._contractWrappers = new ContractWrappers(this.provider, {
networkId,
});
}
/**
- * Get a `BuyQuote` containing all information relevant to fulfilling a buy.
+ * Get a `BuyQuote` containing all information relevant to fulfilling a buy given a desired assetData.
* You can then pass the `BuyQuote` to `executeBuyQuoteAsync` to execute the buy.
+ * @param assetData The assetData of the desired asset to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
* @param assetBuyAmount The amount of asset to buy.
- * @param feePercentage The affiliate fee percentage. Defaults to 0.
- * @param forceOrderRefresh If set to true, new orders and state will be fetched instead of waiting for
- * the next orderRefreshIntervalMs. Defaults to false.
+ * @param options Options for the request. See type definition for more information.
+ *
* @return An object that conforms to BuyQuote that satisfies the request. See type definition for more information.
*/
- public async getBuyQuoteAsync(assetBuyAmount: BigNumber, options: Partial<BuyQuoteRequestOpts>): Promise<BuyQuote> {
+ public async getBuyQuoteAsync(
+ assetData: string,
+ assetBuyAmount: BigNumber,
+ options: Partial<BuyQuoteRequestOpts>,
+ ): Promise<BuyQuote> {
const { feePercentage, shouldForceOrderRefresh, slippagePercentage } = {
- ...options,
...constants.DEFAULT_BUY_QUOTE_REQUEST_OPTS,
+ ...options,
};
+ assert.isString('assetData', assetData);
assert.isBigNumber('assetBuyAmount', assetBuyAmount);
assert.isValidPercentage('feePercentage', feePercentage);
assert.isBoolean('shouldForceOrderRefresh', shouldForceOrderRefresh);
- // we should refresh if:
- // we do not have any orders OR
- // we are forced to OR
- // we have some last refresh time AND that time was sufficiently long ago
- const shouldRefresh =
- _.isUndefined(this._currentOrdersAndFillableAmountsIfExists) ||
- shouldForceOrderRefresh ||
- (!_.isUndefined(this._lastRefreshTimeIfExists) &&
- this._lastRefreshTimeIfExists + this.orderRefreshIntervalMs < Date.now());
- let ordersAndFillableAmounts: AssetBuyerOrdersAndFillableAmounts;
- if (shouldRefresh) {
- ordersAndFillableAmounts = await this._getLatestOrdersAndFillableAmountsAsync();
- this._lastRefreshTimeIfExists = Date.now();
- this._currentOrdersAndFillableAmountsIfExists = ordersAndFillableAmounts;
- } else {
- // it is safe to cast to AssetBuyerOrdersAndFillableAmounts because shouldRefresh catches the undefined case above
- ordersAndFillableAmounts = this
- ._currentOrdersAndFillableAmountsIfExists as AssetBuyerOrdersAndFillableAmounts;
+ assert.isNumber('slippagePercentage', slippagePercentage);
+ const zrxTokenAssetData = this._getZrxTokenAssetDataOrThrow();
+ const [ordersAndFillableAmounts, feeOrdersAndFillableAmounts] = await Promise.all([
+ this._getOrdersAndFillableAmountsAsync(assetData, shouldForceOrderRefresh),
+ this._getOrdersAndFillableAmountsAsync(zrxTokenAssetData, shouldForceOrderRefresh),
+ shouldForceOrderRefresh,
+ ]);
+ if (ordersAndFillableAmounts.orders.length === 0) {
+ throw new Error(`${AssetBuyerError.AssetUnavailable}: For assetData ${assetData}`);
}
const buyQuote = buyQuoteCalculator.calculate(
ordersAndFillableAmounts,
+ feeOrdersAndFillableAmounts,
assetBuyAmount,
feePercentage,
slippagePercentage,
@@ -220,19 +153,37 @@ export class AssetBuyer {
return buyQuote;
}
/**
+ * Get a `BuyQuote` containing all information relevant to fulfilling a buy given a desired ERC20 token address.
+ * You can then pass the `BuyQuote` to `executeBuyQuoteAsync` to execute the buy.
+ * @param tokenAddress The ERC20 token address.
+ * @param assetBuyAmount The amount of asset to buy.
+ * @param options Options for the request. See type definition for more information.
+ *
+ * @return An object that conforms to BuyQuote that satisfies the request. See type definition for more information.
+ */
+ public async getBuyQuoteForERC20TokenAddressAsync(
+ tokenAddress: string,
+ assetBuyAmount: BigNumber,
+ options: Partial<BuyQuoteRequestOpts>,
+ ): Promise<BuyQuote> {
+ assert.isETHAddressHex('tokenAddress', tokenAddress);
+ assert.isBigNumber('assetBuyAmount', assetBuyAmount);
+ const assetData = assetDataUtils.encodeERC20AssetData(tokenAddress);
+ const buyQuote = this.getBuyQuoteAsync(assetData, assetBuyAmount, options);
+ return buyQuote;
+ }
+ /**
* Given a BuyQuote and desired rate, attempt to execute the buy.
* @param buyQuote An object that conforms to BuyQuote. See type definition for more information.
- * @param rate The desired rate to execute the buy at. Affects the amount of ETH sent with the transaction, defaults to buyQuote.maxRate.
- * @param takerAddress The address to perform the buy. Defaults to the first available address from the provider.
- * @param feeRecipient The address where affiliate fees are sent. Defaults to null address (0x000...000).
+ * @param options Options for the execution of the BuyQuote. See type definition for more information.
+ *
* @return A promise of the txHash.
*/
- public async executeBuyQuoteAsync(
- buyQuote: BuyQuote,
- rate?: BigNumber,
- takerAddress?: string,
- feeRecipient: string = constants.NULL_ADDRESS,
- ): Promise<string> {
+ public async executeBuyQuoteAsync(buyQuote: BuyQuote, options: Partial<BuyQuoteExecutionOpts>): Promise<string> {
+ const { rate, takerAddress, feeRecipient } = {
+ ...constants.DEFAULT_BUY_QUOTE_EXECUTION_OPTS,
+ ...options,
+ };
assert.isValidBuyQuote('buyQuote', buyQuote);
if (!_.isUndefined(rate)) {
assert.isBigNumber('rate', rate);
@@ -272,39 +223,55 @@ export class AssetBuyer {
return txHash;
}
/**
- * Ask the order Provider for orders and process them.
+ * Grab orders from the map, if there is a miss or it is time to refresh, fetch and process the orders
*/
- private async _getLatestOrdersAndFillableAmountsAsync(): Promise<AssetBuyerOrdersAndFillableAmounts> {
+ private async _getOrdersAndFillableAmountsAsync(
+ assetData: string,
+ shouldForceOrderRefresh: boolean,
+ ): Promise<OrdersAndFillableAmounts> {
+ // try to get ordersEntry from the map
+ const ordersEntryIfExists = this._ordersEntryMap[assetData];
+ // we should refresh if:
+ // we do not have any orders OR
+ // we are forced to OR
+ // we have some last refresh time AND that time was sufficiently long ago
+ const shouldRefresh =
+ _.isUndefined(ordersEntryIfExists) ||
+ shouldForceOrderRefresh ||
+ // tslint:disable:restrict-plus-operands
+ ordersEntryIfExists.lastRefreshTime + this.orderRefreshIntervalMs < Date.now();
+ if (!shouldRefresh) {
+ const result = ordersEntryIfExists.ordersAndFillableAmounts;
+ return result;
+ }
const etherTokenAssetData = this._getEtherTokenAssetDataOrThrow();
const zrxTokenAssetData = this._getZrxTokenAssetDataOrThrow();
- // construct order Provider requests
- const targetOrderProviderRequest = {
- makerAssetData: this.assetData,
- takerAssetData: etherTokenAssetData,
- networkId: this.networkId,
- };
- const feeOrderProviderRequest = {
- makerAssetData: zrxTokenAssetData,
+ // construct orderProvider request
+ const orderProviderRequest = {
+ makerAssetData: assetData,
takerAssetData: etherTokenAssetData,
networkId: this.networkId,
};
- const requests = [targetOrderProviderRequest, feeOrderProviderRequest];
- // fetch orders and possible fillable amounts
- const [targetOrderProviderResponse, feeOrderProviderResponse] = await Promise.all(
- _.map(requests, async request => this.orderProvider.getOrdersAsync(request)),
- );
+ const request = orderProviderRequest;
+ // get provider response
+ const response = await this.orderProvider.getOrdersAsync(request);
// since the order provider is an injected dependency, validate that it respects the API
// ie. it should only return maker/taker assetDatas that are specified
- orderProviderResponseProcessor.throwIfInvalidResponse(targetOrderProviderResponse, targetOrderProviderRequest);
- orderProviderResponseProcessor.throwIfInvalidResponse(feeOrderProviderResponse, feeOrderProviderRequest);
+ orderProviderResponseProcessor.throwIfInvalidResponse(response, request);
// process the responses into one object
+ const isMakerAssetZrxToken = assetData === zrxTokenAssetData;
const ordersAndFillableAmounts = await orderProviderResponseProcessor.processAsync(
- targetOrderProviderResponse,
- feeOrderProviderResponse,
- zrxTokenAssetData,
+ response,
+ isMakerAssetZrxToken,
this.expiryBufferSeconds,
this._contractWrappers.orderValidator,
);
+ const lastRefreshTime = Date.now();
+ const updatedOrdersEntry = {
+ ordersAndFillableAmounts,
+ lastRefreshTime,
+ };
+ this._ordersEntryMap[assetData] = updatedOrdersEntry;
return ordersAndFillableAmounts;
}
/**
diff --git a/packages/asset-buyer/src/constants.ts b/packages/asset-buyer/src/constants.ts
index 79b5d9052..e1056e39b 100644
--- a/packages/asset-buyer/src/constants.ts
+++ b/packages/asset-buyer/src/constants.ts
@@ -1,6 +1,15 @@
import { BigNumber } from '@0xproject/utils';
-import { BuyQuoteRequestOpts } from './types';
+import { AssetBuyerOpts, BuyQuoteExecutionOpts, BuyQuoteRequestOpts } from './types';
+
+const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
+const MAINNET_NETWORK_ID = 1;
+
+const DEFAULT_ASSET_BUYER_OPTS: AssetBuyerOpts = {
+ networkId: MAINNET_NETWORK_ID,
+ orderRefreshIntervalMs: 10000, // 10 seconds
+ expiryBufferSeconds: 15,
+};
const DEFAULT_BUY_QUOTE_REQUEST_OPTS: BuyQuoteRequestOpts = {
feePercentage: 0,
@@ -8,13 +17,18 @@ const DEFAULT_BUY_QUOTE_REQUEST_OPTS: BuyQuoteRequestOpts = {
slippagePercentage: 0.2, // 20% slippage protection
};
+// Other default values are dynamically determined
+const DEFAULT_BUY_QUOTE_EXECUTION_OPTS: BuyQuoteExecutionOpts = {
+ feeRecipient: NULL_ADDRESS,
+};
+
export const constants = {
ZERO_AMOUNT: new BigNumber(0),
- NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
- MAINNET_NETWORK_ID: 1,
- DEFAULT_ORDER_REFRESH_INTERVAL_MS: 10000, // 10 seconds
+ NULL_ADDRESS,
+ MAINNET_NETWORK_ID,
ETHER_TOKEN_DECIMALS: 18,
+ DEFAULT_ASSET_BUYER_OPTS,
+ DEFAULT_BUY_QUOTE_EXECUTION_OPTS,
DEFAULT_BUY_QUOTE_REQUEST_OPTS,
MAX_PER_PAGE: 10000,
- DEFAULT_EXPIRY_BUFFER_SECONDS: 15,
};
diff --git a/packages/asset-buyer/src/index.ts b/packages/asset-buyer/src/index.ts
index 8ef529ac0..2da2724d7 100644
--- a/packages/asset-buyer/src/index.ts
+++ b/packages/asset-buyer/src/index.ts
@@ -5,13 +5,14 @@ export { BigNumber } from '@0xproject/utils';
export { AssetBuyer } from './asset_buyer';
export { BasicOrderProvider } from './order_providers/basic_order_provider';
export { StandardRelayerAPIOrderProvider } from './order_providers/standard_relayer_api_order_provider';
-export { StandardRelayerAPIAssetBuyerManager } from './standard_relayer_api_asset_buyer_manager';
export {
AssetBuyerError,
+ AssetBuyerOpts,
BuyQuote,
+ BuyQuoteExecutionOpts,
+ BuyQuoteRequestOpts,
OrderProvider,
OrderProviderRequest,
OrderProviderResponse,
SignedOrderWithRemainingFillableMakerAssetAmount,
- StandardRelayerApiAssetBuyerManagerError,
} from './types';
diff --git a/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts b/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts
deleted file mode 100644
index 947c738a1..000000000
--- a/packages/asset-buyer/src/standard_relayer_api_asset_buyer_manager.ts
+++ /dev/null
@@ -1,133 +0,0 @@
-import { HttpClient } from '@0xproject/connect';
-import { ContractWrappers } from '@0xproject/contract-wrappers';
-import { ObjectMap } from '@0xproject/types';
-import { Provider } from 'ethereum-types';
-import * as _ from 'lodash';
-
-import { AssetBuyer } from './asset_buyer';
-import { constants } from './constants';
-import { assert } from './utils/assert';
-import { assetDataUtils } from './utils/asset_data_utils';
-
-import { OrderProvider, StandardRelayerApiAssetBuyerManagerError } from './types';
-
-export class StandardRelayerAPIAssetBuyerManager {
- // Map of assetData to AssetBuyer for that assetData
- private readonly _assetBuyerMap: ObjectMap<AssetBuyer>;
- /**
- * Returns an array of all assetDatas available at the provided sraApiUrl
- * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from.
- * @param pairedWithAssetData Optional filter argument to return assetDatas that only pair with this assetData value.
- *
- * @return An array of all assetDatas available at the provider sraApiUrl
- */
- public static async getAllAvailableAssetDatasAsync(
- sraApiUrl: string,
- pairedWithAssetData?: string,
- ): Promise<string[]> {
- const client = new HttpClient(sraApiUrl);
- const params = {
- assetDataA: pairedWithAssetData,
- perPage: constants.MAX_PER_PAGE,
- };
- const assetPairsResponse = await client.getAssetPairsAsync(params);
- return _.uniq(_.map(assetPairsResponse.records, pairsItem => pairsItem.assetDataB.assetData));
- }
- /**
- * Instantiates a new StandardRelayerAPIAssetBuyerManager instance with all available assetDatas at the provided sraApiUrl
- * @param provider The Provider instance you would like to use for interacting with the Ethereum network.
- * @param sraApiUrl The standard relayer API base HTTP url you would like to source orders from.
- * @param orderProvider An object that conforms to OrderProvider, see type for definition.
- * @param networkId The ethereum network id. Defaults to 1 (mainnet).
- * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states.
- * Defaults to 10000ms (10s).
- * @return An promise of an instance of StandardRelayerAPIAssetBuyerManager
- */
- public static async getAssetBuyerManagerWithAllAvailableAssetDatasAsync(
- provider: Provider,
- sraApiUrl: string,
- orderProvider: OrderProvider,
- networkId: number = constants.MAINNET_NETWORK_ID,
- orderRefreshIntervalMs?: number,
- ): Promise<StandardRelayerAPIAssetBuyerManager> {
- const contractWrappers = new ContractWrappers(provider, { networkId });
- const etherTokenAssetData = assetDataUtils.getEtherTokenAssetDataOrThrow(contractWrappers);
- const assetDatas = await StandardRelayerAPIAssetBuyerManager.getAllAvailableAssetDatasAsync(
- sraApiUrl,
- etherTokenAssetData,
- );
- return new StandardRelayerAPIAssetBuyerManager(
- provider,
- assetDatas,
- orderProvider,
- networkId,
- orderRefreshIntervalMs,
- );
- }
- /**
- * Instantiates a new StandardRelayerAPIAssetBuyerManager instance
- * @param provider The Provider instance you would like to use for interacting with the Ethereum network.
- * @param assetDatas The assetDatas of the desired assets to buy (for more info: https://github.com/0xProject/0x-protocol-specification/blob/master/v2/v2-specification.md).
- * @param orderProvider An object that conforms to OrderProvider, see type for definition.
- * @param networkId The ethereum network id. Defaults to 1 (mainnet).
- * @param orderRefreshIntervalMs The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states.
- * Defaults to 10000ms (10s).
- * @return An instance of StandardRelayerAPIAssetBuyerManager
- */
- constructor(
- provider: Provider,
- assetDatas: string[],
- orderProvider: OrderProvider,
- networkId?: number,
- orderRefreshIntervalMs?: number,
- ) {
- assert.assert(assetDatas.length > 0, `Expected 'assetDatas' to be a non-empty array.`);
- this._assetBuyerMap = _.reduce(
- assetDatas,
- (accAssetBuyerMap: ObjectMap<AssetBuyer>, assetData: string) => {
- accAssetBuyerMap[assetData] = new AssetBuyer(
- provider,
- assetData,
- orderProvider,
- networkId,
- orderRefreshIntervalMs,
- );
- return accAssetBuyerMap;
- },
- {},
- );
- }
- /**
- * Get an AssetBuyer for the provided assetData
- * @param assetData The desired assetData.
- *
- * @return An instance of AssetBuyer
- */
- public getAssetBuyerFromAssetData(assetData: string): AssetBuyer {
- const assetBuyer = this._assetBuyerMap[assetData];
- if (_.isUndefined(assetBuyer)) {
- throw new Error(
- `${StandardRelayerApiAssetBuyerManagerError.AssetBuyerNotFound}: For assetData ${assetData}`,
- );
- }
- return assetBuyer;
- }
- /**
- * Get an AssetBuyer for the provided ERC20 tokenAddress
- * @param tokenAddress The desired tokenAddress.
- *
- * @return An instance of AssetBuyer
- */
- public getAssetBuyerFromERC20TokenAddress(tokenAddress: string): AssetBuyer {
- const assetData = assetDataUtils.encodeERC20AssetData(tokenAddress);
- return this.getAssetBuyerFromAssetData(assetData);
- }
- /**
- * Get a list of all the assetDatas that the instance supports
- *
- * @return An array of assetData strings
- */
- public getAssetDatas(): string[] {
- return _.keys(this._assetBuyerMap);
- }
-}
diff --git a/packages/asset-buyer/src/types.ts b/packages/asset-buyer/src/types.ts
index ee6858525..8d3dcbfe6 100644
--- a/packages/asset-buyer/src/types.ts
+++ b/packages/asset-buyer/src/types.ts
@@ -52,6 +52,11 @@ export interface BuyQuote {
feePercentage?: number;
}
+/**
+ * feePercentage: The affiliate fee percentage. Defaults to 0.
+ * shouldForceOrderRefresh: If set to true, new orders and state will be fetched instead of waiting for the next orderRefreshIntervalMs. Defaults to false.
+ * slippagePercentage: The percentage buffer to add to account for slippage. Affects max ETH price estimates. Defaults to 0.2 (20%).
+ */
export interface BuyQuoteRequestOpts {
feePercentage: number;
shouldForceOrderRefresh: boolean;
@@ -59,6 +64,28 @@ export interface BuyQuoteRequestOpts {
}
/**
+ * rate: The desired rate to execute the buy at. Affects the amount of ETH sent with the transaction, defaults to buyQuote.maxRate.
+ * takerAddress: The address to perform the buy. Defaults to the first available address from the provider.
+ * feeRecipient: The address where affiliate fees are sent. Defaults to null address (0x000...000).
+ */
+export interface BuyQuoteExecutionOpts {
+ rate?: BigNumber;
+ takerAddress?: string;
+ feeRecipient: string;
+}
+
+/**
+ * networkId: The ethereum network id. Defaults to 1 (mainnet).
+ * orderRefreshIntervalMs: The interval in ms that getBuyQuoteAsync should trigger an refresh of orders and order states. Defaults to 10000ms (10s).
+ * expiryBufferSeconds: The number of seconds to add when calculating whether an order is expired or not. Defaults to 15s.
+ */
+export interface AssetBuyerOpts {
+ networkId: number;
+ orderRefreshIntervalMs: number;
+ expiryBufferSeconds: number;
+}
+
+/**
* Possible errors thrown by an AssetBuyer instance or associated static methods.
*/
export enum AssetBuyerError {
@@ -69,18 +96,10 @@ export enum AssetBuyerError {
InsufficientZrxLiquidity = 'INSUFFICIENT_ZRX_LIQUIDITY',
NoAddressAvailable = 'NO_ADDRESS_AVAILABLE',
InvalidOrderProviderResponse = 'INVALID_ORDER_PROVIDER_RESPONSE',
+ AssetUnavailable = 'ASSET_UNAVAILABLE',
}
-/**
- * Possible errors thrown by an StandardRelayerApiAssetBuyerManager instance or associated static methods.
- */
-export enum StandardRelayerApiAssetBuyerManagerError {
- AssetBuyerNotFound = 'ASSET_BUYER_NOT_FOUND',
-}
-
-export interface AssetBuyerOrdersAndFillableAmounts {
+export interface OrdersAndFillableAmounts {
orders: SignedOrder[];
- feeOrders: SignedOrder[];
remainingFillableMakerAssetAmounts: BigNumber[];
- remainingFillableFeeAmounts: BigNumber[];
}
diff --git a/packages/asset-buyer/src/utils/buy_quote_calculator.ts b/packages/asset-buyer/src/utils/buy_quote_calculator.ts
index 9946924ef..b706ea143 100644
--- a/packages/asset-buyer/src/utils/buy_quote_calculator.ts
+++ b/packages/asset-buyer/src/utils/buy_quote_calculator.ts
@@ -3,24 +3,23 @@ import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import { constants } from '../constants';
-import { AssetBuyerError, AssetBuyerOrdersAndFillableAmounts, BuyQuote } from '../types';
+import { AssetBuyerError, BuyQuote, OrdersAndFillableAmounts } from '../types';
import { orderUtils } from './order_utils';
// Calculates a buy quote for orders that have WETH as the takerAsset
export const buyQuoteCalculator = {
calculate(
- ordersAndFillableAmounts: AssetBuyerOrdersAndFillableAmounts,
+ ordersAndFillableAmounts: OrdersAndFillableAmounts,
+ feeOrdersAndFillableAmounts: OrdersAndFillableAmounts,
assetBuyAmount: BigNumber,
feePercentage: number,
slippagePercentage: number,
): BuyQuote {
- const {
- orders,
- feeOrders,
- remainingFillableMakerAssetAmounts,
- remainingFillableFeeAmounts,
- } = ordersAndFillableAmounts;
+ const orders = ordersAndFillableAmounts.orders;
+ const remainingFillableMakerAssetAmounts = ordersAndFillableAmounts.remainingFillableMakerAssetAmounts;
+ const feeOrders = feeOrdersAndFillableAmounts.orders;
+ const remainingFillableFeeAmounts = feeOrdersAndFillableAmounts.remainingFillableMakerAssetAmounts;
const slippageBufferAmount = assetBuyAmount.mul(slippagePercentage).round();
const {
resultOrders,
diff --git a/packages/asset-buyer/src/utils/order_provider_response_processor.ts b/packages/asset-buyer/src/utils/order_provider_response_processor.ts
index 31fdcc182..74eec162d 100644
--- a/packages/asset-buyer/src/utils/order_provider_response_processor.ts
+++ b/packages/asset-buyer/src/utils/order_provider_response_processor.ts
@@ -8,19 +8,14 @@ import * as _ from 'lodash';
import { constants } from '../constants';
import {
AssetBuyerError,
- AssetBuyerOrdersAndFillableAmounts,
OrderProviderRequest,
OrderProviderResponse,
+ OrdersAndFillableAmounts,
SignedOrderWithRemainingFillableMakerAssetAmount,
} from '../types';
import { orderUtils } from './order_utils';
-interface OrdersAndRemainingFillableMakerAssetAmounts {
- orders: SignedOrder[];
- remainingFillableMakerAssetAmounts: BigNumber[];
-}
-
export const orderProviderResponseProcessor = {
throwIfInvalidResponse(response: OrderProviderResponse, request: OrderProviderRequest): void {
const { makerAssetData, takerAssetData } = request;
@@ -38,65 +33,40 @@ export const orderProviderResponseProcessor = {
* - Sort by rate
*/
async processAsync(
- targetOrderProviderResponse: OrderProviderResponse,
- feeOrderProviderResponse: OrderProviderResponse,
- zrxTokenAssetData: string,
+ orderProviderResponse: OrderProviderResponse,
+ isMakerAssetZrxToken: boolean,
expiryBufferSeconds: number,
orderValidator?: OrderValidatorWrapper,
- ): Promise<AssetBuyerOrdersAndFillableAmounts> {
+ ): Promise<OrdersAndFillableAmounts> {
// drop orders that are expired or not open
- const filteredTargetOrders = filterOutExpiredAndNonOpenOrders(
- targetOrderProviderResponse.orders,
- expiryBufferSeconds,
- );
- const filteredFeeOrders = filterOutExpiredAndNonOpenOrders(
- feeOrderProviderResponse.orders,
- expiryBufferSeconds,
- );
+ const filteredOrders = filterOutExpiredAndNonOpenOrders(orderProviderResponse.orders, expiryBufferSeconds);
// set the orders to be sorted equal to the filtered orders
- let unsortedTargetOrders = filteredTargetOrders;
- let unsortedFeeOrders = filteredFeeOrders;
+ let unsortedOrders = filteredOrders;
// if an orderValidator is provided, use on chain information to calculate remaining fillable makerAsset amounts
if (!_.isUndefined(orderValidator)) {
// TODO(bmillman): improvement
- // try/catch these requests and throw a more domain specific error
- // TODO(bmillman): optimization
- // reduce this to once RPC call buy combining orders into one array and then splitting up the response
- const [targetOrdersAndTradersInfo, feeOrdersAndTradersInfo] = await Promise.all(
- _.map([filteredTargetOrders, filteredFeeOrders], ordersToBeValidated => {
- const takerAddresses = _.map(ordersToBeValidated, () => constants.NULL_ADDRESS);
- return orderValidator.getOrdersAndTradersInfoAsync(ordersToBeValidated, takerAddresses);
- }),
- );
- // take orders + on chain information and find the valid orders and remaining fillable maker asset amounts
- unsortedTargetOrders = getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain(
- filteredTargetOrders,
- targetOrdersAndTradersInfo,
- zrxTokenAssetData,
+ // try/catch this request and throw a more domain specific error
+ const takerAddresses = _.map(filteredOrders, () => constants.NULL_ADDRESS);
+ const ordersAndTradersInfo = await orderValidator.getOrdersAndTradersInfoAsync(
+ filteredOrders,
+ takerAddresses,
);
// take orders + on chain information and find the valid orders and remaining fillable maker asset amounts
- unsortedFeeOrders = getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain(
- filteredFeeOrders,
- feeOrdersAndTradersInfo,
- zrxTokenAssetData,
+ unsortedOrders = getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain(
+ filteredOrders,
+ ordersAndTradersInfo,
+ isMakerAssetZrxToken,
);
}
// sort orders by rate
// TODO(bmillman): optimization
// provide a feeRate to the sorting function to more accurately sort based on the current market for ZRX tokens
- const sortedTargetOrders = sortingUtils.sortOrdersByFeeAdjustedRate(unsortedTargetOrders);
- const sortedFeeOrders = sortingUtils.sortFeeOrdersByFeeAdjustedRate(unsortedFeeOrders);
+ const sortedOrders = isMakerAssetZrxToken
+ ? sortingUtils.sortFeeOrdersByFeeAdjustedRate(unsortedOrders)
+ : sortingUtils.sortOrdersByFeeAdjustedRate(unsortedOrders);
// unbundle orders and fillable amounts and compile final result
- const targetOrdersAndRemainingFillableMakerAssetAmounts = unbundleOrdersWithAmounts(sortedTargetOrders);
- const feeOrdersAndRemainingFillableMakerAssetAmounts = unbundleOrdersWithAmounts(sortedFeeOrders);
- return {
- orders: targetOrdersAndRemainingFillableMakerAssetAmounts.orders,
- feeOrders: feeOrdersAndRemainingFillableMakerAssetAmounts.orders,
- remainingFillableMakerAssetAmounts:
- targetOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts,
- remainingFillableFeeAmounts:
- feeOrdersAndRemainingFillableMakerAssetAmounts.remainingFillableMakerAssetAmounts,
- };
+ const result = unbundleOrdersWithAmounts(sortedOrders);
+ return result;
},
};
@@ -120,7 +90,7 @@ function filterOutExpiredAndNonOpenOrders(
function getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain(
inputOrders: SignedOrder[],
ordersAndTradersInfo: OrderAndTraderInfo[],
- zrxAssetData: string,
+ isMakerAssetZrxToken: boolean,
): SignedOrderWithRemainingFillableMakerAssetAmount[] {
// iterate through the input orders and find the ones that are still fillable
// for the orders that are still fillable, calculate the remaining fillable maker asset amount
@@ -147,7 +117,7 @@ function getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain(
const remainingFillableCalculator = new RemainingFillableCalculator(
order.makerFee,
order.makerAssetAmount,
- order.makerAssetData === zrxAssetData,
+ isMakerAssetZrxToken,
transferrableAssetAmount,
transferrableFeeAssetAmount,
remainingMakerAssetAmount,
@@ -175,7 +145,7 @@ function getValidOrdersWithRemainingFillableMakerAssetAmountsFromOnChain(
*/
function unbundleOrdersWithAmounts(
ordersWithAmounts: SignedOrderWithRemainingFillableMakerAssetAmount[],
-): OrdersAndRemainingFillableMakerAssetAmounts {
+): OrdersAndFillableAmounts {
const result = _.reduce(
ordersWithAmounts,
(acc, orderWithAmount) => {
diff --git a/packages/base-contract/CHANGELOG.json b/packages/base-contract/CHANGELOG.json
index 9408ffc86..92680729f 100644
--- a/packages/base-contract/CHANGELOG.json
+++ b/packages/base-contract/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "3.0.1",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"version": "3.0.0",
"changes": [
{
diff --git a/packages/base-contract/CHANGELOG.md b/packages/base-contract/CHANGELOG.md
index 30ef4507e..90d7f3bc2 100644
--- a/packages/base-contract/CHANGELOG.md
+++ b/packages/base-contract/CHANGELOG.md
@@ -5,6 +5,10 @@ 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)
diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json
index d86dfa6c7..e95a753e6 100644
--- a/packages/base-contract/package.json
+++ b/packages/base-contract/package.json
@@ -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",
diff --git a/packages/connect/CHANGELOG.json b/packages/connect/CHANGELOG.json
index 31df1e808..2b42f1654 100644
--- a/packages/connect/CHANGELOG.json
+++ b/packages/connect/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "3.0.1",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"version": "3.0.0",
"changes": [
{
diff --git a/packages/connect/CHANGELOG.md b/packages/connect/CHANGELOG.md
index 3f0a22ced..564a91685 100644
--- a/packages/connect/CHANGELOG.md
+++ b/packages/connect/CHANGELOG.md
@@ -5,6 +5,10 @@ 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)
diff --git a/packages/connect/package.json b/packages/connect/package.json
index c4961ac55..c8f53d526 100644
--- a/packages/connect/package.json
+++ b/packages/connect/package.json
@@ -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 .",
diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json
index 6a9a1d110..ffb15c43a 100644
--- a/packages/contract-wrappers/CHANGELOG.json
+++ b/packages/contract-wrappers/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "2.0.2",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "2.0.1",
"changes": [
diff --git a/packages/contract-wrappers/CHANGELOG.md b/packages/contract-wrappers/CHANGELOG.md
index 8a9612be5..217347d1f 100644
--- a/packages/contract-wrappers/CHANGELOG.md
+++ b/packages/contract-wrappers/CHANGELOG.md
@@ -5,6 +5,10 @@ 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
diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json
index b561fff75..c345d0a6a 100644
--- a/packages/contract-wrappers/package.json
+++ b/packages/contract-wrappers/package.json
@@ -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/**/*",
@@ -52,7 +53,6 @@
"@types/sinon": "^2.2.2",
"@types/uuid": "^3.4.2",
"@types/web3-provider-engine": "^14.0.0",
- "awesome-typescript-loader": "^3.1.3",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^2.0.1",
diff --git a/packages/contract-wrappers/src/contract_wrappers.ts b/packages/contract-wrappers/src/contract_wrappers.ts
index 4272cc943..89402029b 100644
--- a/packages/contract-wrappers/src/contract_wrappers.ts
+++ b/packages/contract-wrappers/src/contract_wrappers.ts
@@ -58,7 +58,7 @@ export class ContractWrappers {
*/
public orderValidator: OrderValidatorWrapper;
- private _web3Wrapper: Web3Wrapper;
+ private readonly _web3Wrapper: Web3Wrapper;
/**
* Instantiates a new ContractWrappers instance.
* @param provider The Provider instance you would like the 0x.js library to use for interacting with
diff --git a/packages/contract-wrappers/src/fetchers/order_filled_cancelled_fetcher.ts b/packages/contract-wrappers/src/fetchers/order_filled_cancelled_fetcher.ts
index ba6f5fb5e..7a252aed3 100644
--- a/packages/contract-wrappers/src/fetchers/order_filled_cancelled_fetcher.ts
+++ b/packages/contract-wrappers/src/fetchers/order_filled_cancelled_fetcher.ts
@@ -3,7 +3,6 @@ import { AbstractOrderFilledCancelledFetcher } from '@0xproject/order-utils';
import { BigNumber } from '@0xproject/utils';
import { BlockParamLiteral } from 'ethereum-types';
-import { ERC20TokenWrapper } from '../contract_wrappers/erc20_token_wrapper';
import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
export class OrderFilledCancelledFetcher implements AbstractOrderFilledCancelledFetcher {
diff --git a/packages/contract-wrappers/src/utils/assert.ts b/packages/contract-wrappers/src/utils/assert.ts
index bed833b8f..30726c546 100644
--- a/packages/contract-wrappers/src/utils/assert.ts
+++ b/packages/contract-wrappers/src/utils/assert.ts
@@ -1,7 +1,7 @@
import { assert as sharedAssert } from '@0xproject/assert';
// HACK: We need those two unused imports because they're actually used by sharedAssert which gets injected here
import { Schema } from '@0xproject/json-schemas'; // tslint:disable-line:no-unused-variable
-import { signatureUtils, assetDataUtils } from '@0xproject/order-utils';
+import { assetDataUtils, signatureUtils } from '@0xproject/order-utils';
import { Order } from '@0xproject/types'; // tslint:disable-line:no-unused-variable
import { BigNumber } from '@0xproject/utils'; // tslint:disable-line:no-unused-variable
import { Web3Wrapper } from '@0xproject/web3-wrapper';
diff --git a/packages/contract-wrappers/src/utils/decorators.ts b/packages/contract-wrappers/src/utils/decorators.ts
index d6bf6ec1e..e17246015 100644
--- a/packages/contract-wrappers/src/utils/decorators.ts
+++ b/packages/contract-wrappers/src/utils/decorators.ts
@@ -1,4 +1,3 @@
-import { RevertReason } from '@0xproject/types';
import * as _ from 'lodash';
import { AsyncMethod, ContractWrappersError, SyncMethod } from '../types';
@@ -46,7 +45,7 @@ const asyncErrorHandlerFactory = (errorTransformer: ErrorTransformer) => {
// tslint:disable-next-line:only-arrow-functions
descriptor.value = async function(...args: any[]): Promise<any> {
try {
- const result = await originalMethod.apply(this, args);
+ const result = await originalMethod.apply(this, args); // tslint:disable-line:no-invalid-this
return result;
} catch (error) {
const transformedError = errorTransformer(error);
@@ -73,7 +72,7 @@ const syncErrorHandlerFactory = (errorTransformer: ErrorTransformer) => {
// tslint:disable-next-line:only-arrow-functions
descriptor.value = function(...args: any[]): any {
try {
- const result = originalMethod.apply(this, args);
+ const result = originalMethod.apply(this, args); // tslint:disable-line:no-invalid-this
return result;
} catch (error) {
const transformedError = errorTransformer(error);
diff --git a/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts b/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts
index 279f2a796..a7c4a238f 100644
--- a/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts
+++ b/packages/contract-wrappers/src/utils/exchange_transfer_simulator.ts
@@ -34,7 +34,7 @@ const ERR_MSG_MAPPING = {
};
export class ExchangeTransferSimulator {
- private _store: AbstractBalanceAndProxyAllowanceLazyStore;
+ private readonly _store: AbstractBalanceAndProxyAllowanceLazyStore;
private static _throwValidationError(
failureReason: FailureReason,
tradeSide: TradeSide,
diff --git a/packages/contract-wrappers/src/utils/filter_utils.ts b/packages/contract-wrappers/src/utils/filter_utils.ts
index 0e73987f7..c05be062c 100644
--- a/packages/contract-wrappers/src/utils/filter_utils.ts
+++ b/packages/contract-wrappers/src/utils/filter_utils.ts
@@ -1,4 +1,4 @@
-import { ConstructorAbi, ContractAbi, EventAbi, FallbackAbi, FilterObject, LogEntry, MethodAbi } from 'ethereum-types';
+import { ContractAbi, EventAbi, FilterObject, LogEntry } from 'ethereum-types';
import * as ethUtil from 'ethereumjs-util';
import * as jsSHA3 from 'js-sha3';
import * as _ from 'lodash';
diff --git a/packages/contract-wrappers/src/utils/transaction_encoder.ts b/packages/contract-wrappers/src/utils/transaction_encoder.ts
index 8821079dc..87cbb43fd 100644
--- a/packages/contract-wrappers/src/utils/transaction_encoder.ts
+++ b/packages/contract-wrappers/src/utils/transaction_encoder.ts
@@ -23,7 +23,7 @@ const EIP712_ZEROEX_TRANSACTION_SCHEMA: EIP712Schema = {
* can submit this to the blockchain. The Exchange context executes as if UserA had directly submitted this transaction.
*/
export class TransactionEncoder {
- private _exchangeInstance: ExchangeContract;
+ private readonly _exchangeInstance: ExchangeContract;
constructor(exchangeInstance: ExchangeContract) {
this._exchangeInstance = exchangeInstance;
}
diff --git a/packages/contract-wrappers/test/calldata_optimization_utils_test.ts b/packages/contract-wrappers/test/calldata_optimization_utils_test.ts
index a3abb8503..94e55bffa 100644
--- a/packages/contract-wrappers/test/calldata_optimization_utils_test.ts
+++ b/packages/contract-wrappers/test/calldata_optimization_utils_test.ts
@@ -3,7 +3,6 @@ import * as chai from 'chai';
import * as _ from 'lodash';
import 'mocha';
-import { assert } from '../src/utils/assert';
import { calldataOptimizationUtils } from '../src/utils/calldata_optimization_utils';
import { constants } from '../src/utils/constants';
diff --git a/packages/contract-wrappers/test/erc721_wrapper_test.ts b/packages/contract-wrappers/test/erc721_wrapper_test.ts
index ab6ff0984..10bac6086 100644
--- a/packages/contract-wrappers/test/erc721_wrapper_test.ts
+++ b/packages/contract-wrappers/test/erc721_wrapper_test.ts
@@ -229,11 +229,17 @@ describe('ERC721Wrapper', () => {
it('should set the proxy approval', async () => {
const tokenId = await tokenUtils.mintDummyERC721Async(tokenAddress, ownerAddress);
- const approvalBeforeSet = await contractWrappers.erc721Token.isProxyApprovedAsync(tokenAddress, tokenId);
- expect(approvalBeforeSet).to.be.false();
+ const isProxyApprovedBeforeSet = await contractWrappers.erc721Token.isProxyApprovedAsync(
+ tokenAddress,
+ tokenId,
+ );
+ expect(isProxyApprovedBeforeSet).to.be.false();
await contractWrappers.erc721Token.setProxyApprovalAsync(tokenAddress, tokenId);
- const approvalAfterSet = await contractWrappers.erc721Token.isProxyApprovedAsync(tokenAddress, tokenId);
- expect(approvalAfterSet).to.be.true();
+ const isProxyApprovedAfterSet = await contractWrappers.erc721Token.isProxyApprovedAsync(
+ tokenAddress,
+ tokenId,
+ );
+ expect(isProxyApprovedAfterSet).to.be.true();
});
});
describe('#subscribe', () => {
@@ -357,7 +363,6 @@ describe('ERC721Wrapper', () => {
);
contractWrappers.erc721Token.unsubscribe(subscriptionToken);
- const tokenId = await tokenUtils.mintDummyERC721Async(tokenAddress, ownerAddress);
const isApproved = true;
await web3Wrapper.awaitTransactionSuccessAsync(
await contractWrappers.erc721Token.setApprovalForAllAsync(
@@ -373,15 +378,11 @@ describe('ERC721Wrapper', () => {
});
});
describe('#getLogsAsync', () => {
- let tokenTransferProxyAddress: string;
const blockRange: BlockRange = {
fromBlock: 0,
toBlock: BlockParamLiteral.Latest,
};
let txHash: string;
- before(() => {
- tokenTransferProxyAddress = contractWrappers.erc721Proxy.getContractAddress();
- });
it('should get logs with decoded args emitted by ApprovalForAll', async () => {
const isApprovedForAll = true;
txHash = await contractWrappers.erc721Token.setApprovalForAllAsync(
diff --git a/packages/contract-wrappers/test/ether_token_wrapper_test.ts b/packages/contract-wrappers/test/ether_token_wrapper_test.ts
index c15b8c016..c48fc224f 100644
--- a/packages/contract-wrappers/test/ether_token_wrapper_test.ts
+++ b/packages/contract-wrappers/test/ether_token_wrapper_test.ts
@@ -344,7 +344,7 @@ describe('EtherTokenWrapper', () => {
etherTokenAddress = tokenUtils.getWethTokenAddress();
erc20ProxyAddress = contractWrappers.erc20Proxy.getContractAddress();
// Start the block range after all migrations to avoid unexpected logs
- const currentBlock = await web3Wrapper.getBlockNumberAsync();
+ const currentBlock: number = await web3Wrapper.getBlockNumberAsync();
const fromBlock = currentBlock + 1;
blockRange = {
fromBlock,
diff --git a/packages/contract-wrappers/test/forwarder_wrapper_test.ts b/packages/contract-wrappers/test/forwarder_wrapper_test.ts
index a969807b2..f77b47337 100644
--- a/packages/contract-wrappers/test/forwarder_wrapper_test.ts
+++ b/packages/contract-wrappers/test/forwarder_wrapper_test.ts
@@ -1,14 +1,12 @@
-import { BlockchainLifecycle, callbackErrorReporter } from '@0xproject/dev-utils';
+import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { FillScenarios } from '@0xproject/fill-scenarios';
-import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils';
-import { DoneCallback, SignedOrder } from '@0xproject/types';
+import { assetDataUtils } from '@0xproject/order-utils';
+import { SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
-import { BlockParamLiteral } from 'ethereum-types';
import 'mocha';
-import { ContractWrappers, ExchangeCancelEventArgs, ExchangeEvents, ExchangeFillEventArgs, OrderStatus } from '../src';
-import { DecodedLogEvent } from '../src/types';
+import { ContractWrappers, OrderStatus } from '../src';
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
diff --git a/packages/contract-wrappers/test/order_validator_wrapper_test.ts b/packages/contract-wrappers/test/order_validator_wrapper_test.ts
index 2fdb00a71..baac3eeee 100644
--- a/packages/contract-wrappers/test/order_validator_wrapper_test.ts
+++ b/packages/contract-wrappers/test/order_validator_wrapper_test.ts
@@ -1,15 +1,14 @@
-import { BlockchainLifecycle, callbackErrorReporter } from '@0xproject/dev-utils';
+import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { FillScenarios } from '@0xproject/fill-scenarios';
-import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils';
-import { DoneCallback, SignedOrder } from '@0xproject/types';
+import { assetDataUtils } from '@0xproject/order-utils';
+import { SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
-import { BlockParamLiteral } from 'ethereum-types';
import * as _ from 'lodash';
import 'mocha';
-import { ContractWrappers, ExchangeCancelEventArgs, ExchangeEvents, ExchangeFillEventArgs, OrderStatus } from '../src';
-import { DecodedLogEvent, OrderInfo, TraderInfo } from '../src/types';
+import { ContractWrappers, OrderStatus } from '../src';
+import { OrderInfo, TraderInfo } from '../src/types';
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
@@ -26,7 +25,6 @@ describe('OrderValidator', () => {
blockPollingIntervalMs: 0,
};
const fillableAmount = new BigNumber(5);
- const partialFillAmount = new BigNumber(2);
let contractWrappers: ContractWrappers;
let fillScenarios: FillScenarios;
let exchangeContractAddress: string;
diff --git a/packages/contract-wrappers/test/subscription_test.ts b/packages/contract-wrappers/test/subscription_test.ts
index 68ef7225e..6ec7519fe 100644
--- a/packages/contract-wrappers/test/subscription_test.ts
+++ b/packages/contract-wrappers/test/subscription_test.ts
@@ -1,6 +1,5 @@
-import { BlockchainLifecycle, callbackErrorReporter } from '@0xproject/dev-utils';
+import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { DoneCallback } from '@0xproject/types';
-import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import 'mocha';
import * as Sinon from 'sinon';
@@ -18,17 +17,11 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('SubscriptionTest', () => {
let contractWrappers: ContractWrappers;
- let userAddresses: string[];
- let coinbase: string;
- let addressWithoutFunds: string;
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
};
before(async () => {
contractWrappers = new ContractWrappers(provider, config);
- userAddresses = await web3Wrapper.getAvailableAddressesAsync();
- coinbase = userAddresses[0];
- addressWithoutFunds = userAddresses[1];
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -39,7 +32,6 @@ describe('SubscriptionTest', () => {
describe('#subscribe', () => {
const indexFilterValues = {};
let tokenAddress: string;
- const allowanceAmount = new BigNumber(42);
let stubs: Sinon.SinonStub[] = [];
before(() => {
const tokenAddresses = tokenUtils.getDummyERC20TokenAddresses();
@@ -53,7 +45,7 @@ describe('SubscriptionTest', () => {
it('Should allow unsubscribeAll to be called successfully after an error', (done: DoneCallback) => {
(async () => {
const callback = (err: Error | null, _logEvent?: DecodedLogEvent<ERC20TokenApprovalEventArgs>) =>
- _.noop;
+ _.noop.bind(_);
contractWrappers.erc20Token.subscribe(
tokenAddress,
ERC20TokenEvents.Approval,
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index edd2f96b5..6d4534eac 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -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",
diff --git a/packages/dev-utils/CHANGELOG.json b/packages/dev-utils/CHANGELOG.json
index 8d3f613b8..e825c012a 100644
--- a/packages/dev-utils/CHANGELOG.json
+++ b/packages/dev-utils/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.0.12",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.0.11",
"changes": [
diff --git a/packages/dev-utils/CHANGELOG.md b/packages/dev-utils/CHANGELOG.md
index f978fcbb5..4598c8e5b 100644
--- a/packages/dev-utils/CHANGELOG.md
+++ b/packages/dev-utils/CHANGELOG.md
@@ -5,6 +5,10 @@ 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
diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json
index bd8f50d3c..c0f6107b3 100644
--- a/packages/dev-utils/package.json
+++ b/packages/dev-utils/package.json
@@ -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",
diff --git a/packages/ethereum-types/CHANGELOG.json b/packages/ethereum-types/CHANGELOG.json
index 50f46fc02..0552bb184 100644
--- a/packages/ethereum-types/CHANGELOG.json
+++ b/packages/ethereum-types/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.0.10",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.0.9",
"changes": [
diff --git a/packages/ethereum-types/CHANGELOG.md b/packages/ethereum-types/CHANGELOG.md
index 3370531b0..0ce074916 100644
--- a/packages/ethereum-types/CHANGELOG.md
+++ b/packages/ethereum-types/CHANGELOG.md
@@ -5,6 +5,10 @@ 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
diff --git a/packages/ethereum-types/package.json b/packages/ethereum-types/package.json
index b65e5b25b..d52f39a2d 100644
--- a/packages/ethereum-types/package.json
+++ b/packages/ethereum-types/package.json
@@ -1,6 +1,6 @@
{
"name": "ethereum-types",
- "version": "1.0.9",
+ "version": "1.0.10",
"engines": {
"node": ">=6.12"
},
@@ -9,6 +9,7 @@
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc -b",
+ "build:ci": "yarn build",
"clean": "shx rm -rf lib generated_docs",
"lint": "tslint --project .",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
diff --git a/packages/ethereum-types/src/index.ts b/packages/ethereum-types/src/index.ts
index 916661638..7e8b9de3e 100644
--- a/packages/ethereum-types/src/index.ts
+++ b/packages/ethereum-types/src/index.ts
@@ -497,4 +497,4 @@ export interface CompilerOptions {
compilerSettings?: CompilerSettings;
contracts?: string[] | '*';
solcVersion?: string;
-}
+} // tslint:disable-line:max-file-line-count
diff --git a/packages/fill-scenarios/CHANGELOG.json b/packages/fill-scenarios/CHANGELOG.json
index ac03ccba5..dca21f447 100644
--- a/packages/fill-scenarios/CHANGELOG.json
+++ b/packages/fill-scenarios/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.0.7",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.0.6",
"changes": [
diff --git a/packages/fill-scenarios/CHANGELOG.md b/packages/fill-scenarios/CHANGELOG.md
index 3abf688ed..585a31027 100644
--- a/packages/fill-scenarios/CHANGELOG.md
+++ b/packages/fill-scenarios/CHANGELOG.md
@@ -5,6 +5,10 @@ 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
diff --git a/packages/fill-scenarios/package.json b/packages/fill-scenarios/package.json
index 12e591dac..54c2f90da 100644
--- a/packages/fill-scenarios/package.json
+++ b/packages/fill-scenarios/package.json
@@ -6,6 +6,7 @@
"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",
diff --git a/packages/instant/.gitignore b/packages/instant/.gitignore
new file mode 100644
index 000000000..e1ce60fa2
--- /dev/null
+++ b/packages/instant/.gitignore
@@ -0,0 +1,2 @@
+public/main.bundle.js
+public/main.bundle.js.map \ No newline at end of file
diff --git a/packages/instant/CHANGELOG.json b/packages/instant/CHANGELOG.json
new file mode 100644
index 000000000..fe51488c7
--- /dev/null
+++ b/packages/instant/CHANGELOG.json
@@ -0,0 +1 @@
+[]
diff --git a/packages/instant/CHANGELOG.md b/packages/instant/CHANGELOG.md
new file mode 100644
index 000000000..8b1378917
--- /dev/null
+++ b/packages/instant/CHANGELOG.md
@@ -0,0 +1 @@
+
diff --git a/packages/instant/README.md b/packages/instant/README.md
new file mode 100644
index 000000000..25aca9d3b
--- /dev/null
+++ b/packages/instant/README.md
@@ -0,0 +1,99 @@
+## @0xproject/instant
+
+## Installation
+
+```bash
+yarn add @0xproject/instant
+```
+
+**Import**
+
+**CommonJS module**
+
+```typescript
+import { ZeroExInstant } from '@0xproject/instant';
+```
+
+or
+
+```javascript
+var ZeroExInstant = require('@0xproject/instant').ZeroExInstant;
+```
+
+If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
+
+```json
+"compilerOptions": {
+ "typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
+}
+```
+
+**UMD Module**
+
+The package is also available as a UMD module named `zeroExInstant`.
+
+```html
+<head>
+ <script type="text/javascript" src="[zeroExInstantUMDPath]" charset="utf-8"></script>
+</head>
+<body>
+ <div id="zeroExInstantContainer"></div>
+ <script>
+ zeroExInstant.render({
+ // Initialization options
+ }, '#zeroExInstantContainer');
+ </script>
+</body>
+```
+
+## Contributing
+
+We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
+
+Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
+
+### Install dependencies
+
+If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
+
+```bash
+yarn config set workspaces-experimental true
+```
+
+Then install dependencies
+
+```bash
+yarn install
+```
+
+### Build
+
+To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
+
+```bash
+PKG=@0xproject/instant yarn build
+```
+
+Or continuously rebuild on change:
+
+```bash
+PKG=@0xproject/instant yarn watch
+```
+
+### Clean
+
+```bash
+yarn clean
+```
+
+### Lint
+
+```bash
+yarn lint
+```
+
+### Run Tests
+
+```bash
+yarn test
+```
diff --git a/packages/instant/jest.config.js b/packages/instant/jest.config.js
new file mode 100644
index 000000000..29c365835
--- /dev/null
+++ b/packages/instant/jest.config.js
@@ -0,0 +1,10 @@
+module.exports = {
+ roots: ['<rootDir>/test'],
+ coverageDirectory: 'coverage',
+ transform: {
+ '.*.tsx?$': 'ts-jest',
+ },
+ testRegex: '(/__test__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
+ collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/index.tsx'],
+};
diff --git a/packages/instant/package.json b/packages/instant/package.json
new file mode 100644
index 000000000..365312a70
--- /dev/null
+++ b/packages/instant/package.json
@@ -0,0 +1,84 @@
+{
+ "name": "@0xproject/instant",
+ "version": "0.0.1",
+ "engines": {
+ "node": ">=6.12"
+ },
+ "private": true,
+ "description": "0x Instant React Component",
+ "main": "lib/src/index.js",
+ "types": "lib/src/index.d.ts",
+ "scripts": {
+ "build": "yarn build:all",
+ "build:all": "run-p build:umd:prod build:commonjs",
+ "build:umd:prod": "webpack --mode production",
+ "build:commonjs": "tsc -b",
+ "build:ci": "yarn build",
+ "watch_without_deps": "tsc -w",
+ "dev": "webpack-dev-server --mode development",
+ "lint": "tslint --project .",
+ "test": "jest",
+ "test:coverage": "jest --coverage",
+ "rebuild_and_test": "run-s clean build test",
+ "test:circleci": "yarn test:coverage",
+ "clean": "shx rm -rf lib coverage scripts",
+ "manual:postpublish": "yarn build; node ./scripts/postpublish.js"
+ },
+ "config": {
+ "postpublish": {
+ "assets": [
+ "packages/instant/public/index.js",
+ "packages/instant/public/index.min.js"
+ ]
+ }
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/0xProject/0x-monorepo.git"
+ },
+ "author": "Francesco Agosti",
+ "license": "Apache-2.0",
+ "bugs": {
+ "url": "https://github.com/0xProject/0x-monorepo/issues"
+ },
+ "homepage": "https://github.com/0xProject/0x-monorepo/packages/instant/README.md",
+ "dependencies": {
+ "@0xproject/connect": "^2.0.4",
+ "@0xproject/types": "^1.1.1",
+ "@0xproject/typescript-typings": "^2.0.2",
+ "@0xproject/utils": "^1.0.11",
+ "@0xproject/web3-wrapper": "^3.0.1",
+ "ethereum-types": "^1.0.8",
+ "lodash": "^4.17.10",
+ "react": "^16.5.2",
+ "react-dom": "^16.5.2"
+ },
+ "devDependencies": {
+ "@0xproject/tslint-config": "^1.0.7",
+ "@types/enzyme": "^3.1.14",
+ "@types/enzyme-adapter-react-16": "^1.0.3",
+ "@types/lodash": "^4.14.116",
+ "@types/node": "*",
+ "@types/react": "16.4.7",
+ "@types/react-dom": "^16.0.8",
+ "awesome-typescript-loader": "^5.2.1",
+ "copyfiles": "^1.2.0",
+ "enzyme": "^3.6.0",
+ "enzyme-adapter-react-16": "^1.5.0",
+ "jest": "^23.6.0",
+ "make-promises-safe": "^1.1.0",
+ "npm-run-all": "^4.1.2",
+ "nyc": "^11.0.1",
+ "shx": "^0.2.2",
+ "ts-jest": "^23.10.3",
+ "tslint": "5.11.0",
+ "typedoc": "0.12.0",
+ "typescript": "3.0.1",
+ "webpack": "^4.20.2",
+ "webpack-cli": "^3.1.1",
+ "webpack-dev-server": "^3.1.9"
+ },
+ "publishConfig": {
+ "access": "private"
+ }
+}
diff --git a/packages/instant/public/index.html b/packages/instant/public/index.html
new file mode 100644
index 000000000..45968a3c9
--- /dev/null
+++ b/packages/instant/public/index.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>0x Instant Dev Environment</title>
+ <script type="text/javascript" src="/main.bundle.js" charset="utf-8"></script>
+</head>
+
+<body>
+ <div id="zeroExInstantContainer"></div>
+ <script>
+ zeroExInstant.render({
+
+ });
+ </script>
+</body>
+
+</html> \ No newline at end of file
diff --git a/packages/instant/src/components/zero_ex_instant.tsx b/packages/instant/src/components/zero_ex_instant.tsx
new file mode 100644
index 000000000..67e1b683d
--- /dev/null
+++ b/packages/instant/src/components/zero_ex_instant.tsx
@@ -0,0 +1,5 @@
+import * as React from 'react';
+
+export interface ZeroExInstantProps {}
+
+export const ZeroExInstant: React.StatelessComponent<ZeroExInstantProps> = () => <div>ZeroExInstant</div>;
diff --git a/packages/instant/src/globals.d.ts b/packages/instant/src/globals.d.ts
new file mode 100644
index 000000000..94e63a32d
--- /dev/null
+++ b/packages/instant/src/globals.d.ts
@@ -0,0 +1,6 @@
+declare module '*.json' {
+ const json: any;
+ /* tslint:disable */
+ export default json;
+ /* tslint:enable */
+}
diff --git a/packages/instant/src/index.ts b/packages/instant/src/index.ts
new file mode 100644
index 000000000..54059cdad
--- /dev/null
+++ b/packages/instant/src/index.ts
@@ -0,0 +1 @@
+export { ZeroExInstant, ZeroExInstantProps } from './components/zero_ex_instant';
diff --git a/packages/instant/src/index.umd.ts b/packages/instant/src/index.umd.ts
new file mode 100644
index 000000000..d4eca177d
--- /dev/null
+++ b/packages/instant/src/index.umd.ts
@@ -0,0 +1,10 @@
+import * as React from 'react';
+import * as ReactDOM from 'react-dom';
+
+import { ZeroExInstant } from './index';
+
+export interface ZeroExInstantOptions {}
+
+export const render = (props: ZeroExInstantOptions, selector: string = '#zeroExInstantContainer') => {
+ ReactDOM.render(React.createElement(ZeroExInstant, props), document.querySelector(selector));
+};
diff --git a/packages/instant/test/components/zero_ex_instant.test.tsx b/packages/instant/test/components/zero_ex_instant.test.tsx
new file mode 100644
index 000000000..5858732cf
--- /dev/null
+++ b/packages/instant/test/components/zero_ex_instant.test.tsx
@@ -0,0 +1,13 @@
+import { configure, shallow } from 'enzyme';
+import * as Adapter from 'enzyme-adapter-react-16';
+import * as React from 'react';
+
+configure({ adapter: new Adapter() });
+
+import { ZeroExInstant } from '../../src';
+
+describe('<ZeroExInstant />', () => {
+ it('shallow renders without crashing', () => {
+ shallow(<ZeroExInstant />);
+ });
+});
diff --git a/packages/instant/tsconfig.json b/packages/instant/tsconfig.json
new file mode 100644
index 000000000..28a6190b8
--- /dev/null
+++ b/packages/instant/tsconfig.json
@@ -0,0 +1,17 @@
+{
+ "extends": "../../tsconfig",
+ "compilerOptions": {
+ "outDir": "lib",
+ "rootDir": ".",
+ "jsx": "react",
+ "allowSyntheticDefaultImports": true,
+ "noImplicitAny": true,
+ "module": "ESNext",
+ "moduleResolution": "node",
+ "lib": ["es2015", "dom"],
+ "target": "es5",
+ "sourceMap": true
+ },
+ "include": ["./src/**/*", "./test/**/*"],
+ "exclude": ["./src/index.umd.ts"]
+}
diff --git a/packages/instant/tslint.json b/packages/instant/tslint.json
new file mode 100644
index 000000000..ffaefe83a
--- /dev/null
+++ b/packages/instant/tslint.json
@@ -0,0 +1,3 @@
+{
+ "extends": ["@0xproject/tslint-config"]
+}
diff --git a/packages/instant/typedoc-tsconfig.json b/packages/instant/typedoc-tsconfig.json
new file mode 100644
index 000000000..c9b0af1ae
--- /dev/null
+++ b/packages/instant/typedoc-tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../typedoc-tsconfig",
+ "compilerOptions": {
+ "outDir": "lib"
+ },
+ "include": ["./src/**/*", "./test/**/*"]
+}
diff --git a/packages/instant/webpack.config.js b/packages/instant/webpack.config.js
new file mode 100644
index 000000000..78a33ce90
--- /dev/null
+++ b/packages/instant/webpack.config.js
@@ -0,0 +1,28 @@
+const path = require('path');
+// The common js bundle (not this one) is built using tsc.
+// The umd bundle (this one) has a different entrypoint.
+module.exports = {
+ entry: './src/index.umd.ts',
+ output: {
+ filename: '[name].bundle.js',
+ path: path.resolve(__dirname, 'public'),
+ library: 'zeroExInstant',
+ libraryTarget: 'umd',
+ },
+ devtool: 'source-map',
+ resolve: {
+ extensions: ['.js', '.json', '.ts', '.tsx'],
+ },
+ module: {
+ rules: [
+ {
+ test: /\.(ts|tsx)$/,
+ loader: 'awesome-typescript-loader',
+ },
+ ],
+ },
+ devServer: {
+ contentBase: path.join(__dirname, 'public'),
+ port: 5000,
+ },
+};
diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json
index 1b6bb61bb..b9f6b08dd 100644
--- a/packages/json-schemas/CHANGELOG.json
+++ b/packages/json-schemas/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.0.6",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.0.5",
"changes": [
diff --git a/packages/json-schemas/CHANGELOG.md b/packages/json-schemas/CHANGELOG.md
index b0547dccf..7bfd02c9b 100644
--- a/packages/json-schemas/CHANGELOG.md
+++ b/packages/json-schemas/CHANGELOG.md
@@ -5,6 +5,10 @@ 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
diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json
index 495f9ba78..dc3e97a86 100644
--- a/packages/json-schemas/package.json
+++ b/packages/json-schemas/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/json-schemas",
- "version": "1.0.5",
+ "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",
diff --git a/packages/metacoin/package.json b/packages/metacoin/package.json
index accfa00a6..d7c5aadec 100644
--- a/packages/metacoin/package.json
+++ b/packages/metacoin/package.json
@@ -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",
diff --git a/packages/migrations/CHANGELOG.json b/packages/migrations/CHANGELOG.json
index 34c0d44a3..772fc6cac 100644
--- a/packages/migrations/CHANGELOG.json
+++ b/packages/migrations/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.0.14",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.0.13",
"changes": [
diff --git a/packages/migrations/CHANGELOG.md b/packages/migrations/CHANGELOG.md
index 685aa07c5..78b6ae149 100644
--- a/packages/migrations/CHANGELOG.md
+++ b/packages/migrations/CHANGELOG.md
@@ -5,6 +5,10 @@ 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
diff --git a/packages/migrations/package.json b/packages/migrations/package.json
index 7374c5210..896570cd4 100644
--- a/packages/migrations/package.json
+++ b/packages/migrations/package.json
@@ -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",
diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json
index 748b88f6a..ba4c4fead 100644
--- a/packages/monorepo-scripts/package.json
+++ b/packages/monorepo-scripts/package.json
@@ -10,6 +10,7 @@
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc -b",
+ "build:ci": "yarn build",
"lint": "tslint --project .",
"clean": "shx rm -rf lib",
"test:publish": "run-s build script:publish",
diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json
index b486d6503..b6c284908 100644
--- a/packages/order-utils/CHANGELOG.json
+++ b/packages/order-utils/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.0.7",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"version": "1.0.6",
"changes": [
{
diff --git a/packages/order-utils/CHANGELOG.md b/packages/order-utils/CHANGELOG.md
index 5109b9040..747c988a2 100644
--- a/packages/order-utils/CHANGELOG.md
+++ b/packages/order-utils/CHANGELOG.md
@@ -5,6 +5,10 @@ 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)
diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json
index 832a112dc..9fefdba5e 100644
--- a/packages/order-utils/package.json
+++ b/packages/order-utils/package.json
@@ -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;",
diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json
index 3a5462727..f26bf4ca4 100644
--- a/packages/order-watcher/CHANGELOG.json
+++ b/packages/order-watcher/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "2.1.1",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"version": "2.1.0",
"changes": [
{
diff --git a/packages/order-watcher/CHANGELOG.md b/packages/order-watcher/CHANGELOG.md
index ef4398cab..7bc74cf2a 100644
--- a/packages/order-watcher/CHANGELOG.md
+++ b/packages/order-watcher/CHANGELOG.md
@@ -5,6 +5,10 @@ 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)
diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json
index f2469f172..de5f7ba09 100644
--- a/packages/order-watcher/package.json
+++ b/packages/order-watcher/package.json
@@ -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",
@@ -51,13 +52,11 @@
"@types/mocha": "^2.2.42",
"@types/node": "*",
"@types/sinon": "^2.2.2",
- "awesome-typescript-loader": "^3.1.3",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^2.0.1",
"copyfiles": "^2.0.0",
"dirty-chai": "^2.0.1",
- "json-loader": "^0.5.4",
"make-promises-safe": "^1.1.0",
"mocha": "^4.1.0",
"npm-run-all": "^4.1.2",
diff --git a/packages/react-docs/CHANGELOG.json b/packages/react-docs/CHANGELOG.json
index 7f0b25c2c..3fa89b0bc 100644
--- a/packages/react-docs/CHANGELOG.json
+++ b/packages/react-docs/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.0.13",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.0.12",
"changes": [
diff --git a/packages/react-docs/CHANGELOG.md b/packages/react-docs/CHANGELOG.md
index ccf6ccc41..48cd4d654 100644
--- a/packages/react-docs/CHANGELOG.md
+++ b/packages/react-docs/CHANGELOG.md
@@ -5,6 +5,10 @@ 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
diff --git a/packages/react-docs/package.json b/packages/react-docs/package.json
index 48df0b3cc..0379e9e2f 100644
--- a/packages/react-docs/package.json
+++ b/packages/react-docs/package.json
@@ -10,6 +10,7 @@
"scripts": {
"lint": "tslint --project .",
"build": "tsc -b",
+ "build:ci": "yarn build",
"clean": "shx rm -rf lib"
},
"author": "Fabio Berger",
diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/documentation.tsx
index 3cd14923c..a23111297 100644
--- a/packages/react-docs/src/components/documentation.tsx
+++ b/packages/react-docs/src/components/documentation.tsx
@@ -218,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}
@@ -353,7 +353,7 @@ export class Documentation extends React.Component<DocumentationProps, Documenta
key={`badge-${networkName}-${sectionName}`}
href={linkIfExists}
target="_blank"
- style={{ color: colors.white, textDecoration: 'none' }}
+ style={{ color: colors.white, textDecoration: 'none', marginTop: 8 }}
>
<Badge title={networkName} backgroundColor={networkNameToColor[networkName]} />
</a>
diff --git a/packages/react-docs/src/components/interface.tsx b/packages/react-docs/src/components/interface.tsx
index 9f0800d71..cad7d6c46 100644
--- a/packages/react-docs/src/components/interface.tsx
+++ b/packages/react-docs/src/components/interface.tsx
@@ -20,9 +20,9 @@ export interface InterfaceProps {
export const Interface: React.SFC<InterfaceProps> = (props: InterfaceProps): any => {
const type = props.type;
- const properties = _.map(type.children, property => {
+ const properties = _.map(type.children, (property, i) => {
return (
- <span key={`property-${property.name}-${property.type}-${type.name}`}>
+ <span key={`property-${property.name}-${property.type}-${type.name}-${i}`}>
{property.name}:{' '}
{property.type && !_.isUndefined(property.type.method) ? (
<Signature
diff --git a/packages/react-docs/src/components/signature.tsx b/packages/react-docs/src/components/signature.tsx
index a690a1f03..1f3dd0ee8 100644
--- a/packages/react-docs/src/components/signature.tsx
+++ b/packages/react-docs/src/components/signature.tsx
@@ -19,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) => {
@@ -34,6 +36,7 @@ export const Signature: React.SFC<SignatureProps> = (props: SignatureProps) => {
props.docsInfo,
sectionName,
props.isInPopover,
+ props.name,
props.typeDefinitionByName,
);
const paramStringArray: any[] = [];
@@ -75,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 && (
@@ -101,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 = (
@@ -116,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>
);
diff --git a/packages/react-docs/src/components/signature_block.tsx b/packages/react-docs/src/components/signature_block.tsx
index 1ea0ea28c..5ec82983a 100644
--- a/packages/react-docs/src/components/signature_block.tsx
+++ b/packages/react-docs/src/components/signature_block.tsx
@@ -32,7 +32,6 @@ export interface SignatureBlockState {
const styles: Styles = {
chip: {
fontSize: 13,
- backgroundColor: colors.lightBlueA700,
color: colors.white,
height: 11,
borderRadius: 14,
@@ -50,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}`}
@@ -63,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}
/>
@@ -84,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 && (
@@ -95,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 && (
@@ -114,19 +118,19 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu
</div>
);
}
- private _renderChip(text: string): React.ReactNode {
+ private _renderChip(text: string, backgroundColor: string = colors.lightBlueA700): React.ReactNode {
return (
- <div className="p1 mr1" style={styles.chip}>
+ <div className="p1 mr1" style={{ ...styles.chip, backgroundColor }}>
{text}
</div>
);
}
- private _renderParameterDescriptions(parameters: Parameter[]): React.ReactNode {
- const descriptions = _.map(parameters, parameter => {
+ private _renderParameterDescriptions(parameters: Parameter[], name: string): React.ReactNode {
+ const descriptions = _.map(parameters, (parameter: Parameter, i: number) => {
const isOptional = parameter.isOptional;
return (
<div
- key={`param-description-${parameter.name}`}
+ key={`param-description-${parameter.name}-${name}-${i}`}
className="flex pb1 mb2"
style={{ borderBottom: '1px solid #f0f4f7' }}
>
diff --git a/packages/react-docs/src/components/type.tsx b/packages/react-docs/src/components/type.tsx
index 156a3496d..5c018f5dd 100644
--- a/packages/react-docs/src/components/type.tsx
+++ b/packages/react-docs/src/components/type.tsx
@@ -7,12 +7,12 @@ import { Link as ScrollLink } from 'react-scroll';
import * as ReactTooltip from 'react-tooltip';
import { DocsInfo } from '../docs_info';
-import { constants } from '../utils/constants';
import { Signature } from './signature';
import { TypeDefinition } from './type_definition';
const basicJsTypes = ['string', 'number', 'undefined', 'null', 'boolean'];
+const basicSolidityTypes = ['bytes', 'bytes4', 'bytes32', 'uint8', 'uint256', 'address'];
const defaultProps = {};
@@ -80,7 +80,7 @@ export const Type: React.SFC<TypeProps> = (props: TypeProps): any => {
case TypeDocTypes.Array:
typeName = type.elementType.name;
- if (_.includes(basicJsTypes, typeName)) {
+ if (_.includes(basicJsTypes, typeName) || _.includes(basicSolidityTypes, typeName)) {
typeNameColor = colors.orange;
}
break;
@@ -168,10 +168,10 @@ export const Type: React.SFC<TypeProps> = (props: TypeProps): any => {
break;
case TypeDocTypes.Tuple:
- const tupleTypes = _.map(type.tupleElements, t => {
+ const tupleTypes = _.map(type.tupleElements, (t, i) => {
return (
<Type
- key={`type-tuple-${t.name}-${t.typeDocType}`}
+ key={`type-tuple-${t.name}-${t.typeDocType}-${i}`}
type={t}
sectionName={props.sectionName}
typeDefinitionByName={props.typeDefinitionByName}
@@ -221,7 +221,7 @@ export const Type: React.SFC<TypeProps> = (props: TypeProps): any => {
const id = Math.random().toString();
const typeDefinitionAnchorId = isExportedClassReference
? props.type.name
- : `${constants.TYPES_SECTION_NAME}-${typeName}`;
+ : `${props.docsInfo.typeSectionName}-${typeName}`;
typeName = (
<ScrollLink
to={typeDefinitionAnchorId}
diff --git a/packages/react-docs/src/components/type_definition.tsx b/packages/react-docs/src/components/type_definition.tsx
index 09cb3ff74..9a3e50a1b 100644
--- a/packages/react-docs/src/components/type_definition.tsx
+++ b/packages/react-docs/src/components/type_definition.tsx
@@ -5,7 +5,7 @@ import * as _ from 'lodash';
import * as React from 'react';
import { DocsInfo } from '../docs_info';
-import { KindString } from '../types';
+import { KindString, SupportedDocJson } from '../types';
import { constants } from '../utils/constants';
import { Comment } from './comment';
@@ -46,7 +46,7 @@ export class TypeDefinition extends React.Component<TypeDefinitionProps, TypeDef
let codeSnippet: React.ReactNode;
switch (customType.kindString) {
case KindString.Interface:
- typePrefix = 'Interface';
+ typePrefix = this.props.docsInfo.type === SupportedDocJson.SolDoc ? 'Struct' : 'Interface';
codeSnippet = (
<Interface
type={customType}
diff --git a/packages/react-docs/src/docs_info.ts b/packages/react-docs/src/docs_info.ts
index 6355a2f88..092a8c266 100644
--- a/packages/react-docs/src/docs_info.ts
+++ b/packages/react-docs/src/docs_info.ts
@@ -18,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;
@@ -28,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;
@@ -53,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;
@@ -82,12 +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;
}
}
diff --git a/packages/react-shared/CHANGELOG.json b/packages/react-shared/CHANGELOG.json
index c4ccc6013..1a01527e3 100644
--- a/packages/react-shared/CHANGELOG.json
+++ b/packages/react-shared/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.0.14",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.0.13",
"changes": [
diff --git a/packages/react-shared/CHANGELOG.md b/packages/react-shared/CHANGELOG.md
index aa2f27266..e26a2916e 100644
--- a/packages/react-shared/CHANGELOG.md
+++ b/packages/react-shared/CHANGELOG.md
@@ -5,6 +5,10 @@ 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
diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json
index 67c644bf3..95bf849ad 100644
--- a/packages/react-shared/package.json
+++ b/packages/react-shared/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/react-shared",
- "version": "1.0.13",
+ "version": "1.0.14",
"engines": {
"node": ">=6.12"
},
@@ -10,6 +10,7 @@
"scripts": {
"lint": "tslint --project .",
"build": "tsc",
+ "build:ci": "yarn build",
"watch_without_deps": "tsc -w",
"clean": "shx rm -rf lib"
},
diff --git a/packages/sol-compiler/CHANGELOG.json b/packages/sol-compiler/CHANGELOG.json
index 4d22fe827..836c34e5f 100644
--- a/packages/sol-compiler/CHANGELOG.json
+++ b/packages/sol-compiler/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.1.7",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.1.6",
"changes": [
diff --git a/packages/sol-compiler/CHANGELOG.md b/packages/sol-compiler/CHANGELOG.md
index 1882f9a8f..21cfaa879 100644
--- a/packages/sol-compiler/CHANGELOG.md
+++ b/packages/sol-compiler/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.1.7 - _October 2, 2018_
+
+ * Dependencies updated
+
## v1.1.6 - _September 28, 2018_
* Dependencies updated
diff --git a/packages/sol-compiler/package.json b/packages/sol-compiler/package.json
index 8aed81e23..d7e9653e0 100644
--- a/packages/sol-compiler/package.json
+++ b/packages/sol-compiler/package.json
@@ -9,6 +9,7 @@
"types": "lib/src/index.d.ts",
"scripts": {
"build": "yarn pre_build && tsc -b",
+ "build:ci": "yarn build",
"pre_build": "run-s update_contract_fixtures",
"update_contract_fixtures": "copyfiles 'test/fixtures/contracts/**/*' ./lib",
"test": "yarn run_mocha",
diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts
index a29367485..7eefc1474 100644
--- a/packages/sol-compiler/src/compiler.ts
+++ b/packages/sol-compiler/src/compiler.ts
@@ -296,13 +296,16 @@ export class Compiler {
compilerOutput: solc.StandardOutput,
): Promise<void> {
const compiledContract = compilerOutput.contracts[contractPath][contractName];
- const sourceCodes = _.mapValues(
- compilerOutput.sources,
- (_1, sourceFilePath) => this._resolver.resolve(sourceFilePath).source,
- );
+
+ // need to gather sourceCodes for this artifact, but compilerOutput.sources (the list of contract modules)
+ // contains listings for for every contract compiled during the compiler invocation that compiled the contract
+ // to be persisted, which could include many that are irrelevant to the contract at hand. So, gather up only
+ // the relevant sources:
+ const { sourceCodes, sources } = this._getSourcesWithDependencies(contractPath, compilerOutput.sources);
+
const contractVersion: ContractVersionData = {
compilerOutput: compiledContract,
- sources: compilerOutput.sources,
+ sources,
sourceCodes,
sourceTreeHashHex,
compiler: {
@@ -333,6 +336,80 @@ export class Compiler {
await fsWrapper.writeFileAsync(currentArtifactPath, artifactString);
logUtils.warn(`${contractName} artifact saved!`);
}
+ /**
+ * For the given @param contractPath, populates JSON objects to be used in the ContractVersionData interface's
+ * properties `sources` (source code file names mapped to ID numbers) and `sourceCodes` (source code content of
+ * contracts) for that contract. The source code pointed to by contractPath is read and parsed directly (via
+ * `this._resolver.resolve().source`), as are its imports, recursively. The ID numbers for @return `sources` are
+ * taken from the corresponding ID's in @param fullSources, and the content for @return sourceCodes is read from
+ * disk (via the aforementioned `resolver.source`).
+ */
+ private _getSourcesWithDependencies(
+ contractPath: string,
+ fullSources: { [sourceName: string]: { id: number } },
+ ): { sourceCodes: { [sourceName: string]: string }; sources: { [sourceName: string]: { id: number } } } {
+ const sources = { [contractPath]: { id: fullSources[contractPath].id } };
+ const sourceCodes = { [contractPath]: this._resolver.resolve(contractPath).source };
+ this._recursivelyGatherDependencySources(
+ contractPath,
+ sourceCodes[contractPath],
+ fullSources,
+ sources,
+ sourceCodes,
+ );
+ return { sourceCodes, sources };
+ }
+ private _recursivelyGatherDependencySources(
+ contractPath: string,
+ contractSource: string,
+ fullSources: { [sourceName: string]: { id: number } },
+ sourcesToAppendTo: { [sourceName: string]: { id: number } },
+ sourceCodesToAppendTo: { [sourceName: string]: string },
+ ): void {
+ const importStatementMatches = contractSource.match(/\nimport[^;]*;/g);
+ if (importStatementMatches === null) {
+ return;
+ }
+ for (const importStatementMatch of importStatementMatches) {
+ const importPathMatches = importStatementMatch.match(/\"([^\"]*)\"/);
+ if (importPathMatches === null || importPathMatches.length === 0) {
+ continue;
+ }
+
+ let importPath = importPathMatches[1];
+ // HACK(ablrow): We have, e.g.:
+ //
+ // importPath = "../../utils/LibBytes/LibBytes.sol"
+ // contractPath = "2.0.0/protocol/AssetProxyOwner/AssetProxyOwner.sol"
+ //
+ // Resolver doesn't understand "../" so we want to pass
+ // "2.0.0/utils/LibBytes/LibBytes.sol" to resolver.
+ //
+ // This hack involves using path.resolve. But path.resolve returns
+ // absolute directories by default. We trick it into thinking that
+ // contractPath is a root directory by prepending a '/' and then
+ // removing the '/' the end.
+ //
+ // path.resolve("/a/b/c", ""../../d/e") === "/a/d/e"
+ //
+ const lastPathSeparatorPos = contractPath.lastIndexOf('/');
+ const contractFolder = lastPathSeparatorPos === -1 ? '' : contractPath.slice(0, lastPathSeparatorPos + 1);
+ importPath = path.resolve('/' + contractFolder, importPath).replace('/', '');
+
+ if (_.isUndefined(sourcesToAppendTo[importPath])) {
+ sourcesToAppendTo[importPath] = { id: fullSources[importPath].id };
+ sourceCodesToAppendTo[importPath] = this._resolver.resolve(importPath).source;
+
+ this._recursivelyGatherDependencySources(
+ importPath,
+ this._resolver.resolve(importPath).source,
+ fullSources,
+ sourcesToAppendTo,
+ sourceCodesToAppendTo,
+ );
+ }
+ }
+ }
private _compile(solcInstance: solc.SolcInstance, standardInput: solc.StandardInput): solc.StandardOutput {
const compiled: solc.StandardOutput = JSON.parse(
solcInstance.compileStandardWrapper(JSON.stringify(standardInput), importPath => {
diff --git a/packages/sol-cov/CHANGELOG.json b/packages/sol-cov/CHANGELOG.json
index 4daf3de41..334492760 100644
--- a/packages/sol-cov/CHANGELOG.json
+++ b/packages/sol-cov/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "2.1.7",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "2.1.6",
"changes": [
diff --git a/packages/sol-cov/CHANGELOG.md b/packages/sol-cov/CHANGELOG.md
index 35b7bbc33..5c1e61c1f 100644
--- a/packages/sol-cov/CHANGELOG.md
+++ b/packages/sol-cov/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v2.1.7 - _October 2, 2018_
+
+ * Dependencies updated
+
## v2.1.6 - _September 28, 2018_
* Dependencies updated
diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json
index 9b284c6d3..4711c9770 100644
--- a/packages/sol-cov/package.json
+++ b/packages/sol-cov/package.json
@@ -9,6 +9,7 @@
"types": "lib/src/index.d.ts",
"scripts": {
"build": "yarn pre_build && tsc -b",
+ "build:ci": "yarn build",
"pre_build": "run-s copy_test_fixtures",
"lint": "tslint --project .",
"test": "run-s compile_test run_mocha",
diff --git a/packages/sol-doc/CHANGELOG.json b/packages/sol-doc/CHANGELOG.json
index 77f90ff7a..9d3f4bcde 100644
--- a/packages/sol-doc/CHANGELOG.json
+++ b/packages/sol-doc/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.0.2",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.0.1",
"changes": [
diff --git a/packages/sol-doc/CHANGELOG.md b/packages/sol-doc/CHANGELOG.md
index 9ff92821e..9f16fb108 100644
--- a/packages/sol-doc/CHANGELOG.md
+++ b/packages/sol-doc/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.0.2 - _October 2, 2018_
+
+ * Dependencies updated
+
## v1.0.1 - _September 28, 2018_
* Dependencies updated
diff --git a/packages/sol-doc/package.json b/packages/sol-doc/package.json
index 2f8525ff4..0b0c7c963 100644
--- a/packages/sol-doc/package.json
+++ b/packages/sol-doc/package.json
@@ -6,6 +6,7 @@
"types": "lib/src/index.d.js",
"scripts": {
"build": "tsc",
+ "build:ci": "yarn build",
"test": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --timeout 6000 --exit",
"test:circleci": "yarn test:coverage",
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
@@ -13,7 +14,7 @@
"lint": "tslint --project . --format stylish",
"clean": "shx rm -rf lib",
"generate-v1-protocol-docs": "(cd ../contracts/src/1.0.0; node ../../../../node_modules/.bin/sol-doc --contracts-dir . --contracts Exchange/Exchange_v1.sol TokenRegistry/TokenRegistry.sol TokenTransferProxy/TokenTransferProxy_v1.sol) > v1.0.0.json",
- "generate-v2-protocol-docs": "(cd ../contracts/src/2.0.0; node ../../../../node_modules/.bin/sol-doc --contracts-dir . --contracts $(cd protocol; ls -C1 */*.sol */interfaces/*.sol) ) > v2.0.0.json",
+ "generate-v2-protocol-docs": "(cd ../contracts/src/2.0.0; node ../../../../node_modules/.bin/sol-doc --contracts-dir . --contracts Exchange/Exchange.sol AssetProxy/ERC20Proxy.sol AssetProxy/ERC721Proxy.sol OrderValidator/OrderValidator.sol Forwarder/Forwarder.sol AssetProxyOwner/AssetProxyOwner.sol) > v2.0.0.json",
"deploy-v2-protocol-docs": "aws --profile 0xproject s3 cp --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json v2.0.0.json s3://staging-doc-jsons/contracts/",
"deploy-v1-protocol-docs": "aws --profile 0xproject s3 cp --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json v1.0.0.json s3://staging-doc-jsons/contracts/"
},
@@ -28,6 +29,7 @@
"@0xproject/types": "^1.1.2",
"@0xproject/utils": "^2.0.0",
"ethereum-types": "^1.0.9",
+ "ethereumjs-util": "^5.1.1",
"lodash": "^4.17.10",
"yargs": "^12.0.2"
},
diff --git a/packages/sol-doc/src/cli.ts b/packages/sol-doc/src/cli.ts
index eb0f00bf6..a1847e868 100644
--- a/packages/sol-doc/src/cli.ts
+++ b/packages/sol-doc/src/cli.ts
@@ -3,7 +3,7 @@ import * as yargs from 'yargs';
import { logUtils } from '@0xproject/utils';
-import { generateSolDocAsync } from './solidity_doc_generator';
+import { SolDoc } from './sol_doc';
const JSON_TAB_WIDTH = 4;
@@ -20,7 +20,20 @@ const JSON_TAB_WIDTH = 4;
.demandOption('contracts-dir')
.array('contracts')
.help().argv;
- const doc = await generateSolDocAsync(argv.contractsDir, argv.contracts);
+ // Unfortunately, the only way to currently retrieve the declared structs within Solidity contracts
+ // is to tease them out of the params/return values included in the ABI. These structures do
+ // not include the structs actual name, so we need a mapping to assign the proper name to a
+ // struct. If the name is not in this mapping, the structs name will default to the param/return value
+ // name (which mostly coincide).
+ const customTypeHashToName: { [hash: string]: string } = {
+ '52d4a768701076c7bac06e386e430883975eb398732eccba797fd09dd064a60e': 'Order',
+ '46f7e8c4d144d11a72ce5338458ea37b933500d7a65e740cbca6d16e350eaa48': 'FillResults',
+ c22239cf0d29df1e6cf1be54f21692a8c0b3a48b9367540d4ffff4608b331ce9: 'OrderInfo',
+ c21e9ff31a30941c22e1cb43752114bb467c34dea58947f98966c9030fc8e4a9: 'TraderInfo',
+ '6de3264a1040e027d4bdd29c71e963028238ac4ef060541078a7aced44a4d46f': 'MatchedFillResults',
+ };
+ const solDoc = new SolDoc();
+ const doc = await solDoc.generateSolDocAsync(argv.contractsDir, argv.contracts, customTypeHashToName);
process.stdout.write(JSON.stringify(doc, null, JSON_TAB_WIDTH));
})().catch(err => {
logUtils.warn(err);
diff --git a/packages/sol-doc/src/index.ts b/packages/sol-doc/src/index.ts
index 03f3c9de6..521668cc8 100644
--- a/packages/sol-doc/src/index.ts
+++ b/packages/sol-doc/src/index.ts
@@ -1 +1 @@
-export { generateSolDocAsync } from './solidity_doc_generator';
+export { SolDoc } from './sol_doc';
diff --git a/packages/sol-doc/src/sol_doc.ts b/packages/sol-doc/src/sol_doc.ts
new file mode 100644
index 000000000..138882c92
--- /dev/null
+++ b/packages/sol-doc/src/sol_doc.ts
@@ -0,0 +1,500 @@
+import * as path from 'path';
+
+import {
+ AbiDefinition,
+ ConstructorAbi,
+ DataItem,
+ DevdocOutput,
+ EventAbi,
+ EventParameter,
+ FallbackAbi,
+ MethodAbi,
+ StandardContractOutput,
+} from 'ethereum-types';
+import ethUtil = require('ethereumjs-util');
+import * as _ from 'lodash';
+
+import { Compiler, CompilerOptions } from '@0xproject/sol-compiler';
+import {
+ CustomType,
+ CustomTypeChild,
+ DocAgnosticFormat,
+ DocSection,
+ Event,
+ EventArg,
+ ObjectMap,
+ Parameter,
+ SolidityMethod,
+ Type,
+ TypeDocTypes,
+} from '@0xproject/types';
+
+export class SolDoc {
+ private _customTypeHashToName: ObjectMap<string> | undefined;
+ private static _genEventDoc(abiDefinition: EventAbi): Event {
+ const eventDoc: Event = {
+ name: abiDefinition.name,
+ eventArgs: SolDoc._genEventArgsDoc(abiDefinition.inputs),
+ };
+ return eventDoc;
+ }
+ private static _devdocMethodDetailsIfExist(
+ methodSignature: string,
+ devdocIfExists: DevdocOutput | undefined,
+ ): string | undefined {
+ let details;
+ if (!_.isUndefined(devdocIfExists)) {
+ const devdocMethodsIfExist = devdocIfExists.methods;
+ if (!_.isUndefined(devdocMethodsIfExist)) {
+ const devdocMethodIfExists = devdocMethodsIfExist[methodSignature];
+ if (!_.isUndefined(devdocMethodIfExists)) {
+ const devdocMethodDetailsIfExist = devdocMethodIfExists.details;
+ if (!_.isUndefined(devdocMethodDetailsIfExist)) {
+ details = devdocMethodDetailsIfExist;
+ }
+ }
+ }
+ }
+ return details;
+ }
+ private static _genFallbackDoc(
+ abiDefinition: FallbackAbi,
+ devdocIfExists: DevdocOutput | undefined,
+ ): SolidityMethod {
+ const methodSignature = `()`;
+ const comment = SolDoc._devdocMethodDetailsIfExist(methodSignature, devdocIfExists);
+
+ const returnComment =
+ _.isUndefined(devdocIfExists) || _.isUndefined(devdocIfExists.methods[methodSignature])
+ ? undefined
+ : devdocIfExists.methods[methodSignature].return;
+
+ const methodDoc: SolidityMethod = {
+ isConstructor: false,
+ name: 'fallback',
+ callPath: '',
+ parameters: [],
+ returnType: { name: 'void', typeDocType: TypeDocTypes.Intrinsic },
+ returnComment,
+ isConstant: true,
+ isPayable: abiDefinition.payable,
+ isFallback: true,
+ comment: _.isEmpty(comment)
+ ? 'The fallback function. It is executed on a call to the contract if none of the other functions match the given public identifier (or if no data was supplied at all).'
+ : comment,
+ };
+ return methodDoc;
+ }
+ private static _genEventArgsDoc(args: EventParameter[]): EventArg[] {
+ const eventArgsDoc: EventArg[] = [];
+
+ for (const arg of args) {
+ const name = arg.name;
+
+ const type: Type = {
+ name: arg.type,
+ typeDocType: TypeDocTypes.Intrinsic,
+ };
+
+ const eventArgDoc: EventArg = {
+ isIndexed: arg.indexed,
+ name,
+ type,
+ };
+
+ eventArgsDoc.push(eventArgDoc);
+ }
+ return eventArgsDoc;
+ }
+ private static _dedupStructs(customTypes: CustomType[]): CustomType[] {
+ const uniqueCustomTypes: CustomType[] = [];
+ const seenTypes: { [hash: string]: boolean } = {};
+ _.each(customTypes, customType => {
+ const hash = SolDoc._generateCustomTypeHash(customType);
+ if (!seenTypes[hash]) {
+ uniqueCustomTypes.push(customType);
+ seenTypes[hash] = true;
+ }
+ });
+ return uniqueCustomTypes;
+ }
+ private static _capitalize(text: string): string {
+ return `${text.charAt(0).toUpperCase()}${text.slice(1)}`;
+ }
+ private static _generateCustomTypeHash(customType: CustomType): string {
+ const customTypeWithoutName = _.cloneDeep(customType);
+ delete customTypeWithoutName.name;
+ const customTypeWithoutNameStr = JSON.stringify(customTypeWithoutName);
+ const hash = ethUtil.sha256(customTypeWithoutNameStr).toString('hex');
+ return hash;
+ }
+ private static _makeCompilerOptions(contractsDir: string, contractsToCompile?: string[]): CompilerOptions {
+ const compilerOptions: CompilerOptions = {
+ contractsDir,
+ contracts: '*',
+ compilerSettings: {
+ outputSelection: {
+ ['*']: {
+ ['*']: ['abi', 'devdoc'],
+ },
+ },
+ },
+ };
+
+ const shouldOverrideCatchAllContractsConfig =
+ !_.isUndefined(contractsToCompile) && contractsToCompile.length > 0;
+ if (shouldOverrideCatchAllContractsConfig) {
+ compilerOptions.contracts = contractsToCompile;
+ }
+
+ return compilerOptions;
+ }
+ /**
+ * Invoke the Solidity compiler and transform its ABI and devdoc outputs into a
+ * JSON format easily consumed by documentation rendering tools.
+ * @param contractsToDocument list of contracts for which to generate doc objects
+ * @param contractsDir the directory in which to find the `contractsToCompile` as well as their dependencies.
+ * @return doc object for use with documentation generation tools.
+ */
+ public async generateSolDocAsync(
+ contractsDir: string,
+ contractsToDocument?: string[],
+ customTypeHashToName?: ObjectMap<string>,
+ ): Promise<DocAgnosticFormat> {
+ this._customTypeHashToName = customTypeHashToName;
+ const docWithDependencies: DocAgnosticFormat = {};
+ const compilerOptions = SolDoc._makeCompilerOptions(contractsDir, contractsToDocument);
+ const compiler = new Compiler(compilerOptions);
+ const compilerOutputs = await compiler.getCompilerOutputsAsync();
+ let structs: CustomType[] = [];
+ for (const compilerOutput of compilerOutputs) {
+ const contractFileNames = _.keys(compilerOutput.contracts);
+ for (const contractFileName of contractFileNames) {
+ const contractNameToOutput = compilerOutput.contracts[contractFileName];
+
+ const contractNames = _.keys(contractNameToOutput);
+ for (const contractName of contractNames) {
+ const compiledContract = contractNameToOutput[contractName];
+ if (_.isUndefined(compiledContract.abi)) {
+ throw new Error('compiled contract did not contain ABI output');
+ }
+ docWithDependencies[contractName] = this._genDocSection(compiledContract, contractName);
+ structs = [...structs, ...this._extractStructs(compiledContract)];
+ }
+ }
+ }
+ structs = SolDoc._dedupStructs(structs);
+ structs = this._overwriteStructNames(structs);
+
+ let doc: DocAgnosticFormat = {};
+ if (_.isUndefined(contractsToDocument) || contractsToDocument.length === 0) {
+ doc = docWithDependencies;
+ } else {
+ for (const contractToDocument of contractsToDocument) {
+ const contractBasename = path.basename(contractToDocument);
+ const contractName =
+ contractBasename.lastIndexOf('.sol') === -1
+ ? contractBasename
+ : contractBasename.substring(0, contractBasename.lastIndexOf('.sol'));
+ doc[contractName] = docWithDependencies[contractName];
+ }
+ }
+
+ if (structs.length > 0) {
+ doc.structs = {
+ comment: '',
+ constructors: [],
+ methods: [],
+ properties: [],
+ types: structs,
+ functions: [],
+ events: [],
+ };
+ }
+
+ delete this._customTypeHashToName; // Clean up instance state
+ return doc;
+ }
+ private _getCustomTypeFromDataItem(inputOrOutput: DataItem): CustomType {
+ const customType: CustomType = {
+ name: _.capitalize(inputOrOutput.name),
+ kindString: 'Interface',
+ children: [],
+ };
+ _.each(inputOrOutput.components, (component: DataItem) => {
+ const childType = this._getTypeFromDataItem(component);
+ const customTypeChild = {
+ name: component.name,
+ type: childType,
+ };
+ // (fabio): Not sure why this type casting is necessary. Seems TS doesn't
+ // deduce that `customType.children` cannot be undefined anymore after being
+ // set to `[]` above.
+ (customType.children as CustomTypeChild[]).push(customTypeChild);
+ });
+ return customType;
+ }
+ private _getNameFromDataItemIfExists(dataItem: DataItem): string | undefined {
+ if (_.isUndefined(dataItem.components)) {
+ return undefined;
+ }
+ const customType = this._getCustomTypeFromDataItem(dataItem);
+ const hash = SolDoc._generateCustomTypeHash(customType);
+ if (_.isUndefined(this._customTypeHashToName) || _.isUndefined(this._customTypeHashToName[hash])) {
+ return undefined;
+ }
+ return this._customTypeHashToName[hash];
+ }
+ private _getTypeFromDataItem(dataItem: DataItem): Type {
+ const typeDocType = !_.isUndefined(dataItem.components) ? TypeDocTypes.Reference : TypeDocTypes.Intrinsic;
+ let typeName: string;
+ if (typeDocType === TypeDocTypes.Reference) {
+ const nameIfExists = this._getNameFromDataItemIfExists(dataItem);
+ typeName = _.isUndefined(nameIfExists) ? SolDoc._capitalize(dataItem.name) : nameIfExists;
+ } else {
+ typeName = dataItem.type;
+ }
+
+ const isArrayType = _.endsWith(dataItem.type, '[]');
+ let type: Type;
+ if (isArrayType) {
+ // tslint:disable-next-line:custom-no-magic-numbers
+ typeName = typeDocType === TypeDocTypes.Intrinsic ? typeName.slice(0, -2) : typeName;
+ type = {
+ elementType: { name: typeName, typeDocType },
+ typeDocType: TypeDocTypes.Array,
+ name: '',
+ };
+ } else {
+ type = { name: typeName, typeDocType };
+ }
+ return type;
+ }
+ private _overwriteStructNames(customTypes: CustomType[]): CustomType[] {
+ if (_.isUndefined(this._customTypeHashToName)) {
+ return customTypes;
+ }
+ const localCustomTypes = _.cloneDeep(customTypes);
+ _.each(localCustomTypes, (customType, i) => {
+ const hash = SolDoc._generateCustomTypeHash(customType);
+ if (!_.isUndefined(this._customTypeHashToName) && !_.isUndefined(this._customTypeHashToName[hash])) {
+ localCustomTypes[i].name = this._customTypeHashToName[hash];
+ }
+ });
+ return localCustomTypes;
+ }
+ private _extractStructs(compiledContract: StandardContractOutput): CustomType[] {
+ let customTypes: CustomType[] = [];
+ for (const abiDefinition of compiledContract.abi) {
+ let types: CustomType[] = [];
+ switch (abiDefinition.type) {
+ case 'constructor': {
+ types = this._getStructsAsCustomTypes(abiDefinition);
+ break;
+ }
+ case 'function': {
+ types = this._getStructsAsCustomTypes(abiDefinition);
+ break;
+ }
+ case 'event':
+ case 'fallback':
+ // No types exist
+ break;
+ default:
+ throw new Error(
+ `unknown and unsupported AbiDefinition type '${(abiDefinition as AbiDefinition).type}'`, // tslint:disable-line:no-unnecessary-type-assertion
+ );
+ }
+ customTypes = [...customTypes, ...types];
+ }
+ return customTypes;
+ }
+ private _genDocSection(compiledContract: StandardContractOutput, contractName: string): DocSection {
+ const docSection: DocSection = {
+ comment: _.isUndefined(compiledContract.devdoc) ? '' : compiledContract.devdoc.title,
+ constructors: [],
+ methods: [],
+ properties: [],
+ types: [],
+ functions: [],
+ events: [],
+ };
+
+ for (const abiDefinition of compiledContract.abi) {
+ switch (abiDefinition.type) {
+ case 'constructor':
+ docSection.constructors.push(
+ this._genConstructorDoc(contractName, abiDefinition, compiledContract.devdoc),
+ );
+ break;
+ case 'event':
+ (docSection.events as Event[]).push(SolDoc._genEventDoc(abiDefinition));
+ // note that we're not sending devdoc to this._genEventDoc().
+ // that's because the type of the events array doesn't have any fields for documentation!
+ break;
+ case 'function':
+ docSection.methods.push(this._genMethodDoc(abiDefinition, compiledContract.devdoc));
+ break;
+ case 'fallback':
+ docSection.methods.push(SolDoc._genFallbackDoc(abiDefinition, compiledContract.devdoc));
+ break;
+ default:
+ throw new Error(
+ `unknown and unsupported AbiDefinition type '${(abiDefinition as AbiDefinition).type}'`, // tslint:disable-line:no-unnecessary-type-assertion
+ );
+ }
+ }
+
+ return docSection;
+ }
+ private _genConstructorDoc(
+ contractName: string,
+ abiDefinition: ConstructorAbi,
+ devdocIfExists: DevdocOutput | undefined,
+ ): SolidityMethod {
+ const { parameters, methodSignature } = this._genMethodParamsDoc('', abiDefinition.inputs, devdocIfExists);
+
+ const comment = SolDoc._devdocMethodDetailsIfExist(methodSignature, devdocIfExists);
+
+ const constructorDoc: SolidityMethod = {
+ isConstructor: true,
+ name: contractName,
+ callPath: '',
+ parameters,
+ returnType: { name: contractName, typeDocType: TypeDocTypes.Reference }, // sad we have to specify this
+ isConstant: false,
+ isPayable: abiDefinition.payable,
+ comment,
+ };
+
+ return constructorDoc;
+ }
+ private _genMethodDoc(abiDefinition: MethodAbi, devdocIfExists: DevdocOutput | undefined): SolidityMethod {
+ const name = abiDefinition.name;
+ const { parameters, methodSignature } = this._genMethodParamsDoc(name, abiDefinition.inputs, devdocIfExists);
+ const devDocComment = SolDoc._devdocMethodDetailsIfExist(methodSignature, devdocIfExists);
+ const returnType = this._genMethodReturnTypeDoc(abiDefinition.outputs);
+ const returnComment =
+ _.isUndefined(devdocIfExists) || _.isUndefined(devdocIfExists.methods[methodSignature])
+ ? undefined
+ : devdocIfExists.methods[methodSignature].return;
+
+ const hasNoNamedParameters = _.isUndefined(_.find(parameters, p => !_.isEmpty(p.name)));
+ const isGeneratedGetter = hasNoNamedParameters;
+ const comment =
+ _.isEmpty(devDocComment) && isGeneratedGetter
+ ? `This is an auto-generated accessor method of the '${name}' contract instance variable.`
+ : devDocComment;
+ const methodDoc: SolidityMethod = {
+ isConstructor: false,
+ name,
+ callPath: '',
+ parameters,
+ returnType,
+ returnComment,
+ isConstant: abiDefinition.constant,
+ isPayable: abiDefinition.payable,
+ comment,
+ };
+ return methodDoc;
+ }
+ /**
+ * Extract documentation for each method parameter from @param params.
+ */
+ private _genMethodParamsDoc(
+ name: string,
+ abiParams: DataItem[],
+ devdocIfExists: DevdocOutput | undefined,
+ ): { parameters: Parameter[]; methodSignature: string } {
+ const parameters: Parameter[] = [];
+ for (const abiParam of abiParams) {
+ const type = this._getTypeFromDataItem(abiParam);
+
+ const parameter: Parameter = {
+ name: abiParam.name,
+ comment: '<No comment>',
+ isOptional: false, // Unsupported in Solidity, until resolution of https://github.com/ethereum/solidity/issues/232
+ type,
+ };
+ parameters.push(parameter);
+ }
+
+ const methodSignature = `${name}(${abiParams
+ .map(abiParam => {
+ if (!_.startsWith(abiParam.type, 'tuple')) {
+ return abiParam.type;
+ } else {
+ // Need to expand tuples:
+ // E.g: fillOrder(tuple,uint256,bytes) -> fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)
+ const isArray = _.endsWith(abiParam.type, '[]');
+ const expandedTypes = _.map(abiParam.components, c => c.type);
+ const type = `(${expandedTypes.join(',')})${isArray ? '[]' : ''}`;
+ return type;
+ }
+ })
+ .join(',')})`;
+
+ if (!_.isUndefined(devdocIfExists)) {
+ const devdocMethodIfExists = devdocIfExists.methods[methodSignature];
+ if (!_.isUndefined(devdocMethodIfExists)) {
+ const devdocParamsIfExist = devdocMethodIfExists.params;
+ if (!_.isUndefined(devdocParamsIfExist)) {
+ for (const parameter of parameters) {
+ parameter.comment = devdocParamsIfExist[parameter.name];
+ }
+ }
+ }
+ }
+
+ return { parameters, methodSignature };
+ }
+ private _genMethodReturnTypeDoc(outputs: DataItem[]): Type {
+ let type: Type;
+ if (outputs.length > 1) {
+ type = {
+ name: '',
+ typeDocType: TypeDocTypes.Tuple,
+ tupleElements: [],
+ };
+ for (const output of outputs) {
+ const tupleType = this._getTypeFromDataItem(output);
+ (type.tupleElements as Type[]).push(tupleType);
+ }
+ return type;
+ } else if (outputs.length === 1) {
+ const output = outputs[0];
+ type = this._getTypeFromDataItem(output);
+ } else {
+ type = {
+ name: 'void',
+ typeDocType: TypeDocTypes.Intrinsic,
+ };
+ }
+ return type;
+ }
+ private _getStructsAsCustomTypes(abiDefinition: AbiDefinition): CustomType[] {
+ const customTypes: CustomType[] = [];
+ // We cast to `any` here because we do not know yet if this type of abiDefinition contains
+ // an `input` key
+ if (!_.isUndefined((abiDefinition as any).inputs)) {
+ const methodOrConstructorAbi = abiDefinition as MethodAbi | ConstructorAbi;
+ _.each(methodOrConstructorAbi.inputs, input => {
+ if (!_.isUndefined(input.components)) {
+ const customType = this._getCustomTypeFromDataItem(input);
+ customTypes.push(customType);
+ }
+ });
+ }
+ if (!_.isUndefined((abiDefinition as any).outputs)) {
+ const methodAbi = abiDefinition as MethodAbi; // tslint:disable-line:no-unnecessary-type-assertion
+ _.each(methodAbi.outputs, output => {
+ if (!_.isUndefined(output.components)) {
+ const customType = this._getCustomTypeFromDataItem(output);
+ customTypes.push(customType);
+ }
+ });
+ }
+ return customTypes;
+ }
+}
+// tslint:disable:max-file-line-count
diff --git a/packages/sol-doc/src/solidity_doc_generator.ts b/packages/sol-doc/src/solidity_doc_generator.ts
deleted file mode 100644
index 5ddf001a6..000000000
--- a/packages/sol-doc/src/solidity_doc_generator.ts
+++ /dev/null
@@ -1,306 +0,0 @@
-import * as path from 'path';
-
-import * as _ from 'lodash';
-
-import {
- AbiDefinition,
- ConstructorAbi,
- DataItem,
- DevdocOutput,
- EventAbi,
- EventParameter,
- FallbackAbi,
- MethodAbi,
- StandardContractOutput,
-} from 'ethereum-types';
-
-import { Compiler, CompilerOptions } from '@0xproject/sol-compiler';
-import {
- DocAgnosticFormat,
- DocSection,
- Event,
- EventArg,
- Parameter,
- SolidityMethod,
- Type,
- TypeDocTypes,
-} from '@0xproject/types';
-
-/**
- * Invoke the Solidity compiler and transform its ABI and devdoc outputs into a
- * JSON format easily consumed by documentation rendering tools.
- * @param contractsToDocument list of contracts for which to generate doc objects
- * @param contractsDir the directory in which to find the `contractsToCompile` as well as their dependencies.
- * @return doc object for use with documentation generation tools.
- */
-export async function generateSolDocAsync(
- contractsDir: string,
- contractsToDocument?: string[],
-): Promise<DocAgnosticFormat> {
- const docWithDependencies: DocAgnosticFormat = {};
- const compilerOptions = _makeCompilerOptions(contractsDir, contractsToDocument);
- const compiler = new Compiler(compilerOptions);
- const compilerOutputs = await compiler.getCompilerOutputsAsync();
- for (const compilerOutput of compilerOutputs) {
- const contractFileNames = _.keys(compilerOutput.contracts);
- for (const contractFileName of contractFileNames) {
- const contractNameToOutput = compilerOutput.contracts[contractFileName];
-
- const contractNames = _.keys(contractNameToOutput);
- for (const contractName of contractNames) {
- const compiledContract = contractNameToOutput[contractName];
- if (_.isUndefined(compiledContract.abi)) {
- throw new Error('compiled contract did not contain ABI output');
- }
- docWithDependencies[contractName] = _genDocSection(compiledContract, contractName);
- }
- }
- }
-
- let doc: DocAgnosticFormat = {};
- if (_.isUndefined(contractsToDocument) || contractsToDocument.length === 0) {
- doc = docWithDependencies;
- } else {
- for (const contractToDocument of contractsToDocument) {
- const contractBasename = path.basename(contractToDocument);
- const contractName =
- contractBasename.lastIndexOf('.sol') === -1
- ? contractBasename
- : contractBasename.substring(0, contractBasename.lastIndexOf('.sol'));
- doc[contractName] = docWithDependencies[contractName];
- }
- }
-
- return doc;
-}
-
-function _makeCompilerOptions(contractsDir: string, contractsToCompile?: string[]): CompilerOptions {
- const compilerOptions: CompilerOptions = {
- contractsDir,
- contracts: '*',
- compilerSettings: {
- outputSelection: {
- ['*']: {
- ['*']: ['abi', 'devdoc'],
- },
- },
- },
- };
-
- const shouldOverrideCatchAllContractsConfig = !_.isUndefined(contractsToCompile) && contractsToCompile.length > 0;
- if (shouldOverrideCatchAllContractsConfig) {
- compilerOptions.contracts = contractsToCompile;
- }
-
- return compilerOptions;
-}
-
-function _genDocSection(compiledContract: StandardContractOutput, contractName: string): DocSection {
- const docSection: DocSection = {
- comment: _.isUndefined(compiledContract.devdoc) ? '' : compiledContract.devdoc.title,
- constructors: [],
- methods: [],
- properties: [],
- types: [],
- functions: [],
- events: [],
- };
-
- for (const abiDefinition of compiledContract.abi) {
- switch (abiDefinition.type) {
- case 'constructor':
- docSection.constructors.push(_genConstructorDoc(contractName, abiDefinition, compiledContract.devdoc));
- break;
- case 'event':
- (docSection.events as Event[]).push(_genEventDoc(abiDefinition));
- // note that we're not sending devdoc to _genEventDoc().
- // that's because the type of the events array doesn't have any fields for documentation!
- break;
- case 'function':
- case 'fallback':
- docSection.methods.push(_genMethodDoc(abiDefinition, compiledContract.devdoc));
- break;
- default:
- throw new Error(
- `unknown and unsupported AbiDefinition type '${(abiDefinition as AbiDefinition).type}'`,
- );
- }
- }
-
- return docSection;
-}
-
-function _genConstructorDoc(
- contractName: string,
- abiDefinition: ConstructorAbi,
- devdocIfExists: DevdocOutput | undefined,
-): SolidityMethod {
- const { parameters, methodSignature } = _genMethodParamsDoc('', abiDefinition.inputs, devdocIfExists);
-
- const comment = _devdocMethodDetailsIfExist(methodSignature, devdocIfExists);
-
- const constructorDoc: SolidityMethod = {
- isConstructor: true,
- name: contractName,
- callPath: '',
- parameters,
- returnType: { name: contractName, typeDocType: TypeDocTypes.Reference }, // sad we have to specify this
- isConstant: false,
- isPayable: abiDefinition.payable,
- comment,
- };
-
- return constructorDoc;
-}
-
-function _devdocMethodDetailsIfExist(
- methodSignature: string,
- devdocIfExists: DevdocOutput | undefined,
-): string | undefined {
- let details;
- if (!_.isUndefined(devdocIfExists)) {
- const devdocMethodsIfExist = devdocIfExists.methods;
- if (!_.isUndefined(devdocMethodsIfExist)) {
- const devdocMethodIfExists = devdocMethodsIfExist[methodSignature];
- if (!_.isUndefined(devdocMethodIfExists)) {
- const devdocMethodDetailsIfExist = devdocMethodIfExists.details;
- if (!_.isUndefined(devdocMethodDetailsIfExist)) {
- details = devdocMethodDetailsIfExist;
- }
- }
- }
- }
- return details;
-}
-
-function _genMethodDoc(
- abiDefinition: MethodAbi | FallbackAbi,
- devdocIfExists: DevdocOutput | undefined,
-): SolidityMethod {
- const name = abiDefinition.type === 'fallback' ? '' : abiDefinition.name;
-
- const { parameters, methodSignature } =
- abiDefinition.type === 'fallback'
- ? { parameters: [], methodSignature: `${name}()` }
- : _genMethodParamsDoc(name, abiDefinition.inputs, devdocIfExists);
-
- const comment = _devdocMethodDetailsIfExist(methodSignature, devdocIfExists);
-
- const returnType =
- abiDefinition.type === 'fallback'
- ? { name: '', typeDocType: TypeDocTypes.Intrinsic }
- : _genMethodReturnTypeDoc(abiDefinition.outputs, methodSignature, devdocIfExists);
-
- const returnComment =
- _.isUndefined(devdocIfExists) || _.isUndefined(devdocIfExists.methods[methodSignature])
- ? undefined
- : devdocIfExists.methods[methodSignature].return;
-
- const isConstant = abiDefinition.type === 'fallback' ? true : abiDefinition.constant;
-
- const methodDoc: SolidityMethod = {
- isConstructor: false,
- name,
- callPath: '',
- parameters,
- returnType,
- returnComment,
- isConstant,
- isPayable: abiDefinition.payable,
- comment,
- };
- return methodDoc;
-}
-
-function _genEventDoc(abiDefinition: EventAbi): Event {
- const eventDoc: Event = {
- name: abiDefinition.name,
- eventArgs: _genEventArgsDoc(abiDefinition.inputs, undefined),
- };
- return eventDoc;
-}
-
-function _genEventArgsDoc(args: EventParameter[], devdocIfExists: DevdocOutput | undefined): EventArg[] {
- const eventArgsDoc: EventArg[] = [];
-
- for (const arg of args) {
- const name = arg.name;
-
- const type: Type = {
- name: arg.type,
- typeDocType: TypeDocTypes.Intrinsic,
- };
-
- const eventArgDoc: EventArg = {
- isIndexed: arg.indexed,
- name,
- type,
- };
-
- eventArgsDoc.push(eventArgDoc);
- }
- return eventArgsDoc;
-}
-
-/**
- * Extract documentation for each method parameter from @param params.
- */
-function _genMethodParamsDoc(
- name: string,
- abiParams: DataItem[],
- devdocIfExists: DevdocOutput | undefined,
-): { parameters: Parameter[]; methodSignature: string } {
- const parameters: Parameter[] = [];
- for (const abiParam of abiParams) {
- const parameter: Parameter = {
- name: abiParam.name,
- comment: '',
- isOptional: false, // Unsupported in Solidity, until resolution of https://github.com/ethereum/solidity/issues/232
- type: { name: abiParam.type, typeDocType: TypeDocTypes.Intrinsic },
- };
- parameters.push(parameter);
- }
-
- const methodSignature = `${name}(${abiParams
- .map(abiParam => {
- return abiParam.type;
- })
- .join(',')})`;
-
- if (!_.isUndefined(devdocIfExists)) {
- const devdocMethodIfExists = devdocIfExists.methods[methodSignature];
- if (!_.isUndefined(devdocMethodIfExists)) {
- const devdocParamsIfExist = devdocMethodIfExists.params;
- if (!_.isUndefined(devdocParamsIfExist)) {
- for (const parameter of parameters) {
- parameter.comment = devdocParamsIfExist[parameter.name];
- }
- }
- }
- }
-
- return { parameters, methodSignature };
-}
-
-function _genMethodReturnTypeDoc(
- outputs: DataItem[],
- methodSignature: string,
- devdocIfExists: DevdocOutput | undefined,
-): Type {
- const methodReturnTypeDoc: Type = {
- name: '',
- typeDocType: TypeDocTypes.Intrinsic,
- tupleElements: undefined,
- };
- if (outputs.length > 1) {
- methodReturnTypeDoc.typeDocType = TypeDocTypes.Tuple;
- methodReturnTypeDoc.tupleElements = [];
- for (const output of outputs) {
- methodReturnTypeDoc.tupleElements.push({ name: output.type, typeDocType: TypeDocTypes.Intrinsic });
- }
- } else if (outputs.length === 1) {
- methodReturnTypeDoc.typeDocType = TypeDocTypes.Intrinsic;
- methodReturnTypeDoc.name = outputs[0].type;
- }
- return methodReturnTypeDoc;
-}
diff --git a/packages/sol-doc/test/fixtures/contracts/StructParamAndReturn.sol b/packages/sol-doc/test/fixtures/contracts/StructParamAndReturn.sol
new file mode 100644
index 000000000..b9a7ccdbc
--- /dev/null
+++ b/packages/sol-doc/test/fixtures/contracts/StructParamAndReturn.sol
@@ -0,0 +1,18 @@
+pragma solidity 0.4.24;
+pragma experimental ABIEncoderV2;
+
+
+contract StructParamAndReturn {
+
+ struct Stuff {
+ address anAddress;
+ uint256 aNumber;
+ }
+
+ /// @dev DEV_COMMENT
+ /// @param stuff STUFF_COMMENT
+ /// @return RETURN_COMMENT
+ function methodWithStructParamAndReturn(Stuff stuff) public pure returns(Stuff) {
+ return stuff;
+ }
+}
diff --git a/packages/sol-doc/test/solidity_doc_generator_test.ts b/packages/sol-doc/test/solidity_doc_generator_test.ts
index c780d3d31..f166fb143 100644
--- a/packages/sol-doc/test/solidity_doc_generator_test.ts
+++ b/packages/sol-doc/test/solidity_doc_generator_test.ts
@@ -5,16 +5,17 @@ import 'mocha';
import { DocAgnosticFormat, Event, SolidityMethod } from '@0xproject/types';
-import { generateSolDocAsync } from '../src/solidity_doc_generator';
+import { SolDoc } from '../src/sol_doc';
import { chaiSetup } from './util/chai_setup';
chaiSetup.configure();
const expect = chai.expect;
+const solDoc = new SolDoc();
describe('#SolidityDocGenerator', () => {
it('should generate a doc object that matches the devdoc-free TokenTransferProxy fixture', async () => {
- const doc = await generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, [
+ const doc = await solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, [
'TokenTransferProxyNoDevdoc',
]);
expect(doc).to.not.be.undefined();
@@ -22,8 +23,8 @@ describe('#SolidityDocGenerator', () => {
verifyTokenTransferProxyABIIsDocumented(doc, 'TokenTransferProxyNoDevdoc');
});
const docPromises: Array<Promise<DocAgnosticFormat>> = [
- generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`),
- generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, []),
+ solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`),
+ solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, []),
];
docPromises.forEach(docPromise => {
it('should generate a doc object that matches the TokenTransferProxy fixture with its dependencies', async () => {
@@ -48,7 +49,7 @@ describe('#SolidityDocGenerator', () => {
});
});
it('should generate a doc object that matches the TokenTransferProxy fixture', async () => {
- const doc: DocAgnosticFormat = await generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, [
+ const doc: DocAgnosticFormat = await solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, [
'TokenTransferProxy',
]);
verifyTokenTransferProxyABIIsDocumented(doc, 'TokenTransferProxy');
@@ -56,7 +57,7 @@ describe('#SolidityDocGenerator', () => {
describe('when processing all the permutations of devdoc stuff that we use in our contracts', () => {
let doc: DocAgnosticFormat;
before(async () => {
- doc = await generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, ['NatspecEverything']);
+ doc = await solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, ['NatspecEverything']);
expect(doc).to.not.be.undefined();
expect(doc.NatspecEverything).to.not.be.undefined();
});
@@ -159,7 +160,9 @@ describe('#SolidityDocGenerator', () => {
});
});
it('should document a method that returns multiple values', async () => {
- const doc = await generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, ['MultipleReturnValues']);
+ const doc = await solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, [
+ 'MultipleReturnValues',
+ ]);
expect(doc.MultipleReturnValues).to.not.be.undefined();
expect(doc.MultipleReturnValues.methods).to.not.be.undefined();
let methodWithMultipleReturnValues: SolidityMethod | undefined;
@@ -178,6 +181,39 @@ describe('#SolidityDocGenerator', () => {
}
expect(returnType.tupleElements.length).to.equal(2);
});
+ it('should document a method that has a struct param and return value', async () => {
+ const doc = await solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, [
+ 'StructParamAndReturn',
+ ]);
+ expect(doc.StructParamAndReturn).to.not.be.undefined();
+ expect(doc.StructParamAndReturn.methods).to.not.be.undefined();
+ let methodWithStructParamAndReturn: SolidityMethod | undefined;
+ for (const method of doc.StructParamAndReturn.methods) {
+ if (method.name === 'methodWithStructParamAndReturn') {
+ methodWithStructParamAndReturn = method;
+ }
+ }
+ if (_.isUndefined(methodWithStructParamAndReturn)) {
+ throw new Error('method should not be undefined');
+ }
+ /**
+ * Solc maps devDoc comments to methods using a method signature. If we incorrectly
+ * generate the methodSignatures, the devDoc comments won't be correctly associated
+ * with their methods and they won't show up in the output. By checking that the comments
+ * are included for a method with structs as params/returns, we are sure that the methodSignature
+ * generation is correct for this case.
+ */
+ expect(methodWithStructParamAndReturn.comment).to.be.equal('DEV_COMMENT');
+ expect(methodWithStructParamAndReturn.returnComment).to.be.equal('RETURN_COMMENT');
+ expect(methodWithStructParamAndReturn.parameters[0].comment).to.be.equal('STUFF_COMMENT');
+ });
+ it('should document the structs included in a contract', async () => {
+ const doc = await solDoc.generateSolDocAsync(`${__dirname}/../../test/fixtures/contracts`, [
+ 'StructParamAndReturn',
+ ]);
+ expect(doc.structs).to.not.be.undefined();
+ expect(doc.structs.types.length).to.be.equal(1);
+ });
});
function verifyTokenTransferProxyABIIsDocumented(doc: DocAgnosticFormat, contractName: string): void {
diff --git a/packages/sol-resolver/CHANGELOG.json b/packages/sol-resolver/CHANGELOG.json
index f14dcc5e0..6b0df115b 100644
--- a/packages/sol-resolver/CHANGELOG.json
+++ b/packages/sol-resolver/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.0.13",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.0.12",
"changes": [
diff --git a/packages/sol-resolver/CHANGELOG.md b/packages/sol-resolver/CHANGELOG.md
index 449089e5d..22c378c92 100644
--- a/packages/sol-resolver/CHANGELOG.md
+++ b/packages/sol-resolver/CHANGELOG.md
@@ -5,6 +5,10 @@ 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
diff --git a/packages/sol-resolver/package.json b/packages/sol-resolver/package.json
index e8bf1721b..a91abaf42 100644
--- a/packages/sol-resolver/package.json
+++ b/packages/sol-resolver/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/sol-resolver",
- "version": "1.0.12",
+ "version": "1.0.13",
"engines": {
"node": ">=6.12"
},
@@ -9,6 +9,7 @@
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc -b",
+ "build:ci": "yarn build",
"clean": "shx rm -rf lib",
"lint": "tslint --project ."
},
diff --git a/packages/sra-report/CHANGELOG.json b/packages/sra-report/CHANGELOG.json
index c1e0a3790..7b23b1889 100644
--- a/packages/sra-report/CHANGELOG.json
+++ b/packages/sra-report/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.0.13",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.0.12",
"changes": [
diff --git a/packages/sra-report/CHANGELOG.md b/packages/sra-report/CHANGELOG.md
index ab16dea43..ca2b884bd 100644
--- a/packages/sra-report/CHANGELOG.md
+++ b/packages/sra-report/CHANGELOG.md
@@ -5,6 +5,10 @@ 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
diff --git a/packages/sra-report/package.json b/packages/sra-report/package.json
index 976a74aa0..0b6f9896b 100644
--- a/packages/sra-report/package.json
+++ b/packages/sra-report/package.json
@@ -10,6 +10,7 @@
"scripts": {
"clean": "shx rm -rf lib",
"build": "tsc -b",
+ "build:ci": "yarn build",
"lint": "tslint --project .",
"test:circleci": "yarn test:coverage",
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
diff --git a/packages/sra-spec/CHANGELOG.json b/packages/sra-spec/CHANGELOG.json
index 848401163..0af03193a 100644
--- a/packages/sra-spec/CHANGELOG.json
+++ b/packages/sra-spec/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.0.6",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.0.5",
"changes": [
diff --git a/packages/sra-spec/CHANGELOG.md b/packages/sra-spec/CHANGELOG.md
index f4d76fb06..67790563e 100644
--- a/packages/sra-spec/CHANGELOG.md
+++ b/packages/sra-spec/CHANGELOG.md
@@ -5,6 +5,10 @@ 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
diff --git a/packages/sra-spec/package.json b/packages/sra-spec/package.json
index 5e39eb54a..5b4bc821e 100644
--- a/packages/sra-spec/package.json
+++ b/packages/sra-spec/package.json
@@ -18,6 +18,7 @@
"test:circleci": "yarn test:coverage",
"clean": "shx rm -rf lib",
"build": "tsc -b && yarn copy_md_files && yarn build-json",
+ "build:ci": "yarn build",
"build-json": "node ./lib/build_scripts/buildJson",
"build:watch": "chokidar 'src/**/*' -c 'yarn build' ",
"copy_md_files": "copyfiles -u 2 './src/md/**/*.md' ./lib/src/md",
diff --git a/packages/subproviders/CHANGELOG.json b/packages/subproviders/CHANGELOG.json
index 55614ba66..8ded2d2d4 100644
--- a/packages/subproviders/CHANGELOG.json
+++ b/packages/subproviders/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "2.0.7",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "2.0.6",
"changes": [
diff --git a/packages/subproviders/CHANGELOG.md b/packages/subproviders/CHANGELOG.md
index 6039a2983..ca8f767c7 100644
--- a/packages/subproviders/CHANGELOG.md
+++ b/packages/subproviders/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v2.0.7 - _October 2, 2018_
+
+ * Dependencies updated
+
## v2.0.6 - _September 28, 2018_
* Dependencies updated
diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json
index 3351dc6a1..491f079d2 100644
--- a/packages/subproviders/package.json
+++ b/packages/subproviders/package.json
@@ -9,6 +9,7 @@
"license": "Apache-2.0",
"scripts": {
"build": "tsc -b",
+ "build:ci": "yarn build",
"clean": "shx rm -rf lib generated_docs",
"lint": "tslint --project .",
"run_mocha_unit": "mocha --require source-map-support/register --require make-promises-safe lib/test/unit/**/*_test.js --timeout 10000 --bail --exit",
@@ -75,7 +76,7 @@
"tslint": "5.11.0",
"typedoc": "0.12.0",
"typescript": "3.0.1",
- "webpack": "^3.1.0"
+ "webpack": "^4.20.2"
},
"optionalDependencies": {
"@ledgerhq/hw-transport-node-hid": "^4.3.0"
diff --git a/packages/testnet-faucets/package.json b/packages/testnet-faucets/package.json
index 9f1196464..8213f896f 100644
--- a/packages/testnet-faucets/package.json
+++ b/packages/testnet-faucets/package.json
@@ -9,6 +9,7 @@
"main": "server.js",
"scripts": {
"build": "node ../../node_modules/gulp/bin/gulp.js build",
+ "build:ci": "yarn build",
"dev": "node ../../node_modules/gulp/bin/gulp.js run",
"start": "node ./server/server.js",
"lint": "tslint --project .",
@@ -35,15 +36,15 @@
"@types/body-parser": "^1.16.1",
"@types/express": "^4.0.35",
"@types/lodash": "4.14.104",
- "awesome-typescript-loader": "^3.1.3",
+ "awesome-typescript-loader": "^5.2.1",
"gulp": "^3.9.1",
"make-promises-safe": "^1.1.0",
"nodemon": "^1.11.0",
"shx": "^0.2.2",
- "source-map-loader": "^0.1.6",
+ "source-map-loader": "^0.2.4",
"tslint": "5.11.0",
"typescript": "3.0.1",
- "webpack": "^3.1.0",
+ "webpack": "^4.20.2",
"webpack-node-externals": "^1.6.0"
}
}
diff --git a/packages/tslint-config/package.json b/packages/tslint-config/package.json
index 4b0694012..91596d32a 100644
--- a/packages/tslint-config/package.json
+++ b/packages/tslint-config/package.json
@@ -8,6 +8,7 @@
"main": "tslint.json",
"scripts": {
"build": "tsc -b",
+ "build:ci": "yarn build",
"clean": "shx rm -rf lib",
"lint": "tslint --project ."
},
diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json
index 9d2010b9a..abf62c19d 100644
--- a/packages/types/CHANGELOG.json
+++ b/packages/types/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "1.1.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "1.1.2",
"changes": [
diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md
index 33c5d5e9c..a207a2c0c 100644
--- a/packages/types/CHANGELOG.md
+++ b/packages/types/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v1.1.3 - _October 2, 2018_
+
+ * Dependencies updated
+
## v1.1.2 - _September 28, 2018_
* Dependencies updated
diff --git a/packages/types/package.json b/packages/types/package.json
index 15f07c6f5..2901b067c 100644
--- a/packages/types/package.json
+++ b/packages/types/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/types",
- "version": "1.1.2",
+ "version": "1.1.3",
"engines": {
"node": ">=6.12"
},
@@ -9,6 +9,7 @@
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc -b",
+ "build:ci": "yarn build",
"clean": "shx rm -rf lib",
"lint": "tslint --project ."
},
diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts
index 5ef8b54a4..3ae0536d5 100644
--- a/packages/types/src/index.ts
+++ b/packages/types/src/index.ts
@@ -519,6 +519,7 @@ export interface TypescriptFunction extends BaseFunction {
export interface SolidityMethod extends BaseMethod {
isConstant?: boolean;
isPayable?: boolean;
+ isFallback?: boolean;
}
export interface Source {
diff --git a/packages/typescript-typings/CHANGELOG.json b/packages/typescript-typings/CHANGELOG.json
index df6fe16e7..c3ee81bde 100644
--- a/packages/typescript-typings/CHANGELOG.json
+++ b/packages/typescript-typings/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "3.0.1",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"version": "3.0.0",
"changes": [
{
diff --git a/packages/typescript-typings/CHANGELOG.md b/packages/typescript-typings/CHANGELOG.md
index 1240dbcf7..ea9e4d441 100644
--- a/packages/typescript-typings/CHANGELOG.md
+++ b/packages/typescript-typings/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v3.0.1 - _October 2, 2018_
+
+ * Dependencies updated
+
## v3.0.0 - _September 28, 2018_
* Remove types for ethers.js (#1069)
diff --git a/packages/typescript-typings/package.json b/packages/typescript-typings/package.json
index 17098efc5..07ac730ff 100644
--- a/packages/typescript-typings/package.json
+++ b/packages/typescript-typings/package.json
@@ -1,12 +1,13 @@
{
"name": "@0xproject/typescript-typings",
- "version": "3.0.0",
+ "version": "3.0.1",
"engines": {
"node": ">=6.12"
},
"description": "0x project typescript type definitions",
"scripts": {
"build": "tsc -b",
+ "build:ci": "yarn build",
"clean": "shx rm -rf lib"
},
"repository": {
diff --git a/packages/utils/CHANGELOG.json b/packages/utils/CHANGELOG.json
index a24d58b30..b666ee829 100644
--- a/packages/utils/CHANGELOG.json
+++ b/packages/utils/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "2.0.1",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"version": "2.0.0",
"changes": [
{
diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md
index 80b3bfd2d..c62e414f8 100644
--- a/packages/utils/CHANGELOG.md
+++ b/packages/utils/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v2.0.1 - _October 2, 2018_
+
+ * Dependencies updated
+
## v2.0.0 - _September 28, 2018_
* Make abi_decoder compatible with ethers ^4.0.0 (#1069)
diff --git a/packages/utils/package.json b/packages/utils/package.json
index a68a05d52..d2ed67554 100644
--- a/packages/utils/package.json
+++ b/packages/utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/utils",
- "version": "2.0.0",
+ "version": "2.0.1",
"engines": {
"node": ">=6.12"
},
@@ -9,6 +9,7 @@
"types": "lib/src/index.d.ts",
"scripts": {
"build": "tsc -b",
+ "build:ci": "yarn build",
"clean": "shx rm -rf lib",
"lint": "tslint --project .",
"test": "yarn run_mocha",
diff --git a/packages/web3-wrapper/CHANGELOG.json b/packages/web3-wrapper/CHANGELOG.json
index 444b9e175..7261dd474 100644
--- a/packages/web3-wrapper/CHANGELOG.json
+++ b/packages/web3-wrapper/CHANGELOG.json
@@ -1,5 +1,14 @@
[
{
+ "timestamp": 1538475601,
+ "version": "3.0.3",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
"timestamp": 1538157789,
"version": "3.0.2",
"changes": [
diff --git a/packages/web3-wrapper/CHANGELOG.md b/packages/web3-wrapper/CHANGELOG.md
index 5d10a3549..05e6a998b 100644
--- a/packages/web3-wrapper/CHANGELOG.md
+++ b/packages/web3-wrapper/CHANGELOG.md
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
+## v3.0.3 - _October 2, 2018_
+
+ * Dependencies updated
+
## v3.0.2 - _September 28, 2018_
* Dependencies updated
diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json
index 32e2b64cc..5b5c0ec5b 100644
--- a/packages/web3-wrapper/package.json
+++ b/packages/web3-wrapper/package.json
@@ -9,6 +9,7 @@
"types": "lib/src/index.d.ts",
"scripts": {
"build": "tsc -b",
+ "build:ci": "yarn build",
"clean": "shx rm -rf lib generated_docs",
"lint": "tslint --project .",
"test": "yarn run_mocha",
diff --git a/packages/web3-wrapper/src/utils.ts b/packages/web3-wrapper/src/utils.ts
index 01605dc9a..0b568aac5 100644
--- a/packages/web3-wrapper/src/utils.ts
+++ b/packages/web3-wrapper/src/utils.ts
@@ -37,7 +37,7 @@ export const utils = {
const hexBase = 16;
const valueHex = valueBigNumber.toString(hexBase);
- return valueBigNumber.lessThan(0) ? '-0x' + valueHex.substr(1) : '0x' + valueHex;
+ return valueBigNumber.lessThan(0) ? `-0x${valueHex.substr(1)}` : `0x${valueHex}`;
},
numberToHex(value: number): string {
if (!isFinite(value) && !utils.isHexStrict(value)) {
@@ -48,7 +48,7 @@ export const utils = {
const hexBase = 16;
const result = valueBigNumber.toString(hexBase);
- return valueBigNumber.lt(0) ? '-0x' + result.substr(1) : '0x' + result;
+ return valueBigNumber.lt(0) ? `-0x${result.substr(1)}` : `0x${result}`;
},
isHexStrict(hex: string | number): boolean {
return (
diff --git a/packages/website/README.md b/packages/website/README.md
index 7115a3b5c..2edc17cd9 100644
--- a/packages/website/README.md
+++ b/packages/website/README.md
@@ -14,7 +14,7 @@ Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting
## Local Dev Setup
-Requires Node version 6.9.5 or higher.
+Requires Node version 6.9.5 or higher
Add the following to your `/etc/hosts` file:
diff --git a/packages/website/package.json b/packages/website/package.json
index ab8835248..3cf243645 100644
--- a/packages/website/package.json
+++ b/packages/website/package.json
@@ -7,10 +7,11 @@
"private": true,
"description": "Website and 0x portal dapp",
"scripts": {
- "build": "NODE_ENV=production node --max_old_space_size=8192 ../../node_modules/.bin/webpack",
+ "build": "node --max_old_space_size=8192 ../../node_modules/.bin/webpack --mode production",
+ "build:dev": "../../node_modules/.bin/webpack --mode development",
"clean": "shx rm -f public/bundle*",
"lint": "tslint --project . 'ts/**/*.ts' 'ts/**/*.tsx'",
- "watch_without_deps": "webpack-dev-server --content-base public --https",
+ "dev": "webpack-dev-server --mode development --content-base public --https",
"deploy_dogfood": "npm run build; aws s3 sync ./public/. s3://dogfood.0xproject.com --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers",
"deploy_staging": "npm run build; aws s3 sync ./public/. s3://staging-0xproject --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers",
"deploy_live": "DEPLOY_ROLLBAR_SOURCEMAPS=true npm run build; aws s3 sync ./public/. s3://0xproject.com --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --exclude *.map.js"
@@ -86,26 +87,23 @@
"@types/react-tap-event-plugin": "0.0.30",
"@types/redux": "^3.6.0",
"@types/web3-provider-engine": "^14.0.0",
- "awesome-typescript-loader": "^3.1.3",
- "copy-webpack-plugin": "^4.0.1",
+ "awesome-typescript-loader": "^5.2.1",
"copyfiles": "^2.0.0",
"css-loader": "0.23.x",
- "exports-loader": "0.6.x",
- "imports-loader": "0.6.x",
- "json-loader": "^0.5.4",
- "less-loader": "^2.2.3",
+ "less-loader": "^4.1.0",
"make-promises-safe": "^1.1.0",
"raw-loader": "^0.5.1",
- "rollbar-sourcemap-webpack-plugin": "^2.3.0",
+ "rollbar-sourcemap-webpack-plugin": "^2.4.0",
"shx": "^0.2.2",
- "source-map-loader": "^0.1.6",
- "style-loader": "0.13.x",
+ "source-map-loader": "^0.2.4",
+ "style-loader": "0.23.x",
+ "terser-webpack-plugin": "^1.1.0",
"tslint": "5.11.0",
"tslint-config-0xproject": "^0.0.2",
"typescript": "3.0.1",
- "uglifyjs-webpack-plugin": "^1.2.5",
- "webpack": "^3.1.0",
- "webpack-dev-middleware": "^1.10.0",
- "webpack-dev-server": "^2.5.0"
+ "uglifyjs-webpack-plugin": "^2.0.1",
+ "webpack": "^4.20.2",
+ "webpack-cli": "3.1.2",
+ "webpack-dev-server": "^3.1.9"
}
}
diff --git a/packages/website/public/images/team/jason.png b/packages/website/public/images/team/jason.png
new file mode 100644
index 000000000..a39522252
--- /dev/null
+++ b/packages/website/public/images/team/jason.png
Binary files differ
diff --git a/packages/website/ts/containers/smart_contracts_documentation.ts b/packages/website/ts/containers/smart_contracts_documentation.ts
index 8d69afe71..05b2a50c3 100644
--- a/packages/website/ts/containers/smart_contracts_documentation.ts
+++ b/packages/website/ts/containers/smart_contracts_documentation.ts
@@ -37,28 +37,56 @@ const docsInfoConfig: DocsInfoConfig = {
contractsByVersionByNetworkId: {
'1.0.0': {
[Networks.Mainnet]: {
- [Sections.Exchange]: '0x12459c951127e0c374ff9105dda097662a027093',
- [Sections.TokenTransferProxy]: '0x8da0d80f5007ef1e431dd2127178d224e32c2ef4',
- [Sections.ZRXToken]: '0xe41d2489571d322189246dafa5ebde1f4699f498',
- [Sections.TokenRegistry]: '0x926a74c5c36adf004c87399e65f75628b0f98d2c',
+ Exchange_v1: '0x12459c951127e0c374ff9105dda097662a027093',
+ TokenTransferProxy_v1: '0x8da0d80f5007ef1e431dd2127178d224e32c2ef4',
+ TokenRegistry: '0x926a74c5c36adf004c87399e65f75628b0f98d2c',
},
[Networks.Ropsten]: {
- [Sections.Exchange]: '0x479cc461fecd078f766ecc58533d6f69580cf3ac',
- [Sections.TokenTransferProxy]: '0x4e9aad8184de8833365fea970cd9149372fdf1e6',
- [Sections.ZRXToken]: '0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d',
- [Sections.TokenRegistry]: '0x6b1a50f0bb5a7995444bd3877b22dc89c62843ed',
+ Exchange_v1: '0x479cc461fecd078f766ecc58533d6f69580cf3ac',
+ TokenTransferProxy_v1: '0x4e9aad8184de8833365fea970cd9149372fdf1e6',
+ TokenRegistry: '0x6b1a50f0bb5a7995444bd3877b22dc89c62843ed',
},
[Networks.Kovan]: {
- [Sections.Exchange]: '0x90fe2af704b34e0224bf2299c838e04d4dcf1364',
- [Sections.TokenTransferProxy]: '0x087Eed4Bc1ee3DE49BeFbd66C662B434B15d49d4',
- [Sections.ZRXToken]: '0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570',
- [Sections.TokenRegistry]: '0xf18e504561f4347bea557f3d4558f559dddbae7f',
+ Exchange_v1: '0x90fe2af704b34e0224bf2299c838e04d4dcf1364',
+ TokenTransferProxy_v1: '0x087Eed4Bc1ee3DE49BeFbd66C662B434B15d49d4',
+ TokenRegistry: '0xf18e504561f4347bea557f3d4558f559dddbae7f',
},
[Networks.Rinkeby]: {
- [Sections.Exchange]: '0x1d16ef40fac01cec8adac2ac49427b9384192c05',
- [Sections.TokenTransferProxy]: '0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d',
- [Sections.ZRXToken]: '0x00f58d6d585f84b2d7267940cede30ce2fe6eae8',
- [Sections.TokenRegistry]: '0x4e9aad8184de8833365fea970cd9149372fdf1e6',
+ Exchange_v1: '0x1d16ef40fac01cec8adac2ac49427b9384192c05',
+ TokenTransferProxy_v1: '0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d',
+ TokenRegistry: '0x4e9aad8184de8833365fea970cd9149372fdf1e6',
+ },
+ },
+ '2.0.0': {
+ [Networks.Mainnet]: {
+ AssetProxyOwner: '0x17992e4ffb22730138e4b62aaa6367fa9d3699a6',
+ ERC20Proxy: '0x2240dab907db71e64d3e0dba4800c83b5c502d4e',
+ ERC721Proxy: '0x208e41fb445f1bb1b6780d58356e81405f3e6127',
+ Exchange: '0x4f833a24e1f95d70f028921e27040ca56e09ab0b',
+ Forwarder: '0x7afc2d5107af94c462a194d2c21b5bdd238709d6',
+ OrderValidator: '0x9463e518dea6810309563c81d5266c1b1d149138',
+ WETH9: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
+ ZRXToken: '0xe41d2489571d322189246dafa5ebde1f4699f498',
+ },
+ [Networks.Ropsten]: {
+ AssetProxyOwner: '0xf5fa5b5fed2727a0e44ac67f6772e97977aa358b',
+ ERC20Proxy: '0xb1408f4c245a23c31b98d2c626777d4c0d766caa',
+ ERC721Proxy: '0xe654aac058bfbf9f83fcaee7793311dd82f6ddb4',
+ Exchange: '0x4530c0483a1633c7a1c97d2c53721caff2caaaaf',
+ Forwarder: '0x3983e204b12b3c02fb0638caf2cd406a62e0ead3',
+ OrderValidator: '0x90431a90516ab49af23a0530e04e8c7836e7122f',
+ WETH9: '0xc778417e063141139fce010982780140aa0cd5ab',
+ ZRXToken: '0xff67881f8d12f372d91baae9752eb3631ff0ed00',
+ },
+ [Networks.Kovan]: {
+ AssetProxyOwner: '0x2c824d2882baa668e0d5202b1e7f2922278703f8',
+ ERC20Proxy: '0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e',
+ ERC721Proxy: '0x2a9127c745688a165106c11cd4d647d2220af821',
+ Exchange: '0x35dd2932454449b14cee11a94d3674a936d5d7b2',
+ Forwarder: '0xd85e2fa7e7e252b27b01bf0d65c946959d2f45b8',
+ OrderValidator: '0xb389da3d204b412df2f75c6afb3d0a7ce0bc283d',
+ WETH9: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
+ ZRXToken: '0x2002d3812f58e35f0ea1ffbf80a75a38c32175fa',
},
},
},
diff --git a/packages/website/ts/index.tsx b/packages/website/ts/index.tsx
index 9e59b00ac..d4a79cc4f 100644
--- a/packages/website/ts/index.tsx
+++ b/packages/website/ts/index.tsx
@@ -26,47 +26,47 @@ import 'less/all.less';
// We pass modulePromise returning lambda instead of module promise,
// cause we only want to import the module when the user navigates to the page.
-// At the same time webpack statically parses for System.import() to determine bundle chunk split points
-// so each lazy import needs it's own `System.import()` declaration.
+// At the same time webpack statically parses for import() to determine bundle chunk split points
+// so each lazy import needs it's own `import()` declaration.
const LazyPortal = createLazyComponent('Portal', async () =>
- System.import<any>(/* webpackChunkName: "portal" */ 'ts/containers/portal'),
+ import(/* webpackChunkName: "portal" */ 'ts/containers/portal'),
);
const LazyZeroExJSDocumentation = createLazyComponent('Documentation', async () =>
- System.import<any>(/* webpackChunkName: "zeroExDocs" */ 'ts/containers/zero_ex_js_documentation'),
+ import(/* webpackChunkName: "zeroExDocs" */ 'ts/containers/zero_ex_js_documentation'),
);
const LazyContractWrappersDocumentation = createLazyComponent('Documentation', async () =>
- System.import<any>(/* webpackChunkName: "contractWrapperDocs" */ 'ts/containers/contract_wrappers_documentation'),
+ import(/* webpackChunkName: "contractWrapperDocs" */ 'ts/containers/contract_wrappers_documentation'),
);
const LazyOrderWatcherDocumentation = createLazyComponent('Documentation', async () =>
- System.import<any>(/* webpackChunkName: "orderWatcherDocs" */ 'ts/containers/order_watcher_documentation'),
+ import(/* webpackChunkName: "orderWatcherDocs" */ 'ts/containers/order_watcher_documentation'),
);
const LazySmartContractsDocumentation = createLazyComponent('Documentation', async () =>
- System.import<any>(/* webpackChunkName: "smartContractDocs" */ 'ts/containers/smart_contracts_documentation'),
+ import(/* webpackChunkName: "smartContractDocs" */ 'ts/containers/smart_contracts_documentation'),
);
const LazyConnectDocumentation = createLazyComponent('Documentation', async () =>
- System.import<any>(/* webpackChunkName: "connectDocs" */ 'ts/containers/connect_documentation'),
+ import(/* webpackChunkName: "connectDocs" */ 'ts/containers/connect_documentation'),
);
const LazyWeb3WrapperDocumentation = createLazyComponent('Documentation', async () =>
- System.import<any>(/* webpackChunkName: "web3WrapperDocs" */ 'ts/containers/web3_wrapper_documentation'),
+ import(/* webpackChunkName: "web3WrapperDocs" */ 'ts/containers/web3_wrapper_documentation'),
);
const LazySolCompilerDocumentation = createLazyComponent('Documentation', async () =>
- System.import<any>(/* webpackChunkName: "solCompilerDocs" */ 'ts/containers/sol_compiler_documentation'),
+ import(/* webpackChunkName: "solCompilerDocs" */ 'ts/containers/sol_compiler_documentation'),
);
const LazyJSONSchemasDocumentation = createLazyComponent('Documentation', async () =>
- System.import<any>(/* webpackChunkName: "jsonSchemasDocs" */ 'ts/containers/json_schemas_documentation'),
+ import(/* webpackChunkName: "jsonSchemasDocs" */ 'ts/containers/json_schemas_documentation'),
);
const LazySolCovDocumentation = createLazyComponent('Documentation', async () =>
- System.import<any>(/* webpackChunkName: "solCovDocs" */ 'ts/containers/sol_cov_documentation'),
+ import(/* webpackChunkName: "solCovDocs" */ 'ts/containers/sol_cov_documentation'),
);
const LazySubprovidersDocumentation = createLazyComponent('Documentation', async () =>
- System.import<any>(/* webpackChunkName: "subproviderDocs" */ 'ts/containers/subproviders_documentation'),
+ import(/* webpackChunkName: "subproviderDocs" */ 'ts/containers/subproviders_documentation'),
);
const LazyOrderUtilsDocumentation = createLazyComponent('Documentation', async () =>
- System.import<any>(/* webpackChunkName: "orderUtilsDocs" */ 'ts/containers/order_utils_documentation'),
+ import(/* webpackChunkName: "orderUtilsDocs" */ 'ts/containers/order_utils_documentation'),
);
const LazyEthereumTypesDocumentation = createLazyComponent('Documentation', async () =>
- System.import<any>(/* webpackChunkName: "ethereumTypesDocs" */ 'ts/containers/ethereum_types_documentation'),
+ import(/* webpackChunkName: "ethereumTypesDocs" */ 'ts/containers/ethereum_types_documentation'),
);
const DOCUMENT_TITLE = '0x: The Protocol for Trading Tokens';
diff --git a/packages/website/ts/lazy_component.tsx b/packages/website/ts/lazy_component.tsx
index dce06ed8d..9d3b9944a 100644
--- a/packages/website/ts/lazy_component.tsx
+++ b/packages/website/ts/lazy_component.tsx
@@ -49,7 +49,7 @@ export class LazyComponent extends React.Component<LazyComponentProps, LazyCompo
* @param componentName name of exported component
* @param lazyImport lambda returning module promise
* we pass a lambda because we only want to require a module if it's used
- * @example `const LazyPortal = createLazyComponent('Portal', () => System.import<any>('ts/containers/portal'));``
+ * @example `const LazyPortal = createLazyComponent('Portal', () => import<any>('ts/containers/portal'));``
*/
export const createLazyComponent = (componentName: string, lazyImport: () => Promise<any>) => {
return (props: any) => {
diff --git a/packages/website/ts/pages/about/about.tsx b/packages/website/ts/pages/about/about.tsx
index e097578bc..037647161 100644
--- a/packages/website/ts/pages/about/about.tsx
+++ b/packages/website/ts/pages/about/about.tsx
@@ -231,6 +231,13 @@ const teamRow8: ProfileInfo[] = [
image: 'images/team/rahul.png',
linkedIn: 'https://www.linkedin.com/in/rahul-singireddy-3037908a/',
},
+ {
+ name: 'Jason Somensatto',
+ title: 'Strategic Legal Counsel',
+ description: `Legal. Previously head of blockchain and crypto practice at Orrick. JD from George Washington University and undergrad at UVA.`,
+ image: 'images/team/jason.png',
+ linkedIn: 'https://www.linkedin.com/in/jasonsomensatto/',
+ },
];
const advisors1: ProfileInfo[] = [
diff --git a/packages/website/ts/pages/documentation/doc_page.tsx b/packages/website/ts/pages/documentation/doc_page.tsx
index 6f029b6a2..87a806b2b 100644
--- a/packages/website/ts/pages/documentation/doc_page.tsx
+++ b/packages/website/ts/pages/documentation/doc_page.tsx
@@ -146,9 +146,9 @@ export class DocPage extends React.Component<DocPageProps, DocPageState> {
docAgnosticFormat = versionDocObj as DocAgnosticFormat;
// HACK: need to modify docsInfo like convertToDocAgnosticFormat() would do
this.props.docsInfo.menu.Contracts = [];
- _.each(docAgnosticFormat, (docObj, contractName) => {
- this.props.docsInfo.sections[contractName] = contractName;
- this.props.docsInfo.menu.Contracts.push(contractName);
+ _.each(docAgnosticFormat, (_docObj, sectionName) => {
+ this.props.docsInfo.sections[sectionName] = sectionName;
+ this.props.docsInfo.menu.Contracts.push(sectionName);
});
}
diff --git a/packages/website/webpack.config.js b/packages/website/webpack.config.js
index 8653196a6..ec265be93 100644
--- a/packages/website/webpack.config.js
+++ b/packages/website/webpack.config.js
@@ -1,6 +1,6 @@
const path = require('path');
const webpack = require('webpack');
-const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
+const TerserPlugin = require('terser-webpack-plugin');
const RollbarSourceMapPlugin = require('rollbar-sourcemap-webpack-plugin');
const childProcess = require('child_process');
@@ -9,44 +9,7 @@ const GIT_SHA = childProcess
.toString()
.trim();
-const generatePlugins = () => {
- let plugins = [];
- if (process.env.NODE_ENV === 'production') {
- plugins = plugins.concat([
- // Since we do not use moment's locale feature, we exclude them from the bundle.
- // This reduces the bundle size by 0.4MB.
- new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
- new webpack.DefinePlugin({
- 'process.env': {
- NODE_ENV: JSON.stringify(process.env.NODE_ENV),
- GIT_SHA: JSON.stringify(GIT_SHA),
- },
- }),
- // TODO: Revert to webpack bundled version with webpack v4.
- // The v3 series bundled version does not support ES6 and
- // fails to build.
- new UglifyJsPlugin({
- sourceMap: true,
- uglifyOptions: {
- mangle: {
- reserved: ['BigNumber'],
- },
- },
- }),
- ]);
- if (process.env.DEPLOY_ROLLBAR_SOURCEMAPS === 'true') {
- plugins = plugins.concat([
- new RollbarSourceMapPlugin({
- accessToken: '32c39bfa4bb6440faedc1612a9c13d28',
- version: GIT_SHA,
- publicPath: 'https://0xproject.com/',
- }),
- ]);
- }
- }
- return plugins;
-};
-module.exports = {
+const config = {
entry: ['./ts/index.tsx'],
output: {
path: path.join(__dirname, '/public'),
@@ -92,10 +55,18 @@ module.exports = {
test: /\.css$/,
loaders: ['style-loader', 'css-loader'],
},
- {
- test: /\.json$/,
- loader: 'json-loader',
- },
+ ],
+ },
+ optimization: {
+ minimizer: [
+ new TerserPlugin({
+ sourceMap: true,
+ terserOptions: {
+ mangle: {
+ reserved: ['BigNumber'],
+ },
+ },
+ }),
],
},
devServer: {
@@ -115,5 +86,39 @@ module.exports = {
},
disableHostCheck: true,
},
- plugins: generatePlugins(),
+};
+
+module.exports = (_env, argv) => {
+ let plugins = [];
+ if (argv.mode === 'development') {
+ config.mode = 'development';
+ } else {
+ config.mode = 'production';
+ plugins = plugins.concat([
+ // Since we do not use moment's locale feature, we exclude them from the bundle.
+ // This reduces the bundle size by 0.4MB.
+ new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
+ new webpack.DefinePlugin({
+ 'process.env': {
+ NODE_ENV: JSON.stringify(process.env.NODE_ENV),
+ GIT_SHA: JSON.stringify(GIT_SHA),
+ },
+ }),
+ ]);
+ if (process.env.DEPLOY_ROLLBAR_SOURCEMAPS === 'true') {
+ plugins = plugins.concat([
+ new RollbarSourceMapPlugin({
+ accessToken: '32c39bfa4bb6440faedc1612a9c13d28',
+ version: GIT_SHA,
+ publicPath: 'https://0xproject.com/',
+ }),
+ ]);
+ }
+ }
+ console.log('i 「atl」: Mode: ', config.mode);
+
+ config.plugins = plugins;
+ console.log('i 「atl」: Plugin Count: ', config.plugins.length);
+
+ return config;
};