aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-watcher
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-12-17 08:52:37 +0800
committerFabio Berger <me@fabioberger.com>2018-12-17 08:52:37 +0800
commitee4185ab465c76b64b65efefb92e11b0ca4ecad4 (patch)
treeafbe107fe1de101ad8e804df35f3886b0fbc7276 /packages/order-watcher
parent7661cfc85ef9e267d15bd4d7bd06c3b6cc3f7931 (diff)
downloaddexon-sol-tools-ee4185ab465c76b64b65efefb92e11b0ca4ecad4.tar
dexon-sol-tools-ee4185ab465c76b64b65efefb92e11b0ca4ecad4.tar.gz
dexon-sol-tools-ee4185ab465c76b64b65efefb92e11b0ca4ecad4.tar.bz2
dexon-sol-tools-ee4185ab465c76b64b65efefb92e11b0ca4ecad4.tar.lz
dexon-sol-tools-ee4185ab465c76b64b65efefb92e11b0ca4ecad4.tar.xz
dexon-sol-tools-ee4185ab465c76b64b65efefb92e11b0ca4ecad4.tar.zst
dexon-sol-tools-ee4185ab465c76b64b65efefb92e11b0ca4ecad4.zip
Move OrderWatcher Websocket schemas to json-schemas and convert to JSON so that they are language agnostic
Diffstat (limited to 'packages/order-watcher')
-rw-r--r--packages/order-watcher/src/order_watcher/order_watcher_websocket_server.ts6
-rw-r--r--packages/order-watcher/src/schemas/websocket_schemas.ts61
2 files changed, 3 insertions, 64 deletions
diff --git a/packages/order-watcher/src/order_watcher/order_watcher_websocket_server.ts b/packages/order-watcher/src/order_watcher/order_watcher_websocket_server.ts
index eac48f849..f90961cc8 100644
--- a/packages/order-watcher/src/order_watcher/order_watcher_websocket_server.ts
+++ b/packages/order-watcher/src/order_watcher/order_watcher_websocket_server.ts
@@ -1,11 +1,11 @@
import { ContractAddresses } from '@0x/contract-addresses';
+import { schemas } from '@0x/json-schemas';
import { OrderStateInvalid, OrderStateValid, SignedOrder } from '@0x/types';
import { BigNumber, logUtils } from '@0x/utils';
import { Provider } from 'ethereum-types';
import * as http from 'http';
import * as WebSocket from 'websocket';
-import { webSocketRequestSchema, webSocketUtf8MessageSchema } from '../schemas/websocket_schemas';
import { GetStatsResult, OrderWatcherConfig, OrderWatcherMethod, WebSocketRequest, WebSocketResponse } from '../types';
import { assert } from '../utils/assert';
@@ -105,9 +105,9 @@ export class OrderWatcherWebSocketServer {
private async _onMessageCallbackAsync(connection: WebSocket.connection, message: any): Promise<void> {
let response: WebSocketResponse;
- assert.doesConformToSchema('message', message, webSocketUtf8MessageSchema);
+ assert.doesConformToSchema('message', message, schemas.orderWatcherWebSocketUtf8MessageSchema);
const request: WebSocketRequest = JSON.parse(message.utf8Data);
- assert.doesConformToSchema('request', request, webSocketRequestSchema);
+ assert.doesConformToSchema('request', request, schemas.orderWatcherWebSocketRequestSchema);
assert.isString(request.jsonrpc, JSON_RPC_VERSION);
try {
response = {
diff --git a/packages/order-watcher/src/schemas/websocket_schemas.ts b/packages/order-watcher/src/schemas/websocket_schemas.ts
index 263dd45b3..df54a38e1 100644
--- a/packages/order-watcher/src/schemas/websocket_schemas.ts
+++ b/packages/order-watcher/src/schemas/websocket_schemas.ts
@@ -1,63 +1,2 @@
// TODO: Move these schemas to the `json-schemas` package and convert to JSON
// Rename to `OrderWatcherWebSocketRequestSchema`, etc...
-export const webSocketUtf8MessageSchema = {
- id: '/webSocketUtf8MessageSchema',
- properties: {
- utf8Data: { type: 'string' },
- },
- type: 'object',
- required: ['utf8Data'],
-};
-
-export const webSocketRequestSchema = {
- id: '/webSocketRequestSchema',
- type: 'object',
- definitions: {
- signedOrderParam: {
- type: 'object',
- properties: {
- signedOrder: { $ref: '/signedOrderSchema' },
- },
- required: ['signedOrder'],
- },
- orderHashParam: {
- type: 'object',
- properties: {
- orderHash: { $ref: '/hexSchema' },
- },
- required: ['orderHash'],
- },
- },
- oneOf: [
- {
- type: 'object',
- properties: {
- id: { type: 'string' },
- jsonrpc: { type: 'string' },
- method: { enum: ['ADD_ORDER'] },
- params: { $ref: '#/definitions/signedOrderParam' },
- },
- required: ['id', 'jsonrpc', 'method', 'params'],
- },
- {
- type: 'object',
- properties: {
- id: { type: 'string' },
- jsonrpc: { type: 'string' },
- method: { enum: ['REMOVE_ORDER'] },
- params: { $ref: '#/definitions/orderHashParam' },
- },
- required: ['id', 'jsonrpc', 'method', 'params'],
- },
- {
- type: 'object',
- properties: {
- id: { type: 'string' },
- jsonrpc: { type: 'string' },
- method: { enum: ['GET_STATS'] },
- params: {},
- },
- required: ['id', 'jsonrpc', 'method'],
- },
- ],
-};