aboutsummaryrefslogtreecommitdiffstats
path: root/packages/connect
diff options
context:
space:
mode:
authorHsuan Lee <hsuan@cobinhood.com>2019-01-19 18:42:04 +0800
committerHsuan Lee <hsuan@cobinhood.com>2019-01-19 18:42:04 +0800
commit7ae38906926dc09bc10670c361af0d2bf0050426 (patch)
tree5fb10ae366b987db09e4ddb4bc3ba0f75404ad08 /packages/connect
parentb5fd3c72a08aaa6957917d74c333387a16edf66b (diff)
downloaddexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar
dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.gz
dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.bz2
dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.lz
dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.xz
dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.tar.zst
dexon-sol-tools-7ae38906926dc09bc10670c361af0d2bf0050426.zip
Update dependency packages
Diffstat (limited to 'packages/connect')
-rw-r--r--packages/connect/.npmignore8
-rw-r--r--packages/connect/CHANGELOG.json471
-rw-r--r--packages/connect/CHANGELOG.md201
-rw-r--r--packages/connect/README.md74
-rw-r--r--packages/connect/coverage/.gitkeep0
-rw-r--r--packages/connect/package.json86
-rw-r--r--packages/connect/src/globals.d.ts4
-rw-r--r--packages/connect/src/http_client.ts210
-rw-r--r--packages/connect/src/index.ts20
-rw-r--r--packages/connect/src/orders_channel_factory.ts29
-rw-r--r--packages/connect/src/types.ts48
-rw-r--r--packages/connect/src/utils/assert.ts25
-rw-r--r--packages/connect/src/utils/orders_channel_message_parser.ts37
-rw-r--r--packages/connect/src/utils/relayer_response_json_parsers.ts50
-rw-r--r--packages/connect/src/utils/type_converters.ts26
-rw-r--r--packages/connect/src/ws_orders_channel.ts102
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/asset_pairs.json21
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/asset_pairs.ts25
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/fee_recipients.json10
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts12
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json19
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts21
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/order_config.json6
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/order_config.ts10
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/orderbook.json54
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/orderbook.ts58
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/orders.json26
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/orders.ts30
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/unknown_orders_channel_message.ts10
-rw-r--r--packages/connect/test/fixtures/standard_relayer_api/update_orders_channel_message.ts17
-rw-r--r--packages/connect/test/http_client_test.ts193
-rw-r--r--packages/connect/test/orders_channel_factory_test.ts34
-rw-r--r--packages/connect/test/orders_channel_message_parsers_test.ts59
-rw-r--r--packages/connect/test/ws_orders_channel_test.ts49
-rw-r--r--packages/connect/tsconfig.json8
-rw-r--r--packages/connect/tslint.json3
-rw-r--r--packages/connect/typedoc-tsconfig.json7
37 files changed, 0 insertions, 2063 deletions
diff --git a/packages/connect/.npmignore b/packages/connect/.npmignore
deleted file mode 100644
index 9db6e838d..000000000
--- a/packages/connect/.npmignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.*
-yarn-error.log
-/src/
-/scripts/
-/generated_docs/
-test/
-tsconfig.json
-/lib/src/monorepo_scripts/
diff --git a/packages/connect/CHANGELOG.json b/packages/connect/CHANGELOG.json
deleted file mode 100644
index c2f16d96a..000000000
--- a/packages/connect/CHANGELOG.json
+++ /dev/null
@@ -1,471 +0,0 @@
-[
- {
- "version": "4.0.0",
- "changes": [
- {
- "note": "Upgrade the bignumber.js to v8.0.2",
- "pr": 1517
- }
- ]
- },
- {
- "timestamp": 1547561734,
- "version": "3.0.13",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1547225310,
- "version": "3.0.12",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1547040760,
- "version": "3.0.11",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "version": "3.0.10",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ],
- "timestamp": 1544739608
- },
- {
- "version": "3.0.9",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ],
- "timestamp": 1544570656
- },
- {
- "timestamp": 1543401373,
- "version": "3.0.8",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1542821676,
- "version": "3.0.7",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1542208198,
- "version": "3.0.6",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1542134075,
- "version": "3.0.5",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1542028948,
- "version": "3.0.4",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "version": "3.0.3",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ],
- "timestamp": 1541740904
- },
- {
- "timestamp": 1539871071,
- "version": "3.0.2",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "version": "3.0.1",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ],
- "timestamp": 1538693146
- },
- {
- "version": "3.0.0",
- "changes": [
- {
- "note": "Change /order_config request to a POST instead of GET",
- "pr": 1091
- }
- ],
- "timestamp": 1538157789
- },
- {
- "timestamp": 1537907159,
- "version": "2.0.4",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "version": "2.0.3",
- "changes": [
- {
- "note": "Import SRA-related types from @0xproject/types",
- "pr": 1085
- }
- ],
- "timestamp": 1537875740
- },
- {
- "timestamp": 1537541580,
- "version": "2.0.2",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1537369748,
- "version": "2.0.1",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "version": "2.0.0",
- "changes": [
- {
- "note": "Change `OrderConfigRequest` to use BigNumber instead of string for relevant fields.",
- "pr": 1058
- }
- ],
- "timestamp": 1536142250
- },
- {
- "version": "2.0.0-rc.2",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ],
- "timestamp": 1535377027
- },
- {
- "version": "2.0.0-rc.1",
- "changes": [
- {
- "note": "Updated for SRA v2",
- "pr": 974
- },
- {
- "note": "Stopped exporting `Order` type",
- "pr": 924
- }
- ],
- "timestamp": 1535133899
- },
- {
- "timestamp": 1534210131,
- "version": "1.0.5",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1532619515,
- "version": "1.0.4",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1532614997,
- "version": "1.0.3",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1532605697,
- "version": "1.0.2",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1532357734,
- "version": "1.0.1",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1532043000,
- "version": "1.0.0",
- "changes": [
- {
- "note": "Remove `WebSocketOrderbookChannel` from the public interface and replace with `orderbookChannelFactory`"
- }
- ]
- },
- {
- "timestamp": 1531919263,
- "version": "0.6.17",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1531149657,
- "version": "0.6.16",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1529397769,
- "version": "0.6.15",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1527616612,
- "version": "0.6.14",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1527008270,
- "version": "0.6.13",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1525477860,
- "version": "0.6.12",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1525428773,
- "version": "0.6.11",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1524044013,
- "version": "0.6.10",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1523462196,
- "version": "0.6.9",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1522673609,
- "version": "0.6.8",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "timestamp": 1522658513,
- "version": "0.6.7",
- "changes": [
- {
- "note": "Dependencies updated"
- }
- ]
- },
- {
- "version": "0.6.4",
- "changes": [
- {
- "note": "Consolidate `Order`, `SignedOrder`, and `ECSignature` into the `@0xproject/types` package",
- "pr": 456
- }
- ],
- "timestamp": 1521298800
- },
- {
- "version": "0.6.2",
- "changes": [
- {
- "note": "Fix JSON parse empty response",
- "pr": 407
- }
- ],
- "timestamp": 1518706800
- },
- {
- "version": "0.6.0",
- "changes": [
- {
- "note": "Add pagination options to HttpClient methods",
- "pr": 393
- },
- {
- "note": "Add heartbeat configuration to WebSocketOrderbookChannel constructor",
- "pr": 406
- }
- ],
- "timestamp": 1518706800
- },
- {
- "version": "0.5.7",
- "changes": [
- {
- "note": "Fix publishing issue where .npmignore was not properly excluding undesired content",
- "pr": 389
- }
- ],
- "timestamp": 1518102000
- },
- {
- "version": "0.5.0",
- "changes": [
- {
- "note": "Sanitize api endpoint url and remove trailing slashes",
- "pr": 318
- },
- {
- "note": "Improve error message text in HttpClient",
- "pr": 318
- },
- {
- "note": "Stop appending '/v0' to api endpoint url in HttpClient",
- "pr": 318
- }
- ],
- "timestamp": 1516114800
- },
- {
- "version": "0.4.0",
- "changes": [
- {
- "note": "Prevent getFeesAsync method on HttpClient from mutating input",
- "pr": 296
- }
- ],
- "timestamp": 1515596400
- },
- {
- "version": "0.3.0",
- "changes": [
- {
- "note": "Expose WebSocketOrderbookChannel and associated types to public interface",
- "pr": 251
- },
- {
- "note": "Remove tokenA and tokenB fields from OrdersRequest",
- "pr": 256
- }
- ],
- "timestamp": 1512658800
- },
- {
- "version": "0.2.0",
- "changes": [
- {
- "note": "Add SignedOrder and TokenTradeInfo to the public interface"
- },
- {
- "note": "Add ECSignature and Order to the public interface"
- },
- {
- "note": "Remove dependency on 0x.js"
- }
- ],
- "timestamp": 1511881200
- },
- {
- "version": "0.1.0",
- "changes": [
- {
- "note": "Provide a HttpClient class for interacting with standard relayer api compliant HTTP urls"
- }
- ],
- "timestamp": 1511276400
- }
-]
diff --git a/packages/connect/CHANGELOG.md b/packages/connect/CHANGELOG.md
deleted file mode 100644
index 7556aae72..000000000
--- a/packages/connect/CHANGELOG.md
+++ /dev/null
@@ -1,201 +0,0 @@
-<!--
-changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
-Edit the package's CHANGELOG.json file only.
--->
-
-CHANGELOG
-
-## v3.0.13 - _January 15, 2019_
-
- * Dependencies updated
-
-## v3.0.12 - _January 11, 2019_
-
- * Dependencies updated
-
-## v3.0.11 - _January 9, 2019_
-
- * Dependencies updated
-
-## v3.0.10 - _December 13, 2018_
-
- * Dependencies updated
-
-## v3.0.9 - _December 11, 2018_
-
- * Dependencies updated
-
-## v3.0.8 - _November 28, 2018_
-
- * Dependencies updated
-
-## v3.0.7 - _November 21, 2018_
-
- * Dependencies updated
-
-## v3.0.6 - _November 14, 2018_
-
- * Dependencies updated
-
-## v3.0.5 - _November 13, 2018_
-
- * Dependencies updated
-
-## v3.0.4 - _November 12, 2018_
-
- * Dependencies updated
-
-## v3.0.3 - _November 9, 2018_
-
- * Dependencies updated
-
-## v3.0.2 - _October 18, 2018_
-
- * Dependencies updated
-
-## v3.0.1 - _October 4, 2018_
-
- * Dependencies updated
-
-## v3.0.0 - _September 28, 2018_
-
- * Change /order_config request to a POST instead of GET (#1091)
-
-## v2.0.4 - _September 25, 2018_
-
- * Dependencies updated
-
-## v2.0.3 - _September 25, 2018_
-
- * Import SRA-related types from @0xproject/types (#1085)
-
-## v2.0.2 - _September 21, 2018_
-
- * Dependencies updated
-
-## v2.0.1 - _September 19, 2018_
-
- * Dependencies updated
-
-## v2.0.0 - _September 5, 2018_
-
- * Change `OrderConfigRequest` to use BigNumber instead of string for relevant fields. (#1058)
-
-## v2.0.0-rc.2 - _August 27, 2018_
-
- * Dependencies updated
-
-## v2.0.0-rc.1 - _August 24, 2018_
-
- * Updated for SRA v2 (#974)
- * Stopped exporting `Order` type (#924)
-
-## v1.0.5 - _August 14, 2018_
-
- * Dependencies updated
-
-## v1.0.4 - _July 26, 2018_
-
- * Dependencies updated
-
-## v1.0.3 - _July 26, 2018_
-
- * Dependencies updated
-
-## v1.0.2 - _July 26, 2018_
-
- * Dependencies updated
-
-## v1.0.1 - _July 23, 2018_
-
- * Dependencies updated
-
-## v1.0.0 - _July 19, 2018_
-
- * Remove `WebSocketOrderbookChannel` from the public interface and replace with `orderbookChannelFactory`
-
-## v0.6.17 - _July 18, 2018_
-
- * Dependencies updated
-
-## v0.6.16 - _July 9, 2018_
-
- * Dependencies updated
-
-## v0.6.15 - _June 19, 2018_
-
- * Dependencies updated
-
-## v0.6.14 - _May 29, 2018_
-
- * Dependencies updated
-
-## v0.6.13 - _May 22, 2018_
-
- * Dependencies updated
-
-## v0.6.12 - _May 4, 2018_
-
- * Dependencies updated
-
-## v0.6.11 - _May 4, 2018_
-
- * Dependencies updated
-
-## v0.6.10 - _April 18, 2018_
-
- * Dependencies updated
-
-## v0.6.9 - _April 11, 2018_
-
- * Dependencies updated
-
-## v0.6.8 - _April 2, 2018_
-
- * Dependencies updated
-
-## v0.6.7 - _April 2, 2018_
-
- * Dependencies updated
-
-## v0.6.4 - _March 17, 2018_
-
- * Consolidate `Order`, `SignedOrder`, and `ECSignature` into the `@0xproject/types` package (#456)
-
-## v0.6.2 - _February 15, 2018_
-
- * Fix JSON parse empty response (#407)
-
-## v0.6.0 - _February 15, 2018_
-
- * Add pagination options to HttpClient methods (#393)
- * Add heartbeat configuration to WebSocketOrderbookChannel constructor (#406)
-
-## v0.5.7 - _February 8, 2018_
-
- * Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
-
-## v0.5.0 - _January 16, 2018_
-
- * Sanitize api endpoint url and remove trailing slashes (#318)
- * Improve error message text in HttpClient (#318)
- * Stop appending '/v0' to api endpoint url in HttpClient (#318)
-
-## v0.4.0 - _January 10, 2018_
-
- * Prevent getFeesAsync method on HttpClient from mutating input (#296)
-
-## v0.3.0 - _December 7, 2017_
-
- * Expose WebSocketOrderbookChannel and associated types to public interface (#251)
- * Remove tokenA and tokenB fields from OrdersRequest (#256)
-
-## v0.2.0 - _November 28, 2017_
-
- * Add SignedOrder and TokenTradeInfo to the public interface
- * Add ECSignature and Order to the public interface
- * Remove dependency on 0x.js
-
-## v0.1.0 - _November 21, 2017_
-
- * Provide a HttpClient class for interacting with standard relayer api compliant HTTP urls
diff --git a/packages/connect/README.md b/packages/connect/README.md
deleted file mode 100644
index 386b7bbbf..000000000
--- a/packages/connect/README.md
+++ /dev/null
@@ -1,74 +0,0 @@
-## @0x/connect
-
-This repository contains a Javascript library that makes it easy to interact with Relayers that conform to the [Standard Relayer API](https://github.com/0xProject/standard-relayer-api)
-
-## Installation
-
-```bash
-yarn add @0x/connect
-```
-
-If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
-
-```json
-"compilerOptions": {
- "typeRoots": ["node_modules/@0x/typescript-typings/types", "node_modules/@types"],
-}
-```
-
-## Usage
-
-- [Docs](https://0xproject.com/docs/connect)
-- [Tutorials](https://0xproject.com/wiki#connect)
-
-## Contributing
-
-We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
-
-Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
-
-### Install dependencies
-
-If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
-
-```bash
-yarn config set workspaces-experimental true
-```
-
-Then install dependencies
-
-```bash
-yarn install
-```
-
-### Build
-
-To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
-
-```bash
-PKG=@0x/connect yarn build
-```
-
-Or continuously rebuild on change:
-
-```bash
-PKG=@0x/connect yarn watch
-```
-
-### Clean
-
-```bash
-yarn clean
-```
-
-### Lint
-
-```bash
-yarn lint
-```
-
-### Run Tests
-
-```bash
-yarn test
-```
diff --git a/packages/connect/coverage/.gitkeep b/packages/connect/coverage/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
--- a/packages/connect/coverage/.gitkeep
+++ /dev/null
diff --git a/packages/connect/package.json b/packages/connect/package.json
deleted file mode 100644
index 15a4c12f1..000000000
--- a/packages/connect/package.json
+++ /dev/null
@@ -1,86 +0,0 @@
-{
- "name": "@0x/connect",
- "version": "3.0.13",
- "engines": {
- "node": ">=6.12"
- },
- "description": "A javascript library for interacting with the standard relayer api",
- "keywords": [
- "connect",
- "0xproject",
- "ethereum",
- "tokens",
- "exchange"
- ],
- "main": "lib/src/index.js",
- "types": "lib/src/index.d.ts",
- "scripts": {
- "build": "tsc -b",
- "build:ci": "yarn build",
- "clean": "shx rm -rf lib test_temp generated_docs",
- "copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures",
- "lint": "tslint --format stylish --project .",
- "run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
- "test": "run-s copy_test_fixtures run_mocha",
- "rebuild_and_test": "run-s clean build test",
- "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
- "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
- "test:circleci": "yarn test:coverage",
- "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
- },
- "config": {
- "postpublish": {
- "assets": []
- }
- },
- "repository": {
- "type": "git",
- "url": "https://github.com/0xProject/0x-monorepo.git"
- },
- "author": "Brandon Millman",
- "license": "Apache-2.0",
- "bugs": {
- "url": "https://github.com/0xProject/0x-monorepo/issues"
- },
- "homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
- "dependencies": {
- "@0x/assert": "^1.0.23",
- "@0x/json-schemas": "^2.1.7",
- "@0x/order-utils": "^3.1.2",
- "@0x/types": "^1.5.2",
- "@0x/typescript-typings": "^3.0.8",
- "@0x/utils": "^3.0.1",
- "lodash": "^4.17.5",
- "query-string": "^5.0.1",
- "sinon": "^4.0.0",
- "uuid": "^3.3.2",
- "websocket": "^1.0.25"
- },
- "devDependencies": {
- "@0x/tslint-config": "^2.0.2",
- "@types/fetch-mock": "^6.0.3",
- "@types/lodash": "4.14.104",
- "@types/mocha": "^2.2.42",
- "@types/query-string": "^5.0.1",
- "@types/sinon": "^2.2.2",
- "@types/uuid": "^3.4.3",
- "@types/websocket": "^0.0.39",
- "async-child-process": "^1.1.1",
- "chai": "^4.0.1",
- "chai-as-promised": "^7.1.0",
- "copyfiles": "^2.0.0",
- "dirty-chai": "^2.0.1",
- "fetch-mock": "^5.13.1",
- "make-promises-safe": "^1.1.0",
- "mocha": "^4.1.0",
- "npm-run-all": "^4.1.2",
- "nyc": "^11.0.1",
- "shx": "^0.2.2",
- "tslint": "5.11.0",
- "typedoc": "0.13.0",
- "typescript": "3.0.1"
- },
- "publishConfig": {
- "access": "public"
- }
-}
diff --git a/packages/connect/src/globals.d.ts b/packages/connect/src/globals.d.ts
deleted file mode 100644
index 783b92913..000000000
--- a/packages/connect/src/globals.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-declare module '*.json' {
- const value: any;
- export default value;
-}
diff --git a/packages/connect/src/http_client.ts b/packages/connect/src/http_client.ts
deleted file mode 100644
index c52425431..000000000
--- a/packages/connect/src/http_client.ts
+++ /dev/null
@@ -1,210 +0,0 @@
-import { assert } from '@0x/assert';
-import { schemas } from '@0x/json-schemas';
-import {
- APIOrder,
- AssetPairsRequestOpts,
- AssetPairsResponse,
- FeeRecipientsResponse,
- OrderbookRequest,
- OrderbookResponse,
- OrderConfigRequest,
- OrderConfigResponse,
- OrdersRequestOpts,
- OrdersResponse,
- PagedRequestOpts,
- RequestOpts,
- SignedOrder,
-} from '@0x/types';
-import { fetchAsync } from '@0x/utils';
-import * as _ from 'lodash';
-import * as queryString from 'query-string';
-
-import { Client, HttpRequestOptions, HttpRequestType } from './types';
-import { relayerResponseJsonParsers } from './utils/relayer_response_json_parsers';
-
-const TRAILING_SLASHES_REGEX = /\/+$/;
-
-/**
- * This class includes all the functionality related to interacting with a set of HTTP endpoints
- * that implement the standard relayer API v2
- */
-export class HttpClient implements Client {
- private readonly _apiEndpointUrl: string;
- /**
- * Format parameters to be appended to http requests into query string form
- */
- private static _buildQueryStringFromHttpParams(params?: object): string {
- // if params are undefined or empty, return an empty string
- if (_.isUndefined(params) || _.isEmpty(params)) {
- return '';
- }
- // stringify the formatted object
- const stringifiedParams = queryString.stringify(params);
- return `?${stringifiedParams}`;
- }
- /**
- * Instantiates a new HttpClient instance
- * @param url The relayer API base HTTP url you would like to interact with
- * @return An instance of HttpClient
- */
- constructor(url: string) {
- assert.isWebUri('url', url);
- this._apiEndpointUrl = url.replace(TRAILING_SLASHES_REGEX, ''); // remove trailing slashes
- }
- /**
- * Retrieve assetData pair info from the API
- * @param requestOpts Options specifying assetData information to retrieve, page information, and network id.
- * @return The resulting AssetPairsResponse that match the request
- */
- public async getAssetPairsAsync(
- requestOpts?: RequestOpts & AssetPairsRequestOpts & PagedRequestOpts,
- ): Promise<AssetPairsResponse> {
- if (!_.isUndefined(requestOpts)) {
- assert.doesConformToSchema('requestOpts', requestOpts, schemas.assetPairsRequestOptsSchema);
- assert.doesConformToSchema('requestOpts', requestOpts, schemas.pagedRequestOptsSchema);
- assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
- }
- const httpRequestOpts = {
- params: requestOpts,
- };
- const responseJson = await this._requestAsync('/asset_pairs', HttpRequestType.Get, httpRequestOpts);
- const assetDataPairs = relayerResponseJsonParsers.parseAssetDataPairsJson(responseJson);
- return assetDataPairs;
- }
- /**
- * Retrieve orders from the API
- * @param requestOpts Options specifying orders to retrieve and page information, page information, and network id.
- * @return The resulting OrdersResponse that match the request
- */
- public async getOrdersAsync(
- requestOpts?: RequestOpts & OrdersRequestOpts & PagedRequestOpts,
- ): Promise<OrdersResponse> {
- if (!_.isUndefined(requestOpts)) {
- assert.doesConformToSchema('requestOpts', requestOpts, schemas.ordersRequestOptsSchema);
- assert.doesConformToSchema('requestOpts', requestOpts, schemas.pagedRequestOptsSchema);
- assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
- }
- const httpRequestOpts = {
- params: requestOpts,
- };
- const responseJson = await this._requestAsync(`/orders`, HttpRequestType.Get, httpRequestOpts);
- const orders = relayerResponseJsonParsers.parseOrdersJson(responseJson);
- return orders;
- }
- /**
- * Retrieve a specific order from the API
- * @param orderHash An orderHash generated from the desired order
- * @return The APIOrder that matches the supplied orderHash
- */
- public async getOrderAsync(orderHash: string, requestOpts?: RequestOpts): Promise<APIOrder> {
- if (!_.isUndefined(requestOpts)) {
- assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
- }
- assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
- const httpRequestOpts = {
- params: requestOpts,
- };
- const responseJson = await this._requestAsync(`/order/${orderHash}`, HttpRequestType.Get, httpRequestOpts);
- const order = relayerResponseJsonParsers.parseAPIOrderJson(responseJson);
- return order;
- }
- /**
- * Retrieve an orderbook from the API
- * @param request An OrderbookRequest instance describing the specific orderbook to retrieve
- * @param requestOpts Options specifying page information, and network id.
- * @return The resulting OrderbookResponse that matches the request
- */
- public async getOrderbookAsync(
- request: OrderbookRequest,
- requestOpts?: RequestOpts & PagedRequestOpts,
- ): Promise<OrderbookResponse> {
- assert.doesConformToSchema('request', request, schemas.orderBookRequestSchema);
- if (!_.isUndefined(requestOpts)) {
- assert.doesConformToSchema('requestOpts', requestOpts, schemas.pagedRequestOptsSchema);
- assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
- }
- const httpRequestOpts = {
- params: _.defaults({}, request, requestOpts),
- };
- const responseJson = await this._requestAsync('/orderbook', HttpRequestType.Get, httpRequestOpts);
- const orderbook = relayerResponseJsonParsers.parseOrderbookResponseJson(responseJson);
- return orderbook;
- }
- /**
- * Retrieve fee information from the API
- * @param request A OrderConfigRequest instance describing the specific fees to retrieve
- * @param requestOpts Options specifying network id.
- * @return The resulting OrderConfigResponse that matches the request
- */
- public async getOrderConfigAsync(
- request: OrderConfigRequest,
- requestOpts?: RequestOpts,
- ): Promise<OrderConfigResponse> {
- if (!_.isUndefined(requestOpts)) {
- assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
- }
- assert.doesConformToSchema('request', request, schemas.orderConfigRequestSchema);
- const httpRequestOpts = {
- params: requestOpts,
- payload: request,
- };
- const responseJson = await this._requestAsync('/order_config', HttpRequestType.Post, httpRequestOpts);
- const fees = relayerResponseJsonParsers.parseOrderConfigResponseJson(responseJson);
- return fees;
- }
- /**
- * Retrieve the list of fee recipient addresses used by the relayer.
- * @param requestOpts Options specifying page information, and network id.
- * @return The resulting FeeRecipientsResponse
- */
- public async getFeeRecipientsAsync(requestOpts?: RequestOpts & PagedRequestOpts): Promise<FeeRecipientsResponse> {
- if (!_.isUndefined(requestOpts)) {
- assert.doesConformToSchema('requestOpts', requestOpts, schemas.pagedRequestOptsSchema);
- assert.doesConformToSchema('requestOpts', requestOpts, schemas.requestOptsSchema);
- }
- const httpRequestOpts = {
- params: requestOpts,
- };
- const feeRecipients = await this._requestAsync('/fee_recipients', HttpRequestType.Get, httpRequestOpts);
- assert.doesConformToSchema('feeRecipients', feeRecipients, schemas.relayerApiFeeRecipientsResponseSchema);
- return feeRecipients;
- }
- /**
- * Submit a signed order to the API
- * @param signedOrder A SignedOrder instance to submit
- * @param requestOpts Options specifying network id.
- */
- public async submitOrderAsync(signedOrder: SignedOrder, requestOpts?: RequestOpts): Promise<void> {
- assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
- const httpRequestOpts = {
- params: requestOpts,
- payload: signedOrder,
- };
- await this._requestAsync('/order', HttpRequestType.Post, httpRequestOpts);
- }
- private async _requestAsync(
- path: string,
- requestType: HttpRequestType,
- requestOptions?: HttpRequestOptions,
- ): Promise<any> {
- const params = _.get(requestOptions, 'params');
- const payload = _.get(requestOptions, 'payload');
- const query = HttpClient._buildQueryStringFromHttpParams(params);
- const url = `${this._apiEndpointUrl}${path}${query}`;
- const headers = new Headers({
- 'content-type': 'application/json',
- });
- const response = await fetchAsync(url, {
- method: requestType,
- body: JSON.stringify(payload),
- headers,
- });
- const text = await response.text();
- if (!response.ok) {
- const errorString = `${response.status} - ${response.statusText}\n${requestType} ${url}\n${text}`;
- throw Error(errorString);
- }
- const result = !_.isEmpty(text) ? JSON.parse(text) : undefined;
- return result;
- }
-}
diff --git a/packages/connect/src/index.ts b/packages/connect/src/index.ts
deleted file mode 100644
index f319d63cb..000000000
--- a/packages/connect/src/index.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-export { HttpClient } from './http_client';
-export { ordersChannelFactory } from './orders_channel_factory';
-export { Client, OrdersChannel, OrdersChannelHandler } from './types';
-export {
- APIOrder,
- AssetPairsRequestOpts,
- AssetPairsResponse,
- FeeRecipientsResponse,
- OrderbookRequest,
- OrderbookResponse,
- OrderConfigRequest,
- OrderConfigResponse,
- OrdersChannelSubscriptionOpts,
- OrdersRequestOpts,
- OrdersResponse,
- PagedRequestOpts,
- PaginatedCollection,
- RequestOpts,
- SignedOrder,
-} from '@0x/types';
diff --git a/packages/connect/src/orders_channel_factory.ts b/packages/connect/src/orders_channel_factory.ts
deleted file mode 100644
index 5986d2a77..000000000
--- a/packages/connect/src/orders_channel_factory.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import * as WebSocket from 'websocket';
-
-import { OrdersChannel, OrdersChannelHandler } from './types';
-import { assert } from './utils/assert';
-import { WebSocketOrdersChannel } from './ws_orders_channel';
-
-export const ordersChannelFactory = {
- /**
- * Instantiates a new WebSocketOrdersChannel instance
- * @param url The relayer API base WS url you would like to interact with
- * @param handler An OrdersChannelHandler instance that responds to various
- * channel updates
- * @return An OrdersChannel Promise
- */
- async createWebSocketOrdersChannelAsync(url: string, handler: OrdersChannelHandler): Promise<OrdersChannel> {
- assert.isUri('url', url);
- assert.isOrdersChannelHandler('handler', handler);
- return new Promise<OrdersChannel>((resolve, reject) => {
- const client = new WebSocket.w3cwebsocket(url);
- client.onopen = () => {
- const ordersChannel = new WebSocketOrdersChannel(client, handler);
- resolve(ordersChannel);
- };
- client.onerror = err => {
- reject(err);
- };
- });
- },
-};
diff --git a/packages/connect/src/types.ts b/packages/connect/src/types.ts
deleted file mode 100644
index 08a4506ac..000000000
--- a/packages/connect/src/types.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import {
- APIOrder,
- AssetPairsItem,
- AssetPairsRequestOpts,
- FeeRecipientsResponse,
- OrderbookRequest,
- OrderbookResponse,
- OrderConfigRequest,
- OrderConfigResponse,
- OrdersChannelSubscriptionOpts,
- OrdersRequestOpts,
- PagedRequestOpts,
- PaginatedCollection,
- SignedOrder,
-} from '@0x/types';
-
-export interface Client {
- getAssetPairsAsync: (
- requestOpts?: AssetPairsRequestOpts & PagedRequestOpts,
- ) => Promise<PaginatedCollection<AssetPairsItem>>;
- getOrdersAsync: (requestOpts?: OrdersRequestOpts & PagedRequestOpts) => Promise<PaginatedCollection<APIOrder>>;
- getOrderAsync: (orderHash: string) => Promise<APIOrder>;
- getOrderbookAsync: (request: OrderbookRequest, requestOpts?: PagedRequestOpts) => Promise<OrderbookResponse>;
- getOrderConfigAsync: (request: OrderConfigRequest) => Promise<OrderConfigResponse>;
- getFeeRecipientsAsync: (requestOpts?: PagedRequestOpts) => Promise<FeeRecipientsResponse>;
- submitOrderAsync: (signedOrder: SignedOrder) => Promise<void>;
-}
-
-export interface OrdersChannel {
- subscribe: (subscriptionOpts: OrdersChannelSubscriptionOpts) => void;
- close: () => void;
-}
-
-export interface OrdersChannelHandler {
- onUpdate: (channel: OrdersChannel, subscriptionOpts: OrdersChannelSubscriptionOpts, orders: APIOrder[]) => void;
- onError: (channel: OrdersChannel, err: Error, subscriptionOpts?: OrdersChannelSubscriptionOpts) => void;
- onClose: (channel: OrdersChannel) => void;
-}
-
-export interface HttpRequestOptions {
- params?: object;
- payload?: object;
-}
-
-export enum HttpRequestType {
- Get = 'GET',
- Post = 'POST',
-}
diff --git a/packages/connect/src/utils/assert.ts b/packages/connect/src/utils/assert.ts
deleted file mode 100644
index de7536ffe..000000000
--- a/packages/connect/src/utils/assert.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { assert as sharedAssert } from '@0x/assert';
-// HACK: We need those two unused imports because they're actually used by sharedAssert which gets injected here
-// tslint:disable-next-line:no-unused-variable
-import { Schema, schemas } from '@0x/json-schemas';
-// tslint:disable-next-line:no-unused-variable
-import { ECSignature } from '@0x/types';
-// tslint:disable-next-line:no-unused-variable
-import { BigNumber } from '@0x/utils';
-import * as _ from 'lodash';
-
-export const assert = {
- ...sharedAssert,
- isOrdersChannelSubscriptionOpts(variableName: string, subscriptionOpts: any): void {
- sharedAssert.doesConformToSchema(
- variableName,
- subscriptionOpts,
- schemas.relayerApiOrdersChannelSubscribePayloadSchema,
- );
- },
- isOrdersChannelHandler(variableName: string, handler: any): void {
- sharedAssert.isFunction(`${variableName}.onUpdate`, _.get(handler, 'onUpdate'));
- sharedAssert.isFunction(`${variableName}.onError`, _.get(handler, 'onError'));
- sharedAssert.isFunction(`${variableName}.onClose`, _.get(handler, 'onClose'));
- },
-};
diff --git a/packages/connect/src/utils/orders_channel_message_parser.ts b/packages/connect/src/utils/orders_channel_message_parser.ts
deleted file mode 100644
index 1306a74b1..000000000
--- a/packages/connect/src/utils/orders_channel_message_parser.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import { assert } from '@0x/assert';
-import { schemas } from '@0x/json-schemas';
-import * as _ from 'lodash';
-
-import { OrdersChannelMessage, OrdersChannelMessageTypes } from '@0x/types';
-
-import { relayerResponseJsonParsers } from './relayer_response_json_parsers';
-
-export const ordersChannelMessageParser = {
- parse(utf8Data: string): OrdersChannelMessage {
- // parse the message
- const messageObj = JSON.parse(utf8Data);
- // ensure we have a type parameter to switch on
- const type: string = _.get(messageObj, 'type');
- assert.assert(!_.isUndefined(type), `Message is missing a type parameter: ${utf8Data}`);
- assert.isString('type', type);
- // ensure we have a request id for the resulting message
- const requestId: string = _.get(messageObj, 'requestId');
- assert.assert(!_.isUndefined(requestId), `Message is missing a requestId parameter: ${utf8Data}`);
- assert.isString('requestId', requestId);
- switch (type) {
- case OrdersChannelMessageTypes.Update: {
- assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrdersChannelUpdateSchema);
- const ordersJson = messageObj.payload;
- const orders = relayerResponseJsonParsers.parseAPIOrdersJson(ordersJson);
- return _.assign(messageObj, { payload: orders });
- }
- default: {
- return {
- type: OrdersChannelMessageTypes.Unknown,
- requestId,
- payload: undefined,
- };
- }
- }
- },
-};
diff --git a/packages/connect/src/utils/relayer_response_json_parsers.ts b/packages/connect/src/utils/relayer_response_json_parsers.ts
deleted file mode 100644
index 2b1a658d1..000000000
--- a/packages/connect/src/utils/relayer_response_json_parsers.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-import { assert } from '@0x/assert';
-import { schemas } from '@0x/json-schemas';
-import { orderParsingUtils } from '@0x/order-utils';
-
-import {
- APIOrder,
- AssetPairsItem,
- AssetPairsResponse,
- OrderbookResponse,
- OrderConfigResponse,
- OrdersResponse,
-} from '@0x/types';
-
-import { typeConverters } from './type_converters';
-
-export const relayerResponseJsonParsers = {
- parseAssetDataPairsJson(json: any): AssetPairsResponse {
- assert.doesConformToSchema('assetDataPairsResponse', json, schemas.relayerApiAssetDataPairsResponseSchema);
- return { ...json, records: relayerResponseJsonParsers.parseAssetPairsItemsJson(json.records) };
- },
- parseAssetPairsItemsJson(json: any): AssetPairsItem[] {
- return json.map((assetDataPair: any) => {
- return orderParsingUtils.convertStringsFieldsToBigNumbers(assetDataPair, [
- 'assetDataA.minAmount',
- 'assetDataA.maxAmount',
- 'assetDataB.minAmount',
- 'assetDataB.maxAmount',
- ]);
- });
- },
- parseOrdersJson(json: any): OrdersResponse {
- assert.doesConformToSchema('relayerApiOrdersResponse', json, schemas.relayerApiOrdersResponseSchema);
- return { ...json, records: relayerResponseJsonParsers.parseAPIOrdersJson(json.records) };
- },
- parseAPIOrdersJson(json: any): APIOrder[] {
- return json.map(relayerResponseJsonParsers.parseAPIOrderJson.bind(relayerResponseJsonParsers));
- },
- parseAPIOrderJson(json: any): APIOrder {
- assert.doesConformToSchema('relayerApiOrder', json, schemas.relayerApiOrderSchema);
- return typeConverters.convertAPIOrderStringFieldsToBigNumber(json);
- },
- parseOrderbookResponseJson(json: any): OrderbookResponse {
- assert.doesConformToSchema('orderBookResponse', json, schemas.relayerApiOrderbookResponseSchema);
- return typeConverters.convertOrderbookStringFieldsToBigNumber(json);
- },
- parseOrderConfigResponseJson(json: any): OrderConfigResponse {
- assert.doesConformToSchema('orderConfigResponse', json, schemas.relayerApiOrderConfigResponseSchema);
- return orderParsingUtils.convertStringsFieldsToBigNumbers(json, ['makerFee', 'takerFee']);
- },
-};
diff --git a/packages/connect/src/utils/type_converters.ts b/packages/connect/src/utils/type_converters.ts
deleted file mode 100644
index b262a516b..000000000
--- a/packages/connect/src/utils/type_converters.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { orderParsingUtils } from '@0x/order-utils';
-import * as _ from 'lodash';
-
-import { APIOrder } from '@0x/types';
-
-export const typeConverters = {
- convertOrderbookStringFieldsToBigNumber(orderbook: any): any {
- const bids = _.get(orderbook, 'bids', []);
- const asks = _.get(orderbook, 'asks', []);
- const convertedBids = {
- ...bids,
- records: bids.records.map((order: any) => typeConverters.convertAPIOrderStringFieldsToBigNumber(order)),
- };
- const convertedAsks = {
- ...asks,
- records: asks.records.map((order: any) => typeConverters.convertAPIOrderStringFieldsToBigNumber(order)),
- };
- return {
- bids: convertedBids,
- asks: convertedAsks,
- };
- },
- convertAPIOrderStringFieldsToBigNumber(apiOrder: any): APIOrder {
- return { ...apiOrder, order: orderParsingUtils.convertOrderStringFieldsToBigNumber(apiOrder.order) };
- },
-};
diff --git a/packages/connect/src/ws_orders_channel.ts b/packages/connect/src/ws_orders_channel.ts
deleted file mode 100644
index 70a357c61..000000000
--- a/packages/connect/src/ws_orders_channel.ts
+++ /dev/null
@@ -1,102 +0,0 @@
-import { OrdersChannelMessageTypes, OrdersChannelSubscriptionOpts } from '@0x/types';
-import * as _ from 'lodash';
-import { v4 as uuid } from 'uuid';
-import * as WebSocket from 'websocket';
-
-import { OrdersChannel, OrdersChannelHandler } from './types';
-import { assert } from './utils/assert';
-import { ordersChannelMessageParser } from './utils/orders_channel_message_parser';
-
-export interface OrdersChannelSubscriptionOptsMap {
- [key: string]: OrdersChannelSubscriptionOpts;
-}
-
-/**
- * This class includes all the functionality related to interacting with a websocket endpoint
- * that implements the standard relayer API v0
- */
-export class WebSocketOrdersChannel implements OrdersChannel {
- private readonly _client: WebSocket.w3cwebsocket;
- private readonly _handler: OrdersChannelHandler;
- private readonly _subscriptionOptsMap: OrdersChannelSubscriptionOptsMap = {};
- /**
- * Instantiates a new WebSocketOrdersChannel instance
- * @param client A WebSocket client
- * @param handler An OrdersChannelHandler instance that responds to various
- * channel updates
- * @return An instance of WebSocketOrdersChannel
- */
- constructor(client: WebSocket.w3cwebsocket, handler: OrdersChannelHandler) {
- assert.isOrdersChannelHandler('handler', handler);
- // set private members
- this._client = client;
- this._handler = handler;
- // attach client callbacks
- this._client.onerror = err => {
- this._handler.onError(this, err);
- };
- this._client.onclose = () => {
- this._handler.onClose(this);
- };
- this._client.onmessage = message => {
- this._handleWebSocketMessage(message);
- };
- }
- /**
- * Subscribe to orderbook snapshots and updates from the websocket
- * @param subscriptionOpts An OrdersChannelSubscriptionOpts instance describing which
- * assetData pair to subscribe to
- */
- public subscribe(subscriptionOpts: OrdersChannelSubscriptionOpts): void {
- assert.isOrdersChannelSubscriptionOpts('subscriptionOpts', subscriptionOpts);
- assert.assert(this._client.readyState === WebSocket.w3cwebsocket.OPEN, 'WebSocket connection is closed');
- const requestId = uuid();
- this._subscriptionOptsMap[requestId] = subscriptionOpts;
- const subscribeMessage = {
- type: 'subscribe',
- channel: 'orders',
- requestId,
- payload: subscriptionOpts,
- };
- this._client.send(JSON.stringify(subscribeMessage));
- }
- /**
- * Close the websocket and stop receiving updates
- */
- public close(): void {
- this._client.close();
- }
- private _handleWebSocketMessage(message: any): void {
- if (_.isUndefined(message.data)) {
- this._handler.onError(this, new Error(`Message does not contain data. Url: ${this._client.url}`));
- return;
- }
- try {
- const data = message.data;
- const parserResult = ordersChannelMessageParser.parse(data);
- const subscriptionOpts = this._subscriptionOptsMap[parserResult.requestId];
- if (_.isUndefined(subscriptionOpts)) {
- this._handler.onError(
- this,
- new Error(`Message has unknown requestId. Url: ${this._client.url} Message: ${data}`),
- );
- return;
- }
- switch (parserResult.type) {
- case OrdersChannelMessageTypes.Update: {
- this._handler.onUpdate(this, subscriptionOpts, parserResult.payload);
- break;
- }
- default: {
- this._handler.onError(
- this,
- new Error(`Message has unknown type parameter. Url: ${this._client.url} Message: ${data}`),
- subscriptionOpts,
- );
- }
- }
- } catch (error) {
- this._handler.onError(this, error);
- }
- }
-}
diff --git a/packages/connect/test/fixtures/standard_relayer_api/asset_pairs.json b/packages/connect/test/fixtures/standard_relayer_api/asset_pairs.json
deleted file mode 100644
index 603e9f67e..000000000
--- a/packages/connect/test/fixtures/standard_relayer_api/asset_pairs.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "total": 43,
- "page": 1,
- "perPage": 100,
- "records": [
- {
- "assetDataA": {
- "minAmount": "0",
- "maxAmount": "10000000000000000000",
- "precision": 5,
- "assetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d"
- },
- "assetDataB": {
- "minAmount": "0",
- "maxAmount": "50000000000000000000",
- "precision": 5,
- "assetData": "0x0257179264389b814a946f3e92105513705ca6b990"
- }
- }
- ]
-}
diff --git a/packages/connect/test/fixtures/standard_relayer_api/asset_pairs.ts b/packages/connect/test/fixtures/standard_relayer_api/asset_pairs.ts
deleted file mode 100644
index 3ceeffdc8..000000000
--- a/packages/connect/test/fixtures/standard_relayer_api/asset_pairs.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { BigNumber } from '@0x/utils';
-
-import { AssetPairsResponse } from '@0x/types';
-
-export const assetDataPairsResponse: AssetPairsResponse = {
- total: 43,
- page: 1,
- perPage: 100,
- records: [
- {
- assetDataA: {
- minAmount: new BigNumber('0'),
- maxAmount: new BigNumber('10000000000000000000'),
- precision: 5,
- assetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
- },
- assetDataB: {
- minAmount: new BigNumber('0'),
- maxAmount: new BigNumber('50000000000000000000'),
- precision: 5,
- assetData: '0x0257179264389b814a946f3e92105513705ca6b990',
- },
- },
- ],
-};
diff --git a/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.json b/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.json
deleted file mode 100644
index b1d570b03..000000000
--- a/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "total": 3,
- "page": 1,
- "perPage": 10,
- "records": [
- "0x6ec92694ea172ebc430c30fa31de87620967a082",
- "0x9e56625509c2f60af937f23b7b532600390e8c8b",
- "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32"
- ]
-}
diff --git a/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts b/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts
deleted file mode 100644
index 694433128..000000000
--- a/packages/connect/test/fixtures/standard_relayer_api/fee_recipients.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { FeeRecipientsResponse } from '@0x/types';
-
-export const feeRecipientsResponse: FeeRecipientsResponse = {
- total: 3,
- page: 1,
- perPage: 10,
- records: [
- '0x6ec92694ea172ebc430c30fa31de87620967a082',
- '0x9e56625509c2f60af937f23b7b532600390e8c8b',
- '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
- ],
-};
diff --git a/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json b/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json
deleted file mode 100644
index 8d2cdd8ed..000000000
--- a/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "order": {
- "makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
- "takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
- "feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
- "senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
- "makerAssetAmount": "10000000000000000",
- "takerAssetAmount": "20000000000000000",
- "makerFee": "100000000000000",
- "takerFee": "200000000000000",
- "expirationTimeSeconds": "1532560590",
- "salt": "1532559225",
- "makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
- "takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
- "exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
- "signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
- },
- "metaData": {}
-}
diff --git a/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts b/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts
deleted file mode 100644
index 3d2fbdba8..000000000
--- a/packages/connect/test/fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { BigNumber } from '@0x/utils';
-
-export const orderResponse = {
- order: {
- makerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
- takerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
- feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
- senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
- makerAssetAmount: new BigNumber('10000000000000000'),
- takerAssetAmount: new BigNumber('20000000000000000'),
- makerFee: new BigNumber('100000000000000'),
- takerFee: new BigNumber('200000000000000'),
- expirationTimeSeconds: new BigNumber('1532560590'),
- salt: new BigNumber('1532559225'),
- makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
- takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
- exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
- signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
- },
- metaData: {},
-};
diff --git a/packages/connect/test/fixtures/standard_relayer_api/order_config.json b/packages/connect/test/fixtures/standard_relayer_api/order_config.json
deleted file mode 100644
index 39da91e6d..000000000
--- a/packages/connect/test/fixtures/standard_relayer_api/order_config.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
- "feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
- "makerFee": "100000000000000",
- "takerFee": "200000000000000"
-}
diff --git a/packages/connect/test/fixtures/standard_relayer_api/order_config.ts b/packages/connect/test/fixtures/standard_relayer_api/order_config.ts
deleted file mode 100644
index 2290c39c0..000000000
--- a/packages/connect/test/fixtures/standard_relayer_api/order_config.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { BigNumber } from '@0x/utils';
-
-import { OrderConfigResponse } from '@0x/types';
-
-export const orderConfigResponse: OrderConfigResponse = {
- senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
- feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
- makerFee: new BigNumber('100000000000000'),
- takerFee: new BigNumber('200000000000000'),
-};
diff --git a/packages/connect/test/fixtures/standard_relayer_api/orderbook.json b/packages/connect/test/fixtures/standard_relayer_api/orderbook.json
deleted file mode 100644
index 5206c2217..000000000
--- a/packages/connect/test/fixtures/standard_relayer_api/orderbook.json
+++ /dev/null
@@ -1,54 +0,0 @@
-{
- "bids": {
- "total": 325,
- "page": 2,
- "perPage": 100,
- "records": [
- {
- "order": {
- "makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
- "takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
- "feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
- "senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
- "makerAssetAmount": "10000000000000000",
- "takerAssetAmount": "20000000000000000",
- "makerFee": "100000000000000",
- "takerFee": "200000000000000",
- "expirationTimeSeconds": "1532560590",
- "salt": "1532559225",
- "makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
- "takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
- "exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
- "signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
- },
- "metaData": {}
- }
- ]
- },
- "asks": {
- "total": 500,
- "page": 2,
- "perPage": 100,
- "records": [
- {
- "order": {
- "makerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
- "takerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
- "feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
- "senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
- "makerAssetAmount": "20000000000000000",
- "takerAssetAmount": "10000000000000000",
- "makerFee": "200000000000000",
- "takerFee": "100000000000000",
- "expirationTimeSeconds": "1532560590",
- "salt": "1532559225",
- "makerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
- "takerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
- "exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
- "signature": "0x013842a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b3518891"
- },
- "metaData": {}
- }
- ]
- }
-}
diff --git a/packages/connect/test/fixtures/standard_relayer_api/orderbook.ts b/packages/connect/test/fixtures/standard_relayer_api/orderbook.ts
deleted file mode 100644
index de2d4eaea..000000000
--- a/packages/connect/test/fixtures/standard_relayer_api/orderbook.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import { BigNumber } from '@0x/utils';
-
-import { OrderbookResponse } from '@0x/types';
-
-export const orderbookResponse: OrderbookResponse = {
- bids: {
- total: 325,
- page: 2,
- perPage: 100,
- records: [
- {
- order: {
- makerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
- takerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
- feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
- senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
- makerAssetAmount: new BigNumber('10000000000000000'),
- takerAssetAmount: new BigNumber('20000000000000000'),
- makerFee: new BigNumber('100000000000000'),
- takerFee: new BigNumber('200000000000000'),
- expirationTimeSeconds: new BigNumber('1532560590'),
- salt: new BigNumber('1532559225'),
- makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
- takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
- exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
- signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
- },
- metaData: {},
- },
- ],
- },
- asks: {
- total: 500,
- page: 2,
- perPage: 100,
- records: [
- {
- order: {
- makerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
- takerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
- feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
- senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
- makerAssetAmount: new BigNumber('20000000000000000'),
- takerAssetAmount: new BigNumber('10000000000000000'),
- makerFee: new BigNumber('200000000000000'),
- takerFee: new BigNumber('100000000000000'),
- expirationTimeSeconds: new BigNumber('1532560590'),
- salt: new BigNumber('1532559225'),
- makerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
- takerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
- exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
- signature: '0x013842a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b3518891',
- },
- metaData: {},
- },
- ],
- },
-};
diff --git a/packages/connect/test/fixtures/standard_relayer_api/orders.json b/packages/connect/test/fixtures/standard_relayer_api/orders.json
deleted file mode 100644
index 683612071..000000000
--- a/packages/connect/test/fixtures/standard_relayer_api/orders.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "total": 984,
- "page": 1,
- "perPage": 100,
- "records": [
- {
- "order": {
- "makerAddress": "0x9e56625509c2f60af937f23b7b532600390e8c8b",
- "takerAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
- "feeRecipientAddress": "0xb046140686d052fff581f63f8136cce132e857da",
- "senderAddress": "0xa2b31dacf30a9c50ca473337c01d8a201ae33e32",
- "makerAssetAmount": "10000000000000000",
- "takerAssetAmount": "20000000000000000",
- "makerFee": "100000000000000",
- "takerFee": "200000000000000",
- "expirationTimeSeconds": "1532560590",
- "salt": "1532559225",
- "makerAssetData": "0xf47261b04c32345ced77393b3530b1eed0f346429d",
- "takerAssetData": "0x0257179264389b814a946f3e92105513705ca6b990",
- "exchangeAddress": "0x12459c951127e0c374ff9105dda097662a027093",
- "signature": "0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33"
- },
- "metaData": {}
- }
- ]
-}
diff --git a/packages/connect/test/fixtures/standard_relayer_api/orders.ts b/packages/connect/test/fixtures/standard_relayer_api/orders.ts
deleted file mode 100644
index ed1f588df..000000000
--- a/packages/connect/test/fixtures/standard_relayer_api/orders.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { BigNumber } from '@0x/utils';
-
-import { OrdersResponse } from '@0x/types';
-
-export const ordersResponse: OrdersResponse = {
- total: 984,
- page: 1,
- perPage: 100,
- records: [
- {
- order: {
- makerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
- takerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
- feeRecipientAddress: '0xb046140686d052fff581f63f8136cce132e857da',
- senderAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
- makerAssetAmount: new BigNumber('10000000000000000'),
- takerAssetAmount: new BigNumber('20000000000000000'),
- makerFee: new BigNumber('100000000000000'),
- takerFee: new BigNumber('200000000000000'),
- expirationTimeSeconds: new BigNumber('1532560590'),
- salt: new BigNumber('1532559225'),
- makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
- takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
- exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
- signature: '0x012761a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
- },
- metaData: {},
- },
- ],
-};
diff --git a/packages/connect/test/fixtures/standard_relayer_api/unknown_orders_channel_message.ts b/packages/connect/test/fixtures/standard_relayer_api/unknown_orders_channel_message.ts
deleted file mode 100644
index b6c0cd50c..000000000
--- a/packages/connect/test/fixtures/standard_relayer_api/unknown_orders_channel_message.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import * as orderResponseJSON from './order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json';
-
-const orderJSONString = JSON.stringify(orderResponseJSON);
-
-export const unknownOrdersChannelMessage = `{
- "type": "superGoodUpdate",
- "channel": "orderbook",
- "requestId": "6ce8c5a6-5c46-4027-a44a-51831c77b8a1",
- "payload": [${orderJSONString}]
-}`;
diff --git a/packages/connect/test/fixtures/standard_relayer_api/update_orders_channel_message.ts b/packages/connect/test/fixtures/standard_relayer_api/update_orders_channel_message.ts
deleted file mode 100644
index c18a2c789..000000000
--- a/packages/connect/test/fixtures/standard_relayer_api/update_orders_channel_message.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import * as apiOrderJSON from './order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json';
-
-const apiOrderJSONString = JSON.stringify(apiOrderJSON);
-
-export const updateOrdersChannelMessage = `{
- "type": "update",
- "channel": "orders",
- "requestId": "5a1ce3a2-22b9-41e6-a615-68077512e9e2",
- "payload": [${apiOrderJSONString}]
-}`;
-
-export const malformedUpdateOrdersChannelMessage = `{
- "type": "update",
- "channel": "orders",
- "requestId": "4d8efcee-adde-4475-9601-f0b30962ca2b",
- "payload": {}
-}`;
diff --git a/packages/connect/test/http_client_test.ts b/packages/connect/test/http_client_test.ts
deleted file mode 100644
index f799ca849..000000000
--- a/packages/connect/test/http_client_test.ts
+++ /dev/null
@@ -1,193 +0,0 @@
-import { BigNumber } from '@0x/utils';
-import * as chai from 'chai';
-import * as chaiAsPromised from 'chai-as-promised';
-import * as dirtyChai from 'dirty-chai';
-import * as fetchMock from 'fetch-mock';
-import 'mocha';
-
-import { HttpClient } from '../src/index';
-
-import { assetDataPairsResponse } from './fixtures/standard_relayer_api/asset_pairs';
-import * as assetDataPairsResponseJSON from './fixtures/standard_relayer_api/asset_pairs.json';
-import { feeRecipientsResponse } from './fixtures/standard_relayer_api/fee_recipients';
-import * as feeRecipientsResponseJSON from './fixtures/standard_relayer_api/fee_recipients.json';
-import { orderResponse } from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f';
-import * as orderResponseJSON from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f.json';
-import { orderConfigResponse } from './fixtures/standard_relayer_api/order_config';
-import * as orderConfigResponseJSON from './fixtures/standard_relayer_api/order_config.json';
-import { orderbookResponse } from './fixtures/standard_relayer_api/orderbook';
-import * as orderbookJSON from './fixtures/standard_relayer_api/orderbook.json';
-import { ordersResponse } from './fixtures/standard_relayer_api/orders';
-import * as ordersResponseJSON from './fixtures/standard_relayer_api/orders.json';
-
-chai.config.includeStack = true;
-chai.use(dirtyChai);
-chai.use(chaiAsPromised);
-const expect = chai.expect;
-
-describe('HttpClient', () => {
- const relayUrl = 'https://example.com';
- const relayerClient = new HttpClient(relayUrl);
- beforeEach(() => {
- fetchMock.restore();
- });
- describe('#constructor', () => {
- it('should remove trailing slashes from api url', async () => {
- const urlWithTrailingSlash = 'https://slash.com/';
- const urlWithoutTrailingSlash = 'https://slash.com';
- const client = new HttpClient(urlWithTrailingSlash);
- const sanitizedUrl = (client as any)._apiEndpointUrl;
- expect(sanitizedUrl).to.be.deep.equal(urlWithoutTrailingSlash);
- });
- });
- describe('#getAssetPairsAsync', () => {
- const url = `${relayUrl}/asset_pairs`;
- it('gets assetData pairs with default options when none are provided', async () => {
- fetchMock.get(url, assetDataPairsResponseJSON);
- const assetDataPairs = await relayerClient.getAssetPairsAsync();
- expect(assetDataPairs).to.be.deep.equal(assetDataPairsResponse);
- });
- it('gets assetData pairs with specified request options', async () => {
- const assetData = '0xf47261b04c32345ced77393b3530b1eed0f346429d';
- const assetPairsRequestOpts = {
- assetDataA: assetData,
- page: 3,
- perPage: 50,
- networkdId: 42,
- };
- const urlWithQuery = `${url}?assetDataA=${assetData}&networkdId=42&page=3&perPage=50`;
- fetchMock.get(urlWithQuery, assetDataPairsResponseJSON);
- const assetDataPairs = await relayerClient.getAssetPairsAsync(assetPairsRequestOpts);
- expect(assetDataPairs).to.be.deep.equal(assetDataPairsResponse);
- });
- it('throws an error for invalid JSON response', async () => {
- fetchMock.get(url, { test: 'dummy' });
- expect(relayerClient.getAssetPairsAsync()).to.be.rejected();
- });
- });
- describe('#getOrdersAsync', () => {
- const url = `${relayUrl}/orders`;
- it('gets orders with default options when none are provided', async () => {
- fetchMock.get(url, ordersResponseJSON);
- const orders = await relayerClient.getOrdersAsync();
- expect(orders).to.be.deep.equal(ordersResponse);
- });
- it('gets orders with specified request options', async () => {
- const assetDataAddress = '0x323b5d4c32345ced77393b3530b1eed0f346429d';
- const ordersRequest = {
- assetDataAddress,
- page: 3,
- perPage: 50,
- networkdId: 42,
- };
- const urlWithQuery = `${url}?assetDataAddress=${assetDataAddress}&networkdId=42&page=3&perPage=50`;
- fetchMock.get(urlWithQuery, ordersResponseJSON);
- const orders = await relayerClient.getOrdersAsync(ordersRequest);
- expect(orders).to.be.deep.equal(ordersResponse);
- });
- it('throws an error for invalid JSON response', async () => {
- fetchMock.get(url, { test: 'dummy' });
- expect(relayerClient.getOrdersAsync()).to.be.rejected();
- });
- });
- describe('#getOrderAsync', () => {
- const orderHash = '0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f';
- const url = `${relayUrl}/order/${orderHash}`;
- it('gets order', async () => {
- fetchMock.get(url, orderResponseJSON);
- const order = await relayerClient.getOrderAsync(orderHash);
- expect(order).to.be.deep.equal(orderResponse);
- });
- it('throws an error for invalid JSON response', async () => {
- fetchMock.get(url, { test: 'dummy' });
- expect(relayerClient.getOrderAsync(orderHash)).to.be.rejected();
- });
- });
- describe('#getOrderBookAsync', () => {
- const request = {
- baseAssetData: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
- quoteAssetData: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
- };
- const url = `${relayUrl}/orderbook`;
- it('gets orderbook with default page options when none are provided', async () => {
- const urlWithQuery = `${url}?baseAssetData=${request.baseAssetData}&quoteAssetData=${
- request.quoteAssetData
- }`;
- fetchMock.get(urlWithQuery, orderbookJSON);
- const orderbook = await relayerClient.getOrderbookAsync(request);
- expect(orderbook).to.be.deep.equal(orderbookResponse);
- });
- it('gets orderbook with specified page options', async () => {
- const urlWithQuery = `${url}?baseAssetData=${
- request.baseAssetData
- }&networkId=42&page=3&perPage=50&quoteAssetData=${request.quoteAssetData}`;
- fetchMock.get(urlWithQuery, orderbookJSON);
- const pagedRequestOptions = {
- page: 3,
- perPage: 50,
- networkId: 42,
- };
- const orderbook = await relayerClient.getOrderbookAsync(request, pagedRequestOptions);
- expect(orderbook).to.be.deep.equal(orderbookResponse);
- });
- it('throws an error for invalid JSON response', async () => {
- fetchMock.get(url, { test: 'dummy' });
- expect(relayerClient.getOrderbookAsync(request)).to.be.rejected();
- });
- });
- describe('#getOrderConfigAsync', () => {
- const request = {
- makerAddress: '0x9e56625509c2f60af937f23b7b532600390e8c8b',
- takerAddress: '0xa2b31dacf30a9c50ca473337c01d8a201ae33e32',
- makerAssetAmount: new BigNumber('10000000000000000'),
- takerAssetAmount: new BigNumber('20000000000000000'),
- expirationTimeSeconds: new BigNumber('1532560590'),
- makerAssetData: '0xf47261b04c32345ced77393b3530b1eed0f346429d',
- takerAssetData: '0x0257179264389b814a946f3e92105513705ca6b990',
- exchangeAddress: '0x12459c951127e0c374ff9105dda097662a027093',
- };
- const url = `${relayUrl}/order_config`;
- it('gets order config', async () => {
- fetchMock.post(url, orderConfigResponseJSON);
- const fees = await relayerClient.getOrderConfigAsync(request);
- expect(fees).to.be.deep.equal(orderConfigResponse);
- });
- it('does not mutate input', async () => {
- fetchMock.post(url, orderConfigResponseJSON);
- const makerAssetAmountBefore = request.makerAssetAmount;
- const takerAssetAmountBefore = request.takerAssetAmount;
- const expirationTimeSecondsBefore = request.expirationTimeSeconds;
- await relayerClient.getOrderConfigAsync(request);
- expect(makerAssetAmountBefore).to.be.deep.equal(request.makerAssetAmount);
- expect(takerAssetAmountBefore).to.be.deep.equal(request.takerAssetAmount);
- expect(expirationTimeSecondsBefore).to.be.deep.equal(request.expirationTimeSeconds);
- });
- it('throws an error for invalid JSON response', async () => {
- fetchMock.post(url, { test: 'dummy' });
- expect(relayerClient.getOrderConfigAsync(request)).to.be.rejected();
- });
- });
- describe('#getFeeRecipientsAsync', () => {
- const url = `${relayUrl}/fee_recipients`;
- it('gets fee recipients with default page options when none are provided', async () => {
- fetchMock.get(url, feeRecipientsResponseJSON);
- const feeRecipients = await relayerClient.getFeeRecipientsAsync();
- expect(feeRecipients).to.be.deep.equal(feeRecipientsResponse);
- });
- it('gets fee recipient with specified page options', async () => {
- const urlWithQuery = `${url}?networkId=42&page=3&perPage=50`;
- fetchMock.get(urlWithQuery, feeRecipientsResponseJSON);
- const pagedRequestOptions = {
- page: 3,
- perPage: 50,
- networkId: 42,
- };
- const feeRecipients = await relayerClient.getFeeRecipientsAsync(pagedRequestOptions);
- expect(feeRecipients).to.be.deep.equal(feeRecipientsResponse);
- });
- it('throws an error for invalid JSON response', async () => {
- fetchMock.get(url, { test: 'dummy' });
- expect(relayerClient.getFeeRecipientsAsync()).to.be.rejected();
- });
- });
-});
diff --git a/packages/connect/test/orders_channel_factory_test.ts b/packages/connect/test/orders_channel_factory_test.ts
deleted file mode 100644
index 29aa87c65..000000000
--- a/packages/connect/test/orders_channel_factory_test.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import * as chai from 'chai';
-import * as dirtyChai from 'dirty-chai';
-import * as _ from 'lodash';
-
-import 'mocha';
-
-import { ordersChannelFactory } from '../src/orders_channel_factory';
-
-chai.config.includeStack = true;
-chai.use(dirtyChai);
-const expect = chai.expect;
-const emptyOrdersChannelHandler = {
- onUpdate: _.noop.bind(_),
- onError: _.noop.bind(_),
- onClose: _.noop.bind(_),
-};
-
-describe('ordersChannelFactory', () => {
- const websocketUrl = 'ws://localhost:8080';
- describe('#createWebSocketOrdersChannelAsync', () => {
- it('throws when input is not a url', () => {
- const badUrlInput = 54;
- expect(
- ordersChannelFactory.createWebSocketOrdersChannelAsync(badUrlInput as any, emptyOrdersChannelHandler),
- ).to.be.rejected();
- });
- it('throws when handler has the incorrect members', () => {
- const badHandlerInput = {};
- expect(
- ordersChannelFactory.createWebSocketOrdersChannelAsync(websocketUrl, badHandlerInput as any),
- ).to.be.rejected();
- });
- });
-});
diff --git a/packages/connect/test/orders_channel_message_parsers_test.ts b/packages/connect/test/orders_channel_message_parsers_test.ts
deleted file mode 100644
index 4d4a2d23f..000000000
--- a/packages/connect/test/orders_channel_message_parsers_test.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import * as chai from 'chai';
-import * as dirtyChai from 'dirty-chai';
-import 'mocha';
-
-import { ordersChannelMessageParser } from '../src/utils/orders_channel_message_parser';
-
-import { orderResponse } from './fixtures/standard_relayer_api/order/0xabc67323774bdbd24d94f977fa9ac94a50f016026fd13f42990861238897721f';
-import { unknownOrdersChannelMessage } from './fixtures/standard_relayer_api/unknown_orders_channel_message';
-import {
- malformedUpdateOrdersChannelMessage,
- updateOrdersChannelMessage,
-} from './fixtures/standard_relayer_api/update_orders_channel_message';
-
-chai.config.includeStack = true;
-chai.use(dirtyChai);
-const expect = chai.expect;
-
-describe('ordersChannelMessageParser', () => {
- describe('#parser', () => {
- it('parses update messages', () => {
- const updateMessage = ordersChannelMessageParser.parse(updateOrdersChannelMessage);
- expect(updateMessage.type).to.be.equal('update');
- expect(updateMessage.payload).to.be.deep.equal([orderResponse]);
- });
- it('returns unknown message for messages with unsupported types', () => {
- const unknownMessage = ordersChannelMessageParser.parse(unknownOrdersChannelMessage);
- expect(unknownMessage.type).to.be.equal('unknown');
- expect(unknownMessage.payload).to.be.undefined();
- });
- it('throws when message does not include a type', () => {
- const typelessMessage = `{
- "channel": "orders",
- "requestId": "4d8efcee-adde-4475-9601-f0b30962ca2b",
- "payload": []
- }`;
- const badCall = () => ordersChannelMessageParser.parse(typelessMessage);
- expect(badCall).throws(`Message is missing a type parameter: ${typelessMessage}`);
- });
- it('throws when type is not a string', () => {
- const messageWithBadType = `{
- "type": 1,
- "channel": "orders",
- "requestId": "4d8efcee-adde-4475-9601-f0b30962ca2b",
- "payload": []
- }`;
- const badCall = () => ordersChannelMessageParser.parse(messageWithBadType);
- expect(badCall).throws('Expected type to be of type string, encountered: 1');
- });
- it('throws when update message has malformed payload', () => {
- const badCall = () => ordersChannelMessageParser.parse(malformedUpdateOrdersChannelMessage);
- expect(badCall).throws(/^Expected message to conform to schema/);
- });
- it('throws when input message is not valid JSON', () => {
- const nonJsonString = 'h93b{sdfs9fsd f';
- const badCall = () => ordersChannelMessageParser.parse(nonJsonString);
- expect(badCall).throws('Unexpected token h in JSON at position 0');
- });
- });
-});
diff --git a/packages/connect/test/ws_orders_channel_test.ts b/packages/connect/test/ws_orders_channel_test.ts
deleted file mode 100644
index df30bc41d..000000000
--- a/packages/connect/test/ws_orders_channel_test.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import * as chai from 'chai';
-import * as dirtyChai from 'dirty-chai';
-import * as _ from 'lodash';
-import 'mocha';
-import * as Sinon from 'sinon';
-import * as WebSocket from 'websocket';
-
-import { WebSocketOrdersChannel } from '../src/ws_orders_channel';
-
-chai.config.includeStack = true;
-chai.use(dirtyChai);
-const expect = chai.expect;
-const emptyOrdersChannelHandler = {
- onUpdate: _.noop.bind(_),
- onError: _.noop.bind(_),
- onClose: _.noop.bind(_),
-};
-
-describe('WebSocketOrdersChannel', () => {
- const websocketUrl = 'ws://localhost:8080';
- const openClient = new WebSocket.w3cwebsocket(websocketUrl);
- Sinon.stub(openClient, 'readyState').get(() => WebSocket.w3cwebsocket.OPEN);
- Sinon.stub(openClient, 'send').callsFake(_.noop.bind(_));
- const openOrdersChannel = new WebSocketOrdersChannel(openClient, emptyOrdersChannelHandler);
- const subscriptionOpts = {
- baseAssetData: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
- quoteAssetData: '0xef7fff64389b814a946f3e92105513705ca6b990',
- limit: 100,
- };
- describe('#subscribe', () => {
- it('throws when subscriptionOpts does not conform to schema', () => {
- const badSubscribeCall = openOrdersChannel.subscribe.bind(openOrdersChannel, {
- makerAssetData: 5,
- });
- expect(badSubscribeCall).throws();
- });
- it('does not throw when inputs are of correct types', () => {
- const goodSubscribeCall = openOrdersChannel.subscribe.bind(openOrdersChannel, subscriptionOpts);
- expect(goodSubscribeCall).to.not.throw();
- });
- it('throws when client is closed', () => {
- const closedClient = new WebSocket.w3cwebsocket(websocketUrl);
- Sinon.stub(closedClient, 'readyState').get(() => WebSocket.w3cwebsocket.CLOSED);
- const closedOrdersChannel = new WebSocketOrdersChannel(closedClient, emptyOrdersChannelHandler);
- const badSubscribeCall = closedOrdersChannel.subscribe.bind(closedOrdersChannel, subscriptionOpts);
- expect(badSubscribeCall).throws('WebSocket connection is closed');
- });
- });
-});
diff --git a/packages/connect/tsconfig.json b/packages/connect/tsconfig.json
deleted file mode 100644
index 2ee711adc..000000000
--- a/packages/connect/tsconfig.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "extends": "../../tsconfig",
- "compilerOptions": {
- "outDir": "lib",
- "rootDir": "."
- },
- "include": ["./src/**/*", "./test/**/*"]
-}
diff --git a/packages/connect/tslint.json b/packages/connect/tslint.json
deleted file mode 100644
index dd9053357..000000000
--- a/packages/connect/tslint.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "extends": ["@0x/tslint-config"]
-}
diff --git a/packages/connect/typedoc-tsconfig.json b/packages/connect/typedoc-tsconfig.json
deleted file mode 100644
index c9b0af1ae..000000000
--- a/packages/connect/typedoc-tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extends": "../../typedoc-tsconfig",
- "compilerOptions": {
- "outDir": "lib"
- },
- "include": ["./src/**/*", "./test/**/*"]
-}