aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKadinsky <kandinsky454@protonmail.ch>2018-10-18 19:14:32 +0800
committerGitHub <noreply@github.com>2018-10-18 19:14:32 +0800
commit47dc384ea36fecbcf01eb9b3f20936331b43a0c6 (patch)
treee53a0c2d20b9f3271916144528f2214b32a3a83a
parentc333d093b585fa0250a6973f2d396eb3cf227334 (diff)
parente7c6f2a35795610645598deba2c14ceeda6acc89 (diff)
downloaddexon-sol-tools-47dc384ea36fecbcf01eb9b3f20936331b43a0c6.tar
dexon-sol-tools-47dc384ea36fecbcf01eb9b3f20936331b43a0c6.tar.gz
dexon-sol-tools-47dc384ea36fecbcf01eb9b3f20936331b43a0c6.tar.bz2
dexon-sol-tools-47dc384ea36fecbcf01eb9b3f20936331b43a0c6.tar.lz
dexon-sol-tools-47dc384ea36fecbcf01eb9b3f20936331b43a0c6.tar.xz
dexon-sol-tools-47dc384ea36fecbcf01eb9b3f20936331b43a0c6.tar.zst
dexon-sol-tools-47dc384ea36fecbcf01eb9b3f20936331b43a0c6.zip
Merge pull request #1140 from 0xProject/reSkinReferenceDocs
Move Doc Reference Pages & Wiki into Developer Section of Website
-rw-r--r--.circleci/config.yml1
-rw-r--r--.prettierignore1
-rw-r--r--CODEOWNERS18
-rw-r--r--package.json6
-rw-r--r--packages/0x.js/CHANGELOG.json4
-rw-r--r--packages/0x.js/package.json2
-rw-r--r--packages/0x.js/src/index.ts1
-rw-r--r--packages/asset-buyer/CHANGELOG.json16
-rw-r--r--packages/asset-buyer/package.json5
-rw-r--r--packages/asset-buyer/src/index.ts9
-rw-r--r--packages/base-contract/src/index.ts3
-rw-r--r--packages/connect/package.json2
-rw-r--r--packages/connect/src/utils/assert.ts2
-rw-r--r--packages/contract-addresses/CHANGELOG.json10
-rw-r--r--packages/contract-artifacts/CHANGELOG.json10
-rw-r--r--packages/contract-wrappers/package.json2
-rw-r--r--packages/ethereum-types/CHANGELOG.json10
-rw-r--r--packages/ethereum-types/src/index.ts16
-rw-r--r--packages/instant/package.json7
-rw-r--r--packages/instant/src/components/amount_input.tsx12
-rw-r--r--packages/instant/src/components/animations/slide_animations.tsx54
-rw-r--r--packages/instant/src/components/animations/slide_up_and_down_animation.tsx96
-rw-r--r--packages/instant/src/components/asset_amount_input.tsx38
-rw-r--r--packages/instant/src/components/buy_button.tsx58
-rw-r--r--packages/instant/src/components/instant_heading.tsx62
-rw-r--r--packages/instant/src/components/order_details.tsx110
-rw-r--r--packages/instant/src/components/sliding_error.tsx24
-rw-r--r--packages/instant/src/components/zero_ex_instant.tsx3
-rw-r--r--packages/instant/src/components/zero_ex_instant_container.tsx17
-rw-r--r--packages/instant/src/constants.ts6
-rw-r--r--packages/instant/src/containers/latest_buy_quote_order_details.ts27
-rw-r--r--packages/instant/src/containers/latest_error.tsx35
-rw-r--r--packages/instant/src/containers/selected_asset_amount_input.ts89
-rw-r--r--packages/instant/src/containers/selected_asset_amount_input.tsx36
-rw-r--r--packages/instant/src/containers/selected_asset_buy_button.ts55
-rw-r--r--packages/instant/src/containers/selected_asset_instant_heading.ts30
-rw-r--r--packages/instant/src/data/asset_meta_data.ts15
-rw-r--r--packages/instant/src/redux/actions.ts46
-rw-r--r--packages/instant/src/redux/async_data.ts22
-rw-r--r--packages/instant/src/redux/reducer.ts67
-rw-r--r--packages/instant/src/redux/store.ts3
-rw-r--r--packages/instant/src/types.ts36
-rw-r--r--packages/instant/src/util/asset_buyer.ts9
-rw-r--r--packages/instant/src/util/asset_data.ts21
-rw-r--r--packages/instant/src/util/coinbase_api.ts10
-rw-r--r--packages/instant/src/util/error.ts62
-rw-r--r--packages/instant/src/util/format.ts53
-rw-r--r--packages/instant/src/util/provider.ts12
-rw-r--r--packages/instant/src/util/util.ts5
-rw-r--r--packages/instant/src/util/web3_wrapper.ts5
-rw-r--r--packages/instant/test/components/zero_ex_instant.test.tsx12
-rw-r--r--packages/instant/test/util/asset_data.test.ts17
-rw-r--r--packages/instant/test/util/error.test.ts48
-rw-r--r--packages/instant/test/util/format.test.ts97
-rw-r--r--packages/json-schemas/CHANGELOG.json10
-rw-r--r--packages/json-schemas/package.json4
-rw-r--r--packages/json-schemas/schemas/address_schema.json5
-rw-r--r--packages/json-schemas/schemas/basic_type_schemas.ts17
-rw-r--r--packages/json-schemas/schemas/block_param_schema.json11
-rw-r--r--packages/json-schemas/schemas/block_range_schema.json8
-rw-r--r--packages/json-schemas/schemas/block_range_schema.ts20
-rw-r--r--packages/json-schemas/schemas/call_data_schema.json27
-rw-r--r--packages/json-schemas/schemas/call_data_schema.ts27
-rw-r--r--packages/json-schemas/schemas/ec_signature_parameter_schema.json5
-rw-r--r--packages/json-schemas/schemas/ec_signature_schema.json14
-rw-r--r--packages/json-schemas/schemas/ec_signature_schema.ts20
-rw-r--r--packages/json-schemas/schemas/eip712_typed_data.ts28
-rw-r--r--packages/json-schemas/schemas/eip712_typed_data_schema.json28
-rw-r--r--packages/json-schemas/schemas/hex_schema.json5
-rw-r--r--packages/json-schemas/schemas/index_filter_values_schema.json7
-rw-r--r--packages/json-schemas/schemas/index_filter_values_schema.ts7
-rw-r--r--packages/json-schemas/schemas/js_number.json5
-rw-r--r--packages/json-schemas/schemas/number_schema.json5
-rw-r--r--packages/json-schemas/schemas/order_cancel_schema.json12
-rw-r--r--packages/json-schemas/schemas/order_cancel_schema.ts12
-rw-r--r--packages/json-schemas/schemas/order_fill_or_kill_requests_schema.json12
-rw-r--r--packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts12
-rw-r--r--packages/json-schemas/schemas/order_fill_requests_schema.json12
-rw-r--r--packages/json-schemas/schemas/order_fill_requests_schema.ts12
-rw-r--r--packages/json-schemas/schemas/order_hash_schema.json5
-rw-r--r--packages/json-schemas/schemas/order_hash_schema.ts5
-rw-r--r--packages/json-schemas/schemas/order_schema.json34
-rw-r--r--packages/json-schemas/schemas/order_schemas.ts47
-rw-r--r--packages/json-schemas/schemas/orders_schema.json5
-rw-r--r--packages/json-schemas/schemas/orders_schema.ts5
-rw-r--r--packages/json-schemas/schemas/paginated_collection_schema.json10
-rw-r--r--packages/json-schemas/schemas/paginated_collection_schema.ts10
-rw-r--r--packages/json-schemas/schemas/relayer_api_asset_data_pairs_response_schema.json13
-rw-r--r--packages/json-schemas/schemas/relayer_api_asset_data_pairs_schema.json12
-rw-r--r--packages/json-schemas/schemas/relayer_api_asset_data_trade_info_schema.json11
-rw-r--r--packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts38
-rw-r--r--packages/json-schemas/schemas/relayer_api_error_response_schema.json21
-rw-r--r--packages/json-schemas/schemas/relayer_api_error_response_schema.ts21
-rw-r--r--packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.json16
-rw-r--r--packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.ts16
-rw-r--r--packages/json-schemas/schemas/relayer_api_order_config_payload_schema.json24
-rw-r--r--packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts24
-rw-r--r--packages/json-schemas/schemas/relayer_api_order_config_response_schema.json11
-rw-r--r--packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts11
-rw-r--r--packages/json-schemas/schemas/relayer_api_order_schema.json9
-rw-r--r--packages/json-schemas/schemas/relayer_api_order_schema.ts9
-rw-r--r--packages/json-schemas/schemas/relayer_api_orderbook_response_schema.json9
-rw-r--r--packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts9
-rw-r--r--packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_payload_schema.json14
-rw-r--r--packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.json11
-rw-r--r--packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts26
-rw-r--r--packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.json11
-rw-r--r--packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts11
-rw-r--r--packages/json-schemas/schemas/relayer_api_orders_response_schema.json13
-rw-r--r--packages/json-schemas/schemas/relayer_api_orders_response_schema.ts13
-rw-r--r--packages/json-schemas/schemas/relayer_api_orders_schema.json5
-rw-r--r--packages/json-schemas/schemas/relayer_api_orders_schema.ts5
-rw-r--r--packages/json-schemas/schemas/signed_order_schema.json12
-rw-r--r--packages/json-schemas/schemas/signed_orders_schema.json5
-rw-r--r--packages/json-schemas/schemas/signed_orders_schema.ts5
-rw-r--r--packages/json-schemas/schemas/token_schema.json11
-rw-r--r--packages/json-schemas/schemas/token_schema.ts11
-rw-r--r--packages/json-schemas/schemas/tx_data_schema.json26
-rw-r--r--packages/json-schemas/schemas/tx_data_schema.ts32
-rw-r--r--packages/json-schemas/schemas/zero_ex_transaction_schema.json10
-rw-r--r--packages/json-schemas/schemas/zero_ex_transaction_schema.ts10
-rw-r--r--packages/json-schemas/src/globals.d.ts6
-rw-r--r--packages/json-schemas/src/schemas.ts74
-rw-r--r--packages/json-schemas/tsconfig.json44
-rw-r--r--packages/monorepo-scripts/CHANGELOG.json13
-rw-r--r--packages/monorepo-scripts/package.json2
-rw-r--r--packages/monorepo-scripts/src/doc_gen_configs.ts15
-rw-r--r--packages/monorepo-scripts/src/utils/changelog_utils.ts3
-rw-r--r--packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts2
-rw-r--r--packages/order-utils/CHANGELOG.json4
-rw-r--r--packages/order-utils/package.json2
-rw-r--r--packages/order-utils/src/asset_data_utils.ts4
-rw-r--r--packages/order-utils/src/index.ts2
-rw-r--r--packages/react-docs/package.json6
-rw-r--r--packages/react-docs/src/components/comment.tsx4
-rw-r--r--packages/react-docs/src/components/doc_reference.tsx (renamed from packages/react-docs/src/components/documentation.tsx)155
-rw-r--r--packages/react-docs/src/components/signature_block.tsx2
-rw-r--r--packages/react-docs/src/components/type.tsx62
-rw-r--r--packages/react-docs/src/components/type_definition.tsx1
-rw-r--r--packages/react-docs/src/docs_info.ts59
-rw-r--r--packages/react-docs/src/index.ts2
-rw-r--r--packages/react-docs/src/utils/typedoc_utils.ts10
-rw-r--r--packages/react-shared/CHANGELOG.json12
-rw-r--r--packages/react-shared/package.json4
-rw-r--r--packages/react-shared/src/components/anchor_title.tsx76
-rw-r--r--packages/react-shared/src/components/markdown_paragraph_block.tsx10
-rw-r--r--packages/react-shared/src/components/markdown_section.tsx25
-rw-r--r--packages/react-shared/src/components/nested_sidebar_menu.tsx144
-rw-r--r--packages/react-shared/src/components/version_drop_down.tsx37
-rw-r--r--packages/react-shared/src/utils/colors.ts1
-rw-r--r--packages/sol-compiler/package.json2
-rw-r--r--packages/sol-compiler/src/utils/encoder.ts6
-rw-r--r--packages/sol-cov/package.json2
-rw-r--r--packages/sol-doc/src/sol_doc.ts14
-rw-r--r--packages/sra-spec/src/json-schemas.ts4
-rw-r--r--packages/subproviders/package.json2
-rw-r--r--packages/types/CHANGELOG.json4
-rw-r--r--packages/types/src/index.ts2
-rw-r--r--packages/utils/src/abi_decoder.ts8
-rw-r--r--packages/web3-wrapper/package.json2
-rw-r--r--packages/website/less/all.less13
-rw-r--r--packages/website/md/docs/asset_buyer/installation.md17
-rw-r--r--packages/website/md/docs/asset_buyer/introduction.md1
-rw-r--r--packages/website/md/docs/asset_buyer/usage.md39
-rw-r--r--packages/website/md/docs/json_schemas/2.0.0/schemas.md52
-rw-r--r--packages/website/package.json2
-rw-r--r--packages/website/public/css/basscss_responsive_custom.css12
-rw-r--r--packages/website/public/images/developers/chat_icon.svg5
-rw-r--r--packages/website/public/images/developers/forum_icon.svg5
-rw-r--r--packages/website/public/images/developers/github_icon.svg4
-rw-r--r--packages/website/translations/english.json1
-rw-r--r--packages/website/ts/components/documentation/docs_top_bar.tsx104
-rw-r--r--packages/website/ts/components/documentation/overview_content.tsx134
-rw-r--r--packages/website/ts/components/documentation/sidebar_header.tsx57
-rw-r--r--packages/website/ts/components/documentation/version_drop_down.tsx80
-rw-r--r--packages/website/ts/components/dropdowns/developers_drop_down.tsx11
-rw-r--r--packages/website/ts/components/footer.tsx8
-rw-r--r--packages/website/ts/components/portal/portal.tsx9
-rw-r--r--packages/website/ts/components/relayer_index/relayer_grid_tile.tsx46
-rw-r--r--packages/website/ts/components/relayer_index/relayer_index.tsx23
-rw-r--r--packages/website/ts/components/sidebar_header.tsx35
-rw-r--r--packages/website/ts/components/top_bar/top_bar.tsx107
-rw-r--r--packages/website/ts/components/ui/button.tsx7
-rw-r--r--packages/website/ts/components/ui/drop_down.tsx9
-rw-r--r--packages/website/ts/containers/asset_buyer_documentation.ts71
-rw-r--r--packages/website/ts/containers/connect_documentation.ts7
-rw-r--r--packages/website/ts/containers/contract_wrappers_documentation.ts7
-rw-r--r--packages/website/ts/containers/docs_home.ts9
-rw-r--r--packages/website/ts/containers/ethereum_types_documentation.ts8
-rw-r--r--packages/website/ts/containers/json_schemas_documentation.ts10
-rw-r--r--packages/website/ts/containers/order_utils_documentation.ts7
-rw-r--r--packages/website/ts/containers/order_watcher_documentation.ts7
-rw-r--r--packages/website/ts/containers/smart_contracts_documentation.ts4
-rw-r--r--packages/website/ts/containers/sol_compiler_documentation.ts8
-rw-r--r--packages/website/ts/containers/sol_cov_documentation.ts8
-rw-r--r--packages/website/ts/containers/subproviders_documentation.ts8
-rw-r--r--packages/website/ts/containers/web3_wrapper_documentation.ts15
-rw-r--r--packages/website/ts/containers/wiki.ts3
-rw-r--r--packages/website/ts/containers/zero_ex_js_documentation.ts14
-rw-r--r--packages/website/ts/index.tsx8
-rw-r--r--packages/website/ts/pages/about/about.tsx3
-rw-r--r--packages/website/ts/pages/documentation/developers_page.tsx182
-rw-r--r--packages/website/ts/pages/documentation/doc_page.tsx105
-rw-r--r--packages/website/ts/pages/documentation/docs_home.tsx384
-rw-r--r--packages/website/ts/pages/documentation/home.tsx623
-rw-r--r--packages/website/ts/pages/landing/landing.tsx4
-rw-r--r--packages/website/ts/pages/wiki/wiki.tsx195
-rw-r--r--packages/website/ts/types.ts14
-rw-r--r--packages/website/ts/utils/constants.ts29
-rw-r--r--typedoc-tsconfig.json1
-rw-r--r--yarn.lock40
211 files changed, 3425 insertions, 2305 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 876b861d3..1cf665cce 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -98,6 +98,7 @@ jobs:
- run: yarn wsrun test:circleci @0xproject/subproviders
- run: yarn wsrun test:circleci @0xproject/web3-wrapper
- run: yarn wsrun test:circleci @0xproject/utils
+ - run: yarn wsrun test:circleci @0xproject/instant
- save_cache:
key: coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }}
paths:
diff --git a/.prettierignore b/.prettierignore
index 8d302a275..79dec3d1f 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -4,6 +4,7 @@ lib
/packages/contracts/generated-artifacts
/packages/abi-gen-wrappers/src/generated-wrappers
/packages/contract-artifacts/artifacts
+/packages/json-schemas/schemas
/packages/metacoin/src/contract_wrappers
/packages/metacoin/artifacts
/packages/sra-spec/public/
diff --git a/CODEOWNERS b/CODEOWNERS
index e2a8d93cd..278234aff 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -8,3 +8,21 @@
packages/asset-buyer/ @BMillman19 @fragosti @steveklebanoff
packages/instant/ @BMillman19 @fragosti @steveklebanoff
packages/website/ @BMillman19 @fragosti @fabioberger @steveklebanoff
+
+# Dev tools & setup
+packages/abi-gen/ @LogvinovLeon
+packages/base-contract/ @LogvinovLeon
+packages/contract_templates/ @LogvinovLeon
+packages/dev-utils/ @LogvinovLeon @fabioberger
+
+packages/ethereum-types/ @LogvinovLeon
+packages/metacoin/ @LogvinovLeon
+packages/sol-compiler/ @LogvinovLeon
+packages/sol-cov/ @LogvinovLeon
+packages/sol-resolver/ @LogvinovLeon
+packages/web3-wrapper/ @LogvinovLeon @fabioberger
+.circleci/ @LogvinovLeon
+packages/subproviders/ @fabioberger @dekz
+packages/connect/ @fragosti
+packages/monorepo-scripts/ @fabioberger
+packages/order-utils/ @fabioberger @LogvinovLeon
diff --git a/package.json b/package.json
index 031f73ba8..9785cd672 100644
--- a/package.json
+++ b/package.json
@@ -40,7 +40,7 @@
},
"config": {
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic",
- "packagesWithDocPages": "0x.js connect json-schemas subproviders web3-wrapper contract-wrappers order-utils order-watcher sol-compiler sol-cov ethereum-types"
+ "packagesWithDocPages": "0x.js connect json-schemas subproviders web3-wrapper contract-wrappers order-utils order-watcher sol-compiler sol-cov ethereum-types asset-buyer"
},
"bundlewatch" : {
"files": [
@@ -50,7 +50,7 @@
},
{
"path": "packages/instant/public/main.bundle.js",
- "maxSize": "350kB"
+ "maxSize": "500kB"
}
],
"ci": {
@@ -65,7 +65,7 @@
"coveralls": "^3.0.0",
"ganache-cli": "6.1.8",
"lcov-result-merger": "^3.0.0",
- "npm-cli-login": "^0.0.10",
+ "@0xproject/npm-cli-login": "^0.0.11",
"npm-run-all": "^4.1.2",
"prettier": "^1.11.1",
"source-map-support": "^0.5.6",
diff --git a/packages/0x.js/CHANGELOG.json b/packages/0x.js/CHANGELOG.json
index 4efd8f035..98791139f 100644
--- a/packages/0x.js/CHANGELOG.json
+++ b/packages/0x.js/CHANGELOG.json
@@ -24,6 +24,10 @@
{
"note": "Make web3-provider-engine types a 'dependency' so it's available to users of the library",
"pr": 1105
+ },
+ {
+ "note": "Export new `AssetData` type from types",
+ "pr": 1131
}
]
},
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index a78457e22..c439c8af3 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -68,7 +68,7 @@
"sinon": "^4.0.0",
"source-map-support": "^0.5.0",
"tslint": "5.11.0",
- "typedoc": "0.12.0",
+ "typedoc": "0.13.0",
"typescript": "3.0.1",
"uglifyjs-webpack-plugin": "^2.0.1",
"webpack": "^4.20.2"
diff --git a/packages/0x.js/src/index.ts b/packages/0x.js/src/index.ts
index 7fd48da37..2fcfb5ce7 100644
--- a/packages/0x.js/src/index.ts
+++ b/packages/0x.js/src/index.ts
@@ -79,6 +79,7 @@ export {
OrderStateInvalid,
OrderState,
AssetProxyId,
+ AssetData,
ERC20AssetData,
ERC721AssetData,
SignatureType,
diff --git a/packages/asset-buyer/CHANGELOG.json b/packages/asset-buyer/CHANGELOG.json
index b50fe2c63..e55661235 100644
--- a/packages/asset-buyer/CHANGELOG.json
+++ b/packages/asset-buyer/CHANGELOG.json
@@ -6,9 +6,25 @@
"note": "Add `gasLimit` and `gasPrice` as optional properties on `BuyQuoteExecutionOpts`"
},
{
+ "note": "Export `BuyQuoteInfo` type",
+ "pr": 1131
+ },
+ {
"note":
"Updated to use new modularized artifacts and the latest version of @0xproject/contract-wrappers",
"pr": 1105
+ },
+ {
+ "note": "Add `gasLimit` and `gasPrice` as optional properties on `BuyQuoteExecutionOpts`",
+ "pr": 1116
+ },
+ {
+ "note": "Add `docs:json` command to package.json",
+ "pr": 1139
+ },
+ {
+ "note": "Add missing types to public interface",
+ "pr": 1139
}
]
},
diff --git a/packages/asset-buyer/package.json b/packages/asset-buyer/package.json
index 8c8f3c92c..850fce873 100644
--- a/packages/asset-buyer/package.json
+++ b/packages/asset-buyer/package.json
@@ -17,7 +17,8 @@
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
"test:circleci": "yarn test:coverage",
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
- "clean": "shx rm -rf lib test_temp"
+ "clean": "shx rm -rf lib test_temp",
+ "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
},
"config": {
"postpublish": {
@@ -63,7 +64,7 @@
"nyc": "^11.0.1",
"shx": "^0.2.2",
"tslint": "5.11.0",
- "typedoc": "0.12.0",
+ "typedoc": "0.13.0",
"typescript": "3.0.1"
},
"publishConfig": {
diff --git a/packages/asset-buyer/src/index.ts b/packages/asset-buyer/src/index.ts
index 2da2724d7..9ac3c0b8a 100644
--- a/packages/asset-buyer/src/index.ts
+++ b/packages/asset-buyer/src/index.ts
@@ -1,4 +1,10 @@
-export { Provider } from 'ethereum-types';
+export {
+ JSONRPCRequestPayload,
+ JSONRPCResponsePayload,
+ JSONRPCResponseError,
+ JSONRPCErrorCallback,
+ Provider,
+} from 'ethereum-types';
export { SignedOrder } from '@0xproject/types';
export { BigNumber } from '@0xproject/utils';
@@ -10,6 +16,7 @@ export {
AssetBuyerOpts,
BuyQuote,
BuyQuoteExecutionOpts,
+ BuyQuoteInfo,
BuyQuoteRequestOpts,
OrderProvider,
OrderProviderRequest,
diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts
index a8e4ad2e2..73550ffd4 100644
--- a/packages/base-contract/src/index.ts
+++ b/packages/base-contract/src/index.ts
@@ -129,7 +129,8 @@ export class BaseContract {
if (abiDefinition.type !== AbiType.Function) {
return false;
}
- const abiFunctionSignature = abiUtils.getFunctionSignature(abiDefinition);
+ // tslint:disable-next-line:no-unnecessary-type-assertion
+ const abiFunctionSignature = abiUtils.getFunctionSignature(abiDefinition as MethodAbi);
if (abiFunctionSignature === functionSignature) {
return true;
}
diff --git a/packages/connect/package.json b/packages/connect/package.json
index e47ca3b79..591db0f83 100644
--- a/packages/connect/package.json
+++ b/packages/connect/package.json
@@ -77,7 +77,7 @@
"nyc": "^11.0.1",
"shx": "^0.2.2",
"tslint": "5.11.0",
- "typedoc": "0.12.0",
+ "typedoc": "0.13.0",
"typescript": "3.0.1"
},
"publishConfig": {
diff --git a/packages/connect/src/utils/assert.ts b/packages/connect/src/utils/assert.ts
index 3d8f1c799..4e2202d2e 100644
--- a/packages/connect/src/utils/assert.ts
+++ b/packages/connect/src/utils/assert.ts
@@ -14,7 +14,7 @@ export const assert = {
sharedAssert.doesConformToSchema(
variableName,
subscriptionOpts,
- schemas.relayerApiOrdersChannelSubscribePayload,
+ schemas.relayerApiOrdersChannelSubscribePayloadSchema,
);
},
isOrdersChannelHandler(variableName: string, handler: any): void {
diff --git a/packages/contract-addresses/CHANGELOG.json b/packages/contract-addresses/CHANGELOG.json
index d91ad0b36..d9bd2c077 100644
--- a/packages/contract-addresses/CHANGELOG.json
+++ b/packages/contract-addresses/CHANGELOG.json
@@ -1,11 +1,19 @@
[
{
- "version": "1.0.0",
+ "version": "1.0.1",
"changes": [
{
"pr": 1105,
"note": "Initial release"
}
]
+ },
+ {
+ "version": "1.0.0",
+ "changes": [
+ {
+ "note": "Unpublished Package"
+ }
+ ]
}
]
diff --git a/packages/contract-artifacts/CHANGELOG.json b/packages/contract-artifacts/CHANGELOG.json
index d91ad0b36..d9bd2c077 100644
--- a/packages/contract-artifacts/CHANGELOG.json
+++ b/packages/contract-artifacts/CHANGELOG.json
@@ -1,11 +1,19 @@
[
{
- "version": "1.0.0",
+ "version": "1.0.1",
"changes": [
{
"pr": 1105,
"note": "Initial release"
}
]
+ },
+ {
+ "version": "1.0.0",
+ "changes": [
+ {
+ "note": "Unpublished Package"
+ }
+ ]
}
]
diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json
index 3924378d3..ef19057cd 100644
--- a/packages/contract-wrappers/package.json
+++ b/packages/contract-wrappers/package.json
@@ -60,7 +60,7 @@
"sinon": "^4.0.0",
"source-map-support": "^0.5.0",
"tslint": "5.11.0",
- "typedoc": "0.12.0",
+ "typedoc": "0.13.0",
"typescript": "3.0.1",
"web3-provider-engine": "14.0.6"
},
diff --git a/packages/ethereum-types/CHANGELOG.json b/packages/ethereum-types/CHANGELOG.json
index 60fb8c806..ffc4742b1 100644
--- a/packages/ethereum-types/CHANGELOG.json
+++ b/packages/ethereum-types/CHANGELOG.json
@@ -1,6 +1,6 @@
[
{
- "version": "1.1.0",
+ "version": "1.1.1",
"changes": [
{
"note": "Add `JSONRPCResponseError` and error field on `JSONRPCResponsePayload`.",
@@ -9,6 +9,14 @@
]
},
{
+ "version": "1.1.0",
+ "changes": [
+ {
+ "note": "Unpublished package."
+ }
+ ]
+ },
+ {
"timestamp": 1538693146,
"version": "1.0.11",
"changes": [
diff --git a/packages/ethereum-types/src/index.ts b/packages/ethereum-types/src/index.ts
index ddd472010..eff38711a 100644
--- a/packages/ethereum-types/src/index.ts
+++ b/packages/ethereum-types/src/index.ts
@@ -20,7 +20,9 @@ export type ConstructorStateMutability = 'nonpayable' | 'payable';
export type StateMutability = 'pure' | 'view' | ConstructorStateMutability;
export interface MethodAbi {
- type: 'function'; // We hardcode this here b/c doc pages cannot render an enum value
+ // Ideally this would be set to: `'function'` but then TS complains when artifacts are loaded
+ // from JSON files, and this value has type `string` not type `'function'`
+ type: string;
name: string;
inputs: DataItem[];
outputs: DataItem[];
@@ -30,14 +32,18 @@ export interface MethodAbi {
}
export interface ConstructorAbi {
- type: 'constructor'; // We hardcode this here b/c doc pages cannot render an enum value
+ // Ideally this would be set to: `'constructor'` but then TS complains when artifacts are loaded
+ // from JSON files, and this value has type `string` not type `'constructor'`
+ type: string;
inputs: DataItem[];
payable: boolean;
stateMutability: ConstructorStateMutability;
}
export interface FallbackAbi {
- type: 'fallback'; // We hardcode this here b/c doc pages cannot render an enum value
+ // Ideally this would be set to: `'fallback'` but then TS complains when artifacts are loaded
+ // from JSON files, and this value has type `string` not type `'fallback'`
+ type: string;
payable: boolean;
}
@@ -46,7 +52,9 @@ export interface EventParameter extends DataItem {
}
export interface EventAbi {
- type: 'event'; // We hardcode this here b/c doc pages cannot render an enum value
+ // Ideally this would be set to: `'event'` but then TS complains when artifacts are loaded
+ // from JSON files, and this value has type `string` not type `'event'`
+ type: string;
name: string;
inputs: EventParameter[];
anonymous: boolean;
diff --git a/packages/instant/package.json b/packages/instant/package.json
index d15f1ad38..5c4436c52 100644
--- a/packages/instant/package.json
+++ b/packages/instant/package.json
@@ -55,12 +55,15 @@
"react-dom": "^16.5.2",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
- "styled-components": "^3.4.9"
+ "redux-devtools-extension": "^2.13.5",
+ "styled-components": "^3.4.9",
+ "ts-optchain": "^0.1.1"
},
"devDependencies": {
"@0xproject/tslint-config": "^1.0.8",
"@types/enzyme": "^3.1.14",
"@types/enzyme-adapter-react-16": "^1.0.3",
+ "@types/jest": "^23.3.5",
"@types/lodash": "^4.14.116",
"@types/node": "*",
"@types/react": "^16.4.16",
@@ -77,7 +80,7 @@
"shx": "^0.2.2",
"ts-jest": "^23.10.3",
"tslint": "5.11.0",
- "typedoc": "0.12.0",
+ "typedoc": "0.13.0",
"typescript": "3.0.1",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.1",
diff --git a/packages/instant/src/components/amount_input.tsx b/packages/instant/src/components/amount_input.tsx
index 38810063d..7644f5f67 100644
--- a/packages/instant/src/components/amount_input.tsx
+++ b/packages/instant/src/components/amount_input.tsx
@@ -3,6 +3,7 @@ import * as _ from 'lodash';
import * as React from 'react';
import { ColorOption } from '../style/theme';
+import { util } from '../util/util';
import { Container, Input } from './ui';
@@ -10,10 +11,13 @@ export interface AmountInputProps {
fontColor?: ColorOption;
fontSize?: string;
value?: BigNumber;
- onChange?: (value?: BigNumber) => void;
+ onChange: (value?: BigNumber) => void;
}
export class AmountInput extends React.Component<AmountInputProps> {
+ public static defaultProps = {
+ onChange: util.boundNoop,
+ };
public render(): React.ReactNode {
const { fontColor, fontSize, value } = this.props;
return (
@@ -24,7 +28,7 @@ export class AmountInput extends React.Component<AmountInputProps> {
onChange={this._handleChange}
value={!_.isUndefined(value) ? value.toString() : ''}
placeholder="0.00"
- width="2em"
+ width="2.2em"
/>
</Container>
);
@@ -40,8 +44,6 @@ export class AmountInput extends React.Component<AmountInputProps> {
return;
}
}
- if (!_.isUndefined(this.props.onChange)) {
- this.props.onChange(bigNumberValue);
- }
+ this.props.onChange(bigNumberValue);
};
}
diff --git a/packages/instant/src/components/animations/slide_animations.tsx b/packages/instant/src/components/animations/slide_animations.tsx
new file mode 100644
index 000000000..1f10a2ed6
--- /dev/null
+++ b/packages/instant/src/components/animations/slide_animations.tsx
@@ -0,0 +1,54 @@
+import * as React from 'react';
+
+import { keyframes, styled } from '../../style/theme';
+
+const slideKeyframeGenerator = (fromY: string, toY: string) => keyframes`
+ from {
+ position: relative;
+ top: ${fromY};
+ }
+
+ to {
+ position: relative;
+ top: ${toY};
+ }
+`;
+
+export interface SlideAnimationProps {
+ keyframes: string;
+ animationType: string;
+ animationDirection?: string;
+}
+
+export const SlideAnimation =
+ styled.div <
+ SlideAnimationProps >
+ `
+ animation-name: ${props => props.keyframes};
+ animation-duration: 0.3s;
+ animation-timing-function: ${props => props.animationType};
+ animation-delay: 0s;
+ animation-iteration-count: 1;
+ animation-fill-mode: ${props => props.animationDirection || 'none'};
+ position: relative;
+`;
+
+export interface SlideAnimationComponentProps {
+ downY: string;
+}
+
+export const SlideUpAnimation: React.StatelessComponent<SlideAnimationComponentProps> = props => (
+ <SlideAnimation animationType="ease-in" keyframes={slideKeyframeGenerator(props.downY, '0px')}>
+ {props.children}
+ </SlideAnimation>
+);
+
+export const SlideDownAnimation: React.StatelessComponent<SlideAnimationComponentProps> = props => (
+ <SlideAnimation
+ animationDirection="forwards"
+ animationType="cubic-bezier(0.25, 0.1, 0.25, 1)"
+ keyframes={slideKeyframeGenerator('0px', props.downY)}
+ >
+ {props.children}
+ </SlideAnimation>
+);
diff --git a/packages/instant/src/components/animations/slide_up_and_down_animation.tsx b/packages/instant/src/components/animations/slide_up_and_down_animation.tsx
deleted file mode 100644
index 9c18e0933..000000000
--- a/packages/instant/src/components/animations/slide_up_and_down_animation.tsx
+++ /dev/null
@@ -1,96 +0,0 @@
-import * as React from 'react';
-
-import { keyframes, styled } from '../../style/theme';
-
-const slideKeyframeGenerator = (fromY: string, toY: string) => keyframes`
- from {
- position: relative;
- top: ${fromY};
- }
-
- to {
- position: relative;
- top: ${toY};
- }
-`;
-
-export interface SlideAnimationProps {
- keyframes: string;
- animationType: string;
- animationDirection?: string;
-}
-
-export const SlideAnimation =
- styled.div <
- SlideAnimationProps >
- `
- animation-name: ${props => props.keyframes};
- animation-duration: 0.3s;
- animation-timing-function: ${props => props.animationType};
- animation-delay: 0s;
- animation-iteration-count: 1;
- animation-fill-mode: ${props => props.animationDirection || 'none'};
- position: relative;
-`;
-
-export interface SlideAnimationComponentProps {
- downY: string;
-}
-
-export const SlideUpAnimationComponent: React.StatelessComponent<SlideAnimationComponentProps> = props => (
- <SlideAnimation animationType="ease-in" keyframes={slideKeyframeGenerator(props.downY, '0px')}>
- {props.children}
- </SlideAnimation>
-);
-
-export const SlideDownAnimationComponent: React.StatelessComponent<SlideAnimationComponentProps> = props => (
- <SlideAnimation
- animationDirection="forwards"
- animationType="cubic-bezier(0.25, 0.1, 0.25, 1)"
- keyframes={slideKeyframeGenerator('0px', props.downY)}
- >
- {props.children}
- </SlideAnimation>
-);
-
-export interface SlideUpAndDownAnimationProps extends SlideAnimationComponentProps {
- delayMs: number;
-}
-
-enum SlideState {
- Up = 'up',
- Down = 'down',
-}
-interface SlideUpAndDownState {
- slideState: SlideState;
-}
-
-export class SlideUpAndDownAnimation extends React.Component<SlideUpAndDownAnimationProps, SlideUpAndDownState> {
- public state = {
- slideState: SlideState.Up,
- };
-
- private _timeoutId?: number;
- public render(): React.ReactNode {
- return this._renderSlide();
- }
- public componentDidMount(): void {
- this._timeoutId = window.setTimeout(() => {
- this.setState({
- slideState: SlideState.Down,
- });
- }, this.props.delayMs);
-
- return;
- }
- public componentWillUnmount(): void {
- if (this._timeoutId) {
- window.clearTimeout(this._timeoutId);
- }
- }
- private _renderSlide(): React.ReactNode {
- const SlideComponent = this.state.slideState === 'up' ? SlideUpAnimationComponent : SlideDownAnimationComponent;
-
- return <SlideComponent downY={this.props.downY}>{this.props.children}</SlideComponent>;
- }
-}
diff --git a/packages/instant/src/components/asset_amount_input.tsx b/packages/instant/src/components/asset_amount_input.tsx
new file mode 100644
index 000000000..db3dbe7f3
--- /dev/null
+++ b/packages/instant/src/components/asset_amount_input.tsx
@@ -0,0 +1,38 @@
+import { BigNumber } from '@0xproject/utils';
+import * as _ from 'lodash';
+import * as React from 'react';
+
+import { assetDataUtil } from '../util/asset_data';
+
+import { ColorOption } from '../style/theme';
+import { util } from '../util/util';
+
+import { AmountInput, AmountInputProps } from './amount_input';
+import { Container, Text } from './ui';
+
+export interface AssetAmountInputProps extends AmountInputProps {
+ assetData?: string;
+ onChange: (value?: BigNumber, assetData?: string) => void;
+}
+
+export class AssetAmountInput extends React.Component<AssetAmountInputProps> {
+ public static defaultProps = {
+ onChange: util.boundNoop,
+ };
+ public render(): React.ReactNode {
+ const { assetData, onChange, ...rest } = this.props;
+ return (
+ <Container>
+ <AmountInput {...rest} onChange={this._handleChange} />
+ <Container display="inline-block" marginLeft="10px">
+ <Text fontSize={rest.fontSize} fontColor={ColorOption.white} textTransform="uppercase">
+ {assetDataUtil.bestNameForAsset(this.props.assetData, '???')}
+ </Text>
+ </Container>
+ </Container>
+ );
+ }
+ private readonly _handleChange = (value?: BigNumber): void => {
+ this.props.onChange(value, this.props.assetData);
+ };
+}
diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx
index 5a32b9575..0706817c9 100644
--- a/packages/instant/src/components/buy_button.tsx
+++ b/packages/instant/src/components/buy_button.tsx
@@ -1,19 +1,53 @@
+import { BuyQuote } from '@0xproject/asset-buyer';
+import * as _ from 'lodash';
import * as React from 'react';
import { ColorOption } from '../style/theme';
+import { assetBuyer } from '../util/asset_buyer';
+import { util } from '../util/util';
+import { web3Wrapper } from '../util/web3_wrapper';
import { Button, Container, Text } from './ui';
-export interface BuyButtonProps {}
+export interface BuyButtonProps {
+ buyQuote?: BuyQuote;
+ onClick: (buyQuote: BuyQuote) => void;
+ onBuySuccess: (buyQuote: BuyQuote, txnHash: string) => void;
+ onBuyFailure: (buyQuote: BuyQuote, tnxHash?: string) => void;
+ text: string;
+}
-export const BuyButton: React.StatelessComponent<BuyButtonProps> = props => (
- <Container padding="20px" width="100%">
- <Button width="100%">
- <Text fontColor={ColorOption.white} fontWeight={600} fontSize="20px">
- Buy
- </Text>
- </Button>
- </Container>
-);
-
-BuyButton.displayName = 'BuyButton';
+export class BuyButton extends React.Component<BuyButtonProps> {
+ public static defaultProps = {
+ onClick: util.boundNoop,
+ onBuySuccess: util.boundNoop,
+ onBuyFailure: util.boundNoop,
+ };
+ public render(): React.ReactNode {
+ const shouldDisableButton = _.isUndefined(this.props.buyQuote);
+ return (
+ <Container padding="20px" width="100%">
+ <Button width="100%" onClick={this._handleClick} isDisabled={shouldDisableButton}>
+ <Text fontColor={ColorOption.white} fontWeight={600} fontSize="20px">
+ {this.props.text}
+ </Text>
+ </Button>
+ </Container>
+ );
+ }
+ private readonly _handleClick = async () => {
+ // The button is disabled when there is no buy quote anyway.
+ if (_.isUndefined(this.props.buyQuote)) {
+ return;
+ }
+ this.props.onClick(this.props.buyQuote);
+ let txnHash;
+ try {
+ txnHash = await assetBuyer.executeBuyQuoteAsync(this.props.buyQuote);
+ await web3Wrapper.awaitTransactionSuccessAsync(txnHash);
+ this.props.onBuySuccess(this.props.buyQuote, txnHash);
+ } catch {
+ this.props.onBuyFailure(this.props.buyQuote, txnHash);
+ }
+ };
+}
diff --git a/packages/instant/src/components/instant_heading.tsx b/packages/instant/src/components/instant_heading.tsx
index be0414b8d..f57b59b73 100644
--- a/packages/instant/src/components/instant_heading.tsx
+++ b/packages/instant/src/components/instant_heading.tsx
@@ -1,11 +1,58 @@
+import { BigNumber } from '@0xproject/utils';
+import * as _ from 'lodash';
import * as React from 'react';
import { SelectedAssetAmountInput } from '../containers/selected_asset_amount_input';
import { ColorOption } from '../style/theme';
+import { AsyncProcessState } from '../types';
+import { format } from '../util/format';
import { Container, Flex, Text } from './ui';
-export interface InstantHeadingProps {}
+export interface InstantHeadingProps {
+ selectedAssetAmount?: BigNumber;
+ totalEthBaseAmount?: BigNumber;
+ ethUsdPrice?: BigNumber;
+ quoteState: AsyncProcessState;
+}
+
+const Placeholder = () => (
+ <Text fontWeight="bold" fontColor={ColorOption.white}>
+ &mdash;
+ </Text>
+);
+const displaytotalEthBaseAmount = ({
+ selectedAssetAmount,
+ totalEthBaseAmount,
+}: InstantHeadingProps): React.ReactNode => {
+ if (_.isUndefined(selectedAssetAmount)) {
+ return '0 ETH';
+ }
+ return format.ethBaseAmount(totalEthBaseAmount, 4, <Placeholder />);
+};
+
+const displayUsdAmount = ({
+ totalEthBaseAmount,
+ selectedAssetAmount,
+ ethUsdPrice,
+}: InstantHeadingProps): React.ReactNode => {
+ if (_.isUndefined(selectedAssetAmount)) {
+ return '$0.00';
+ }
+ return format.ethBaseAmountInUsd(totalEthBaseAmount, ethUsdPrice, 2, <Placeholder />);
+};
+
+const loadingOrAmount = (quoteState: AsyncProcessState, amount: React.ReactNode): React.ReactNode => {
+ if (quoteState === AsyncProcessState.PENDING) {
+ return (
+ <Text fontWeight="bold" fontColor={ColorOption.white}>
+ &hellip;loading
+ </Text>
+ );
+ } else {
+ return amount;
+ }
+};
export const InstantHeading: React.StatelessComponent<InstantHeadingProps> = props => (
<Container backgroundColor={ColorOption.primaryColor} padding="20px" width="100%" borderRadius="3px 3px 0px 0px">
@@ -22,22 +69,15 @@ export const InstantHeading: React.StatelessComponent<InstantHeadingProps> = pro
</Text>
</Container>
<Flex direction="row" justify="space-between">
- <Container>
- <SelectedAssetAmountInput fontSize="45px" />
- <Container display="inline-block" marginLeft="10px">
- <Text fontSize="45px" fontColor={ColorOption.white} textTransform="uppercase">
- rep
- </Text>
- </Container>
- </Container>
+ <SelectedAssetAmountInput fontSize="45px" />
<Flex direction="column" justify="space-between">
<Container marginBottom="5px">
<Text fontSize="16px" fontColor={ColorOption.white} fontWeight={500}>
- 0 ETH
+ {loadingOrAmount(props.quoteState, displaytotalEthBaseAmount(props))}
</Text>
</Container>
<Text fontSize="16px" fontColor={ColorOption.white} opacity={0.7}>
- $0.00
+ {loadingOrAmount(props.quoteState, displayUsdAmount(props))}
</Text>
</Flex>
</Flex>
diff --git a/packages/instant/src/components/order_details.tsx b/packages/instant/src/components/order_details.tsx
index dbf2c1f0b..a15ff411b 100644
--- a/packages/instant/src/components/order_details.tsx
+++ b/packages/instant/src/components/order_details.tsx
@@ -1,53 +1,90 @@
+import { BuyQuoteInfo } from '@0xproject/asset-buyer';
+import { BigNumber } from '@0xproject/utils';
+import * as _ from 'lodash';
import * as React from 'react';
+import { oc } from 'ts-optchain';
import { ColorOption } from '../style/theme';
+import { format } from '../util/format';
import { Container, Flex, Text } from './ui';
-export interface OrderDetailsProps {}
-
-export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = props => (
- <Container padding="20px" width="100%">
- <Container marginBottom="10px">
- <Text
- letterSpacing="1px"
- fontColor={ColorOption.primaryColor}
- fontWeight={600}
- textTransform="uppercase"
- fontSize="14px"
- >
- Order Details
- </Text>
- </Container>
- <OrderDetailsRow name="Token Price" primaryValue=".013 ETH" secondaryValue="$24.32" />
- <OrderDetailsRow name="Fee" primaryValue=".005 ETH" secondaryValue="$1.04" />
- <OrderDetailsRow name="Total Cost" primaryValue="1.66 ETH" secondaryValue="$589.56" shouldEmphasize={true} />
- </Container>
-);
-
-OrderDetails.displayName = 'OrderDetails';
-
-export interface OrderDetailsRowProps {
- name: string;
- primaryValue: string;
- secondaryValue: string;
+export interface OrderDetailsProps {
+ buyQuoteInfo?: BuyQuoteInfo;
+ ethUsdPrice?: BigNumber;
+}
+
+export class OrderDetails extends React.Component<OrderDetailsProps> {
+ public render(): React.ReactNode {
+ const { buyQuoteInfo, ethUsdPrice } = this.props;
+ const buyQuoteAccessor = oc(buyQuoteInfo);
+ const ethAssetPrice = buyQuoteAccessor.ethPerAssetPrice();
+ const ethTokenFee = buyQuoteAccessor.feeEthAmount();
+ const totalEthAmount = buyQuoteAccessor.totalEthAmount();
+ return (
+ <Container padding="20px" width="100%">
+ <Container marginBottom="10px">
+ <Text
+ letterSpacing="1px"
+ fontColor={ColorOption.primaryColor}
+ fontWeight={600}
+ textTransform="uppercase"
+ fontSize="14px"
+ >
+ Order Details
+ </Text>
+ </Container>
+ <EthAmountRow
+ rowLabel="Token Price"
+ ethAmount={ethAssetPrice}
+ ethUsdPrice={ethUsdPrice}
+ isEthAmountInBaseUnits={false}
+ />
+ <EthAmountRow rowLabel="Fee" ethAmount={ethTokenFee} ethUsdPrice={ethUsdPrice} />
+ <EthAmountRow
+ rowLabel="Total Cost"
+ ethAmount={totalEthAmount}
+ ethUsdPrice={ethUsdPrice}
+ shouldEmphasize={true}
+ />
+ </Container>
+ );
+ }
+}
+
+export interface EthAmountRowProps {
+ rowLabel: string;
+ ethAmount?: BigNumber;
+ isEthAmountInBaseUnits?: boolean;
+ ethUsdPrice?: BigNumber;
shouldEmphasize?: boolean;
}
-export const OrderDetailsRow: React.StatelessComponent<OrderDetailsRowProps> = props => {
- const fontWeight = props.shouldEmphasize ? 700 : 400;
+export const EthAmountRow: React.StatelessComponent<EthAmountRowProps> = ({
+ rowLabel,
+ ethAmount,
+ isEthAmountInBaseUnits,
+ ethUsdPrice,
+ shouldEmphasize,
+}) => {
+ const fontWeight = shouldEmphasize ? 700 : 400;
+ const usdFormatter = isEthAmountInBaseUnits ? format.ethBaseAmountInUsd : format.ethUnitAmountInUsd;
+ const ethFormatter = isEthAmountInBaseUnits ? format.ethBaseAmount : format.ethUnitAmount;
+ const usdPriceSection = _.isUndefined(ethUsdPrice) ? null : (
+ <Container marginRight="3px" display="inline-block">
+ <Text fontColor={ColorOption.lightGrey}>({usdFormatter(ethAmount, ethUsdPrice)})</Text>
+ </Container>
+ );
return (
<Container padding="10px 0px" borderTop="1px dashed" borderColor={ColorOption.feintGrey}>
<Flex justify="space-between">
<Text fontWeight={fontWeight} fontColor={ColorOption.grey}>
- {props.name}
+ {rowLabel}
</Text>
<Container>
- <Container marginRight="3px" display="inline-block">
- <Text fontColor={ColorOption.lightGrey}>({props.secondaryValue}) </Text>
- </Container>
+ {usdPriceSection}
<Text fontWeight={fontWeight} fontColor={ColorOption.grey}>
- {props.primaryValue}
+ {ethFormatter(ethAmount)}
</Text>
</Container>
</Flex>
@@ -55,8 +92,9 @@ export const OrderDetailsRow: React.StatelessComponent<OrderDetailsRowProps> = p
);
};
-OrderDetailsRow.defaultProps = {
+EthAmountRow.defaultProps = {
shouldEmphasize: false,
+ isEthAmountInBaseUnits: true,
};
-OrderDetailsRow.displayName = 'OrderDetailsRow';
+EthAmountRow.displayName = 'EthAmountRow';
diff --git a/packages/instant/src/components/sliding_error.tsx b/packages/instant/src/components/sliding_error.tsx
index 0237fb7e9..3865a8797 100644
--- a/packages/instant/src/components/sliding_error.tsx
+++ b/packages/instant/src/components/sliding_error.tsx
@@ -2,7 +2,7 @@ import * as React from 'react';
import { ColorOption } from '../style/theme';
-import { SlideUpAndDownAnimation } from './animations/slide_up_and_down_animation';
+import { SlideDownAnimation, SlideUpAnimation } from './animations/slide_animations';
import { Container, Text } from './ui';
@@ -20,8 +20,8 @@ export const Error: React.StatelessComponent<ErrorProps> = props => (
borderRadius="6px"
marginBottom="10px"
>
- <Container marginRight="5px" display="inline">
- {props.icon}
+ <Container marginRight="5px" display="inline" top="3px" position="relative">
+ <Text fontSize="20px">{props.icon}</Text>
</Container>
<Text fontWeight="500" fontColor={ColorOption.darkOrange}>
{props.message}
@@ -29,8 +29,16 @@ export const Error: React.StatelessComponent<ErrorProps> = props => (
</Container>
);
-export const SlidingError: React.StatelessComponent<ErrorProps> = props => (
- <SlideUpAndDownAnimation downY="120px" delayMs={5000}>
- <Error icon={props.icon} message={props.message} />
- </SlideUpAndDownAnimation>
-);
+export type SlidingDirection = 'up' | 'down';
+export interface SlidingErrorProps extends ErrorProps {
+ direction: SlidingDirection;
+}
+export const SlidingError: React.StatelessComponent<SlidingErrorProps> = props => {
+ const AnimationComponent = props.direction === 'up' ? SlideUpAnimation : SlideDownAnimation;
+
+ return (
+ <AnimationComponent downY="120px">
+ <Error icon={props.icon} message={props.message} />
+ </AnimationComponent>
+ );
+};
diff --git a/packages/instant/src/components/zero_ex_instant.tsx b/packages/instant/src/components/zero_ex_instant.tsx
index 0e6230d1b..f6472e811 100644
--- a/packages/instant/src/components/zero_ex_instant.tsx
+++ b/packages/instant/src/components/zero_ex_instant.tsx
@@ -1,6 +1,7 @@
import * as React from 'react';
import { Provider } from 'react-redux';
+import { asyncData } from '../redux/async_data';
import { store } from '../redux/store';
import { fonts } from '../style/fonts';
import { theme, ThemeProvider } from '../style/theme';
@@ -8,6 +9,8 @@ import { theme, ThemeProvider } from '../style/theme';
import { ZeroExInstantContainer } from './zero_ex_instant_container';
fonts.include();
+// tslint:disable-next-line:no-floating-promises
+asyncData.fetchAndDispatchToStore();
export interface ZeroExInstantProps {}
diff --git a/packages/instant/src/components/zero_ex_instant_container.tsx b/packages/instant/src/components/zero_ex_instant_container.tsx
index a384c5f1b..cf918d890 100644
--- a/packages/instant/src/components/zero_ex_instant_container.tsx
+++ b/packages/instant/src/components/zero_ex_instant_container.tsx
@@ -1,16 +1,21 @@
import * as React from 'react';
+import { LatestBuyQuoteOrderDetails } from '../containers/latest_buy_quote_order_details';
+import { LatestError } from '../containers/latest_error';
+import { SelectedAssetBuyButton } from '../containers/selected_asset_buy_button';
+import { SelectedAssetInstantHeading } from '../containers/selected_asset_instant_heading';
+
import { ColorOption } from '../style/theme';
-import { BuyButton } from './buy_button';
-import { InstantHeading } from './instant_heading';
-import { OrderDetails } from './order_details';
import { Container, Flex } from './ui';
export interface ZeroExInstantContainerProps {}
export const ZeroExInstantContainer: React.StatelessComponent<ZeroExInstantContainerProps> = props => (
<Container width="350px">
+ <Container zIndex={1} position="relative">
+ <LatestError />
+ </Container>
<Container
zIndex={2}
position="relative"
@@ -19,9 +24,9 @@ export const ZeroExInstantContainer: React.StatelessComponent<ZeroExInstantConta
hasBoxShadow={true}
>
<Flex direction="column" justify="flex-start">
- <InstantHeading />
- <OrderDetails />
- <BuyButton />
+ <SelectedAssetInstantHeading />
+ <LatestBuyQuoteOrderDetails />
+ <SelectedAssetBuyButton />
</Flex>
</Container>
</Container>
diff --git a/packages/instant/src/constants.ts b/packages/instant/src/constants.ts
new file mode 100644
index 000000000..1fd321c5a
--- /dev/null
+++ b/packages/instant/src/constants.ts
@@ -0,0 +1,6 @@
+import { BigNumber } from '@0xproject/utils';
+export const BIG_NUMBER_ZERO = new BigNumber(0);
+export const sraApiUrl = 'https://api.radarrelay.com/0x/v2/';
+export const zrxAssetData = '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498';
+export const zrxDecimals = 18;
+export const ethDecimals = 18;
diff --git a/packages/instant/src/containers/latest_buy_quote_order_details.ts b/packages/instant/src/containers/latest_buy_quote_order_details.ts
new file mode 100644
index 000000000..b354c78fa
--- /dev/null
+++ b/packages/instant/src/containers/latest_buy_quote_order_details.ts
@@ -0,0 +1,27 @@
+import { BuyQuoteInfo } from '@0xproject/asset-buyer';
+import { BigNumber } from '@0xproject/utils';
+import * as _ from 'lodash';
+import * as React from 'react';
+import { connect } from 'react-redux';
+import { oc } from 'ts-optchain';
+
+import { State } from '../redux/reducer';
+
+import { OrderDetails } from '../components/order_details';
+
+export interface LatestBuyQuoteOrderDetailsProps {}
+
+interface ConnectedState {
+ buyQuoteInfo?: BuyQuoteInfo;
+ ethUsdPrice?: BigNumber;
+}
+
+const mapStateToProps = (state: State, _ownProps: LatestBuyQuoteOrderDetailsProps): ConnectedState => ({
+ // use the worst case quote info
+ buyQuoteInfo: oc(state).latestBuyQuote.worstCaseQuoteInfo(),
+ ethUsdPrice: state.ethUsdPrice,
+});
+
+export const LatestBuyQuoteOrderDetails: React.ComponentClass<LatestBuyQuoteOrderDetailsProps> = connect(
+ mapStateToProps,
+)(OrderDetails);
diff --git a/packages/instant/src/containers/latest_error.tsx b/packages/instant/src/containers/latest_error.tsx
new file mode 100644
index 000000000..08ea418e7
--- /dev/null
+++ b/packages/instant/src/containers/latest_error.tsx
@@ -0,0 +1,35 @@
+import * as React from 'react';
+
+import { connect } from 'react-redux';
+
+import { SlidingError } from '../components/sliding_error';
+import { LatestErrorDisplay, State } from '../redux/reducer';
+import { errorUtil } from '../util/error';
+
+export interface LatestErrorComponentProps {
+ assetData?: string;
+ latestError?: any;
+ slidingDirection: 'down' | 'up';
+}
+
+export const LatestErrorComponent: React.StatelessComponent<LatestErrorComponentProps> = props => {
+ if (!props.latestError) {
+ return <div />;
+ }
+ const { icon, message } = errorUtil.errorDescription(props.latestError, props.assetData);
+ return <SlidingError direction={props.slidingDirection} icon={icon} message={message} />;
+};
+
+interface ConnectedState {
+ assetData?: string;
+ latestError?: any;
+ slidingDirection: 'down' | 'up';
+}
+export interface LatestErrorProps {}
+const mapStateToProps = (state: State, _ownProps: LatestErrorProps): ConnectedState => ({
+ assetData: state.selectedAssetData,
+ latestError: state.latestError,
+ slidingDirection: state.latestErrorDisplay === LatestErrorDisplay.Present ? 'up' : 'down',
+});
+
+export const LatestError = connect(mapStateToProps)(LatestErrorComponent);
diff --git a/packages/instant/src/containers/selected_asset_amount_input.ts b/packages/instant/src/containers/selected_asset_amount_input.ts
new file mode 100644
index 000000000..0873f1ab6
--- /dev/null
+++ b/packages/instant/src/containers/selected_asset_amount_input.ts
@@ -0,0 +1,89 @@
+import { BuyQuote } from '@0xproject/asset-buyer';
+import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import * as _ from 'lodash';
+import * as React from 'react';
+import { connect } from 'react-redux';
+import { Dispatch } from 'redux';
+
+import { zrxDecimals } from '../constants';
+import { Action, actions } from '../redux/actions';
+import { State } from '../redux/reducer';
+import { ColorOption } from '../style/theme';
+import { AsyncProcessState } from '../types';
+import { assetBuyer } from '../util/asset_buyer';
+import { errorUtil } from '../util/error';
+
+import { AssetAmountInput } from '../components/asset_amount_input';
+
+export interface SelectedAssetAmountInputProps {
+ fontColor?: ColorOption;
+ fontSize?: string;
+}
+
+interface ConnectedState {
+ value?: BigNumber;
+ assetData?: string;
+}
+
+interface ConnectedDispatch {
+ onChange: (value?: BigNumber, assetData?: string) => void;
+}
+
+const mapStateToProps = (state: State, _ownProps: SelectedAssetAmountInputProps): ConnectedState => ({
+ value: state.selectedAssetAmount,
+ assetData: state.selectedAssetData,
+});
+
+const updateBuyQuoteAsync = async (
+ dispatch: Dispatch<Action>,
+ assetData: string,
+ assetAmount: BigNumber,
+): Promise<void> => {
+ // get a new buy quote.
+ const baseUnitValue = Web3Wrapper.toBaseUnitAmount(assetAmount, zrxDecimals);
+
+ // mark quote as pending
+ dispatch(actions.updateBuyQuoteStatePending());
+
+ let newBuyQuote: BuyQuote | undefined;
+ try {
+ newBuyQuote = await assetBuyer.getBuyQuoteAsync(assetData, baseUnitValue);
+ } catch (error) {
+ dispatch(actions.updateBuyQuoteStateFailure());
+ errorUtil.errorFlasher.flashNewError(dispatch, error);
+ return;
+ }
+ // We have a successful new buy quote
+ errorUtil.errorFlasher.clearError(dispatch);
+ // invalidate the last buy quote.
+ dispatch(actions.updateLatestBuyQuote(newBuyQuote));
+};
+
+const debouncedUpdateBuyQuoteAsync = _.debounce(updateBuyQuoteAsync, 200, { trailing: true });
+
+const mapDispatchToProps = (
+ dispatch: Dispatch<Action>,
+ _ownProps: SelectedAssetAmountInputProps,
+): ConnectedDispatch => ({
+ onChange: (value, assetData) => {
+ // Update the input
+ dispatch(actions.updateSelectedAssetAmount(value));
+ // invalidate the last buy quote.
+ dispatch(actions.updateLatestBuyQuote(undefined));
+ // reset our buy state
+ dispatch(actions.updatebuyOrderState(AsyncProcessState.NONE));
+
+ if (!_.isUndefined(value) && !_.isUndefined(assetData)) {
+ // even if it's debounced, give them the illusion it's loading
+ dispatch(actions.updateBuyQuoteStatePending());
+ // tslint:disable-next-line:no-floating-promises
+ debouncedUpdateBuyQuoteAsync(dispatch, assetData, value);
+ }
+ },
+});
+
+export const SelectedAssetAmountInput: React.ComponentClass<SelectedAssetAmountInputProps> = connect(
+ mapStateToProps,
+ mapDispatchToProps,
+)(AssetAmountInput);
diff --git a/packages/instant/src/containers/selected_asset_amount_input.tsx b/packages/instant/src/containers/selected_asset_amount_input.tsx
deleted file mode 100644
index 800a4c568..000000000
--- a/packages/instant/src/containers/selected_asset_amount_input.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import { BigNumber } from '@0xproject/utils';
-import * as React from 'react';
-import { connect } from 'react-redux';
-import { Dispatch } from 'redux';
-
-import { State } from '../redux/reducer';
-import { ColorOption } from '../style/theme';
-import { Action, ActionTypes } from '../types';
-
-import { AmountInput } from '../components/amount_input';
-
-export interface SelectedAssetAmountInputProps {
- fontColor?: ColorOption;
- fontSize?: string;
-}
-
-interface ConnectedState {
- value?: BigNumber;
-}
-
-interface ConnectedDispatch {
- onChange?: (value?: BigNumber) => void;
-}
-
-const mapStateToProps = (state: State, _ownProps: SelectedAssetAmountInputProps): ConnectedState => ({
- value: state.selectedAssetAmount,
-});
-
-const mapDispatchToProps = (dispatch: Dispatch<Action>): ConnectedDispatch => ({
- onChange: value => dispatch({ type: ActionTypes.UPDATE_SELECTED_ASSET_AMOUNT, data: value }),
-});
-
-export const SelectedAssetAmountInput: React.ComponentClass<SelectedAssetAmountInputProps> = connect(
- mapStateToProps,
- mapDispatchToProps,
-)(AmountInput);
diff --git a/packages/instant/src/containers/selected_asset_buy_button.ts b/packages/instant/src/containers/selected_asset_buy_button.ts
new file mode 100644
index 000000000..7d3919468
--- /dev/null
+++ b/packages/instant/src/containers/selected_asset_buy_button.ts
@@ -0,0 +1,55 @@
+import { BuyQuote } from '@0xproject/asset-buyer';
+import * as _ from 'lodash';
+import * as React from 'react';
+import { connect } from 'react-redux';
+import { Dispatch } from 'redux';
+
+import { Action, actions } from '../redux/actions';
+import { State } from '../redux/reducer';
+import { AsyncProcessState } from '../types';
+
+import { BuyButton } from '../components/buy_button';
+
+export interface SelectedAssetBuyButtonProps {}
+
+interface ConnectedState {
+ text: string;
+ buyQuote?: BuyQuote;
+}
+
+interface ConnectedDispatch {
+ onClick: (buyQuote: BuyQuote) => void;
+ onBuySuccess: (buyQuote: BuyQuote) => void;
+ onBuyFailure: (buyQuote: BuyQuote) => void;
+}
+
+const textForState = (state: AsyncProcessState): string => {
+ switch (state) {
+ case AsyncProcessState.NONE:
+ return 'Buy';
+ case AsyncProcessState.PENDING:
+ return '...Loading';
+ case AsyncProcessState.SUCCESS:
+ return 'Success!';
+ case AsyncProcessState.FAILURE:
+ return 'Failed';
+ default:
+ return 'Buy';
+ }
+};
+
+const mapStateToProps = (state: State, _ownProps: SelectedAssetBuyButtonProps): ConnectedState => ({
+ text: textForState(state.buyOrderState),
+ buyQuote: state.latestBuyQuote,
+});
+
+const mapDispatchToProps = (dispatch: Dispatch<Action>, ownProps: SelectedAssetBuyButtonProps): ConnectedDispatch => ({
+ onClick: buyQuote => dispatch(actions.updatebuyOrderState(AsyncProcessState.PENDING)),
+ onBuySuccess: buyQuote => dispatch(actions.updatebuyOrderState(AsyncProcessState.SUCCESS)),
+ onBuyFailure: buyQuote => dispatch(actions.updatebuyOrderState(AsyncProcessState.FAILURE)),
+});
+
+export const SelectedAssetBuyButton: React.ComponentClass<SelectedAssetBuyButtonProps> = connect(
+ mapStateToProps,
+ mapDispatchToProps,
+)(BuyButton);
diff --git a/packages/instant/src/containers/selected_asset_instant_heading.ts b/packages/instant/src/containers/selected_asset_instant_heading.ts
new file mode 100644
index 000000000..be31527f1
--- /dev/null
+++ b/packages/instant/src/containers/selected_asset_instant_heading.ts
@@ -0,0 +1,30 @@
+import { BigNumber } from '@0xproject/utils';
+import * as _ from 'lodash';
+import * as React from 'react';
+import { connect } from 'react-redux';
+import { oc } from 'ts-optchain';
+
+import { State } from '../redux/reducer';
+import { AsyncProcessState } from '../types';
+
+import { InstantHeading } from '../components/instant_heading';
+
+export interface InstantHeadingProps {}
+
+interface ConnectedState {
+ selectedAssetAmount?: BigNumber;
+ totalEthBaseAmount?: BigNumber;
+ ethUsdPrice?: BigNumber;
+ quoteState: AsyncProcessState;
+}
+
+const mapStateToProps = (state: State, _ownProps: InstantHeadingProps): ConnectedState => ({
+ selectedAssetAmount: state.selectedAssetAmount,
+ totalEthBaseAmount: oc(state).latestBuyQuote.worstCaseQuoteInfo.totalEthAmount(),
+ ethUsdPrice: state.ethUsdPrice,
+ quoteState: state.quoteState,
+});
+
+export const SelectedAssetInstantHeading: React.ComponentClass<InstantHeadingProps> = connect(mapStateToProps)(
+ InstantHeading,
+);
diff --git a/packages/instant/src/data/asset_meta_data.ts b/packages/instant/src/data/asset_meta_data.ts
new file mode 100644
index 000000000..e4d3e8f73
--- /dev/null
+++ b/packages/instant/src/data/asset_meta_data.ts
@@ -0,0 +1,15 @@
+import { AssetProxyId, ObjectMap } from '@0xproject/types';
+
+import { zrxAssetData } from '../constants';
+import { AssetMetaData } from '../types';
+
+// Map from assetData string to AssetMetaData object
+// TODO: import this from somewhere else.
+export const assetMetaData: ObjectMap<AssetMetaData> = {
+ [zrxAssetData]: {
+ assetProxyId: AssetProxyId.ERC20,
+ decimals: 18,
+ primaryColor: 'rgb(54, 50, 60)',
+ symbol: 'zrx',
+ },
+};
diff --git a/packages/instant/src/redux/actions.ts b/packages/instant/src/redux/actions.ts
new file mode 100644
index 000000000..bec847742
--- /dev/null
+++ b/packages/instant/src/redux/actions.ts
@@ -0,0 +1,46 @@
+import { BuyQuote } from '@0xproject/asset-buyer';
+import { BigNumber } from '@0xproject/utils';
+import * as _ from 'lodash';
+
+import { ActionsUnion, AsyncProcessState } from '../types';
+
+export interface PlainAction<T extends string> {
+ type: T;
+}
+
+export interface ActionWithPayload<T extends string, P> extends PlainAction<T> {
+ data: P;
+}
+
+export type Action = ActionsUnion<typeof actions>;
+
+function createAction<T extends string>(type: T): PlainAction<T>;
+function createAction<T extends string, P>(type: T, data: P): ActionWithPayload<T, P>;
+function createAction<T extends string, P>(type: T, data?: P): PlainAction<T> | ActionWithPayload<T, P> {
+ return _.isUndefined(data) ? { type } : { type, data };
+}
+
+export enum ActionTypes {
+ UPDATE_ETH_USD_PRICE = 'UPDATE_ETH_USD_PRICE',
+ UPDATE_SELECTED_ASSET_AMOUNT = 'UPDATE_SELECTED_ASSET_AMOUNT',
+ UPDATE_SELECTED_ASSET_BUY_STATE = 'UPDATE_SELECTED_ASSET_BUY_STATE',
+ UPDATE_LATEST_BUY_QUOTE = 'UPDATE_LATEST_BUY_QUOTE',
+ UPDATE_BUY_QUOTE_STATE_PENDING = 'UPDATE_BUY_QUOTE_STATE_PENDING',
+ UPDATE_BUY_QUOTE_STATE_FAILURE = 'UPDATE_BUY_QUOTE_STATE_FAILURE',
+ SET_ERROR = 'SET_ERROR',
+ HIDE_ERROR = 'HIDE_ERROR',
+ CLEAR_ERROR = 'CLEAR_ERROR',
+}
+
+export const actions = {
+ updateEthUsdPrice: (price?: BigNumber) => createAction(ActionTypes.UPDATE_ETH_USD_PRICE, price),
+ updateSelectedAssetAmount: (amount?: BigNumber) => createAction(ActionTypes.UPDATE_SELECTED_ASSET_AMOUNT, amount),
+ updatebuyOrderState: (buyState: AsyncProcessState) =>
+ createAction(ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE, buyState),
+ updateLatestBuyQuote: (buyQuote?: BuyQuote) => createAction(ActionTypes.UPDATE_LATEST_BUY_QUOTE, buyQuote),
+ updateBuyQuoteStatePending: () => createAction(ActionTypes.UPDATE_BUY_QUOTE_STATE_PENDING),
+ updateBuyQuoteStateFailure: () => createAction(ActionTypes.UPDATE_BUY_QUOTE_STATE_FAILURE),
+ setError: (error?: any) => createAction(ActionTypes.SET_ERROR, error),
+ hideError: () => createAction(ActionTypes.HIDE_ERROR),
+ clearError: () => createAction(ActionTypes.CLEAR_ERROR),
+};
diff --git a/packages/instant/src/redux/async_data.ts b/packages/instant/src/redux/async_data.ts
new file mode 100644
index 000000000..348838307
--- /dev/null
+++ b/packages/instant/src/redux/async_data.ts
@@ -0,0 +1,22 @@
+import { BIG_NUMBER_ZERO } from '../constants';
+import { coinbaseApi } from '../util/coinbase_api';
+
+import { ActionTypes } from './actions';
+
+import { store } from './store';
+
+export const asyncData = {
+ fetchAndDispatchToStore: async () => {
+ let ethUsdPrice = BIG_NUMBER_ZERO;
+ try {
+ ethUsdPrice = await coinbaseApi.getEthUsdPrice();
+ } catch (e) {
+ // ignore
+ } finally {
+ store.dispatch({
+ type: ActionTypes.UPDATE_ETH_USD_PRICE,
+ data: ethUsdPrice,
+ });
+ }
+ },
+};
diff --git a/packages/instant/src/redux/reducer.ts b/packages/instant/src/redux/reducer.ts
index 5026895ae..54290483b 100644
--- a/packages/instant/src/redux/reducer.ts
+++ b/packages/instant/src/redux/reducer.ts
@@ -1,16 +1,37 @@
+import { BuyQuote } from '@0xproject/asset-buyer';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import { Action, ActionTypes } from '../types';
+import { zrxAssetData } from '../constants';
+import { AsyncProcessState } from '../types';
+import { Action, ActionTypes } from './actions';
+
+export enum LatestErrorDisplay {
+ Present,
+ Hidden,
+}
export interface State {
- ethUsdPrice?: string;
+ selectedAssetData?: string;
selectedAssetAmount?: BigNumber;
+ buyOrderState: AsyncProcessState;
+ ethUsdPrice?: BigNumber;
+ latestBuyQuote?: BuyQuote;
+ quoteState: AsyncProcessState;
+ latestError?: any;
+ latestErrorDisplay: LatestErrorDisplay;
}
export const INITIAL_STATE: State = {
- ethUsdPrice: undefined,
+ // TODO: Remove hardcoded zrxAssetData
+ selectedAssetData: zrxAssetData,
selectedAssetAmount: undefined,
+ buyOrderState: AsyncProcessState.NONE,
+ ethUsdPrice: undefined,
+ latestBuyQuote: undefined,
+ latestError: undefined,
+ latestErrorDisplay: LatestErrorDisplay.Hidden,
+ quoteState: AsyncProcessState.NONE,
};
export const reducer = (state: State = INITIAL_STATE, action: Action): State => {
@@ -25,6 +46,46 @@ export const reducer = (state: State = INITIAL_STATE, action: Action): State =>
...state,
selectedAssetAmount: action.data,
};
+ case ActionTypes.UPDATE_LATEST_BUY_QUOTE:
+ return {
+ ...state,
+ latestBuyQuote: action.data,
+ quoteState: AsyncProcessState.SUCCESS,
+ };
+ case ActionTypes.UPDATE_BUY_QUOTE_STATE_PENDING:
+ return {
+ ...state,
+ latestBuyQuote: undefined,
+ quoteState: AsyncProcessState.PENDING,
+ };
+ case ActionTypes.UPDATE_BUY_QUOTE_STATE_FAILURE:
+ return {
+ ...state,
+ latestBuyQuote: undefined,
+ quoteState: AsyncProcessState.FAILURE,
+ };
+ case ActionTypes.UPDATE_SELECTED_ASSET_BUY_STATE:
+ return {
+ ...state,
+ buyOrderState: action.data,
+ };
+ case ActionTypes.SET_ERROR:
+ return {
+ ...state,
+ latestError: action.data,
+ latestErrorDisplay: LatestErrorDisplay.Present,
+ };
+ case ActionTypes.HIDE_ERROR:
+ return {
+ ...state,
+ latestErrorDisplay: LatestErrorDisplay.Hidden,
+ };
+ case ActionTypes.CLEAR_ERROR:
+ return {
+ ...state,
+ latestError: undefined,
+ latestErrorDisplay: LatestErrorDisplay.Hidden,
+ };
default:
return state;
}
diff --git a/packages/instant/src/redux/store.ts b/packages/instant/src/redux/store.ts
index fcd19f9a8..b9ce9c0c1 100644
--- a/packages/instant/src/redux/store.ts
+++ b/packages/instant/src/redux/store.ts
@@ -1,6 +1,7 @@
import * as _ from 'lodash';
import { createStore, Store as ReduxStore } from 'redux';
+import { devToolsEnhancer } from 'redux-devtools-extension/developmentOnly';
import { reducer, State } from './reducer';
-export const store: ReduxStore<State> = createStore(reducer);
+export const store: ReduxStore<State> = createStore(reducer, devToolsEnhancer({}));
diff --git a/packages/instant/src/types.ts b/packages/instant/src/types.ts
index d150bd8ab..f0ffb893b 100644
--- a/packages/instant/src/types.ts
+++ b/packages/instant/src/types.ts
@@ -1,9 +1,33 @@
-export enum ActionTypes {
- UPDATE_ETH_USD_PRICE,
- UPDATE_SELECTED_ASSET_AMOUNT,
+import { AssetProxyId, ObjectMap } from '@0xproject/types';
+
+// Reusable
+export enum AsyncProcessState {
+ NONE = 'None',
+ PENDING = 'Pending',
+ SUCCESS = 'Success',
+ FAILURE = 'Failure',
+}
+
+export type FunctionType = (...args: any[]) => any;
+export type ActionCreatorsMapObject = ObjectMap<FunctionType>;
+export type ActionsUnion<A extends ActionCreatorsMapObject> = ReturnType<A[keyof A]>;
+
+export interface ERC20AssetMetaData {
+ assetProxyId: AssetProxyId.ERC20;
+ decimals: number;
+ primaryColor?: string;
+ symbol: string;
}
-export interface Action {
- type: ActionTypes;
- data?: any;
+export interface ERC721AssetMetaData {
+ assetProxyId: AssetProxyId.ERC721;
+ name: string;
+ primaryColor?: string;
+}
+
+export type AssetMetaData = ERC20AssetMetaData | ERC721AssetMetaData;
+
+export enum Network {
+ Kovan = 42,
+ Mainnet = 1,
}
diff --git a/packages/instant/src/util/asset_buyer.ts b/packages/instant/src/util/asset_buyer.ts
new file mode 100644
index 000000000..27d66d600
--- /dev/null
+++ b/packages/instant/src/util/asset_buyer.ts
@@ -0,0 +1,9 @@
+import { AssetBuyer } from '@0xproject/asset-buyer';
+
+import { sraApiUrl } from '../constants';
+
+import { getProvider } from './provider';
+
+const provider = getProvider();
+
+export const assetBuyer = AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(provider, sraApiUrl);
diff --git a/packages/instant/src/util/asset_data.ts b/packages/instant/src/util/asset_data.ts
new file mode 100644
index 000000000..f7c5b78cd
--- /dev/null
+++ b/packages/instant/src/util/asset_data.ts
@@ -0,0 +1,21 @@
+import * as _ from 'lodash';
+
+import { AssetProxyId } from '@0xproject/types';
+
+import { assetMetaData } from '../data/asset_meta_data';
+
+export const assetDataUtil = {
+ bestNameForAsset: (assetData: string | undefined, defaultString: string) => {
+ if (_.isUndefined(assetData)) {
+ return defaultString;
+ }
+ const metaData = assetMetaData[assetData];
+ if (_.isUndefined(metaData)) {
+ return defaultString;
+ }
+ if (metaData.assetProxyId === AssetProxyId.ERC20) {
+ return metaData.symbol.toUpperCase();
+ }
+ return defaultString;
+ },
+};
diff --git a/packages/instant/src/util/coinbase_api.ts b/packages/instant/src/util/coinbase_api.ts
new file mode 100644
index 000000000..94a5d3c80
--- /dev/null
+++ b/packages/instant/src/util/coinbase_api.ts
@@ -0,0 +1,10 @@
+import { BigNumber } from '@0xproject/utils';
+
+const baseEndpoint = 'https://api.coinbase.com/v2';
+export const coinbaseApi = {
+ getEthUsdPrice: async (): Promise<BigNumber> => {
+ const res = await fetch(`${baseEndpoint}/prices/ETH-USD/buy`);
+ const resJson = await res.json();
+ return new BigNumber(resJson.data.amount);
+ },
+};
diff --git a/packages/instant/src/util/error.ts b/packages/instant/src/util/error.ts
new file mode 100644
index 000000000..48cb131a9
--- /dev/null
+++ b/packages/instant/src/util/error.ts
@@ -0,0 +1,62 @@
+import { AssetBuyerError } from '@0xproject/asset-buyer';
+import { Dispatch } from 'redux';
+
+import { Action, actions } from '../redux/actions';
+import { assetDataUtil } from '../util/asset_data';
+
+class ErrorFlasher {
+ private _timeoutId?: number;
+ public flashNewError(dispatch: Dispatch<Action>, error: any, delayMs: number = 7000): void {
+ this._clearTimeout();
+
+ // dispatch new message
+ dispatch(actions.setError(error));
+
+ this._timeoutId = window.setTimeout(() => {
+ dispatch(actions.hideError());
+ }, delayMs);
+ }
+ public clearError(dispatch: Dispatch<Action>): void {
+ this._clearTimeout();
+ dispatch(actions.hideError());
+ }
+ private _clearTimeout(): void {
+ if (this._timeoutId) {
+ window.clearTimeout(this._timeoutId);
+ }
+ }
+}
+
+const humanReadableMessageForError = (error: Error, assetData?: string): string | undefined => {
+ const hasInsufficientLiquidity =
+ error.message === AssetBuyerError.InsufficientAssetLiquidity ||
+ error.message === AssetBuyerError.InsufficientZrxLiquidity;
+ if (hasInsufficientLiquidity) {
+ const assetName = assetDataUtil.bestNameForAsset(assetData, 'of this asset');
+ return `Not enough ${assetName} available`;
+ }
+
+ if (
+ error.message === AssetBuyerError.StandardRelayerApiError ||
+ error.message.startsWith(AssetBuyerError.AssetUnavailable)
+ ) {
+ const assetName = assetDataUtil.bestNameForAsset(assetData, 'This asset');
+ return `${assetName} is currently unavailable`;
+ }
+
+ return undefined;
+};
+
+export const errorUtil = {
+ errorFlasher: new ErrorFlasher(),
+ errorDescription: (error?: any, assetData?: string): { icon: string; message: string } => {
+ let bestMessage: string | undefined;
+ if (error instanceof Error) {
+ bestMessage = humanReadableMessageForError(error, assetData);
+ }
+ return {
+ icon: '😢',
+ message: bestMessage || 'Something went wrong...',
+ };
+ },
+};
diff --git a/packages/instant/src/util/format.ts b/packages/instant/src/util/format.ts
new file mode 100644
index 000000000..09eb880b2
--- /dev/null
+++ b/packages/instant/src/util/format.ts
@@ -0,0 +1,53 @@
+import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import * as _ from 'lodash';
+
+import { ethDecimals } from '../constants';
+
+export const format = {
+ ethBaseAmount: (
+ ethBaseAmount?: BigNumber,
+ decimalPlaces: number = 4,
+ defaultText: React.ReactNode = '0 ETH',
+ ): React.ReactNode => {
+ if (_.isUndefined(ethBaseAmount)) {
+ return defaultText;
+ }
+ const ethUnitAmount = Web3Wrapper.toUnitAmount(ethBaseAmount, ethDecimals);
+ return format.ethUnitAmount(ethUnitAmount, decimalPlaces);
+ },
+ ethUnitAmount: (
+ ethUnitAmount?: BigNumber,
+ decimalPlaces: number = 4,
+ defaultText: React.ReactNode = '0 ETH',
+ ): React.ReactNode => {
+ if (_.isUndefined(ethUnitAmount)) {
+ return defaultText;
+ }
+ const roundedAmount = ethUnitAmount.round(decimalPlaces);
+ return `${roundedAmount} ETH`;
+ },
+ ethBaseAmountInUsd: (
+ ethBaseAmount?: BigNumber,
+ ethUsdPrice?: BigNumber,
+ decimalPlaces: number = 2,
+ defaultText: React.ReactNode = '$0.00',
+ ): React.ReactNode => {
+ if (_.isUndefined(ethBaseAmount) || _.isUndefined(ethUsdPrice)) {
+ return defaultText;
+ }
+ const ethUnitAmount = Web3Wrapper.toUnitAmount(ethBaseAmount, ethDecimals);
+ return format.ethUnitAmountInUsd(ethUnitAmount, ethUsdPrice, decimalPlaces);
+ },
+ ethUnitAmountInUsd: (
+ ethUnitAmount?: BigNumber,
+ ethUsdPrice?: BigNumber,
+ decimalPlaces: number = 2,
+ defaultText: React.ReactNode = '$0.00',
+ ): React.ReactNode => {
+ if (_.isUndefined(ethUnitAmount) || _.isUndefined(ethUsdPrice)) {
+ return defaultText;
+ }
+ return `$${ethUnitAmount.mul(ethUsdPrice).toFixed(decimalPlaces)}`;
+ },
+};
diff --git a/packages/instant/src/util/provider.ts b/packages/instant/src/util/provider.ts
new file mode 100644
index 000000000..49705fd11
--- /dev/null
+++ b/packages/instant/src/util/provider.ts
@@ -0,0 +1,12 @@
+import { Provider } from 'ethereum-types';
+
+export const getProvider = (): Provider => {
+ const injectedWeb3 = (window as any).web3 || undefined;
+ try {
+ // Use MetaMask/Mist provider
+ return injectedWeb3.currentProvider;
+ } catch (err) {
+ // Throws when user doesn't have MetaMask/Mist running
+ throw new Error(`No injected web3 found: ${err}`);
+ }
+};
diff --git a/packages/instant/src/util/util.ts b/packages/instant/src/util/util.ts
new file mode 100644
index 000000000..232a86850
--- /dev/null
+++ b/packages/instant/src/util/util.ts
@@ -0,0 +1,5 @@
+import * as _ from 'lodash';
+
+export const util = {
+ boundNoop: _.noop.bind(_),
+};
diff --git a/packages/instant/src/util/web3_wrapper.ts b/packages/instant/src/util/web3_wrapper.ts
new file mode 100644
index 000000000..d7e43521f
--- /dev/null
+++ b/packages/instant/src/util/web3_wrapper.ts
@@ -0,0 +1,5 @@
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+
+import { getProvider } from './provider';
+
+export const web3Wrapper = new Web3Wrapper(getProvider());
diff --git a/packages/instant/test/components/zero_ex_instant.test.tsx b/packages/instant/test/components/zero_ex_instant.test.tsx
index 5858732cf..e373bb002 100644
--- a/packages/instant/test/components/zero_ex_instant.test.tsx
+++ b/packages/instant/test/components/zero_ex_instant.test.tsx
@@ -4,10 +4,12 @@ import * as React from 'react';
configure({ adapter: new Adapter() });
-import { ZeroExInstant } from '../../src';
-
-describe('<ZeroExInstant />', () => {
- it('shallow renders without crashing', () => {
- shallow(<ZeroExInstant />);
+// TODO: Write non-trivial tests.
+// At time of writing we cannot render ZeroExInstant
+// because we are looking for a provider on window.
+// But in the future it will be dependency injected.
+describe('<Test />', () => {
+ it('runs a test', () => {
+ shallow(<div />);
});
});
diff --git a/packages/instant/test/util/asset_data.test.ts b/packages/instant/test/util/asset_data.test.ts
new file mode 100644
index 000000000..cf247142a
--- /dev/null
+++ b/packages/instant/test/util/asset_data.test.ts
@@ -0,0 +1,17 @@
+import { assetDataUtil } from '../../src/util/asset_data';
+
+const ZRX_ASSET_DATA = '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498';
+
+describe('assetDataUtil', () => {
+ describe('bestNameForAsset', () => {
+ it('should return default string if assetData is undefined', () => {
+ expect(assetDataUtil.bestNameForAsset(undefined, 'xyz')).toEqual('xyz');
+ });
+ it('should return default string if assetData isnt found', () => {
+ expect(assetDataUtil.bestNameForAsset('fake', 'mah default')).toEqual('mah default');
+ });
+ it('should return ZRX for ZRX assetData', () => {
+ expect(assetDataUtil.bestNameForAsset(ZRX_ASSET_DATA, 'mah default')).toEqual('ZRX');
+ });
+ });
+});
diff --git a/packages/instant/test/util/error.test.ts b/packages/instant/test/util/error.test.ts
new file mode 100644
index 000000000..56f3a1e86
--- /dev/null
+++ b/packages/instant/test/util/error.test.ts
@@ -0,0 +1,48 @@
+import { AssetBuyerError } from '@0xproject/asset-buyer';
+
+import { errorUtil } from '../../src/util/error';
+
+const ZRX_ASSET_DATA = '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498';
+
+describe('errorUtil', () => {
+ describe('errorFlasher', () => {
+ it('should return error and asset name for InsufficientAssetLiquidity', () => {
+ const insufficientAssetError = new Error(AssetBuyerError.InsufficientAssetLiquidity);
+ expect(errorUtil.errorDescription(insufficientAssetError, ZRX_ASSET_DATA).message).toEqual(
+ 'Not enough ZRX available',
+ );
+ });
+ it('should return error default name for InsufficientAssetLiquidity', () => {
+ const insufficientZrxError = new Error(AssetBuyerError.InsufficientZrxLiquidity);
+ expect(errorUtil.errorDescription(insufficientZrxError).message).toEqual(
+ 'Not enough of this asset available',
+ );
+ });
+ it('should return asset name for InsufficientAssetLiquidity', () => {
+ const insufficientZrxError = new Error(AssetBuyerError.InsufficientZrxLiquidity);
+ expect(errorUtil.errorDescription(insufficientZrxError, ZRX_ASSET_DATA).message).toEqual(
+ 'Not enough ZRX available',
+ );
+ });
+ it('should return unavailable error and asset name for StandardRelayerApiError', () => {
+ const standardRelayerError = new Error(AssetBuyerError.StandardRelayerApiError);
+ expect(errorUtil.errorDescription(standardRelayerError, ZRX_ASSET_DATA).message).toEqual(
+ 'ZRX is currently unavailable',
+ );
+ });
+ it('should return error for AssetUnavailable error', () => {
+ const assetUnavailableError = new Error(
+ `${AssetBuyerError.AssetUnavailable}: For assetData ${ZRX_ASSET_DATA}`,
+ );
+ expect(errorUtil.errorDescription(assetUnavailableError, ZRX_ASSET_DATA).message).toEqual(
+ 'ZRX is currently unavailable',
+ );
+ });
+ it('should return default for AssetUnavailable error', () => {
+ const assetUnavailableError = new Error(`${AssetBuyerError.AssetUnavailable}: For assetData xyz`);
+ expect(errorUtil.errorDescription(assetUnavailableError, 'xyz').message).toEqual(
+ 'This asset is currently unavailable',
+ );
+ });
+ });
+});
diff --git a/packages/instant/test/util/format.test.ts b/packages/instant/test/util/format.test.ts
new file mode 100644
index 000000000..073b86b19
--- /dev/null
+++ b/packages/instant/test/util/format.test.ts
@@ -0,0 +1,97 @@
+import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+
+import { ethDecimals } from '../../src/constants';
+import { format } from '../../src/util/format';
+
+const BIG_NUMBER_ONE = new BigNumber(1);
+const BIG_NUMBER_DECIMAL = new BigNumber(0.432414);
+const BIG_NUMBER_IRRATIONAL = new BigNumber(5.3014059295032);
+const ONE_ETH_IN_BASE_UNITS = Web3Wrapper.toBaseUnitAmount(BIG_NUMBER_ONE, ethDecimals);
+const DECIMAL_ETH_IN_BASE_UNITS = Web3Wrapper.toBaseUnitAmount(BIG_NUMBER_DECIMAL, ethDecimals);
+const IRRATIONAL_ETH_IN_BASE_UNITS = Web3Wrapper.toBaseUnitAmount(BIG_NUMBER_IRRATIONAL, ethDecimals);
+const BIG_NUMBER_FAKE_ETH_USD_PRICE = new BigNumber(2.534);
+
+describe('format', () => {
+ describe('ethBaseAmount', () => {
+ it('converts 1 ETH in base units to the string `1 ETH`', () => {
+ expect(format.ethBaseAmount(ONE_ETH_IN_BASE_UNITS)).toBe('1 ETH');
+ });
+ it('converts .432414 ETH in base units to the string `.4324 ETH`', () => {
+ expect(format.ethBaseAmount(DECIMAL_ETH_IN_BASE_UNITS)).toBe('0.4324 ETH');
+ });
+ it('converts 5.3014059295032 ETH in base units to the string `5.3014 ETH`', () => {
+ expect(format.ethBaseAmount(IRRATIONAL_ETH_IN_BASE_UNITS)).toBe('5.3014 ETH');
+ });
+ it('returns defaultText param when ethBaseAmount is not defined', () => {
+ const defaultText = 'defaultText';
+ expect(format.ethBaseAmount(undefined, 4, defaultText)).toBe(defaultText);
+ });
+ it('it allows for configurable decimal places', () => {
+ expect(format.ethBaseAmount(DECIMAL_ETH_IN_BASE_UNITS, 2)).toBe('0.43 ETH');
+ });
+ });
+ describe('ethUnitAmount', () => {
+ it('converts BigNumber(1) to the string `1 ETH`', () => {
+ expect(format.ethUnitAmount(BIG_NUMBER_ONE)).toBe('1 ETH');
+ });
+ it('converts BigNumer(.432414) to the string `.4324 ETH`', () => {
+ expect(format.ethUnitAmount(BIG_NUMBER_DECIMAL)).toBe('0.4324 ETH');
+ });
+ it('converts BigNumber(5.3014059295032) to the string `5.3014 ETH`', () => {
+ expect(format.ethUnitAmount(BIG_NUMBER_IRRATIONAL)).toBe('5.3014 ETH');
+ });
+ it('returns defaultText param when ethUnitAmount is not defined', () => {
+ const defaultText = 'defaultText';
+ expect(format.ethUnitAmount(undefined, 4, defaultText)).toBe(defaultText);
+ expect(format.ethUnitAmount(BIG_NUMBER_ONE, 4, defaultText)).toBe('1 ETH');
+ });
+ it('it allows for configurable decimal places', () => {
+ expect(format.ethUnitAmount(BIG_NUMBER_DECIMAL, 2)).toBe('0.43 ETH');
+ });
+ });
+ describe('ethBaseAmountInUsd', () => {
+ it('correctly formats 1 ETH to usd according to some price', () => {
+ expect(format.ethBaseAmountInUsd(ONE_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('$2.53');
+ });
+ it('correctly formats .432414 ETH to usd according to some price', () => {
+ expect(format.ethBaseAmountInUsd(DECIMAL_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('$1.10');
+ });
+ it('correctly formats 5.3014059295032 ETH to usd according to some price', () => {
+ expect(format.ethBaseAmountInUsd(IRRATIONAL_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe(
+ '$13.43',
+ );
+ });
+ it('returns defaultText param when ethBaseAmountInUsd or ethUsdPrice is not defined', () => {
+ const defaultText = 'defaultText';
+ expect(format.ethBaseAmountInUsd(undefined, undefined, 2, defaultText)).toBe(defaultText);
+ expect(format.ethBaseAmountInUsd(BIG_NUMBER_ONE, undefined, 2, defaultText)).toBe(defaultText);
+ expect(format.ethBaseAmountInUsd(undefined, BIG_NUMBER_ONE, 2, defaultText)).toBe(defaultText);
+ });
+ it('it allows for configurable decimal places', () => {
+ expect(format.ethBaseAmountInUsd(DECIMAL_ETH_IN_BASE_UNITS, BIG_NUMBER_FAKE_ETH_USD_PRICE, 4)).toBe(
+ '$1.0957',
+ );
+ });
+ });
+ describe('ethUnitAmountInUsd', () => {
+ it('correctly formats 1 ETH to usd according to some price', () => {
+ expect(format.ethUnitAmountInUsd(BIG_NUMBER_ONE, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('$2.53');
+ });
+ it('correctly formats .432414 ETH to usd according to some price', () => {
+ expect(format.ethUnitAmountInUsd(BIG_NUMBER_DECIMAL, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('$1.10');
+ });
+ it('correctly formats 5.3014059295032 ETH to usd according to some price', () => {
+ expect(format.ethUnitAmountInUsd(BIG_NUMBER_IRRATIONAL, BIG_NUMBER_FAKE_ETH_USD_PRICE)).toBe('$13.43');
+ });
+ it('returns defaultText param when ethUnitAmountInUsd or ethUsdPrice is not defined', () => {
+ const defaultText = 'defaultText';
+ expect(format.ethUnitAmountInUsd(undefined, undefined, 2, defaultText)).toBe(defaultText);
+ expect(format.ethUnitAmountInUsd(BIG_NUMBER_ONE, undefined, 2, defaultText)).toBe(defaultText);
+ expect(format.ethUnitAmountInUsd(undefined, BIG_NUMBER_ONE, 2, defaultText)).toBe(defaultText);
+ });
+ it('it allows for configurable decimal places', () => {
+ expect(format.ethUnitAmountInUsd(BIG_NUMBER_DECIMAL, BIG_NUMBER_FAKE_ETH_USD_PRICE, 4)).toBe('$1.0957');
+ });
+ });
+});
diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json
index 53d929901..08e74b6db 100644
--- a/packages/json-schemas/CHANGELOG.json
+++ b/packages/json-schemas/CHANGELOG.json
@@ -1,5 +1,15 @@
[
{
+ "version": "2.0.0",
+ "changes": [
+ {
+ "note":
+ "Convert all schemas to JSON files so that they can be used with `json-schema` implemenations in other programming languages.",
+ "pr": 1145
+ }
+ ]
+ },
+ {
"timestamp": 1538693146,
"version": "1.0.7",
"changes": [
diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json
index 38dee306d..20d2e48ce 100644
--- a/packages/json-schemas/package.json
+++ b/packages/json-schemas/package.json
@@ -10,7 +10,7 @@
"scripts": {
"build": "tsc -b",
"build:ci": "yarn build",
- "lint": "tslint --project .",
+ "lint": "tslint --project . --exclude **/schemas/**/*",
"test": "yarn run_mocha",
"rebuild_and_test": "run-s clean build test",
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
@@ -59,7 +59,7 @@
"nyc": "^11.0.1",
"shx": "^0.2.2",
"tslint": "5.11.0",
- "typedoc": "0.12.0",
+ "typedoc": "0.13.0",
"typescript": "3.0.1"
},
"publishConfig": {
diff --git a/packages/json-schemas/schemas/address_schema.json b/packages/json-schemas/schemas/address_schema.json
new file mode 100644
index 000000000..0dc02d331
--- /dev/null
+++ b/packages/json-schemas/schemas/address_schema.json
@@ -0,0 +1,5 @@
+{
+ "id": "/addressSchema",
+ "type": "string",
+ "pattern": "^0x[0-9a-f]{40}$"
+}
diff --git a/packages/json-schemas/schemas/basic_type_schemas.ts b/packages/json-schemas/schemas/basic_type_schemas.ts
deleted file mode 100644
index a59afaef8..000000000
--- a/packages/json-schemas/schemas/basic_type_schemas.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-export const addressSchema = {
- id: '/addressSchema',
- type: 'string',
- pattern: '^0x[0-9a-f]{40}$',
-};
-
-export const hexSchema = {
- id: '/hexSchema',
- type: 'string',
- pattern: '^0x(([0-9a-f][0-9a-f])+)?$',
-};
-
-export const numberSchema = {
- id: '/numberSchema',
- type: 'string',
- pattern: '^\\d+(\\.\\d+)?$',
-};
diff --git a/packages/json-schemas/schemas/block_param_schema.json b/packages/json-schemas/schemas/block_param_schema.json
new file mode 100644
index 000000000..ed4dd1e87
--- /dev/null
+++ b/packages/json-schemas/schemas/block_param_schema.json
@@ -0,0 +1,11 @@
+{
+ "id": "/blockParamSchema",
+ "oneOf": [
+ {
+ "type": "number"
+ },
+ {
+ "enum": ["latest", "earliest", "pending"]
+ }
+ ]
+}
diff --git a/packages/json-schemas/schemas/block_range_schema.json b/packages/json-schemas/schemas/block_range_schema.json
new file mode 100644
index 000000000..b14294649
--- /dev/null
+++ b/packages/json-schemas/schemas/block_range_schema.json
@@ -0,0 +1,8 @@
+{
+ "id": "/blockRangeSchema",
+ "properties": {
+ "fromBlock": { "$ref": "/blockParamSchema" },
+ "toBlock": { "$ref": "/blockParamSchema" }
+ },
+ "type": "object"
+}
diff --git a/packages/json-schemas/schemas/block_range_schema.ts b/packages/json-schemas/schemas/block_range_schema.ts
deleted file mode 100644
index 9eb242fc6..000000000
--- a/packages/json-schemas/schemas/block_range_schema.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-export const blockParamSchema = {
- id: '/blockParamSchema',
- oneOf: [
- {
- type: 'number',
- },
- {
- enum: ['latest', 'earliest', 'pending'],
- },
- ],
-};
-
-export const blockRangeSchema = {
- id: '/blockRangeSchema',
- properties: {
- fromBlock: { $ref: '/blockParamSchema' },
- toBlock: { $ref: '/blockParamSchema' },
- },
- type: 'object',
-};
diff --git a/packages/json-schemas/schemas/call_data_schema.json b/packages/json-schemas/schemas/call_data_schema.json
new file mode 100644
index 000000000..c5972e8c1
--- /dev/null
+++ b/packages/json-schemas/schemas/call_data_schema.json
@@ -0,0 +1,27 @@
+{
+ "id": "/callDataSchema",
+ "properties": {
+ "from": { "$ref": "/addressSchema" },
+ "to": { "$ref": "/addressSchema" },
+ "value": {
+ "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }]
+ },
+ "gas": {
+ "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }]
+ },
+ "gasPrice": {
+ "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }]
+ },
+ "data": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+ },
+ "nonce": {
+ "type": "number",
+ "minimum": 0
+ }
+ },
+ "required": [],
+ "type": "object",
+ "additionalProperties": false
+}
diff --git a/packages/json-schemas/schemas/call_data_schema.ts b/packages/json-schemas/schemas/call_data_schema.ts
deleted file mode 100644
index 4c77d9f9d..000000000
--- a/packages/json-schemas/schemas/call_data_schema.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-export const callDataSchema = {
- id: '/callDataSchema',
- properties: {
- from: { $ref: '/addressSchema' },
- to: { $ref: '/addressSchema' },
- value: {
- oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }],
- },
- gas: {
- oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }],
- },
- gasPrice: {
- oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }],
- },
- data: {
- type: 'string',
- pattern: '^0x[0-9a-f]*$',
- },
- nonce: {
- type: 'number',
- minimum: 0,
- },
- },
- required: [],
- type: 'object',
- additionalProperties: false,
-};
diff --git a/packages/json-schemas/schemas/ec_signature_parameter_schema.json b/packages/json-schemas/schemas/ec_signature_parameter_schema.json
new file mode 100644
index 000000000..0c08ec240
--- /dev/null
+++ b/packages/json-schemas/schemas/ec_signature_parameter_schema.json
@@ -0,0 +1,5 @@
+{
+ "id": "/ecSignatureParameterSchema",
+ "type": "string",
+ "pattern": "^0[xX][0-9A-Fa-f]{64}$"
+}
diff --git a/packages/json-schemas/schemas/ec_signature_schema.json b/packages/json-schemas/schemas/ec_signature_schema.json
new file mode 100644
index 000000000..bc79ca5e9
--- /dev/null
+++ b/packages/json-schemas/schemas/ec_signature_schema.json
@@ -0,0 +1,14 @@
+{
+ "id": "/ECSignature",
+ "properties": {
+ "v": {
+ "type": "number",
+ "minimum": 27,
+ "maximum": 28
+ },
+ "r": { "$ref": "/ecSignatureParameterSchema" },
+ "s": { "$ref": "/ecSignatureParameterSchema" }
+ },
+ "required": ["v", "r", "s"],
+ "type": "object"
+}
diff --git a/packages/json-schemas/schemas/ec_signature_schema.ts b/packages/json-schemas/schemas/ec_signature_schema.ts
deleted file mode 100644
index c59532f09..000000000
--- a/packages/json-schemas/schemas/ec_signature_schema.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-export const ecSignatureParameterSchema = {
- id: '/ecSignatureParameterSchema',
- type: 'string',
- pattern: '^0[xX][0-9A-Fa-f]{64}$',
-};
-
-export const ecSignatureSchema = {
- id: '/ECSignature',
- properties: {
- v: {
- type: 'number',
- minimum: 27,
- maximum: 28,
- },
- r: { $ref: '/ecSignatureParameterSchema' },
- s: { $ref: '/ecSignatureParameterSchema' },
- },
- required: ['v', 'r', 's'],
- type: 'object',
-};
diff --git a/packages/json-schemas/schemas/eip712_typed_data.ts b/packages/json-schemas/schemas/eip712_typed_data.ts
deleted file mode 100644
index 31ad74610..000000000
--- a/packages/json-schemas/schemas/eip712_typed_data.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-export const eip712TypedDataSchema = {
- id: '/eip712TypedData',
- type: 'object',
- properties: {
- types: {
- type: 'object',
- properties: {
- EIP712Domain: { type: 'array' },
- },
- additionalProperties: {
- type: 'array',
- items: {
- type: 'object',
- properties: {
- name: { type: 'string' },
- type: { type: 'string' },
- },
- required: ['name', 'type'],
- },
- },
- required: ['EIP712Domain'],
- },
- primaryType: { type: 'string' },
- domain: { type: 'object' },
- message: { type: 'object' },
- },
- required: ['types', 'primaryType', 'domain', 'message'],
-};
diff --git a/packages/json-schemas/schemas/eip712_typed_data_schema.json b/packages/json-schemas/schemas/eip712_typed_data_schema.json
new file mode 100644
index 000000000..8efd6de44
--- /dev/null
+++ b/packages/json-schemas/schemas/eip712_typed_data_schema.json
@@ -0,0 +1,28 @@
+{
+ "id": "/eip712TypedDataSchema",
+ "type": "object",
+ "properties": {
+ "types": {
+ "type": "object",
+ "properties": {
+ "EIP712Domain": { "type": "array" }
+ },
+ "additionalProperties": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": { "type": "string" },
+ "type": { "type": "string" }
+ },
+ "required": ["name", "type"]
+ }
+ },
+ "required": ["EIP712Domain"]
+ },
+ "primaryType": { "type": "string" },
+ "domain": { "type": "object" },
+ "message": { "type": "object" }
+ },
+ "required": ["types", "primaryType", "domain", "message"]
+}
diff --git a/packages/json-schemas/schemas/hex_schema.json b/packages/json-schemas/schemas/hex_schema.json
new file mode 100644
index 000000000..f37815d5b
--- /dev/null
+++ b/packages/json-schemas/schemas/hex_schema.json
@@ -0,0 +1,5 @@
+{
+ "id": "/hexSchema",
+ "type": "string",
+ "pattern": "^0x(([0-9a-f][0-9a-f])+)?$"
+}
diff --git a/packages/json-schemas/schemas/index_filter_values_schema.json b/packages/json-schemas/schemas/index_filter_values_schema.json
new file mode 100644
index 000000000..bec00d79e
--- /dev/null
+++ b/packages/json-schemas/schemas/index_filter_values_schema.json
@@ -0,0 +1,7 @@
+{
+ "id": "/indexFilterValuesSchema",
+ "additionalProperties": {
+ "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/addressSchema" }, { "$ref": "/orderHashSchema" }]
+ },
+ "type": "object"
+}
diff --git a/packages/json-schemas/schemas/index_filter_values_schema.ts b/packages/json-schemas/schemas/index_filter_values_schema.ts
deleted file mode 100644
index f3c8cef68..000000000
--- a/packages/json-schemas/schemas/index_filter_values_schema.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-export const indexFilterValuesSchema = {
- id: '/indexFilterValuesSchema',
- additionalProperties: {
- oneOf: [{ $ref: '/numberSchema' }, { $ref: '/addressSchema' }, { $ref: '/orderHashSchema' }],
- },
- type: 'object',
-};
diff --git a/packages/json-schemas/schemas/js_number.json b/packages/json-schemas/schemas/js_number.json
new file mode 100644
index 000000000..6a72d92c0
--- /dev/null
+++ b/packages/json-schemas/schemas/js_number.json
@@ -0,0 +1,5 @@
+{
+ "id": "/jsNumber",
+ "type": "number",
+ "minimum": 0
+}
diff --git a/packages/json-schemas/schemas/number_schema.json b/packages/json-schemas/schemas/number_schema.json
new file mode 100644
index 000000000..a48f3e8cf
--- /dev/null
+++ b/packages/json-schemas/schemas/number_schema.json
@@ -0,0 +1,5 @@
+{
+ "id": "/numberSchema",
+ "type": "string",
+ "pattern": "^\\d+(\\.\\d+)?$"
+}
diff --git a/packages/json-schemas/schemas/order_cancel_schema.json b/packages/json-schemas/schemas/order_cancel_schema.json
new file mode 100644
index 000000000..09d4068c6
--- /dev/null
+++ b/packages/json-schemas/schemas/order_cancel_schema.json
@@ -0,0 +1,12 @@
+{
+ "id": "/orderCancellationRequestsSchema",
+ "type": "array",
+ "items": {
+ "properties": {
+ "order": { "$ref": "/orderSchema" },
+ "takerTokenCancelAmount": { "$ref": "/numberSchema" }
+ },
+ "required": ["order", "takerTokenCancelAmount"],
+ "type": "object"
+ }
+}
diff --git a/packages/json-schemas/schemas/order_cancel_schema.ts b/packages/json-schemas/schemas/order_cancel_schema.ts
deleted file mode 100644
index e4edfbca9..000000000
--- a/packages/json-schemas/schemas/order_cancel_schema.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export const orderCancellationRequestsSchema = {
- id: '/orderCancellationRequestsSchema',
- type: 'array',
- items: {
- properties: {
- order: { $ref: '/orderSchema' },
- takerTokenCancelAmount: { $ref: '/numberSchema' },
- },
- required: ['order', 'takerTokenCancelAmount'],
- type: 'object',
- },
-};
diff --git a/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.json b/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.json
new file mode 100644
index 000000000..c9549c72e
--- /dev/null
+++ b/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.json
@@ -0,0 +1,12 @@
+{
+ "id": "/orderFillOrKillRequestsSchema",
+ "type": "array",
+ "items": {
+ "properties": {
+ "signedOrder": { "$ref": "/signedOrderSchema" },
+ "fillTakerAmount": { "$ref": "/numberSchema" }
+ },
+ "required": ["signedOrder", "fillTakerAmount"],
+ "type": "object"
+ }
+}
diff --git a/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts b/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts
deleted file mode 100644
index e2c18ef0a..000000000
--- a/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export const orderFillOrKillRequestsSchema = {
- id: '/orderFillOrKillRequestsSchema',
- type: 'array',
- items: {
- properties: {
- signedOrder: { $ref: '/signedOrderSchema' },
- fillTakerAmount: { $ref: '/numberSchema' },
- },
- required: ['signedOrder', 'fillTakerAmount'],
- type: 'object',
- },
-};
diff --git a/packages/json-schemas/schemas/order_fill_requests_schema.json b/packages/json-schemas/schemas/order_fill_requests_schema.json
new file mode 100644
index 000000000..98325653b
--- /dev/null
+++ b/packages/json-schemas/schemas/order_fill_requests_schema.json
@@ -0,0 +1,12 @@
+{
+ "id": "/orderFillRequestsSchema",
+ "type": "array",
+ "items": {
+ "properties": {
+ "signedOrder": { "$ref": "/signedOrderSchema" },
+ "takerTokenFillAmount": { "$ref": "/numberSchema" }
+ },
+ "required": ["signedOrder", "takerTokenFillAmount"],
+ "type": "object"
+ }
+}
diff --git a/packages/json-schemas/schemas/order_fill_requests_schema.ts b/packages/json-schemas/schemas/order_fill_requests_schema.ts
deleted file mode 100644
index ea8b35e54..000000000
--- a/packages/json-schemas/schemas/order_fill_requests_schema.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export const orderFillRequestsSchema = {
- id: '/orderFillRequestsSchema',
- type: 'array',
- items: {
- properties: {
- signedOrder: { $ref: '/signedOrderSchema' },
- takerTokenFillAmount: { $ref: '/numberSchema' },
- },
- required: ['signedOrder', 'takerTokenFillAmount'],
- type: 'object',
- },
-};
diff --git a/packages/json-schemas/schemas/order_hash_schema.json b/packages/json-schemas/schemas/order_hash_schema.json
new file mode 100644
index 000000000..4a770579f
--- /dev/null
+++ b/packages/json-schemas/schemas/order_hash_schema.json
@@ -0,0 +1,5 @@
+{
+ "id": "/orderHashSchema",
+ "type": "string",
+ "pattern": "^0x[0-9a-fA-F]{64}$"
+}
diff --git a/packages/json-schemas/schemas/order_hash_schema.ts b/packages/json-schemas/schemas/order_hash_schema.ts
deleted file mode 100644
index 9773a88f9..000000000
--- a/packages/json-schemas/schemas/order_hash_schema.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export const orderHashSchema = {
- id: '/orderHashSchema',
- type: 'string',
- pattern: '^0x[0-9a-fA-F]{64}$',
-};
diff --git a/packages/json-schemas/schemas/order_schema.json b/packages/json-schemas/schemas/order_schema.json
new file mode 100644
index 000000000..de2c8c7c2
--- /dev/null
+++ b/packages/json-schemas/schemas/order_schema.json
@@ -0,0 +1,34 @@
+{
+ "id": "/orderSchema",
+ "properties": {
+ "makerAddress": { "$ref": "/addressSchema" },
+ "takerAddress": { "$ref": "/addressSchema" },
+ "makerFee": { "$ref": "/numberSchema" },
+ "takerFee": { "$ref": "/numberSchema" },
+ "senderAddress": { "$ref": "/addressSchema" },
+ "makerAssetAmount": { "$ref": "/numberSchema" },
+ "takerAssetAmount": { "$ref": "/numberSchema" },
+ "makerAssetData": { "$ref": "/hexSchema" },
+ "takerAssetData": { "$ref": "/hexSchema" },
+ "salt": { "$ref": "/numberSchema" },
+ "exchangeAddress": { "$ref": "/addressSchema" },
+ "feeRecipientAddress": { "$ref": "/addressSchema" },
+ "expirationTimeSeconds": { "$ref": "/numberSchema" }
+ },
+ "required": [
+ "makerAddress",
+ "takerAddress",
+ "makerFee",
+ "takerFee",
+ "senderAddress",
+ "makerAssetAmount",
+ "takerAssetAmount",
+ "makerAssetData",
+ "takerAssetData",
+ "salt",
+ "exchangeAddress",
+ "feeRecipientAddress",
+ "expirationTimeSeconds"
+ ],
+ "type": "object"
+}
diff --git a/packages/json-schemas/schemas/order_schemas.ts b/packages/json-schemas/schemas/order_schemas.ts
deleted file mode 100644
index eb7fdaf5a..000000000
--- a/packages/json-schemas/schemas/order_schemas.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-export const orderSchema = {
- id: '/orderSchema',
- properties: {
- makerAddress: { $ref: '/addressSchema' },
- takerAddress: { $ref: '/addressSchema' },
- makerFee: { $ref: '/numberSchema' },
- takerFee: { $ref: '/numberSchema' },
- senderAddress: { $ref: '/addressSchema' },
- makerAssetAmount: { $ref: '/numberSchema' },
- takerAssetAmount: { $ref: '/numberSchema' },
- makerAssetData: { $ref: '/hexSchema' },
- takerAssetData: { $ref: '/hexSchema' },
- salt: { $ref: '/numberSchema' },
- exchangeAddress: { $ref: '/addressSchema' },
- feeRecipientAddress: { $ref: '/addressSchema' },
- expirationTimeSeconds: { $ref: '/numberSchema' },
- },
- required: [
- 'makerAddress',
- 'takerAddress',
- 'makerFee',
- 'takerFee',
- 'senderAddress',
- 'makerAssetAmount',
- 'takerAssetAmount',
- 'makerAssetData',
- 'takerAssetData',
- 'salt',
- 'exchangeAddress',
- 'feeRecipientAddress',
- 'expirationTimeSeconds',
- ],
- type: 'object',
-};
-
-export const signedOrderSchema = {
- id: '/signedOrderSchema',
- allOf: [
- { $ref: '/orderSchema' },
- {
- properties: {
- signature: { $ref: '/hexSchema' },
- },
- required: ['signature'],
- },
- ],
-};
diff --git a/packages/json-schemas/schemas/orders_schema.json b/packages/json-schemas/schemas/orders_schema.json
new file mode 100644
index 000000000..1e1c6a875
--- /dev/null
+++ b/packages/json-schemas/schemas/orders_schema.json
@@ -0,0 +1,5 @@
+{
+ "id": "/ordersSchema",
+ "type": "array",
+ "items": { "$ref": "/orderSchema" }
+}
diff --git a/packages/json-schemas/schemas/orders_schema.ts b/packages/json-schemas/schemas/orders_schema.ts
deleted file mode 100644
index de0abcf00..000000000
--- a/packages/json-schemas/schemas/orders_schema.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export const ordersSchema = {
- id: '/ordersSchema',
- type: 'array',
- items: { $ref: '/orderSchema' },
-};
diff --git a/packages/json-schemas/schemas/paginated_collection_schema.json b/packages/json-schemas/schemas/paginated_collection_schema.json
new file mode 100644
index 000000000..9dcedf5b4
--- /dev/null
+++ b/packages/json-schemas/schemas/paginated_collection_schema.json
@@ -0,0 +1,10 @@
+{
+ "id": "/paginatedCollectionSchema",
+ "type": "object",
+ "properties": {
+ "total": { "type": "number" },
+ "perPage": { "type": "number" },
+ "page": { "type": "number" }
+ },
+ "required": ["total", "perPage", "page"]
+}
diff --git a/packages/json-schemas/schemas/paginated_collection_schema.ts b/packages/json-schemas/schemas/paginated_collection_schema.ts
deleted file mode 100644
index 16044c70a..000000000
--- a/packages/json-schemas/schemas/paginated_collection_schema.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-export const paginatedCollectionSchema = {
- id: '/paginatedCollectionSchema',
- type: 'object',
- properties: {
- total: { type: 'number' },
- perPage: { type: 'number' },
- page: { type: 'number' },
- },
- required: ['total', 'perPage', 'page'],
-};
diff --git a/packages/json-schemas/schemas/relayer_api_asset_data_pairs_response_schema.json b/packages/json-schemas/schemas/relayer_api_asset_data_pairs_response_schema.json
new file mode 100644
index 000000000..d1150d3db
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_asset_data_pairs_response_schema.json
@@ -0,0 +1,13 @@
+{
+ "id": "/relayerApiAssetDataPairsResponseSchema",
+ "type": "object",
+ "allOf": [
+ { "$ref": "/paginatedCollectionSchema" },
+ {
+ "properties": {
+ "records": { "$ref": "/relayerApiAssetDataPairsSchema" }
+ },
+ "required": ["records"]
+ }
+ ]
+}
diff --git a/packages/json-schemas/schemas/relayer_api_asset_data_pairs_schema.json b/packages/json-schemas/schemas/relayer_api_asset_data_pairs_schema.json
new file mode 100644
index 000000000..62d4745b8
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_asset_data_pairs_schema.json
@@ -0,0 +1,12 @@
+{
+ "id": "/relayerApiAssetDataPairsSchema",
+ "type": "array",
+ "items": {
+ "properties": {
+ "assetDataA": { "$ref": "/relayerApiAssetDataTradeInfoSchema" },
+ "assetDataB": { "$ref": "/relayerApiAssetDataTradeInfoSchema" }
+ },
+ "required": ["assetDataA", "assetDataB"],
+ "type": "object"
+ }
+}
diff --git a/packages/json-schemas/schemas/relayer_api_asset_data_trade_info_schema.json b/packages/json-schemas/schemas/relayer_api_asset_data_trade_info_schema.json
new file mode 100644
index 000000000..0ab9b444f
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_asset_data_trade_info_schema.json
@@ -0,0 +1,11 @@
+{
+ "id": "/relayerApiAssetDataTradeInfoSchema",
+ "type": "object",
+ "properties": {
+ "assetData": { "$ref": "/hexSchema" },
+ "minAmount": { "$ref": "/numberSchema" },
+ "maxAmount": { "$ref": "/numberSchema" },
+ "precision": { "type": "number" }
+ },
+ "required": ["assetData"]
+}
diff --git a/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts b/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts
deleted file mode 100644
index c13396d29..000000000
--- a/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-export const relayerApiAssetDataPairsResponseSchema = {
- id: '/relayerApiAssetDataPairsResponseSchema',
- type: 'object',
- allOf: [
- { $ref: '/paginatedCollectionSchema' },
- {
- properties: {
- records: { $ref: '/relayerApiAssetDataPairsSchema' },
- },
- required: ['records'],
- },
- ],
-};
-
-export const relayerApiAssetDataPairsSchema = {
- id: '/relayerApiAssetDataPairsSchema',
- type: 'array',
- items: {
- properties: {
- assetDataA: { $ref: '/relayerApiAssetDataTradeInfoSchema' },
- assetDataB: { $ref: '/relayerApiAssetDataTradeInfoSchema' },
- },
- required: ['assetDataA', 'assetDataB'],
- type: 'object',
- },
-};
-
-export const relayerApiAssetDataTradeInfoSchema = {
- id: '/relayerApiAssetDataTradeInfoSchema',
- type: 'object',
- properties: {
- assetData: { $ref: '/hexSchema' },
- minAmount: { $ref: '/numberSchema' },
- maxAmount: { $ref: '/numberSchema' },
- precision: { type: 'number' },
- },
- required: ['assetData'],
-};
diff --git a/packages/json-schemas/schemas/relayer_api_error_response_schema.json b/packages/json-schemas/schemas/relayer_api_error_response_schema.json
new file mode 100644
index 000000000..be4659b0b
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_error_response_schema.json
@@ -0,0 +1,21 @@
+{
+ "id": "/relayerApiErrorResponseSchema",
+ "type": "object",
+ "properties": {
+ "code": { "type": "integer", "minimum": 100, "maximum": 103 },
+ "reason": { "type": "string" },
+ "validationErrors": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "field": { "type": "string" },
+ "code": { "type": "integer", "minimum": 1000, "maximum": 1006 },
+ "reason": { "type": "string" }
+ },
+ "required": ["field", "code", "reason"]
+ }
+ }
+ },
+ "required": ["code", "reason"]
+}
diff --git a/packages/json-schemas/schemas/relayer_api_error_response_schema.ts b/packages/json-schemas/schemas/relayer_api_error_response_schema.ts
deleted file mode 100644
index 79e33fc85..000000000
--- a/packages/json-schemas/schemas/relayer_api_error_response_schema.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-export const relayerApiErrorResponseSchema = {
- id: '/relayerApiErrorResponseSchema',
- type: 'object',
- properties: {
- code: { type: 'integer', minimum: 100, maximum: 103 },
- reason: { type: 'string' },
- validationErrors: {
- type: 'array',
- items: {
- type: 'object',
- properties: {
- field: { type: 'string' },
- code: { type: 'integer', minimum: 1000, maximum: 1006 },
- reason: { type: 'string' },
- },
- required: ['field', 'code', 'reason'],
- },
- },
- },
- required: ['code', 'reason'],
-};
diff --git a/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.json b/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.json
new file mode 100644
index 000000000..c73506dbb
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.json
@@ -0,0 +1,16 @@
+{
+ "id": "/relayerApiFeeRecipientsResponseSchema",
+ "type": "object",
+ "allOf": [
+ { "$ref": "/paginatedCollectionSchema" },
+ {
+ "properties": {
+ "records": {
+ "type": "array",
+ "items": { "$ref": "/addressSchema" }
+ }
+ },
+ "required": ["records"]
+ }
+ ]
+}
diff --git a/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.ts b/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.ts
deleted file mode 100644
index 5f6bc0530..000000000
--- a/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-export const relayerApiFeeRecipientsResponseSchema = {
- id: '/relayerApiFeeRecipientsResponseSchema',
- type: 'object',
- allOf: [
- { $ref: '/paginatedCollectionSchema' },
- {
- properties: {
- records: {
- type: 'array',
- items: { $ref: '/addressSchema' },
- },
- },
- required: ['records'],
- },
- ],
-};
diff --git a/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.json b/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.json
new file mode 100644
index 000000000..bc95b61ef
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.json
@@ -0,0 +1,24 @@
+{
+ "id": "/relayerApiOrderConfigPayloadSchema",
+ "type": "object",
+ "properties": {
+ "makerAddress": { "$ref": "/addressSchema" },
+ "takerAddress": { "$ref": "/addressSchema" },
+ "makerAssetAmount": { "$ref": "/numberSchema" },
+ "takerAssetAmount": { "$ref": "/numberSchema" },
+ "makerAssetData": { "$ref": "/hexSchema" },
+ "takerAssetData": { "$ref": "/hexSchema" },
+ "exchangeAddress": { "$ref": "/addressSchema" },
+ "expirationTimeSeconds": { "$ref": "/numberSchema" }
+ },
+ "required": [
+ "makerAddress",
+ "takerAddress",
+ "makerAssetAmount",
+ "takerAssetAmount",
+ "makerAssetData",
+ "takerAssetData",
+ "exchangeAddress",
+ "expirationTimeSeconds"
+ ]
+}
diff --git a/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts b/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts
deleted file mode 100644
index 8d1d408d6..000000000
--- a/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-export const relayerApiOrderConfigPayloadSchema = {
- id: '/relayerApiOrderConfigPayloadSchema',
- type: 'object',
- properties: {
- makerAddress: { $ref: '/addressSchema' },
- takerAddress: { $ref: '/addressSchema' },
- makerAssetAmount: { $ref: '/numberSchema' },
- takerAssetAmount: { $ref: '/numberSchema' },
- makerAssetData: { $ref: '/hexSchema' },
- takerAssetData: { $ref: '/hexSchema' },
- exchangeAddress: { $ref: '/addressSchema' },
- expirationTimeSeconds: { $ref: '/numberSchema' },
- },
- required: [
- 'makerAddress',
- 'takerAddress',
- 'makerAssetAmount',
- 'takerAssetAmount',
- 'makerAssetData',
- 'takerAssetData',
- 'exchangeAddress',
- 'expirationTimeSeconds',
- ],
-};
diff --git a/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json b/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json
new file mode 100644
index 000000000..0742febdf
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json
@@ -0,0 +1,11 @@
+{
+ "id": "/relayerApiOrderConfigResponseSchema",
+ "type": "object",
+ "properties": {
+ "makerFee": { "$ref": "/numberSchema" },
+ "takerFee": { "$ref": "/numberSchema" },
+ "feeRecipientAddress": { "$ref": "/addressSchema" },
+ "senderAddress": { "$ref": "/addressSchema" }
+ },
+ "required": ["makerFee", "takerFee", "feeRecipientAddress", "senderAddress"]
+}
diff --git a/packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts b/packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts
deleted file mode 100644
index 390d0b262..000000000
--- a/packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-export const relayerApiOrderConfigResponseSchema = {
- id: '/relayerApiOrderConfigResponseSchema',
- type: 'object',
- properties: {
- makerFee: { $ref: '/numberSchema' },
- takerFee: { $ref: '/numberSchema' },
- feeRecipientAddress: { $ref: '/addressSchema' },
- senderAddress: { $ref: '/addressSchema' },
- },
- required: ['makerFee', 'takerFee', 'feeRecipientAddress', 'senderAddress'],
-};
diff --git a/packages/json-schemas/schemas/relayer_api_order_schema.json b/packages/json-schemas/schemas/relayer_api_order_schema.json
new file mode 100644
index 000000000..e0f6539b9
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_order_schema.json
@@ -0,0 +1,9 @@
+{
+ "id": "/relayerApiOrderSchema",
+ "type": "object",
+ "properties": {
+ "order": { "$ref": "/orderSchema" },
+ "metaData": { "type": "object" }
+ },
+ "required": ["order", "metaData"]
+}
diff --git a/packages/json-schemas/schemas/relayer_api_order_schema.ts b/packages/json-schemas/schemas/relayer_api_order_schema.ts
deleted file mode 100644
index 3952e9683..000000000
--- a/packages/json-schemas/schemas/relayer_api_order_schema.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export const relayerApiOrderSchema = {
- id: '/relayerApiOrderSchema',
- type: 'object',
- properties: {
- order: { $ref: '/orderSchema' },
- metaData: { type: 'object' },
- },
- required: ['order', 'metaData'],
-};
diff --git a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.json b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.json
new file mode 100644
index 000000000..b44f2a740
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.json
@@ -0,0 +1,9 @@
+{
+ "id": "/relayerApiOrderbookResponseSchema",
+ "type": "object",
+ "properties": {
+ "bids": { "$ref": "/relayerApiOrdersResponseSchema" },
+ "asks": { "$ref": "/relayerApiOrdersResponseSchema" }
+ },
+ "required": ["bids", "asks"]
+}
diff --git a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts
deleted file mode 100644
index 7c0b8e0df..000000000
--- a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export const relayerApiOrderbookResponseSchema = {
- id: '/relayerApiOrderbookResponseSchema',
- type: 'object',
- properties: {
- bids: { $ref: '/relayerApiOrdersResponseSchema' },
- asks: { $ref: '/relayerApiOrdersResponseSchema' },
- },
- required: ['bids', 'asks'],
-};
diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_payload_schema.json b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_payload_schema.json
new file mode 100644
index 000000000..274ef1625
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_payload_schema.json
@@ -0,0 +1,14 @@
+{
+ "id": "/relayerApiOrdersChannelSubscribePayloadSchema",
+ "type": "object",
+ "properties": {
+ "makerAssetProxyId": { "$ref": "/hexSchema" },
+ "takerAssetProxyId": { "$ref": "/hexSchema" },
+ "networkId": { "type": "number" },
+ "makerAssetAddress": { "$ref": "/addressSchema" },
+ "takerAssetAddress": { "$ref": "/addressSchema" },
+ "makerAssetData": { "$ref": "/hexSchema" },
+ "takerAssetData": { "$ref": "/hexSchema" },
+ "traderAssetData": { "$ref": "/hexSchema" }
+ }
+}
diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.json b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.json
new file mode 100644
index 000000000..29561d09f
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.json
@@ -0,0 +1,11 @@
+{
+ "id": "/relayerApiOrdersChannelSubscribeSchema",
+ "type": "object",
+ "properties": {
+ "type": { "enum": ["subscribe"] },
+ "channel": { "enum": ["orders"] },
+ "requestId": { "type": "string" },
+ "payload": { "$ref": "/relayerApiOrdersChannelSubscribePayloadSchema" }
+ },
+ "required": ["type", "channel", "requestId"]
+}
diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts
deleted file mode 100644
index a3b9b6d95..000000000
--- a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-export const relayerApiOrdersChannelSubscribeSchema = {
- id: '/relayerApiOrdersChannelSubscribeSchema',
- type: 'object',
- properties: {
- type: { enum: ['subscribe'] },
- channel: { enum: ['orders'] },
- requestId: { type: 'string' },
- payload: { $ref: '/relayerApiOrdersChannelSubscribePayload' },
- },
- required: ['type', 'channel', 'requestId'],
-};
-
-export const relayerApiOrdersChannelSubscribePayload = {
- id: '/relayerApiOrdersChannelSubscribePayload',
- type: 'object',
- properties: {
- makerAssetProxyId: { $ref: '/hexSchema' },
- takerAssetProxyId: { $ref: '/hexSchema' },
- networkId: { type: 'number' },
- makerAssetAddress: { $ref: '/addressSchema' },
- takerAssetAddress: { $ref: '/addressSchema' },
- makerAssetData: { $ref: '/hexSchema' },
- takerAssetData: { $ref: '/hexSchema' },
- traderAssetData: { $ref: '/hexSchema' },
- },
-};
diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.json b/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.json
new file mode 100644
index 000000000..239e7c586
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.json
@@ -0,0 +1,11 @@
+{
+ "id": "/relayerApiOrdersChannelUpdateSchema",
+ "type": "object",
+ "properties": {
+ "type": { "enum": ["update"] },
+ "channel": { "enum": ["orders"] },
+ "requestId": { "type": "string" },
+ "payload": { "$ref": "/relayerApiOrdersSchema" }
+ },
+ "required": ["type", "channel", "requestId"]
+}
diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts
deleted file mode 100644
index 800b818e2..000000000
--- a/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-export const relayerApiOrdersChannelUpdateSchema = {
- id: '/relayerApiOrdersChannelUpdateSchema',
- type: 'object',
- properties: {
- type: { enum: ['update'] },
- channel: { enum: ['orders'] },
- requestId: { type: 'string' },
- payload: { $ref: '/relayerApiOrdersSchema' },
- },
- required: ['type', 'channel', 'requestId'],
-};
diff --git a/packages/json-schemas/schemas/relayer_api_orders_response_schema.json b/packages/json-schemas/schemas/relayer_api_orders_response_schema.json
new file mode 100644
index 000000000..a5023a3fc
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_orders_response_schema.json
@@ -0,0 +1,13 @@
+{
+ "id": "/relayerApiOrdersResponseSchema",
+ "type": "object",
+ "allOf": [
+ { "$ref": "/paginatedCollectionSchema" },
+ {
+ "properties": {
+ "records": { "$ref": "/relayerApiOrdersSchema" }
+ },
+ "required": ["records"]
+ }
+ ]
+}
diff --git a/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts
deleted file mode 100644
index c10d64ca9..000000000
--- a/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-export const relayerApiOrdersResponseSchema = {
- id: '/relayerApiOrdersResponseSchema',
- type: 'object',
- allOf: [
- { $ref: '/paginatedCollectionSchema' },
- {
- properties: {
- records: { $ref: '/relayerApiOrdersSchema' },
- },
- required: ['records'],
- },
- ],
-};
diff --git a/packages/json-schemas/schemas/relayer_api_orders_schema.json b/packages/json-schemas/schemas/relayer_api_orders_schema.json
new file mode 100644
index 000000000..84e75cd04
--- /dev/null
+++ b/packages/json-schemas/schemas/relayer_api_orders_schema.json
@@ -0,0 +1,5 @@
+{
+ "id": "/relayerApiOrdersSchema",
+ "type": "array",
+ "items": { "$ref": "/relayerApiOrderSchema" }
+}
diff --git a/packages/json-schemas/schemas/relayer_api_orders_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_schema.ts
deleted file mode 100644
index ba8ce4722..000000000
--- a/packages/json-schemas/schemas/relayer_api_orders_schema.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export const relayerApiOrdersSchema = {
- id: '/relayerApiOrdersSchema',
- type: 'array',
- items: { $ref: '/relayerApiOrderSchema' },
-};
diff --git a/packages/json-schemas/schemas/signed_order_schema.json b/packages/json-schemas/schemas/signed_order_schema.json
new file mode 100644
index 000000000..137ae4a24
--- /dev/null
+++ b/packages/json-schemas/schemas/signed_order_schema.json
@@ -0,0 +1,12 @@
+{
+ "id": "/signedOrderSchema",
+ "allOf": [
+ { "$ref": "/orderSchema" },
+ {
+ "properties": {
+ "signature": { "$ref": "/hexSchema" }
+ },
+ "required": ["signature"]
+ }
+ ]
+}
diff --git a/packages/json-schemas/schemas/signed_orders_schema.json b/packages/json-schemas/schemas/signed_orders_schema.json
new file mode 100644
index 000000000..e7c3a0b6c
--- /dev/null
+++ b/packages/json-schemas/schemas/signed_orders_schema.json
@@ -0,0 +1,5 @@
+{
+ "id": "/signedOrdersSchema",
+ "type": "array",
+ "items": { "$ref": "/signedOrderSchema" }
+}
diff --git a/packages/json-schemas/schemas/signed_orders_schema.ts b/packages/json-schemas/schemas/signed_orders_schema.ts
deleted file mode 100644
index e2a5aeb56..000000000
--- a/packages/json-schemas/schemas/signed_orders_schema.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export const signedOrdersSchema = {
- id: '/signedOrdersSchema',
- type: 'array',
- items: { $ref: '/signedOrderSchema' },
-};
diff --git a/packages/json-schemas/schemas/token_schema.json b/packages/json-schemas/schemas/token_schema.json
new file mode 100644
index 000000000..31e41c4b8
--- /dev/null
+++ b/packages/json-schemas/schemas/token_schema.json
@@ -0,0 +1,11 @@
+{
+ "id": "/tokenSchema",
+ "properties": {
+ "name": { "type": "string" },
+ "symbol": { "type": "string" },
+ "decimals": { "type": "number" },
+ "address": { "$ref": "/addressSchema" }
+ },
+ "required": ["name", "symbol", "decimals", "address"],
+ "type": "object"
+}
diff --git a/packages/json-schemas/schemas/token_schema.ts b/packages/json-schemas/schemas/token_schema.ts
deleted file mode 100644
index a0b1ae27f..000000000
--- a/packages/json-schemas/schemas/token_schema.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-export const tokenSchema = {
- id: '/tokenSchema',
- properties: {
- name: { type: 'string' },
- symbol: { type: 'string' },
- decimals: { type: 'number' },
- address: { $ref: '/addressSchema' },
- },
- required: ['name', 'symbol', 'decimals', 'address'],
- type: 'object',
-};
diff --git a/packages/json-schemas/schemas/tx_data_schema.json b/packages/json-schemas/schemas/tx_data_schema.json
new file mode 100644
index 000000000..4643521ce
--- /dev/null
+++ b/packages/json-schemas/schemas/tx_data_schema.json
@@ -0,0 +1,26 @@
+{
+ "id": "/txDataSchema",
+ "properties": {
+ "from": { "$ref": "/addressSchema" },
+ "to": { "$ref": "/addressSchema" },
+ "value": {
+ "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }]
+ },
+ "gas": {
+ "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }]
+ },
+ "gasPrice": {
+ "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }]
+ },
+ "data": {
+ "type": "string",
+ "pattern": "^0x[0-9a-f]*$"
+ },
+ "nonce": {
+ "type": "number",
+ "minimum": 0
+ }
+ },
+ "required": ["from"],
+ "type": "object"
+}
diff --git a/packages/json-schemas/schemas/tx_data_schema.ts b/packages/json-schemas/schemas/tx_data_schema.ts
deleted file mode 100644
index c57e18461..000000000
--- a/packages/json-schemas/schemas/tx_data_schema.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-export const jsNumber = {
- id: '/jsNumber',
- type: 'number',
- minimum: 0,
-};
-
-export const txDataSchema = {
- id: '/txDataSchema',
- properties: {
- from: { $ref: '/addressSchema' },
- to: { $ref: '/addressSchema' },
- value: {
- oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }],
- },
- gas: {
- oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }],
- },
- gasPrice: {
- oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }],
- },
- data: {
- type: 'string',
- pattern: '^0x[0-9a-f]*$',
- },
- nonce: {
- type: 'number',
- minimum: 0,
- },
- },
- required: ['from'],
- type: 'object',
-};
diff --git a/packages/json-schemas/schemas/zero_ex_transaction_schema.json b/packages/json-schemas/schemas/zero_ex_transaction_schema.json
new file mode 100644
index 000000000..ad3b11583
--- /dev/null
+++ b/packages/json-schemas/schemas/zero_ex_transaction_schema.json
@@ -0,0 +1,10 @@
+{
+ "id": "/zeroExTransactionSchema",
+ "properties": {
+ "data": { "$ref": "/hexSchema" },
+ "signerAddress": { "$ref": "/addressSchema" },
+ "salt": { "$ref": "/numberSchema" }
+ },
+ "required": ["data", "salt", "signerAddress"],
+ "type": "object"
+}
diff --git a/packages/json-schemas/schemas/zero_ex_transaction_schema.ts b/packages/json-schemas/schemas/zero_ex_transaction_schema.ts
deleted file mode 100644
index 7f729b724..000000000
--- a/packages/json-schemas/schemas/zero_ex_transaction_schema.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-export const zeroExTransactionSchema = {
- id: '/zeroExTransactionSchema',
- properties: {
- data: { $ref: '/hexSchema' },
- signerAddress: { $ref: '/addressSchema' },
- salt: { $ref: '/numberSchema' },
- },
- required: ['data', 'salt', 'signerAddress'],
- type: 'object',
-};
diff --git a/packages/json-schemas/src/globals.d.ts b/packages/json-schemas/src/globals.d.ts
deleted file mode 100644
index 94e63a32d..000000000
--- a/packages/json-schemas/src/globals.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-declare module '*.json' {
- const json: any;
- /* tslint:disable */
- export default json;
- /* tslint:enable */
-}
diff --git a/packages/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts
index 4eb96092d..8318df617 100644
--- a/packages/json-schemas/src/schemas.ts
+++ b/packages/json-schemas/src/schemas.ts
@@ -1,38 +1,40 @@
-import { addressSchema, hexSchema, numberSchema } from '../schemas/basic_type_schemas';
-import { blockParamSchema, blockRangeSchema } from '../schemas/block_range_schema';
-import { callDataSchema } from '../schemas/call_data_schema';
-import { ecSignatureParameterSchema, ecSignatureSchema } from '../schemas/ec_signature_schema';
-import { eip712TypedDataSchema } from '../schemas/eip712_typed_data';
-import { indexFilterValuesSchema } from '../schemas/index_filter_values_schema';
-import { orderCancellationRequestsSchema } from '../schemas/order_cancel_schema';
-import { orderFillOrKillRequestsSchema } from '../schemas/order_fill_or_kill_requests_schema';
-import { orderFillRequestsSchema } from '../schemas/order_fill_requests_schema';
-import { orderHashSchema } from '../schemas/order_hash_schema';
-import { orderSchema, signedOrderSchema } from '../schemas/order_schemas';
-import { ordersSchema } from '../schemas/orders_schema';
-import { paginatedCollectionSchema } from '../schemas/paginated_collection_schema';
-import {
- relayerApiAssetDataPairsResponseSchema,
- relayerApiAssetDataPairsSchema,
- relayerApiAssetDataTradeInfoSchema,
-} from '../schemas/relayer_api_asset_pairs_response_schema';
-import { relayerApiErrorResponseSchema } from '../schemas/relayer_api_error_response_schema';
-import { relayerApiFeeRecipientsResponseSchema } from '../schemas/relayer_api_fee_recipients_response_schema';
-import { relayerApiOrderConfigPayloadSchema } from '../schemas/relayer_api_order_config_payload_schema';
-import { relayerApiOrderConfigResponseSchema } from '../schemas/relayer_api_order_config_response_schema';
-import { relayerApiOrderSchema } from '../schemas/relayer_api_order_schema';
-import { relayerApiOrderbookResponseSchema } from '../schemas/relayer_api_orderbook_response_schema';
-import {
- relayerApiOrdersChannelSubscribePayload,
- relayerApiOrdersChannelSubscribeSchema,
-} from '../schemas/relayer_api_orders_channel_subscribe_schema';
-import { relayerApiOrdersChannelUpdateSchema } from '../schemas/relayer_api_orders_channel_update_response_schema';
-import { relayerApiOrdersResponseSchema } from '../schemas/relayer_api_orders_response_schema';
-import { relayerApiOrdersSchema } from '../schemas/relayer_api_orders_schema';
-import { signedOrdersSchema } from '../schemas/signed_orders_schema';
-import { tokenSchema } from '../schemas/token_schema';
-import { jsNumber, txDataSchema } from '../schemas/tx_data_schema';
-import { zeroExTransactionSchema } from '../schemas/zero_ex_transaction_schema';
+import * as addressSchema from '../schemas/address_schema.json';
+import * as blockParamSchema from '../schemas/block_param_schema.json';
+import * as blockRangeSchema from '../schemas/block_range_schema.json';
+import * as callDataSchema from '../schemas/call_data_schema.json';
+import * as ecSignatureParameterSchema from '../schemas/ec_signature_parameter_schema.json';
+import * as ecSignatureSchema from '../schemas/ec_signature_schema.json';
+import * as eip712TypedDataSchema from '../schemas/eip712_typed_data_schema.json';
+import * as hexSchema from '../schemas/hex_schema.json';
+import * as indexFilterValuesSchema from '../schemas/index_filter_values_schema.json';
+import * as jsNumber from '../schemas/js_number.json';
+import * as numberSchema from '../schemas/number_schema.json';
+import * as orderCancellationRequestsSchema from '../schemas/order_cancel_schema.json';
+import * as orderFillOrKillRequestsSchema from '../schemas/order_fill_or_kill_requests_schema.json';
+import * as orderFillRequestsSchema from '../schemas/order_fill_requests_schema.json';
+import * as orderHashSchema from '../schemas/order_hash_schema.json';
+import * as orderSchema from '../schemas/order_schema.json';
+import * as ordersSchema from '../schemas/orders_schema.json';
+import * as paginatedCollectionSchema from '../schemas/paginated_collection_schema.json';
+import * as relayerApiAssetDataPairsResponseSchema from '../schemas/relayer_api_asset_data_pairs_response_schema.json';
+import * as relayerApiAssetDataPairsSchema from '../schemas/relayer_api_asset_data_pairs_schema.json';
+import * as relayerApiAssetDataTradeInfoSchema from '../schemas/relayer_api_asset_data_trade_info_schema.json';
+import * as relayerApiErrorResponseSchema from '../schemas/relayer_api_error_response_schema.json';
+import * as relayerApiFeeRecipientsResponseSchema from '../schemas/relayer_api_fee_recipients_response_schema.json';
+import * as relayerApiOrderConfigPayloadSchema from '../schemas/relayer_api_order_config_payload_schema.json';
+import * as relayerApiOrderConfigResponseSchema from '../schemas/relayer_api_order_config_response_schema.json';
+import * as relayerApiOrderSchema from '../schemas/relayer_api_order_schema.json';
+import * as relayerApiOrderbookResponseSchema from '../schemas/relayer_api_orderbook_response_schema.json';
+import * as relayerApiOrdersChannelSubscribePayloadSchema from '../schemas/relayer_api_orders_channel_subscribe_payload_schema.json';
+import * as relayerApiOrdersChannelSubscribeSchema from '../schemas/relayer_api_orders_channel_subscribe_schema.json';
+import * as relayerApiOrdersChannelUpdateSchema from '../schemas/relayer_api_orders_channel_update_response_schema.json';
+import * as relayerApiOrdersResponseSchema from '../schemas/relayer_api_orders_response_schema.json';
+import * as relayerApiOrdersSchema from '../schemas/relayer_api_orders_schema.json';
+import * as signedOrderSchema from '../schemas/signed_order_schema.json';
+import * as signedOrdersSchema from '../schemas/signed_orders_schema.json';
+import * as tokenSchema from '../schemas/token_schema.json';
+import * as txDataSchema from '../schemas/tx_data_schema.json';
+import * as zeroExTransactionSchema from '../schemas/zero_ex_transaction_schema.json';
export const schemas = {
numberSchema,
@@ -67,7 +69,7 @@ export const schemas = {
relayerApiAssetDataPairsResponseSchema,
relayerApiAssetDataTradeInfoSchema,
relayerApiOrdersChannelSubscribeSchema,
- relayerApiOrdersChannelSubscribePayload,
+ relayerApiOrdersChannelSubscribePayloadSchema,
relayerApiOrdersChannelUpdateSchema,
relayerApiOrdersResponseSchema,
relayerApiAssetDataPairsSchema,
diff --git a/packages/json-schemas/tsconfig.json b/packages/json-schemas/tsconfig.json
index 96bf8789e..425dfcfe1 100644
--- a/packages/json-schemas/tsconfig.json
+++ b/packages/json-schemas/tsconfig.json
@@ -2,7 +2,47 @@
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib",
- "rootDir": "."
+ "rootDir": ".",
+ "resolveJsonModule": true
},
- "include": ["./src/**/*", "./test/**/*", "./schemas/**/*"]
+ "include": ["./src/**/*", "./test/**/*"],
+ "files": [
+ "./schemas/address_schema.json",
+ "./schemas/number_schema.json",
+ "./schemas/hex_schema.json",
+ "./schemas/block_param_schema.json",
+ "./schemas/block_range_schema.json",
+ "./schemas/call_data_schema.json",
+ "./schemas/ec_signature_parameter_schema.json",
+ "./schemas/ec_signature_schema.json",
+ "./schemas/eip712_typed_data_schema.json",
+ "./schemas/order_cancel_schema.json",
+ "./schemas/order_fill_or_kill_requests_schema.json",
+ "./schemas/order_fill_requests_schema.json",
+ "./schemas/order_hash_schema.json",
+ "./schemas/order_schema.json",
+ "./schemas/signed_order_schema.json",
+ "./schemas/orders_schema.json",
+ "./schemas/paginated_collection_schema.json",
+ "./schemas/relayer_api_asset_data_pairs_response_schema.json",
+ "./schemas/relayer_api_asset_data_pairs_schema.json",
+ "./schemas/relayer_api_asset_data_trade_info_schema.json",
+ "./schemas/relayer_api_error_response_schema.json",
+ "./schemas/relayer_api_fee_recipients_response_schema.json",
+ "./schemas/relayer_api_order_config_payload_schema.json",
+ "./schemas/relayer_api_order_config_response_schema.json",
+ "./schemas/relayer_api_order_schema.json",
+ "./schemas/relayer_api_orderbook_response_schema.json",
+ "./schemas/relayer_api_orders_channel_subscribe_payload_schema.json",
+ "./schemas/relayer_api_orders_channel_subscribe_schema.json",
+ "./schemas/relayer_api_orders_channel_update_response_schema.json",
+ "./schemas/relayer_api_orders_response_schema.json",
+ "./schemas/relayer_api_orders_schema.json",
+ "./schemas/signed_orders_schema.json",
+ "./schemas/token_schema.json",
+ "./schemas/js_number.json",
+ "./schemas/zero_ex_transaction_schema.json",
+ "./schemas/tx_data_schema.json",
+ "./schemas/index_filter_values_schema.json"
+ ]
}
diff --git a/packages/monorepo-scripts/CHANGELOG.json b/packages/monorepo-scripts/CHANGELOG.json
index 3b8684fab..4797fd929 100644
--- a/packages/monorepo-scripts/CHANGELOG.json
+++ b/packages/monorepo-scripts/CHANGELOG.json
@@ -1,5 +1,18 @@
[
{
+ "version": "1.0.6",
+ "changes": [
+ {
+ "note": "Render date formats in UTC to prevent conflicts when publishing in different timezones.",
+ "pr": 1143
+ },
+ {
+ "note": "Add AssetBuyerError to the IGNORED_EXCESSIVE_TYPES array",
+ "pr": 1139
+ }
+ ]
+ },
+ {
"timestamp": 1534210131,
"version": "1.0.5",
"changes": [
diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json
index 83091ae84..57e8bc147 100644
--- a/packages/monorepo-scripts/package.json
+++ b/packages/monorepo-scripts/package.json
@@ -65,7 +65,7 @@
"semver": "5.5.0",
"semver-diff": "^2.1.0",
"semver-sort": "0.0.4",
- "typedoc": "0.12.0",
+ "typedoc": "0.13.0",
"yargs": "^10.0.3"
},
"publishConfig": {
diff --git a/packages/monorepo-scripts/src/doc_gen_configs.ts b/packages/monorepo-scripts/src/doc_gen_configs.ts
index e3ddeddc9..0aaf5a6a5 100644
--- a/packages/monorepo-scripts/src/doc_gen_configs.ts
+++ b/packages/monorepo-scripts/src/doc_gen_configs.ts
@@ -16,8 +16,14 @@ export const docGenConfigs: DocGenConfigs = {
Schema:
'https://github.com/tdegrunt/jsonschema/blob/5c2edd4baba149964aec0f23c87ad12c25a50dfb/lib/index.d.ts#L49',
Uint8Array: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array',
+ // HACK: CI can handle these without the namespace but some local setups (Jacob) require the namespace prefix
+ // This is duplicated until we can discover the source of the issue.
GanacheOpts: 'https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ganache-core/index.d.ts#L8',
keystore: 'https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/eth-lightwallet/index.d.ts#L36',
+ 'Ganache.GanacheOpts':
+ 'https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ganache-core/index.d.ts#L8',
+ 'lightwallet.keystore':
+ 'https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/eth-lightwallet/index.d.ts#L36',
},
// If a 0x package re-exports an external package, we should add a link to it's exported items here
EXTERNAL_EXPORT_TO_LINK: {
@@ -30,6 +36,7 @@ export const docGenConfigs: DocGenConfigs = {
// factory method which instantiates an instance of a class, but we don't want users instantiating it themselves
// and getting confused. Any class name in this list will not have it's constructor rendered in our docs.
CLASSES_WITH_HIDDEN_CONSTRUCTORS: [
+ 'AssetBuyer',
'ERC20ProxyWrapper',
'ERC20TokenWrapper',
'ERC721ProxyWrapper',
@@ -43,7 +50,13 @@ export const docGenConfigs: DocGenConfigs = {
// Some types are not explicitly part of the public interface like params, return values, etc... But we still
// want them exported. E.g error enum types that can be thrown by methods. These must be manually added to this
// config
- IGNORED_EXCESSIVE_TYPES: ['NonceSubproviderErrors', 'Web3WrapperErrors', 'ContractWrappersError', 'OrderError'],
+ IGNORED_EXCESSIVE_TYPES: [
+ 'NonceSubproviderErrors',
+ 'Web3WrapperErrors',
+ 'ContractWrappersError',
+ 'OrderError',
+ 'AssetBuyerError',
+ ],
// Some libraries only export types. In those cases, we cannot check if the exported types are part of the
// "exported public interface". Thus we add them here and skip those checks.
TYPES_ONLY_LIBRARIES: ['ethereum-types', 'types'],
diff --git a/packages/monorepo-scripts/src/utils/changelog_utils.ts b/packages/monorepo-scripts/src/utils/changelog_utils.ts
index 8058d222b..0b46bf670 100644
--- a/packages/monorepo-scripts/src/utils/changelog_utils.ts
+++ b/packages/monorepo-scripts/src/utils/changelog_utils.ts
@@ -19,7 +19,8 @@ CHANGELOG
export const changelogUtils = {
getChangelogMdTitle(versionChangelog: VersionChangelog): string {
- const date = moment(`${versionChangelog.timestamp}`, 'X').format('MMMM D, YYYY');
+ // Use UTC rather than the local machines time (formatted date time is +0:00)
+ const date = moment.utc(`${versionChangelog.timestamp}`, 'X').format('MMMM D, YYYY');
const title = `\n## v${versionChangelog.version} - _${date}_\n\n`;
return title;
},
diff --git a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts
index 4fea94414..547b65eeb 100644
--- a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts
+++ b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts
@@ -331,7 +331,7 @@ export class DocGenerateAndUploadUtils {
throw new Error(
`${this._packageName} package exports BUT does not need: \n${excessiveReferencesExceptIgnored.join(
'\n',
- )} \nin it\'s index.ts. Remove them then try again.`,
+ )} \nin it\'s index.ts. Remove them then try again OR if we still want them exported (e.g error enum types), then add them to the IGNORED_EXCESSIVE_TYPES array.`,
);
}
}
diff --git a/packages/order-utils/CHANGELOG.json b/packages/order-utils/CHANGELOG.json
index 5a0c0db47..9bf16ef2a 100644
--- a/packages/order-utils/CHANGELOG.json
+++ b/packages/order-utils/CHANGELOG.json
@@ -14,6 +14,10 @@
{
"note": "Rename `ecSignOrderHashAsync` to `ecSignHashAsync` removing `SignerType` parameter.",
"pr": 1102
+ },
+ {
+ "note": "Use `AssetData` union type for function return values.",
+ "pr": 1131
}
]
},
diff --git a/packages/order-utils/package.json b/packages/order-utils/package.json
index 50bc0f0a0..09eef849f 100644
--- a/packages/order-utils/package.json
+++ b/packages/order-utils/package.json
@@ -49,7 +49,7 @@
"shx": "^0.2.2",
"sinon": "^4.0.0",
"tslint": "5.11.0",
- "typedoc": "0.12.0",
+ "typedoc": "0.13.0",
"typescript": "3.0.1"
},
"dependencies": {
diff --git a/packages/order-utils/src/asset_data_utils.ts b/packages/order-utils/src/asset_data_utils.ts
index 0c0b59548..12c11bce9 100644
--- a/packages/order-utils/src/asset_data_utils.ts
+++ b/packages/order-utils/src/asset_data_utils.ts
@@ -1,4 +1,4 @@
-import { AssetProxyId, ERC20AssetData, ERC721AssetData } from '@0xproject/types';
+import { AssetData, AssetProxyId, ERC20AssetData, ERC721AssetData } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import ethAbi = require('ethereumjs-abi');
import ethUtil = require('ethereumjs-util');
@@ -112,7 +112,7 @@ export const assetDataUtils = {
* @param assetData Hex encoded assetData string to decode
* @return Either a ERC20 or ERC721 assetData object
*/
- decodeAssetDataOrThrow(assetData: string): ERC20AssetData | ERC721AssetData {
+ decodeAssetDataOrThrow(assetData: string): AssetData {
const assetProxyId = assetDataUtils.decodeAssetProxyId(assetData);
switch (assetProxyId) {
case AssetProxyId.ERC20:
diff --git a/packages/order-utils/src/index.ts b/packages/order-utils/src/index.ts
index dbb782b85..50b8a88a8 100644
--- a/packages/order-utils/src/index.ts
+++ b/packages/order-utils/src/index.ts
@@ -18,7 +18,6 @@ export { ExchangeTransferSimulator } from './exchange_transfer_simulator';
export { BalanceAndProxyAllowanceLazyStore } from './store/balance_and_proxy_allowance_lazy_store';
export { OrderFilledCancelledLazyStore } from './store/order_filled_cancelled_lazy_store';
-export { constants } from './constants';
export { eip712Utils } from './eip712_utils';
export {
@@ -35,6 +34,7 @@ export {
OrderRelevantState,
OrderState,
ECSignature,
+ AssetData,
ERC20AssetData,
ERC721AssetData,
AssetProxyId,
diff --git a/packages/react-docs/package.json b/packages/react-docs/package.json
index b1e80d1b6..6830a2101 100644
--- a/packages/react-docs/package.json
+++ b/packages/react-docs/package.json
@@ -27,6 +27,7 @@
"@0xproject/dev-utils": "^1.0.12",
"@0xproject/tslint-config": "^1.0.8",
"@types/compare-versions": "^3.0.0",
+ "@types/styled-components": "^4.0.0",
"make-promises-safe": "^1.1.0",
"shx": "^0.2.2",
"tslint": "^5.9.1",
@@ -49,9 +50,10 @@
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-markdown": "^3.2.2",
- "react-scroll": "0xproject/react-scroll#similar-to-pr-330",
+ "react-scroll": "0xproject/react-scroll#similar-to-pr-330-but-with-replace-state",
"react-tooltip": "^3.2.7",
- "semver": "5.5.0"
+ "semver": "5.5.0",
+ "styled-components": "^3.3.0"
},
"publishConfig": {
"access": "public"
diff --git a/packages/react-docs/src/components/comment.tsx b/packages/react-docs/src/components/comment.tsx
index c3687c510..9c866e62c 100644
--- a/packages/react-docs/src/components/comment.tsx
+++ b/packages/react-docs/src/components/comment.tsx
@@ -1,4 +1,4 @@
-import { MarkdownCodeBlock } from '@0xproject/react-shared';
+import { colors, MarkdownCodeBlock } from '@0xproject/react-shared';
import * as React from 'react';
import * as ReactMarkdown from 'react-markdown';
@@ -13,7 +13,7 @@ const defaultProps = {
export const Comment: React.SFC<CommentProps> = (props: CommentProps) => {
return (
- <div className={`${props.className} comment`}>
+ <div className={`${props.className} comment`} style={{ color: colors.greyTheme }}>
<ReactMarkdown source={props.comment} renderers={{ code: MarkdownCodeBlock }} />
</div>
);
diff --git a/packages/react-docs/src/components/documentation.tsx b/packages/react-docs/src/components/doc_reference.tsx
index 6a08d50e0..5fdcdd2d9 100644
--- a/packages/react-docs/src/components/documentation.tsx
+++ b/packages/react-docs/src/components/doc_reference.tsx
@@ -2,12 +2,11 @@ import {
colors,
constants as sharedConstants,
EtherscanLinkSuffixes,
+ HeaderSizes,
Link,
MarkdownSection,
- NestedSidebarMenu,
Networks,
SectionHeader,
- Styles,
utils as sharedUtils,
} from '@0xproject/react-shared';
import {
@@ -21,7 +20,6 @@ import {
TypescriptMethod,
} from '@0xproject/types';
import * as _ from 'lodash';
-import CircularProgress from 'material-ui/CircularProgress';
import * as React from 'react';
import * as semver from 'semver';
@@ -43,143 +41,42 @@ const networkNameToColor: { [network: string]: string } = {
[Networks.Rinkeby]: colors.darkYellow,
};
-export interface DocumentationProps {
+export interface DocReferenceProps {
selectedVersion: string;
availableVersions: string[];
docsInfo: DocsInfo;
sourceUrl: string;
- onVersionSelected: (semver: string) => void;
docAgnosticFormat?: DocAgnosticFormat;
- sidebarHeader?: React.ReactNode;
- topBarHeight?: number;
}
-export interface DocumentationState {
- isHoveringSidebar: boolean;
-}
+export interface DocReferenceState {}
-export class Documentation extends React.Component<DocumentationProps, DocumentationState> {
- public static defaultProps: Partial<DocumentationProps> = {
- topBarHeight: 0,
- };
- constructor(props: DocumentationProps) {
- super(props);
- this.state = {
- isHoveringSidebar: false,
- };
- }
+export class DocReference extends React.Component<DocReferenceProps, DocReferenceState> {
public componentDidMount(): void {
window.addEventListener('hashchange', this._onHashChanged.bind(this), false);
}
public componentWillUnmount(): void {
window.removeEventListener('hashchange', this._onHashChanged.bind(this), false);
}
- public componentDidUpdate(prevProps: DocumentationProps, _prevState: DocumentationState): void {
+ public componentDidUpdate(prevProps: DocReferenceProps, _prevState: DocReferenceState): void {
if (!_.isEqual(prevProps.docAgnosticFormat, this.props.docAgnosticFormat)) {
const hash = window.location.hash.slice(1);
sharedUtils.scrollToHash(hash, sharedConstants.SCROLL_CONTAINER_ID);
}
}
public render(): React.ReactNode {
- const styles: Styles = {
- mainContainers: {
- position: 'absolute',
- top: 1,
- left: 0,
- bottom: 0,
- right: 0,
- overflowX: 'hidden',
- overflowY: 'scroll',
- minHeight: `calc(100vh - ${this.props.topBarHeight}px)`,
- WebkitOverflowScrolling: 'touch',
- },
- menuContainer: {
- borderColor: colors.grey300,
- maxWidth: 330,
- marginLeft: 20,
- },
- };
- const sectionNameToLinks = this.props.docsInfo.getSectionNameToLinks();
- const subsectionNameToLinks = this.props.docsInfo.getSubsectionNameToLinks(this.props.docAgnosticFormat);
- return (
- <div>
- {_.isUndefined(this.props.docAgnosticFormat) ? (
- this._renderLoading(styles.mainContainers)
- ) : (
- <div style={{ width: '100%', height: '100%', backgroundColor: colors.gray40 }}>
- <div
- className="mx-auto max-width-4 flex"
- style={{ color: colors.grey800, height: `calc(100vh - ${this.props.topBarHeight}px)` }}
- >
- <div
- className="relative sm-hide xs-hide"
- style={{ width: '36%', height: `calc(100vh - ${this.props.topBarHeight}px)` }}
- >
- <div
- className="border-right absolute"
- style={{
- ...styles.menuContainer,
- ...styles.mainContainers,
- height: `calc(100vh - ${this.props.topBarHeight}px)`,
- overflow: this.state.isHoveringSidebar ? 'auto' : 'hidden',
- }}
- onMouseEnter={this._onSidebarHover.bind(this)}
- onMouseLeave={this._onSidebarHoverOff.bind(this)}
- >
- <NestedSidebarMenu
- selectedVersion={this.props.selectedVersion}
- versions={this.props.availableVersions}
- sidebarHeader={this.props.sidebarHeader}
- sectionNameToLinks={sectionNameToLinks}
- subsectionNameToLinks={subsectionNameToLinks}
- onVersionSelected={this.props.onVersionSelected}
- />
- </div>
- </div>
- <div
- className="relative col lg-col-9 md-col-9 sm-col-12 col-12"
- style={{ backgroundColor: colors.white }}
- >
- <div
- id={sharedConstants.SCROLL_CONTAINER_ID}
- style={styles.mainContainers}
- className="absolute px1"
- >
- <div id={sharedConstants.SCROLL_TOP_ID} />
- {this._renderDocumentation()}
- </div>
- </div>
- </div>
- </div>
- )}
- </div>
- );
- }
- private _renderLoading(mainContainersStyles: React.CSSProperties): React.ReactNode {
- return (
- <div className="col col-12" style={mainContainersStyles}>
- <div
- className="relative sm-px2 sm-pt2 sm-m1"
- style={{ height: 122, top: '50%', transform: 'translateY(-50%)' }}
- >
- <div className="center pb2">
- <CircularProgress size={40} thickness={5} />
- </div>
- <div className="center pt2" style={{ paddingBottom: 11 }}>
- Loading documentation...
- </div>
- </div>
- </div>
- );
- }
- private _renderDocumentation(): React.ReactNode {
- const subMenus = _.values(this.props.docsInfo.menu);
+ const subMenus = _.values(this.props.docsInfo.markdownMenu);
const orderedSectionNames = _.flatten(subMenus);
const typeDefinitionByName = this.props.docsInfo.getTypeDefinitionsByName(this.props.docAgnosticFormat);
const renderedSections = _.map(orderedSectionNames, this._renderSection.bind(this, typeDefinitionByName));
- return renderedSections;
+ return (
+ <div>
+ <div id={sharedConstants.SCROLL_TOP_ID} />
+ {renderedSections}
+ </div>
+ );
}
private _renderSection(typeDefinitionByName: TypeDefinitionByName, sectionName: string): React.ReactNode {
const markdownVersions = _.keys(this.props.docsInfo.sectionNameToMarkdownByVersion);
@@ -197,11 +94,16 @@ export class Documentation extends React.Component<DocumentationProps, Documenta
const closestVersion = sortedEligibleVersions[0];
const markdownFileIfExists = this.props.docsInfo.sectionNameToMarkdownByVersion[closestVersion][sectionName];
if (!_.isUndefined(markdownFileIfExists)) {
+ // Special-case replace the `introduction` sectionName with the package name
+ const isIntroductionSection = sectionName === 'introduction';
+ const headerSize = isIntroductionSection ? HeaderSizes.H1 : HeaderSizes.H3;
return (
<MarkdownSection
key={`markdown-section-${sectionName}`}
sectionName={sectionName}
+ headerSize={headerSize}
markdownContent={markdownFileIfExists}
+ alternativeSectionTitle={isIntroductionSection ? this.props.docsInfo.displayName : undefined}
/>
);
}
@@ -292,7 +194,9 @@ export class Documentation extends React.Component<DocumentationProps, Documenta
)}
{!_.isEmpty(docSection.functions) && (
<div>
- {!isExportedFunctionSection && <h2 style={headerStyle}>Functions</h2>}
+ {!isExportedFunctionSection && (
+ <div style={{ ...headerStyle, fontSize: '1.5em' }}>Functions</div>
+ )}
<div>{functionDefs}</div>
</div>
)}
@@ -311,6 +215,15 @@ export class Documentation extends React.Component<DocumentationProps, Documenta
<div>{typeDefs}</div>
</div>
)}
+ <div
+ style={{
+ width: '100%',
+ height: 1,
+ backgroundColor: colors.grey300,
+ marginTop: 32,
+ marginBottom: 12,
+ }}
+ />
</div>
);
}
@@ -410,16 +323,6 @@ export class Documentation extends React.Component<DocumentationProps, Documenta
/>
);
}
- private _onSidebarHover(_event: React.FormEvent<HTMLInputElement>): void {
- this.setState({
- isHoveringSidebar: true,
- });
- }
- private _onSidebarHoverOff(): void {
- this.setState({
- isHoveringSidebar: false,
- });
- }
private _onHashChanged(_event: any): void {
const hash = window.location.hash.slice(1);
sharedUtils.scrollToHash(hash, sharedConstants.SCROLL_CONTAINER_ID);
diff --git a/packages/react-docs/src/components/signature_block.tsx b/packages/react-docs/src/components/signature_block.tsx
index 5ec82983a..819311953 100644
--- a/packages/react-docs/src/components/signature_block.tsx
+++ b/packages/react-docs/src/components/signature_block.tsx
@@ -55,7 +55,7 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu
<div
id={`${this.props.sectionName}-${method.name}`}
style={{ overflow: 'hidden', width: '100%' }}
- className="pb4"
+ className="pb4 pt2"
onMouseOver={this._setAnchorVisibility.bind(this, true)}
onMouseOut={this._setAnchorVisibility.bind(this, false)}
>
diff --git a/packages/react-docs/src/components/type.tsx b/packages/react-docs/src/components/type.tsx
index 1ae1324c6..d579449f4 100644
--- a/packages/react-docs/src/components/type.tsx
+++ b/packages/react-docs/src/components/type.tsx
@@ -204,7 +204,9 @@ export const Type: React.SFC<TypeProps> = (props: TypeProps): any => {
const isExportedClassReference = !!props.type.isExportedClassReference;
const typeNameUrlIfExists = !_.isUndefined(props.type.externalLink) ? props.type.externalLink : undefined;
if (!_.isUndefined(typeNameUrlIfExists)) {
- typeName = (
+ typeName = props.isInPopover ? (
+ <span style={{ color: colors.lightBlueA700, cursor: 'pointer' }}>{typeName}</span>
+ ) : (
<Link to={typeNameUrlIfExists} shouldOpenInNewTab={true} fontColor={colors.lightBlueA700}>
{typeName}
</Link>
@@ -218,39 +220,41 @@ export const Type: React.SFC<TypeProps> = (props: TypeProps): any => {
? props.type.name
: `${props.docsInfo.typeSectionName}-${typeName}`;
typeName = (
- <ScrollLink
- to={typeDefinitionAnchorId}
- offset={0}
- hashSpy={true}
- duration={sharedConstants.DOCS_SCROLL_DURATION_MS}
- containerId={sharedConstants.SCROLL_CONTAINER_ID}
- >
+ <span>
{sharedUtils.isUserOnMobile() || props.isInPopover || isExportedClassReference ? (
<span style={{ color: colors.lightBlueA700, cursor: 'pointer' }}>{typeName}</span>
) : (
- <span
- data-tip={true}
- data-for={id}
- style={{
- color: colors.lightBlueA700,
- cursor: 'pointer',
- display: 'inline-block',
- }}
+ <ScrollLink
+ to={typeDefinitionAnchorId}
+ offset={0}
+ hashSpy={true}
+ duration={sharedConstants.DOCS_SCROLL_DURATION_MS}
+ containerId={sharedConstants.SCROLL_CONTAINER_ID}
>
- {typeName}
- <ReactTooltip type="light" effect="solid" id={id} className="typeTooltip">
- <TypeDefinition
- sectionName={props.sectionName}
- customType={props.typeDefinitionByName[typeName as string]}
- shouldAddId={false}
- docsInfo={props.docsInfo}
- typeDefinitionByName={props.typeDefinitionByName}
- isInPopover={true}
- />
- </ReactTooltip>
- </span>
+ <span
+ data-tip={true}
+ data-for={id}
+ style={{
+ color: colors.lightBlueA700,
+ cursor: 'pointer',
+ display: 'inline-block',
+ }}
+ >
+ {typeName}
+ <ReactTooltip type="light" effect="solid" id={id} className="typeTooltip">
+ <TypeDefinition
+ sectionName={props.sectionName}
+ customType={props.typeDefinitionByName[typeName as string]}
+ shouldAddId={false}
+ docsInfo={props.docsInfo}
+ typeDefinitionByName={props.typeDefinitionByName}
+ isInPopover={true}
+ />
+ </ReactTooltip>
+ </span>
+ </ScrollLink>
)}
- </ScrollLink>
+ </span>
);
}
return (
diff --git a/packages/react-docs/src/components/type_definition.tsx b/packages/react-docs/src/components/type_definition.tsx
index 9a3e50a1b..3b64247f2 100644
--- a/packages/react-docs/src/components/type_definition.tsx
+++ b/packages/react-docs/src/components/type_definition.tsx
@@ -124,6 +124,7 @@ export class TypeDefinition extends React.Component<TypeDefinitionProps, TypeDef
title={`${typePrefix} ${customType.name}`}
id={this.props.shouldAddId ? typeDefinitionAnchorId : ''}
shouldShowAnchor={this.state.shouldShowAnchor}
+ isDisabled={this.props.isInPopover}
/>
<div style={{ fontSize: 16 }}>
<pre>
diff --git a/packages/react-docs/src/docs_info.ts b/packages/react-docs/src/docs_info.ts
index 549106c77..08e7703df 100644
--- a/packages/react-docs/src/docs_info.ts
+++ b/packages/react-docs/src/docs_info.ts
@@ -17,7 +17,7 @@ export class DocsInfo {
public displayName: string;
public packageName: string;
public packageUrl: string;
- public menu: DocsMenu;
+ public markdownMenu: DocsMenu;
public typeSectionName: string;
public sections: SectionsMap;
public sectionNameToMarkdownByVersion: SectionNameToMarkdownByVersion;
@@ -25,7 +25,7 @@ export class DocsInfo {
constructor(config: DocsInfoConfig) {
this.id = config.id;
this.type = config.type;
- this.menu = config.markdownMenu;
+ this.markdownMenu = config.markdownMenu;
this.displayName = config.displayName;
this.packageName = config.packageName;
this.packageUrl = config.packageUrl;
@@ -34,10 +34,31 @@ export class DocsInfo {
this.sectionNameToMarkdownByVersion = config.sectionNameToMarkdownByVersion;
this.contractsByVersionByNetworkId = config.contractsByVersionByNetworkId;
}
- public getSubsectionNameToLinks(docAgnosticFormat?: DocAgnosticFormat): ObjectMap<ALink[]> {
- const subsectionNameToLinks: ObjectMap<ALink[]> = {};
+ public getTypeDefinitionsByName(docAgnosticFormat: DocAgnosticFormat): ObjectMap<TypeDefinitionByName> {
+ if (_.isUndefined(docAgnosticFormat[this.typeSectionName])) {
+ return {};
+ }
+
+ const section = docAgnosticFormat[this.typeSectionName];
+ const typeDefinitionByName = _.keyBy(section.types, 'name') as any;
+ return typeDefinitionByName;
+ }
+ public getSectionNameToLinks(docAgnosticFormat: DocAgnosticFormat): ObjectMap<ALink[]> {
+ const sectionNameToLinks: ObjectMap<ALink[]> = {};
+ _.each(this.markdownMenu, (linkTitles, sectionName) => {
+ sectionNameToLinks[sectionName] = [];
+ _.each(linkTitles, linkTitle => {
+ const to = sharedUtils.getIdFromName(linkTitle);
+ const links = sectionNameToLinks[sectionName];
+ links.push({
+ title: linkTitle,
+ to,
+ });
+ });
+ });
+
if (_.isUndefined(docAgnosticFormat)) {
- return subsectionNameToLinks;
+ return sectionNameToLinks;
}
const docSections = _.keys(this.sections);
@@ -64,7 +85,7 @@ export class DocsInfo {
title: typeName,
};
});
- subsectionNameToLinks[sectionName] = typeLinks;
+ sectionNameToLinks[sectionName] = typeLinks;
} else if (isExportedFunctionSection) {
// Noop so that we don't have the method listed underneath itself.
} else {
@@ -88,33 +109,9 @@ export class DocsInfo {
};
});
- subsectionNameToLinks[sectionName] = links;
+ sectionNameToLinks[sectionName] = links;
}
});
- return subsectionNameToLinks;
- }
- public getTypeDefinitionsByName(docAgnosticFormat: DocAgnosticFormat): { [name: string]: TypeDefinitionByName } {
- if (_.isUndefined(docAgnosticFormat[this.typeSectionName])) {
- return {};
- }
-
- const section = docAgnosticFormat[this.typeSectionName];
- const typeDefinitionByName = _.keyBy(section.types, 'name') as any;
- return typeDefinitionByName;
- }
- public getSectionNameToLinks(): ObjectMap<ALink[]> {
- const sectionNameToLinks: ObjectMap<ALink[]> = {};
- _.each(this.menu, (linkTitles, sectionName) => {
- sectionNameToLinks[sectionName] = [];
- _.each(linkTitles, linkTitle => {
- const to = sharedUtils.getIdFromName(linkTitle);
- const links = sectionNameToLinks[sectionName];
- links.push({
- title: linkTitle,
- to,
- });
- });
- });
return sectionNameToLinks;
}
}
diff --git a/packages/react-docs/src/index.ts b/packages/react-docs/src/index.ts
index f9382940c..504091b34 100644
--- a/packages/react-docs/src/index.ts
+++ b/packages/react-docs/src/index.ts
@@ -5,7 +5,7 @@ export { DocAgnosticFormat, GeneratedDocJson } from '@0xproject/types';
export { Badge } from './components/badge';
export { Comment } from './components/comment';
export { CustomEnum } from './components/custom_enum';
-export { Documentation } from './components/documentation';
+export { DocReference } from './components/doc_reference';
export { Enum } from './components/enum';
export { EventDefinition } from './components/event_definition';
export { Interface } from './components/interface';
diff --git a/packages/react-docs/src/utils/typedoc_utils.ts b/packages/react-docs/src/utils/typedoc_utils.ts
index 19605d497..05c9dae55 100644
--- a/packages/react-docs/src/utils/typedoc_utils.ts
+++ b/packages/react-docs/src/utils/typedoc_utils.ts
@@ -95,7 +95,9 @@ export class TypeDocUtils {
if (!_.isEmpty(this._externalExportToLink)) {
this._docsInfo.sections[constants.EXTERNAL_EXPORTS_SECTION_NAME] = constants.EXTERNAL_EXPORTS_SECTION_NAME;
- this._docsInfo.menu[constants.EXTERNAL_EXPORTS_SECTION_NAME] = [constants.EXTERNAL_EXPORTS_SECTION_NAME];
+ this._docsInfo.markdownMenu[constants.EXTERNAL_EXPORTS_SECTION_NAME] = [
+ constants.EXTERNAL_EXPORTS_SECTION_NAME,
+ ];
const docSection: DocSection = {
comment: 'This package also re-exports some third-party libraries for your convenience.',
constructors: [],
@@ -119,7 +121,7 @@ export class TypeDocUtils {
case KindString.ObjectLiteral: {
sectionName = child.name;
this._docsInfo.sections[sectionName] = sectionName;
- this._docsInfo.menu[sectionName] = [sectionName];
+ this._docsInfo.markdownMenu[sectionName] = [sectionName];
const entities = child.children;
const commentObj = child.comment;
const sectionComment = !_.isUndefined(commentObj) ? commentObj.shortText : '';
@@ -136,7 +138,7 @@ export class TypeDocUtils {
case KindString.Function: {
sectionName = child.name;
this._docsInfo.sections[sectionName] = sectionName;
- this._docsInfo.menu[sectionName] = [sectionName];
+ this._docsInfo.markdownMenu[sectionName] = [sectionName];
const entities = [child];
const commentObj = child.comment;
const SectionComment = !_.isUndefined(commentObj) ? commentObj.shortText : '';
@@ -158,7 +160,7 @@ export class TypeDocUtils {
});
if (!_.isEmpty(typeEntities)) {
this._docsInfo.sections[constants.TYPES_SECTION_NAME] = constants.TYPES_SECTION_NAME;
- this._docsInfo.menu[constants.TYPES_SECTION_NAME] = [constants.TYPES_SECTION_NAME];
+ this._docsInfo.markdownMenu[constants.TYPES_SECTION_NAME] = [constants.TYPES_SECTION_NAME];
const docSection = this._convertEntitiesToDocSection(typeEntities, constants.TYPES_SECTION_NAME);
docAgnosticFormat[constants.TYPES_SECTION_NAME] = docSection;
}
diff --git a/packages/react-shared/CHANGELOG.json b/packages/react-shared/CHANGELOG.json
index d1907e785..ee0352561 100644
--- a/packages/react-shared/CHANGELOG.json
+++ b/packages/react-shared/CHANGELOG.json
@@ -1,7 +1,6 @@
[
{
- "timestamp": 1538693146,
- "version": "1.0.15",
+ "version": "1.0.17",
"changes": [
{
"note": "Dependencies updated"
@@ -9,6 +8,15 @@
]
},
{
+ "timestamp": 1538693146,
+ "version": "1.0.16",
+ "changes": [
+ {
+ "note": "Unpublished package"
+ }
+ ]
+ },
+ {
"timestamp": 1538475601,
"version": "1.0.14",
"changes": [
diff --git a/packages/react-shared/package.json b/packages/react-shared/package.json
index 178b6d76e..847946eb1 100644
--- a/packages/react-shared/package.json
+++ b/packages/react-shared/package.json
@@ -44,6 +44,7 @@
"@types/react-router-dom": "^4.0.4",
"@types/react-scroll": "1.5.3",
"@types/valid-url": "^1.0.2",
+ "@types/styled-components": "^4.0.0",
"basscss": "^8.0.3",
"change-case": "^3.0.2",
"is-mobile": "^0.2.2",
@@ -53,8 +54,9 @@
"react-dom": "^16.4.2",
"react-highlight": "0xproject/react-highlight#2f40a42e0a3f0ad126f9f42d505b97b603fc7162",
"react-markdown": "^3.2.2",
- "react-scroll": "0xproject/react-scroll#similar-to-pr-330",
+ "react-scroll": "0xproject/react-scroll#similar-to-pr-330-but-with-replace-state",
"react-router-dom": "^4.1.1",
+ "styled-components": "^3.3.0",
"valid-url": "^1.0.9"
},
"publishConfig": {
diff --git a/packages/react-shared/src/components/anchor_title.tsx b/packages/react-shared/src/components/anchor_title.tsx
index a83881b67..bd99edcab 100644
--- a/packages/react-shared/src/components/anchor_title.tsx
+++ b/packages/react-shared/src/components/anchor_title.tsx
@@ -1,7 +1,9 @@
import * as React from 'react';
import { Link as ScrollLink } from 'react-scroll';
+import styled from 'styled-components';
import { HeaderSizes, Styles } from '../types';
+import { colors } from '../utils/colors';
import { constants } from '../utils/constants';
const headerSizeToScrollOffset: { [headerSize: string]: number } = {
@@ -14,20 +16,14 @@ export interface AnchorTitleProps {
id: string;
headerSize: HeaderSizes;
shouldShowAnchor: boolean;
+ isDisabled: boolean;
}
-export interface AnchorTitleState {
- isHovering: boolean;
-}
+export interface AnchorTitleState {}
const styles: Styles = {
- anchor: {
- fontSize: 20,
- transform: 'rotate(45deg)',
- cursor: 'pointer',
- },
h1: {
- fontSize: '1.8em',
+ fontSize: '1.875em',
},
h2: {
fontSize: '1.5em',
@@ -38,18 +34,28 @@ const styles: Styles = {
},
};
+interface AnchorIconProps {
+ shouldShowAnchor: boolean;
+}
+
+const AnchorIcon =
+ styled.i <
+ AnchorIconProps >
+ `
+ opacity: ${props => (props.shouldShowAnchor ? 1 : 0)};
+ &:hover {
+ opacity: ${props => (props.shouldShowAnchor ? 0.6 : 0)};
+ }
+ font-size: 20px;
+ transform: rotate(45deg);
+ cursor: pointer;
+ `;
+
export class AnchorTitle extends React.Component<AnchorTitleProps, AnchorTitleState> {
- constructor(props: AnchorTitleProps) {
- super(props);
- this.state = {
- isHovering: false,
- };
- }
+ public static defaultProps: Partial<AnchorTitleProps> = {
+ isDisabled: false,
+ };
public render(): React.ReactNode {
- let opacity = 0;
- if (this.props.shouldShowAnchor) {
- opacity = this.state.isHovering ? 0.6 : 1;
- }
return (
<div
className="relative flex"
@@ -63,29 +69,21 @@ export class AnchorTitle extends React.Component<AnchorTitleProps, AnchorTitleSt
} as any
}
>
- <div className="inline-block" style={{ paddingRight: 4 }}>
+ <div className="inline-block" style={{ paddingRight: 4, color: colors.darkestGrey }}>
{this.props.title}
</div>
- <ScrollLink
- to={this.props.id}
- hashSpy={true}
- offset={headerSizeToScrollOffset[this.props.headerSize]}
- duration={constants.DOCS_SCROLL_DURATION_MS}
- containerId={constants.SCROLL_CONTAINER_ID}
- >
- <i
- className="zmdi zmdi-link"
- style={{ ...styles.anchor, opacity }}
- onMouseOver={this._setHoverState.bind(this, true)}
- onMouseOut={this._setHoverState.bind(this, false)}
- />
- </ScrollLink>
+ {!this.props.isDisabled && (
+ <ScrollLink
+ to={this.props.id}
+ hashSpy={true}
+ offset={headerSizeToScrollOffset[this.props.headerSize]}
+ duration={constants.DOCS_SCROLL_DURATION_MS}
+ containerId={constants.SCROLL_CONTAINER_ID}
+ >
+ <AnchorIcon className="zmdi zmdi-link" shouldShowAnchor={this.props.shouldShowAnchor} />
+ </ScrollLink>
+ )}
</div>
);
}
- private _setHoverState(isHovering: boolean): void {
- this.setState({
- isHovering,
- });
- }
}
diff --git a/packages/react-shared/src/components/markdown_paragraph_block.tsx b/packages/react-shared/src/components/markdown_paragraph_block.tsx
new file mode 100644
index 000000000..eeaef8571
--- /dev/null
+++ b/packages/react-shared/src/components/markdown_paragraph_block.tsx
@@ -0,0 +1,10 @@
+import * as _ from 'lodash';
+import * as React from 'react';
+
+import { colors } from '../utils/colors';
+
+export interface MarkdownParagraphBlockProps {}
+
+export const MarkdownParagraphBlock: React.StatelessComponent<MarkdownParagraphBlockProps> = ({ children }) => {
+ return <span style={{ color: colors.greyTheme, lineHeight: '26px' }}>{children}</span>;
+};
diff --git a/packages/react-shared/src/components/markdown_section.tsx b/packages/react-shared/src/components/markdown_section.tsx
index e84d2b078..e6a7d80d5 100644
--- a/packages/react-shared/src/components/markdown_section.tsx
+++ b/packages/react-shared/src/components/markdown_section.tsx
@@ -11,12 +11,14 @@ import { AnchorTitle } from './anchor_title';
import { Link } from './link';
import { MarkdownCodeBlock } from './markdown_code_block';
import { MarkdownLinkBlock } from './markdown_link_block';
+import { MarkdownParagraphBlock } from './markdown_paragraph_block';
export interface MarkdownSectionProps {
sectionName: string;
markdownContent: string;
headerSize?: HeaderSizes;
githubLink?: string;
+ alternativeSectionTitle?: string;
}
interface DefaultMarkdownSectionProps {
@@ -43,20 +45,23 @@ export class MarkdownSection extends React.Component<MarkdownSectionProps, Markd
const { sectionName, markdownContent, headerSize, githubLink } = this.props as PropsWithDefaults;
const id = utils.getIdFromName(sectionName);
- const finalSectionName = utils.convertCamelCaseToSpaces(sectionName);
+ const formattedSectionName = utils.convertCamelCaseToSpaces(sectionName);
+ const title = !_.isUndefined(this.props.alternativeSectionTitle)
+ ? this.props.alternativeSectionTitle
+ : formattedSectionName;
return (
<div
className="md-px1 sm-px2 overflow-hidden"
onMouseOver={this._setAnchorVisibility.bind(this, true)}
onMouseOut={this._setAnchorVisibility.bind(this, false)}
>
- <ScrollElement name={id}>
- <div className="clearfix pt3">
+ <ScrollElement name={id} style={{ paddingBottom: 20 }}>
+ <div className="clearfix" style={{ paddingTop: 30, paddingBottom: 20 }}>
<div className="col lg-col-8 md-col-8 sm-col-12">
- <span style={{ textTransform: 'capitalize', color: colors.grey700 }}>
+ <span style={{ color: colors.grey700 }}>
<AnchorTitle
headerSize={headerSize}
- title={finalSectionName}
+ title={_.capitalize(title)}
id={id}
shouldShowAnchor={this.state.shouldShowAnchor}
/>
@@ -72,13 +77,21 @@ export class MarkdownSection extends React.Component<MarkdownSectionProps, Markd
)}
</div>
</div>
- <hr style={{ border: `1px solid ${colors.lightestGrey}` }} />
<ReactMarkdown
source={markdownContent}
escapeHtml={false}
renderers={{
code: MarkdownCodeBlock,
link: MarkdownLinkBlock,
+ paragraph: MarkdownParagraphBlock,
+ }}
+ />
+ <div
+ style={{
+ width: '100%',
+ height: 1,
+ backgroundColor: colors.grey300,
+ marginTop: 32,
}}
/>
</ScrollElement>
diff --git a/packages/react-shared/src/components/nested_sidebar_menu.tsx b/packages/react-shared/src/components/nested_sidebar_menu.tsx
index 5b6076df6..f734dc654 100644
--- a/packages/react-shared/src/components/nested_sidebar_menu.tsx
+++ b/packages/react-shared/src/components/nested_sidebar_menu.tsx
@@ -8,97 +8,100 @@ import { colors } from '../utils/colors';
import { utils } from '../utils/utils';
import { Link } from './link';
-import { VersionDropDown } from './version_drop_down';
export interface NestedSidebarMenuProps {
sectionNameToLinks: ObjectMap<ALink[]>;
- subsectionNameToLinks?: ObjectMap<ALink[]>;
sidebarHeader?: React.ReactNode;
- shouldDisplaySectionHeaders?: boolean;
- onMenuItemClick?: () => void;
- selectedVersion?: string;
- versions?: string[];
- onVersionSelected?: (semver: string) => void;
shouldReformatMenuItemNames?: boolean;
}
-export interface NestedSidebarMenuState {}
+export interface NestedSidebarMenuState {
+ scrolledToId?: string;
+}
const styles: Styles = {
- menuItemWithHeaders: {
+ menuItem: {
minHeight: 0,
+ paddingLeft: 8,
+ borderRadius: 6,
},
- menuItemWithoutHeaders: {
- minHeight: 48,
- },
- menuItemInnerDivWithHeaders: {
+ menuItemInnerDiv: {
color: colors.grey800,
fontSize: 14,
lineHeight: 2,
padding: 0,
+ whiteSpace: 'nowrap',
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
},
};
export class NestedSidebarMenu extends React.Component<NestedSidebarMenuProps, NestedSidebarMenuState> {
public static defaultProps: Partial<NestedSidebarMenuProps> = {
- shouldDisplaySectionHeaders: true,
- onMenuItemClick: _.noop.bind(_),
shouldReformatMenuItemNames: true,
- subsectionNameToLinks: {},
};
+ private _urlIntervalCheckId: number | undefined = undefined;
+ constructor(props: NestedSidebarMenuProps) {
+ super(props);
+ this.state = {};
+ }
+ public componentDidMount(): void {
+ this._urlIntervalCheckId = window.setInterval(() => {
+ const scrollId = location.hash.slice(1);
+ if (scrollId !== this.state.scrolledToId) {
+ this.setState({
+ scrolledToId: scrollId,
+ });
+ }
+ }, 200);
+ }
+ public componentWillUnmount(): void {
+ window.clearInterval(this._urlIntervalCheckId);
+ }
public render(): React.ReactNode {
const navigation = _.map(this.props.sectionNameToLinks, (links: ALink[], sectionName: string) => {
const finalSectionName = utils.convertCamelCaseToSpaces(sectionName);
- if (this.props.shouldDisplaySectionHeaders) {
- // tslint:disable-next-line:no-unused-variable
- return (
- <div key={`section-${sectionName}`} className="py1" style={{ color: colors.linkSectionGrey }}>
- <div style={{ fontWeight: 'bold', fontSize: 15, letterSpacing: 0.5 }} className="py1">
- {finalSectionName.toUpperCase()}
- </div>
- {this._renderMenuItems(links)}
+ // tslint:disable-next-line:no-unused-variable
+ return (
+ <div key={`section-${sectionName}`} className="py1" style={{ color: colors.greyTheme }}>
+ <div style={{ fontSize: 14, letterSpacing: 0.5 }} className="py1 pl1">
+ {finalSectionName.toUpperCase()}
</div>
- );
- } else {
- return <div key={`section-${sectionName}`}>{this._renderMenuItems(links)}</div>;
- }
+ {this._renderMenuItems(links)}
+ </div>
+ );
});
- const maxWidthWithScrollbar = 307;
return (
<div>
{this.props.sidebarHeader}
- {!_.isUndefined(this.props.versions) &&
- !_.isUndefined(this.props.selectedVersion) &&
- !_.isUndefined(this.props.onVersionSelected) && (
- <div style={{ maxWidth: maxWidthWithScrollbar }}>
- <VersionDropDown
- selectedVersion={this.props.selectedVersion}
- versions={this.props.versions}
- onVersionSelected={this.props.onVersionSelected}
- />
- </div>
- )}
- <div className="pl1">{navigation}</div>
+ <div>{navigation}</div>
</div>
);
}
private _renderMenuItems(links: ALink[]): React.ReactNode[] {
- const menuItemStyles = this.props.shouldDisplaySectionHeaders
- ? styles.menuItemWithHeaders
- : styles.menuItemWithoutHeaders;
- const menuItemInnerDivStyles = this.props.shouldDisplaySectionHeaders ? styles.menuItemInnerDivWithHeaders : {};
+ const scrolledToId = this.state.scrolledToId;
const menuItems = _.map(links, link => {
const finalMenuItemName = this.props.shouldReformatMenuItemNames
? utils.convertDashesToSpaces(link.title)
: link.title;
+ let menuItemStyle = styles.menuItem;
+ let menuItemInnerDivStyle = styles.menuItemInnerDiv;
+ const isScrolledTo = link.to === scrolledToId;
+ if (isScrolledTo) {
+ menuItemStyle = {
+ ...menuItemStyle,
+ backgroundColor: colors.lightLinkBlue,
+ };
+ menuItemInnerDivStyle = {
+ ...menuItemInnerDivStyle,
+ color: colors.white,
+ fontWeight: 'bold',
+ };
+ }
return (
<div key={`menuItem-${finalMenuItemName}`}>
<Link to={link.to} shouldOpenInNewTab={link.shouldOpenInNewTab}>
- <MenuItem
- style={menuItemStyles}
- innerDivStyle={menuItemInnerDivStyles}
- onClick={this._onMenuItemClick.bind(this)}
- >
+ <MenuItem style={menuItemStyle} innerDivStyle={menuItemInnerDivStyle}>
<span
style={{
textTransform: this.props.shouldReformatMenuItemNames ? 'capitalize' : 'none',
@@ -108,50 +111,9 @@ export class NestedSidebarMenu extends React.Component<NestedSidebarMenuProps, N
</span>
</MenuItem>
</Link>
- {this._renderMenuItemSubsections(link.title)}
</div>
);
});
return menuItems;
}
- private _renderMenuItemSubsections(menuItemName: string): React.ReactNode {
- if (
- _.isUndefined(this.props.subsectionNameToLinks) ||
- _.isUndefined(this.props.subsectionNameToLinks[menuItemName])
- ) {
- return null;
- }
- return this._renderSubsectionLinks(menuItemName, this.props.subsectionNameToLinks[menuItemName]);
- }
- private _renderSubsectionLinks(menuItemName: string, links: ALink[]): React.ReactNode {
- return (
- <ul style={{ margin: 0, listStyleType: 'none', paddingLeft: 0 }} key={menuItemName}>
- {_.map(links, link => {
- const name = `${menuItemName}-${link.title}`;
- return (
- <li key={`menuSubsectionItem-${name}`}>
- <Link to={link.to} shouldOpenInNewTab={link.shouldOpenInNewTab}>
- <MenuItem
- style={{ minHeight: 35 }}
- innerDivStyle={{
- paddingLeft: 16,
- fontSize: 14,
- lineHeight: '35px',
- }}
- onClick={this._onMenuItemClick.bind(this)}
- >
- {link.title}
- </MenuItem>
- </Link>
- </li>
- );
- })}
- </ul>
- );
- }
- private _onMenuItemClick(): void {
- if (!_.isUndefined(this.props.onMenuItemClick)) {
- this.props.onMenuItemClick();
- }
- }
}
diff --git a/packages/react-shared/src/components/version_drop_down.tsx b/packages/react-shared/src/components/version_drop_down.tsx
deleted file mode 100644
index 5ff4bed54..000000000
--- a/packages/react-shared/src/components/version_drop_down.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import MenuItem from '@material-ui/core/MenuItem';
-import Select from '@material-ui/core/Select';
-import * as _ from 'lodash';
-import * as React from 'react';
-
-export interface VersionDropDownProps {
- selectedVersion: string;
- versions: string[];
- onVersionSelected: (semver: string) => void;
-}
-
-export interface VersionDropDownState {}
-
-export class VersionDropDown extends React.Component<VersionDropDownProps, VersionDropDownState> {
- public render(): React.ReactNode {
- return (
- <div className="mx-auto" style={{ width: 120 }}>
- <Select value={this.props.selectedVersion} onChange={this._updateSelectedVersion.bind(this)}>
- {this._renderDropDownItems()}
- </Select>
- </div>
- );
- }
- private _renderDropDownItems(): React.ReactNode[] {
- const items = _.map(this.props.versions, version => {
- return (
- <MenuItem key={version} value={version}>
- v{version}
- </MenuItem>
- );
- });
- return items;
- }
- private _updateSelectedVersion(event: React.ChangeEvent<HTMLSelectElement>): void {
- this.props.onVersionSelected(event.target.value);
- }
-}
diff --git a/packages/react-shared/src/utils/colors.ts b/packages/react-shared/src/utils/colors.ts
index 596c17e83..a4dd7fefa 100644
--- a/packages/react-shared/src/utils/colors.ts
+++ b/packages/react-shared/src/utils/colors.ts
@@ -18,6 +18,7 @@ const baseColors = {
darkGrey: '#818181',
landingLinkGrey: '#919191',
linkSectionGrey: '#999999',
+ greyTheme: '#666666',
grey700: '#616161',
grey750: '#515151',
grey800: '#424242',
diff --git a/packages/sol-compiler/package.json b/packages/sol-compiler/package.json
index 9ee88a5ef..828ce1dbc 100644
--- a/packages/sol-compiler/package.json
+++ b/packages/sol-compiler/package.json
@@ -58,7 +58,7 @@
"nyc": "^11.0.1",
"shx": "^0.2.2",
"tslint": "5.11.0",
- "typedoc": "0.12.0",
+ "typedoc": "0.13.0",
"types-bn": "^0.0.1",
"typescript": "3.0.1",
"web3-typescript-typings": "^0.10.2",
diff --git a/packages/sol-compiler/src/utils/encoder.ts b/packages/sol-compiler/src/utils/encoder.ts
index 0f2d75691..40b103fd5 100644
--- a/packages/sol-compiler/src/utils/encoder.ts
+++ b/packages/sol-compiler/src/utils/encoder.ts
@@ -1,4 +1,4 @@
-import { AbiDefinition, AbiType, ContractAbi, DataItem } from 'ethereum-types';
+import { AbiDefinition, AbiType, ConstructorAbi, ContractAbi, DataItem } from 'ethereum-types';
import * as _ from 'lodash';
import * as web3Abi from 'web3-eth-abi';
@@ -7,7 +7,9 @@ export const encoder = {
const constructorTypes: string[] = [];
_.each(abi, (element: AbiDefinition) => {
if (element.type === AbiType.Constructor) {
- _.each(element.inputs, (input: DataItem) => {
+ // tslint:disable-next-line:no-unnecessary-type-assertion
+ const constuctorAbi = element as ConstructorAbi;
+ _.each(constuctorAbi.inputs, (input: DataItem) => {
constructorTypes.push(input.type);
});
}
diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json
index e093aa2ad..49473f6c8 100644
--- a/packages/sol-cov/package.json
+++ b/packages/sol-cov/package.json
@@ -78,7 +78,7 @@
"shx": "^0.2.2",
"sinon": "^4.0.0",
"tslint": "5.11.0",
- "typedoc": "0.12.0",
+ "typedoc": "0.13.0",
"typescript": "3.0.1"
},
"publishConfig": {
diff --git a/packages/sol-doc/src/sol_doc.ts b/packages/sol-doc/src/sol_doc.ts
index 138882c92..686e9ca34 100644
--- a/packages/sol-doc/src/sol_doc.ts
+++ b/packages/sol-doc/src/sol_doc.ts
@@ -324,19 +324,25 @@ export class SolDoc {
switch (abiDefinition.type) {
case 'constructor':
docSection.constructors.push(
- this._genConstructorDoc(contractName, abiDefinition, compiledContract.devdoc),
+ // tslint:disable-next-line:no-unnecessary-type-assertion
+ this._genConstructorDoc(contractName, abiDefinition as ConstructorAbi, compiledContract.devdoc),
);
break;
case 'event':
- (docSection.events as Event[]).push(SolDoc._genEventDoc(abiDefinition));
+ // tslint:disable-next-line:no-unnecessary-type-assertion
+ (docSection.events as Event[]).push(SolDoc._genEventDoc(abiDefinition as EventAbi));
// 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));
+ // tslint:disable-next-line:no-unnecessary-type-assertion
+ docSection.methods.push(this._genMethodDoc(abiDefinition as MethodAbi, compiledContract.devdoc));
break;
case 'fallback':
- docSection.methods.push(SolDoc._genFallbackDoc(abiDefinition, compiledContract.devdoc));
+ // tslint:disable-next-line:no-unnecessary-type-assertion
+ docSection.methods.push(
+ SolDoc._genFallbackDoc(abiDefinition as FallbackAbi, compiledContract.devdoc),
+ );
break;
default:
throw new Error(
diff --git a/packages/sra-spec/src/json-schemas.ts b/packages/sra-spec/src/json-schemas.ts
index 173a04bfb..47cca9b04 100644
--- a/packages/sra-spec/src/json-schemas.ts
+++ b/packages/sra-spec/src/json-schemas.ts
@@ -21,7 +21,7 @@ const {
relayerApiAssetDataPairsResponseSchema,
relayerApiAssetDataTradeInfoSchema,
relayerApiOrdersChannelSubscribeSchema,
- relayerApiOrdersChannelSubscribePayload,
+ relayerApiOrdersChannelSubscribePayloadSchema,
relayerApiOrdersChannelUpdateSchema,
relayerApiOrdersResponseSchema,
relayerApiAssetDataPairsSchema,
@@ -47,7 +47,7 @@ const usedSchemas = {
relayerApiAssetDataPairsResponseSchema,
relayerApiAssetDataTradeInfoSchema,
relayerApiOrdersChannelSubscribeSchema,
- relayerApiOrdersChannelSubscribePayload,
+ relayerApiOrdersChannelSubscribePayloadSchema,
relayerApiOrdersChannelUpdateSchema,
relayerApiOrdersResponseSchema,
relayerApiAssetDataPairsSchema,
diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json
index bef93a572..1fe1ee4ad 100644
--- a/packages/subproviders/package.json
+++ b/packages/subproviders/package.json
@@ -73,7 +73,7 @@
"shx": "^0.2.2",
"sinon": "^4.0.0",
"tslint": "5.11.0",
- "typedoc": "0.12.0",
+ "typedoc": "0.13.0",
"typescript": "3.0.1",
"webpack": "^4.20.2"
},
diff --git a/packages/types/CHANGELOG.json b/packages/types/CHANGELOG.json
index 53e1f3716..106dc3281 100644
--- a/packages/types/CHANGELOG.json
+++ b/packages/types/CHANGELOG.json
@@ -9,6 +9,10 @@
{
"note": "Added `ZeroExTransaction` type for Exchange executeTransaction",
"pr": 1102
+ },
+ {
+ "note": "Add `AssetData` union type (`type AssetData = ERC20AssetData | ERC721AssetData`)",
+ "pr": 1131
}
]
},
diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts
index d33048b61..3c9b6bbc5 100644
--- a/packages/types/src/index.ts
+++ b/packages/types/src/index.ts
@@ -168,6 +168,8 @@ export interface ERC721AssetData {
tokenId: BigNumber;
}
+export type AssetData = ERC20AssetData | ERC721AssetData;
+
// TODO: DRY. These should be extracted from contract code.
export enum RevertReason {
OrderUnfillable = 'ORDER_UNFILLABLE',
diff --git a/packages/utils/src/abi_decoder.ts b/packages/utils/src/abi_decoder.ts
index ac3e54efb..c0b2c7950 100644
--- a/packages/utils/src/abi_decoder.ts
+++ b/packages/utils/src/abi_decoder.ts
@@ -99,11 +99,13 @@ export class AbiDecoder {
const ethersInterface = new ethers.utils.Interface(abiArray);
_.map(abiArray, (abi: AbiDefinition) => {
if (abi.type === AbiType.Event) {
- const topic = ethersInterface.events[abi.name].topic;
- const numIndexedArgs = _.reduce(abi.inputs, (sum, input) => (input.indexed ? sum + 1 : sum), 0);
+ // tslint:disable-next-line:no-unnecessary-type-assertion
+ const eventAbi = abi as EventAbi;
+ const topic = ethersInterface.events[eventAbi.name].topic;
+ const numIndexedArgs = _.reduce(eventAbi.inputs, (sum, input) => (input.indexed ? sum + 1 : sum), 0);
this._methodIds[topic] = {
...this._methodIds[topic],
- [numIndexedArgs]: abi,
+ [numIndexedArgs]: eventAbi,
};
}
});
diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json
index 972dfa7a2..4d033e130 100644
--- a/packages/web3-wrapper/package.json
+++ b/packages/web3-wrapper/package.json
@@ -49,7 +49,7 @@
"nyc": "^11.0.1",
"shx": "^0.2.2",
"tslint": "5.11.0",
- "typedoc": "0.12.0",
+ "typedoc": "0.13.0",
"typescript": "3.0.1"
},
"dependencies": {
diff --git a/packages/website/less/all.less b/packages/website/less/all.less
index c62db0d20..3747e4860 100644
--- a/packages/website/less/all.less
+++ b/packages/website/less/all.less
@@ -34,17 +34,7 @@ a {
}
}
-#documentation {
- p {
- line-height: 1.5;
- }
-
- .comment {
- p {
- margin: 0px;
- }
- }
-
+#scroll_container {
.typeTooltip {
border: 1px solid lightgray;
opacity: 1;
@@ -83,6 +73,7 @@ a {
code {
border: 1px solid #e3eefe;
+ border-radius: 4px;
font-family: 'Roboto Mono';
background-color: #f2f6ff !important; // lightBlue
}
diff --git a/packages/website/md/docs/asset_buyer/installation.md b/packages/website/md/docs/asset_buyer/installation.md
new file mode 100644
index 000000000..483ee2b65
--- /dev/null
+++ b/packages/website/md/docs/asset_buyer/installation.md
@@ -0,0 +1,17 @@
+**Install**
+
+```bash
+yarn add @0xproject/asset-buyer
+```
+
+**Import**
+
+```javascript
+import { AssetBuyer } from '@0xproject/asset-buyer';
+```
+
+or
+
+```javascript
+var AssetBuyer = require('@0xproject/asset-buyer').AssetBuyer;
+```
diff --git a/packages/website/md/docs/asset_buyer/introduction.md b/packages/website/md/docs/asset_buyer/introduction.md
new file mode 100644
index 000000000..a40d20cc9
--- /dev/null
+++ b/packages/website/md/docs/asset_buyer/introduction.md
@@ -0,0 +1 @@
+Welcome to the [@0xproject/asset-buyer](https://github.com/0xProject/0x-monorepo/tree/development/packages/asset-buyer) documentation! AssetBuyer is a library that provides an easy way to buy any asset with ETH in one click, leveraging 0x liquidity and the [Forwarder contract](https://0xproject.com/docs/contracts#Forwarder).
diff --git a/packages/website/md/docs/asset_buyer/usage.md b/packages/website/md/docs/asset_buyer/usage.md
new file mode 100644
index 000000000..6462d938e
--- /dev/null
+++ b/packages/website/md/docs/asset_buyer/usage.md
@@ -0,0 +1,39 @@
+**Construction**
+
+Connecting to a standard relayer API compliant url:
+
+```typescript
+const provider = web3.currentProvider;
+const apiUrl = 'https://api.relayer.com/v2';
+const assetBuyer = AssetBuyer.getAssetBuyerForStandardRelayerAPIUrl(provider, apiUrl);
+```
+
+Providing your own orders:
+
+```typescript
+const provider = web3.currentProvider;
+const orders = []; // get these from your own API, a relayer, a friend, from anywhere
+const assetBuyer = AssetBuyer.getAssetBuyerForProvidedOrders(provider, orders);
+```
+
+**Get a quote**
+
+A [BuyQuote](#types-BuyQuote) object contains enough information to display buy information to an end user
+
+```typescript
+const erc20TokenAddress = '0x5fa3c....';
+const amountToBuy = new BigNumber(50000000000000000000);
+const buyQuote = await assetBuyer.getBuyQuoteForERC20TokenAddressAsync(erc20TokenAddress, amountToBuy);
+const quoteInfo = buyQuote.worstCaseQuoteInfo;
+console.log(quoteInfo.ethAmount); // the total amount the user needs to pay to buy the desired amount (including ZRX fees)
+console.log(quoteInfo.feeAmount); // a portion of the total ethAmount above that was used to buy affiliate fees
+console.log(quoteInfo.ethPerAssetPrice); // the rate that this quote provides (e.g. 0.0035ETH / REP)
+```
+
+**Perform a buy**
+
+Pass the [BuyQuote](#types-BuyQuote) object from above back to the assetBuyer in order to initiate the buy transaction
+
+```typescript
+const txHash = await assetBuyer.executeBuyQuoteAsync(buyQuote); // the hash of the transaction submitted to the Ethereum network
+```
diff --git a/packages/website/md/docs/json_schemas/2.0.0/schemas.md b/packages/website/md/docs/json_schemas/2.0.0/schemas.md
index 4f3200b1c..ec7cf6f15 100644
--- a/packages/website/md/docs/json_schemas/2.0.0/schemas.md
+++ b/packages/website/md/docs/json_schemas/2.0.0/schemas.md
@@ -1,28 +1,40 @@
+Basic Schemas
+
+* [Address type](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/address.json)
+* [Number type](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/number.json)
+* [Hex type](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/hex.json)
+* [JS number](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/js_number.json)
+
0x Protocol Schemas
-* [Basic types](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/basic_type_schemas.ts) (e.g Ethereum address, number, hex)
-* [Order/SignedOrder](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_schemas.ts)
-* [OrderHash](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_hash_schema.ts)
+* [Order](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_schema.json)
+* [SignedOrder](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/signed_order_schema.json)
+* [OrderHash](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_hash_schema.json)
+* [ECSignature](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/ec_signature_schema.json)
0x.js Schemas
-* [BlockRange](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/block_range_schema.ts)
-* [IndexFilter Values](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/index_filter_values_schema.ts)
-* [OrderFillRequests](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_fill_requests_schema.ts)
-* [OrderCancellationRequests](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_cancel_schema.ts)
-* [OrderFillOrKillRequests](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts)
-* [SignedOrders](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/signed_orders_schema.ts)
-* [Token](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/token_schema.ts)
-* [TxData](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/tx_data_schema.ts)
+* [BlockParam](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/block_param_schema.json)
+* [BlockRange](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/block_range_schema.json)
+* [IndexFilter Values](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/index_filter_values_schema.json)
+* [OrderFillRequests](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_fill_requests_schema.json)
+* [OrderCancellationRequests](https://github.com/0xProjet/0x-monorepo/blob/development/packages/json-schemas/schemas/order_cancel_schema.json)
+* [OrderFillOrKillRequests](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.json)
+* [SignedOrders](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/signed_orders_schema.json)
+* [Token](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/token_schema.json)
+* [TxData](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/tx_data_schema.json)
Standard Relayer API Schemas
-* [Paginated collection](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/paginated_collection_schema.ts)
-* [Error response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_error_response_schema.ts)
-* [Order config payload](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts)
-* [Order config response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts)
-* [Orders channel subscribe](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts)
-* [Orders channel update](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts)
-* [Orderbook response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts)
-* [Asset pairs response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts)
-* [Fee recipients response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.ts)
+* [Paginated collection](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/paginated_collection_schema.json)
+* [Error response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_error_response_schema.json)
+* [Order config payload](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.json)
+* [Order config response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json)
+* [Orders channel subscribe payload](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_payload_schema.json)
+* [Orders channel subscribe](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.json)
+* [Orders channel update](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.json)
+* [Orderbook response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.json)
+* [Asset pairs](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_asset_pairs_schema.json)
+* [Trade info](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_asset_trade_info_schema.json)
+* [Asset pairs response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.json)
+* [Fee recipients response](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.json)
diff --git a/packages/website/package.json b/packages/website/package.json
index 22250f59a..4af556b5f 100644
--- a/packages/website/package.json
+++ b/packages/website/package.json
@@ -53,7 +53,7 @@
"react-helmet": "^5.2.0",
"react-popper": "^1.0.0-beta.6",
"react-redux": "^5.0.3",
- "react-scroll": "0xproject/react-scroll#similar-to-pr-330",
+ "react-scroll": "0xproject/react-scroll#similar-to-pr-330-but-with-replace-state",
"react-tooltip": "^3.2.7",
"react-typist": "^2.0.4",
"redux": "^3.6.0",
diff --git a/packages/website/public/css/basscss_responsive_custom.css b/packages/website/public/css/basscss_responsive_custom.css
index 5f8bd9117..92a681cb1 100644
--- a/packages/website/public/css/basscss_responsive_custom.css
+++ b/packages/website/public/css/basscss_responsive_custom.css
@@ -26,6 +26,10 @@
.sm-right {
float: right;
}
+ .sm-justify-end {
+ ms-flex-pack: end;
+ justify-content: flex-end;
+ }
}
@media (min-width: 52em) {
@@ -54,6 +58,10 @@
.md-right {
float: right;
}
+ .md-justify-end {
+ ms-flex-pack: end;
+ justify-content: flex-end;
+ }
}
@media (min-width: 64em) {
@@ -82,4 +90,8 @@
.lg-right {
float: right;
}
+ .lg-justify-end {
+ ms-flex-pack: end;
+ justify-content: flex-end;
+ }
}
diff --git a/packages/website/public/images/developers/chat_icon.svg b/packages/website/public/images/developers/chat_icon.svg
deleted file mode 100644
index c48881454..000000000
--- a/packages/website/public/images/developers/chat_icon.svg
+++ /dev/null
@@ -1,5 +0,0 @@
-<svg width="34" height="32" viewBox="0 0 34 32" fill="none" xmlns="http://www.w3.org/2000/svg">
-<rect width="16.5161" height="16" fill="black" fill-opacity="0" transform="scale(2)"/>
-<path d="M8.25781 32.0002L17.5481 24.7744H8.25781V32.0002Z" fill="#3289F1"/>
-<path d="M0 6C0 2.68629 2.68629 0 6 0H27.0323C30.346 0 33.0323 2.68629 33.0323 6V18.7742C33.0323 22.0879 30.346 24.7742 27.0323 24.7742H6C2.68629 24.7742 0 22.0879 0 18.7742V6Z" fill="#3289F1"/>
-</svg>
diff --git a/packages/website/public/images/developers/forum_icon.svg b/packages/website/public/images/developers/forum_icon.svg
deleted file mode 100644
index 8fb659475..000000000
--- a/packages/website/public/images/developers/forum_icon.svg
+++ /dev/null
@@ -1,5 +0,0 @@
-<svg width="36" height="30" viewBox="0 0 36 30" fill="none" xmlns="http://www.w3.org/2000/svg">
-<rect width="17.2308" height="14" fill="black" fill-opacity="0" transform="translate(0 29) scale(2 -2)"/>
-<rect width="17.2308" height="14" fill="black" fill-opacity="0" transform="translate(0 29) scale(2 -2)"/>
-<path fill-rule="evenodd" clip-rule="evenodd" d="M11.9196 6.90474C18.7267 6.90474 25.5338 6.90474 32.3409 6.90474C35.1684 6.90474 35.1684 2.355 32.3409 2.355C25.5338 2.355 18.7267 2.355 11.9196 2.355C9.0921 2.355 9.0921 6.90474 11.9196 6.90474ZM3.41008 8.27457C5.29364 8.27457 6.82103 6.64616 6.82103 4.63682C6.82103 2.62841 5.29364 1 3.41008 1C1.5274 1 0 2.62841 0 4.63682C0 6.64616 1.5274 8.27457 3.41008 8.27457ZM11.9196 17.2684C18.7267 17.2684 25.5338 17.2684 32.3409 17.2684C35.1684 17.2684 35.1684 12.7177 32.3409 12.7177C25.5338 12.7177 18.7267 12.7177 11.9196 12.7177C9.0921 12.7177 9.0921 17.2684 11.9196 17.2684ZM3.41008 18.6373C5.29364 18.6373 6.82103 17.0089 6.82103 14.9995C6.82103 12.9911 5.29364 11.3627 3.41008 11.3627C1.5274 11.3627 0 12.9911 0 14.9995C0 17.0089 1.5274 18.6373 3.41008 18.6373ZM11.9196 27.6311C18.7267 27.6311 25.5338 27.6311 32.3409 27.6311C35.1684 27.6311 35.1684 23.0804 32.3409 23.0804C25.5338 23.0804 18.7267 23.0804 11.9196 23.0804C9.0921 23.0804 9.0921 27.6311 11.9196 27.6311ZM3.41008 29C5.29364 29 6.82103 27.3716 6.82103 25.3623C6.82103 23.3538 5.29364 21.7254 3.41008 21.7254C1.5274 21.7254 0 23.3538 0 25.3623C0 27.3716 1.5274 29 3.41008 29Z" fill="#999999"/>
-</svg>
diff --git a/packages/website/public/images/developers/github_icon.svg b/packages/website/public/images/developers/github_icon.svg
deleted file mode 100644
index bf10cb221..000000000
--- a/packages/website/public/images/developers/github_icon.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-<svg width="38" height="36" viewBox="0 0 38 36" fill="none" xmlns="http://www.w3.org/2000/svg">
-<rect width="18.3529" height="18" fill="black" fill-opacity="0" transform="scale(2)"/>
-<path d="M18.3529 0C8.2176 0 0 8.26332 0 18.455C0 26.6102 5.25812 33.5264 12.5515 35.9661C13.469 36.1351 13.8039 35.5651 13.8039 35.0785C13.8039 34.6392 13.7871 33.1839 13.7781 31.643C8.67463 32.7581 7.5959 29.4668 7.5959 29.4668C6.76026 27.3356 5.55829 26.7679 5.55829 26.7679C3.89036 25.6235 5.68482 25.646 5.68482 25.646C7.5275 25.7744 8.49763 27.5474 8.49763 27.5474C10.1353 30.3679 12.7946 29.5524 13.8386 29.0793C14.0054 27.8898 14.4804 27.0743 15.0036 26.6147C10.9295 26.1484 6.64376 24.5647 6.64376 17.4931C6.64376 15.4768 7.35957 13.8323 8.53125 12.5403C8.34417 12.0717 7.71239 10.194 8.7127 7.65394C8.7127 7.65394 10.2518 7.15832 13.7602 9.5463C15.2231 9.13517 16.7925 8.93242 18.3529 8.92564C19.9122 8.93242 21.4827 9.13741 22.9479 9.54854C26.4496 7.15832 27.9909 7.65617 27.9909 7.65617C28.9946 10.1985 28.3628 12.0739 28.1746 12.5403C29.3508 13.8323 30.061 15.4768 30.061 17.4931C30.061 24.5827 25.7685 26.1439 21.6799 26.6012C22.3408 27.1734 22.9255 28.2953 22.9255 30.0165C22.9255 32.4833 22.9009 34.4725 22.9009 35.0808C22.9009 35.5719 23.2346 36.1464 24.1644 35.9661C31.4523 33.5218 36.7059 26.6057 36.7059 18.455C36.7059 8.26332 28.4883 0 18.3529 0Z" fill="#999999"/>
-</svg>
diff --git a/packages/website/translations/english.json b/packages/website/translations/english.json
index 6ee780c78..fab8ed56b 100644
--- a/packages/website/translations/english.json
+++ b/packages/website/translations/english.json
@@ -73,6 +73,7 @@
"WIKI": "wiki",
"WEB3_WRAPPER": "Web3Wrapper",
"ORDER_UTILS": "Order Utils",
+ "ASSET_BUYER": "AssetBuyer",
"FAQ": "FAQ",
"SMART_CONTRACTS": "0x smart contracts",
"STANDARD_RELAYER_API": "standard relayer API",
diff --git a/packages/website/ts/components/documentation/docs_top_bar.tsx b/packages/website/ts/components/documentation/docs_top_bar.tsx
index 9a2146f9c..9a9b9a616 100644
--- a/packages/website/ts/components/documentation/docs_top_bar.tsx
+++ b/packages/website/ts/components/documentation/docs_top_bar.tsx
@@ -1,33 +1,25 @@
-import { ALink, colors, Link, NestedSidebarMenu } from '@0xproject/react-shared';
-import { ObjectMap } from '@0xproject/types';
+import { ALink, colors, Link } from '@0xproject/react-shared';
import * as _ from 'lodash';
import Drawer from 'material-ui/Drawer';
import * as React from 'react';
import { DocsLogo } from 'ts/components/documentation/docs_logo';
import { Container } from 'ts/components/ui/container';
import { Text } from 'ts/components/ui/text';
-import { Deco, Key, WebsitePaths } from 'ts/types';
+import { Deco, Key, ScreenWidths } from 'ts/types';
import { constants } from 'ts/utils/constants';
import { Translate } from 'ts/utils/translate';
export interface DocsTopBarProps {
location: Location;
+ screenWidth: ScreenWidths;
translate: Translate;
- sectionNameToLinks?: ObjectMap<ALink[]>;
+ sidebar?: React.ReactNode;
}
interface DocsTopBarState {
isDrawerOpen: boolean;
}
-interface MenuItemInfo {
- title: string;
- url: string;
- iconUrl: string;
- fontColor: string;
- fontWeight?: string;
-}
-
export class DocsTopBar extends React.Component<DocsTopBarProps, DocsTopBarState> {
constructor(props: DocsTopBarProps) {
super(props);
@@ -43,52 +35,19 @@ export class DocsTopBar extends React.Component<DocsTopBarProps, DocsTopBarState
}
}
public render(): React.ReactNode {
- const menuItemInfos: MenuItemInfo[] = [
- {
- title: this.props.translate.get(Key.Github, Deco.Cap),
- url: constants.URL_GITHUB_ORG,
- iconUrl: '/images/developers/github_icon.svg',
- fontColor: colors.linkSectionGrey,
- },
- {
- title: this.props.translate.get(Key.Forum, Deco.Cap),
- url: constants.URL_FORUM,
- iconUrl: '/images/developers/forum_icon.svg',
- fontColor: colors.linkSectionGrey,
- },
- {
- title: this.props.translate.get(Key.LiveChat, Deco.Cap),
- url: constants.URL_ZEROEX_CHAT,
- iconUrl: '/images/developers/chat_icon.svg',
- fontColor: colors.lightLinkBlue,
- fontWeight: 'bold',
- },
- ];
return (
<Container height={80}>
- <Container className="flex items-center lg-pt3 md-pt3 sm-pt1 relative" width="100%">
- <Container className="col col-2 sm-hide xs-hide">
- <Link
- to={WebsitePaths.Home}
- fontColor={colors.linkSectionGrey}
- className="flex items-center text-decoration-none"
- >
- <i className="zmdi zmdi-chevron-left bold" style={{ fontSize: 16 }} />
- <Container paddingLeft="8px">
- <Text fontSize="16px" fontColor={colors.linkSectionGrey}>
- 0xproject.com
- </Text>
- </Container>
- </Link>
- </Container>
- <Container className="col col-4 md-hide sm-hide xs-hide" />
- <Container className="col col-6 md-pl4 md-ml4 sm-hide xs-hide">
+ <Container
+ className="flex items-center lg-pt3 md-pt3 sm-pt1 lg-mt1 md-mt1 sm-mt0 lg-justify-end md-justify-end sm-justify-start"
+ width="100%"
+ >
+ <Container className="sm-hide xs-hide">
<Container className="flex items-center justify-between right" width="300px">
- {this._renderMenuItems(menuItemInfos)}
+ {this._renderMenuItems(constants.DEVELOPER_TOPBAR_LINKS)}
</Container>
</Container>
<Container className="lg-hide md-hide">
- <Container paddingTop="6px" paddingLeft="18px">
+ <Container paddingTop="6px">
<DocsLogo height={30} />
</Container>
</Container>
@@ -104,33 +63,25 @@ export class DocsTopBar extends React.Component<DocsTopBarProps, DocsTopBarState
/>
</Container>
</Container>
- <Container width={'100%'} height={'1px'} backgroundColor={colors.grey300} marginTop={'11px'} />
- {this._renderDrawer()}
+ <Container width={'100%'} height={'1px'} backgroundColor={colors.grey300} marginTop={'13px'} />
+ {this.props.screenWidth === ScreenWidths.Sm && this._renderDrawer()}
</Container>
);
}
- private _renderMenuItems(menuItemInfos: MenuItemInfo[]): React.ReactNode {
- const menuItems = _.map(menuItemInfos, menuItemInfo => {
+ private _renderMenuItems(menuItemLinks: ALink[]): React.ReactNode {
+ const menuItems = _.map(menuItemLinks, menuItemInfo => {
return (
- <a
+ <Link
key={`menu-item-${menuItemInfo.title}`}
- href={menuItemInfo.url}
- target="_blank"
- className="text-decoration-none"
+ to={menuItemInfo.to}
+ shouldOpenInNewTab={menuItemInfo.shouldOpenInNewTab}
>
- <Container className="flex">
- <img src={menuItemInfo.iconUrl} width="18" />
- <Container className="flex items-center" paddingLeft="4px">
- <Text
- fontSize="16px"
- fontWeight={menuItemInfo.fontWeight || 'normal'}
- fontColor={menuItemInfo.fontColor}
- >
- {menuItemInfo.title}
- </Text>
- </Container>
+ <Container className="flex items-center" paddingLeft="4px">
+ <Text fontSize="16px" fontColor={colors.lightLinkBlue} fontWeight="bold">
+ {this.props.translate.get(menuItemInfo.title as Key, Deco.Cap)}
+ </Text>
</Container>
- </a>
+ </Link>
);
});
return menuItems;
@@ -143,13 +94,8 @@ export class DocsTopBar extends React.Component<DocsTopBarProps, DocsTopBarState
openSecondary={true}
onRequestChange={this._onMenuButtonClick.bind(this)}
>
- <Container className="clearfix pl1">
- <NestedSidebarMenu
- sectionNameToLinks={this.props.sectionNameToLinks}
- shouldDisplaySectionHeaders={true}
- shouldReformatMenuItemNames={false}
- onMenuItemClick={this._onMenuButtonClick.bind(this)}
- />
+ <Container className="clearfix pl1 pt2" onClick={this._onMenuButtonClick.bind(this)}>
+ {this.props.sidebar}
</Container>
</Drawer>
);
diff --git a/packages/website/ts/components/documentation/overview_content.tsx b/packages/website/ts/components/documentation/overview_content.tsx
new file mode 100644
index 000000000..6999e039a
--- /dev/null
+++ b/packages/website/ts/components/documentation/overview_content.tsx
@@ -0,0 +1,134 @@
+import { colors, Link, MarkdownLinkBlock, utils as sharedUtils } from '@0xproject/react-shared';
+import { ObjectMap } from '@0xproject/types';
+import * as _ from 'lodash';
+import * as React from 'react';
+import * as ReactMarkdown from 'react-markdown';
+import { Element as ScrollElement } from 'react-scroll';
+import { TutorialButton } from 'ts/components/documentation/tutorial_button';
+import { Container } from 'ts/components/ui/container';
+import { Text } from 'ts/components/ui/text';
+import { Deco, Key, Package, TutorialInfo } from 'ts/types';
+import { Translate } from 'ts/utils/translate';
+
+export interface OverviewContentProps {
+ translate: Translate;
+ tutorials: TutorialInfo[];
+ categoryToPackages: ObjectMap<Package[]>;
+}
+
+export interface OverviewContentState {}
+
+export class OverviewContent extends React.Component<OverviewContentProps, OverviewContentState> {
+ public render(): React.ReactNode {
+ return (
+ <Container>
+ {this._renderSectionTitle(this.props.translate.get(Key.StartBuildOn0x, Deco.Cap))}
+ <Container paddingTop="12px">
+ {this._renderSectionDescription(this.props.translate.get(Key.StartBuildOn0xDescription, Deco.Cap))}
+ <Container marginTop="36px">
+ {_.map(this.props.tutorials, tutorialInfo => (
+ <ScrollElement
+ name={sharedUtils.getIdFromName(
+ this.props.translate.get(tutorialInfo.link.title as Key, Deco.Cap),
+ )}
+ key={`tutorial-${tutorialInfo.link.title}`}
+ >
+ <TutorialButton translate={this.props.translate} tutorialInfo={tutorialInfo} />
+ </ScrollElement>
+ ))}
+ </Container>
+ </Container>
+ <Container marginTop="32px" paddingBottom="100px">
+ {this._renderSectionTitle(this.props.translate.get(Key.LibrariesAndTools, Deco.CapWords))}
+ <Container paddingTop="12px">
+ {this._renderSectionDescription(
+ this.props.translate.get(Key.LibrariesAndToolsDescription, Deco.Cap),
+ )}
+ <Container marginTop="36px">
+ {_.map(this.props.categoryToPackages, (pkgs, category) =>
+ this._renderPackageCategory(category, pkgs),
+ )}
+ </Container>
+ </Container>
+ </Container>
+ </Container>
+ );
+ }
+ private _renderPackageCategory(category: string, pkgs: Package[]): React.ReactNode {
+ return (
+ <Container key={`category-${category}`}>
+ <Text fontSize="18px">{category}</Text>
+ <Container>{_.map(pkgs, pkg => this._renderPackage(pkg))}</Container>
+ </Container>
+ );
+ }
+ private _renderPackage(pkg: Package): React.ReactNode {
+ const id = sharedUtils.getIdFromName(pkg.link.title);
+ return (
+ <ScrollElement name={id} key={`package-${pkg.link.title}`}>
+ <Container className="pb2">
+ <Container width="100%" height="1px" backgroundColor={colors.grey300} marginTop="11px" />
+ <Container className="clearfix mt2 pt1">
+ <Container className="md-col lg-col md-col-4 lg-col-4">
+ <Link
+ to={pkg.link.to}
+ fontColor={colors.lightLinkBlue}
+ shouldOpenInNewTab={!!pkg.link.shouldOpenInNewTab}
+ >
+ <Text Tag="div" fontColor={colors.lightLinkBlue} fontWeight="bold">
+ {pkg.link.title}
+ </Text>
+ </Link>
+ </Container>
+ <Container className="md-col lg-col md-col-6 lg-col-6 sm-py2">
+ <Text fontColor={colors.grey700}>
+ <ReactMarkdown
+ source={pkg.description}
+ renderers={{
+ link: MarkdownLinkBlock,
+ paragraph: 'span',
+ }}
+ />
+ </Text>
+ </Container>
+ <Container className="md-col lg-col md-col-2 lg-col-2 sm-pb2 relative">
+ <Container position="absolute" right="0px">
+ <Link
+ to={pkg.link.to}
+ fontColor={colors.lightLinkBlue}
+ shouldOpenInNewTab={!!pkg.link.shouldOpenInNewTab}
+ >
+ <Container className="flex">
+ <Container>{this.props.translate.get(Key.More, Deco.Cap)}</Container>
+ <Container paddingTop="1px" paddingLeft="6px">
+ <i
+ className="zmdi zmdi-chevron-right bold"
+ style={{ fontSize: 18, color: colors.lightLinkBlue }}
+ />
+ </Container>
+ </Container>
+ </Link>
+ </Container>
+ </Container>
+ </Container>
+ </Container>
+ </ScrollElement>
+ );
+ }
+ private _renderSectionTitle(text: string): React.ReactNode {
+ return (
+ <Container paddingTop="30px">
+ <Text fontColor={colors.projectsGrey} fontSize="30px" fontWeight="bold">
+ {text}
+ </Text>
+ </Container>
+ );
+ }
+ private _renderSectionDescription(text: string): React.ReactNode {
+ return (
+ <Text fontColor={colors.linkSectionGrey} fontSize="16px" fontFamily="Roboto Mono">
+ {text}
+ </Text>
+ );
+ }
+} // tslint:disable:max-file-line-count
diff --git a/packages/website/ts/components/documentation/sidebar_header.tsx b/packages/website/ts/components/documentation/sidebar_header.tsx
new file mode 100644
index 000000000..ec0ada8bd
--- /dev/null
+++ b/packages/website/ts/components/documentation/sidebar_header.tsx
@@ -0,0 +1,57 @@
+import { colors } from '@0xproject/react-shared';
+import * as _ from 'lodash';
+import * as React from 'react';
+import { VersionDropDown } from 'ts/components/documentation/version_drop_down';
+import { Container } from 'ts/components/ui/container';
+import { Text } from 'ts/components/ui/text';
+import { ScreenWidths } from 'ts/types';
+
+export interface SidebarHeaderProps {
+ screenWidth: ScreenWidths;
+ title: string;
+ docsVersion?: string;
+ availableDocVersions?: string[];
+ onVersionSelected?: () => void;
+}
+
+export const SidebarHeader: React.StatelessComponent<SidebarHeaderProps> = ({
+ screenWidth,
+ title,
+ docsVersion,
+ availableDocVersions,
+ onVersionSelected,
+}) => {
+ return (
+ <Container>
+ <Container className="flex justify-bottom">
+ <Container className="left pl1" width="150px">
+ <Text
+ fontColor={colors.lightLinkBlue}
+ fontSize={screenWidth === ScreenWidths.Sm ? '20px' : '22px'}
+ fontWeight="bold"
+ >
+ {title}
+ </Text>
+ </Container>
+ {!_.isUndefined(docsVersion) &&
+ !_.isUndefined(availableDocVersions) &&
+ !_.isUndefined(onVersionSelected) && (
+ <div className="right" style={{ alignSelf: 'flex-end' }}>
+ <VersionDropDown
+ selectedVersion={docsVersion}
+ versions={availableDocVersions}
+ onVersionSelected={onVersionSelected}
+ />
+ </div>
+ )}
+ </Container>
+ <Container
+ width={'100%'}
+ height={'1px'}
+ backgroundColor={colors.grey300}
+ marginTop="20px"
+ marginBottom="27px"
+ />
+ </Container>
+ );
+};
diff --git a/packages/website/ts/components/documentation/version_drop_down.tsx b/packages/website/ts/components/documentation/version_drop_down.tsx
new file mode 100644
index 000000000..ec1c99f7b
--- /dev/null
+++ b/packages/website/ts/components/documentation/version_drop_down.tsx
@@ -0,0 +1,80 @@
+import { colors } from '@0xproject/react-shared';
+import * as _ from 'lodash';
+import * as React from 'react';
+import { Button } from 'ts/components/ui/button';
+import { Container } from 'ts/components/ui/container';
+import { DropDown, DropdownMouseEvent } from 'ts/components/ui/drop_down';
+import { Text } from 'ts/components/ui/text';
+import { styled } from 'ts/style/theme';
+
+interface ActiveNodeProps {
+ className?: string;
+ selectedVersion: string;
+}
+
+const PlainActiveNode: React.StatelessComponent<ActiveNodeProps> = ({ className, selectedVersion }) => (
+ <Container className={className}>
+ <Container className="flex justify-center">
+ <Text fontColor={colors.grey700} fontSize="12px">
+ v {selectedVersion}
+ </Text>
+ <Container paddingLeft="6px">
+ <i className="zmdi zmdi-chevron-down" style={{ fontSize: 17, color: 'rgba(153, 153, 153, 0.8)' }} />
+ </Container>
+ </Container>
+ </Container>
+);
+
+const ActiveNode = styled(PlainActiveNode)`
+ cursor: pointer;
+ border: 2px solid ${colors.beigeWhite};
+ border-radius: 4px;
+ padding: 4px 6px 4px 8px;
+`;
+
+interface VersionDropDownProps {
+ selectedVersion: string;
+ versions: string[];
+ onVersionSelected: (semver: string) => void;
+}
+
+interface VersionDropDownState {}
+
+export class VersionDropDown extends React.Component<VersionDropDownProps, VersionDropDownState> {
+ public render(): React.ReactNode {
+ const activeNode = <ActiveNode selectedVersion={this.props.selectedVersion} />;
+ return (
+ <DropDown
+ activateEvent={DropdownMouseEvent.Click}
+ activeNode={activeNode}
+ popoverContent={this._renderDropdownMenu()}
+ anchorOrigin={{ horizontal: 'middle', vertical: 'bottom' }}
+ targetOrigin={{ horizontal: 'middle', vertical: 'top' }}
+ popoverStyle={{ borderRadius: 4 }}
+ />
+ );
+ }
+ private _renderDropdownMenu(): React.ReactNode {
+ const items = _.map(this.props.versions, version => {
+ const isSelected = version === this.props.selectedVersion;
+ return (
+ <Container key={`dropdown-items-${version}`}>
+ <Button
+ borderRadius="0px"
+ padding="0.8em 0em"
+ width="100%"
+ isDisabled={isSelected}
+ onClick={this._onClick.bind(this, version)}
+ >
+ v {version}
+ </Button>
+ </Container>
+ );
+ });
+ const dropdownMenu = <Container width="88px">{items}</Container>;
+ return dropdownMenu;
+ }
+ private _onClick(selectedVersion: string): void {
+ this.props.onVersionSelected(selectedVersion);
+ }
+}
diff --git a/packages/website/ts/components/dropdowns/developers_drop_down.tsx b/packages/website/ts/components/dropdowns/developers_drop_down.tsx
index df5dc173d..1db1e89b8 100644
--- a/packages/website/ts/components/dropdowns/developers_drop_down.tsx
+++ b/packages/website/ts/components/dropdowns/developers_drop_down.tsx
@@ -44,6 +44,10 @@ const popularDocsToLinkInfos: ALink[] = [
];
const usefulLinksToLinkInfo: ALink[] = [
{
+ title: Key.Wiki,
+ to: WebsitePaths.Wiki,
+ },
+ {
title: Key.Github,
to: constants.URL_GITHUB_ORG,
shouldOpenInNewTab: true,
@@ -53,11 +57,6 @@ const usefulLinksToLinkInfo: ALink[] = [
to: WebsitePaths.Whitepaper,
shouldOpenInNewTab: true,
},
- {
- title: Key.Sandbox,
- to: constants.URL_SANDBOX,
- shouldOpenInNewTab: true,
- },
];
interface DevelopersDropDownProps {
@@ -85,7 +84,7 @@ export class DevelopersDropDown extends React.Component<DevelopersDropDownProps,
anchorOrigin={{ horizontal: 'left', vertical: 'bottom' }}
targetOrigin={{ horizontal: 'left', vertical: 'top' }}
style={this.props.menuItemStyles}
- popoverStyle={{ borderRadius: 4, width: 427, height: 373, marginTop: 10 }}
+ popoverStyle={{ borderRadius: 4, width: 397, height: 373, marginTop: 0 }}
/>
);
}
diff --git a/packages/website/ts/components/footer.tsx b/packages/website/ts/components/footer.tsx
index f11ecae19..db4f57100 100644
--- a/packages/website/ts/components/footer.tsx
+++ b/packages/website/ts/components/footer.tsx
@@ -40,6 +40,10 @@ export class Footer extends React.Component<FooterProps, FooterState> {
const sectionNameToLinks: ObjectMap<ALink[]> = {
[Key.Documentation]: [
{
+ title: 'Developer Home',
+ to: WebsitePaths.Docs,
+ },
+ {
title: '0x.js',
to: WebsitePaths.ZeroExJs,
},
@@ -60,10 +64,6 @@ export class Footer extends React.Component<FooterProps, FooterState> {
title: this.props.translate.get(Key.Wiki, Deco.Cap),
to: WebsitePaths.Wiki,
},
- {
- title: this.props.translate.get(Key.Faq, Deco.Cap),
- to: WebsitePaths.FAQ,
- },
],
[Key.Community]: [
{
diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx
index b8cd45661..c58dc26bd 100644
--- a/packages/website/ts/components/portal/portal.tsx
+++ b/packages/website/ts/components/portal/portal.tsx
@@ -18,7 +18,7 @@ import { Loading } from 'ts/components/portal/loading';
import { Menu, MenuTheme } from 'ts/components/portal/menu';
import { Section } from 'ts/components/portal/section';
import { TextHeader } from 'ts/components/portal/text_header';
-import { RelayerIndex } from 'ts/components/relayer_index/relayer_index';
+import { RelayerIndex, RelayerIndexCellStyle } from 'ts/components/relayer_index/relayer_index';
import { TokenBalances } from 'ts/components/token_balances';
import { TopBar, TopBarDisplayType } from 'ts/components/top_bar/top_bar';
import { TradeHistory } from 'ts/components/trade_history/trade_history';
@@ -539,6 +539,7 @@ export class Portal extends React.Component<PortalProps, PortalState> {
}
private _renderRelayerIndexSection(): React.ReactNode {
const isMobile = utils.isMobileWidth(this.props.screenWidth);
+ // TODO(bmillman): revert RelayerIndex cellStyle to Expanded once data pipeline is tracking v2 volume
return (
<Section
header={!isMobile && <TextHeader labelText="0x Relayers" />}
@@ -549,7 +550,11 @@ export class Portal extends React.Component<PortalProps, PortalState> {
{this._renderStartOnboarding()}
</Container>
)}
- <RelayerIndex networkId={this.props.networkId} screenWidth={this.props.screenWidth} />
+ <RelayerIndex
+ networkId={this.props.networkId}
+ screenWidth={this.props.screenWidth}
+ cellStyle={RelayerIndexCellStyle.Minimized}
+ />
</Container>
}
/>
diff --git a/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx b/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx
index 193dd237a..a81ab107a 100644
--- a/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx
+++ b/packages/website/ts/components/relayer_index/relayer_grid_tile.tsx
@@ -14,9 +14,15 @@ import { styled } from 'ts/style/theme';
import { WebsiteBackendRelayerInfo } from 'ts/types';
import { utils } from 'ts/utils/utils';
+export enum RelayerGridTileStyle {
+ Expanded = 0,
+ Minimized,
+}
+
export interface RelayerGridTileProps {
relayerInfo: WebsiteBackendRelayerInfo;
networkId: number;
+ style: RelayerGridTileStyle;
}
const styles: Styles = {
@@ -30,10 +36,14 @@ const styles: Styles = {
height: '100%',
boxSizing: 'border-box',
},
- header: {
+ expandedHeader: {
height: '50%',
width: '100%',
},
+ minimizedHeader: {
+ height: '100%',
+ width: '100%',
+ },
body: {
height: '50%',
width: '100%',
@@ -75,10 +85,12 @@ export const RelayerGridTile: React.StatelessComponent<RelayerGridTileProps> = (
!_.isUndefined(headerImageUrl) && !_.isUndefined(props.relayerInfo.primaryColor)
? props.relayerInfo.primaryColor
: FALLBACK_PRIMARY_COLOR;
+ const isExpanded = props.style === RelayerGridTileStyle.Expanded;
+ const headerStyle = isExpanded ? styles.expandedHeader : styles.minimizedHeader;
return (
<Island style={styles.root} Component={GridTile}>
<div style={styles.innerDiv} onClick={onClick}>
- <div className="flex items-center" style={{ ...styles.header, backgroundColor: headerBackgroundColor }}>
+ <div className="flex items-center" style={{ ...headerStyle, backgroundColor: headerBackgroundColor }}>
<Image
className="mx-auto"
src={props.relayerInfo.logoImgUrl}
@@ -86,21 +98,23 @@ export const RelayerGridTile: React.StatelessComponent<RelayerGridTileProps> = (
height={RELAYER_ICON_HEIGHT}
/>
</div>
- <div style={styles.body}>
- <div className="pb1" style={styles.relayerNameLabel}>
- {props.relayerInfo.name}
- </div>
- <Section titleText="Weekly Trade Volume">
- {!_.isUndefined(weeklyTxnVolume) && (
- <div style={styles.weeklyTradeVolumeLabel}>{props.relayerInfo.weeklyTxnVolume}</div>
- )}
- </Section>
- <Container marginTop="10px">
- <Section titleText="Top Tokens">
- {!_.isEmpty(topTokens) && <TopTokens tokens={topTokens} networkId={props.networkId} />}
+ {isExpanded && (
+ <div style={styles.body}>
+ <div className="pb1" style={styles.relayerNameLabel}>
+ {props.relayerInfo.name}
+ </div>
+ <Section titleText="Weekly Trade Volume">
+ {!_.isUndefined(weeklyTxnVolume) && (
+ <div style={styles.weeklyTradeVolumeLabel}>{props.relayerInfo.weeklyTxnVolume}</div>
+ )}
</Section>
- </Container>
- </div>
+ <Container marginTop="10px">
+ <Section titleText="Top Tokens">
+ {!_.isEmpty(topTokens) && <TopTokens tokens={topTokens} networkId={props.networkId} />}
+ </Section>
+ </Container>
+ </div>
+ )}
</div>
</Island>
);
diff --git a/packages/website/ts/components/relayer_index/relayer_index.tsx b/packages/website/ts/components/relayer_index/relayer_index.tsx
index 91dbeb27a..e88c20d7e 100644
--- a/packages/website/ts/components/relayer_index/relayer_index.tsx
+++ b/packages/website/ts/components/relayer_index/relayer_index.tsx
@@ -3,14 +3,20 @@ import CircularProgress from 'material-ui/CircularProgress';
import { GridList } from 'material-ui/GridList';
import * as React from 'react';
-import { RelayerGridTile } from 'ts/components/relayer_index/relayer_grid_tile';
+import { RelayerGridTile, RelayerGridTileStyle } from 'ts/components/relayer_index/relayer_grid_tile';
import { Retry } from 'ts/components/ui/retry';
import { ScreenWidths, WebsiteBackendRelayerInfo } from 'ts/types';
import { backendClient } from 'ts/utils/backend_client';
+export enum RelayerIndexCellStyle {
+ Expanded = 0,
+ Minimized,
+}
+
export interface RelayerIndexProps {
networkId: number;
screenWidth: ScreenWidths;
+ cellStyle: RelayerIndexCellStyle;
}
interface RelayerIndexState {
@@ -18,7 +24,8 @@ interface RelayerIndexState {
error?: Error;
}
-const CELL_HEIGHT = 290;
+const CELL_HEIGHT_EXPANDED = 290;
+const CELL_HEIGHT_MINIMIZED = 225;
const NUMBER_OF_COLUMNS_LARGE = 3;
const NUMBER_OF_COLUMNS_MEDIUM = 2;
const NUMBER_OF_COLUMNS_SMALL = 2;
@@ -61,15 +68,23 @@ export class RelayerIndex extends React.Component<RelayerIndexProps, RelayerInde
numberOfRelayers,
this._numberOfColumnsForScreenWidth(this.props.screenWidth),
);
+ const isExpanded = this.props.cellStyle === RelayerIndexCellStyle.Expanded;
+ const cellHeight = isExpanded ? CELL_HEIGHT_EXPANDED : CELL_HEIGHT_MINIMIZED;
+ const gridTileStyle = isExpanded ? RelayerGridTileStyle.Expanded : RelayerGridTileStyle.Minimized;
return (
<GridList
- cellHeight={CELL_HEIGHT}
+ cellHeight={cellHeight}
cols={numberOfColumns}
padding={GRID_PADDING}
style={{ marginTop: -10, marginBottom: 0 }}
>
{this.state.relayerInfos.map((relayerInfo: WebsiteBackendRelayerInfo, index) => (
- <RelayerGridTile key={index} relayerInfo={relayerInfo} networkId={this.props.networkId} />
+ <RelayerGridTile
+ key={index}
+ relayerInfo={relayerInfo}
+ networkId={this.props.networkId}
+ style={gridTileStyle}
+ />
))}
</GridList>
);
diff --git a/packages/website/ts/components/sidebar_header.tsx b/packages/website/ts/components/sidebar_header.tsx
deleted file mode 100644
index a14ab54f5..000000000
--- a/packages/website/ts/components/sidebar_header.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import { colors } from '@0xproject/react-shared';
-import * as React from 'react';
-
-interface SidebarHeaderProps {
- title: string;
- iconUrl: string;
-}
-
-interface SidebarHeaderState {}
-
-export class SidebarHeader extends React.Component<SidebarHeaderProps, SidebarHeaderState> {
- public render(): React.ReactNode {
- return (
- <div className="pt2 md-px1 sm-px2" style={{ color: colors.black, paddingBottom: 18 }}>
- <div className="flex" style={{ fontSize: 25 }}>
- <div style={{ fontWeight: 'bold', fontFamily: 'Roboto Mono' }}>0x</div>
- <div className="pl2" style={{ lineHeight: 1.4, fontWeight: 300 }}>
- docs
- </div>
- </div>
- <div className="pl1" style={{ color: colors.grey350, paddingBottom: 9, paddingLeft: 10, height: 17 }}>
- |
- </div>
- <div className="flex">
- <div>
- <img src={this.props.iconUrl} width="22" />
- </div>
- <div className="pl1" style={{ fontWeight: 600, fontSize: 20, lineHeight: 1.2 }}>
- {this.props.title}
- </div>
- </div>
- </div>
- );
- }
-}
diff --git a/packages/website/ts/components/top_bar/top_bar.tsx b/packages/website/ts/components/top_bar/top_bar.tsx
index 3297befad..7e7247c25 100644
--- a/packages/website/ts/components/top_bar/top_bar.tsx
+++ b/packages/website/ts/components/top_bar/top_bar.tsx
@@ -1,5 +1,5 @@
import { DocsInfo } from '@0xproject/react-docs';
-import { ALink, colors, constants as sharedConstants, Link, NestedSidebarMenu, Styles } from '@0xproject/react-shared';
+import { ALink, colors, Link, Styles } from '@0xproject/react-shared';
import { ObjectMap } from '@0xproject/types';
import * as _ from 'lodash';
import Drawer from 'material-ui/Drawer';
@@ -35,7 +35,6 @@ export interface TopBarProps {
docsVersion?: string;
availableDocVersions?: string[];
sectionNameToLinks?: ObjectMap<ALink[]>;
- subsectionNameToLinks?: ObjectMap<ALink[]>;
displayType?: TopBarDisplayType;
docsInfo?: DocsInfo;
style?: React.CSSProperties;
@@ -73,20 +72,6 @@ const styles: Styles = {
},
};
-const DOC_WEBSITE_PATHS_TO_KEY = {
- [WebsitePaths.SolCov]: Key.SolCov,
- [WebsitePaths.SmartContracts]: Key.SmartContracts,
- [WebsitePaths.Web3Wrapper]: Key.Web3Wrapper,
- [WebsitePaths.SolCompiler]: Key.SolCompiler,
- [WebsitePaths.JSONSchemas]: Key.JsonSchemas,
- [WebsitePaths.Subproviders]: Key.Subproviders,
- [WebsitePaths.ContractWrappers]: Key.ContractWrappers,
- [WebsitePaths.Connect]: Key.Connect,
- [WebsitePaths.ZeroExJs]: Key.ZeroExJs,
- [WebsitePaths.OrderUtils]: Key.OrderUtils,
- [WebsitePaths.OrderWatcher]: Key.OrderWatcher,
-};
-
const DEFAULT_HEIGHT = 68;
const EXPANDED_HEIGHT = 75;
@@ -154,17 +139,11 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
<div className="flex items-center justify-between">
<DevelopersDropDown
location={this.props.location}
- menuItemStyles={styles.menuItem}
+ menuItemStyles={{ ...styles.menuItem, paddingBottom: 12, paddingTop: 12 }}
translate={this.props.translate}
menuIconStyle={menuIconStyle}
/>
<TopBarMenuItem
- title={this.props.translate.get(Key.Wiki, Deco.Cap)}
- path={WebsitePaths.Wiki}
- style={styles.menuItem}
- isNightVersion={isNightVersion}
- />
- <TopBarMenuItem
title={this.props.translate.get(Key.Blog, Deco.Cap)}
path={constants.URL_BLOG}
style={styles.menuItem}
@@ -246,30 +225,15 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
onRequestChange={this._onMenuButtonClick.bind(this)}
>
<div className="clearfix">
- {this._renderDocsMenu()}
- {this._renderWiki()}
<div className="pl1 py1 mt3" style={{ backgroundColor: colors.lightGrey }}>
{this.props.translate.get(Key.Website, Deco.Cap)}
</div>
<Link to={WebsitePaths.Home}>
<MenuItem className="py2">{this.props.translate.get(Key.Home, Deco.Cap)}</MenuItem>
</Link>
- <Link to={WebsitePaths.Wiki}>
- <MenuItem className="py2">{this.props.translate.get(Key.Wiki, Deco.Cap)}</MenuItem>
+ <Link to={WebsitePaths.Docs}>
+ <MenuItem className="py2">{this.props.translate.get(Key.Docs, Deco.Cap)}</MenuItem>
</Link>
- {_.map(DOC_WEBSITE_PATHS_TO_KEY, (key, websitePath) => {
- if (!this._doesUrlInclude(websitePath)) {
- return (
- <Link key={`drawer-menu-item-${websitePath}`} to={websitePath}>
- <MenuItem className="py2">
- {this.props.translate.get(key, Deco.Cap)}{' '}
- {this.props.translate.get(Key.Docs, Deco.Cap)}
- </MenuItem>
- </Link>
- );
- }
- return null;
- })}
{!this._isViewingPortal() && (
<Link to={WebsitePaths.Portal}>
<MenuItem className="py2">
@@ -298,49 +262,6 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
</Drawer>
);
}
- private _renderDocsMenu(): React.ReactNode {
- const isViewingDocsPage = _.some(DOC_WEBSITE_PATHS_TO_KEY, (_key, websitePath) => {
- return this._doesUrlInclude(websitePath);
- });
- // HACK: We need to make sure the SCROLL_CONTAINER is loaded before rendering the Sidebar
- // because the sidebar renders `react-scroll` links which depend on the scroll container already
- // being rendered.
- const documentationContainer = document.getElementById(sharedConstants.SCROLL_CONTAINER_ID);
- if (!isViewingDocsPage || _.isUndefined(this.props.sectionNameToLinks) || _.isNull(documentationContainer)) {
- return undefined;
- }
- return (
- <div className="lg-hide md-hide">
- <NestedSidebarMenu
- sectionNameToLinks={this.props.sectionNameToLinks}
- subsectionNameToLinks={this.props.subsectionNameToLinks}
- sidebarHeader={this.props.sidebarHeader}
- shouldDisplaySectionHeaders={false}
- onMenuItemClick={this._onMenuButtonClick.bind(this)}
- selectedVersion={this.props.docsVersion}
- versions={this.props.availableDocVersions}
- onVersionSelected={this.props.onVersionSelected}
- />
- </div>
- );
- }
- private _renderWiki(): React.ReactNode {
- if (!this._isViewingWiki()) {
- return undefined;
- }
-
- return (
- <div className="lg-hide md-hide">
- <NestedSidebarMenu
- sectionNameToLinks={this.props.sectionNameToLinks}
- subsectionNameToLinks={this.props.subsectionNameToLinks}
- sidebarHeader={this.props.sidebarHeader}
- shouldDisplaySectionHeaders={false}
- onMenuItemClick={this._onMenuButtonClick.bind(this)}
- />
- </div>
- );
- }
private _onMenuButtonClick(): void {
this.setState({
isDrawerOpen: !this.state.isDrawerOpen,
@@ -349,28 +270,10 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
private _isViewingPortal(): boolean {
return _.includes(this.props.location.pathname, WebsitePaths.Portal);
}
- private _isViewingDocs(): boolean {
- return _.includes(this.props.location.pathname, WebsitePaths.Docs);
- }
private _isViewingFAQ(): boolean {
return _.includes(this.props.location.pathname, WebsitePaths.FAQ);
}
- private _doesUrlInclude(aPath: string): boolean {
- return _.includes(this.props.location.pathname, aPath);
- }
- private _isViewingWiki(): boolean {
- return _.includes(this.props.location.pathname, WebsitePaths.Wiki);
- }
private _shouldDisplayBottomBar(): boolean {
- const isViewingDocsPage = _.some(DOC_WEBSITE_PATHS_TO_KEY, (_key, websitePath) => {
- return this._doesUrlInclude(websitePath);
- });
- return (
- isViewingDocsPage ||
- this._isViewingWiki() ||
- this._isViewingFAQ() ||
- this._isViewingDocs() ||
- this._isViewingPortal()
- );
+ return this._isViewingFAQ() || this._isViewingPortal();
}
} // tslint:disable:max-file-line-count
diff --git a/packages/website/ts/components/ui/button.tsx b/packages/website/ts/components/ui/button.tsx
index 75ba7bcff..2a6a1f477 100644
--- a/packages/website/ts/components/ui/button.tsx
+++ b/packages/website/ts/components/ui/button.tsx
@@ -10,11 +10,13 @@ export interface ButtonProps {
fontFamily?: string;
backgroundColor?: string;
borderColor?: string;
+ borderRadius?: string;
width?: string;
padding?: string;
type?: string;
isDisabled?: boolean;
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
+ textAlign?: string;
}
const PlainButton: React.StatelessComponent<ButtonProps> = ({ children, isDisabled, onClick, type, className }) => (
@@ -29,11 +31,12 @@ export const Button = styled(PlainButton)`
color: ${props => props.fontColor};
transition: background-color, opacity 0.5s ease;
padding: ${props => props.padding};
- border-radius: 6px;
+ border-radius: ${props => props.borderRadius};
font-weight: 500;
outline: none;
font-family: ${props => props.fontFamily};
width: ${props => props.width};
+ text-align: ${props => props.textAlign};
background-color: ${props => props.backgroundColor};
border: ${props => (props.borderColor ? `1px solid ${props.borderColor}` : 'none')};
&:hover {
@@ -52,11 +55,13 @@ export const Button = styled(PlainButton)`
Button.defaultProps = {
fontSize: '12px',
+ borderRadius: '6px',
backgroundColor: colors.white,
width: 'auto',
fontFamily: 'Roboto',
isDisabled: false,
padding: '0.8em 2.2em',
+ textAlign: 'center',
};
Button.displayName = 'Button';
diff --git a/packages/website/ts/components/ui/drop_down.tsx b/packages/website/ts/components/ui/drop_down.tsx
index 1daaeb1c3..4138b3fe5 100644
--- a/packages/website/ts/components/ui/drop_down.tsx
+++ b/packages/website/ts/components/ui/drop_down.tsx
@@ -1,3 +1,4 @@
+import * as _ from 'lodash';
import Popover from 'material-ui/Popover';
import * as React from 'react';
import { MaterialUIPosition } from 'ts/types';
@@ -75,7 +76,11 @@ export class DropDown extends React.Component<DropDownProps, DropDownState> {
anchorEl={this.state.anchorEl}
anchorOrigin={this.props.anchorOrigin}
targetOrigin={this.props.targetOrigin}
- onRequestClose={this._closePopover.bind(this)}
+ onRequestClose={
+ this.props.closeEvent === DropdownMouseEvent.Click
+ ? this._closePopover.bind(this)
+ : _.noop.bind(_)
+ }
useLayerForClickAway={this.props.closeEvent === DropdownMouseEvent.Click}
animated={false}
zDepth={this.props.zDepth}
@@ -95,7 +100,7 @@ export class DropDown extends React.Component<DropDownProps, DropDownState> {
private _onActiveNodeClick(event: React.FormEvent<HTMLInputElement>): void {
if (this.props.activateEvent === DropdownMouseEvent.Click) {
this.setState({
- isDropDownOpen: true,
+ isDropDownOpen: !this.state.isDropDownOpen,
anchorEl: event.currentTarget,
});
}
diff --git a/packages/website/ts/containers/asset_buyer_documentation.ts b/packages/website/ts/containers/asset_buyer_documentation.ts
new file mode 100644
index 000000000..13a597ea3
--- /dev/null
+++ b/packages/website/ts/containers/asset_buyer_documentation.ts
@@ -0,0 +1,71 @@
+import { DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0xproject/react-docs';
+import * as React from 'react';
+import { connect } from 'react-redux';
+import { Dispatch } from 'redux';
+import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
+import { Dispatcher } from 'ts/redux/dispatcher';
+import { State } from 'ts/redux/reducer';
+import { DocPackages, ScreenWidths } from 'ts/types';
+import { Translate } from 'ts/utils/translate';
+
+/* tslint:disable:no-var-requires */
+const IntroMarkdown = require('md/docs/asset_buyer/introduction');
+const InstallationMarkdown = require('md/docs/asset_buyer/installation');
+const UsageMarkdown = require('md/docs/asset_buyer/usage');
+/* tslint:enable:no-var-requires */
+
+const markdownSections = {
+ introduction: 'introduction',
+ installation: 'installation',
+ usage: 'usage',
+};
+
+const docsInfoConfig: DocsInfoConfig = {
+ id: DocPackages.AssetBuyer,
+ packageName: '@0xproject/asset-buyer',
+ type: SupportedDocJson.TypeDoc,
+ displayName: 'AssetBuyer',
+ packageUrl: 'https://github.com/0xProject/0x-monorepo',
+ markdownMenu: {
+ introduction: [markdownSections.introduction],
+ install: [markdownSections.installation],
+ usage: [markdownSections.usage],
+ },
+ sectionNameToMarkdownByVersion: {
+ '0.0.1': {
+ [markdownSections.introduction]: IntroMarkdown,
+ [markdownSections.installation]: InstallationMarkdown,
+ [markdownSections.usage]: UsageMarkdown,
+ },
+ },
+ markdownSections,
+};
+const docsInfo = new DocsInfo(docsInfoConfig);
+
+interface ConnectedState {
+ docsVersion: string;
+ availableDocVersions: string[];
+ docsInfo: DocsInfo;
+ translate: Translate;
+ screenWidth: ScreenWidths;
+}
+
+interface ConnectedDispatch {
+ dispatcher: Dispatcher;
+}
+
+const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({
+ docsVersion: state.docsVersion,
+ availableDocVersions: state.availableDocVersions,
+ translate: state.translate,
+ docsInfo,
+ screenWidth: state.screenWidth,
+});
+
+const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
+ dispatcher: new Dispatcher(dispatch),
+});
+
+export const Documentation: React.ComponentClass<DocPageProps> = connect(mapStateToProps, mapDispatchToProps)(
+ DocPageComponent,
+);
diff --git a/packages/website/ts/containers/connect_documentation.ts b/packages/website/ts/containers/connect_documentation.ts
index a728abe2c..7c86357c5 100644
--- a/packages/website/ts/containers/connect_documentation.ts
+++ b/packages/website/ts/containers/connect_documentation.ts
@@ -5,7 +5,7 @@ import { Dispatch } from 'redux';
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer';
-import { DocPackages } from 'ts/types';
+import { DocPackages, ScreenWidths } from 'ts/types';
import { Translate } from 'ts/utils/translate';
/* tslint:disable:no-var-requires */
@@ -26,8 +26,7 @@ const docsInfoConfig: DocsInfoConfig = {
displayName: '0x Connect',
packageUrl: 'https://github.com/0xProject/0x-monorepo',
markdownMenu: {
- introduction: [markdownSections.introduction],
- install: [markdownSections.installation],
+ 'getting-started': [markdownSections.introduction, markdownSections.installation],
},
sectionNameToMarkdownByVersion: {
'0.0.1': {
@@ -48,6 +47,7 @@ interface ConnectedState {
availableDocVersions: string[];
docsInfo: DocsInfo;
translate: Translate;
+ screenWidth: ScreenWidths;
}
interface ConnectedDispatch {
@@ -59,6 +59,7 @@ const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState
availableDocVersions: state.availableDocVersions,
translate: state.translate,
docsInfo,
+ screenWidth: state.screenWidth,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
diff --git a/packages/website/ts/containers/contract_wrappers_documentation.ts b/packages/website/ts/containers/contract_wrappers_documentation.ts
index 1e1735846..f7e5f17eb 100644
--- a/packages/website/ts/containers/contract_wrappers_documentation.ts
+++ b/packages/website/ts/containers/contract_wrappers_documentation.ts
@@ -5,7 +5,7 @@ import { Dispatch } from 'redux';
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer';
-import { DocPackages } from 'ts/types';
+import { DocPackages, ScreenWidths } from 'ts/types';
import { Translate } from 'ts/utils/translate';
/* tslint:disable:no-var-requires */
@@ -25,8 +25,7 @@ const docsInfoConfig: DocsInfoConfig = {
displayName: 'Contract Wrappers',
packageUrl: 'https://github.com/0xProject/0x-monorepo',
markdownMenu: {
- introduction: [markdownSections.introduction],
- install: [markdownSections.installation],
+ 'getting-started': [markdownSections.introduction, markdownSections.installation],
},
sectionNameToMarkdownByVersion: {
'0.0.1': {
@@ -43,6 +42,7 @@ interface ConnectedState {
availableDocVersions: string[];
docsInfo: DocsInfo;
translate: Translate;
+ screenWidth: ScreenWidths;
}
interface ConnectedDispatch {
@@ -54,6 +54,7 @@ const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState
availableDocVersions: state.availableDocVersions,
docsInfo,
translate: state.translate,
+ screenWidth: state.screenWidth,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
diff --git a/packages/website/ts/containers/docs_home.ts b/packages/website/ts/containers/docs_home.ts
index 9c7b70a6f..e0ca439a6 100644
--- a/packages/website/ts/containers/docs_home.ts
+++ b/packages/website/ts/containers/docs_home.ts
@@ -1,7 +1,8 @@
+import * as _ from 'lodash';
import * as React from 'react';
import { connect } from 'react-redux';
import { Dispatch } from 'redux';
-import { Home as HomeComponent, HomeProps } from 'ts/pages/documentation/home';
+import { DocsHome as DocsHomeComponent, DocsHomeProps } from 'ts/pages/documentation/docs_home';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer';
import { ScreenWidths } from 'ts/types';
@@ -16,7 +17,7 @@ interface ConnectedDispatch {
dispatcher: Dispatcher;
}
-const mapStateToProps = (state: State, _ownProps: HomeProps): ConnectedState => ({
+const mapStateToProps = (state: State, _ownProps: DocsHomeProps): ConnectedState => ({
translate: state.translate,
screenWidth: state.screenWidth,
});
@@ -25,4 +26,6 @@ const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
dispatcher: new Dispatcher(dispatch),
});
-export const DocsHome: React.ComponentClass<HomeProps> = connect(mapStateToProps, mapDispatchToProps)(HomeComponent);
+export const DocsHome: React.ComponentClass<DocsHomeProps> = connect(mapStateToProps, mapDispatchToProps)(
+ DocsHomeComponent,
+);
diff --git a/packages/website/ts/containers/ethereum_types_documentation.ts b/packages/website/ts/containers/ethereum_types_documentation.ts
index 2b6d6e64d..3cab885b4 100644
--- a/packages/website/ts/containers/ethereum_types_documentation.ts
+++ b/packages/website/ts/containers/ethereum_types_documentation.ts
@@ -5,7 +5,7 @@ import { Dispatch } from 'redux';
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer';
-import { DocPackages } from 'ts/types';
+import { DocPackages, ScreenWidths } from 'ts/types';
import { Translate } from 'ts/utils/translate';
/* tslint:disable:no-var-requires */
@@ -26,9 +26,7 @@ const docsInfoConfig: DocsInfoConfig = {
displayName: 'Ethereum Types',
packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/ethereum-types',
markdownMenu: {
- introduction: [markdownSections.introduction],
- install: [markdownSections.installation],
- types: [markdownSections.types],
+ 'getting-started': [markdownSections.introduction, markdownSections.installation],
},
sectionNameToMarkdownByVersion: {
'0.0.1': {
@@ -45,6 +43,7 @@ interface ConnectedState {
availableDocVersions: string[];
docsInfo: DocsInfo;
translate: Translate;
+ screenWidth: ScreenWidths;
}
interface ConnectedDispatch {
@@ -56,6 +55,7 @@ const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState
availableDocVersions: state.availableDocVersions,
translate: state.translate,
docsInfo,
+ screenWidth: state.screenWidth,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
diff --git a/packages/website/ts/containers/json_schemas_documentation.ts b/packages/website/ts/containers/json_schemas_documentation.ts
index f32a50ea9..4b3200203 100644
--- a/packages/website/ts/containers/json_schemas_documentation.ts
+++ b/packages/website/ts/containers/json_schemas_documentation.ts
@@ -5,7 +5,7 @@ import { Dispatch } from 'redux';
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer';
-import { DocPackages } from 'ts/types';
+import { DocPackages, ScreenWidths } from 'ts/types';
import { Translate } from 'ts/utils/translate';
/* tslint:disable:no-var-requires */
@@ -20,7 +20,6 @@ const markdownSections = {
introduction: 'introduction',
installation: 'installation',
usage: 'usage',
- schemaValidator: 'schemaValidator',
schemas: 'schemas',
};
@@ -31,10 +30,7 @@ const docsInfoConfig: DocsInfoConfig = {
displayName: 'JSON Schemas',
packageUrl: 'https://github.com/0xProject/0x-monorepo',
markdownMenu: {
- introduction: [markdownSections.introduction],
- install: [markdownSections.installation],
- usage: [markdownSections.usage],
- schemaValidator: [markdownSections.schemaValidator],
+ 'getting-started': [markdownSections.introduction, markdownSections.installation, markdownSections.usage],
schemas: [markdownSections.schemas],
},
sectionNameToMarkdownByVersion: {
@@ -60,6 +56,7 @@ interface ConnectedState {
availableDocVersions: string[];
docsInfo: DocsInfo;
translate: Translate;
+ screenWidth: ScreenWidths;
}
interface ConnectedDispatch {
@@ -71,6 +68,7 @@ const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState
availableDocVersions: state.availableDocVersions,
translate: state.translate,
docsInfo,
+ screenWidth: state.screenWidth,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
diff --git a/packages/website/ts/containers/order_utils_documentation.ts b/packages/website/ts/containers/order_utils_documentation.ts
index b54c30a1e..77204b480 100644
--- a/packages/website/ts/containers/order_utils_documentation.ts
+++ b/packages/website/ts/containers/order_utils_documentation.ts
@@ -5,7 +5,7 @@ import { Dispatch } from 'redux';
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer';
-import { DocPackages } from 'ts/types';
+import { DocPackages, ScreenWidths } from 'ts/types';
import { Translate } from 'ts/utils/translate';
/* tslint:disable:no-var-requires */
@@ -25,8 +25,7 @@ const docsInfoConfig: DocsInfoConfig = {
displayName: 'Order utils',
packageUrl: 'https://github.com/0xProject/0x-monorepo',
markdownMenu: {
- introduction: [markdownSections.introduction],
- install: [markdownSections.installation],
+ 'getting-started': [markdownSections.introduction, markdownSections.installation],
},
sectionNameToMarkdownByVersion: {
'0.0.1': {
@@ -43,6 +42,7 @@ interface ConnectedState {
availableDocVersions: string[];
docsInfo: DocsInfo;
translate: Translate;
+ screenWidth: ScreenWidths;
}
interface ConnectedDispatch {
@@ -54,6 +54,7 @@ const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState
availableDocVersions: state.availableDocVersions,
translate: state.translate,
docsInfo,
+ screenWidth: state.screenWidth,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
diff --git a/packages/website/ts/containers/order_watcher_documentation.ts b/packages/website/ts/containers/order_watcher_documentation.ts
index 59a018847..1b0c1ec91 100644
--- a/packages/website/ts/containers/order_watcher_documentation.ts
+++ b/packages/website/ts/containers/order_watcher_documentation.ts
@@ -5,7 +5,7 @@ import { Dispatch } from 'redux';
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer';
-import { DocPackages } from 'ts/types';
+import { DocPackages, ScreenWidths } from 'ts/types';
import { Translate } from 'ts/utils/translate';
/* tslint:disable:no-var-requires */
@@ -25,8 +25,7 @@ const docsInfoConfig: DocsInfoConfig = {
displayName: 'OrderWatcher',
packageUrl: 'https://github.com/0xProject/0x-monorepo',
markdownMenu: {
- introduction: [markdownSections.introduction],
- install: [markdownSections.installation],
+ 'getting-started': [markdownSections.introduction, markdownSections.installation],
},
sectionNameToMarkdownByVersion: {
'0.0.1': {
@@ -43,6 +42,7 @@ interface ConnectedState {
availableDocVersions: string[];
docsInfo: DocsInfo;
translate: Translate;
+ screenWidth: ScreenWidths;
}
interface ConnectedDispatch {
@@ -54,6 +54,7 @@ const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState
availableDocVersions: state.availableDocVersions,
translate: state.translate,
docsInfo,
+ screenWidth: state.screenWidth,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
diff --git a/packages/website/ts/containers/smart_contracts_documentation.ts b/packages/website/ts/containers/smart_contracts_documentation.ts
index 05b2a50c3..0989a7d0e 100644
--- a/packages/website/ts/containers/smart_contracts_documentation.ts
+++ b/packages/website/ts/containers/smart_contracts_documentation.ts
@@ -6,7 +6,7 @@ import { Dispatch } from 'redux';
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer';
-import { DocPackages, SmartContractDocSections as Sections } from 'ts/types';
+import { DocPackages, ScreenWidths, SmartContractDocSections as Sections } from 'ts/types';
import { Translate } from 'ts/utils/translate';
/* tslint:disable:no-var-requires */
@@ -97,6 +97,7 @@ interface ConnectedState {
docsVersion: string;
availableDocVersions: string[];
translate: Translate;
+ screenWidth: ScreenWidths;
}
interface ConnectedDispatch {
@@ -108,6 +109,7 @@ const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState
docsVersion: state.docsVersion,
availableDocVersions: state.availableDocVersions,
translate: state.translate,
+ screenWidth: state.screenWidth,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
diff --git a/packages/website/ts/containers/sol_compiler_documentation.ts b/packages/website/ts/containers/sol_compiler_documentation.ts
index 20f26ed1d..b84974d69 100644
--- a/packages/website/ts/containers/sol_compiler_documentation.ts
+++ b/packages/website/ts/containers/sol_compiler_documentation.ts
@@ -5,7 +5,7 @@ import { Dispatch } from 'redux';
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer';
-import { DocPackages } from 'ts/types';
+import { DocPackages, ScreenWidths } from 'ts/types';
import { Translate } from 'ts/utils/translate';
/* tslint:disable:no-var-requires */
@@ -27,9 +27,7 @@ const docsInfoConfig: DocsInfoConfig = {
displayName: 'Solidity Compiler',
packageUrl: 'https://github.com/0xProject/0x-monorepo',
markdownMenu: {
- introduction: [markdownSections.introduction],
- install: [markdownSections.installation],
- usage: [markdownSections.usage],
+ 'getting-started': [markdownSections.introduction, markdownSections.installation, markdownSections.usage],
},
sectionNameToMarkdownByVersion: {
'0.0.1': {
@@ -47,6 +45,7 @@ interface ConnectedState {
availableDocVersions: string[];
docsInfo: DocsInfo;
translate: Translate;
+ screenWidth: ScreenWidths;
}
interface ConnectedDispatch {
@@ -58,6 +57,7 @@ const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState
availableDocVersions: state.availableDocVersions,
translate: state.translate,
docsInfo,
+ screenWidth: state.screenWidth,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
diff --git a/packages/website/ts/containers/sol_cov_documentation.ts b/packages/website/ts/containers/sol_cov_documentation.ts
index 27efd641e..f9c428f8e 100644
--- a/packages/website/ts/containers/sol_cov_documentation.ts
+++ b/packages/website/ts/containers/sol_cov_documentation.ts
@@ -5,7 +5,7 @@ import { Dispatch } from 'redux';
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer';
-import { DocPackages } from 'ts/types';
+import { DocPackages, ScreenWidths } from 'ts/types';
import { Translate } from 'ts/utils/translate';
/* tslint:disable:no-var-requires */
@@ -27,9 +27,7 @@ const docsInfoConfig: DocsInfoConfig = {
displayName: 'Sol-cov',
packageUrl: 'https://github.com/0xProject/0x-monorepo',
markdownMenu: {
- introduction: [markdownSections.introduction],
- install: [markdownSections.installation],
- usage: [markdownSections.usage],
+ 'getting-started': [markdownSections.introduction, markdownSections.installation, markdownSections.usage],
},
sectionNameToMarkdownByVersion: {
'0.0.1': {
@@ -47,6 +45,7 @@ interface ConnectedState {
availableDocVersions: string[];
docsInfo: DocsInfo;
translate: Translate;
+ screenWidth: ScreenWidths;
}
interface ConnectedDispatch {
@@ -58,6 +57,7 @@ const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState
availableDocVersions: state.availableDocVersions,
translate: state.translate,
docsInfo,
+ screenWidth: state.screenWidth,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
diff --git a/packages/website/ts/containers/subproviders_documentation.ts b/packages/website/ts/containers/subproviders_documentation.ts
index 28b2e9508..1588c7d46 100644
--- a/packages/website/ts/containers/subproviders_documentation.ts
+++ b/packages/website/ts/containers/subproviders_documentation.ts
@@ -5,7 +5,7 @@ import { Dispatch } from 'redux';
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer';
-import { DocPackages } from 'ts/types';
+import { DocPackages, ScreenWidths } from 'ts/types';
import { Translate } from 'ts/utils/translate';
/* tslint:disable:no-var-requires */
@@ -27,9 +27,7 @@ const docsInfoConfig: DocsInfoConfig = {
displayName: 'Subproviders',
packageUrl: 'https://github.com/0xProject/0x-monorepo',
markdownMenu: {
- introduction: [docSections.introduction],
- install: [docSections.installation],
- ['ledger-node-hid-issue']: [docSections.ledgerNodeHid],
+ 'getting-started': [docSections.introduction, docSections.installation, docSections.ledgerNodeHid],
},
sectionNameToMarkdownByVersion: {
'0.0.1': {
@@ -47,6 +45,7 @@ interface ConnectedState {
availableDocVersions: string[];
docsInfo: DocsInfo;
translate: Translate;
+ screenWidth: ScreenWidths;
}
interface ConnectedDispatch {
@@ -58,6 +57,7 @@ const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState
availableDocVersions: state.availableDocVersions,
translate: state.translate,
docsInfo,
+ screenWidth: state.screenWidth,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
diff --git a/packages/website/ts/containers/web3_wrapper_documentation.ts b/packages/website/ts/containers/web3_wrapper_documentation.ts
index dc9d23304..0154c05b9 100644
--- a/packages/website/ts/containers/web3_wrapper_documentation.ts
+++ b/packages/website/ts/containers/web3_wrapper_documentation.ts
@@ -5,7 +5,7 @@ import { Dispatch } from 'redux';
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer';
-import { DocPackages } from 'ts/types';
+import { DocPackages, ScreenWidths } from 'ts/types';
import { Translate } from 'ts/utils/translate';
/* tslint:disable:no-var-requires */
@@ -13,7 +13,7 @@ const IntroMarkdownV1 = require('md/docs/web3_wrapper/introduction');
const InstallationMarkdownV1 = require('md/docs/web3_wrapper/installation');
/* tslint:enable:no-var-requires */
-const docSections = {
+const markdownSections = {
introduction: 'introduction',
installation: 'installation',
};
@@ -25,16 +25,15 @@ const docsInfoConfig: DocsInfoConfig = {
displayName: 'Web3Wrapper',
packageUrl: 'https://github.com/0xProject/0x-monorepo',
markdownMenu: {
- introduction: [docSections.introduction],
- install: [docSections.installation],
+ 'getting-started': [markdownSections.introduction, markdownSections.installation],
},
sectionNameToMarkdownByVersion: {
'0.0.1': {
- [docSections.introduction]: IntroMarkdownV1,
- [docSections.installation]: InstallationMarkdownV1,
+ [markdownSections.introduction]: IntroMarkdownV1,
+ [markdownSections.installation]: InstallationMarkdownV1,
},
},
- markdownSections: docSections,
+ markdownSections,
};
const docsInfo = new DocsInfo(docsInfoConfig);
@@ -43,6 +42,7 @@ interface ConnectedState {
availableDocVersions: string[];
docsInfo: DocsInfo;
translate: Translate;
+ screenWidth: ScreenWidths;
}
interface ConnectedDispatch {
@@ -54,6 +54,7 @@ const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState
availableDocVersions: state.availableDocVersions,
translate: state.translate,
docsInfo,
+ screenWidth: state.screenWidth,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
diff --git a/packages/website/ts/containers/wiki.ts b/packages/website/ts/containers/wiki.ts
index 357f8bbf4..069b0ae54 100644
--- a/packages/website/ts/containers/wiki.ts
+++ b/packages/website/ts/containers/wiki.ts
@@ -4,10 +4,12 @@ import { Dispatch } from 'redux';
import { Wiki as WikiComponent, WikiProps } from 'ts/pages/wiki/wiki';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer';
+import { ScreenWidths } from 'ts/types';
import { Translate } from 'ts/utils/translate';
interface ConnectedState {
translate: Translate;
+ screenWidth: ScreenWidths;
}
interface ConnectedDispatch {
@@ -16,6 +18,7 @@ interface ConnectedDispatch {
const mapStateToProps = (state: State, _ownProps: WikiProps): ConnectedState => ({
translate: state.translate,
+ screenWidth: state.screenWidth,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
diff --git a/packages/website/ts/containers/zero_ex_js_documentation.ts b/packages/website/ts/containers/zero_ex_js_documentation.ts
index 2a3afd86c..459d8390a 100644
--- a/packages/website/ts/containers/zero_ex_js_documentation.ts
+++ b/packages/website/ts/containers/zero_ex_js_documentation.ts
@@ -5,7 +5,7 @@ import { Dispatch } from 'redux';
import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page';
import { Dispatcher } from 'ts/redux/dispatcher';
import { State } from 'ts/redux/reducer';
-import { DocPackages } from 'ts/types';
+import { DocPackages, ScreenWidths } from 'ts/types';
import { Translate } from 'ts/utils/translate';
/* tslint:disable:no-var-requires */
@@ -39,9 +39,13 @@ const docsInfoConfig: DocsInfoConfig = {
displayName: '0x.js',
packageUrl: 'https://github.com/0xProject/0x-monorepo',
markdownMenu: {
- introduction: [markdownSections.introduction],
- install: [markdownSections.installation],
- topics: [markdownSections.async, markdownSections.errors, markdownSections.versioning],
+ 'getting-started': [
+ markdownSections.introduction,
+ markdownSections.installation,
+ markdownSections.async,
+ markdownSections.errors,
+ markdownSections.versioning,
+ ],
},
sectionNameToMarkdownByVersion: {
'0.0.1': {
@@ -68,6 +72,7 @@ interface ConnectedState {
availableDocVersions: string[];
docsInfo: DocsInfo;
translate: Translate;
+ screenWidth: ScreenWidths;
}
interface ConnectedDispatch {
@@ -79,6 +84,7 @@ const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState
availableDocVersions: state.availableDocVersions,
docsInfo,
translate: state.translate,
+ screenWidth: state.screenWidth,
});
const mapDispatchToProps = (dispatch: Dispatch<State>): ConnectedDispatch => ({
diff --git a/packages/website/ts/index.tsx b/packages/website/ts/index.tsx
index 4f0a12f20..21157e427 100644
--- a/packages/website/ts/index.tsx
+++ b/packages/website/ts/index.tsx
@@ -69,6 +69,9 @@ const LazyOrderUtilsDocumentation = createLazyComponent('Documentation', async (
const LazyEthereumTypesDocumentation = createLazyComponent('Documentation', async () =>
import(/* webpackChunkName: "ethereumTypesDocs" */ 'ts/containers/ethereum_types_documentation'),
);
+const LazyAssetBuyerDocumentation = createLazyComponent('Documentation', async () =>
+ import(/* webpackChunkName: "assetBuyerDocs" */ 'ts/containers/asset_buyer_documentation'),
+);
const DOCUMENT_TITLE = '0x: The Protocol for Trading Tokens';
const DOCUMENT_DESCRIPTION = 'An Open Protocol For Decentralized Exchange On The Ethereum Blockchain';
@@ -134,8 +137,11 @@ render(
path={`${WebsitePaths.EthereumTypes}/:version?`}
component={LazyEthereumTypesDocumentation}
/>
+ <Route
+ path={`${WebsitePaths.AssetBuyer}/:version?`}
+ component={LazyAssetBuyerDocumentation}
+ />
<Route path={WebsitePaths.Docs} component={DocsHome as any} />
-
{/* Legacy endpoints */}
<Route
path={`${WebsiteLegacyPaths.ZeroExJs}/:version?`}
diff --git a/packages/website/ts/pages/about/about.tsx b/packages/website/ts/pages/about/about.tsx
index 5f42dfa97..4d346327b 100644
--- a/packages/website/ts/pages/about/about.tsx
+++ b/packages/website/ts/pages/about/about.tsx
@@ -243,9 +243,10 @@ const teamRow9: ProfileInfo[] = [
{
name: 'Steve Klebanoff',
title: 'Senior Engineer',
- description: ` Full-stack engineer. Previously Staff Software Engineer at Appfolio. Computer Science & Cognitive Psychology at Northeastern University.`,
+ description: ` Full-stack engineer. Previously Staff Software Engineer at AppFolio. Computer Science & Cognitive Psychology at Northeastern University.`,
image: 'images/team/steve.png',
linkedIn: 'https://www.linkedin.com/in/steveklebanoff/',
+ github: 'https://github.com/steveklebanoff',
},
];
diff --git a/packages/website/ts/pages/documentation/developers_page.tsx b/packages/website/ts/pages/documentation/developers_page.tsx
new file mode 100644
index 000000000..e35218a70
--- /dev/null
+++ b/packages/website/ts/pages/documentation/developers_page.tsx
@@ -0,0 +1,182 @@
+import { colors, constants as sharedConstants } from '@0xproject/react-shared';
+import * as _ from 'lodash';
+import * as React from 'react';
+import DocumentTitle = require('react-document-title');
+import { DocsLogo } from 'ts/components/documentation/docs_logo';
+import { DocsTopBar } from 'ts/components/documentation/docs_top_bar';
+import { Container } from 'ts/components/ui/container';
+import { Dispatcher } from 'ts/redux/dispatcher';
+import { ScreenWidths } from 'ts/types';
+import { Translate } from 'ts/utils/translate';
+import { utils } from 'ts/utils/utils';
+
+const THROTTLE_TIMEOUT = 100;
+const TOP_BAR_HEIGHT = 80;
+const SCROLLER_WIDTH = 4;
+
+export interface DevelopersPageProps {
+ location: Location;
+ translate: Translate;
+ screenWidth: ScreenWidths;
+ dispatcher: Dispatcher;
+ mainContent: React.ReactNode;
+ sidebar: React.ReactNode;
+}
+
+export interface DevelopersPageState {
+ isHoveringSidebar: boolean;
+ isHoveringMainContent: boolean;
+ isSidebarScrolling: boolean;
+}
+
+export class DevelopersPage extends React.Component<DevelopersPageProps, DevelopersPageState> {
+ private readonly _throttledScreenWidthUpdate: () => void;
+ private readonly _throttledSidebarScrolling: () => void;
+ private _sidebarScrollClearingInterval: number;
+ constructor(props: DevelopersPageProps) {
+ super(props);
+ this._throttledScreenWidthUpdate = _.throttle(this._updateScreenWidth.bind(this), THROTTLE_TIMEOUT);
+ this._throttledSidebarScrolling = _.throttle(this._onSidebarScroll.bind(this), THROTTLE_TIMEOUT);
+ this.state = {
+ isHoveringSidebar: false,
+ isHoveringMainContent: false,
+ isSidebarScrolling: false,
+ };
+ }
+ public componentDidMount(): void {
+ window.addEventListener('resize', this._throttledScreenWidthUpdate);
+ window.scrollTo(0, 0);
+ this._sidebarScrollClearingInterval = window.setInterval(() => {
+ this.setState({
+ isSidebarScrolling: false,
+ });
+ }, 1000);
+ }
+ public componentWillUnmount(): void {
+ window.removeEventListener('resize', this._throttledScreenWidthUpdate);
+ window.clearInterval(this._sidebarScrollClearingInterval);
+ }
+ public render(): React.ReactNode {
+ const scrollableContainerStyles: React.CSSProperties = {
+ position: 'absolute',
+ top: 80,
+ left: 0,
+ bottom: 0,
+ right: 0,
+ overflowX: 'hidden',
+ overflowY: 'scroll',
+ minHeight: `calc(100vh - ${TOP_BAR_HEIGHT}px)`,
+ WebkitOverflowScrolling: 'touch',
+ };
+ const isSmallScreen = this.props.screenWidth === ScreenWidths.Sm;
+ const mainContentPadding = isSmallScreen ? 20 : 50;
+ const sidebarPadding = 22;
+ return (
+ <Container
+ className="flex items-center overflow-hidden"
+ width="100%"
+ background={`linear-gradient(to right, ${colors.grey100} 0%, ${colors.grey100} 50%, ${
+ colors.white
+ } 50%, ${colors.white} 100%)`}
+ >
+ <DocumentTitle title="0x Docs DevelopersPage" />
+ <Container className="flex mx-auto" height="100vh">
+ <Container
+ className="sm-hide xs-hide relative"
+ width={234}
+ paddingLeft={22}
+ paddingRight={22}
+ paddingTop={0}
+ backgroundColor={colors.grey100}
+ >
+ <Container
+ borderBottom={this.state.isSidebarScrolling ? `1px solid ${colors.grey300}` : 'none'}
+ >
+ <Container paddingTop="30px" paddingLeft="10px" paddingBottom="8px">
+ <DocsLogo height={36} />
+ </Container>
+ </Container>
+ <div
+ style={{
+ ...scrollableContainerStyles,
+ paddingTop: 27,
+ overflow: this.state.isHoveringSidebar ? 'auto' : 'hidden',
+ }}
+ onMouseEnter={this._onSidebarHover.bind(this, true)}
+ onMouseLeave={this._onSidebarHover.bind(this, false)}
+ onWheel={this._throttledSidebarScrolling}
+ >
+ <div
+ style={{
+ paddingBottom: 100,
+ paddingLeft: sidebarPadding,
+ paddingRight: this.state.isHoveringSidebar
+ ? sidebarPadding - SCROLLER_WIDTH
+ : sidebarPadding,
+ }}
+ >
+ {this.props.screenWidth !== ScreenWidths.Sm && this.props.sidebar}
+ </div>
+ </div>
+ </Container>
+ <Container
+ className="relative"
+ width={isSmallScreen ? '100vw' : 786}
+ paddingBottom="100px"
+ backgroundColor={colors.white}
+ >
+ <Container paddingLeft={mainContentPadding} paddingRight={mainContentPadding}>
+ <DocsTopBar
+ location={this.props.location}
+ screenWidth={this.props.screenWidth}
+ translate={this.props.translate}
+ sidebar={this.props.sidebar}
+ />
+ </Container>
+ <div
+ id={sharedConstants.SCROLL_CONTAINER_ID}
+ className="absolute"
+ style={{
+ ...scrollableContainerStyles,
+ paddingTop: 0,
+ paddingLeft: mainContentPadding,
+ paddingRight: this.state.isHoveringMainContent
+ ? mainContentPadding - SCROLLER_WIDTH
+ : mainContentPadding,
+ overflow: this.state.isHoveringMainContent ? 'auto' : 'hidden',
+ }}
+ onMouseEnter={this._onMainContentHover.bind(this, true)}
+ onMouseOver={this._onMainContentHover.bind(this, true)}
+ onMouseLeave={this._onMainContentHover.bind(this, false)}
+ >
+ {this.props.mainContent}
+ </div>
+ </Container>
+ </Container>
+ </Container>
+ );
+ }
+ private _onSidebarHover(isHovering: boolean, _event: React.FormEvent<HTMLInputElement>): void {
+ if (isHovering !== this.state.isHoveringSidebar) {
+ this.setState({
+ isHoveringSidebar: isHovering,
+ });
+ }
+ }
+ private _onMainContentHover(isHovering: boolean, _event: React.FormEvent<HTMLInputElement>): void {
+ if (isHovering !== this.state.isHoveringMainContent) {
+ this.setState({
+ isHoveringMainContent: isHovering,
+ });
+ }
+ }
+ private _onSidebarScroll(_event: React.FormEvent<HTMLInputElement>): void {
+ this.setState({
+ isSidebarScrolling: true,
+ });
+ }
+ private _updateScreenWidth(): void {
+ const newScreenWidth = utils.getScreenWidth();
+ this.props.dispatcher.updateScreenWidth(newScreenWidth);
+ }
+} // tslint:disable:max-file-line-count
diff --git a/packages/website/ts/pages/documentation/doc_page.tsx b/packages/website/ts/pages/documentation/doc_page.tsx
index c64751f65..40c728c24 100644
--- a/packages/website/ts/pages/documentation/doc_page.tsx
+++ b/packages/website/ts/pages/documentation/doc_page.tsx
@@ -1,35 +1,30 @@
import {
DocAgnosticFormat,
+ DocReference,
DocsInfo,
- Documentation,
GeneratedDocJson,
SupportedDocJson,
TypeDocUtils,
} from '@0xproject/react-docs';
+import { NestedSidebarMenu } from '@0xproject/react-shared';
import findVersions = require('find-versions');
import * as _ from 'lodash';
+import CircularProgress from 'material-ui/CircularProgress';
import * as React from 'react';
-import DocumentTitle = require('react-document-title');
import semverSort = require('semver-sort');
-import { SidebarHeader } from 'ts/components/sidebar_header';
-import { TopBar } from 'ts/components/top_bar/top_bar';
+import { SidebarHeader } from 'ts/components/documentation/sidebar_header';
+import { Container } from 'ts/components/ui/container';
+import { DevelopersPage } from 'ts/pages/documentation/developers_page';
import { Dispatcher } from 'ts/redux/dispatcher';
-import { DocPackages } from 'ts/types';
+import { DocPackages, ScreenWidths } from 'ts/types';
import { constants } from 'ts/utils/constants';
import { docUtils } from 'ts/utils/doc_utils';
import { Translate } from 'ts/utils/translate';
import { utils } from 'ts/utils/utils';
const isDevelopmentOrStaging = utils.isDevelopment() || utils.isStaging();
-const DEFAULT_ICON = 'docs.png';
const ZERO_EX_JS_VERSION_MISSING_TOPLEVEL_PATH = '0.32.4';
-const idToIcon: { [id: string]: string } = {
- [DocPackages.ZeroExJs]: 'zeroExJs.png',
- [DocPackages.Connect]: 'connect.png',
- [DocPackages.SmartContracts]: 'contracts.png',
-};
-
const docIdToSubpackageName: { [id: string]: string } = {
[DocPackages.ZeroExJs]: '0x.js',
[DocPackages.Connect]: 'connect',
@@ -43,6 +38,7 @@ const docIdToSubpackageName: { [id: string]: string } = {
[DocPackages.OrderUtils]: 'order-utils',
[DocPackages.OrderWatcher]: 'order-watcher',
[DocPackages.EthereumTypes]: 'ethereum-types',
+ [DocPackages.AssetBuyer]: 'asset-buyer',
};
export interface DocPageProps {
@@ -52,6 +48,7 @@ export interface DocPageProps {
availableDocVersions: string[];
docsInfo: DocsInfo;
translate: Translate;
+ screenWidth: ScreenWidths;
}
interface DocPageState {
@@ -79,38 +76,58 @@ export class DocPage extends React.Component<DocPageProps, DocPageState> {
this._isUnmounted = true;
}
public render(): React.ReactNode {
- const subsectionNameToLinks = _.isUndefined(this.state.docAgnosticFormat)
- ? {}
- : this.props.docsInfo.getSubsectionNameToLinks(this.state.docAgnosticFormat);
const sourceUrl = this._getSourceUrl();
- const iconFileName = idToIcon[this.props.docsInfo.id] || DEFAULT_ICON;
- const iconUrl = `/images/doc_icons/${iconFileName}`;
+ const sectionNameToLinks = _.isUndefined(this.state.docAgnosticFormat)
+ ? {}
+ : this.props.docsInfo.getSectionNameToLinks(this.state.docAgnosticFormat);
+ const mainContent = _.isUndefined(this.state.docAgnosticFormat) ? (
+ <div className="flex justify-center">{this._renderLoading()}</div>
+ ) : (
+ <DocReference
+ selectedVersion={this.props.docsVersion}
+ availableVersions={this.props.availableDocVersions}
+ docsInfo={this.props.docsInfo}
+ docAgnosticFormat={this.state.docAgnosticFormat}
+ sourceUrl={sourceUrl}
+ />
+ );
+ const sidebar = _.isUndefined(this.state.docAgnosticFormat) ? (
+ <div />
+ ) : (
+ <NestedSidebarMenu sidebarHeader={this._renderSidebarHeader()} sectionNameToLinks={sectionNameToLinks} />
+ );
+ return (
+ <DevelopersPage
+ sidebar={sidebar}
+ mainContent={mainContent}
+ location={this.props.location}
+ screenWidth={this.props.screenWidth}
+ translate={this.props.translate}
+ dispatcher={this.props.dispatcher}
+ />
+ );
+ }
+ private _renderSidebarHeader(): React.ReactNode {
+ return (
+ <SidebarHeader
+ screenWidth={this.props.screenWidth}
+ title={this.props.docsInfo.displayName}
+ docsVersion={this.props.docsVersion}
+ availableDocVersions={this.props.availableDocVersions}
+ onVersionSelected={this._onVersionSelected.bind(this)}
+ />
+ );
+ }
+ private _renderLoading(): React.ReactNode {
return (
- <div>
- <DocumentTitle title={`${this.props.docsInfo.displayName} Documentation`} />
- <TopBar
- blockchainIsLoaded={false}
- location={this.props.location}
- docsVersion={this.props.docsVersion}
- availableDocVersions={this.props.availableDocVersions}
- sectionNameToLinks={this.props.docsInfo.getSectionNameToLinks()}
- subsectionNameToLinks={subsectionNameToLinks}
- docsInfo={this.props.docsInfo}
- translate={this.props.translate}
- onVersionSelected={this._onVersionSelected.bind(this)}
- sidebarHeader={<SidebarHeader title={this.props.docsInfo.displayName} iconUrl={iconUrl} />}
- />
- <Documentation
- selectedVersion={this.props.docsVersion}
- availableVersions={this.props.availableDocVersions}
- docsInfo={this.props.docsInfo}
- docAgnosticFormat={this.state.docAgnosticFormat}
- sidebarHeader={<SidebarHeader title={this.props.docsInfo.displayName} iconUrl={iconUrl} />}
- sourceUrl={sourceUrl}
- topBarHeight={60}
- onVersionSelected={this._onVersionSelected.bind(this)}
- />
- </div>
+ <Container className="pt4">
+ <Container className="center pb2">
+ <CircularProgress size={40} thickness={5} />
+ </Container>
+ <Container className="center pt2" paddingBottom="11px">
+ Loading documentation...
+ </Container>
+ </Container>
);
}
private async _fetchJSONDocsFireAndForgetAsync(preferredVersionIfExists?: string): Promise<void> {
@@ -145,10 +162,10 @@ export class DocPage extends React.Component<DocPageProps, DocPageState> {
// documenting solidity.
docAgnosticFormat = versionDocObj as DocAgnosticFormat;
// HACK: need to modify docsInfo like convertToDocAgnosticFormat() would do
- this.props.docsInfo.menu.Contracts = [];
+ this.props.docsInfo.markdownMenu.Contracts = [];
_.each(docAgnosticFormat, (_docObj, sectionName) => {
this.props.docsInfo.sections[sectionName] = sectionName;
- this.props.docsInfo.menu.Contracts.push(sectionName);
+ this.props.docsInfo.markdownMenu.Contracts.push(sectionName);
});
}
diff --git a/packages/website/ts/pages/documentation/docs_home.tsx b/packages/website/ts/pages/documentation/docs_home.tsx
new file mode 100644
index 000000000..f0af78fc1
--- /dev/null
+++ b/packages/website/ts/pages/documentation/docs_home.tsx
@@ -0,0 +1,384 @@
+import { ALink, colors, Link, NestedSidebarMenu } from '@0xproject/react-shared';
+import { ObjectMap } from '@0xproject/types';
+import * as _ from 'lodash';
+import * as React from 'react';
+import { OverviewContent } from 'ts/components/documentation/overview_content';
+import { Button } from 'ts/components/ui/button';
+import { DevelopersPage } from 'ts/pages/documentation/developers_page';
+import { Dispatcher } from 'ts/redux/dispatcher';
+import { Categories, Deco, Key, Package, ScreenWidths, TutorialInfo, WebsitePaths } from 'ts/types';
+import { constants } from 'ts/utils/constants';
+import { Translate } from 'ts/utils/translate';
+
+const TUTORIALS: TutorialInfo[] = [
+ {
+ iconUrl: '/images/developers/tutorials/develop_on_ethereum.svg',
+ description: Key.DevelopOnEthereumDescription,
+ link: {
+ title: Key.DevelopOnEthereum,
+ to: `${WebsitePaths.Wiki}#Ethereum-Development`,
+ },
+ },
+ {
+ iconUrl: '/images/developers/tutorials/build_a_relayer.svg',
+ description: Key.BuildARelayerDescription,
+ link: {
+ title: Key.BuildARelayer,
+ to: `${WebsitePaths.Wiki}#Build-A-Relayer`,
+ },
+ },
+ {
+ iconUrl: '/images/developers/tutorials/0x_order_basics.svg',
+ description: Key.OrderBasicsDescription,
+ link: {
+ title: Key.OrderBasics,
+ to: `${WebsitePaths.Wiki}#Create,-Validate,-Fill-Order`,
+ },
+ },
+ {
+ iconUrl: '/images/developers/tutorials/use_shared_liquidity.svg',
+ description: Key.UseSharedLiquidityDescription,
+ link: {
+ title: Key.UseSharedLiquidity,
+ to: `${WebsitePaths.Wiki}#Find,-Submit,-Fill-Order-From-Relayer`,
+ },
+ },
+];
+
+const CATEGORY_TO_PACKAGES: ObjectMap<Package[]> = {
+ [Categories.ZeroExProtocol]: [
+ {
+ description:
+ 'A library for interacting with the 0x protocol. It is a high level package which combines a number of smaller specific-purpose packages such as [order-utils](https://0xproject.com/docs/order-utils) and [contract-wrappers](https://0xproject.com/docs/contract-wrappers).',
+ link: {
+ title: '0x.js',
+ to: WebsitePaths.ZeroExJs,
+ },
+ },
+ {
+ description:
+ 'A Typescript starter project that will walk you through the basics of how to interact with 0x Protocol and trade of an SRA relayer',
+ link: {
+ title: '0x starter project',
+ to: 'https://github.com/0xProject/0x-starter-project',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description:
+ 'An http & websocket client for interacting with relayers that have implemented the [Standard Relayer API](https://github.com/0xProject/standard-relayer-api)',
+ link: {
+ title: '@0xproject/connect',
+ to: WebsitePaths.Connect,
+ },
+ },
+ {
+ description:
+ 'Typescript/Javascript wrappers of the 0x protocol Ethereum smart contracts. Use this library to call methods on the 0x smart contracts, subscribe to contract events and to fetch information stored in contracts.',
+ link: {
+ title: '@0xproject/contract-wrappers',
+ to: WebsitePaths.ContractWrappers,
+ },
+ },
+ {
+ description:
+ 'A collection of 0x-related JSON-schemas (incl. SRA request/response schemas, 0x order message format schema, etc...)',
+ link: {
+ title: '@0xproject/json-schemas',
+ to: WebsitePaths.JSONSchemas,
+ },
+ },
+ {
+ description:
+ 'A set of utils for working with 0x orders. It includes utilities for creating, signing, validating 0x orders, encoding/decoding assetData and much more.',
+ link: {
+ title: '@0xproject/order-utils',
+ to: WebsitePaths.OrderUtils,
+ },
+ },
+ {
+ description:
+ "A daemon that watches a set of 0x orders and emits events when an order's fillability has changed. Can be used by a relayer to prune their orderbook or by a trader to keep their view of the market up-to-date.",
+ link: {
+ title: '@0xproject/order-watcher',
+ to: WebsitePaths.OrderWatcher,
+ },
+ },
+ {
+ description:
+ 'Contains the Standard Relayer API OpenAPI Spec. The package distributes both a javascript object version and a json version.',
+ link: {
+ title: '@0xproject/sra-spec',
+ to: 'https://github.com/0xProject/0x-monorepo/tree/development/packages/sra-spec',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description:
+ '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.',
+ link: {
+ title: '@0xproject/asset-buyer',
+ to: WebsitePaths.AssetBuyer,
+ },
+ },
+ ],
+ [Categories.Ethereum]: [
+ {
+ description:
+ "This package allows you to generate TypeScript contract wrappers from ABI files. It's heavily inspired by Geth abigen but takes a different approach. You can write your custom handlebars templates which will allow you to seamlessly integrate the generated code into your existing codebase with existing conventions.",
+ link: {
+ title: 'abi-gen',
+ to: 'https://github.com/0xProject/0x-monorepo/tree/development/packages/abi-gen',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description:
+ 'A collection of Typescript types that are useful when working on an Ethereum-based project (e.g RawLog, Transaction, TxData, SolidityTypes, etc...).',
+ link: {
+ title: 'ethereum-types',
+ to: WebsitePaths.EthereumTypes,
+ },
+ },
+ {
+ description:
+ 'A wrapper around [solc-js](https://github.com/ethereum/solc-js) that adds smart re-compilation, ability to compile an entire project, Solidity version specific compilation, standard input description support and much more.',
+ link: {
+ title: '@0xproject/sol-compiler',
+ to: WebsitePaths.SolCompiler,
+ },
+ },
+ {
+ description:
+ 'A Solidity code coverage tool. Sol-cov uses transaction traces to figure out which lines of your code has been covered by your tests.',
+ link: {
+ title: '@0xproject/sol-cov',
+ to: WebsitePaths.SolCov,
+ },
+ },
+ {
+ description:
+ 'A collection of subproviders to use with [web3-provider-engine](https://www.npmjs.com/package/web3-provider-engine) (e.g subproviders for interfacing with Ledger hardware wallet, Mnemonic wallet, private key wallet, etc...)',
+ link: {
+ title: '@0xproject/subproviders',
+ to: WebsitePaths.Subproviders,
+ },
+ },
+ {
+ description:
+ 'A raw Ethereum JSON RPC client to simplify interfacing with Ethereum nodes. Also includes some convenience functions for awaiting transactions to be mined, converting between token units, etc...',
+ link: {
+ title: '@0xproject/web3-wrapper',
+ to: WebsitePaths.Web3Wrapper,
+ },
+ },
+ ],
+ [Categories.CommunityMaintained]: [
+ {
+ description:
+ 'Node.js worker originally built for 0x Tracker which extracts 0x fill events from the Ethereum blockchain and persists them to MongoDB. Support for both V1 and V2 of the 0x protocol is included with events tagged against the protocol version they belong to.',
+ link: {
+ title: '0x Event Extractor',
+ to: 'https://github.com/0xTracker/0x-event-extractor',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description:
+ 'Node.js worker built for 0x Tracker which performs various ETL tasks related to the 0x protocol trading data and other information used on 0x Tracker.',
+ link: {
+ title: '0x Tracker Worker',
+ to: 'https://github.com/0xTracker/0x-tracker-worker',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description:
+ "ERCdex's Javascript SDK for trading on their relayer, as well as other Aquaduct partner relayers",
+ link: {
+ title: 'Aquaduct',
+ to: 'https://www.npmjs.com/package/aqueduct',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description:
+ 'SDKs for automation using Aqueduct & ERC dEX. Aqueduct Server is a lightweight, portable and secure server that runs locally on any workstation. The server exposes a small number of foundational endpoints that enable working with the decentralized Aqueduct liquidity pool from any context or programming language.',
+ link: {
+ title: 'Aquaduct Server SDK',
+ to: 'https://github.com/ERCdEX/aqueduct-server-sdk',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description: 'A node.js SDK for trading on the DDEX relayer',
+ link: {
+ to: 'https://www.npmjs.com/package/ddex-api',
+ title: 'DDEX Node.js SDK',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description: "The ERC dEX Trade Widget let's any website provide token liquidity to it's users",
+ link: {
+ to: 'https://github.com/ERCdEX/widget',
+ title: 'ERCdex Widget',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description: "ERCdex's Java SDK for trading on their relayer, as well as other Aquaduct partner relayers",
+ link: {
+ to: 'https://github.com/ERCdEX/java',
+ title: 'ERCdex Java SDK',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description: "ERCdex's Python SDK for trading on their relayer, as well as other Aquaduct partner relayers",
+ link: {
+ to: 'https://github.com/ERCdEX/python',
+ title: 'ERCdex Python SDK',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description:
+ 'A set of command-line tools for creating command-line scripts for interacting with the Ethereum blockchain in general, and 0x in particular',
+ link: {
+ title: 'Massive',
+ to: 'https://github.com/NoteGio/massive',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description: 'An open-source API-only Relayer written in Go',
+ link: {
+ to: 'https://github.com/NoteGio/openrelay',
+ title: 'OpenRelay',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description:
+ 'A JavaScript Library for Interacting with OpenRelay.xyz and other 0x Standard Relayer API Implementations',
+ link: {
+ title: 'OpenRelay.js',
+ to: 'https://github.com/NoteGio/openrelay.js',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description:
+ 'The Radar Relay SDK is a software development kit that simplifies the interactions with Radar Relay’s APIs',
+ link: {
+ title: 'Radar SDK',
+ to: 'https://github.com/RadarRelay/sdk',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description:
+ 'The Ocean provides a simple REST API, WebSockets API, and JavaScript library to help you integrate decentralized trading into your existing trading strategy.',
+ link: {
+ title: 'The Ocean Javascript SDK',
+ to: 'https://github.com/TheOceanTrade/theoceanx-javascript',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description: "Tokenlon SDK provides APIs for developers to trade of imToken's relayer",
+ link: {
+ to: 'https://www.npmjs.com/package/tokenlon-sdk',
+ title: 'Tokenlon Javascript SDK',
+ shouldOpenInNewTab: true,
+ },
+ },
+ {
+ description: 'A small library that implements the 0x order assetData encoding/decoding in Java',
+ link: {
+ to: 'https://github.com/wildnothing/asset-data-decoder',
+ title: 'AssetData decoder library in Java',
+ shouldOpenInNewTab: true,
+ },
+ },
+ ],
+};
+
+export interface DocsHomeProps {
+ location: Location;
+ translate: Translate;
+ screenWidth: ScreenWidths;
+ tutorials: TutorialInfo[];
+ categoryToPackages: ObjectMap<Package[]>;
+ dispatcher: Dispatcher;
+}
+
+export interface DocsHomeState {}
+
+export class DocsHome extends React.Component<DocsHomeProps, DocsHomeState> {
+ public render(): React.ReactNode {
+ const sectionNameToLinks: ObjectMap<ALink[]> = {
+ 'Starter guides': _.map(TUTORIALS, tutorialInfo => {
+ return {
+ ...tutorialInfo.link,
+ title: this.props.translate.get(tutorialInfo.link.title as Key, Deco.Cap),
+ };
+ }),
+ [Categories.ZeroExProtocol]: _.map(CATEGORY_TO_PACKAGES[Categories.ZeroExProtocol], pkg => pkg.link),
+ [Categories.Ethereum]: _.map(CATEGORY_TO_PACKAGES[Categories.Ethereum], pkg => pkg.link),
+ [Categories.CommunityMaintained]: _.map(
+ CATEGORY_TO_PACKAGES[Categories.CommunityMaintained],
+ pkg => pkg.link,
+ ),
+ };
+ const mainContent = (
+ <OverviewContent
+ translate={this.props.translate}
+ tutorials={TUTORIALS}
+ categoryToPackages={CATEGORY_TO_PACKAGES}
+ />
+ );
+ const isSmallScreen = this.props.screenWidth === ScreenWidths.Sm;
+ const sidebar = (
+ <NestedSidebarMenu
+ sidebarHeader={isSmallScreen ? this._renderSidebarHeader() : undefined}
+ sectionNameToLinks={sectionNameToLinks}
+ shouldReformatMenuItemNames={false}
+ />
+ );
+ return (
+ <DevelopersPage
+ mainContent={mainContent}
+ sidebar={sidebar}
+ location={this.props.location}
+ screenWidth={this.props.screenWidth}
+ translate={this.props.translate}
+ dispatcher={this.props.dispatcher}
+ />
+ );
+ }
+ private _renderSidebarHeader(): React.ReactNode {
+ const menuItems = _.map(constants.DEVELOPER_TOPBAR_LINKS, menuItemInfo => {
+ return (
+ <Link
+ key={`menu-item-${menuItemInfo.title}`}
+ to={menuItemInfo.to}
+ shouldOpenInNewTab={menuItemInfo.shouldOpenInNewTab}
+ >
+ <Button
+ borderRadius="4px"
+ padding="0.4em 6px"
+ width="100%"
+ fontColor={colors.grey800}
+ fontSize="14px"
+ textAlign="left"
+ >
+ {this.props.translate.get(menuItemInfo.title as Key, Deco.Cap)}
+ </Button>
+ </Link>
+ );
+ });
+ return menuItems;
+ }
+}
diff --git a/packages/website/ts/pages/documentation/home.tsx b/packages/website/ts/pages/documentation/home.tsx
deleted file mode 100644
index f7c4839b4..000000000
--- a/packages/website/ts/pages/documentation/home.tsx
+++ /dev/null
@@ -1,623 +0,0 @@
-import {
- ALink,
- colors,
- constants as sharedConstants,
- Link,
- MarkdownLinkBlock,
- NestedSidebarMenu,
- utils as sharedUtils,
-} from '@0xproject/react-shared';
-import { ObjectMap } from '@0xproject/types';
-import * as _ from 'lodash';
-import * as React from 'react';
-import DocumentTitle = require('react-document-title');
-import * as ReactMarkdown from 'react-markdown';
-import { Element as ScrollElement } from 'react-scroll';
-import { DocsLogo } from 'ts/components/documentation/docs_logo';
-import { DocsTopBar } from 'ts/components/documentation/docs_top_bar';
-import { TutorialButton } from 'ts/components/documentation/tutorial_button';
-import { Container } from 'ts/components/ui/container';
-import { Text } from 'ts/components/ui/text';
-import { Dispatcher } from 'ts/redux/dispatcher';
-import { Deco, Key, ScreenWidths, TutorialInfo, WebsitePaths } from 'ts/types';
-import { Translate } from 'ts/utils/translate';
-import { utils } from 'ts/utils/utils';
-
-const THROTTLE_TIMEOUT = 100;
-const TOP_BAR_HEIGHT = 80;
-const SCROLLER_WIDTH = 4;
-const TUTORIALS: TutorialInfo[] = [
- {
- iconUrl: '/images/developers/tutorials/develop_on_ethereum.svg',
- description: Key.DevelopOnEthereumDescription,
- link: {
- title: Key.DevelopOnEthereum,
- to: `${WebsitePaths.Wiki}#Ethereum-Development`,
- shouldOpenInNewTab: true,
- },
- },
- {
- iconUrl: '/images/developers/tutorials/build_a_relayer.svg',
- description: Key.BuildARelayerDescription,
- link: {
- title: Key.BuildARelayer,
- to: `${WebsitePaths.Wiki}#Build-A-Relayer`,
- shouldOpenInNewTab: true,
- },
- },
- {
- iconUrl: '/images/developers/tutorials/0x_order_basics.svg',
- description: Key.OrderBasicsDescription,
- link: {
- title: Key.OrderBasics,
- to: `${WebsitePaths.Wiki}#Create,-Validate,-Fill-Order`,
- shouldOpenInNewTab: true,
- },
- },
- {
- iconUrl: '/images/developers/tutorials/use_shared_liquidity.svg',
- description: Key.UseSharedLiquidityDescription,
- link: {
- title: Key.UseSharedLiquidity,
- to: `${WebsitePaths.Wiki}#Find,-Submit,-Fill-Order-From-Relayer`,
- shouldOpenInNewTab: true,
- },
- },
-];
-enum Categories {
- ZeroExProtocol = '0x Protocol',
- Ethereum = 'Ethereum',
- CommunityMaintained = 'Community Maintained',
-}
-// TODO(fabio): Move this to it's own file
-const CATEGORY_TO_PACKAGES: { [category: string]: Package[] } = {
- [Categories.ZeroExProtocol]: [
- {
- description:
- 'A library for interacting with the 0x protocol. It is a high level package which combines a number of smaller specific-purpose packages such as [order-utils](https://0xproject.com/docs/order-utils) and [contract-wrappers](https://0xproject.com/docs/contract-wrappers).',
- link: {
- title: '0x.js',
- to: WebsitePaths.ZeroExJs,
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'A Typescript starter project that will walk you through the basics of how to interact with 0x Protocol and trade of an SRA relayer',
- link: {
- title: '0x starter project',
- to: 'https://github.com/0xProject/0x-starter-project',
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'An http & websocket client for interacting with relayers that have implemented the [Standard Relayer API](https://github.com/0xProject/standard-relayer-api)',
- link: {
- title: '@0xproject/connect',
- to: WebsitePaths.Connect,
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'Typescript/Javascript wrappers of the 0x protocol Ethereum smart contracts. Use this library to call methods on the 0x smart contracts, subscribe to contract events and to fetch information stored in contracts.',
- link: {
- title: '@0xproject/contract-wrappers',
- to: WebsitePaths.ContractWrappers,
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'A collection of 0x-related JSON-schemas (incl. SRA request/response schemas, 0x order message format schema, etc...)',
- link: {
- title: '@0xproject/json-schemas',
- to: WebsitePaths.JSONSchemas,
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'A set of utils for working with 0x orders. It includes utilities for creating, signing, validating 0x orders, encoding/decoding assetData and much more.',
- link: {
- title: '@0xproject/order-utils',
- to: WebsitePaths.OrderUtils,
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- "A daemon that watches a set of 0x orders and emits events when an order's fillability has changed. Can be used by a relayer to prune their orderbook or by a trader to keep their view of the market up-to-date.",
- link: {
- title: '@0xproject/order-watcher',
- to: WebsitePaths.OrderWatcher,
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'Contains the Standard Relayer API OpenAPI Spec. The package distributes both a javascript object version and a json version.',
- link: {
- title: '@0xproject/sra-spec',
- to: 'https://github.com/0xProject/0x-monorepo/tree/development/packages/sra-spec',
- shouldOpenInNewTab: true,
- },
- },
- ],
- [Categories.Ethereum]: [
- {
- description:
- "This package allows you to generate TypeScript contract wrappers from ABI files. It's heavily inspired by Geth abigen but takes a different approach. You can write your custom handlebars templates which will allow you to seamlessly integrate the generated code into your existing codebase with existing conventions.",
- link: {
- title: 'abi-gen',
- to: 'https://github.com/0xProject/0x-monorepo/tree/development/packages/abi-gen',
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'A collection of Typescript types that are useful when working on an Ethereum-based project (e.g RawLog, Transaction, TxData, SolidityTypes, etc...).',
- link: {
- title: 'ethereum-types',
- to: WebsitePaths.EthereumTypes,
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'A wrapper around [solc-js](https://github.com/ethereum/solc-js) that adds smart re-compilation, ability to compile an entire project, Solidity version specific compilation, standard input description support and much more.',
- link: {
- title: '@0xproject/sol-compiler',
- to: WebsitePaths.SolCompiler,
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'A Solidity code coverage tool. Sol-cov uses transaction traces to figure out which lines of your code has been covered by your tests.',
- link: {
- title: '@0xproject/sol-cov',
- to: WebsitePaths.SolCov,
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'A collection of subproviders to use with [web3-provider-engine](https://www.npmjs.com/package/web3-provider-engine) (e.g subproviders for interfacing with Ledger hardware wallet, Mnemonic wallet, private key wallet, etc...)',
- link: {
- title: '@0xproject/subproviders',
- to: WebsitePaths.Subproviders,
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'A raw Ethereum JSON RPC client to simplify interfacing with Ethereum nodes. Also includes some convenience functions for awaiting transactions to be mined, converting between token units, etc...',
- link: {
- title: '@0xproject/web3-wrapper',
- to: WebsitePaths.Web3Wrapper,
- shouldOpenInNewTab: true,
- },
- },
- ],
- [Categories.CommunityMaintained]: [
- {
- description:
- 'Node.js worker originally built for 0x Tracker which extracts 0x fill events from the Ethereum blockchain and persists them to MongoDB. Support for both V1 and V2 of the 0x protocol is included with events tagged against the protocol version they belong to.',
- link: {
- title: '0x Event Extractor',
- to: 'https://github.com/0xTracker/0x-event-extractor',
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'Node.js worker built for 0x Tracker which performs various ETL tasks related to the 0x protocol trading data and other information used on 0x Tracker.',
- link: {
- title: '0x Tracker Worker',
- to: 'https://github.com/0xTracker/0x-tracker-worker',
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- "ERCdex's Javascript SDK for trading on their relayer, as well as other Aquaduct partner relayers",
- link: {
- title: 'Aquaduct',
- to: 'https://www.npmjs.com/package/aqueduct',
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'SDKs for automation using Aqueduct & ERC dEX. Aqueduct Server is a lightweight, portable and secure server that runs locally on any workstation. The server exposes a small number of foundational endpoints that enable working with the decentralized Aqueduct liquidity pool from any context or programming language.',
- link: {
- title: 'Aquaduct Server SDK',
- to: 'https://github.com/ERCdEX/aqueduct-server-sdk',
- shouldOpenInNewTab: true,
- },
- },
- {
- description: 'A node.js SDK for trading on the DDEX relayer',
- link: {
- to: 'https://www.npmjs.com/package/ddex-api',
- title: 'DDEX Node.js SDK',
- shouldOpenInNewTab: true,
- },
- },
- {
- description: "The ERC dEX Trade Widget let's any website provide token liquidity to it's users",
- link: {
- to: 'https://github.com/ERCdEX/widget',
- title: 'ERCdex Widget',
- shouldOpenInNewTab: true,
- },
- },
- {
- description: "ERCdex's Java SDK for trading on their relayer, as well as other Aquaduct partner relayers",
- link: {
- to: 'https://github.com/ERCdEX/java',
- title: 'ERCdex Java SDK',
- shouldOpenInNewTab: true,
- },
- },
- {
- description: "ERCdex's Python SDK for trading on their relayer, as well as other Aquaduct partner relayers",
- link: {
- to: 'https://github.com/ERCdEX/python',
- title: 'ERCdex Python SDK',
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'A set of command-line tools for creating command-line scripts for interacting with the Ethereum blockchain in general, and 0x in particular',
- link: {
- title: 'Massive',
- to: 'https://github.com/NoteGio/massive',
- shouldOpenInNewTab: true,
- },
- },
- {
- description: 'An open-source API-only Relayer written in Go',
- link: {
- to: 'https://github.com/NoteGio/openrelay',
- title: 'OpenRelay',
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'A JavaScript Library for Interacting with OpenRelay.xyz and other 0x Standard Relayer API Implementations',
- link: {
- title: 'OpenRelay.js',
- to: 'https://github.com/NoteGio/openrelay.js',
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'The Radar Relay SDK is a software development kit that simplifies the interactions with Radar Relay’s APIs',
- link: {
- title: 'Radar SDK',
- to: 'https://github.com/RadarRelay/sdk',
- shouldOpenInNewTab: true,
- },
- },
- {
- description:
- 'The Ocean provides a simple REST API, WebSockets API, and JavaScript library to help you integrate decentralized trading into your existing trading strategy.',
- link: {
- title: 'The Ocean Javascript SDK',
- to: 'https://github.com/TheOceanTrade/theoceanx-javascript',
- shouldOpenInNewTab: true,
- },
- },
- {
- description: "Tokenlon SDK provides APIs for developers to trade of imToken's relayer",
- link: {
- to: 'https://www.npmjs.com/package/tokenlon-sdk',
- title: 'Tokenlon Javascript SDK',
- shouldOpenInNewTab: true,
- },
- },
- {
- description: 'A small library that implements the 0x order assetData encoding/decoding in Java',
- link: {
- to: 'https://github.com/wildnothing/asset-data-decoder',
- title: 'AssetData decoder library in Java',
- shouldOpenInNewTab: true,
- },
- },
- ],
-};
-
-interface Package {
- description: string;
- link: ALink;
-}
-
-export interface HomeProps {
- location: Location;
- translate: Translate;
- screenWidth: ScreenWidths;
- dispatcher: Dispatcher;
-}
-
-export interface HomeState {
- isHoveringSidebar: boolean;
- isHoveringMainContent: boolean;
- isSidebarScrolling: boolean;
-}
-
-export class Home extends React.Component<HomeProps, HomeState> {
- private readonly _throttledScreenWidthUpdate: () => void;
- private readonly _throttledSidebarScrolling: () => void;
- private _sidebarScrollClearingInterval: number;
- constructor(props: HomeProps) {
- super(props);
- this._throttledScreenWidthUpdate = _.throttle(this._updateScreenWidth.bind(this), THROTTLE_TIMEOUT);
- this._throttledSidebarScrolling = _.throttle(this._onSidebarScroll.bind(this), THROTTLE_TIMEOUT);
- this.state = {
- isHoveringSidebar: false,
- isHoveringMainContent: false,
- isSidebarScrolling: false,
- };
- }
- public componentDidMount(): void {
- window.addEventListener('resize', this._throttledScreenWidthUpdate);
- window.scrollTo(0, 0);
- this._sidebarScrollClearingInterval = window.setInterval(() => {
- this.setState({
- isSidebarScrolling: false,
- });
- }, 1000);
- }
- public componentWillUnmount(): void {
- window.removeEventListener('resize', this._throttledScreenWidthUpdate);
- window.clearInterval(this._sidebarScrollClearingInterval);
- }
- public render(): React.ReactNode {
- const scrollableContainerStyles: React.CSSProperties = {
- position: 'absolute',
- top: 80,
- left: 0,
- bottom: 0,
- right: 0,
- overflowX: 'hidden',
- overflowY: 'scroll',
- minHeight: `calc(100vh - ${TOP_BAR_HEIGHT}px)`,
- WebkitOverflowScrolling: 'touch',
- };
- const isSmallScreen = this.props.screenWidth === ScreenWidths.Sm;
- const mainContentPadding = isSmallScreen ? 20 : 50;
- const sectionNameToLinks: ObjectMap<ALink[]> = {
- 'Starter guides': _.map(TUTORIALS, tutorialInfo => {
- return {
- ...tutorialInfo.link,
- title: this.props.translate.get(tutorialInfo.link.title as Key, Deco.Cap),
- };
- }),
- [Categories.ZeroExProtocol]: _.map(CATEGORY_TO_PACKAGES[Categories.ZeroExProtocol], pkg => pkg.link),
- [Categories.Ethereum]: _.map(CATEGORY_TO_PACKAGES[Categories.Ethereum], pkg => pkg.link),
- [Categories.CommunityMaintained]: _.map(
- CATEGORY_TO_PACKAGES[Categories.CommunityMaintained],
- pkg => pkg.link,
- ),
- };
- return (
- <Container
- className="flex items-center overflow-hidden"
- width="100%"
- background={`linear-gradient(to right, ${colors.grey100} 0%, ${colors.grey100} 50%, ${
- colors.white
- } 50%, ${colors.white} 100%)`}
- >
- <DocumentTitle title="0x Docs Home" />
- <Container className="flex mx-auto" height="100vh">
- <Container
- className="sm-hide xs-hide relative"
- width={234}
- paddingLeft={22}
- paddingRight={22}
- paddingTop={0}
- backgroundColor={colors.grey100}
- >
- <Container
- borderBottom={this.state.isSidebarScrolling ? `1px solid ${colors.grey300}` : 'none'}
- >
- <Container paddingTop="30px" paddingLeft="10px" paddingBottom="8px">
- <DocsLogo height={36} />
- </Container>
- </Container>
- <div
- style={{
- ...scrollableContainerStyles,
- paddingTop: 27,
- overflow: this.state.isHoveringSidebar ? 'auto' : 'hidden',
- }}
- onMouseEnter={this._onSidebarHover.bind(this, true)}
- onMouseLeave={this._onSidebarHover.bind(this, false)}
- onWheel={this._throttledSidebarScrolling}
- >
- <Container paddingLeft="22px" paddingRight="22px" paddingBottom="100px">
- <NestedSidebarMenu
- sectionNameToLinks={sectionNameToLinks}
- shouldReformatMenuItemNames={false}
- />
- </Container>
- </div>
- </Container>
- <Container
- className="relative"
- width={isSmallScreen ? '100vw' : 716}
- paddingBottom="100px"
- backgroundColor={colors.white}
- >
- <Container paddingLeft={mainContentPadding} paddingRight={mainContentPadding}>
- <DocsTopBar
- location={this.props.location}
- translate={this.props.translate}
- sectionNameToLinks={sectionNameToLinks}
- />
- </Container>
- <div
- id={sharedConstants.SCROLL_CONTAINER_ID}
- className="absolute"
- style={{
- ...scrollableContainerStyles,
- paddingTop: 30,
- paddingLeft: mainContentPadding,
- paddingRight: this.state.isHoveringMainContent
- ? mainContentPadding - SCROLLER_WIDTH
- : mainContentPadding,
- overflow: this.state.isHoveringMainContent ? 'auto' : 'hidden',
- }}
- onMouseEnter={this._onMainContentHover.bind(this, true)}
- onMouseOver={this._onMainContentHover.bind(this, true)}
- onMouseLeave={this._onMainContentHover.bind(this, false)}
- >
- <Container>
- {this._renderSectionTitle(this.props.translate.get(Key.StartBuildOn0x, Deco.Cap))}
- <Container paddingTop="12px">
- {this._renderSectionDescription(
- this.props.translate.get(Key.StartBuildOn0xDescription, Deco.Cap),
- )}
- <Container marginTop="36px">
- {_.map(TUTORIALS, tutorialInfo => (
- <ScrollElement
- name={sharedUtils.getIdFromName(
- this.props.translate.get(tutorialInfo.link.title as Key, Deco.Cap),
- )}
- key={`tutorial-${tutorialInfo.link.title}`}
- >
- <TutorialButton
- translate={this.props.translate}
- tutorialInfo={tutorialInfo}
- />
- </ScrollElement>
- ))}
- </Container>
- </Container>
- <Container marginTop="32px" paddingBottom="100px">
- {this._renderSectionTitle(
- this.props.translate.get(Key.LibrariesAndTools, Deco.CapWords),
- )}
- <Container paddingTop="12px">
- {this._renderSectionDescription(
- this.props.translate.get(Key.LibrariesAndToolsDescription, Deco.Cap),
- )}
- <Container marginTop="36px">
- {_.map(CATEGORY_TO_PACKAGES, (pkgs, category) =>
- this._renderPackageCategory(category, pkgs),
- )}
- </Container>
- </Container>
- </Container>
- </Container>
- </div>
- </Container>
- </Container>
- </Container>
- );
- }
- private _renderPackageCategory(category: string, pkgs: Package[]): React.ReactNode {
- return (
- <Container key={`category-${category}`}>
- <Text fontSize="18px">{category}</Text>
- <Container>{_.map(pkgs, pkg => this._renderPackage(pkg))}</Container>
- </Container>
- );
- }
- private _renderPackage(pkg: Package): React.ReactNode {
- const id = sharedUtils.getIdFromName(pkg.link.title);
- return (
- <ScrollElement name={id} key={`package-${pkg.link.title}`}>
- <Container className="pb2">
- <Container width="100%" height="1px" backgroundColor={colors.grey300} marginTop="11px" />
- <Container className="clearfix mt2 pt1">
- <Container className="md-col lg-col md-col-4 lg-col-4">
- <Link
- to={pkg.link.to}
- fontColor={colors.lightLinkBlue}
- shouldOpenInNewTab={!!pkg.link.shouldOpenInNewTab}
- >
- <Text Tag="div" fontColor={colors.lightLinkBlue} fontWeight="bold">
- {pkg.link.title}
- </Text>
- </Link>
- </Container>
- <Container className="md-col lg-col md-col-6 lg-col-6 sm-py2">
- <Text fontColor={colors.grey700}>
- <ReactMarkdown
- source={pkg.description}
- renderers={{
- link: MarkdownLinkBlock,
- paragraph: 'span',
- }}
- />
- </Text>
- </Container>
- <Container className="md-col lg-col md-col-2 lg-col-2 sm-pb2 relative">
- <Container position="absolute" right="0px">
- <Link
- to={pkg.link.to}
- fontColor={colors.lightLinkBlue}
- shouldOpenInNewTab={!!pkg.link.shouldOpenInNewTab}
- >
- <Container className="flex">
- <Container>{this.props.translate.get(Key.More, Deco.Cap)}</Container>
- <Container paddingTop="1px" paddingLeft="6px">
- <i
- className="zmdi zmdi-chevron-right bold"
- style={{ fontSize: 18, color: colors.lightLinkBlue }}
- />
- </Container>
- </Container>
- </Link>
- </Container>
- </Container>
- </Container>
- </Container>
- </ScrollElement>
- );
- }
- private _renderSectionTitle(text: string): React.ReactNode {
- return (
- <Text fontColor={colors.projectsGrey} fontSize="30px" fontWeight="bold">
- {text}
- </Text>
- );
- }
- private _renderSectionDescription(text: string): React.ReactNode {
- return (
- <Text fontColor={colors.linkSectionGrey} fontSize="16px" fontFamily="Roboto Mono">
- {text}
- </Text>
- );
- }
- private _onSidebarHover(isHovering: boolean, _event: React.FormEvent<HTMLInputElement>): void {
- if (isHovering !== this.state.isHoveringSidebar) {
- this.setState({
- isHoveringSidebar: isHovering,
- });
- }
- }
- private _onMainContentHover(isHovering: boolean, _event: React.FormEvent<HTMLInputElement>): void {
- if (isHovering !== this.state.isHoveringMainContent) {
- this.setState({
- isHoveringMainContent: isHovering,
- });
- }
- }
- private _onSidebarScroll(_event: React.FormEvent<HTMLInputElement>): void {
- this.setState({
- isSidebarScrolling: true,
- });
- }
- private _updateScreenWidth(): void {
- const newScreenWidth = utils.getScreenWidth();
- this.props.dispatcher.updateScreenWidth(newScreenWidth);
- }
-} // tslint:disable:max-file-line-count
diff --git a/packages/website/ts/pages/landing/landing.tsx b/packages/website/ts/pages/landing/landing.tsx
index 395cdabf8..f7a6fe0ce 100644
--- a/packages/website/ts/pages/landing/landing.tsx
+++ b/packages/website/ts/pages/landing/landing.tsx
@@ -212,7 +212,7 @@ export class Landing extends React.Component<LandingProps, LandingState> {
className={`pt3 flex clearfix sm-mx-auto ${isSmallScreen ? 'justify-center' : ''}`}
>
<Container paddingRight="20px">
- <Link to={WebsitePaths.ZeroExJs}>
+ <Link to={WebsitePaths.Docs}>
<CallToAction type="light">
{this.props.translate.get(Key.BuildCallToAction, Deco.Cap)}
</CallToAction>
@@ -598,7 +598,7 @@ export class Landing extends React.Component<LandingProps, LandingState> {
{this.props.translate.get(Key.FinalCallToAction, Deco.Cap)}
</div>
<div className="sm-center sm-pt2 lg-table-cell md-table-cell">
- <Link to={WebsitePaths.ZeroExJs}>
+ <Link to={WebsitePaths.Docs}>
<CallToAction fontSize="15px">
{this.props.translate.get(Key.BuildCallToAction, Deco.Cap)}
</CallToAction>
diff --git a/packages/website/ts/pages/wiki/wiki.tsx b/packages/website/ts/pages/wiki/wiki.tsx
index 70f54aceb..76d52c9bd 100644
--- a/packages/website/ts/pages/wiki/wiki.tsx
+++ b/packages/website/ts/pages/wiki/wiki.tsx
@@ -3,27 +3,26 @@ import {
colors,
constants as sharedConstants,
HeaderSizes,
+ Link,
MarkdownSection,
NestedSidebarMenu,
- Styles,
utils as sharedUtils,
} from '@0xproject/react-shared';
import { ObjectMap } from '@0xproject/types';
import * as _ from 'lodash';
import CircularProgress from 'material-ui/CircularProgress';
-import RaisedButton from 'material-ui/RaisedButton';
import * as React from 'react';
-import DocumentTitle = require('react-document-title');
-import { SidebarHeader } from 'ts/components/sidebar_header';
-import { TopBar } from 'ts/components/top_bar/top_bar';
+import { SidebarHeader } from 'ts/components/documentation/sidebar_header';
+import { Button } from 'ts/components/ui/button';
+import { Container } from 'ts/components/ui/container';
+import { DevelopersPage } from 'ts/pages/documentation/developers_page';
import { Dispatcher } from 'ts/redux/dispatcher';
-import { Article, ArticlesBySection } from 'ts/types';
+import { Article, ArticlesBySection, Deco, Key, ScreenWidths } from 'ts/types';
import { backendClient } from 'ts/utils/backend_client';
import { constants } from 'ts/utils/constants';
import { Translate } from 'ts/utils/translate';
import { utils } from 'ts/utils/utils';
-const TOP_BAR_HEIGHT = 60;
const WIKI_NOT_READY_BACKOUT_TIMEOUT_MS = 5000;
export interface WikiProps {
@@ -31,6 +30,7 @@ export interface WikiProps {
location: Location;
dispatcher: Dispatcher;
translate: Translate;
+ screenWidth: ScreenWidths;
}
interface WikiState {
@@ -38,24 +38,6 @@ interface WikiState {
isHoveringSidebar: boolean;
}
-const styles: Styles = {
- mainContainers: {
- position: 'absolute',
- top: 1,
- left: 0,
- bottom: 0,
- right: 0,
- overflow: 'hidden',
- height: `calc(100vh - ${TOP_BAR_HEIGHT}px)`,
- WebkitOverflowScrolling: 'touch',
- },
- menuContainer: {
- borderColor: colors.grey300,
- maxWidth: 330,
- backgroundColor: colors.gray40,
- },
-};
-
export class Wiki extends React.Component<WikiProps, WikiState> {
private _wikiBackoffTimeoutId: number;
private _isUnmounted: boolean;
@@ -83,85 +65,70 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
const sectionNameToLinks = _.isUndefined(this.state.articlesBySection)
? {}
: this._getSectionNameToLinks(this.state.articlesBySection);
- const mainContainersStyle: React.CSSProperties = {
- ...styles.mainContainers,
- overflow: this.state.isHoveringSidebar ? 'auto' : 'hidden',
- };
- const sidebarHeader = <SidebarHeader title="Wiki" iconUrl="/images/doc_icons/wiki.png" />;
- return (
- <div>
- <DocumentTitle title="0x Protocol Wiki" />
- <TopBar
- blockchainIsLoaded={false}
- location={this.props.location}
- sectionNameToLinks={sectionNameToLinks}
- translate={this.props.translate}
- sidebarHeader={sidebarHeader}
- />
- {_.isUndefined(this.state.articlesBySection) ? (
- <div className="col col-12" style={mainContainersStyle}>
- <div
- className="relative sm-px2 sm-pt2 sm-m1"
- style={{ height: 122, top: '50%', transform: 'translateY(-50%)' }}
- >
- <div className="center pb2">
- <CircularProgress size={40} thickness={5} />
- </div>
- <div className="center pt2" style={{ paddingBottom: 11 }}>
- Loading wiki...
- </div>
- </div>
- </div>
- ) : (
- <div style={{ width: '100%', height: '100%', backgroundColor: colors.gray40 }}>
- <div
- className="mx-auto max-width-4 flex"
- style={{ color: colors.grey800, height: `calc(100vh - ${TOP_BAR_HEIGHT}px)` }}
- >
- <div
- className="relative lg-pl0 md-pl1 sm-hide xs-hide"
- style={{ height: `calc(100vh - ${TOP_BAR_HEIGHT}px)`, width: '36%' }}
- >
- <div
- className="absolute"
- style={{
- ...styles.menuContainer,
- ...mainContainersStyle,
- height: 'calc(100vh - 76px)',
- }}
- onMouseEnter={this._onSidebarHover.bind(this)}
- onMouseLeave={this._onSidebarHoverOff.bind(this)}
- >
- <NestedSidebarMenu
- sectionNameToLinks={sectionNameToLinks}
- sidebarHeader={sidebarHeader}
- />
- </div>
- </div>
- <div
- className="relative"
- style={{
- width: '100%',
- height: `calc(100vh - ${TOP_BAR_HEIGHT}px)`,
- backgroundColor: 'white',
- }}
- >
- <div
- id={sharedConstants.SCROLL_CONTAINER_ID}
- style={{ ...mainContainersStyle, overflow: 'auto' }}
- className="absolute"
- >
- <div id={sharedConstants.SCROLL_TOP_ID} />
- <div id="wiki" style={{ paddingRight: 2 }}>
- {this._renderWikiArticles()}
- </div>
- </div>
- </div>
- </div>
- </div>
- )}
+
+ const mainContent = _.isUndefined(this.state.articlesBySection) ? (
+ <div className="flex justify-center">{this._renderLoading()}</div>
+ ) : (
+ <div id="wiki" style={{ paddingRight: 2 }}>
+ {this._renderWikiArticles()}
</div>
);
+ const sidebar = _.isUndefined(this.state.articlesBySection) ? (
+ <div />
+ ) : (
+ <NestedSidebarMenu sidebarHeader={this._renderSidebarHeader()} sectionNameToLinks={sectionNameToLinks} />
+ );
+ return (
+ <DevelopersPage
+ sidebar={sidebar}
+ mainContent={mainContent}
+ location={this.props.location}
+ screenWidth={this.props.screenWidth}
+ translate={this.props.translate}
+ dispatcher={this.props.dispatcher}
+ />
+ );
+ }
+ private _renderSidebarHeader(): React.ReactNode {
+ const menuItems = _.map(constants.DEVELOPER_TOPBAR_LINKS, menuItemInfo => {
+ return (
+ <Link
+ key={`menu-item-${menuItemInfo.title}`}
+ to={menuItemInfo.to}
+ shouldOpenInNewTab={menuItemInfo.shouldOpenInNewTab}
+ >
+ <Button
+ borderRadius="4px"
+ padding="0.4em 6px"
+ width="100%"
+ fontColor={colors.grey800}
+ fontSize="14px"
+ textAlign="left"
+ >
+ {this.props.translate.get(menuItemInfo.title as Key, Deco.Cap)}
+ </Button>
+ </Link>
+ );
+ });
+ const wikiTitle = this.props.translate.get(Key.Wiki, Deco.Cap);
+ return (
+ <Container>
+ <SidebarHeader screenWidth={this.props.screenWidth} title={wikiTitle} />
+ {menuItems}
+ </Container>
+ );
+ }
+ private _renderLoading(): React.ReactNode {
+ return (
+ <Container className="pt4">
+ <Container className="center pb2">
+ <CircularProgress size={40} thickness={5} />
+ </Container>
+ <Container className="center pt2" paddingBottom="11px">
+ Loading wiki...
+ </Container>
+ </Container>
+ );
}
private _renderWikiArticles(): React.ReactNode {
const sectionNames = _.keys(this.state.articlesBySection);
@@ -180,22 +147,10 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
headerSize={HeaderSizes.H2}
githubLink={githubLink}
/>
- <div className="clearfix mb3 mt2 p3 mx-auto lg-flex md-flex sm-pb4" style={{ maxWidth: 390 }}>
- <div className="sm-col sm-col-12 sm-center" style={{ opacity: 0.4, lineHeight: 2.5 }}>
- See a way to improve this article?
- </div>
- <div className="sm-col sm-col-12 lg-col-7 md-col-7 sm-center sm-pt2">
- <RaisedButton href={githubLink} target="_blank" label="Edit on Github" />
- </div>
- </div>
</div>
);
});
- return (
- <div key={`section-${sectionName}`} className="py2 md-px1 sm-px0">
- {renderedArticles}
- </div>
- );
+ return <div key={`section-${sectionName}`}>{renderedArticles}</div>;
}
private async _fetchArticlesBySectionAsync(): Promise<void> {
try {
@@ -239,16 +194,6 @@ export class Wiki extends React.Component<WikiProps, WikiState> {
}
return sectionNameToLinks;
}
- private _onSidebarHover(_event: React.FormEvent<HTMLInputElement>): void {
- this.setState({
- isHoveringSidebar: true,
- });
- }
- private _onSidebarHoverOff(): void {
- this.setState({
- isHoveringSidebar: false,
- });
- }
private _onHashChanged(_event: any): void {
const hash = window.location.hash.slice(1);
sharedUtils.scrollToHash(hash, sharedConstants.SCROLL_CONTAINER_ID);
diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts
index a3d248a9d..84be4d3b0 100644
--- a/packages/website/ts/types.ts
+++ b/packages/website/ts/types.ts
@@ -364,6 +364,7 @@ export enum WebsitePaths {
Subproviders = '/docs/subproviders',
OrderUtils = '/docs/order-utils',
EthereumTypes = '/docs/ethereum-types',
+ AssetBuyer = '/docs/asset-buyer',
Careers = '/careers',
}
@@ -380,6 +381,7 @@ export enum DocPackages {
EthereumTypes = 'ETHEREUM_TYPES',
ContractWrappers = 'CONTRACT_WRAPPERS',
OrderWatcher = 'ORDER_WATCHER',
+ AssetBuyer = 'ASSET_BUYER',
}
export enum Key {
@@ -441,6 +443,7 @@ export enum Key {
ZeroExJs = '0X_JS',
ContractWrappers = 'CONTRACT_WRAPPERS',
OrderWatcher = 'ORDER_WATCHER',
+ AssetBuyer = 'ASSET_BUYER',
Blog = 'BLOG',
Forum = 'FORUM',
Connect = 'CONNECT',
@@ -624,4 +627,15 @@ export interface TutorialInfo {
description: string;
link: ALink;
}
+
+export enum Categories {
+ ZeroExProtocol = '0x Protocol',
+ Ethereum = 'Ethereum',
+ CommunityMaintained = 'Community Maintained',
+}
+
+export interface Package {
+ description: string;
+ link: ALink;
+}
// tslint:disable:max-file-line-count
diff --git a/packages/website/ts/utils/constants.ts b/packages/website/ts/utils/constants.ts
index 0809fb438..e76d40bd3 100644
--- a/packages/website/ts/utils/constants.ts
+++ b/packages/website/ts/utils/constants.ts
@@ -1,4 +1,9 @@
+import { ALink } from '@0xproject/react-shared';
import { BigNumber } from '@0xproject/utils';
+import { Key, WebsitePaths } from 'ts/types';
+
+const URL_FORUM = 'https://forum.0xproject.com';
+const URL_ZEROEX_CHAT = 'https://chat.0xproject.com';
export const constants = {
DECIMAL_PLACES_ETH: 18,
@@ -74,7 +79,7 @@ export const constants = {
URL_TESTNET_FAUCET: 'https://faucet.0xproject.com',
URL_GITHUB_ORG: 'https://github.com/0xProject',
URL_GITHUB_WIKI: 'https://github.com/0xProject/wiki',
- URL_FORUM: 'https://forum.0xproject.com',
+ URL_FORUM,
URL_METAMASK_CHROME_STORE: 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn',
URL_METAMASK_FIREFOX_STORE: 'https://addons.mozilla.org/en-US/firefox/addon/ether-metamask/',
URL_COINBASE_WALLET_IOS_APP_STORE: 'https://itunes.apple.com/us/app/coinbase-wallet/id1278383455?mt=8',
@@ -89,7 +94,7 @@ export const constants = {
URL_STANDARD_RELAYER_API_GITHUB: 'https://github.com/0xProject/standard-relayer-api/blob/master/README.md',
URL_TWITTER: 'https://twitter.com/0xproject',
URL_WETH_IO: 'https://weth.io/',
- URL_ZEROEX_CHAT: 'https://chat.0xproject.com',
+ URL_ZEROEX_CHAT,
URL_WEB3_DOCS: 'https://github.com/ethereum/wiki/wiki/JavaScript-API',
URL_WEB3_DECODED_LOG_ENTRY_EVENT:
'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L123',
@@ -97,4 +102,24 @@ export const constants = {
URL_WEB3_PROVIDER_DOCS: 'https://github.com/0xProject/web3-typescript-typings/blob/f5bcb96/index.d.ts#L150',
URL_BIGNUMBERJS_GITHUB: 'http://mikemcl.github.io/bignumber.js',
URL_MISSION_AND_VALUES_BLOG_POST: 'https://blog.0xproject.com/the-0x-mission-and-values-181a58706f9f',
+ DEVELOPER_TOPBAR_LINKS: [
+ {
+ title: Key.Home,
+ to: WebsitePaths.Home,
+ },
+ {
+ title: Key.Wiki,
+ to: WebsitePaths.Wiki,
+ },
+ {
+ title: Key.Forum,
+ to: URL_FORUM,
+ shouldOpenInNewTab: true,
+ },
+ {
+ title: Key.LiveChat,
+ to: URL_ZEROEX_CHAT,
+ shouldOpenInNewTab: true,
+ },
+ ] as ALink[],
};
diff --git a/typedoc-tsconfig.json b/typedoc-tsconfig.json
index 588285140..32efdb4cf 100644
--- a/typedoc-tsconfig.json
+++ b/typedoc-tsconfig.json
@@ -8,6 +8,7 @@
"experimentalDecorators": true,
"downlevelIteration": true,
"noImplicitReturns": true,
+ "resolveJsonModule": true,
"pretty": true,
"skipLibCheck": true,
"typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
diff --git a/yarn.lock b/yarn.lock
index d210d7a8c..3a23bb767 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -571,6 +571,12 @@
jsonschema "1.2.2"
lodash.values "4.3.0"
+"@0xproject/npm-cli-login@^0.0.11":
+ version "0.0.11"
+ resolved "https://registry.yarnpkg.com/@0xproject/npm-cli-login/-/npm-cli-login-0.0.11.tgz#3f1ec06112ce62aad300ff0575358f68aeecde2e"
+ dependencies:
+ npm-registry-client "7.0.9"
+
"@0xproject/order-utils@^0.0.9":
version "0.0.9"
resolved "https://registry.yarnpkg.com/@0xproject/order-utils/-/order-utils-0.0.9.tgz#75225dfbd87335d18810abf995d8e077b9a84868"
@@ -1022,6 +1028,10 @@
version "0.4.30"
resolved "https://registry.yarnpkg.com/@types/istanbul/-/istanbul-0.4.30.tgz#073159320ab3296b2cfeb481f756a1f8f4c9c8e4"
+"@types/jest@^23.3.5":
+ version "23.3.5"
+ resolved "https://registry.npmjs.org/@types/jest/-/jest-23.3.5.tgz#870a1434208b60603745bfd214fc3fc675142364"
+
"@types/js-combinatorics@^0.5.29":
version "0.5.29"
resolved "https://registry.yarnpkg.com/@types/js-combinatorics/-/js-combinatorics-0.5.29.tgz#47a7819a0b6925b6dc4bd2c2278a7e6329b29387"
@@ -10337,12 +10347,6 @@ npm-bundled@^1.0.1:
version "1.0.3"
resolved "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.3.tgz#7e71703d973af3370a9591bafe3a63aca0be2308"
-npm-cli-login@^0.0.10:
- version "0.0.10"
- resolved "https://registry.yarnpkg.com/npm-cli-login/-/npm-cli-login-0.0.10.tgz#b1e8b5b7405008e0a26ccc170443434a59c5364c"
- dependencies:
- npm-registry-client "7.0.9"
-
npm-lifecycle@^2.0.0:
version "2.0.3"
resolved "http://registry.yarnpkg.com/npm-lifecycle/-/npm-lifecycle-2.0.3.tgz#696bedf1143371163e9cc16fe872357e25d8d90e"
@@ -12164,7 +12168,7 @@ react-router@^4.2.0:
prop-types "^15.5.4"
warning "^3.0.0"
-react-scroll@0xproject/react-scroll#similar-to-pr-330:
+react-scroll@0xproject/react-scroll#similar-to-pr-330-but-with-replace-state:
version "1.7.10"
resolved "https://codeload.github.com/0xproject/react-scroll/tar.gz/0f625b270d7e966313cac8b811c0ae807b37e170"
dependencies:
@@ -12483,6 +12487,10 @@ redux-devtools-extension@^2.13.2:
version "2.13.2"
resolved "https://registry.yarnpkg.com/redux-devtools-extension/-/redux-devtools-extension-2.13.2.tgz#e0f9a8e8dfca7c17be92c7124958a3b94eb2911d"
+redux-devtools-extension@^2.13.5:
+ version "2.13.5"
+ resolved "https://registry.yarnpkg.com/redux-devtools-extension/-/redux-devtools-extension-2.13.5.tgz#3ff34f7227acfeef3964194f5f7fc2765e5c5a39"
+
redux@*, redux@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.0.tgz#aa698a92b729315d22b34a0553d7e6533555cc03"
@@ -14693,6 +14701,10 @@ ts-node@^7.0.0:
source-map-support "^0.5.6"
yn "^2.0.0"
+ts-optchain@^0.1.1:
+ version "0.1.1"
+ resolved "https://registry.npmjs.org/ts-optchain/-/ts-optchain-0.1.1.tgz#9d45e2c3fc6201c2f9be82edad4c76fefb2a36d9"
+
tslib@1.9.0, tslib@^1.8.0, tslib@^1.8.1:
version "1.9.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8"
@@ -14836,9 +14848,9 @@ typedoc-default-themes@^0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.5.0.tgz#6dc2433e78ed8bea8e887a3acde2f31785bd6227"
-typedoc@0.12.0:
- version "0.12.0"
- resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.12.0.tgz#c5d606f52af29d841658e18d9faa1a72acf0e270"
+typedoc@0.13.0:
+ version "0.13.0"
+ resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.13.0.tgz#9efdf352bd54873955cd161bd4b75f24a8c59dde"
dependencies:
"@types/fs-extra" "^5.0.3"
"@types/handlebars" "^4.0.38"
@@ -14856,7 +14868,7 @@ typedoc@0.12.0:
progress "^2.0.0"
shelljs "^0.8.2"
typedoc-default-themes "^0.5.0"
- typescript "3.0.x"
+ typescript "3.1.x"
types-bn@^0.0.1:
version "0.0.1"
@@ -14864,10 +14876,14 @@ types-bn@^0.0.1:
dependencies:
bn.js "4.11.7"
-typescript@3.0.1, typescript@3.0.x:
+typescript@3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.1.tgz#43738f29585d3a87575520a4b93ab6026ef11fdb"
+typescript@3.1.x:
+ version "3.1.3"
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.1.3.tgz#01b70247a6d3c2467f70c45795ef5ea18ce191d5"
+
typewise-core@^1.2, typewise-core@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/typewise-core/-/typewise-core-1.2.0.tgz#97eb91805c7f55d2f941748fa50d315d991ef195"