aboutsummaryrefslogtreecommitdiffstats
path: root/packages/json-schemas
diff options
context:
space:
mode:
Diffstat (limited to 'packages/json-schemas')
-rw-r--r--packages/json-schemas/schemas/paginated_collection_schema.ts4
-rw-r--r--packages/json-schemas/src/schemas.ts12
-rw-r--r--packages/json-schemas/test/schema_test.ts205
3 files changed, 65 insertions, 156 deletions
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', () => {