diff options
Diffstat (limited to 'packages/json-schemas')
59 files changed, 0 insertions, 2405 deletions
diff --git a/packages/json-schemas/.npmignore b/packages/json-schemas/.npmignore deleted file mode 100644 index 5333847e7..000000000 --- a/packages/json-schemas/.npmignore +++ /dev/null @@ -1,8 +0,0 @@ -.* -yarn-error.log -/src/ -/scripts/ -/schemas/ -test/ -tsconfig.json -/lib/src/monorepo_scripts/ diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json deleted file mode 100644 index 66de84299..000000000 --- a/packages/json-schemas/CHANGELOG.json +++ /dev/null @@ -1,381 +0,0 @@ -[ - { - "version": "3.0.0", - "changes": [ - { - "note": "Upgrade the bignumber.js to v8.0.2", - "pr": 1517 - } - ] - }, - { - "timestamp": 1547561734, - "version": "2.1.7", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1547225310, - "version": "2.1.6", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1547040760, - "version": "2.1.5", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "version": "2.1.4", - "changes": [ - { - "note": "Dependencies updated" - } - ], - "timestamp": 1544739608 - }, - { - "version": "2.1.3", - "changes": [ - { - "note": "Dependencies updated" - } - ], - "timestamp": 1544570656 - }, - { - "timestamp": 1542821676, - "version": "2.1.2", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1542208198, - "version": "2.1.1", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "version": "2.1.0", - "changes": [ - { - "note": "Improve schemas by enforcing that amounts that must be whole numbers (e.g Order asset amounts) no longer allow decimal amounts", - "pr": 1173 - }, - { - "note": "Add schemas from @0x/connect", - "pr": 1250 - } - ], - "timestamp": 1542028948 - }, - { - "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": 1539871071 - }, - { - "timestamp": 1538693146, - "version": "1.0.7", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1538475601, - "version": "1.0.6", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1538157789, - "version": "1.0.5", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1537907159, - "version": "1.0.4", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1537875740, - "version": "1.0.3", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1537541580, - "version": "1.0.2", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1536142250, - "version": "1.0.1", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "version": "1.0.1-rc.6", - "changes": [ - { - "note": "Dependencies updated" - } - ], - "timestamp": 1535377027 - }, - { - "version": "1.0.1-rc.5", - "changes": [ - { - "note": "Update incorrect relayer api fee recipients response schema", - "pr": 974 - } - ], - "timestamp": 1535133899 - }, - { - "version": "1.0.1-rc.4", - "changes": [ - { - "note": "Allow for additional properties in txData schema", - "pr": 938 - }, - { - "note": "Change hexSchema to match `0x`", - "pr": 937 - }, - { - "note": "Upgrade Relayer API schemas for relayer API V2", - "pr": 916 - } - ], - "timestamp": 1534210131 - }, - { - "version": "1.0.1-rc.3", - "changes": [ - { - "note": "Dependencies updated" - } - ], - "timestamp": 1532619515 - }, - { - "version": "1.0.1-rc.2", - "changes": [ - { - "note": "Dependencies updated" - } - ], - "timestamp": 1532614997 - }, - { - "version": "1.0.1-rc.1", - "changes": [ - { - "note": "Dependencies updated" - } - ], - "timestamp": 1532605697 - }, - { - "timestamp": 1532357734, - "version": "1.0.0", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1532043000, - "version": "1.0.0-rc.1", - "changes": [ - { - "note": "Update schemas for V2 or 0x Protocol", - "pr": 615 - }, - { - "note": "Added CallData schema", - "pr": 821 - }, - { - "note": "Update CallData schema id to CallData", - "pr": 894 - } - ] - }, - { - "timestamp": 1531919263, - "version": "0.8.3", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1531149657, - "version": "0.8.2", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1529397769, - "version": "0.8.1", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "version": "0.8.0", - "changes": [ - { - "note": "Update Order & SignedOrder schemas, remove ECSignature schema and add Hex schema as part of V2 upgrades", - "pr": 615 - } - ], - "timestamp": 1527008794 - }, - { - "timestamp": 1527008794, - "version": "0.7.24", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1525477860, - "version": "0.7.23", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1525428773, - "version": "0.7.22", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1524044013, - "version": "0.7.21", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1523462196, - "version": "0.7.20", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1522673609, - "version": "0.7.19", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "timestamp": 1522658513, - "version": "0.7.18", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, - { - "version": "0.7.13", - "changes": [ - { - "note": " Fix publishing issue where .npmignore was not properly excluding undesired content", - "pr": 389 - } - ], - "timestamp": 1518102000 - }, - { - "version": "0.7.0", - "changes": [ - { - "note": "Rename `subscriptionOptsSchema` to `blockRangeSchema`", - "pr": 272 - } - ], - "timestamp": 1513695600 - }, - { - "version": "0.6.7", - "changes": [ - { - "note": "Re-publish JSON-schema previously published under NPM package 0x-json-schemas" - } - ], - "timestamp": 1510585200 - } -] diff --git a/packages/json-schemas/CHANGELOG.md b/packages/json-schemas/CHANGELOG.md deleted file mode 100644 index 4e562d9e8..000000000 --- a/packages/json-schemas/CHANGELOG.md +++ /dev/null @@ -1,163 +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 - -## v2.1.7 - _January 15, 2019_ - - * Dependencies updated - -## v2.1.6 - _January 11, 2019_ - - * Dependencies updated - -## v2.1.5 - _January 9, 2019_ - - * Dependencies updated - -## v2.1.4 - _December 13, 2018_ - - * Dependencies updated - -## v2.1.3 - _December 11, 2018_ - - * Dependencies updated - -## v2.1.2 - _November 21, 2018_ - - * Dependencies updated - -## v2.1.1 - _November 14, 2018_ - - * Dependencies updated - -## v2.1.0 - _November 12, 2018_ - - * Improve schemas by enforcing that amounts that must be whole numbers (e.g Order asset amounts) no longer allow decimal amounts (#1173) - * Add schemas from @0x/connect (#1250) - -## v2.0.0 - _October 18, 2018_ - - * Convert all schemas to JSON files so that they can be used with `json-schema` implemenations in other programming languages. (#1145) - -## v1.0.7 - _October 4, 2018_ - - * Dependencies updated - -## v1.0.6 - _October 2, 2018_ - - * Dependencies updated - -## v1.0.5 - _September 28, 2018_ - - * Dependencies updated - -## v1.0.4 - _September 25, 2018_ - - * Dependencies updated - -## v1.0.3 - _September 25, 2018_ - - * Dependencies updated - -## v1.0.2 - _September 21, 2018_ - - * Dependencies updated - -## v1.0.1 - _September 5, 2018_ - - * Dependencies updated - -## v1.0.1-rc.6 - _August 27, 2018_ - - * Dependencies updated - -## v1.0.1-rc.5 - _August 24, 2018_ - - * Update incorrect relayer api fee recipients response schema (#974) - -## v1.0.1-rc.4 - _August 14, 2018_ - - * Allow for additional properties in txData schema (#938) - * Change hexSchema to match `0x` (#937) - * Upgrade Relayer API schemas for relayer API V2 (#916) - -## v1.0.1-rc.3 - _July 26, 2018_ - - * Dependencies updated - -## v1.0.1-rc.2 - _July 26, 2018_ - - * Dependencies updated - -## v1.0.1-rc.1 - _July 26, 2018_ - - * Dependencies updated - -## v1.0.0 - _July 23, 2018_ - - * Dependencies updated - -## v1.0.0-rc.1 - _July 19, 2018_ - - * Update schemas for V2 or 0x Protocol (#615) - * Added CallData schema (#821) - * Update CallData schema id to CallData (#894) - -## v0.8.3 - _July 18, 2018_ - - * Dependencies updated - -## v0.8.2 - _July 9, 2018_ - - * Dependencies updated - -## v0.8.1 - _June 19, 2018_ - - * Dependencies updated - -## v0.8.0 - _May 22, 2018_ - - * Update Order & SignedOrder schemas, remove ECSignature schema and add Hex schema as part of V2 upgrades (#615) - -## v0.7.24 - _May 22, 2018_ - - * Dependencies updated - -## v0.7.23 - _May 4, 2018_ - - * Dependencies updated - -## v0.7.22 - _May 4, 2018_ - - * Dependencies updated - -## v0.7.21 - _April 18, 2018_ - - * Dependencies updated - -## v0.7.20 - _April 11, 2018_ - - * Dependencies updated - -## v0.7.19 - _April 2, 2018_ - - * Dependencies updated - -## v0.7.18 - _April 2, 2018_ - - * Dependencies updated - -## v0.7.13 - _February 8, 2018_ - - * Fix publishing issue where .npmignore was not properly excluding undesired content (#389) - -## v0.7.0 - _December 19, 2017_ - - * Rename `subscriptionOptsSchema` to `blockRangeSchema` (#272) - -## v0.6.7 - _November 13, 2017_ - - * Re-publish JSON-schema previously published under NPM package 0x-json-schemas diff --git a/packages/json-schemas/README.md b/packages/json-schemas/README.md deleted file mode 100644 index f50382f4b..000000000 --- a/packages/json-schemas/README.md +++ /dev/null @@ -1,83 +0,0 @@ -## @0x/json-schemas - -Contains 0x-related json schemas - -### Read the [Documentation](https://0xproject.com/docs/json-schemas). - -## Installation - -```bash -yarn add @0x/json-schemas -``` - -**Import** - -```typescript -import { SchemaValidator, ValidatorResult, schemas } from '@0x/json-schemas'; -``` - -or - -```javascript -var schemas = require('@0x/json-schemas').schemas; -``` - -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"], -} -``` - -## 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/json-schemas yarn build -``` - -Or continuously rebuild on change: - -```bash -PKG=@0x/json-schemas yarn watch -``` - -### Clean - -```bash -yarn clean -``` - -### Lint - -```bash -yarn lint -``` - -### Run Tests - -```bash -yarn test -``` diff --git a/packages/json-schemas/coverage/.gitkeep b/packages/json-schemas/coverage/.gitkeep deleted file mode 100644 index e69de29bb..000000000 --- a/packages/json-schemas/coverage/.gitkeep +++ /dev/null diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json deleted file mode 100644 index cd515a747..000000000 --- a/packages/json-schemas/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@0x/json-schemas", - "version": "2.1.7", - "engines": { - "node": ">=6.12" - }, - "description": "0x-related json schemas", - "main": "lib/src/index.js", - "types": "lib/src/index.d.ts", - "scripts": { - "build": "tsc -b", - "build:ci": "yarn build", - "lint": "tslint --format stylish --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", - "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 generated_docs", - "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES" - }, - "config": { - "postpublish": { - "assets": [], - "docOmitExports": [ - "schemas" - ] - } - }, - "repository": { - "type": "git", - "url": "https://github.com/0xProject/0x-monorepo.git" - }, - "author": "", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/0xProject/0x-monorepo/issues" - }, - "homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md", - "dependencies": { - "@0x/typescript-typings": "^3.0.8", - "@types/node": "*", - "jsonschema": "^1.2.0", - "lodash.values": "^4.3.0" - }, - "devDependencies": { - "@0x/tslint-config": "^2.0.2", - "@0x/utils": "^3.0.1", - "@types/lodash.foreach": "^4.5.3", - "@types/lodash.values": "^4.3.3", - "@types/mocha": "^2.2.42", - "chai": "^4.0.1", - "dirty-chai": "^2.0.1", - "lodash.foreach": "^4.5.0", - "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/json-schemas/schemas/address_schema.json b/packages/json-schemas/schemas/address_schema.json deleted file mode 100644 index 0dc02d331..000000000 --- a/packages/json-schemas/schemas/address_schema.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "id": "/addressSchema", - "type": "string", - "pattern": "^0x[0-9a-f]{40}$" -} diff --git a/packages/json-schemas/schemas/asset_pairs_request_opts_schema.json b/packages/json-schemas/schemas/asset_pairs_request_opts_schema.json deleted file mode 100644 index fad0bd371..000000000 --- a/packages/json-schemas/schemas/asset_pairs_request_opts_schema.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "/AssetPairsRequestOptsSchema", - "type": "object", - "properties": { - "assetDataA": { "$ref": "/hexSchema" }, - "assetDataB": { "$ref": "/hexSchema" } - } -} diff --git a/packages/json-schemas/schemas/block_param_schema.json b/packages/json-schemas/schemas/block_param_schema.json deleted file mode 100644 index ed4dd1e87..000000000 --- a/packages/json-schemas/schemas/block_param_schema.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "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 deleted file mode 100644 index b14294649..000000000 --- a/packages/json-schemas/schemas/block_range_schema.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "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 deleted file mode 100644 index e5e6e3282..000000000 --- a/packages/json-schemas/schemas/call_data_schema.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "id": "/callDataSchema", - "properties": { - "from": { "$ref": "/addressSchema" }, - "to": { "$ref": "/addressSchema" }, - "value": { - "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumberSchema" }] - }, - "gas": { - "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumberSchema" }] - }, - "gasPrice": { - "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumberSchema" }] - }, - "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 deleted file mode 100644 index 0c08ec240..000000000 --- a/packages/json-schemas/schemas/ec_signature_parameter_schema.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "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 deleted file mode 100644 index 52ccfe7bb..000000000 --- a/packages/json-schemas/schemas/ec_signature_schema.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "id": "/ecSignatureSchema", - "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_schema.json b/packages/json-schemas/schemas/eip712_typed_data_schema.json deleted file mode 100644 index 8efd6de44..000000000 --- a/packages/json-schemas/schemas/eip712_typed_data_schema.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "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 deleted file mode 100644 index f37815d5b..000000000 --- a/packages/json-schemas/schemas/hex_schema.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "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 deleted file mode 100644 index bec00d79e..000000000 --- a/packages/json-schemas/schemas/index_filter_values_schema.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "/indexFilterValuesSchema", - "additionalProperties": { - "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/addressSchema" }, { "$ref": "/orderHashSchema" }] - }, - "type": "object" -} diff --git a/packages/json-schemas/schemas/js_number_schema.json b/packages/json-schemas/schemas/js_number_schema.json deleted file mode 100644 index 7df1c4747..000000000 --- a/packages/json-schemas/schemas/js_number_schema.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "id": "/jsNumberSchema", - "type": "number", - "minimum": 0 -} diff --git a/packages/json-schemas/schemas/number_schema.json b/packages/json-schemas/schemas/number_schema.json deleted file mode 100644 index a48f3e8cf..000000000 --- a/packages/json-schemas/schemas/number_schema.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "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 deleted file mode 100644 index 8d0999941..000000000 --- a/packages/json-schemas/schemas/order_cancel_schema.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "id": "/orderCancellationRequestsSchema", - "type": "array", - "items": { - "properties": { - "order": { "$ref": "/orderSchema" }, - "takerTokenCancelAmount": { "$ref": "/wholeNumberSchema" } - }, - "required": ["order", "takerTokenCancelAmount"], - "type": "object" - } -} diff --git a/packages/json-schemas/schemas/order_config_request_schema.json b/packages/json-schemas/schemas/order_config_request_schema.json deleted file mode 100644 index 19b043e7f..000000000 --- a/packages/json-schemas/schemas/order_config_request_schema.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "id": "/OrderConfigRequestSchema", - "type": "object", - "properties": { - "makerAddress": { "$ref": "/addressSchema" }, - "takerAddress": { "$ref": "/addressSchema" }, - "makerAssetAmount": { "$ref": "/wholeNumberSchema" }, - "takerAssetAmount": { "$ref": "/wholeNumberSchema" }, - "makerAssetData": { "$ref": "/hexSchema" }, - "takerAssetData": { "$ref": "/hexSchema" }, - "exchangeAddress": { "$ref": "/addressSchema" }, - "expirationTimeSeconds": { "$ref": "/wholeNumberSchema" } - }, - "required": [ - "makerAddress", - "takerAddress", - "makerAssetAmount", - "takerAssetAmount", - "makerAssetData", - "takerAssetData", - "exchangeAddress", - "expirationTimeSeconds" - ] -} 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 deleted file mode 100644 index 73bbf20bb..000000000 --- a/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "id": "/orderFillOrKillRequestsSchema", - "type": "array", - "items": { - "properties": { - "signedOrder": { "$ref": "/signedOrderSchema" }, - "fillTakerAmount": { "$ref": "/wholeNumberSchema" } - }, - "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 deleted file mode 100644 index d06fb19a2..000000000 --- a/packages/json-schemas/schemas/order_fill_requests_schema.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "id": "/orderFillRequestsSchema", - "type": "array", - "items": { - "properties": { - "signedOrder": { "$ref": "/signedOrderSchema" }, - "takerTokenFillAmount": { "$ref": "/wholeNumberSchema" } - }, - "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 deleted file mode 100644 index 4a770579f..000000000 --- a/packages/json-schemas/schemas/order_hash_schema.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "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 deleted file mode 100644 index c70b9e2dd..000000000 --- a/packages/json-schemas/schemas/order_schema.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "id": "/orderSchema", - "properties": { - "makerAddress": { "$ref": "/addressSchema" }, - "takerAddress": { "$ref": "/addressSchema" }, - "makerFee": { "$ref": "/wholeNumberSchema" }, - "takerFee": { "$ref": "/wholeNumberSchema" }, - "senderAddress": { "$ref": "/addressSchema" }, - "makerAssetAmount": { "$ref": "/wholeNumberSchema" }, - "takerAssetAmount": { "$ref": "/wholeNumberSchema" }, - "makerAssetData": { "$ref": "/hexSchema" }, - "takerAssetData": { "$ref": "/hexSchema" }, - "salt": { "$ref": "/wholeNumberSchema" }, - "exchangeAddress": { "$ref": "/addressSchema" }, - "feeRecipientAddress": { "$ref": "/addressSchema" }, - "expirationTimeSeconds": { "$ref": "/wholeNumberSchema" } - }, - "required": [ - "makerAddress", - "takerAddress", - "makerFee", - "takerFee", - "senderAddress", - "makerAssetAmount", - "takerAssetAmount", - "makerAssetData", - "takerAssetData", - "salt", - "exchangeAddress", - "feeRecipientAddress", - "expirationTimeSeconds" - ], - "type": "object" -} diff --git a/packages/json-schemas/schemas/order_watcher_web_socket_request_schema.json b/packages/json-schemas/schemas/order_watcher_web_socket_request_schema.json deleted file mode 100644 index b0c419f94..000000000 --- a/packages/json-schemas/schemas/order_watcher_web_socket_request_schema.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "id": "/orderWatcherWebSocketRequestSchema", - "type": "object", - "definitions": { - "signedOrderParam": { - "type": "object", - "properties": { - "signedOrder": { "$ref": "/signedOrderSchema" } - }, - "required": ["signedOrder"] - }, - "orderHashParam": { - "type": "object", - "properties": { - "orderHash": { "$ref": "/hexSchema" } - }, - "required": ["orderHash"] - } - }, - "oneOf": [ - { - "type": "object", - "properties": { - "id": { "type": "number" }, - "jsonrpc": { "type": "string" }, - "method": { "enum": ["ADD_ORDER"] }, - "params": { "$ref": "#/definitions/signedOrderParam" } - }, - "required": ["id", "jsonrpc", "method", "params"] - }, - { - "type": "object", - "properties": { - "id": { "type": "number" }, - "jsonrpc": { "type": "string" }, - "method": { "enum": ["REMOVE_ORDER"] }, - "params": { "$ref": "#/definitions/orderHashParam" } - }, - "required": ["id", "jsonrpc", "method", "params"] - }, - { - "type": "object", - "properties": { - "id": { "type": "number" }, - "jsonrpc": { "type": "string" }, - "method": { "enum": ["GET_STATS"] }, - "params": {} - }, - "required": ["id", "jsonrpc", "method"] - } - ] -}
\ No newline at end of file diff --git a/packages/json-schemas/schemas/order_watcher_web_socket_utf8_message_schema.json b/packages/json-schemas/schemas/order_watcher_web_socket_utf8_message_schema.json deleted file mode 100644 index 154d6d754..000000000 --- a/packages/json-schemas/schemas/order_watcher_web_socket_utf8_message_schema.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "id": "/orderWatcherWebSocketUtf8MessageSchema", - "properties": { - "utf8Data": { "type": "string" } - }, - "required": [ - "utf8Data" - ], - "type": "object" -} diff --git a/packages/json-schemas/schemas/orderbook_request_schema.json b/packages/json-schemas/schemas/orderbook_request_schema.json deleted file mode 100644 index 5ce6e8ab0..000000000 --- a/packages/json-schemas/schemas/orderbook_request_schema.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "id": "/OrderbookRequestSchema", - "type": "object", - "properties": { - "baseAssetData": { "$ref": "/hexSchema" }, - "quoteAssetData": { "$ref": "/hexSchema" } - }, - "required": ["baseAssetData", "quoteAssetData"] -} diff --git a/packages/json-schemas/schemas/orders_request_opts_schema.json b/packages/json-schemas/schemas/orders_request_opts_schema.json deleted file mode 100644 index 4c1b9b4e9..000000000 --- a/packages/json-schemas/schemas/orders_request_opts_schema.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "id": "/OrdersRequestOptsSchema", - "type": "object", - "properties": { - "makerAssetProxyId": { "$ref": "/hexSchema" }, - "takerAssetProxyId": { "$ref": "/hexSchema" }, - "makerAssetAddress": { "$ref": "/addressSchema" }, - "takerAssetAddress": { "$ref": "/addressSchema" }, - "exchangeAddress": { "$ref": "/addressSchema" }, - "senderAddress": { "$ref": "/addressSchema" }, - "makerAssetData": { "$ref": "/hexSchema" }, - "takerAssetData": { "$ref": "/hexSchema" }, - "traderAssetData": { "$ref": "/hexSchema" }, - "makerAddress": { "$ref": "/addressSchema" }, - "takerAddress": { "$ref": "/addressSchema" }, - "traderAddress": { "$ref": "/addressSchema" }, - "feeRecipientAddress": { "$ref": "/addressSchema" } - } -} diff --git a/packages/json-schemas/schemas/orders_schema.json b/packages/json-schemas/schemas/orders_schema.json deleted file mode 100644 index 1e1c6a875..000000000 --- a/packages/json-schemas/schemas/orders_schema.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "id": "/ordersSchema", - "type": "array", - "items": { "$ref": "/orderSchema" } -} diff --git a/packages/json-schemas/schemas/paged_request_opts_schema.json b/packages/json-schemas/schemas/paged_request_opts_schema.json deleted file mode 100644 index f143c28b0..000000000 --- a/packages/json-schemas/schemas/paged_request_opts_schema.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "id": "/PagedRequestOptsSchema", - "type": "object", - "properties": { - "page": { "type": "number" }, - "perPage": { "type": "number" } - } -} diff --git a/packages/json-schemas/schemas/paginated_collection_schema.json b/packages/json-schemas/schemas/paginated_collection_schema.json deleted file mode 100644 index 9dcedf5b4..000000000 --- a/packages/json-schemas/schemas/paginated_collection_schema.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "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 deleted file mode 100644 index d1150d3db..000000000 --- a/packages/json-schemas/schemas/relayer_api_asset_data_pairs_response_schema.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "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 deleted file mode 100644 index 62d4745b8..000000000 --- a/packages/json-schemas/schemas/relayer_api_asset_data_pairs_schema.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "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 deleted file mode 100644 index e0f274c5d..000000000 --- a/packages/json-schemas/schemas/relayer_api_asset_data_trade_info_schema.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "id": "/relayerApiAssetDataTradeInfoSchema", - "type": "object", - "properties": { - "assetData": { "$ref": "/hexSchema" }, - "minAmount": { "$ref": "/wholeNumberSchema" }, - "maxAmount": { "$ref": "/wholeNumberSchema" }, - "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 deleted file mode 100644 index be4659b0b..000000000 --- a/packages/json-schemas/schemas/relayer_api_error_response_schema.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "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 deleted file mode 100644 index c73506dbb..000000000 --- a/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "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 deleted file mode 100644 index f4583fc62..000000000 --- a/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "id": "/relayerApiOrderConfigPayloadSchema", - "type": "object", - "properties": { - "makerAddress": { "$ref": "/addressSchema" }, - "takerAddress": { "$ref": "/addressSchema" }, - "makerAssetAmount": { "$ref": "/wholeNumberSchema" }, - "takerAssetAmount": { "$ref": "/wholeNumberSchema" }, - "makerAssetData": { "$ref": "/hexSchema" }, - "takerAssetData": { "$ref": "/hexSchema" }, - "exchangeAddress": { "$ref": "/addressSchema" }, - "expirationTimeSeconds": { "$ref": "/wholeNumberSchema" } - }, - "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 deleted file mode 100644 index 8193861e1..000000000 --- a/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "id": "/relayerApiOrderConfigResponseSchema", - "type": "object", - "properties": { - "makerFee": { "$ref": "/wholeNumberSchema" }, - "takerFee": { "$ref": "/wholeNumberSchema" }, - "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 deleted file mode 100644 index e0f6539b9..000000000 --- a/packages/json-schemas/schemas/relayer_api_order_schema.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "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 deleted file mode 100644 index b44f2a740..000000000 --- a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "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 deleted file mode 100644 index 274ef1625..000000000 --- a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_payload_schema.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "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 deleted file mode 100644 index 29561d09f..000000000 --- a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "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_update_response_schema.json b/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.json deleted file mode 100644 index 239e7c586..000000000 --- a/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "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 deleted file mode 100644 index a5023a3fc..000000000 --- a/packages/json-schemas/schemas/relayer_api_orders_response_schema.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "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 deleted file mode 100644 index 84e75cd04..000000000 --- a/packages/json-schemas/schemas/relayer_api_orders_schema.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "id": "/relayerApiOrdersSchema", - "type": "array", - "items": { "$ref": "/relayerApiOrderSchema" } -} diff --git a/packages/json-schemas/schemas/request_opts_schema.json b/packages/json-schemas/schemas/request_opts_schema.json deleted file mode 100644 index 2206f5016..000000000 --- a/packages/json-schemas/schemas/request_opts_schema.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "id": "/RequestOptsSchema", - "type": "object", - "properties": { - "networkId": { "type": "number" } - } -} diff --git a/packages/json-schemas/schemas/signed_order_schema.json b/packages/json-schemas/schemas/signed_order_schema.json deleted file mode 100644 index 137ae4a24..000000000 --- a/packages/json-schemas/schemas/signed_order_schema.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "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 deleted file mode 100644 index e7c3a0b6c..000000000 --- a/packages/json-schemas/schemas/signed_orders_schema.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "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 deleted file mode 100644 index 31e41c4b8..000000000 --- a/packages/json-schemas/schemas/token_schema.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "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 deleted file mode 100644 index 8c3daba4e..000000000 --- a/packages/json-schemas/schemas/tx_data_schema.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "id": "/txDataSchema", - "properties": { - "from": { "$ref": "/addressSchema" }, - "to": { "$ref": "/addressSchema" }, - "value": { - "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumberSchema" }] - }, - "gas": { - "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumberSchema" }] - }, - "gasPrice": { - "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumberSchema" }] - }, - "data": { - "type": "string", - "pattern": "^0x[0-9a-f]*$" - }, - "nonce": { - "type": "number", - "minimum": 0 - } - }, - "required": ["from"], - "type": "object" -} diff --git a/packages/json-schemas/schemas/whole_number_schema.json b/packages/json-schemas/schemas/whole_number_schema.json deleted file mode 100644 index aa469954c..000000000 --- a/packages/json-schemas/schemas/whole_number_schema.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "id": "/wholeNumberSchema", - "anyOf": [ - { - "type": "string", - "pattern": "^\\d+$" - }, - { - "type": "integer" - } - ] -} diff --git a/packages/json-schemas/schemas/zero_ex_transaction_schema.json b/packages/json-schemas/schemas/zero_ex_transaction_schema.json deleted file mode 100644 index 0c714f14d..000000000 --- a/packages/json-schemas/schemas/zero_ex_transaction_schema.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "id": "/zeroExTransactionSchema", - "properties": { - "data": { "$ref": "/hexSchema" }, - "signerAddress": { "$ref": "/addressSchema" }, - "salt": { "$ref": "/wholeNumberSchema" } - }, - "required": ["data", "salt", "signerAddress"], - "type": "object" -} diff --git a/packages/json-schemas/src/index.ts b/packages/json-schemas/src/index.ts deleted file mode 100644 index 9d8470348..000000000 --- a/packages/json-schemas/src/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { ValidatorResult, Schema } from 'jsonschema'; - -export { SchemaValidator } from './schema_validator'; -export { schemas } from './schemas'; diff --git a/packages/json-schemas/src/schema_validator.ts b/packages/json-schemas/src/schema_validator.ts deleted file mode 100644 index 43647b594..000000000 --- a/packages/json-schemas/src/schema_validator.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Schema, Validator, ValidatorResult } from 'jsonschema'; -import values = require('lodash.values'); - -import { schemas } from './schemas'; - -/** - * A validator for [JSON-schemas](http://json-schema.org/) - */ -export class SchemaValidator { - private readonly _validator: Validator; - private static _assertSchemaDefined(schema: Schema): void { - if (schema === undefined) { - throw new Error(`Cannot add undefined schema`); - } - } - /** - * Instantiates a SchemaValidator instance - */ - constructor() { - this._validator = new Validator(); - for (const schema of values(schemas)) { - SchemaValidator._assertSchemaDefined(schema); - this._validator.addSchema(schema, schema.id); - } - } - /** - * Add a schema to the validator. All schemas and sub-schemas must be added to - * the validator before the `validate` and `isValid` methods can be called with - * instances of that schema. - * @param schema The schema to add - */ - public addSchema(schema: Schema): void { - SchemaValidator._assertSchemaDefined(schema); - this._validator.addSchema(schema, schema.id); - } - // In order to validate a complex JS object using jsonschema, we must replace any complex - // sub-types (e.g BigNumber) with a simpler string representation. Since BigNumber and other - // complex types implement the `toString` method, we can stringify the object and - // then parse it. The resultant object can then be checked using jsonschema. - /** - * Validate the JS object conforms to a specific JSON schema - * @param instance JS object in question - * @param schema Schema to check against - * @returns The results of the validation - */ - public validate(instance: any, schema: Schema): ValidatorResult { - SchemaValidator._assertSchemaDefined(schema); - const jsonSchemaCompatibleObject = JSON.parse(JSON.stringify(instance)); - return this._validator.validate(jsonSchemaCompatibleObject, schema); - } - /** - * Check whether an instance properly adheres to a JSON schema - * @param instance JS object in question - * @param schema Schema to check against - * @returns Whether or not the instance adheres to the schema - */ - public isValid(instance: any, schema: Schema): boolean { - const isValid = this.validate(instance, schema).errors.length === 0; - return isValid; - } -} diff --git a/packages/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts deleted file mode 100644 index 9e8eb6959..000000000 --- a/packages/json-schemas/src/schemas.ts +++ /dev/null @@ -1,95 +0,0 @@ -import * as addressSchema from '../schemas/address_schema.json'; -import * as assetPairsRequestOptsSchema from '../schemas/asset_pairs_request_opts_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_schema.json'; -import * as numberSchema from '../schemas/number_schema.json'; -import * as orderCancellationRequestsSchema from '../schemas/order_cancel_schema.json'; -import * as orderConfigRequestSchema from '../schemas/order_config_request_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 orderWatcherWebSocketRequestSchema from '../schemas/order_watcher_web_socket_request_schema.json'; -import * as orderWatcherWebSocketUtf8MessageSchema from '../schemas/order_watcher_web_socket_utf8_message_schema.json'; -import * as orderBookRequestSchema from '../schemas/orderbook_request_schema.json'; -import * as ordersRequestOptsSchema from '../schemas/orders_request_opts_schema.json'; -import * as ordersSchema from '../schemas/orders_schema.json'; -import * as pagedRequestOptsSchema from '../schemas/paged_request_opts_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 requestOptsSchema from '../schemas/request_opts_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 wholeNumberSchema from '../schemas/whole_number_schema.json'; -import * as zeroExTransactionSchema from '../schemas/zero_ex_transaction_schema.json'; - -export const schemas = { - numberSchema, - addressSchema, - callDataSchema, - hexSchema, - ecSignatureParameterSchema, - ecSignatureSchema, - eip712TypedDataSchema, - indexFilterValuesSchema, - orderCancellationRequestsSchema, - orderFillOrKillRequestsSchema, - orderFillRequestsSchema, - orderHashSchema, - orderSchema, - signedOrderSchema, - signedOrdersSchema, - ordersSchema, - blockParamSchema, - blockRangeSchema, - tokenSchema, - jsNumber, - requestOptsSchema, - pagedRequestOptsSchema, - orderWatcherWebSocketRequestSchema, - orderWatcherWebSocketUtf8MessageSchema, - ordersRequestOptsSchema, - orderBookRequestSchema, - orderConfigRequestSchema, - assetPairsRequestOptsSchema, - txDataSchema, - paginatedCollectionSchema, - relayerApiErrorResponseSchema, - relayerApiFeeRecipientsResponseSchema, - relayerApiOrderSchema, - relayerApiOrdersSchema, - relayerApiOrderConfigPayloadSchema, - relayerApiOrderConfigResponseSchema, - relayerApiOrderbookResponseSchema, - relayerApiAssetDataPairsResponseSchema, - relayerApiAssetDataTradeInfoSchema, - relayerApiOrdersChannelSubscribeSchema, - relayerApiOrdersChannelSubscribePayloadSchema, - relayerApiOrdersChannelUpdateSchema, - relayerApiOrdersResponseSchema, - relayerApiAssetDataPairsSchema, - zeroExTransactionSchema, - wholeNumberSchema, -}; diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts deleted file mode 100644 index bfa2c5668..000000000 --- a/packages/json-schemas/test/schema_test.ts +++ /dev/null @@ -1,872 +0,0 @@ -import { BigNumber } from '@0x/utils'; -import * as chai from 'chai'; -import * as dirtyChai from 'dirty-chai'; -import forEach = require('lodash.foreach'); -import 'mocha'; - -import { schemas, SchemaValidator } from '../src/index'; - -chai.config.includeStack = true; -chai.use(dirtyChai); -const expect = chai.expect; -const NULL_ADDRESS = '0x0000000000000000000000000000000000000000'; -const { - numberSchema, - addressSchema, - hexSchema, - orderCancellationRequestsSchema, - orderFillOrKillRequestsSchema, - orderFillRequestsSchema, - orderHashSchema, - orderSchema, - signedOrderSchema, - signedOrdersSchema, - blockParamSchema, - blockRangeSchema, - tokenSchema, - jsNumber, - txDataSchema, - paginatedCollectionSchema, - relayerApiErrorResponseSchema, - relayerApiOrderbookResponseSchema, - relayerApiAssetDataPairsResponseSchema, - relayerApiOrderConfigPayloadSchema, - relayerApiOrderConfigResponseSchema, - relayerApiOrdersChannelSubscribeSchema, - relayerApiOrdersChannelUpdateSchema, - relayerApiOrdersResponseSchema, - relayerApiOrderSchema, - wholeNumberSchema, -} = schemas; - -describe('Schema', () => { - const validator = new SchemaValidator(); - const validateAgainstSchema = (testCases: any[], schema: any, shouldFail = false) => { - forEach(testCases, (testCase: any) => { - const validationResult = validator.validate(testCase, schema); - const hasErrors = validationResult.errors.length !== 0; - if (shouldFail) { - if (!hasErrors) { - throw new Error( - `Expected testCase: ${JSON.stringify(testCase, null, '\t')} to fail and it didn't.`, - ); - } - } else { - if (hasErrors) { - throw new Error(JSON.stringify(validationResult.errors, null, '\t')); - } - } - }); - }; - const paginatedResponse = { - total: 100, - perPage: 10, - page: 3, - }; - describe('#numberSchema', () => { - it('should validate valid numbers', () => { - const testCases = ['42', '0', '1.3', '0.2', '00.00']; - validateAgainstSchema(testCases, numberSchema); - }); - it('should fail for invalid numbers', () => { - const testCases = ['.3', '1.', 'abacaba', 'и', '1..0']; - const shouldFail = true; - validateAgainstSchema(testCases, numberSchema, shouldFail); - }); - }); - describe('#wholeNumberSchema', () => { - it('should validate valid numbers', () => { - const testCases = ['5', '42', '0']; - validateAgainstSchema(testCases, wholeNumberSchema); - }); - it('should fail for invalid numbers', () => { - const testCases = ['1.3', '0.2', '00.00', '.3', '1.', 'abacaba', 'и', '1..0']; - const shouldFail = true; - validateAgainstSchema(testCases, wholeNumberSchema, shouldFail); - }); - }); - describe('#addressSchema', () => { - it('should validate valid addresses', () => { - const testCases = ['0x8b0292b11a196601ed2ce54b665cafeca0347d42', NULL_ADDRESS]; - validateAgainstSchema(testCases, addressSchema); - }); - it('should fail for invalid addresses', () => { - const testCases = [ - '0x', - '0', - '0x00', - '0xzzzzzzB11a196601eD2ce54B665CaFEca0347D42', - '0x8b0292B11a196601eD2ce54B665CaFEca0347D42', - ]; - const shouldFail = true; - validateAgainstSchema(testCases, addressSchema, shouldFail); - }); - }); - describe('#hexSchema', () => { - it('should validate valid hex string', () => { - const testCases = ['0x8b0292b11a196601ed2ce54b665cafeca0347d42', NULL_ADDRESS]; - validateAgainstSchema(testCases, hexSchema); - }); - it('should fail for invalid hex string', () => { - const testCases = ['0', '0xzzzzzzB11a196601eD2ce54B665CaFEca0347D42']; - const shouldFail = true; - validateAgainstSchema(testCases, hexSchema, shouldFail); - }); - }); - describe('#orderHashSchema', () => { - it('should validate valid order hash', () => { - const testCases = [ - '0x61a3ed31B43c8780e905a260a35faefEc527be7516aa11c0256729b5b351bc33', - '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', - ]; - validateAgainstSchema(testCases, orderHashSchema); - }); - it('should fail for invalid order hash', () => { - const testCases = [ - {}, - '0x', - '0x8b0292B11a196601eD2ce54B665CaFEca0347D42', - '61a3ed31B43c8780e905a260a35faefEc527be7516aa11c0256729b5b351bc33', - ]; - const shouldFail = true; - validateAgainstSchema(testCases, orderHashSchema, shouldFail); - }); - }); - describe('#blockParamSchema', () => { - it('should validate valid block param', () => { - const blockNumber = 42; - const testCases = [blockNumber, 'latest', 'pending', 'earliest']; - validateAgainstSchema(testCases, blockParamSchema); - }); - it('should fail for invalid block param', () => { - const testCases = [{}, '42', 'pemding']; - const shouldFail = true; - validateAgainstSchema(testCases, blockParamSchema, shouldFail); - }); - }); - describe('#blockRangeSchema', () => { - it('should validate valid subscription opts', () => { - const testCases = [{ fromBlock: 42, toBlock: 'latest' }, { fromBlock: 42 }, {}]; - validateAgainstSchema(testCases, blockRangeSchema); - }); - it('should fail for invalid subscription opts', () => { - const testCases = [{ fromBlock: '42' }]; - const shouldFail = true; - validateAgainstSchema(testCases, blockRangeSchema, shouldFail); - }); - }); - describe('#tokenSchema', () => { - const token = { - name: 'Zero Ex', - symbol: 'ZRX', - decimals: 100500, - address: '0x8b0292b11a196601ed2ce54b665cafeca0347d42', - url: 'https://0xproject.com', - }; - it('should validate valid token', () => { - const testCases = [token]; - validateAgainstSchema(testCases, tokenSchema); - }); - it('should fail for invalid token', () => { - const num = 4; - const testCases = [ - { - ...token, - address: null, - }, - { - ...token, - decimals: undefined, - }, - [], - num, - ]; - const shouldFail = true; - validateAgainstSchema(testCases, tokenSchema, shouldFail); - }); - }); - describe('#paginatedCollectionSchema', () => { - it('should validate valid paginated collections', () => { - const testCases = [paginatedResponse]; - validateAgainstSchema(testCases, paginatedCollectionSchema); - }); - it('should fail for invalid paginated collections', () => { - const paginatedCollectionNoTotal = { - page: 10, - perPage: 2, - }; - const paginatedCollectionNoPerPage = { - page: 10, - total: 100, - }; - const paginatedCollectionNoPage = { - total: 10, - perPage: 20, - }; - const testCases = [{}, paginatedCollectionNoPage, paginatedCollectionNoPerPage, paginatedCollectionNoTotal]; - const shouldFail = true; - validateAgainstSchema(testCases, paginatedCollectionSchema, shouldFail); - }); - }); - describe('order including schemas', () => { - const order = { - makerAddress: NULL_ADDRESS, - takerAddress: NULL_ADDRESS, - senderAddress: NULL_ADDRESS, - makerFee: '1', - takerFee: '2', - makerAssetAmount: '1', - takerAssetAmount: '2', - makerAssetData: NULL_ADDRESS, - takerAssetData: NULL_ADDRESS, - salt: '67006738228878699843088602623665307406148487219438534730168799356281242528500', - feeRecipientAddress: NULL_ADDRESS, - exchangeAddress: NULL_ADDRESS, - expirationTimeSeconds: '42', - }; - const relayerApiOrder = { - order, - metaData: { - someMetaData: 5, - }, - }; - const relayerApiOrdersResponse = { - ...paginatedResponse, - records: [relayerApiOrder, relayerApiOrder], - }; - describe('#orderSchema', () => { - it('should validate valid order', () => { - const testCases = [order]; - validateAgainstSchema(testCases, orderSchema); - }); - it('should fail for invalid order', () => { - const testCases = [ - { - ...order, - salt: undefined, - }, - { - ...order, - salt: 'salt', - }, - 'order', - ]; - const shouldFail = true; - validateAgainstSchema(testCases, orderSchema, shouldFail); - }); - }); - describe('signed order including schemas', () => { - const signedOrder = { - ...order, - signature: - '0x031b61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3340349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', - }; - describe('#signedOrdersSchema', () => { - it('should validate valid signed orders', () => { - const testCases = [[signedOrder], []]; - validateAgainstSchema(testCases, signedOrdersSchema); - }); - it('should fail for invalid signed orders', () => { - const testCases = [[signedOrder, 1]]; - const shouldFail = true; - validateAgainstSchema(testCases, signedOrdersSchema, shouldFail); - }); - }); - describe('#signedOrderSchema', () => { - it('should validate valid signed order', () => { - const testCases = [signedOrder]; - validateAgainstSchema(testCases, signedOrderSchema); - }); - it('should fail for invalid signed order', () => { - const testCases = [ - { - ...signedOrder, - signature: undefined, - }, - ]; - const shouldFail = true; - validateAgainstSchema(testCases, signedOrderSchema, shouldFail); - }); - }); - describe('#orderFillOrKillRequestsSchema', () => { - const orderFillOrKillRequests = [ - { - signedOrder, - fillTakerAmount: '5', - }, - ]; - it('should validate valid order fill or kill requests', () => { - const testCases = [orderFillOrKillRequests]; - validateAgainstSchema(testCases, orderFillOrKillRequestsSchema); - }); - it('should fail for invalid order fill or kill requests', () => { - const testCases = [ - [ - { - ...orderFillOrKillRequests[0], - fillTakerAmount: undefined, - }, - ], - ]; - const shouldFail = true; - validateAgainstSchema(testCases, orderFillOrKillRequestsSchema, shouldFail); - }); - }); - describe('#orderCancellationRequestsSchema', () => { - const orderCancellationRequests = [ - { - order, - takerTokenCancelAmount: '5', - }, - ]; - it('should validate valid order cancellation requests', () => { - const testCases = [orderCancellationRequests]; - validateAgainstSchema(testCases, orderCancellationRequestsSchema); - }); - it('should fail for invalid order cancellation requests', () => { - const testCases = [ - [ - { - ...orderCancellationRequests[0], - takerTokenCancelAmount: undefined, - }, - ], - ]; - const shouldFail = true; - validateAgainstSchema(testCases, orderCancellationRequestsSchema, shouldFail); - }); - }); - describe('#orderFillRequestsSchema', () => { - const orderFillRequests = [ - { - signedOrder, - takerTokenFillAmount: '5', - }, - ]; - it('should validate valid order fill requests', () => { - const testCases = [orderFillRequests]; - validateAgainstSchema(testCases, orderFillRequestsSchema); - }); - it('should fail for invalid order fill requests', () => { - const testCases = [ - [ - { - ...orderFillRequests[0], - takerTokenFillAmount: undefined, - }, - ], - ]; - const shouldFail = true; - validateAgainstSchema(testCases, orderFillRequestsSchema, shouldFail); - }); - }); - describe('standard relayer api schemas', () => { - describe('#relayerApiOrderSchema', () => { - it('should validate valid relayer api order', () => { - const testCases = [relayerApiOrder]; - validateAgainstSchema(testCases, relayerApiOrderSchema); - }); - it('should fail for invalid relayer api orders', () => { - const testCases = [{}, order, { order }, { order, metaData: 5 }]; - const shouldFail = true; - validateAgainstSchema(testCases, relayerApiOrderSchema, shouldFail); - }); - }); - describe('#relayerApiErrorResponseSchema', () => { - it('should validate valid errorResponse', () => { - const testCases = [ - { - code: 102, - reason: 'Order submission disabled', - }, - { - code: 101, - reason: 'Validation failed', - validationErrors: [ - { - field: 'maker', - code: 1002, - reason: 'Invalid address', - }, - ], - }, - ]; - validateAgainstSchema(testCases, relayerApiErrorResponseSchema); - }); - it('should fail for invalid error responses', () => { - const testCases = [ - {}, - { - code: 102, - }, - { - code: '102', - reason: 'Order submission disabled', - }, - { - reason: 'Order submission disabled', - }, - { - code: 101, - reason: 'Validation failed', - validationErrors: [ - { - field: 'maker', - reason: 'Invalid address', - }, - ], - }, - { - code: 101, - reason: 'Validation failed', - validationErrors: [ - { - field: 'maker', - code: '1002', - reason: 'Invalid address', - }, - ], - }, - ]; - const shouldFail = true; - validateAgainstSchema(testCases, relayerApiErrorResponseSchema, shouldFail); - }); - }); - describe('#relayerApiOrderConfigPayloadSchema', () => { - it('should validate valid fees payloads', () => { - const testCases = [ - { - exchangeAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - makerAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - takerAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - makerAssetData: NULL_ADDRESS, - takerAssetData: NULL_ADDRESS, - makerAssetAmount: '10000000000000000000', - takerAssetAmount: '30000000000000000000', - expirationTimeSeconds: '42', - }, - ]; - validateAgainstSchema(testCases, relayerApiOrderConfigPayloadSchema); - }); - it('should fail for invalid fees payloads', () => { - const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; - const testCases = [ - {}, - { - makerAssetAmount: '10000000000000000000', - takerAssetAmount: '30000000000000000000', - makerAssetData: NULL_ADDRESS, - takerAssetData: NULL_ADDRESS, - }, - { - takerAddress: checksummedAddress, - makerAssetAmount: '10000000000000000000', - takerAssetAmount: '30000000000000000000', - }, - { - makerAssetAmount: 10000000000000000000, - takerAssetAmount: 30000000000000000000, - }, - ]; - const shouldFail = true; - validateAgainstSchema(testCases, relayerApiOrderConfigPayloadSchema, shouldFail); - }); - }); - describe('#relayerApiOrderConfigResponseSchema', () => { - it('should validate valid fees responses', () => { - const testCases = [ - { - makerFee: '10000000000000000', - takerFee: '30000000000000000', - feeRecipientAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - senderAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - }, - ]; - validateAgainstSchema(testCases, relayerApiOrderConfigResponseSchema); - }); - it('should fail for invalid fees responses', () => { - const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; - const testCases = [ - {}, - { - makerFee: 10000000000000000, - takerFee: 30000000000000000, - }, - { - feeRecipient: checksummedAddress, - takerToSpecify: checksummedAddress, - makerFee: '10000000000000000', - takerFee: '30000000000000000', - }, - ]; - const shouldFail = true; - validateAgainstSchema(testCases, relayerApiOrderConfigResponseSchema, shouldFail); - }); - }); - describe('#relayerAssetDataPairsResponseSchema', () => { - it('should validate valid assetPairs response', () => { - const testCases = [ - { - ...paginatedResponse, - records: [], - }, - { - ...paginatedResponse, - records: [ - { - assetDataA: { - assetData: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - minAmount: '0', - maxAmount: '10000000000000000000', - precision: 5, - }, - assetDataB: { - assetData: '0xef7fff64389b814a946f3e92105513705ca6b990', - minAmount: '0', - maxAmount: '50000000000000000000', - precision: 5, - }, - }, - ], - }, - { - ...paginatedResponse, - records: [ - { - assetDataA: { - assetData: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - }, - assetDataB: { - assetData: '0xef7fff64389b814a946f3e92105513705ca6b990', - }, - }, - ], - }, - ]; - validateAgainstSchema(testCases, relayerApiAssetDataPairsResponseSchema); - }); - it('should fail for invalid assetPairs responses', () => { - const testCases = [ - { - ...paginatedResponse, - records: [ - { - assetDataA: { - assetData: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - minAmount: '0', - maxAmount: '10000000000000000000', - precision: 5, - }, - assetDataC: { - assetData: '0xef7fff64389b814a946f3e92105513705ca6b990', - minAmount: '0', - maxAmount: '50000000000000000000', - precision: 5, - }, - }, - ], - }, - { - records: [ - { - assetDataA: { - assetData: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - minAmount: '0', - maxAmount: '10000000000000000000', - precision: 5, - }, - assetDataB: { - assetData: '0xef7fff64389b814a946f3e92105513705ca6b990', - minAmount: '0', - maxAmount: '50000000000000000000', - precision: 5, - }, - }, - ], - }, - { - ...paginatedResponse, - records: [ - { - assetDataA: { - minAmount: '0', - maxAmount: '10000000000000000000', - precision: 5, - }, - assetDataB: { - minAmount: '0', - maxAmount: '50000000000000000000', - precision: 5, - }, - }, - ], - }, - ]; - const shouldFail = true; - validateAgainstSchema(testCases, relayerApiAssetDataPairsResponseSchema, shouldFail); - }); - }); - describe('#relayerApiOrdersResponseSchema', () => { - it('should validate valid orders responses', () => { - const testCases = [ - relayerApiOrdersResponse, - { - ...paginatedResponse, - records: [], - }, - ]; - validateAgainstSchema(testCases, relayerApiOrdersResponseSchema); - }); - it('should fail for invalid orders responses', () => { - const testCases = [ - { - records: [relayerApiOrder, relayerApiOrder], - }, - { - ...paginatedResponse, - }, - { - ...paginatedResponse, - records: [{}, relayerApiOrder], - }, - ]; - const shouldFail = true; - validateAgainstSchema(testCases, relayerApiOrdersResponseSchema, shouldFail); - }); - }); - describe('#relayerApiOrderbookResponseSchema', () => { - it('should validate valid order book responses', () => { - const testCases = [ - { - bids: { - ...paginatedResponse, - records: [relayerApiOrder], - }, - asks: { - ...paginatedResponse, - records: [], - }, - }, - { - bids: { - ...paginatedResponse, - records: [relayerApiOrder, relayerApiOrder], - }, - asks: { - ...paginatedResponse, - records: [relayerApiOrder, relayerApiOrder], - }, - }, - { - bids: { - ...paginatedResponse, - records: [], - }, - asks: { - ...paginatedResponse, - records: [relayerApiOrder, relayerApiOrder], - }, - }, - ]; - validateAgainstSchema(testCases, relayerApiOrderbookResponseSchema); - }); - it('should fail for invalid order fill requests', () => { - const testCases = [ - {}, - { - bids: { - records: [relayerApiOrder], - }, - asks: { - ...paginatedResponse, - records: [], - }, - }, - { - bids: { - ...paginatedResponse, - records: [relayerApiOrder, relayerApiOrder], - }, - asks: {}, - }, - { - bids: { - ...paginatedResponse, - }, - asks: { - ...paginatedResponse, - records: [relayerApiOrder, relayerApiOrder], - }, - }, - ]; - const shouldFail = true; - validateAgainstSchema(testCases, relayerApiOrdersResponseSchema, shouldFail); - }); - }); - describe('#relayerApiOrdersChannelSubscribeSchema', () => { - it('should validate valid orders channel websocket subscribe message', () => { - const testCases = [ - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - }, - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: { - makerAssetProxyId: '0x02571792', - takerAssetProxyId: '0xf47261b0', - }, - }, - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: {}, - }, - ]; - validateAgainstSchema(testCases, relayerApiOrdersChannelSubscribeSchema); - }); - it('should fail for invalid orders channel websocket subscribe message', () => { - const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; - const testCases = [ - { - type: 'subscribe', - channel: 'orders', - }, - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: { - makerAssetProxyId: '0x02571792', - takerAssetProxyId: '0xf47261b0', - makerAssetAddress: checksummedAddress, - }, - }, - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: { - makerAssetProxyId: 'invalidId', - }, - }, - ]; - const shouldFail = true; - validateAgainstSchema(testCases, relayerApiOrdersChannelSubscribeSchema, shouldFail); - }); - }); - describe('#relayerApiOrdersChannelUpdateSchema', () => { - it('should validate valid orders channel websocket update message', () => { - const testCases = [ - { - type: 'update', - channel: 'orders', - requestId: 'randomId', - payload: [relayerApiOrder], - }, - { - type: 'update', - channel: 'orders', - requestId: 'randomId', - payload: [], - }, - ]; - validateAgainstSchema(testCases, relayerApiOrdersChannelUpdateSchema); - }); - it('should fail for invalid orders channel websocket update message', () => { - const testCases = [ - { - type: 'foo', - channel: 'orders', - requestId: 'randomId', - }, - { - type: 'update', - channel: 'bar', - requestId: 2, - payload: [relayerApiOrder], - }, - { - type: 'update', - channel: 'orders', - requestId: 'randomId', - payload: {}, - }, - { - type: 'update', - channel: 'orders', - requestId: 'randomId', - payload: relayerApiErrorResponseSchema, - }, - ]; - const shouldFail = true; - validateAgainstSchema(testCases, relayerApiOrdersChannelUpdateSchema, shouldFail); - }); - }); - }); - }); - }); - describe('BigNumber serialization', () => { - it('should correctly serialize BigNumbers', () => { - const testCases = { - '42': '42', - '0': '0', - '1.3': '1.3', - '0.2': '0.2', - '00.00': '0', - '.3': '0.3', - }; - forEach(testCases, (serialized: string, input: string) => { - expect(JSON.parse(JSON.stringify(new BigNumber(input)))).to.be.equal(serialized); - }); - }); - }); - describe('#jsNumberSchema', () => { - it('should validate valid js number', () => { - // tslint:disable-next-line:custom-no-magic-numbers - const testCases = [1, 42]; - validateAgainstSchema(testCases, jsNumber); - }); - it('should fail for invalid js number', () => { - // tslint:disable-next-line:custom-no-magic-numbers - const testCases = [NaN, -1, new BigNumber(1)]; - const shouldFail = true; - validateAgainstSchema(testCases, jsNumber, shouldFail); - }); - }); - describe('#txDataSchema', () => { - it('should validate valid txData', () => { - const bigNumGasAmount = new BigNumber(42); - const testCases = [ - { - from: NULL_ADDRESS, - }, - { - from: NULL_ADDRESS, - gas: bigNumGasAmount, - }, - { - from: NULL_ADDRESS, - gas: 42, - }, - ]; - validateAgainstSchema(testCases, txDataSchema); - }); - it('should fail for invalid txData', () => { - const testCases = [ - { - gas: new BigNumber(42), - }, - {}, - [], - new BigNumber(1), - ]; - const shouldFail = true; - validateAgainstSchema(testCases, txDataSchema, shouldFail); - }); - }); -}); // tslint:disable:max-file-line-count diff --git a/packages/json-schemas/tsconfig.json b/packages/json-schemas/tsconfig.json deleted file mode 100644 index 7d7ce1d7e..000000000 --- a/packages/json-schemas/tsconfig.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "extends": "../../tsconfig", - "compilerOptions": { - "outDir": "lib", - "rootDir": ".", - "resolveJsonModule": true - }, - "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/order_watcher_web_socket_request_schema.json", - "./schemas/order_watcher_web_socket_utf8_message_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_schema.json", - "./schemas/zero_ex_transaction_schema.json", - "./schemas/tx_data_schema.json", - "./schemas/index_filter_values_schema.json", - "./schemas/whole_number_schema.json", - "./schemas/asset_pairs_request_opts_schema.json", - "./schemas/orderbook_request_schema.json", - "./schemas/orders_request_opts_schema.json", - "./schemas/paged_request_opts_schema.json", - "./schemas/request_opts_schema.json", - "./schemas/order_config_request_schema.json" - ] -} diff --git a/packages/json-schemas/tslint.json b/packages/json-schemas/tslint.json deleted file mode 100644 index dd9053357..000000000 --- a/packages/json-schemas/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["@0x/tslint-config"] -} diff --git a/packages/json-schemas/typedoc-tsconfig.json b/packages/json-schemas/typedoc-tsconfig.json deleted file mode 100644 index c9b0af1ae..000000000 --- a/packages/json-schemas/typedoc-tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../typedoc-tsconfig", - "compilerOptions": { - "outDir": "lib" - }, - "include": ["./src/**/*", "./test/**/*"] -} |