From e671563f1e8b9eb4015bd2b3034bad951ef3eda4 Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 30 Jul 2018 17:16:14 -0700 Subject: Update json-schemas for SRA v1 --- packages/json-schemas/CHANGELOG.json | 8 +++++ .../schemas/paginated_collection_schema.ts | 10 ++++++ .../relayer_api_asset_pairs_response_schema.ts | 38 ++++++++++++++++++++++ .../schemas/relayer_api_fees_payload_schema.ts | 24 -------------- .../schemas/relayer_api_fees_response_schema.ts | 10 ------ ...layer_api_orberbook_channel_subscribe_schema.ts | 23 ------------- .../relayer_api_order_config_payload_schema.ts | 24 ++++++++++++++ .../relayer_api_order_config_response_schema.ts | 11 +++++++ .../schemas/relayer_api_order_schema.ts | 9 +++++ ...elayer_api_orderbook_channel_snapshot_schema.ts | 21 ------------ ...api_orderbook_channel_update_response_schema.ts | 11 ------- .../relayer_api_orderbook_response_schema.ts | 4 +-- .../relayer_api_orders_channel_subscribe_schema.ts | 26 +++++++++++++++ ...er_api_orders_channel_update_response_schema.ts | 11 +++++++ .../schemas/relayer_api_orders_response_schema.ts | 13 ++++++++ .../schemas/relayer_api_orders_schema.ts | 5 +++ .../relayer_api_token_pairs_response_schema.ts | 24 -------------- 17 files changed, 157 insertions(+), 115 deletions(-) create mode 100644 packages/json-schemas/schemas/paginated_collection_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts delete mode 100644 packages/json-schemas/schemas/relayer_api_fees_payload_schema.ts delete mode 100644 packages/json-schemas/schemas/relayer_api_fees_response_schema.ts delete mode 100644 packages/json-schemas/schemas/relayer_api_orberbook_channel_subscribe_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_order_schema.ts delete mode 100644 packages/json-schemas/schemas/relayer_api_orderbook_channel_snapshot_schema.ts delete mode 100644 packages/json-schemas/schemas/relayer_api_orderbook_channel_update_response_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_orders_response_schema.ts create mode 100644 packages/json-schemas/schemas/relayer_api_orders_schema.ts delete mode 100644 packages/json-schemas/schemas/relayer_api_token_pairs_response_schema.ts (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/CHANGELOG.json b/packages/json-schemas/CHANGELOG.json index 31da6a7f7..d4557d872 100644 --- a/packages/json-schemas/CHANGELOG.json +++ b/packages/json-schemas/CHANGELOG.json @@ -1,4 +1,12 @@ [ + { + "version": "2.0.0", + "changes": [ + { + "note": "Upgrade Relayer API schemas for relayer API V1" + } + ] + }, { "version": "1.0.1-rc.3", "changes": [ diff --git a/packages/json-schemas/schemas/paginated_collection_schema.ts b/packages/json-schemas/schemas/paginated_collection_schema.ts new file mode 100644 index 000000000..5dd82ab3d --- /dev/null +++ b/packages/json-schemas/schemas/paginated_collection_schema.ts @@ -0,0 +1,10 @@ +export const paginatedCollectionSchema = { + id: '/PaginatedCollection', + type: 'object', + properties: { + total: { $ref: '/Number' }, + per_page: { $ref: '/Number' }, + page: { $ref: '/Number' }, + }, + required: ['total', 'per_page', 'page'], +}; 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 new file mode 100644 index 000000000..74b919a8f --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts @@ -0,0 +1,38 @@ +export const relayerApiAssetDataPairsResponseSchema = { + id: '/RelayerApiAssetDataPairsResponse', + type: 'object', + allOf: [ + { $ref: '/PaginatedCollection' }, + { + properties: { + records: { $ref: '/RelayerApiAssetDataPairs' }, + }, + required: ['records'], + }, + ], +}; + +export const relayerApiAssetDataPairsSchema = { + id: '/RelayerApiAssetDataPairs', + type: 'array', + items: { + properties: { + assetDataA: { $ref: '/RelayerApiAssetDataTradeInfo' }, + assetDataB: { $ref: '/RelayerApiAssetDataTradeInfo' }, + }, + required: ['assetDataA', 'assetDataB'], + type: 'object', + }, +}; + +export const relayerApiAssetDataTradeInfoSchema = { + id: '/RelayerApiAssetDataTradeInfo', + type: 'object', + properties: { + assetData: { $ref: '/Hex' }, + minAmount: { $ref: '/Number' }, + maxAmount: { $ref: '/Number' }, + precision: { type: 'number' }, + }, + required: ['assetData'], +}; diff --git a/packages/json-schemas/schemas/relayer_api_fees_payload_schema.ts b/packages/json-schemas/schemas/relayer_api_fees_payload_schema.ts deleted file mode 100644 index eaaf777a1..000000000 --- a/packages/json-schemas/schemas/relayer_api_fees_payload_schema.ts +++ /dev/null @@ -1,24 +0,0 @@ -export const relayerApiFeesPayloadSchema = { - id: '/RelayerApiFeesPayload', - type: 'object', - properties: { - exchangeContractAddress: { $ref: '/Address' }, - maker: { $ref: '/Address' }, - taker: { $ref: '/Address' }, - makerTokenAddress: { $ref: '/Address' }, - takerTokenAddress: { $ref: '/Address' }, - makerTokenAmount: { $ref: '/Number' }, - takerTokenAmount: { $ref: '/Number' }, - expirationUnixTimestampSec: { $ref: '/Number' }, - salt: { $ref: '/Number' }, - }, - required: [ - 'exchangeContractAddress', - 'maker', - 'taker', - 'makerTokenAddress', - 'takerTokenAddress', - 'expirationUnixTimestampSec', - 'salt', - ], -}; diff --git a/packages/json-schemas/schemas/relayer_api_fees_response_schema.ts b/packages/json-schemas/schemas/relayer_api_fees_response_schema.ts deleted file mode 100644 index e7440613f..000000000 --- a/packages/json-schemas/schemas/relayer_api_fees_response_schema.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const relayerApiFeesResponseSchema = { - id: '/RelayerApiFeesResponse', - type: 'object', - properties: { - makerFee: { $ref: '/Number' }, - takerFee: { $ref: '/Number' }, - feeRecipient: { $ref: '/Address' }, - }, - required: ['makerFee', 'takerFee', 'feeRecipient'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_orberbook_channel_subscribe_schema.ts b/packages/json-schemas/schemas/relayer_api_orberbook_channel_subscribe_schema.ts deleted file mode 100644 index d93fa73d6..000000000 --- a/packages/json-schemas/schemas/relayer_api_orberbook_channel_subscribe_schema.ts +++ /dev/null @@ -1,23 +0,0 @@ -export const relayerApiOrderbookChannelSubscribeSchema = { - id: '/RelayerApiOrderbookChannelSubscribe', - type: 'object', - properties: { - type: { enum: ['subscribe'] }, - channel: { enum: ['orderbook'] }, - requestId: { type: 'number' }, - payload: { $ref: '/RelayerApiOrderbookChannelSubscribePayload' }, - }, - required: ['type', 'channel', 'requestId', 'payload'], -}; - -export const relayerApiOrderbookChannelSubscribePayload = { - id: '/RelayerApiOrderbookChannelSubscribePayload', - type: 'object', - properties: { - baseTokenAddress: { $ref: '/Address' }, - quoteTokenAddress: { $ref: '/Address' }, - snapshot: { type: 'boolean' }, - limit: { type: 'number' }, - }, - required: ['baseTokenAddress', 'quoteTokenAddress'], -}; 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 new file mode 100644 index 000000000..7b4a88e84 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts @@ -0,0 +1,24 @@ +export const relayerApiOrderConfigPayloadSchema = { + id: '/RelayerApiOrderConfigPayload', + type: 'object', + properties: { + makerAddress: { $ref: '/Address' }, + takerAddress: { $ref: '/Address' }, + makerAssetAmount: { $ref: '/Number' }, + takerAssetAmount: { $ref: '/Number' }, + makerAssetData: { $ref: '/Hex' }, + takerAssetData: { $ref: '/Hex' }, + exchangeAddress: { $ref: '/Address' }, + expirationTimeSeconds: { $ref: '/Number' }, + }, + required: [ + 'makerAddress', + 'takerAddress', + 'makerAssetAmount', + 'takerAssetAmount', + 'makerAssetData', + 'takerAssetData', + 'exchangeAddress', + 'expirationTimeSeconds', + ], +}; 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 new file mode 100644 index 000000000..d7960cd9d --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts @@ -0,0 +1,11 @@ +export const relayerApiOrderConfigResponseSchema = { + id: '/RelayerApiOrderConfigResponse', + type: 'object', + properties: { + makerFee: { $ref: '/Number' }, + takerFee: { $ref: '/Number' }, + feeRecipientAddress: { $ref: '/Address' }, + senderAddress: { $ref: '/Address' }, + }, + required: ['makerFee', 'takerFee', 'feeRecipientAddress', 'senderAddress'], +}; diff --git a/packages/json-schemas/schemas/relayer_api_order_schema.ts b/packages/json-schemas/schemas/relayer_api_order_schema.ts new file mode 100644 index 000000000..4e138af12 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_order_schema.ts @@ -0,0 +1,9 @@ +export const relayerApiOrderSchema = { + id: '/RelayerApiOrder', + type: 'object', + properties: { + order: { $ref: '/Order' }, + remainingFillableAmount: { $ref: '/Number' }, + }, + required: ['order', 'remainingFillableAmount'], +}; diff --git a/packages/json-schemas/schemas/relayer_api_orderbook_channel_snapshot_schema.ts b/packages/json-schemas/schemas/relayer_api_orderbook_channel_snapshot_schema.ts deleted file mode 100644 index fe1510d5b..000000000 --- a/packages/json-schemas/schemas/relayer_api_orderbook_channel_snapshot_schema.ts +++ /dev/null @@ -1,21 +0,0 @@ -export const relayerApiOrderbookChannelSnapshotSchema = { - id: '/RelayerApiOrderbookChannelSnapshot', - type: 'object', - properties: { - type: { enum: ['snapshot'] }, - channel: { enum: ['orderbook'] }, - requestId: { type: 'number' }, - payload: { $ref: '/RelayerApiOrderbookChannelSnapshotPayload' }, - }, - required: ['type', 'channel', 'requestId', 'payload'], -}; - -export const relayerApiOrderbookChannelSnapshotPayload = { - id: '/RelayerApiOrderbookChannelSnapshotPayload', - type: 'object', - properties: { - bids: { $ref: '/signedOrdersSchema' }, - asks: { $ref: '/signedOrdersSchema' }, - }, - required: ['bids', 'asks'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_orderbook_channel_update_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orderbook_channel_update_response_schema.ts deleted file mode 100644 index 9a6d83d4c..000000000 --- a/packages/json-schemas/schemas/relayer_api_orderbook_channel_update_response_schema.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const relayerApiOrderbookChannelUpdateSchema = { - id: '/RelayerApiOrderbookChannelUpdate', - type: 'object', - properties: { - type: { enum: ['update'] }, - channel: { enum: ['orderbook'] }, - requestId: { type: 'number' }, - payload: { $ref: '/SignedOrder' }, - }, - required: ['type', 'channel', 'requestId', 'payload'], -}; diff --git a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts index 5c409c807..f311908db 100644 --- a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts +++ b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts @@ -2,8 +2,8 @@ export const relayerApiOrderBookResponseSchema = { id: '/RelayerApiOrderBookResponse', type: 'object', properties: { - bids: { $ref: '/signedOrdersSchema' }, - asks: { $ref: '/signedOrdersSchema' }, + bids: { $ref: '/RelayerApiOrdersResponse' }, + asks: { $ref: '/RelayerApiOrdersResponse' }, }, required: ['bids', 'asks'], }; 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 new file mode 100644 index 000000000..1fe612949 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts @@ -0,0 +1,26 @@ +export const relayerApiOrdersChannelSubscribeSchema = { + id: '/RelayerApiOrdersChannelSubscribe', + 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: '/Address' }, + takerAssetProxyId: { $ref: '/Address' }, + networkId: { type: 'number' }, + makerAssetAddress: { $ref: '/Address' }, + takerAssetAddress: { $ref: '/Address' }, + makerAssetData: { $ref: '/Hex' }, + takerAssetData: { $ref: '/Hex' }, + traderAssetData: { $ref: '/Hex' }, + }, +}; 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 new file mode 100644 index 000000000..38306391b --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts @@ -0,0 +1,11 @@ +export const relayerApiOrdersChannelUpdateSchema = { + id: '/RelayerApiOrdersChannelUpdate', + type: 'object', + properties: { + type: { enum: ['update'] }, + channel: { enum: ['orders'] }, + requestId: { type: 'string' }, + payload: { $ref: '/RelayerApiOrders' }, + }, + required: ['type', 'channel', 'requestId', 'payload'], +}; diff --git a/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts new file mode 100644 index 000000000..4bef260c1 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts @@ -0,0 +1,13 @@ +export const relayerApiOrdersResponseSchema = { + id: '/RelayerApiOrdersResponse', + type: 'object', + allOf: [ + { $ref: '/PaginatedCollection' }, + { + properties: { + records: { $ref: '/RelayerApiOrders' }, + }, + required: ['records'], + }, + ], +}; diff --git a/packages/json-schemas/schemas/relayer_api_orders_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_schema.ts new file mode 100644 index 000000000..da739a300 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_orders_schema.ts @@ -0,0 +1,5 @@ +export const relayerApiOrdersSchema = { + id: '/RelayerApiOrders', + type: 'array', + items: { $ref: '/RelayerApiOrder' }, +}; diff --git a/packages/json-schemas/schemas/relayer_api_token_pairs_response_schema.ts b/packages/json-schemas/schemas/relayer_api_token_pairs_response_schema.ts deleted file mode 100644 index 5009c7955..000000000 --- a/packages/json-schemas/schemas/relayer_api_token_pairs_response_schema.ts +++ /dev/null @@ -1,24 +0,0 @@ -export const relayerApiTokenPairsResponseSchema = { - id: '/RelayerApiTokenPairsResponse', - type: 'array', - items: { - properties: { - tokenA: { $ref: '/RelayerApiTokenTradeInfo' }, - tokenB: { $ref: '/RelayerApiTokenTradeInfo' }, - }, - required: ['tokenA', 'tokenB'], - type: 'object', - }, -}; - -export const relayerApiTokenTradeInfoSchema = { - id: '/RelayerApiTokenTradeInfo', - type: 'object', - properties: { - address: { $ref: '/Address' }, - minAmount: { $ref: '/Number' }, - maxAmount: { $ref: '/Number' }, - precision: { type: 'number' }, - }, - required: ['address'], -}; -- cgit v1.2.3 From 162fe797fcd4c41d8d84184ca5c0352c8342937b Mon Sep 17 00:00:00 2001 From: fragosti Date: Mon, 30 Jul 2018 17:53:01 -0700 Subject: Update schemas export --- packages/json-schemas/src/schemas.ts | 40 +++++++++++++++--------------------- 1 file changed, 17 insertions(+), 23 deletions(-) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts index 8b7c538ed..a06729617 100644 --- a/packages/json-schemas/src/schemas.ts +++ b/packages/json-schemas/src/schemas.ts @@ -9,23 +9,19 @@ 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 { relayerApiErrorResponseSchema } from '../schemas/relayer_api_error_response_schema'; -import { relayerApiFeesPayloadSchema } from '../schemas/relayer_api_fees_payload_schema'; -import { relayerApiFeesResponseSchema } from '../schemas/relayer_api_fees_response_schema'; -import { - relayerApiOrderbookChannelSubscribePayload, - relayerApiOrderbookChannelSubscribeSchema, -} from '../schemas/relayer_api_orberbook_channel_subscribe_schema'; import { - relayerApiOrderbookChannelSnapshotPayload, - relayerApiOrderbookChannelSnapshotSchema, -} from '../schemas/relayer_api_orderbook_channel_snapshot_schema'; -import { relayerApiOrderbookChannelUpdateSchema } from '../schemas/relayer_api_orderbook_channel_update_response_schema'; + relayerApiAssetDataPairsResponseSchema, + relayerApiAssetDataTradeInfoSchema, +} from '../schemas/relayer_api_asset_pairs_response_schema'; +import { relayerApiErrorResponseSchema } from '../schemas/relayer_api_error_response_schema'; +import { relayerApiOrderConfigPayloadSchema } from '../schemas/relayer_api_order_config_payload_schema'; +import { relayerApiOrderConfigResponseSchema } from '../schemas/relayer_api_order_config_response_schema'; import { relayerApiOrderBookResponseSchema } from '../schemas/relayer_api_orderbook_response_schema'; import { - relayerApiTokenPairsResponseSchema, - relayerApiTokenTradeInfoSchema, -} from '../schemas/relayer_api_token_pairs_response_schema'; + relayerApiOrdersChannelSubscribePayload, + relayerApiOrdersChannelSubscribeSchema, +} from '../schemas/relayer_api_orders_channel_subscribe_schema'; +import { relayerApiOrdersChannelUpdateSchema } from '../schemas/relayer_api_orders_channel_update_response_schema'; import { signedOrdersSchema } from '../schemas/signed_orders_schema'; import { tokenSchema } from '../schemas/token_schema'; import { jsNumber, txDataSchema } from '../schemas/tx_data_schema'; @@ -52,14 +48,12 @@ export const schemas = { jsNumber, txDataSchema, relayerApiErrorResponseSchema, - relayerApiFeesPayloadSchema, - relayerApiFeesResponseSchema, + relayerApiOrderConfigPayloadSchema, + relayerApiOrderConfigResponseSchema, relayerApiOrderBookResponseSchema, - relayerApiTokenPairsResponseSchema, - relayerApiTokenTradeInfoSchema, - relayerApiOrderbookChannelSubscribeSchema, - relayerApiOrderbookChannelSubscribePayload, - relayerApiOrderbookChannelUpdateSchema, - relayerApiOrderbookChannelSnapshotSchema, - relayerApiOrderbookChannelSnapshotPayload, + relayerApiAssetPairsResponseSchema, + relayerApiAssetTradeInfoSchema, + relayerApiOrdersChannelSubscribeSchema, + relayerApiOrdersChannelSubscribePayload, + relayerApiOrdersChannelUpdateSchema, }; -- cgit v1.2.3 From 4aff9515d807feb5fc30431d109d503a6c52f0cd Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 31 Jul 2018 16:37:51 -0700 Subject: Get schema tests running (not crashiing) --- .../schemas/paginated_collection_schema.ts | 4 +- packages/json-schemas/src/schemas.ts | 12 +- packages/json-schemas/test/schema_test.ts | 205 ++++++--------------- 3 files changed, 65 insertions(+), 156 deletions(-) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/schemas/paginated_collection_schema.ts b/packages/json-schemas/schemas/paginated_collection_schema.ts index 5dd82ab3d..2c29ef4e0 100644 --- a/packages/json-schemas/schemas/paginated_collection_schema.ts +++ b/packages/json-schemas/schemas/paginated_collection_schema.ts @@ -3,8 +3,8 @@ export const paginatedCollectionSchema = { type: 'object', properties: { total: { $ref: '/Number' }, - per_page: { $ref: '/Number' }, + perPage: { $ref: '/Number' }, page: { $ref: '/Number' }, }, - required: ['total', 'per_page', 'page'], + required: ['total', 'perPage', 'page'], }; diff --git a/packages/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts index a06729617..defe55bda 100644 --- a/packages/json-schemas/src/schemas.ts +++ b/packages/json-schemas/src/schemas.ts @@ -9,6 +9,7 @@ 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, relayerApiAssetDataTradeInfoSchema, @@ -22,6 +23,9 @@ import { 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 { relayerApiOrderSchema } from '../schemas/relayer_api_order_schema'; import { signedOrdersSchema } from '../schemas/signed_orders_schema'; import { tokenSchema } from '../schemas/token_schema'; import { jsNumber, txDataSchema } from '../schemas/tx_data_schema'; @@ -47,13 +51,17 @@ export const schemas = { tokenSchema, jsNumber, txDataSchema, + paginatedCollectionSchema, relayerApiErrorResponseSchema, + relayerApiOrderSchema, + relayerApiOrdersSchema, relayerApiOrderConfigPayloadSchema, relayerApiOrderConfigResponseSchema, relayerApiOrderBookResponseSchema, - relayerApiAssetPairsResponseSchema, - relayerApiAssetTradeInfoSchema, + relayerApiAssetDataPairsResponseSchema, + relayerApiAssetDataTradeInfoSchema, relayerApiOrdersChannelSubscribeSchema, relayerApiOrdersChannelSubscribePayload, relayerApiOrdersChannelUpdateSchema, + relayerApiOrdersResponseSchema, }; diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index d202b5643..a6bbf12e6 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -26,14 +26,15 @@ const { tokenSchema, jsNumber, txDataSchema, + paginatedCollectionSchema, relayerApiErrorResponseSchema, relayerApiOrderBookResponseSchema, - relayerApiTokenPairsResponseSchema, - relayerApiFeesPayloadSchema, - relayerApiFeesResponseSchema, - relayerApiOrderbookChannelSubscribeSchema, - relayerApiOrderbookChannelUpdateSchema, - relayerApiOrderbookChannelSnapshotSchema, + relayerApiAssetDataPairsResponseSchema, + relayerApiOrderConfigPayloadSchema, + relayerApiOrderConfigResponseSchema, + relayerApiOrdersChannelSubscribeSchema, + relayerApiOrdersChannelUpdateSchema, + relayerApiOrdersResponseSchema, } = schemas; describe('Schema', () => { @@ -328,7 +329,7 @@ describe('Schema', () => { asks: [signedOrder, signedOrder], }, ]; - validateAgainstSchema(testCases, relayerApiOrderBookResponseSchema); + validateAgainstSchema(testCases, relayerApiOrdersResponseSchema); }); it('should fail for invalid order fill requests', () => { const testCases = [ @@ -349,16 +350,16 @@ describe('Schema', () => { }, ]; const shouldFail = true; - validateAgainstSchema(testCases, relayerApiOrderBookResponseSchema, shouldFail); + validateAgainstSchema(testCases, relayerApiOrdersResponseSchema, shouldFail); }); }); - describe('#relayerApiOrderbookChannelSubscribeSchema', () => { - it('should validate valid orderbook channel websocket subscribe message', () => { + describe('#relayerApiOrdersChannelSubscribeSchema', () => { + it('should validate valid orders channel websocket subscribe message', () => { const testCases = [ { type: 'subscribe', - channel: 'orderbook', - requestId: 1, + channel: 'orders', + requestId: 'randomId', payload: { baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', @@ -368,22 +369,22 @@ describe('Schema', () => { }, { type: 'subscribe', - channel: 'orderbook', - requestId: 1, + channel: 'orders', + requestId: 'randomId', payload: { baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', }, }, ]; - validateAgainstSchema(testCases, relayerApiOrderbookChannelSubscribeSchema); + validateAgainstSchema(testCases, relayerApiOrdersChannelSubscribeSchema); }); - it('should fail for invalid orderbook channel websocket subscribe message', () => { + it('should fail for invalid orders channel websocket subscribe message', () => { const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; const testCases = [ { type: 'subscribe', - channel: 'orderbook', + channel: 'orders', payload: { baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', @@ -393,8 +394,8 @@ describe('Schema', () => { }, { type: 'foo', - channel: 'orderbook', - requestId: 1, + channel: 'orders', + requestId: 'randomId', payload: { baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', @@ -403,7 +404,7 @@ describe('Schema', () => { { type: 'subscribe', channel: 'bar', - requestId: 1, + requestId: 'randomId', payload: { baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', @@ -411,8 +412,8 @@ describe('Schema', () => { }, { type: 'subscribe', - channel: 'orderbook', - requestId: 1, + channel: 'orders', + requestId: 'randomId', payload: { baseTokenAddress: checksummedAddress, quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', @@ -420,8 +421,8 @@ describe('Schema', () => { }, { type: 'subscribe', - channel: 'orderbook', - requestId: 1, + channel: 'orders', + requestId: 'randomId', payload: { baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', quoteTokenAddress: checksummedAddress, @@ -429,24 +430,24 @@ describe('Schema', () => { }, { type: 'subscribe', - channel: 'orderbook', - requestId: 1, + channel: 'orders', + requestId: 'randomId', payload: { quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', }, }, { type: 'subscribe', - channel: 'orderbook', - requestId: 1, + channel: 'orders', + requestId: 'randomId', payload: { baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', }, }, { type: 'subscribe', - channel: 'orderbook', - requestId: 1, + channel: 'orders', + requestId: 'randomId', payload: { baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', @@ -456,8 +457,8 @@ describe('Schema', () => { }, { type: 'subscribe', - channel: 'orderbook', - requestId: 1, + channel: 'orders', + requestId: 'randomId', payload: { baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', @@ -467,126 +468,26 @@ describe('Schema', () => { }, ]; const shouldFail = true; - validateAgainstSchema(testCases, relayerApiOrderbookChannelSubscribeSchema, shouldFail); + validateAgainstSchema(testCases, relayerApiOrdersChannelSubscribeSchema, shouldFail); }); }); - describe('#relayerApiOrderbookChannelSnapshotSchema', () => { - it('should validate valid orderbook channel websocket snapshot message', () => { - const testCases = [ - { - type: 'snapshot', - channel: 'orderbook', - requestId: 2, - payload: { - bids: [], - asks: [], - }, - }, - { - type: 'snapshot', - channel: 'orderbook', - requestId: 2, - payload: { - bids: [signedOrder], - asks: [signedOrder], - }, - }, - ]; - validateAgainstSchema(testCases, relayerApiOrderbookChannelSnapshotSchema); - }); - it('should fail for invalid orderbook channel websocket snapshot message', () => { - const testCases = [ - { - type: 'foo', - channel: 'orderbook', - requestId: 2, - payload: { - bids: [signedOrder], - asks: [signedOrder], - }, - }, - { - type: 'snapshot', - channel: 'bar', - requestId: 2, - payload: { - bids: [signedOrder], - asks: [signedOrder], - }, - }, - { - type: 'snapshot', - channel: 'orderbook', - payload: { - bids: [signedOrder], - asks: [signedOrder], - }, - }, - { - type: 'snapshot', - channel: 'orderbook', - requestId: '2', - payload: { - bids: [signedOrder], - asks: [signedOrder], - }, - }, - { - type: 'snapshot', - channel: 'orderbook', - requestId: 2, - payload: { - bids: [signedOrder], - }, - }, - { - type: 'snapshot', - channel: 'orderbook', - requestId: 2, - payload: { - asks: [signedOrder], - }, - }, - { - type: 'snapshot', - channel: 'orderbook', - requestId: 2, - payload: { - bids: [signedOrder], - asks: [{}], - }, - }, - { - type: 'snapshot', - channel: 'orderbook', - requestId: 2, - payload: { - bids: [{}], - asks: [signedOrder], - }, - }, - ]; - const shouldFail = true; - validateAgainstSchema(testCases, relayerApiOrderbookChannelSnapshotSchema, shouldFail); - }); - }); - describe('#relayerApiOrderbookChannelUpdateSchema', () => { - it('should validate valid orderbook channel websocket update message', () => { + describe('#relayerApiOrdersChannelUpdateSchema', () => { + it('should validate valid orders channel websocket update message', () => { const testCases = [ { type: 'update', - channel: 'orderbook', + channel: 'orders', requestId: 2, payload: signedOrder, }, ]; - validateAgainstSchema(testCases, relayerApiOrderbookChannelUpdateSchema); + validateAgainstSchema(testCases, relayerApiOrdersChannelUpdateSchema); }); - it('should fail for invalid orderbook channel websocket update message', () => { + it('should fail for invalid orders channel websocket update message', () => { const testCases = [ { type: 'foo', - channel: 'orderbook', + channel: 'orders', requestId: 2, payload: signedOrder, }, @@ -598,13 +499,13 @@ describe('Schema', () => { }, { type: 'update', - channel: 'orderbook', + channel: 'orders', requestId: 2, payload: {}, }, ]; const shouldFail = true; - validateAgainstSchema(testCases, relayerApiOrderbookChannelUpdateSchema, shouldFail); + validateAgainstSchema(testCases, relayerApiOrdersChannelUpdateSchema, shouldFail); }); }); }); @@ -684,7 +585,7 @@ describe('Schema', () => { validateAgainstSchema(testCases, relayerApiErrorResponseSchema, shouldFail); }); }); - describe('#relayerApiFeesPayloadSchema', () => { + describe('#relayerApiOrderConfigPayloadSchema', () => { it('should validate valid fees payloads', () => { const testCases = [ { @@ -699,7 +600,7 @@ describe('Schema', () => { salt: '67006738228878699843088602623665307406148487219438534730168799356281242528500', }, ]; - validateAgainstSchema(testCases, relayerApiFeesPayloadSchema); + validateAgainstSchema(testCases, relayerApiOrderConfigPayloadSchema); }); it('should fail for invalid fees payloads', () => { const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; @@ -725,10 +626,10 @@ describe('Schema', () => { }, ]; const shouldFail = true; - validateAgainstSchema(testCases, relayerApiFeesPayloadSchema, shouldFail); + validateAgainstSchema(testCases, relayerApiOrderConfigPayloadSchema, shouldFail); }); }); - describe('#relayerApiFeesResponseSchema', () => { + describe('#relayerApiOrderConfigResponseSchema', () => { it('should validate valid fees responses', () => { const testCases = [ { @@ -737,7 +638,7 @@ describe('Schema', () => { feeRecipient: '0x323b5d4c32345ced77393b3530b1eed0f346429d', }, ]; - validateAgainstSchema(testCases, relayerApiFeesResponseSchema); + validateAgainstSchema(testCases, relayerApiOrderConfigResponseSchema); }); it('should fail for invalid fees responses', () => { const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; @@ -755,11 +656,11 @@ describe('Schema', () => { }, ]; const shouldFail = true; - validateAgainstSchema(testCases, relayerApiFeesResponseSchema, shouldFail); + validateAgainstSchema(testCases, relayerApiOrderConfigResponseSchema, shouldFail); }); }); - describe('#relayerApiTokenPairsResponseSchema', () => { - it('should validate valid tokenPairs response', () => { + describe('#relayerAssetDataPairsResponseSchema', () => { + it('should validate valid assetPairs response', () => { const testCases = [ [], [ @@ -789,9 +690,9 @@ describe('Schema', () => { }, ], ]; - validateAgainstSchema(testCases, relayerApiTokenPairsResponseSchema); + validateAgainstSchema(testCases, relayerApiAssetDataPairsResponseSchema); }); - it('should fail for invalid tokenPairs responses', () => { + it('should fail for invalid assetPairs responses', () => { const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; const testCases = [ [ @@ -832,7 +733,7 @@ describe('Schema', () => { ], ]; const shouldFail = true; - validateAgainstSchema(testCases, relayerApiTokenPairsResponseSchema, shouldFail); + validateAgainstSchema(testCases, relayerApiAssetDataPairsResponseSchema, shouldFail); }); }); describe('#jsNumberSchema', () => { -- cgit v1.2.3 From 63e869f6d01663a22773d244920362921dbcdcdc Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 31 Jul 2018 17:04:22 -0700 Subject: Add paginated collection test case --- .../schemas/paginated_collection_schema.ts | 6 ++--- packages/json-schemas/src/schemas.ts | 2 +- packages/json-schemas/test/schema_test.ts | 30 +++++++++++++++++++++- 3 files changed, 33 insertions(+), 5 deletions(-) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/schemas/paginated_collection_schema.ts b/packages/json-schemas/schemas/paginated_collection_schema.ts index 2c29ef4e0..abd86f1ef 100644 --- a/packages/json-schemas/schemas/paginated_collection_schema.ts +++ b/packages/json-schemas/schemas/paginated_collection_schema.ts @@ -2,9 +2,9 @@ export const paginatedCollectionSchema = { id: '/PaginatedCollection', type: 'object', properties: { - total: { $ref: '/Number' }, - perPage: { $ref: '/Number' }, - page: { $ref: '/Number' }, + total: { type: 'number' }, + perPage: { type: 'number' }, + page: { type: 'number' }, }, required: ['total', 'perPage', 'page'], }; diff --git a/packages/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts index defe55bda..97aa486f2 100644 --- a/packages/json-schemas/src/schemas.ts +++ b/packages/json-schemas/src/schemas.ts @@ -17,6 +17,7 @@ import { import { relayerApiErrorResponseSchema } from '../schemas/relayer_api_error_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, @@ -25,7 +26,6 @@ import { 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 { relayerApiOrderSchema } from '../schemas/relayer_api_order_schema'; import { signedOrdersSchema } from '../schemas/signed_orders_schema'; import { tokenSchema } from '../schemas/token_schema'; import { jsNumber, txDataSchema } from '../schemas/tx_data_schema'; diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index a6bbf12e6..03c0e950b 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -167,6 +167,34 @@ describe('Schema', () => { validateAgainstSchema(testCases, tokenSchema, shouldFail); }); }); + describe('#paginatedCollectionSchema', () => { + const paginatedResponse = { + total: 100, + perPage: 10, + page: 3, + }; + 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, @@ -329,7 +357,7 @@ describe('Schema', () => { asks: [signedOrder, signedOrder], }, ]; - validateAgainstSchema(testCases, relayerApiOrdersResponseSchema); + validateAgainstSchema(testCases, relayerApiOrderBookResponseSchema); }); it('should fail for invalid order fill requests', () => { const testCases = [ -- cgit v1.2.3 From a78d35f84ee896e70385476fcc8ee2c9db9931bd Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 31 Jul 2018 17:22:26 -0700 Subject: Add test for relayerApiOrderSchema --- packages/json-schemas/schemas/orders_schema.ts | 2 +- ...relayer_api_orders_channel_update_response_schema.ts | 2 +- packages/json-schemas/schemas/signed_orders_schema.ts | 2 +- packages/json-schemas/test/schema_test.ts | 17 +++++++++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/schemas/orders_schema.ts b/packages/json-schemas/schemas/orders_schema.ts index 3ba3291a2..73816a57e 100644 --- a/packages/json-schemas/schemas/orders_schema.ts +++ b/packages/json-schemas/schemas/orders_schema.ts @@ -1,5 +1,5 @@ export const ordersSchema = { - id: '/ordersSchema', + id: '/OrdersSchema', type: 'array', items: { $ref: '/Order' }, }; 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 index 38306391b..31f5ab389 100644 --- 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 @@ -7,5 +7,5 @@ export const relayerApiOrdersChannelUpdateSchema = { requestId: { type: 'string' }, payload: { $ref: '/RelayerApiOrders' }, }, - required: ['type', 'channel', 'requestId', 'payload'], + required: ['type', 'channel', 'requestId'], }; diff --git a/packages/json-schemas/schemas/signed_orders_schema.ts b/packages/json-schemas/schemas/signed_orders_schema.ts index 34d956836..164201f76 100644 --- a/packages/json-schemas/schemas/signed_orders_schema.ts +++ b/packages/json-schemas/schemas/signed_orders_schema.ts @@ -1,5 +1,5 @@ export const signedOrdersSchema = { - id: '/signedOrdersSchema', + id: '/SignedOrdersSchema', type: 'array', items: { $ref: '/SignedOrder' }, }; diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index 03c0e950b..e8ccd4ec6 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -5,6 +5,8 @@ import forEach = require('lodash.foreach'); import 'mocha'; import { schemas, SchemaValidator } from '../src/index'; +import { validate } from 'jsonschema'; +import { relayerApiOrderSchema } from '../schemas/relayer_api_order_schema'; chai.config.includeStack = true; chai.use(dirtyChai); @@ -211,6 +213,10 @@ describe('Schema', () => { exchangeAddress: NULL_ADDRESS, expirationTimeSeconds: '42', }; + const relayerApiOrder = { + order, + remainingFillableAmount: '50000000000000', + }; describe('#orderSchema', () => { it('should validate valid order', () => { const testCases = [order]; @@ -232,6 +238,17 @@ describe('Schema', () => { validateAgainstSchema(testCases, orderSchema, shouldFail); }); }); + 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, remainingFillableAmount: 5 }]; + const shouldFail = true; + validateAgainstSchema(testCases, shouldFail); + }); + }); describe('signed order including schemas', () => { const signedOrder = { ...order, -- cgit v1.2.3 From 63e088730ac2eef63c2da7e05a19904e964259e9 Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 31 Jul 2018 17:46:57 -0700 Subject: Group all standard relayer api tests together --- packages/json-schemas/test/schema_test.ts | 811 +++++++++++++++--------------- 1 file changed, 406 insertions(+), 405 deletions(-) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index e8ccd4ec6..57ef25172 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -5,8 +5,6 @@ import forEach = require('lodash.foreach'); import 'mocha'; import { schemas, SchemaValidator } from '../src/index'; -import { validate } from 'jsonschema'; -import { relayerApiOrderSchema } from '../schemas/relayer_api_order_schema'; chai.config.includeStack = true; chai.use(dirtyChai); @@ -37,6 +35,7 @@ const { relayerApiOrdersChannelSubscribeSchema, relayerApiOrdersChannelUpdateSchema, relayerApiOrdersResponseSchema, + relayerApiOrderSchema, } = schemas; describe('Schema', () => { @@ -238,17 +237,6 @@ describe('Schema', () => { validateAgainstSchema(testCases, orderSchema, shouldFail); }); }); - 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, remainingFillableAmount: 5 }]; - const shouldFail = true; - validateAgainstSchema(testCases, shouldFail); - }); - }); describe('signed order including schemas', () => { const signedOrder = { ...order, @@ -354,203 +342,427 @@ describe('Schema', () => { validateAgainstSchema(testCases, orderFillRequestsSchema, shouldFail); }); }); - describe('#relayerApiOrderBookResponseSchema', () => { - it('should validate valid order book responses', () => { - const testCases = [ - { - bids: [], - asks: [], - }, - { - bids: [signedOrder, signedOrder], - asks: [], - }, - { - bids: [], - asks: [signedOrder, signedOrder], - }, - { - bids: [signedOrder], - asks: [signedOrder, signedOrder], - }, - ]; - validateAgainstSchema(testCases, relayerApiOrderBookResponseSchema); + 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, remainingFillableAmount: 5 }]; + const shouldFail = true; + validateAgainstSchema(testCases, relayerApiOrderSchema, shouldFail); + }); }); - it('should fail for invalid order fill requests', () => { - const testCases = [ - {}, - { - bids: [signedOrder, signedOrder], - }, - { - asks: [signedOrder, signedOrder], - }, - { - bids: signedOrder, - asks: [signedOrder, signedOrder], - }, - { - bids: [signedOrder], - asks: signedOrder, - }, - ]; - const shouldFail = true; - validateAgainstSchema(testCases, relayerApiOrdersResponseSchema, 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('#relayerApiOrdersChannelSubscribeSchema', () => { - it('should validate valid orders channel websocket subscribe message', () => { - const testCases = [ - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - snapshot: true, - limit: 100, + describe('#relayerApiOrderConfigPayloadSchema', () => { + it('should validate valid fees payloads', () => { + const testCases = [ + { + exchangeContractAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + maker: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + taker: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', + makerTokenAmount: '10000000000000000000', + takerTokenAmount: '30000000000000000000', + expirationUnixTimestampSec: '42', + salt: '67006738228878699843088602623665307406148487219438534730168799356281242528500', }, - }, - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + ]; + validateAgainstSchema(testCases, relayerApiOrderConfigPayloadSchema); + }); + it('should fail for invalid fees payloads', () => { + const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; + const testCases = [ + {}, + { + takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', + makerTokenAmount: '10000000000000000000', + takerTokenAmount: '30000000000000000000', }, - }, - ]; - validateAgainstSchema(testCases, relayerApiOrdersChannelSubscribeSchema); + { + taker: checksummedAddress, + makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', + makerTokenAmount: '10000000000000000000', + takerTokenAmount: '30000000000000000000', + }, + { + makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', + makerTokenAmount: 10000000000000000000, + takerTokenAmount: 30000000000000000000, + }, + ]; + const shouldFail = true; + validateAgainstSchema(testCases, relayerApiOrderConfigPayloadSchema, shouldFail); + }); }); - it('should fail for invalid orders channel websocket subscribe message', () => { - const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; - const testCases = [ - { - type: 'subscribe', - channel: 'orders', - payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - snapshot: true, - limit: 100, + describe('#relayerApiOrderConfigResponseSchema', () => { + it('should validate valid fees responses', () => { + const testCases = [ + { + makerFee: '10000000000000000', + takerFee: '30000000000000000', + feeRecipient: '0x323b5d4c32345ced77393b3530b1eed0f346429d', }, - }, - { - type: 'foo', - channel: 'orders', - requestId: 'randomId', - payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + ]; + validateAgainstSchema(testCases, relayerApiOrderConfigResponseSchema); + }); + it('should fail for invalid fees responses', () => { + const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; + const testCases = [ + {}, + { + makerFee: 10000000000000000, + takerFee: 30000000000000000, }, - }, - { - type: 'subscribe', - channel: 'bar', - requestId: 'randomId', - payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + { + feeRecipient: checksummedAddress, + takerToSpecify: checksummedAddress, + makerFee: '10000000000000000', + takerFee: '30000000000000000', }, - }, - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: { - baseTokenAddress: checksummedAddress, - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + ]; + const shouldFail = true; + validateAgainstSchema(testCases, relayerApiOrderConfigResponseSchema, shouldFail); + }); + }); + describe('#relayerAssetDataPairsResponseSchema', () => { + it('should validate valid assetPairs response', () => { + const testCases = [ + [], + [ + { + tokenA: { + address: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + minAmount: '0', + maxAmount: '10000000000000000000', + precision: 5, + }, + tokenB: { + address: '0xef7fff64389b814a946f3e92105513705ca6b990', + minAmount: '0', + maxAmount: '50000000000000000000', + precision: 5, + }, + }, + ], + [ + { + tokenA: { + address: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + }, + tokenB: { + address: '0xef7fff64389b814a946f3e92105513705ca6b990', + }, + }, + ], + ]; + validateAgainstSchema(testCases, relayerApiAssetDataPairsResponseSchema); + }); + it('should fail for invalid assetPairs responses', () => { + const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; + const testCases = [ + [ + { + tokenA: { + address: checksummedAddress, + }, + tokenB: { + address: checksummedAddress, + }, + }, + ], + [ + { + tokenA: { + address: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + minAmount: 0, + maxAmount: 10000000000000000000, + }, + tokenB: { + address: '0xef7fff64389b814a946f3e92105513705ca6b990', + minAmount: 0, + maxAmount: 50000000000000000000, + }, + }, + ], + [ + { + tokenA: { + address: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + precision: '5', + }, + tokenB: { + address: '0xef7fff64389b814a946f3e92105513705ca6b990', + precision: '5', + }, + }, + ], + ]; + const shouldFail = true; + validateAgainstSchema(testCases, relayerApiAssetDataPairsResponseSchema, shouldFail); + }); + }); + describe('#relayerApiOrderBookResponseSchema', () => { + it('should validate valid order book responses', () => { + const testCases = [ + { + bids: [], + asks: [], }, - }, - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: checksummedAddress, + { + bids: [signedOrder, signedOrder], + asks: [], }, - }, - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: { - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + { + bids: [], + asks: [signedOrder, signedOrder], }, - }, - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + { + bids: [signedOrder], + asks: [signedOrder, signedOrder], }, - }, - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - snapshot: 'true', - limit: 100, + ]; + validateAgainstSchema(testCases, relayerApiOrderBookResponseSchema); + }); + it('should fail for invalid order fill requests', () => { + const testCases = [ + {}, + { + bids: [signedOrder, signedOrder], }, - }, - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - snapshot: true, - limit: '100', + { + asks: [signedOrder, signedOrder], }, - }, - ]; - const shouldFail = true; - validateAgainstSchema(testCases, relayerApiOrdersChannelSubscribeSchema, shouldFail); + { + bids: signedOrder, + asks: [signedOrder, signedOrder], + }, + { + bids: [signedOrder], + asks: signedOrder, + }, + ]; + const shouldFail = true; + validateAgainstSchema(testCases, relayerApiOrdersResponseSchema, shouldFail); + }); }); - }); - describe('#relayerApiOrdersChannelUpdateSchema', () => { - it('should validate valid orders channel websocket update message', () => { - const testCases = [ - { - type: 'update', - channel: 'orders', - requestId: 2, - payload: signedOrder, - }, - ]; - validateAgainstSchema(testCases, relayerApiOrdersChannelUpdateSchema); + describe('#relayerApiOrdersChannelSubscribeSchema', () => { + it('should validate valid orders channel websocket subscribe message', () => { + const testCases = [ + { + type: 'subscribe', + channel: 'orders', + requestId: 'randomId', + payload: { + baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + snapshot: true, + limit: 100, + }, + }, + { + type: 'subscribe', + channel: 'orders', + requestId: 'randomId', + payload: { + baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + }, + }, + ]; + validateAgainstSchema(testCases, relayerApiOrdersChannelSubscribeSchema); + }); + it('should fail for invalid orders channel websocket subscribe message', () => { + const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; + const testCases = [ + { + type: 'subscribe', + channel: 'orders', + payload: { + baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + snapshot: true, + limit: 100, + }, + }, + { + type: 'foo', + channel: 'orders', + requestId: 'randomId', + payload: { + baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + }, + }, + { + type: 'subscribe', + channel: 'bar', + requestId: 'randomId', + payload: { + baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + }, + }, + { + type: 'subscribe', + channel: 'orders', + requestId: 'randomId', + payload: { + baseTokenAddress: checksummedAddress, + quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + }, + }, + { + type: 'subscribe', + channel: 'orders', + requestId: 'randomId', + payload: { + baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + quoteTokenAddress: checksummedAddress, + }, + }, + { + type: 'subscribe', + channel: 'orders', + requestId: 'randomId', + payload: { + quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + }, + }, + { + type: 'subscribe', + channel: 'orders', + requestId: 'randomId', + payload: { + baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + }, + }, + { + type: 'subscribe', + channel: 'orders', + requestId: 'randomId', + payload: { + baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + snapshot: 'true', + limit: 100, + }, + }, + { + type: 'subscribe', + channel: 'orders', + requestId: 'randomId', + payload: { + baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + snapshot: true, + limit: '100', + }, + }, + ]; + const shouldFail = true; + validateAgainstSchema(testCases, relayerApiOrdersChannelSubscribeSchema, shouldFail); + }); }); - it('should fail for invalid orders channel websocket update message', () => { - const testCases = [ - { - type: 'foo', - channel: 'orders', - requestId: 2, - payload: signedOrder, - }, - { - type: 'update', - channel: 'bar', - requestId: 2, - payload: signedOrder, - }, - { - type: 'update', - channel: 'orders', - requestId: 2, - payload: {}, - }, - ]; - const shouldFail = true; - validateAgainstSchema(testCases, relayerApiOrdersChannelUpdateSchema, shouldFail); + describe('#relayerApiOrdersChannelUpdateSchema', () => { + it('should validate valid orders channel websocket update message', () => { + const testCases = [ + { + type: 'update', + channel: 'orders', + requestId: 2, + payload: signedOrder, + }, + ]; + validateAgainstSchema(testCases, relayerApiOrdersChannelUpdateSchema); + }); + it('should fail for invalid orders channel websocket update message', () => { + const testCases = [ + { + type: 'foo', + channel: 'orders', + requestId: 2, + payload: signedOrder, + }, + { + type: 'update', + channel: 'bar', + requestId: 2, + payload: signedOrder, + }, + { + type: 'update', + channel: 'orders', + requestId: 2, + payload: {}, + }, + ]; + const shouldFail = true; + validateAgainstSchema(testCases, relayerApiOrdersChannelUpdateSchema, shouldFail); + }); }); }); }); @@ -570,217 +782,6 @@ describe('Schema', () => { }); }); }); - 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 = [ - { - exchangeContractAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - maker: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - taker: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', - makerTokenAmount: '10000000000000000000', - takerTokenAmount: '30000000000000000000', - expirationUnixTimestampSec: '42', - salt: '67006738228878699843088602623665307406148487219438534730168799356281242528500', - }, - ]; - validateAgainstSchema(testCases, relayerApiOrderConfigPayloadSchema); - }); - it('should fail for invalid fees payloads', () => { - const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; - const testCases = [ - {}, - { - takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', - makerTokenAmount: '10000000000000000000', - takerTokenAmount: '30000000000000000000', - }, - { - taker: checksummedAddress, - makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', - makerTokenAmount: '10000000000000000000', - takerTokenAmount: '30000000000000000000', - }, - { - makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', - makerTokenAmount: 10000000000000000000, - takerTokenAmount: 30000000000000000000, - }, - ]; - const shouldFail = true; - validateAgainstSchema(testCases, relayerApiOrderConfigPayloadSchema, shouldFail); - }); - }); - describe('#relayerApiOrderConfigResponseSchema', () => { - it('should validate valid fees responses', () => { - const testCases = [ - { - makerFee: '10000000000000000', - takerFee: '30000000000000000', - feeRecipient: '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 = [ - [], - [ - { - tokenA: { - address: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - minAmount: '0', - maxAmount: '10000000000000000000', - precision: 5, - }, - tokenB: { - address: '0xef7fff64389b814a946f3e92105513705ca6b990', - minAmount: '0', - maxAmount: '50000000000000000000', - precision: 5, - }, - }, - ], - [ - { - tokenA: { - address: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - }, - tokenB: { - address: '0xef7fff64389b814a946f3e92105513705ca6b990', - }, - }, - ], - ]; - validateAgainstSchema(testCases, relayerApiAssetDataPairsResponseSchema); - }); - it('should fail for invalid assetPairs responses', () => { - const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; - const testCases = [ - [ - { - tokenA: { - address: checksummedAddress, - }, - tokenB: { - address: checksummedAddress, - }, - }, - ], - [ - { - tokenA: { - address: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - minAmount: 0, - maxAmount: 10000000000000000000, - }, - tokenB: { - address: '0xef7fff64389b814a946f3e92105513705ca6b990', - minAmount: 0, - maxAmount: 50000000000000000000, - }, - }, - ], - [ - { - tokenA: { - address: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - precision: '5', - }, - tokenB: { - address: '0xef7fff64389b814a946f3e92105513705ca6b990', - precision: '5', - }, - }, - ], - ]; - const shouldFail = true; - validateAgainstSchema(testCases, relayerApiAssetDataPairsResponseSchema, shouldFail); - }); - }); describe('#jsNumberSchema', () => { it('should validate valid js number', () => { // tslint:disable-next-line:custom-no-magic-numbers -- cgit v1.2.3 From 86eafeb82623c40c621edaa3e1f59bd3b0eee4bb Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 1 Aug 2018 11:44:59 -0700 Subject: Add tests for asset pair endpoint --- packages/json-schemas/src/schemas.ts | 2 + packages/json-schemas/test/schema_test.ts | 194 +++++++++++++++++------------- 2 files changed, 111 insertions(+), 85 deletions(-) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts index 97aa486f2..61614ebde 100644 --- a/packages/json-schemas/src/schemas.ts +++ b/packages/json-schemas/src/schemas.ts @@ -12,6 +12,7 @@ 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'; @@ -64,4 +65,5 @@ export const schemas = { relayerApiOrdersChannelSubscribePayload, relayerApiOrdersChannelUpdateSchema, relayerApiOrdersResponseSchema, + relayerApiAssetDataPairsSchema, }; diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index 57ef25172..0af948df7 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -57,6 +57,11 @@ describe('Schema', () => { } }); }; + 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']; @@ -169,11 +174,6 @@ describe('Schema', () => { }); }); describe('#paginatedCollectionSchema', () => { - const paginatedResponse = { - total: 100, - perPage: 10, - page: 3, - }; it('should validate valid paginated collections', () => { const testCases = [paginatedResponse]; validateAgainstSchema(testCases, paginatedCollectionSchema); @@ -418,15 +418,14 @@ describe('Schema', () => { it('should validate valid fees payloads', () => { const testCases = [ { - exchangeContractAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - maker: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - taker: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', - makerTokenAmount: '10000000000000000000', - takerTokenAmount: '30000000000000000000', - expirationUnixTimestampSec: '42', - salt: '67006738228878699843088602623665307406148487219438534730168799356281242528500', + exchangeAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + makerAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + takerAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + makerAssetData: NULL_ADDRESS, + takerAssetData: NULL_ADDRESS, + makerAssetAmount: '10000000000000000000', + takerAssetAmount: '30000000000000000000', + expirationTimeSeconds: '42', }, ]; validateAgainstSchema(testCases, relayerApiOrderConfigPayloadSchema); @@ -436,22 +435,19 @@ describe('Schema', () => { const testCases = [ {}, { - takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', - makerTokenAmount: '10000000000000000000', - takerTokenAmount: '30000000000000000000', + makerAssetAmount: '10000000000000000000', + takerAssetAmount: '30000000000000000000', + makerAssetData: NULL_ADDRESS, + takerAssetData: NULL_ADDRESS, }, { - taker: checksummedAddress, - makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', - makerTokenAmount: '10000000000000000000', - takerTokenAmount: '30000000000000000000', + takerAddress: checksummedAddress, + makerAssetAmount: '10000000000000000000', + takerAssetAmount: '30000000000000000000', }, { - makerTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - takerTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990', - makerTokenAmount: 10000000000000000000, - takerTokenAmount: 30000000000000000000, + makerAssetAmount: 10000000000000000000, + takerAssetAmount: 30000000000000000000, }, ]; const shouldFail = true; @@ -464,7 +460,8 @@ describe('Schema', () => { { makerFee: '10000000000000000', takerFee: '30000000000000000', - feeRecipient: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + feeRecipientAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + senderAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', }, ]; validateAgainstSchema(testCases, relayerApiOrderConfigResponseSchema); @@ -491,75 +488,102 @@ describe('Schema', () => { describe('#relayerAssetDataPairsResponseSchema', () => { it('should validate valid assetPairs response', () => { const testCases = [ - [], - [ - { - tokenA: { - address: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - minAmount: '0', - maxAmount: '10000000000000000000', - precision: 5, - }, - tokenB: { - address: '0xef7fff64389b814a946f3e92105513705ca6b990', - minAmount: '0', - maxAmount: '50000000000000000000', - precision: 5, - }, - }, - ], - [ - { - tokenA: { - address: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + { + ...paginatedResponse, + records: [], + }, + { + ...paginatedResponse, + records: [ + { + assetDataA: { + assetData: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + minAmount: '0', + maxAmount: '10000000000000000000', + precision: 5, + }, + assetDataB: { + assetData: '0xef7fff64389b814a946f3e92105513705ca6b990', + minAmount: '0', + maxAmount: '50000000000000000000', + precision: 5, + }, }, - tokenB: { - address: '0xef7fff64389b814a946f3e92105513705ca6b990', + ], + }, + { + ...paginatedResponse, + records: [ + { + assetDataA: { + assetData: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + }, + assetDataB: { + assetData: '0xef7fff64389b814a946f3e92105513705ca6b990', + }, }, - }, - ], + ], + }, ]; validateAgainstSchema(testCases, relayerApiAssetDataPairsResponseSchema); }); it('should fail for invalid assetPairs responses', () => { const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; const testCases = [ - [ - { - tokenA: { - address: checksummedAddress, - }, - tokenB: { - address: checksummedAddress, - }, - }, - ], - [ - { - tokenA: { - address: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - minAmount: 0, - maxAmount: 10000000000000000000, - }, - tokenB: { - address: '0xef7fff64389b814a946f3e92105513705ca6b990', - minAmount: 0, - maxAmount: 50000000000000000000, + { + ...paginatedResponse, + records: [ + { + assetDataA: { + assetData: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + minAmount: '0', + maxAmount: '10000000000000000000', + precision: 5, + }, + assetDataC: { + assetData: '0xef7fff64389b814a946f3e92105513705ca6b990', + minAmount: '0', + maxAmount: '50000000000000000000', + precision: 5, + }, }, - }, - ], - [ - { - tokenA: { - address: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - precision: '5', + ], + }, + { + records: [ + { + assetDataA: { + assetData: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + minAmount: '0', + maxAmount: '10000000000000000000', + precision: 5, + }, + assetDataB: { + assetData: '0xef7fff64389b814a946f3e92105513705ca6b990', + minAmount: '0', + maxAmount: '50000000000000000000', + precision: 5, + }, }, - tokenB: { - address: '0xef7fff64389b814a946f3e92105513705ca6b990', - 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); -- cgit v1.2.3 From 8351f5998ab3960461b255826778ff279991c184 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 1 Aug 2018 13:27:01 -0700 Subject: Add relayerApiOrdersResponseTest --- packages/json-schemas/test/schema_test.ts | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index 0af948df7..119c13388 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -5,6 +5,7 @@ import forEach = require('lodash.foreach'); import 'mocha'; import { schemas, SchemaValidator } from '../src/index'; +import { validate } from 'jsonschema'; chai.config.includeStack = true; chai.use(dirtyChai); @@ -216,6 +217,10 @@ describe('Schema', () => { order, remainingFillableAmount: '50000000000000', }; + const relayerApiOrdersResponse = { + ...paginatedResponse, + records: [relayerApiOrder, relayerApiOrder], + }; describe('#orderSchema', () => { it('should validate valid order', () => { const testCases = [order]; @@ -589,6 +594,34 @@ describe('Schema', () => { 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 = [ -- cgit v1.2.3 From 48aaf228558ae7312d314a0c1f5bd920428eb39d Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 1 Aug 2018 13:34:10 -0700 Subject: Update order book schema test --- packages/json-schemas/test/schema_test.ts | 61 ++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 18 deletions(-) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index 119c13388..7b090ad87 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -626,20 +626,34 @@ describe('Schema', () => { it('should validate valid order book responses', () => { const testCases = [ { - bids: [], - asks: [], - }, - { - bids: [signedOrder, signedOrder], - asks: [], + bids: { + ...paginatedResponse, + records: [relayerApiOrder], + }, + asks: { + ...paginatedResponse, + records: [], + }, }, { - bids: [], - asks: [signedOrder, signedOrder], + bids: { + ...paginatedResponse, + records: [relayerApiOrder, relayerApiOrder], + }, + asks: { + ...paginatedResponse, + records: [relayerApiOrder, relayerApiOrder], + }, }, { - bids: [signedOrder], - asks: [signedOrder, signedOrder], + bids: { + ...paginatedResponse, + records: [], + }, + asks: { + ...paginatedResponse, + records: [relayerApiOrder, relayerApiOrder], + }, }, ]; validateAgainstSchema(testCases, relayerApiOrderBookResponseSchema); @@ -648,18 +662,29 @@ describe('Schema', () => { const testCases = [ {}, { - bids: [signedOrder, signedOrder], - }, - { - asks: [signedOrder, signedOrder], + bids: { + records: [relayerApiOrder], + }, + asks: { + ...paginatedResponse, + records: [], + }, }, { - bids: signedOrder, - asks: [signedOrder, signedOrder], + bids: { + ...paginatedResponse, + records: [relayerApiOrder, relayerApiOrder], + }, + asks: {}, }, { - bids: [signedOrder], - asks: signedOrder, + bids: { + ...paginatedResponse, + }, + asks: { + ...paginatedResponse, + records: [relayerApiOrder, relayerApiOrder], + }, }, ]; const shouldFail = true; -- cgit v1.2.3 From 962d6e71b6cbe7f4e267bfb16d3c9fb4de511a22 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 1 Aug 2018 13:52:40 -0700 Subject: update orders channel subscribe schema --- .../relayer_api_orders_channel_subscribe_schema.ts | 4 +- packages/json-schemas/test/schema_test.ts | 86 +++------------------- 2 files changed, 14 insertions(+), 76 deletions(-) (limited to 'packages/json-schemas') 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 index 1fe612949..d36048047 100644 --- a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts +++ b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts @@ -14,8 +14,8 @@ export const relayerApiOrdersChannelSubscribePayload = { id: '/RelayerApiOrdersChannelSubscribePayload', type: 'object', properties: { - makerAssetProxyId: { $ref: '/Address' }, - takerAssetProxyId: { $ref: '/Address' }, + makerAssetProxyId: { $ref: '/Hex' }, + takerAssetProxyId: { $ref: '/Hex' }, networkId: { type: 'number' }, makerAssetAddress: { $ref: '/Address' }, takerAssetAddress: { $ref: '/Address' }, diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index 7b090ad87..0b520f6e3 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -698,22 +698,22 @@ describe('Schema', () => { type: 'subscribe', channel: 'orders', requestId: 'randomId', - payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - snapshot: true, - limit: 100, - }, }, { type: 'subscribe', channel: 'orders', requestId: 'randomId', payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', + makerAssetProxyId: '0x02571792', + takerAssetProxyId: '0xf47261b0', }, }, + { + type: 'subscribe', + channel: 'orders', + requestId: 'randomId', + payload: {}, + }, ]; validateAgainstSchema(testCases, relayerApiOrdersChannelSubscribeSchema); }); @@ -723,74 +723,15 @@ describe('Schema', () => { { type: 'subscribe', channel: 'orders', - payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - snapshot: true, - limit: 100, - }, - }, - { - type: 'foo', - channel: 'orders', - requestId: 'randomId', - payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - }, - }, - { - type: 'subscribe', - channel: 'bar', - requestId: 'randomId', - payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - }, - }, - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: { - baseTokenAddress: checksummedAddress, - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - }, - }, - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: checksummedAddress, - }, - }, - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: { - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - }, - }, - { - type: 'subscribe', - channel: 'orders', - requestId: 'randomId', - payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - }, }, { type: 'subscribe', channel: 'orders', requestId: 'randomId', payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - snapshot: 'true', - limit: 100, + makerAssetProxyId: '0x02571792', + takerAssetProxyId: '0xf47261b0', + makerAssetAddress: checksummedAddress, }, }, { @@ -798,10 +739,7 @@ describe('Schema', () => { channel: 'orders', requestId: 'randomId', payload: { - baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - quoteTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d', - snapshot: true, - limit: '100', + makerAssetProxyId: 'invalidId', }, }, ]; -- cgit v1.2.3 From f8a252d1427a6dddffa3cdb177ebc6ffd9cb774c Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 1 Aug 2018 13:55:16 -0700 Subject: All schema tests padding --- packages/json-schemas/test/schema_test.ts | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index 0b520f6e3..e1538ba56 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -753,8 +753,14 @@ describe('Schema', () => { { type: 'update', channel: 'orders', - requestId: 2, - payload: signedOrder, + requestId: 'randomId', + payload: [relayerApiOrder], + }, + { + type: 'update', + channel: 'orders', + requestId: 'randomId', + payload: [], }, ]; validateAgainstSchema(testCases, relayerApiOrdersChannelUpdateSchema); @@ -764,21 +770,26 @@ describe('Schema', () => { { type: 'foo', channel: 'orders', - requestId: 2, - payload: signedOrder, + requestId: 'randomId', }, { type: 'update', channel: 'bar', requestId: 2, - payload: signedOrder, + payload: [relayerApiOrder], }, { type: 'update', channel: 'orders', - requestId: 2, + requestId: 'randomId', payload: {}, }, + { + type: 'update', + channel: 'orders', + requestId: 'randomId', + payload: relayerApiErrorResponseSchema, + }, ]; const shouldFail = true; validateAgainstSchema(testCases, relayerApiOrdersChannelUpdateSchema, shouldFail); -- cgit v1.2.3 From afc5c2616acfaf59e8ce716bc9329bc06021dc7a Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 2 Aug 2018 11:57:23 -0700 Subject: Enforce stronger naming convention for json schema ids --- .../json-schemas/schemas/basic_type_schemas.ts | 6 ++-- .../json-schemas/schemas/block_range_schema.ts | 8 ++--- packages/json-schemas/schemas/call_data_schema.ts | 12 ++++---- .../json-schemas/schemas/ec_signature_schema.ts | 6 ++-- .../schemas/index_filter_values_schema.ts | 4 +-- .../json-schemas/schemas/order_cancel_schema.ts | 6 ++-- .../schemas/order_fill_or_kill_requests_schema.ts | 6 ++-- .../schemas/order_fill_requests_schema.ts | 6 ++-- packages/json-schemas/schemas/order_hash_schema.ts | 2 +- packages/json-schemas/schemas/order_schemas.ts | 34 +++++++++++----------- packages/json-schemas/schemas/orders_schema.ts | 4 +-- .../schemas/paginated_collection_schema.ts | 2 +- .../relayer_api_asset_pairs_response_schema.ts | 20 ++++++------- .../schemas/relayer_api_error_response_schema.ts | 2 +- .../relayer_api_order_config_payload_schema.ts | 18 ++++++------ .../relayer_api_order_config_response_schema.ts | 10 +++---- .../schemas/relayer_api_order_schema.ts | 6 ++-- .../relayer_api_orderbook_response_schema.ts | 6 ++-- .../relayer_api_orders_channel_subscribe_schema.ts | 20 ++++++------- ...er_api_orders_channel_update_response_schema.ts | 4 +-- .../schemas/relayer_api_orders_response_schema.ts | 6 ++-- .../schemas/relayer_api_orders_schema.ts | 4 +-- .../json-schemas/schemas/signed_orders_schema.ts | 4 +-- packages/json-schemas/schemas/token_schema.ts | 4 +-- packages/json-schemas/schemas/tx_data_schema.ts | 14 ++++----- 25 files changed, 107 insertions(+), 107 deletions(-) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/schemas/basic_type_schemas.ts b/packages/json-schemas/schemas/basic_type_schemas.ts index 7565df9e0..031383a11 100644 --- a/packages/json-schemas/schemas/basic_type_schemas.ts +++ b/packages/json-schemas/schemas/basic_type_schemas.ts @@ -1,17 +1,17 @@ export const addressSchema = { - id: '/Address', + id: '/addressSchema', type: 'string', pattern: '^0x[0-9a-f]{40}$', }; export const hexSchema = { - id: '/Hex', + id: '/hexSchema', type: 'string', pattern: '^0x([0-9a-f][0-9a-f])+$', }; export const numberSchema = { - id: '/Number', + id: '/numberSchema', type: 'string', pattern: '^\\d+(\\.\\d+)?$', }; diff --git a/packages/json-schemas/schemas/block_range_schema.ts b/packages/json-schemas/schemas/block_range_schema.ts index 1f6a63151..9eb242fc6 100644 --- a/packages/json-schemas/schemas/block_range_schema.ts +++ b/packages/json-schemas/schemas/block_range_schema.ts @@ -1,5 +1,5 @@ export const blockParamSchema = { - id: '/BlockParam', + id: '/blockParamSchema', oneOf: [ { type: 'number', @@ -11,10 +11,10 @@ export const blockParamSchema = { }; export const blockRangeSchema = { - id: '/BlockRange', + id: '/blockRangeSchema', properties: { - fromBlock: { $ref: '/BlockParam' }, - toBlock: { $ref: '/BlockParam' }, + fromBlock: { $ref: '/blockParamSchema' }, + toBlock: { $ref: '/blockParamSchema' }, }, type: 'object', }; diff --git a/packages/json-schemas/schemas/call_data_schema.ts b/packages/json-schemas/schemas/call_data_schema.ts index b9d00ad2a..4c77d9f9d 100644 --- a/packages/json-schemas/schemas/call_data_schema.ts +++ b/packages/json-schemas/schemas/call_data_schema.ts @@ -1,16 +1,16 @@ export const callDataSchema = { - id: '/CallData', + id: '/callDataSchema', properties: { - from: { $ref: '/Address' }, - to: { $ref: '/Address' }, + from: { $ref: '/addressSchema' }, + to: { $ref: '/addressSchema' }, value: { - oneOf: [{ $ref: '/Number' }, { $ref: '/JsNumber' }], + oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], }, gas: { - oneOf: [{ $ref: '/Number' }, { $ref: '/JsNumber' }], + oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], }, gasPrice: { - oneOf: [{ $ref: '/Number' }, { $ref: '/JsNumber' }], + oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], }, data: { type: 'string', diff --git a/packages/json-schemas/schemas/ec_signature_schema.ts b/packages/json-schemas/schemas/ec_signature_schema.ts index 71b840dd8..c59532f09 100644 --- a/packages/json-schemas/schemas/ec_signature_schema.ts +++ b/packages/json-schemas/schemas/ec_signature_schema.ts @@ -1,5 +1,5 @@ export const ecSignatureParameterSchema = { - id: '/ECSignatureParameter', + id: '/ecSignatureParameterSchema', type: 'string', pattern: '^0[xX][0-9A-Fa-f]{64}$', }; @@ -12,8 +12,8 @@ export const ecSignatureSchema = { minimum: 27, maximum: 28, }, - r: { $ref: '/ECSignatureParameter' }, - s: { $ref: '/ECSignatureParameter' }, + r: { $ref: '/ecSignatureParameterSchema' }, + s: { $ref: '/ecSignatureParameterSchema' }, }, required: ['v', 'r', 's'], type: 'object', diff --git a/packages/json-schemas/schemas/index_filter_values_schema.ts b/packages/json-schemas/schemas/index_filter_values_schema.ts index 3374d63e0..f3c8cef68 100644 --- a/packages/json-schemas/schemas/index_filter_values_schema.ts +++ b/packages/json-schemas/schemas/index_filter_values_schema.ts @@ -1,7 +1,7 @@ export const indexFilterValuesSchema = { - id: '/IndexFilterValues', + id: '/indexFilterValuesSchema', additionalProperties: { - oneOf: [{ $ref: '/Number' }, { $ref: '/Address' }, { $ref: '/OrderHashSchema' }], + oneOf: [{ $ref: '/numberSchema' }, { $ref: '/addressSchema' }, { $ref: '/orderHashSchema' }], }, type: 'object', }; diff --git a/packages/json-schemas/schemas/order_cancel_schema.ts b/packages/json-schemas/schemas/order_cancel_schema.ts index ad23d01cc..e4edfbca9 100644 --- a/packages/json-schemas/schemas/order_cancel_schema.ts +++ b/packages/json-schemas/schemas/order_cancel_schema.ts @@ -1,10 +1,10 @@ export const orderCancellationRequestsSchema = { - id: '/OrderCancellationRequests', + id: '/orderCancellationRequestsSchema', type: 'array', items: { properties: { - order: { $ref: '/Order' }, - takerTokenCancelAmount: { $ref: '/Number' }, + order: { $ref: '/orderSchema' }, + takerTokenCancelAmount: { $ref: '/numberSchema' }, }, required: ['order', 'takerTokenCancelAmount'], 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 index 61f2c8849..e2c18ef0a 100644 --- a/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts +++ b/packages/json-schemas/schemas/order_fill_or_kill_requests_schema.ts @@ -1,10 +1,10 @@ export const orderFillOrKillRequestsSchema = { - id: '/OrderFillOrKillRequests', + id: '/orderFillOrKillRequestsSchema', type: 'array', items: { properties: { - signedOrder: { $ref: '/SignedOrder' }, - fillTakerAmount: { $ref: '/Number' }, + signedOrder: { $ref: '/signedOrderSchema' }, + fillTakerAmount: { $ref: '/numberSchema' }, }, required: ['signedOrder', 'fillTakerAmount'], type: 'object', diff --git a/packages/json-schemas/schemas/order_fill_requests_schema.ts b/packages/json-schemas/schemas/order_fill_requests_schema.ts index 419d0670f..ea8b35e54 100644 --- a/packages/json-schemas/schemas/order_fill_requests_schema.ts +++ b/packages/json-schemas/schemas/order_fill_requests_schema.ts @@ -1,10 +1,10 @@ export const orderFillRequestsSchema = { - id: '/OrderFillRequests', + id: '/orderFillRequestsSchema', type: 'array', items: { properties: { - signedOrder: { $ref: '/SignedOrder' }, - takerTokenFillAmount: { $ref: '/Number' }, + signedOrder: { $ref: '/signedOrderSchema' }, + takerTokenFillAmount: { $ref: '/numberSchema' }, }, required: ['signedOrder', 'takerTokenFillAmount'], type: 'object', diff --git a/packages/json-schemas/schemas/order_hash_schema.ts b/packages/json-schemas/schemas/order_hash_schema.ts index 6af06927f..9773a88f9 100644 --- a/packages/json-schemas/schemas/order_hash_schema.ts +++ b/packages/json-schemas/schemas/order_hash_schema.ts @@ -1,5 +1,5 @@ export const orderHashSchema = { - id: '/OrderHashSchema', + id: '/orderHashSchema', type: 'string', pattern: '^0x[0-9a-fA-F]{64}$', }; diff --git a/packages/json-schemas/schemas/order_schemas.ts b/packages/json-schemas/schemas/order_schemas.ts index dcbfde6e0..eb7fdaf5a 100644 --- a/packages/json-schemas/schemas/order_schemas.ts +++ b/packages/json-schemas/schemas/order_schemas.ts @@ -1,19 +1,19 @@ export const orderSchema = { - id: '/Order', + id: '/orderSchema', properties: { - makerAddress: { $ref: '/Address' }, - takerAddress: { $ref: '/Address' }, - makerFee: { $ref: '/Number' }, - takerFee: { $ref: '/Number' }, - senderAddress: { $ref: '/Address' }, - makerAssetAmount: { $ref: '/Number' }, - takerAssetAmount: { $ref: '/Number' }, - makerAssetData: { $ref: '/Hex' }, - takerAssetData: { $ref: '/Hex' }, - salt: { $ref: '/Number' }, - exchangeAddress: { $ref: '/Address' }, - feeRecipientAddress: { $ref: '/Address' }, - expirationTimeSeconds: { $ref: '/Number' }, + 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', @@ -34,12 +34,12 @@ export const orderSchema = { }; export const signedOrderSchema = { - id: '/SignedOrder', + id: '/signedOrderSchema', allOf: [ - { $ref: '/Order' }, + { $ref: '/orderSchema' }, { properties: { - signature: { $ref: '/Hex' }, + signature: { $ref: '/hexSchema' }, }, required: ['signature'], }, diff --git a/packages/json-schemas/schemas/orders_schema.ts b/packages/json-schemas/schemas/orders_schema.ts index 73816a57e..de0abcf00 100644 --- a/packages/json-schemas/schemas/orders_schema.ts +++ b/packages/json-schemas/schemas/orders_schema.ts @@ -1,5 +1,5 @@ export const ordersSchema = { - id: '/OrdersSchema', + id: '/ordersSchema', type: 'array', - items: { $ref: '/Order' }, + items: { $ref: '/orderSchema' }, }; diff --git a/packages/json-schemas/schemas/paginated_collection_schema.ts b/packages/json-schemas/schemas/paginated_collection_schema.ts index abd86f1ef..16044c70a 100644 --- a/packages/json-schemas/schemas/paginated_collection_schema.ts +++ b/packages/json-schemas/schemas/paginated_collection_schema.ts @@ -1,5 +1,5 @@ export const paginatedCollectionSchema = { - id: '/PaginatedCollection', + id: '/paginatedCollectionSchema', type: 'object', properties: { total: { type: 'number' }, 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 index 74b919a8f..c13396d29 100644 --- a/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts +++ b/packages/json-schemas/schemas/relayer_api_asset_pairs_response_schema.ts @@ -1,11 +1,11 @@ export const relayerApiAssetDataPairsResponseSchema = { - id: '/RelayerApiAssetDataPairsResponse', + id: '/relayerApiAssetDataPairsResponseSchema', type: 'object', allOf: [ - { $ref: '/PaginatedCollection' }, + { $ref: '/paginatedCollectionSchema' }, { properties: { - records: { $ref: '/RelayerApiAssetDataPairs' }, + records: { $ref: '/relayerApiAssetDataPairsSchema' }, }, required: ['records'], }, @@ -13,12 +13,12 @@ export const relayerApiAssetDataPairsResponseSchema = { }; export const relayerApiAssetDataPairsSchema = { - id: '/RelayerApiAssetDataPairs', + id: '/relayerApiAssetDataPairsSchema', type: 'array', items: { properties: { - assetDataA: { $ref: '/RelayerApiAssetDataTradeInfo' }, - assetDataB: { $ref: '/RelayerApiAssetDataTradeInfo' }, + assetDataA: { $ref: '/relayerApiAssetDataTradeInfoSchema' }, + assetDataB: { $ref: '/relayerApiAssetDataTradeInfoSchema' }, }, required: ['assetDataA', 'assetDataB'], type: 'object', @@ -26,12 +26,12 @@ export const relayerApiAssetDataPairsSchema = { }; export const relayerApiAssetDataTradeInfoSchema = { - id: '/RelayerApiAssetDataTradeInfo', + id: '/relayerApiAssetDataTradeInfoSchema', type: 'object', properties: { - assetData: { $ref: '/Hex' }, - minAmount: { $ref: '/Number' }, - maxAmount: { $ref: '/Number' }, + 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.ts b/packages/json-schemas/schemas/relayer_api_error_response_schema.ts index 27fdb166f..3a71cdfa6 100644 --- a/packages/json-schemas/schemas/relayer_api_error_response_schema.ts +++ b/packages/json-schemas/schemas/relayer_api_error_response_schema.ts @@ -1,5 +1,5 @@ export const relayerApiErrorResponseSchema = { - id: '/RelayerApiErrorResponse', + id: '/relayerApiErrorResponseSchema', type: 'object', properties: { code: { type: 'number' }, 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 index 7b4a88e84..8d1d408d6 100644 --- a/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts +++ b/packages/json-schemas/schemas/relayer_api_order_config_payload_schema.ts @@ -1,15 +1,15 @@ export const relayerApiOrderConfigPayloadSchema = { - id: '/RelayerApiOrderConfigPayload', + id: '/relayerApiOrderConfigPayloadSchema', type: 'object', properties: { - makerAddress: { $ref: '/Address' }, - takerAddress: { $ref: '/Address' }, - makerAssetAmount: { $ref: '/Number' }, - takerAssetAmount: { $ref: '/Number' }, - makerAssetData: { $ref: '/Hex' }, - takerAssetData: { $ref: '/Hex' }, - exchangeAddress: { $ref: '/Address' }, - expirationTimeSeconds: { $ref: '/Number' }, + 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', 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 index d7960cd9d..390d0b262 100644 --- a/packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts +++ b/packages/json-schemas/schemas/relayer_api_order_config_response_schema.ts @@ -1,11 +1,11 @@ export const relayerApiOrderConfigResponseSchema = { - id: '/RelayerApiOrderConfigResponse', + id: '/relayerApiOrderConfigResponseSchema', type: 'object', properties: { - makerFee: { $ref: '/Number' }, - takerFee: { $ref: '/Number' }, - feeRecipientAddress: { $ref: '/Address' }, - senderAddress: { $ref: '/Address' }, + 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.ts b/packages/json-schemas/schemas/relayer_api_order_schema.ts index 4e138af12..17fa146c4 100644 --- a/packages/json-schemas/schemas/relayer_api_order_schema.ts +++ b/packages/json-schemas/schemas/relayer_api_order_schema.ts @@ -1,9 +1,9 @@ export const relayerApiOrderSchema = { - id: '/RelayerApiOrder', + id: '/relayerApiOrderSchema', type: 'object', properties: { - order: { $ref: '/Order' }, - remainingFillableAmount: { $ref: '/Number' }, + order: { $ref: '/orderSchema' }, + remainingFillableAmount: { $ref: '/numberSchema' }, }, required: ['order', 'remainingFillableAmount'], }; diff --git a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts index f311908db..2e5b0c6f2 100644 --- a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts +++ b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts @@ -1,9 +1,9 @@ export const relayerApiOrderBookResponseSchema = { - id: '/RelayerApiOrderBookResponse', + id: '/relayerApiOrderBookResponseSchema', type: 'object', properties: { - bids: { $ref: '/RelayerApiOrdersResponse' }, - asks: { $ref: '/RelayerApiOrdersResponse' }, + bids: { $ref: '/relayerApiOrdersResponseSchema' }, + asks: { $ref: '/relayerApiOrdersResponseSchema' }, }, required: ['bids', 'asks'], }; 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 index d36048047..a3b9b6d95 100644 --- a/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts +++ b/packages/json-schemas/schemas/relayer_api_orders_channel_subscribe_schema.ts @@ -1,26 +1,26 @@ export const relayerApiOrdersChannelSubscribeSchema = { - id: '/RelayerApiOrdersChannelSubscribe', + id: '/relayerApiOrdersChannelSubscribeSchema', type: 'object', properties: { type: { enum: ['subscribe'] }, channel: { enum: ['orders'] }, requestId: { type: 'string' }, - payload: { $ref: '/RelayerApiOrdersChannelSubscribePayload' }, + payload: { $ref: '/relayerApiOrdersChannelSubscribePayload' }, }, required: ['type', 'channel', 'requestId'], }; export const relayerApiOrdersChannelSubscribePayload = { - id: '/RelayerApiOrdersChannelSubscribePayload', + id: '/relayerApiOrdersChannelSubscribePayload', type: 'object', properties: { - makerAssetProxyId: { $ref: '/Hex' }, - takerAssetProxyId: { $ref: '/Hex' }, + makerAssetProxyId: { $ref: '/hexSchema' }, + takerAssetProxyId: { $ref: '/hexSchema' }, networkId: { type: 'number' }, - makerAssetAddress: { $ref: '/Address' }, - takerAssetAddress: { $ref: '/Address' }, - makerAssetData: { $ref: '/Hex' }, - takerAssetData: { $ref: '/Hex' }, - traderAssetData: { $ref: '/Hex' }, + 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.ts b/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts index 31f5ab389..800b818e2 100644 --- 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 @@ -1,11 +1,11 @@ export const relayerApiOrdersChannelUpdateSchema = { - id: '/RelayerApiOrdersChannelUpdate', + id: '/relayerApiOrdersChannelUpdateSchema', type: 'object', properties: { type: { enum: ['update'] }, channel: { enum: ['orders'] }, requestId: { type: 'string' }, - payload: { $ref: '/RelayerApiOrders' }, + payload: { $ref: '/relayerApiOrdersSchema' }, }, required: ['type', 'channel', 'requestId'], }; diff --git a/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts index 4bef260c1..c10d64ca9 100644 --- a/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts +++ b/packages/json-schemas/schemas/relayer_api_orders_response_schema.ts @@ -1,11 +1,11 @@ export const relayerApiOrdersResponseSchema = { - id: '/RelayerApiOrdersResponse', + id: '/relayerApiOrdersResponseSchema', type: 'object', allOf: [ - { $ref: '/PaginatedCollection' }, + { $ref: '/paginatedCollectionSchema' }, { properties: { - records: { $ref: '/RelayerApiOrders' }, + records: { $ref: '/relayerApiOrdersSchema' }, }, required: ['records'], }, diff --git a/packages/json-schemas/schemas/relayer_api_orders_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_schema.ts index da739a300..ba8ce4722 100644 --- a/packages/json-schemas/schemas/relayer_api_orders_schema.ts +++ b/packages/json-schemas/schemas/relayer_api_orders_schema.ts @@ -1,5 +1,5 @@ export const relayerApiOrdersSchema = { - id: '/RelayerApiOrders', + id: '/relayerApiOrdersSchema', type: 'array', - items: { $ref: '/RelayerApiOrder' }, + items: { $ref: '/relayerApiOrderSchema' }, }; diff --git a/packages/json-schemas/schemas/signed_orders_schema.ts b/packages/json-schemas/schemas/signed_orders_schema.ts index 164201f76..e2a5aeb56 100644 --- a/packages/json-schemas/schemas/signed_orders_schema.ts +++ b/packages/json-schemas/schemas/signed_orders_schema.ts @@ -1,5 +1,5 @@ export const signedOrdersSchema = { - id: '/SignedOrdersSchema', + id: '/signedOrdersSchema', type: 'array', - items: { $ref: '/SignedOrder' }, + items: { $ref: '/signedOrderSchema' }, }; diff --git a/packages/json-schemas/schemas/token_schema.ts b/packages/json-schemas/schemas/token_schema.ts index e64565c8b..a0b1ae27f 100644 --- a/packages/json-schemas/schemas/token_schema.ts +++ b/packages/json-schemas/schemas/token_schema.ts @@ -1,10 +1,10 @@ export const tokenSchema = { - id: '/Token', + id: '/tokenSchema', properties: { name: { type: 'string' }, symbol: { type: 'string' }, decimals: { type: 'number' }, - address: { $ref: '/Address' }, + address: { $ref: '/addressSchema' }, }, required: ['name', 'symbol', 'decimals', 'address'], type: 'object', diff --git a/packages/json-schemas/schemas/tx_data_schema.ts b/packages/json-schemas/schemas/tx_data_schema.ts index 4274c553f..41a5c708a 100644 --- a/packages/json-schemas/schemas/tx_data_schema.ts +++ b/packages/json-schemas/schemas/tx_data_schema.ts @@ -1,22 +1,22 @@ export const jsNumber = { - id: '/JsNumber', + id: '/jsNumber', type: 'number', minimum: 0, }; export const txDataSchema = { - id: '/TxData', + id: '/txDataSchema', properties: { - from: { $ref: '/Address' }, - to: { $ref: '/Address' }, + from: { $ref: '/addressSchema' }, + to: { $ref: '/addressSchema' }, value: { - oneOf: [{ $ref: '/Number' }, { $ref: '/JsNumber' }], + oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], }, gas: { - oneOf: [{ $ref: '/Number' }, { $ref: '/JsNumber' }], + oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], }, gasPrice: { - oneOf: [{ $ref: '/Number' }, { $ref: '/JsNumber' }], + oneOf: [{ $ref: '/numberSchema' }, { $ref: '/jsNumber' }], }, data: { type: 'string', -- cgit v1.2.3 From 1ce6579c3a05264f93957b0c2d845a1351f4a3b1 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 2 Aug 2018 15:25:40 -0700 Subject: Create asset_pairs SRA endpoint (and establish conventions) --- packages/json-schemas/test/schema_test.ts | 1 - 1 file changed, 1 deletion(-) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index e1538ba56..ebce30e59 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -5,7 +5,6 @@ import forEach = require('lodash.foreach'); import 'mocha'; import { schemas, SchemaValidator } from '../src/index'; -import { validate } from 'jsonschema'; chai.config.includeStack = true; chai.use(dirtyChai); -- cgit v1.2.3 From 0390a5ecbfc79dfd435d3f9e911abd610f33d455 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 2 Aug 2018 18:08:36 -0700 Subject: Limit error codes with ranges --- packages/json-schemas/schemas/relayer_api_error_response_schema.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/schemas/relayer_api_error_response_schema.ts b/packages/json-schemas/schemas/relayer_api_error_response_schema.ts index 3a71cdfa6..05740aa54 100644 --- a/packages/json-schemas/schemas/relayer_api_error_response_schema.ts +++ b/packages/json-schemas/schemas/relayer_api_error_response_schema.ts @@ -2,7 +2,7 @@ export const relayerApiErrorResponseSchema = { id: '/relayerApiErrorResponseSchema', type: 'object', properties: { - code: { type: 'number' }, + code: { type: 'number', minimum: 100, maximum: 103 }, reason: { type: 'string' }, validationErrors: { type: 'array', @@ -10,7 +10,7 @@ export const relayerApiErrorResponseSchema = { type: 'object', properties: { field: { type: 'string' }, - code: { type: 'number' }, + code: { type: 'number', minimum: 1000, maximum: 1006 }, reason: { type: 'string' }, }, required: ['field', 'code', 'reason'], -- cgit v1.2.3 From 95b656f360f635447725e00bb90642f1b859477a Mon Sep 17 00:00:00 2001 From: fragosti Date: Tue, 7 Aug 2018 17:42:22 -0700 Subject: Add GET fee_recipients --- .../schemas/relayer_api_fee_recipients_response_schema.ts | 13 +++++++++++++ packages/json-schemas/src/schemas.ts | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.ts (limited to 'packages/json-schemas') 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 new file mode 100644 index 000000000..84d39eb20 --- /dev/null +++ b/packages/json-schemas/schemas/relayer_api_fee_recipients_response_schema.ts @@ -0,0 +1,13 @@ +export const relayerApiFeeRecipientsResponseSchema = { + id: '/relayerApiFeeRecipientsResponseSchema', + type: 'object', + allOf: [ + { $ref: '/paginatedCollectionSchema' }, + { + properties: { + records: { $ref: '/addressSchema' }, + }, + required: ['records'], + }, + ], +}; diff --git a/packages/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts index 61614ebde..002a470be 100644 --- a/packages/json-schemas/src/schemas.ts +++ b/packages/json-schemas/src/schemas.ts @@ -16,6 +16,7 @@ import { 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'; @@ -54,6 +55,7 @@ export const schemas = { txDataSchema, paginatedCollectionSchema, relayerApiErrorResponseSchema, + relayerApiFeeRecipientsResponseSchema, relayerApiOrderSchema, relayerApiOrdersSchema, relayerApiOrderConfigPayloadSchema, -- cgit v1.2.3 From c9e1b7c5dc4eebf447fdc97568f08db0e2546904 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 8 Aug 2018 11:57:16 -0700 Subject: Change remainingFillableAmount to metaData --- packages/json-schemas/schemas/relayer_api_order_schema.ts | 4 ++-- packages/json-schemas/test/schema_test.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/schemas/relayer_api_order_schema.ts b/packages/json-schemas/schemas/relayer_api_order_schema.ts index 17fa146c4..3952e9683 100644 --- a/packages/json-schemas/schemas/relayer_api_order_schema.ts +++ b/packages/json-schemas/schemas/relayer_api_order_schema.ts @@ -3,7 +3,7 @@ export const relayerApiOrderSchema = { type: 'object', properties: { order: { $ref: '/orderSchema' }, - remainingFillableAmount: { $ref: '/numberSchema' }, + metaData: { type: 'object' }, }, - required: ['order', 'remainingFillableAmount'], + required: ['order', 'metaData'], }; diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index 01fa53045..1f59f4da2 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -214,7 +214,9 @@ describe('Schema', () => { }; const relayerApiOrder = { order, - remainingFillableAmount: '50000000000000', + metaData: { + someMetaData: 5, + }, }; const relayerApiOrdersResponse = { ...paginatedResponse, @@ -353,7 +355,7 @@ describe('Schema', () => { validateAgainstSchema(testCases, relayerApiOrderSchema); }); it('should fail for invalid relayer api orders', () => { - const testCases = [{}, order, { order }, { order, remainingFillableAmount: 5 }]; + const testCases = [{}, order, { order }, { order, metaData: 5 }]; const shouldFail = true; validateAgainstSchema(testCases, relayerApiOrderSchema, shouldFail); }); -- cgit v1.2.3 From 76b91cbcda160b4143fb36cbcd1c1db24bb68229 Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 8 Aug 2018 14:16:59 -0700 Subject: Enforce that error code are ints not number --- packages/json-schemas/schemas/relayer_api_error_response_schema.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/schemas/relayer_api_error_response_schema.ts b/packages/json-schemas/schemas/relayer_api_error_response_schema.ts index 05740aa54..79e33fc85 100644 --- a/packages/json-schemas/schemas/relayer_api_error_response_schema.ts +++ b/packages/json-schemas/schemas/relayer_api_error_response_schema.ts @@ -2,7 +2,7 @@ export const relayerApiErrorResponseSchema = { id: '/relayerApiErrorResponseSchema', type: 'object', properties: { - code: { type: 'number', minimum: 100, maximum: 103 }, + code: { type: 'integer', minimum: 100, maximum: 103 }, reason: { type: 'string' }, validationErrors: { type: 'array', @@ -10,7 +10,7 @@ export const relayerApiErrorResponseSchema = { type: 'object', properties: { field: { type: 'string' }, - code: { type: 'number', minimum: 1000, maximum: 1006 }, + code: { type: 'integer', minimum: 1000, maximum: 1006 }, reason: { type: 'string' }, }, required: ['field', 'code', 'reason'], -- cgit v1.2.3 From cc67c0df51037d093567b82fa4ca7962c5c3bfdd Mon Sep 17 00:00:00 2001 From: fragosti Date: Wed, 8 Aug 2018 14:18:24 -0700 Subject: Correct orderbook typo --- .../json-schemas/schemas/relayer_api_orderbook_response_schema.ts | 4 ++-- packages/json-schemas/src/schemas.ts | 4 ++-- packages/json-schemas/test/schema_test.ts | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts index 2e5b0c6f2..7c0b8e0df 100644 --- a/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts +++ b/packages/json-schemas/schemas/relayer_api_orderbook_response_schema.ts @@ -1,5 +1,5 @@ -export const relayerApiOrderBookResponseSchema = { - id: '/relayerApiOrderBookResponseSchema', +export const relayerApiOrderbookResponseSchema = { + id: '/relayerApiOrderbookResponseSchema', type: 'object', properties: { bids: { $ref: '/relayerApiOrdersResponseSchema' }, diff --git a/packages/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts index 002a470be..3bc37f96b 100644 --- a/packages/json-schemas/src/schemas.ts +++ b/packages/json-schemas/src/schemas.ts @@ -20,7 +20,7 @@ import { relayerApiFeeRecipientsResponseSchema } from '../schemas/relayer_api_fe 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 { relayerApiOrderbookResponseSchema } from '../schemas/relayer_api_orderbook_response_schema'; import { relayerApiOrdersChannelSubscribePayload, relayerApiOrdersChannelSubscribeSchema, @@ -60,7 +60,7 @@ export const schemas = { relayerApiOrdersSchema, relayerApiOrderConfigPayloadSchema, relayerApiOrderConfigResponseSchema, - relayerApiOrderBookResponseSchema, + relayerApiOrderbookResponseSchema, relayerApiAssetDataPairsResponseSchema, relayerApiAssetDataTradeInfoSchema, relayerApiOrdersChannelSubscribeSchema, diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index 1f59f4da2..61ef3d7ac 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -28,7 +28,7 @@ const { txDataSchema, paginatedCollectionSchema, relayerApiErrorResponseSchema, - relayerApiOrderBookResponseSchema, + relayerApiOrderbookResponseSchema, relayerApiAssetDataPairsResponseSchema, relayerApiOrderConfigPayloadSchema, relayerApiOrderConfigResponseSchema, @@ -623,7 +623,7 @@ describe('Schema', () => { validateAgainstSchema(testCases, relayerApiOrdersResponseSchema, shouldFail); }); }); - describe('#relayerApiOrderBookResponseSchema', () => { + describe('#relayerApiOrderbookResponseSchema', () => { it('should validate valid order book responses', () => { const testCases = [ { @@ -657,7 +657,7 @@ describe('Schema', () => { }, }, ]; - validateAgainstSchema(testCases, relayerApiOrderBookResponseSchema); + validateAgainstSchema(testCases, relayerApiOrderbookResponseSchema); }); it('should fail for invalid order fill requests', () => { const testCases = [ -- cgit v1.2.3 From 2f66f26048af6e1edb415fd632dbb2e078cb8597 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 9 Aug 2018 16:41:43 -0700 Subject: Fix linting issues --- packages/json-schemas/test/schema_test.ts | 1 - 1 file changed, 1 deletion(-) (limited to 'packages/json-schemas') diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index 61ef3d7ac..39cdec8a2 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -534,7 +534,6 @@ describe('Schema', () => { validateAgainstSchema(testCases, relayerApiAssetDataPairsResponseSchema); }); it('should fail for invalid assetPairs responses', () => { - const checksummedAddress = '0xA2b31daCf30a9C50ca473337c01d8A201ae33e32'; const testCases = [ { ...paginatedResponse, -- cgit v1.2.3