diff options
Diffstat (limited to 'packages/json-schemas')
76 files changed, 732 insertions, 515 deletions
diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json index d78a1c11e..3bd6552e3 100644 --- a/packages/json-schemas/CHANGELOG.json +++ b/packages/json-schemas/CHANGELOG.json @@ -1,5 +1,108 @@ [ { + "version": "2.0.1", + "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 + } + ] + }, + { + "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": [ { diff --git a/packages/json-schemas/CHANGELOG.md b/packages/json-schemas/CHANGELOG.md index 0ebc3d237..21efe1be0 100644 --- a/packages/json-schemas/CHANGELOG.md +++ b/packages/json-schemas/CHANGELOG.md @@ -5,7 +5,47 @@ Edit the package's CHANGELOG.json file only. CHANGELOG -## v1.0.1-rc.4 - _August 13, 2018_ +## 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) diff --git a/packages/json-schemas/README.md b/packages/json-schemas/README.md index ab57833be..f50382f4b 100644 --- a/packages/json-schemas/README.md +++ b/packages/json-schemas/README.md @@ -1,4 +1,4 @@ -## @0xproject/json-schemas +## @0x/json-schemas Contains 0x-related json schemas @@ -7,26 +7,26 @@ Contains 0x-related json schemas ## Installation ```bash -yarn add @0xproject/json-schemas +yarn add @0x/json-schemas ``` **Import** ```typescript -import { SchemaValidator, ValidatorResult, schemas } from '@0xproject/json-schemas'; +import { SchemaValidator, ValidatorResult, schemas } from '@0x/json-schemas'; ``` or ```javascript -var schemas = require('@0xproject/json-schemas').schemas; +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/@0xproject/typescript-typings/types", "node_modules/@types"], + "typeRoots": ["node_modules/@0x/typescript-typings/types", "node_modules/@types"], } ``` @@ -55,13 +55,13 @@ yarn install To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: ```bash -PKG=@0xproject/json-schemas yarn build +PKG=@0x/json-schemas yarn build ``` Or continuously rebuild on change: ```bash -PKG=@0xproject/json-schemas yarn watch +PKG=@0x/json-schemas yarn watch ``` ### Clean diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json index 062304585..57715c601 100644 --- a/packages/json-schemas/package.json +++ b/packages/json-schemas/package.json @@ -1,6 +1,6 @@ { - "name": "@0xproject/json-schemas", - "version": "1.0.1-rc.4", + "name": "@0x/json-schemas", + "version": "2.0.0", "engines": { "node": ">=6.12" }, @@ -8,32 +8,24 @@ "main": "lib/src/index.js", "types": "lib/src/index.d.ts", "scripts": { - "watch_without_deps": "tsc -w", - "lint": "tslint --project .", + "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 scripts", - "build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", - "manual:postpublish": "yarn build; node ./scripts/postpublish.js", - "docs:stage": "node scripts/stage_docs.js", - "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES", - "upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json" + "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": [], - "docPublishConfigs": { - "extraFileIncludes": [ - "../types/src/index.ts", - "../ethereum-types/src/index.ts" - ], - "s3BucketPath": "s3://doc-jsons/json-schemas/", - "s3StagingBucketPath": "s3://staging-doc-jsons/json-schemas/" - } + "docOmitExports": [ + "schemas" + ] } }, "repository": { @@ -47,20 +39,18 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md", "dependencies": { - "@0xproject/typescript-typings": "^1.0.4", - "@types/node": "^8.0.53", + "@0x/typescript-typings": "^3.0.3", + "@types/node": "*", "jsonschema": "^1.2.0", "lodash.values": "^4.3.0" }, "devDependencies": { - "@0xproject/monorepo-scripts": "^1.0.5", - "@0xproject/tslint-config": "^1.0.5", - "@0xproject/utils": "^1.0.5", + "@0x/tslint-config": "^1.0.9", + "@0x/utils": "^2.0.3", "@types/lodash.foreach": "^4.5.3", "@types/lodash.values": "^4.3.3", "@types/mocha": "^2.2.42", "chai": "^4.0.1", - "copyfiles": "^2.0.0", "dirty-chai": "^2.0.1", "lodash.foreach": "^4.5.0", "make-promises-safe": "^1.1.0", @@ -69,7 +59,7 @@ "nyc": "^11.0.1", "shx": "^0.2.2", "tslint": "5.11.0", - "typedoc": "0xProject/typedoc", + "typedoc": "0.13.0", "typescript": "3.0.1" }, "publishConfig": { diff --git a/packages/json-schemas/schemas/address_schema.json b/packages/json-schemas/schemas/address_schema.json new file mode 100644 index 000000000..0dc02d331 --- /dev/null +++ b/packages/json-schemas/schemas/address_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/addressSchema", + "type": "string", + "pattern": "^0x[0-9a-f]{40}$" +} diff --git a/packages/json-schemas/schemas/basic_type_schemas.ts b/packages/json-schemas/schemas/basic_type_schemas.ts deleted file mode 100644 index a59afaef8..000000000 --- a/packages/json-schemas/schemas/basic_type_schemas.ts +++ /dev/null @@ -1,17 +0,0 @@ -export const addressSchema = { - id: '/addressSchema', - type: 'string', - pattern: '^0x[0-9a-f]{40}$', -}; - -export const hexSchema = { - id: '/hexSchema', - type: 'string', - pattern: '^0x(([0-9a-f][0-9a-f])+)?$', -}; - -export const numberSchema = { - id: '/numberSchema', - type: 'string', - pattern: '^\\d+(\\.\\d+)?$', -}; diff --git a/packages/json-schemas/schemas/block_param_schema.json b/packages/json-schemas/schemas/block_param_schema.json new file mode 100644 index 000000000..ed4dd1e87 --- /dev/null +++ b/packages/json-schemas/schemas/block_param_schema.json @@ -0,0 +1,11 @@ +{ + "id": "/blockParamSchema", + "oneOf": [ + { + "type": "number" + }, + { + "enum": ["latest", "earliest", "pending"] + } + ] +} diff --git a/packages/json-schemas/schemas/block_range_schema.json b/packages/json-schemas/schemas/block_range_schema.json new file mode 100644 index 000000000..b14294649 --- /dev/null +++ b/packages/json-schemas/schemas/block_range_schema.json @@ -0,0 +1,8 @@ +{ + "id": "/blockRangeSchema", + "properties": { + "fromBlock": { "$ref": "/blockParamSchema" }, + "toBlock": { "$ref": "/blockParamSchema" } + }, + "type": "object" +} diff --git a/packages/json-schemas/schemas/block_range_schema.ts b/packages/json-schemas/schemas/block_range_schema.ts deleted file mode 100644 index 9eb242fc6..000000000 --- a/packages/json-schemas/schemas/block_range_schema.ts +++ /dev/null @@ -1,20 +0,0 @@ -export const blockParamSchema = { - id: '/blockParamSchema', - oneOf: [ - { - type: 'number', - }, - { - enum: ['latest', 'earliest', 'pending'], - }, - ], -}; - -export const blockRangeSchema = { - id: '/blockRangeSchema', - properties: { - fromBlock: { $ref: '/blockParamSchema' }, - toBlock: { $ref: '/blockParamSchema' }, - }, - type: 'object', -}; diff --git a/packages/json-schemas/schemas/call_data_schema.json b/packages/json-schemas/schemas/call_data_schema.json new file mode 100644 index 000000000..c5972e8c1 --- /dev/null +++ b/packages/json-schemas/schemas/call_data_schema.json @@ -0,0 +1,27 @@ +{ + "id": "/callDataSchema", + "properties": { + "from": { "$ref": "/addressSchema" }, + "to": { "$ref": "/addressSchema" }, + "value": { + "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] + }, + "gas": { + "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] + }, + "gasPrice": { + "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] + }, + "data": { + "type": "string", + "pattern": "^0x[0-9a-f]*$" + }, + "nonce": { + "type": "number", + "minimum": 0 + } + }, + "required": [], + "type": "object", + "additionalProperties": false +} diff --git a/packages/json-schemas/schemas/call_data_schema.ts b/packages/json-schemas/schemas/call_data_schema.ts deleted file mode 100644 index 4c77d9f9d..000000000 --- a/packages/json-schemas/schemas/call_data_schema.ts +++ /dev/null @@ -1,27 +0,0 @@ -export const callDataSchema = { - id: '/callDataSchema', - properties: { - from: { $ref: '/addressSchema' }, - to: { $ref: '/addressSchema' }, - value: { - oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], - }, - gas: { - oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], - }, - gasPrice: { - oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], - }, - data: { - type: 'string', - pattern: '^0x[0-9a-f]*$', - }, - nonce: { - type: 'number', - minimum: 0, - }, - }, - required: [], - type: 'object', - additionalProperties: false, -}; diff --git a/packages/json-schemas/schemas/ec_signature_parameter_schema.json b/packages/json-schemas/schemas/ec_signature_parameter_schema.json new file mode 100644 index 000000000..0c08ec240 --- /dev/null +++ b/packages/json-schemas/schemas/ec_signature_parameter_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/ecSignatureParameterSchema", + "type": "string", + "pattern": "^0[xX][0-9A-Fa-f]{64}$" +} diff --git a/packages/json-schemas/schemas/ec_signature_schema.json b/packages/json-schemas/schemas/ec_signature_schema.json new file mode 100644 index 000000000..bc79ca5e9 --- /dev/null +++ b/packages/json-schemas/schemas/ec_signature_schema.json @@ -0,0 +1,14 @@ +{ + "id": "/ECSignature", + "properties": { + "v": { + "type": "number", + "minimum": 27, + "maximum": 28 + }, + "r": { "$ref": "/ecSignatureParameterSchema" }, + "s": { "$ref": "/ecSignatureParameterSchema" } + }, + "required": ["v", "r", "s"], + "type": "object" +} diff --git a/packages/json-schemas/schemas/ec_signature_schema.ts b/packages/json-schemas/schemas/ec_signature_schema.ts deleted file mode 100644 index c59532f09..000000000 --- a/packages/json-schemas/schemas/ec_signature_schema.ts +++ /dev/null @@ -1,20 +0,0 @@ -export const ecSignatureParameterSchema = { - id: '/ecSignatureParameterSchema', - type: 'string', - pattern: '^0[xX][0-9A-Fa-f]{64}$', -}; - -export const ecSignatureSchema = { - id: '/ECSignature', - properties: { - v: { - type: 'number', - minimum: 27, - maximum: 28, - }, - r: { $ref: '/ecSignatureParameterSchema' }, - s: { $ref: '/ecSignatureParameterSchema' }, - }, - required: ['v', 'r', 's'], - type: 'object', -}; diff --git a/packages/json-schemas/schemas/eip712_typed_data_schema.json b/packages/json-schemas/schemas/eip712_typed_data_schema.json new file mode 100644 index 000000000..8efd6de44 --- /dev/null +++ b/packages/json-schemas/schemas/eip712_typed_data_schema.json @@ -0,0 +1,28 @@ +{ + "id": "/eip712TypedDataSchema", + "type": "object", + "properties": { + "types": { + "type": "object", + "properties": { + "EIP712Domain": { "type": "array" } + }, + "additionalProperties": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { "type": "string" }, + "type": { "type": "string" } + }, + "required": ["name", "type"] + } + }, + "required": ["EIP712Domain"] + }, + "primaryType": { "type": "string" }, + "domain": { "type": "object" }, + "message": { "type": "object" } + }, + "required": ["types", "primaryType", "domain", "message"] +} diff --git a/packages/json-schemas/schemas/hex_schema.json b/packages/json-schemas/schemas/hex_schema.json new file mode 100644 index 000000000..f37815d5b --- /dev/null +++ b/packages/json-schemas/schemas/hex_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/hexSchema", + "type": "string", + "pattern": "^0x(([0-9a-f][0-9a-f])+)?$" +} diff --git a/packages/json-schemas/schemas/index_filter_values_schema.json b/packages/json-schemas/schemas/index_filter_values_schema.json new file mode 100644 index 000000000..bec00d79e --- /dev/null +++ b/packages/json-schemas/schemas/index_filter_values_schema.json @@ -0,0 +1,7 @@ +{ + "id": "/indexFilterValuesSchema", + "additionalProperties": { + "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/addressSchema" }, { "$ref": "/orderHashSchema" }] + }, + "type": "object" +} diff --git a/packages/json-schemas/schemas/index_filter_values_schema.ts b/packages/json-schemas/schemas/index_filter_values_schema.ts deleted file mode 100644 index f3c8cef68..000000000 --- a/packages/json-schemas/schemas/index_filter_values_schema.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const indexFilterValuesSchema = { - id: '/indexFilterValuesSchema', - additionalProperties: { - oneOf: [{ $ref: '/numberSchema' }, { $ref: '/addressSchema' }, { $ref: '/orderHashSchema' }], - }, - type: 'object', -}; diff --git a/packages/json-schemas/schemas/js_number.json b/packages/json-schemas/schemas/js_number.json new file mode 100644 index 000000000..6a72d92c0 --- /dev/null +++ b/packages/json-schemas/schemas/js_number.json @@ -0,0 +1,5 @@ +{ + "id": "/jsNumber", + "type": "number", + "minimum": 0 +} diff --git a/packages/json-schemas/schemas/number_schema.json b/packages/json-schemas/schemas/number_schema.json new file mode 100644 index 000000000..a48f3e8cf --- /dev/null +++ b/packages/json-schemas/schemas/number_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/numberSchema", + "type": "string", + "pattern": "^\\d+(\\.\\d+)?$" +} diff --git a/packages/json-schemas/schemas/order_cancel_schema.json b/packages/json-schemas/schemas/order_cancel_schema.json new file mode 100644 index 000000000..8d0999941 --- /dev/null +++ b/packages/json-schemas/schemas/order_cancel_schema.json @@ -0,0 +1,12 @@ +{ + "id": "/orderCancellationRequestsSchema", + "type": "array", + "items": { + "properties": { + "order": { "$ref": "/orderSchema" }, + "takerTokenCancelAmount": { "$ref": "/wholeNumberSchema" } + }, + "required": ["order", "takerTokenCancelAmount"], + "type": "object" + } +} diff --git a/packages/json-schemas/schemas/order_cancel_schema.ts b/packages/json-schemas/schemas/order_cancel_schema.ts deleted file mode 100644 index e4edfbca9..000000000 --- a/packages/json-schemas/schemas/order_cancel_schema.ts +++ /dev/null @@ -1,12 +0,0 @@ -export const orderCancellationRequestsSchema = { - id: '/orderCancellationRequestsSchema', - type: 'array', - items: { - properties: { - order: { $ref: '/orderSchema' }, - takerTokenCancelAmount: { $ref: '/numberSchema' }, - }, - required: ['order', 'takerTokenCancelAmount'], - type: 'object', - }, -}; diff --git a/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.json b/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.json new file mode 100644 index 000000000..73bbf20bb --- /dev/null +++ b/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.json @@ -0,0 +1,12 @@ +{ + "id": "/orderFillOrKillRequestsSchema", + "type": "array", + "items": { + "properties": { + "signedOrder": { "$ref": "/signedOrderSchema" }, + "fillTakerAmount": { "$ref": "/wholeNumberSchema" } + }, + "required": ["signedOrder", "fillTakerAmount"], + "type": "object" + } +} diff --git a/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts b/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts deleted file mode 100644 index e2c18ef0a..000000000 --- a/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts +++ /dev/null @@ -1,12 +0,0 @@ -export const orderFillOrKillRequestsSchema = { - id: '/orderFillOrKillRequestsSchema', - type: 'array', - items: { - properties: { - signedOrder: { $ref: '/signedOrderSchema' }, - fillTakerAmount: { $ref: '/numberSchema' }, - }, - required: ['signedOrder', 'fillTakerAmount'], - type: 'object', - }, -}; diff --git a/packages/json-schemas/schemas/order_fill_requests_schema.json b/packages/json-schemas/schemas/order_fill_requests_schema.json new file mode 100644 index 000000000..d06fb19a2 --- /dev/null +++ b/packages/json-schemas/schemas/order_fill_requests_schema.json @@ -0,0 +1,12 @@ +{ + "id": "/orderFillRequestsSchema", + "type": "array", + "items": { + "properties": { + "signedOrder": { "$ref": "/signedOrderSchema" }, + "takerTokenFillAmount": { "$ref": "/wholeNumberSchema" } + }, + "required": ["signedOrder", "takerTokenFillAmount"], + "type": "object" + } +} diff --git a/packages/json-schemas/schemas/order_fill_requests_schema.ts b/packages/json-schemas/schemas/order_fill_requests_schema.ts deleted file mode 100644 index ea8b35e54..000000000 --- a/packages/json-schemas/schemas/order_fill_requests_schema.ts +++ /dev/null @@ -1,12 +0,0 @@ -export const orderFillRequestsSchema = { - id: '/orderFillRequestsSchema', - type: 'array', - items: { - properties: { - signedOrder: { $ref: '/signedOrderSchema' }, - takerTokenFillAmount: { $ref: '/numberSchema' }, - }, - required: ['signedOrder', 'takerTokenFillAmount'], - type: 'object', - }, -}; diff --git a/packages/json-schemas/schemas/order_hash_schema.json b/packages/json-schemas/schemas/order_hash_schema.json new file mode 100644 index 000000000..4a770579f --- /dev/null +++ b/packages/json-schemas/schemas/order_hash_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/orderHashSchema", + "type": "string", + "pattern": "^0x[0-9a-fA-F]{64}$" +} diff --git a/packages/json-schemas/schemas/order_hash_schema.ts b/packages/json-schemas/schemas/order_hash_schema.ts deleted file mode 100644 index 9773a88f9..000000000 --- a/packages/json-schemas/schemas/order_hash_schema.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const orderHashSchema = { - id: '/orderHashSchema', - type: 'string', - pattern: '^0x[0-9a-fA-F]{64}$', -}; diff --git a/packages/json-schemas/schemas/order_schema.json b/packages/json-schemas/schemas/order_schema.json new file mode 100644 index 000000000..c70b9e2dd --- /dev/null +++ b/packages/json-schemas/schemas/order_schema.json @@ -0,0 +1,34 @@ +{ + "id": "/orderSchema", + "properties": { + "makerAddress": { "$ref": "/addressSchema" }, + "takerAddress": { "$ref": "/addressSchema" }, + "makerFee": { "$ref": "/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_schemas.ts b/packages/json-schemas/schemas/order_schemas.ts deleted file mode 100644 index eb7fdaf5a..000000000 --- a/packages/json-schemas/schemas/order_schemas.ts +++ /dev/null @@ -1,47 +0,0 @@ -export const orderSchema = { - id: '/orderSchema', - properties: { - makerAddress: { $ref: '/addressSchema' }, - takerAddress: { $ref: '/addressSchema' }, - makerFee: { $ref: '/numberSchema' }, - takerFee: { $ref: '/numberSchema' }, - senderAddress: { $ref: '/addressSchema' }, - makerAssetAmount: { $ref: '/numberSchema' }, - takerAssetAmount: { $ref: '/numberSchema' }, - makerAssetData: { $ref: '/hexSchema' }, - takerAssetData: { $ref: '/hexSchema' }, - salt: { $ref: '/numberSchema' }, - exchangeAddress: { $ref: '/addressSchema' }, - feeRecipientAddress: { $ref: '/addressSchema' }, - expirationTimeSeconds: { $ref: '/numberSchema' }, - }, - required: [ - 'makerAddress', - 'takerAddress', - 'makerFee', - 'takerFee', - 'senderAddress', - 'makerAssetAmount', - 'takerAssetAmount', - 'makerAssetData', - 'takerAssetData', - 'salt', - 'exchangeAddress', - 'feeRecipientAddress', - 'expirationTimeSeconds', - ], - type: 'object', -}; - -export const signedOrderSchema = { - id: '/signedOrderSchema', - allOf: [ - { $ref: '/orderSchema' }, - { - properties: { - signature: { $ref: '/hexSchema' }, - }, - required: ['signature'], - }, - ], -}; diff --git a/packages/json-schemas/schemas/orders_schema.json b/packages/json-schemas/schemas/orders_schema.json new file mode 100644 index 000000000..1e1c6a875 --- /dev/null +++ b/packages/json-schemas/schemas/orders_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/ordersSchema", + "type": "array", + "items": { "$ref": "/orderSchema" } +} diff --git a/packages/json-schemas/schemas/orders_schema.ts b/packages/json-schemas/schemas/orders_schema.ts deleted file mode 100644 index de0abcf00..000000000 --- a/packages/json-schemas/schemas/orders_schema.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const ordersSchema = { - id: '/ordersSchema', - type: 'array', - items: { $ref: '/orderSchema' }, -}; diff --git a/packages/json-schemas/schemas/paginated_collection_schema.json b/packages/json-schemas/schemas/paginated_collection_schema.json new file mode 100644 index 000000000..9dcedf5b4 --- /dev/null +++ b/packages/json-schemas/schemas/paginated_collection_schema.json @@ -0,0 +1,10 @@ +{ + "id": "/paginatedCollectionSchema", + "type": "object", + "properties": { + "total": { "type": "number" }, + "perPage": { "type": "number" }, + "page": { "type": "number" } + }, + "required": ["total", "perPage", "page"] +} diff --git a/packages/json-schemas/schemas/paginated_collection_schema.ts b/packages/json-schemas/schemas/paginated_collection_schema.ts deleted file mode 100644 index 16044c70a..000000000 --- a/packages/json-schemas/schemas/paginated_collection_schema.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const paginatedCollectionSchema = { - id: '/paginatedCollectionSchema', - type: 'object', - properties: { - total: { type: 'number' }, - perPage: { type: 'number' }, - page: { type: 'number' }, - }, - required: ['total', 'perPage', 'page'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_asset_data_pairs_response_schema.json b/packages/json-schemas/schemas/relayer_api_asset_data_pairs_response_schema.json new file mode 100644 index 000000000..d1150d3db --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_asset_data_pairs_response_schema.json @@ -0,0 +1,13 @@ +{ + "id": "/relayerApiAssetDataPairsResponseSchema", + "type": "object", + "allOf": [ + { "$ref": "/paginatedCollectionSchema" }, + { + "properties": { + "records": { "$ref": "/relayerApiAssetDataPairsSchema" } + }, + "required": ["records"] + } + ] +} diff --git a/packages/json-schemas/schemas/relayer_api_asset_data_pairs_schema.json b/packages/json-schemas/schemas/relayer_api_asset_data_pairs_schema.json new file mode 100644 index 000000000..62d4745b8 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_asset_data_pairs_schema.json @@ -0,0 +1,12 @@ +{ + "id": "/relayerApiAssetDataPairsSchema", + "type": "array", + "items": { + "properties": { + "assetDataA": { "$ref": "/relayerApiAssetDataTradeInfoSchema" }, + "assetDataB": { "$ref": "/relayerApiAssetDataTradeInfoSchema" } + }, + "required": ["assetDataA", "assetDataB"], + "type": "object" + } +} diff --git a/packages/json-schemas/schemas/relayer_api_asset_data_trade_info_schema.json b/packages/json-schemas/schemas/relayer_api_asset_data_trade_info_schema.json new file mode 100644 index 000000000..e0f274c5d --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_asset_data_trade_info_schema.json @@ -0,0 +1,11 @@ +{ + "id": "/relayerApiAssetDataTradeInfoSchema", + "type": "object", + "properties": { + "assetData": { "$ref": "/hexSchema" }, + "minAmount": { "$ref": "/wholeNumberSchema" }, + "maxAmount": { "$ref": "/wholeNumberSchema" }, + "precision": { "type": "number" } + }, + "required": ["assetData"] +} diff --git a/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts b/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts deleted file mode 100644 index c13396d29..000000000 --- a/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts +++ /dev/null @@ -1,38 +0,0 @@ -export const relayerApiAssetDataPairsResponseSchema = { - id: '/relayerApiAssetDataPairsResponseSchema', - type: 'object', - allOf: [ - { $ref: '/paginatedCollectionSchema' }, - { - properties: { - records: { $ref: '/relayerApiAssetDataPairsSchema' }, - }, - required: ['records'], - }, - ], -}; - -export const relayerApiAssetDataPairsSchema = { - id: '/relayerApiAssetDataPairsSchema', - type: 'array', - items: { - properties: { - assetDataA: { $ref: '/relayerApiAssetDataTradeInfoSchema' }, - assetDataB: { $ref: '/relayerApiAssetDataTradeInfoSchema' }, - }, - required: ['assetDataA', 'assetDataB'], - type: 'object', - }, -}; - -export const relayerApiAssetDataTradeInfoSchema = { - id: '/relayerApiAssetDataTradeInfoSchema', - type: 'object', - properties: { - assetData: { $ref: '/hexSchema' }, - minAmount: { $ref: '/numberSchema' }, - maxAmount: { $ref: '/numberSchema' }, - precision: { type: 'number' }, - }, - required: ['assetData'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_error_response_schema.json b/packages/json-schemas/schemas/relayer_api_error_response_schema.json new file mode 100644 index 000000000..be4659b0b --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_error_response_schema.json @@ -0,0 +1,21 @@ +{ + "id": "/relayerApiErrorResponseSchema", + "type": "object", + "properties": { + "code": { "type": "integer", "minimum": 100, "maximum": 103 }, + "reason": { "type": "string" }, + "validationErrors": { + "type": "array", + "items": { + "type": "object", + "properties": { + "field": { "type": "string" }, + "code": { "type": "integer", "minimum": 1000, "maximum": 1006 }, + "reason": { "type": "string" } + }, + "required": ["field", "code", "reason"] + } + } + }, + "required": ["code", "reason"] +} diff --git a/packages/json-schemas/schemas/relayer_api_error_response_schema.ts b/packages/json-schemas/schemas/relayer_api_error_response_schema.ts deleted file mode 100644 index 79e33fc85..000000000 --- a/packages/json-schemas/schemas/relayer_api_error_response_schema.ts +++ /dev/null @@ -1,21 +0,0 @@ -export const relayerApiErrorResponseSchema = { - id: '/relayerApiErrorResponseSchema', - type: 'object', - properties: { - code: { type: 'integer', minimum: 100, maximum: 103 }, - reason: { type: 'string' }, - validationErrors: { - type: 'array', - items: { - type: 'object', - properties: { - field: { type: 'string' }, - code: { type: 'integer', minimum: 1000, maximum: 1006 }, - reason: { type: 'string' }, - }, - required: ['field', 'code', 'reason'], - }, - }, - }, - required: ['code', 'reason'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.json b/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.json new file mode 100644 index 000000000..c73506dbb --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.json @@ -0,0 +1,16 @@ +{ + "id": "/relayerApiFeeRecipientsResponseSchema", + "type": "object", + "allOf": [ + { "$ref": "/paginatedCollectionSchema" }, + { + "properties": { + "records": { + "type": "array", + "items": { "$ref": "/addressSchema" } + } + }, + "required": ["records"] + } + ] +} diff --git a/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.ts b/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.ts deleted file mode 100644 index 84d39eb20..000000000 --- a/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.ts +++ /dev/null @@ -1,13 +0,0 @@ -export const relayerApiFeeRecipientsResponseSchema = { - id: '/relayerApiFeeRecipientsResponseSchema', - type: 'object', - allOf: [ - { $ref: '/paginatedCollectionSchema' }, - { - properties: { - records: { $ref: '/addressSchema' }, - }, - required: ['records'], - }, - ], -}; diff --git a/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.json b/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.json new file mode 100644 index 000000000..f4583fc62 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.json @@ -0,0 +1,24 @@ +{ + "id": "/relayerApiOrderConfigPayloadSchema", + "type": "object", + "properties": { + "makerAddress": { "$ref": "/addressSchema" }, + "takerAddress": { "$ref": "/addressSchema" }, + "makerAssetAmount": { "$ref": "/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_payload_schema.ts b/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts deleted file mode 100644 index 8d1d408d6..000000000 --- a/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts +++ /dev/null @@ -1,24 +0,0 @@ -export const relayerApiOrderConfigPayloadSchema = { - id: '/relayerApiOrderConfigPayloadSchema', - type: 'object', - properties: { - makerAddress: { $ref: '/addressSchema' }, - takerAddress: { $ref: '/addressSchema' }, - makerAssetAmount: { $ref: '/numberSchema' }, - takerAssetAmount: { $ref: '/numberSchema' }, - makerAssetData: { $ref: '/hexSchema' }, - takerAssetData: { $ref: '/hexSchema' }, - exchangeAddress: { $ref: '/addressSchema' }, - expirationTimeSeconds: { $ref: '/numberSchema' }, - }, - required: [ - 'makerAddress', - 'takerAddress', - 'makerAssetAmount', - 'takerAssetAmount', - 'makerAssetData', - 'takerAssetData', - 'exchangeAddress', - 'expirationTimeSeconds', - ], -}; diff --git a/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json b/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json new file mode 100644 index 000000000..8193861e1 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_order_config_response_schema.json @@ -0,0 +1,11 @@ +{ + "id": "/relayerApiOrderConfigResponseSchema", + "type": "object", + "properties": { + "makerFee": { "$ref": "/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_config_response_schema.ts b/packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts deleted file mode 100644 index 390d0b262..000000000 --- a/packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const relayerApiOrderConfigResponseSchema = { - id: '/relayerApiOrderConfigResponseSchema', - type: 'object', - properties: { - makerFee: { $ref: '/numberSchema' }, - takerFee: { $ref: '/numberSchema' }, - feeRecipientAddress: { $ref: '/addressSchema' }, - senderAddress: { $ref: '/addressSchema' }, - }, - required: ['makerFee', 'takerFee', 'feeRecipientAddress', 'senderAddress'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_order_schema.json b/packages/json-schemas/schemas/relayer_api_order_schema.json new file mode 100644 index 000000000..e0f6539b9 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_order_schema.json @@ -0,0 +1,9 @@ +{ + "id": "/relayerApiOrderSchema", + "type": "object", + "properties": { + "order": { "$ref": "/orderSchema" }, + "metaData": { "type": "object" } + }, + "required": ["order", "metaData"] +} diff --git a/packages/json-schemas/schemas/relayer_api_order_schema.ts b/packages/json-schemas/schemas/relayer_api_order_schema.ts deleted file mode 100644 index 3952e9683..000000000 --- a/packages/json-schemas/schemas/relayer_api_order_schema.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const relayerApiOrderSchema = { - id: '/relayerApiOrderSchema', - type: 'object', - properties: { - order: { $ref: '/orderSchema' }, - metaData: { type: 'object' }, - }, - required: ['order', 'metaData'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.json b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.json new file mode 100644 index 000000000..b44f2a740 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.json @@ -0,0 +1,9 @@ +{ + "id": "/relayerApiOrderbookResponseSchema", + "type": "object", + "properties": { + "bids": { "$ref": "/relayerApiOrdersResponseSchema" }, + "asks": { "$ref": "/relayerApiOrdersResponseSchema" } + }, + "required": ["bids", "asks"] +} diff --git a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts deleted file mode 100644 index 7c0b8e0df..000000000 --- a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const relayerApiOrderbookResponseSchema = { - id: '/relayerApiOrderbookResponseSchema', - type: 'object', - properties: { - bids: { $ref: '/relayerApiOrdersResponseSchema' }, - asks: { $ref: '/relayerApiOrdersResponseSchema' }, - }, - required: ['bids', 'asks'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_payload_schema.json b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_payload_schema.json new file mode 100644 index 000000000..274ef1625 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_payload_schema.json @@ -0,0 +1,14 @@ +{ + "id": "/relayerApiOrdersChannelSubscribePayloadSchema", + "type": "object", + "properties": { + "makerAssetProxyId": { "$ref": "/hexSchema" }, + "takerAssetProxyId": { "$ref": "/hexSchema" }, + "networkId": { "type": "number" }, + "makerAssetAddress": { "$ref": "/addressSchema" }, + "takerAssetAddress": { "$ref": "/addressSchema" }, + "makerAssetData": { "$ref": "/hexSchema" }, + "takerAssetData": { "$ref": "/hexSchema" }, + "traderAssetData": { "$ref": "/hexSchema" } + } +} diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.json b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.json new file mode 100644 index 000000000..29561d09f --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.json @@ -0,0 +1,11 @@ +{ + "id": "/relayerApiOrdersChannelSubscribeSchema", + "type": "object", + "properties": { + "type": { "enum": ["subscribe"] }, + "channel": { "enum": ["orders"] }, + "requestId": { "type": "string" }, + "payload": { "$ref": "/relayerApiOrdersChannelSubscribePayloadSchema" } + }, + "required": ["type", "channel", "requestId"] +} diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts deleted file mode 100644 index a3b9b6d95..000000000 --- a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts +++ /dev/null @@ -1,26 +0,0 @@ -export const relayerApiOrdersChannelSubscribeSchema = { - id: '/relayerApiOrdersChannelSubscribeSchema', - type: 'object', - properties: { - type: { enum: ['subscribe'] }, - channel: { enum: ['orders'] }, - requestId: { type: 'string' }, - payload: { $ref: '/relayerApiOrdersChannelSubscribePayload' }, - }, - required: ['type', 'channel', 'requestId'], -}; - -export const relayerApiOrdersChannelSubscribePayload = { - id: '/relayerApiOrdersChannelSubscribePayload', - type: 'object', - properties: { - makerAssetProxyId: { $ref: '/hexSchema' }, - takerAssetProxyId: { $ref: '/hexSchema' }, - networkId: { type: 'number' }, - makerAssetAddress: { $ref: '/addressSchema' }, - takerAssetAddress: { $ref: '/addressSchema' }, - makerAssetData: { $ref: '/hexSchema' }, - takerAssetData: { $ref: '/hexSchema' }, - traderAssetData: { $ref: '/hexSchema' }, - }, -}; diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.json b/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.json new file mode 100644 index 000000000..239e7c586 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.json @@ -0,0 +1,11 @@ +{ + "id": "/relayerApiOrdersChannelUpdateSchema", + "type": "object", + "properties": { + "type": { "enum": ["update"] }, + "channel": { "enum": ["orders"] }, + "requestId": { "type": "string" }, + "payload": { "$ref": "/relayerApiOrdersSchema" } + }, + "required": ["type", "channel", "requestId"] +} diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts deleted file mode 100644 index 800b818e2..000000000 --- a/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const relayerApiOrdersChannelUpdateSchema = { - id: '/relayerApiOrdersChannelUpdateSchema', - type: 'object', - properties: { - type: { enum: ['update'] }, - channel: { enum: ['orders'] }, - requestId: { type: 'string' }, - payload: { $ref: '/relayerApiOrdersSchema' }, - }, - required: ['type', 'channel', 'requestId'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_orders_response_schema.json b/packages/json-schemas/schemas/relayer_api_orders_response_schema.json new file mode 100644 index 000000000..a5023a3fc --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orders_response_schema.json @@ -0,0 +1,13 @@ +{ + "id": "/relayerApiOrdersResponseSchema", + "type": "object", + "allOf": [ + { "$ref": "/paginatedCollectionSchema" }, + { + "properties": { + "records": { "$ref": "/relayerApiOrdersSchema" } + }, + "required": ["records"] + } + ] +} diff --git a/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts deleted file mode 100644 index c10d64ca9..000000000 --- a/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts +++ /dev/null @@ -1,13 +0,0 @@ -export const relayerApiOrdersResponseSchema = { - id: '/relayerApiOrdersResponseSchema', - type: 'object', - allOf: [ - { $ref: '/paginatedCollectionSchema' }, - { - properties: { - records: { $ref: '/relayerApiOrdersSchema' }, - }, - required: ['records'], - }, - ], -}; diff --git a/packages/json-schemas/schemas/relayer_api_orders_schema.json b/packages/json-schemas/schemas/relayer_api_orders_schema.json new file mode 100644 index 000000000..84e75cd04 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orders_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/relayerApiOrdersSchema", + "type": "array", + "items": { "$ref": "/relayerApiOrderSchema" } +} diff --git a/packages/json-schemas/schemas/relayer_api_orders_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_schema.ts deleted file mode 100644 index ba8ce4722..000000000 --- a/packages/json-schemas/schemas/relayer_api_orders_schema.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const relayerApiOrdersSchema = { - id: '/relayerApiOrdersSchema', - type: 'array', - items: { $ref: '/relayerApiOrderSchema' }, -}; diff --git a/packages/json-schemas/schemas/signed_order_schema.json b/packages/json-schemas/schemas/signed_order_schema.json new file mode 100644 index 000000000..137ae4a24 --- /dev/null +++ b/packages/json-schemas/schemas/signed_order_schema.json @@ -0,0 +1,12 @@ +{ + "id": "/signedOrderSchema", + "allOf": [ + { "$ref": "/orderSchema" }, + { + "properties": { + "signature": { "$ref": "/hexSchema" } + }, + "required": ["signature"] + } + ] +} diff --git a/packages/json-schemas/schemas/signed_orders_schema.json b/packages/json-schemas/schemas/signed_orders_schema.json new file mode 100644 index 000000000..e7c3a0b6c --- /dev/null +++ b/packages/json-schemas/schemas/signed_orders_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/signedOrdersSchema", + "type": "array", + "items": { "$ref": "/signedOrderSchema" } +} diff --git a/packages/json-schemas/schemas/signed_orders_schema.ts b/packages/json-schemas/schemas/signed_orders_schema.ts deleted file mode 100644 index e2a5aeb56..000000000 --- a/packages/json-schemas/schemas/signed_orders_schema.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const signedOrdersSchema = { - id: '/signedOrdersSchema', - type: 'array', - items: { $ref: '/signedOrderSchema' }, -}; diff --git a/packages/json-schemas/schemas/token_schema.json b/packages/json-schemas/schemas/token_schema.json new file mode 100644 index 000000000..31e41c4b8 --- /dev/null +++ b/packages/json-schemas/schemas/token_schema.json @@ -0,0 +1,11 @@ +{ + "id": "/tokenSchema", + "properties": { + "name": { "type": "string" }, + "symbol": { "type": "string" }, + "decimals": { "type": "number" }, + "address": { "$ref": "/addressSchema" } + }, + "required": ["name", "symbol", "decimals", "address"], + "type": "object" +} diff --git a/packages/json-schemas/schemas/token_schema.ts b/packages/json-schemas/schemas/token_schema.ts deleted file mode 100644 index a0b1ae27f..000000000 --- a/packages/json-schemas/schemas/token_schema.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const tokenSchema = { - id: '/tokenSchema', - properties: { - name: { type: 'string' }, - symbol: { type: 'string' }, - decimals: { type: 'number' }, - address: { $ref: '/addressSchema' }, - }, - required: ['name', 'symbol', 'decimals', 'address'], - type: 'object', -}; diff --git a/packages/json-schemas/schemas/tx_data_schema.json b/packages/json-schemas/schemas/tx_data_schema.json new file mode 100644 index 000000000..4643521ce --- /dev/null +++ b/packages/json-schemas/schemas/tx_data_schema.json @@ -0,0 +1,26 @@ +{ + "id": "/txDataSchema", + "properties": { + "from": { "$ref": "/addressSchema" }, + "to": { "$ref": "/addressSchema" }, + "value": { + "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] + }, + "gas": { + "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] + }, + "gasPrice": { + "oneOf": [{ "$ref": "/numberSchema" }, { "$ref": "/jsNumber" }] + }, + "data": { + "type": "string", + "pattern": "^0x[0-9a-f]*$" + }, + "nonce": { + "type": "number", + "minimum": 0 + } + }, + "required": ["from"], + "type": "object" +} diff --git a/packages/json-schemas/schemas/tx_data_schema.ts b/packages/json-schemas/schemas/tx_data_schema.ts deleted file mode 100644 index c57e18461..000000000 --- a/packages/json-schemas/schemas/tx_data_schema.ts +++ /dev/null @@ -1,32 +0,0 @@ -export const jsNumber = { - id: '/jsNumber', - type: 'number', - minimum: 0, -}; - -export const txDataSchema = { - id: '/txDataSchema', - properties: { - from: { $ref: '/addressSchema' }, - to: { $ref: '/addressSchema' }, - value: { - oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], - }, - gas: { - oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], - }, - gasPrice: { - oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], - }, - data: { - type: 'string', - pattern: '^0x[0-9a-f]*$', - }, - nonce: { - type: 'number', - minimum: 0, - }, - }, - required: ['from'], - type: 'object', -}; diff --git a/packages/json-schemas/schemas/whole_number_schema.json b/packages/json-schemas/schemas/whole_number_schema.json new file mode 100644 index 000000000..944ce820e --- /dev/null +++ b/packages/json-schemas/schemas/whole_number_schema.json @@ -0,0 +1,5 @@ +{ + "id": "/wholeNumberSchema", + "type": "string", + "pattern": "^\\d+$" +} diff --git a/packages/json-schemas/schemas/zero_ex_transaction_schema.json b/packages/json-schemas/schemas/zero_ex_transaction_schema.json new file mode 100644 index 000000000..0c714f14d --- /dev/null +++ b/packages/json-schemas/schemas/zero_ex_transaction_schema.json @@ -0,0 +1,10 @@ +{ + "id": "/zeroExTransactionSchema", + "properties": { + "data": { "$ref": "/hexSchema" }, + "signerAddress": { "$ref": "/addressSchema" }, + "salt": { "$ref": "/wholeNumberSchema" } + }, + "required": ["data", "salt", "signerAddress"], + "type": "object" +} diff --git a/packages/json-schemas/src/globals.d.ts b/packages/json-schemas/src/globals.d.ts deleted file mode 100644 index 94e63a32d..000000000 --- a/packages/json-schemas/src/globals.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -declare module '*.json' { - const json: any; - /* tslint:disable */ - export default json; - /* tslint:enable */ -} diff --git a/packages/json-schemas/src/monorepo_scripts/postpublish.ts b/packages/json-schemas/src/monorepo_scripts/postpublish.ts deleted file mode 100644 index dcb99d0f7..000000000 --- a/packages/json-schemas/src/monorepo_scripts/postpublish.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { postpublishUtils } from '@0xproject/monorepo-scripts'; - -import * as packageJSON from '../package.json'; -import * as tsConfigJSON from '../tsconfig.json'; - -const cwd = `${__dirname}/..`; -// tslint:disable-next-line:no-floating-promises -postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd); diff --git a/packages/json-schemas/src/monorepo_scripts/stage_docs.ts b/packages/json-schemas/src/monorepo_scripts/stage_docs.ts deleted file mode 100644 index e732ac8eb..000000000 --- a/packages/json-schemas/src/monorepo_scripts/stage_docs.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { postpublishUtils } from '@0xproject/monorepo-scripts'; - -import * as packageJSON from '../package.json'; -import * as tsConfigJSON from '../tsconfig.json'; - -const cwd = `${__dirname}/..`; -// tslint:disable-next-line:no-floating-promises -postpublishUtils.publishDocsToStagingAsync(packageJSON, tsConfigJSON, cwd); diff --git a/packages/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts index 3bc37f96b..8ece5de75 100644 --- a/packages/json-schemas/src/schemas.ts +++ b/packages/json-schemas/src/schemas.ts @@ -1,36 +1,41 @@ -import { addressSchema, hexSchema, numberSchema } from '../schemas/basic_type_schemas'; -import { blockParamSchema, blockRangeSchema } from '../schemas/block_range_schema'; -import { callDataSchema } from '../schemas/call_data_schema'; -import { ecSignatureParameterSchema, ecSignatureSchema } from '../schemas/ec_signature_schema'; -import { indexFilterValuesSchema } from '../schemas/index_filter_values_schema'; -import { orderCancellationRequestsSchema } from '../schemas/order_cancel_schema'; -import { orderFillOrKillRequestsSchema } from '../schemas/order_fill_or_kill_requests_schema'; -import { orderFillRequestsSchema } from '../schemas/order_fill_requests_schema'; -import { orderHashSchema } from '../schemas/order_hash_schema'; -import { orderSchema, signedOrderSchema } from '../schemas/order_schemas'; -import { ordersSchema } from '../schemas/orders_schema'; -import { paginatedCollectionSchema } from '../schemas/paginated_collection_schema'; -import { - relayerApiAssetDataPairsResponseSchema, - relayerApiAssetDataPairsSchema, - relayerApiAssetDataTradeInfoSchema, -} from '../schemas/relayer_api_asset_pairs_response_schema'; -import { relayerApiErrorResponseSchema } from '../schemas/relayer_api_error_response_schema'; -import { relayerApiFeeRecipientsResponseSchema } from '../schemas/relayer_api_fee_recipients_response_schema'; -import { relayerApiOrderConfigPayloadSchema } from '../schemas/relayer_api_order_config_payload_schema'; -import { relayerApiOrderConfigResponseSchema } from '../schemas/relayer_api_order_config_response_schema'; -import { relayerApiOrderSchema } from '../schemas/relayer_api_order_schema'; -import { relayerApiOrderbookResponseSchema } from '../schemas/relayer_api_orderbook_response_schema'; -import { - relayerApiOrdersChannelSubscribePayload, - relayerApiOrdersChannelSubscribeSchema, -} from '../schemas/relayer_api_orders_channel_subscribe_schema'; -import { relayerApiOrdersChannelUpdateSchema } from '../schemas/relayer_api_orders_channel_update_response_schema'; -import { relayerApiOrdersResponseSchema } from '../schemas/relayer_api_orders_response_schema'; -import { relayerApiOrdersSchema } from '../schemas/relayer_api_orders_schema'; -import { signedOrdersSchema } from '../schemas/signed_orders_schema'; -import { tokenSchema } from '../schemas/token_schema'; -import { jsNumber, txDataSchema } from '../schemas/tx_data_schema'; +import * as addressSchema from '../schemas/address_schema.json'; +import * as blockParamSchema from '../schemas/block_param_schema.json'; +import * as blockRangeSchema from '../schemas/block_range_schema.json'; +import * as callDataSchema from '../schemas/call_data_schema.json'; +import * as ecSignatureParameterSchema from '../schemas/ec_signature_parameter_schema.json'; +import * as ecSignatureSchema from '../schemas/ec_signature_schema.json'; +import * as eip712TypedDataSchema from '../schemas/eip712_typed_data_schema.json'; +import * as hexSchema from '../schemas/hex_schema.json'; +import * as indexFilterValuesSchema from '../schemas/index_filter_values_schema.json'; +import * as jsNumber from '../schemas/js_number.json'; +import * as numberSchema from '../schemas/number_schema.json'; +import * as orderCancellationRequestsSchema from '../schemas/order_cancel_schema.json'; +import * as orderFillOrKillRequestsSchema from '../schemas/order_fill_or_kill_requests_schema.json'; +import * as orderFillRequestsSchema from '../schemas/order_fill_requests_schema.json'; +import * as orderHashSchema from '../schemas/order_hash_schema.json'; +import * as orderSchema from '../schemas/order_schema.json'; +import * as ordersSchema from '../schemas/orders_schema.json'; +import * as paginatedCollectionSchema from '../schemas/paginated_collection_schema.json'; +import * as relayerApiAssetDataPairsResponseSchema from '../schemas/relayer_api_asset_data_pairs_response_schema.json'; +import * as relayerApiAssetDataPairsSchema from '../schemas/relayer_api_asset_data_pairs_schema.json'; +import * as relayerApiAssetDataTradeInfoSchema from '../schemas/relayer_api_asset_data_trade_info_schema.json'; +import * as relayerApiErrorResponseSchema from '../schemas/relayer_api_error_response_schema.json'; +import * as relayerApiFeeRecipientsResponseSchema from '../schemas/relayer_api_fee_recipients_response_schema.json'; +import * as relayerApiOrderConfigPayloadSchema from '../schemas/relayer_api_order_config_payload_schema.json'; +import * as relayerApiOrderConfigResponseSchema from '../schemas/relayer_api_order_config_response_schema.json'; +import * as relayerApiOrderSchema from '../schemas/relayer_api_order_schema.json'; +import * as relayerApiOrderbookResponseSchema from '../schemas/relayer_api_orderbook_response_schema.json'; +import * as relayerApiOrdersChannelSubscribePayloadSchema from '../schemas/relayer_api_orders_channel_subscribe_payload_schema.json'; +import * as relayerApiOrdersChannelSubscribeSchema from '../schemas/relayer_api_orders_channel_subscribe_schema.json'; +import * as relayerApiOrdersChannelUpdateSchema from '../schemas/relayer_api_orders_channel_update_response_schema.json'; +import * as relayerApiOrdersResponseSchema from '../schemas/relayer_api_orders_response_schema.json'; +import * as relayerApiOrdersSchema from '../schemas/relayer_api_orders_schema.json'; +import * as signedOrderSchema from '../schemas/signed_order_schema.json'; +import * as signedOrdersSchema from '../schemas/signed_orders_schema.json'; +import * as tokenSchema from '../schemas/token_schema.json'; +import * as txDataSchema from '../schemas/tx_data_schema.json'; +import * as wholeNumberSchema from '../schemas/whole_number_schema.json'; +import * as zeroExTransactionSchema from '../schemas/zero_ex_transaction_schema.json'; export const schemas = { numberSchema, @@ -39,6 +44,7 @@ export const schemas = { hexSchema, ecSignatureParameterSchema, ecSignatureSchema, + eip712TypedDataSchema, indexFilterValuesSchema, orderCancellationRequestsSchema, orderFillOrKillRequestsSchema, @@ -64,8 +70,10 @@ export const schemas = { relayerApiAssetDataPairsResponseSchema, relayerApiAssetDataTradeInfoSchema, relayerApiOrdersChannelSubscribeSchema, - relayerApiOrdersChannelSubscribePayload, + relayerApiOrdersChannelSubscribePayloadSchema, relayerApiOrdersChannelUpdateSchema, relayerApiOrdersResponseSchema, relayerApiAssetDataPairsSchema, + zeroExTransactionSchema, + wholeNumberSchema, }; diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index 4e0f66ef5..bfa2c5668 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -1,4 +1,4 @@ -import { BigNumber } from '@0xproject/utils'; +import { BigNumber } from '@0x/utils'; import * as chai from 'chai'; import * as dirtyChai from 'dirty-chai'; import forEach = require('lodash.foreach'); @@ -36,6 +36,7 @@ const { relayerApiOrdersChannelUpdateSchema, relayerApiOrdersResponseSchema, relayerApiOrderSchema, + wholeNumberSchema, } = schemas; describe('Schema', () => { @@ -73,6 +74,17 @@ describe('Schema', () => { 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]; diff --git a/packages/json-schemas/tsconfig.json b/packages/json-schemas/tsconfig.json index e35816553..7b14166c0 100644 --- a/packages/json-schemas/tsconfig.json +++ b/packages/json-schemas/tsconfig.json @@ -1,7 +1,49 @@ { "extends": "../../tsconfig", "compilerOptions": { - "outDir": "lib" + "outDir": "lib", + "rootDir": ".", + "resolveJsonModule": true }, - "include": ["./src/**/*", "./test/**/*"] + "include": ["./src/**/*", "./test/**/*"], + "files": [ + "./schemas/address_schema.json", + "./schemas/number_schema.json", + "./schemas/hex_schema.json", + "./schemas/block_param_schema.json", + "./schemas/block_range_schema.json", + "./schemas/call_data_schema.json", + "./schemas/ec_signature_parameter_schema.json", + "./schemas/ec_signature_schema.json", + "./schemas/eip712_typed_data_schema.json", + "./schemas/order_cancel_schema.json", + "./schemas/order_fill_or_kill_requests_schema.json", + "./schemas/order_fill_requests_schema.json", + "./schemas/order_hash_schema.json", + "./schemas/order_schema.json", + "./schemas/signed_order_schema.json", + "./schemas/orders_schema.json", + "./schemas/paginated_collection_schema.json", + "./schemas/relayer_api_asset_data_pairs_response_schema.json", + "./schemas/relayer_api_asset_data_pairs_schema.json", + "./schemas/relayer_api_asset_data_trade_info_schema.json", + "./schemas/relayer_api_error_response_schema.json", + "./schemas/relayer_api_fee_recipients_response_schema.json", + "./schemas/relayer_api_order_config_payload_schema.json", + "./schemas/relayer_api_order_config_response_schema.json", + "./schemas/relayer_api_order_schema.json", + "./schemas/relayer_api_orderbook_response_schema.json", + "./schemas/relayer_api_orders_channel_subscribe_payload_schema.json", + "./schemas/relayer_api_orders_channel_subscribe_schema.json", + "./schemas/relayer_api_orders_channel_update_response_schema.json", + "./schemas/relayer_api_orders_response_schema.json", + "./schemas/relayer_api_orders_schema.json", + "./schemas/signed_orders_schema.json", + "./schemas/token_schema.json", + "./schemas/js_number.json", + "./schemas/zero_ex_transaction_schema.json", + "./schemas/tx_data_schema.json", + "./schemas/index_filter_values_schema.json", + "./schemas/whole_number_schema.json" + ] } diff --git a/packages/json-schemas/tslint.json b/packages/json-schemas/tslint.json index ffaefe83a..dd9053357 100644 --- a/packages/json-schemas/tslint.json +++ b/packages/json-schemas/tslint.json @@ -1,3 +1,3 @@ { - "extends": ["@0xproject/tslint-config"] + "extends": ["@0x/tslint-config"] } diff --git a/packages/json-schemas/typedoc-tsconfig.json b/packages/json-schemas/typedoc-tsconfig.json new file mode 100644 index 000000000..c9b0af1ae --- /dev/null +++ b/packages/json-schemas/typedoc-tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../typedoc-tsconfig", + "compilerOptions": { + "outDir": "lib" + }, + "include": ["./src/**/*", "./test/**/*"] +} |