aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-watcher/src/types.ts
diff options
context:
space:
mode:
authorkao <zichongkao@gmail.com>2018-12-14 05:33:46 +0800
committerkao <zichongkao@gmail.com>2018-12-15 04:52:55 +0800
commitd9b58848346a4be41684eea244e393afaab6a617 (patch)
treecec032005acf9ad8c70e05a4b5387c1f1df8b79f /packages/order-watcher/src/types.ts
parent687749460d026ae8b16e355c85c70e1e79b63252 (diff)
downloaddexon-sol-tools-d9b58848346a4be41684eea244e393afaab6a617.tar
dexon-sol-tools-d9b58848346a4be41684eea244e393afaab6a617.tar.gz
dexon-sol-tools-d9b58848346a4be41684eea244e393afaab6a617.tar.bz2
dexon-sol-tools-d9b58848346a4be41684eea244e393afaab6a617.tar.lz
dexon-sol-tools-d9b58848346a4be41684eea244e393afaab6a617.tar.xz
dexon-sol-tools-d9b58848346a4be41684eea244e393afaab6a617.tar.zst
dexon-sol-tools-d9b58848346a4be41684eea244e393afaab6a617.zip
Respond to CR
Diffstat (limited to 'packages/order-watcher/src/types.ts')
-rw-r--r--packages/order-watcher/src/types.ts30
1 files changed, 29 insertions, 1 deletions
diff --git a/packages/order-watcher/src/types.ts b/packages/order-watcher/src/types.ts
index 8078dd971..7f6219732 100644
--- a/packages/order-watcher/src/types.ts
+++ b/packages/order-watcher/src/types.ts
@@ -1,4 +1,4 @@
-import { OrderState } from '@0x/types';
+import { OrderState, SignedOrder } from '@0x/types';
import { LogEntryEvent } from 'ethereum-types';
export enum OrderWatcherError {
@@ -31,3 +31,31 @@ export enum InternalOrderWatcherError {
ZrxNotInTokenRegistry = 'ZRX_NOT_IN_TOKEN_REGISTRY',
WethNotInTokenRegistry = 'WETH_NOT_IN_TOKEN_REGISTRY',
}
+
+export enum OrderWatcherAction {
+ // Actions initiated by the user.
+ GetStats = 'GET_STATS',
+ AddOrder = 'ADD_ORDER',
+ RemoveOrder = 'REMOVE_ORDER',
+ // These are spontaneous; they are primarily orderstate changes.
+ Update = 'UPDATE',
+ // `subscribe` and `unsubscribe` are methods of OrderWatcher, but we don't
+ // need to expose them to the WebSocket server user because the user implicitly
+ // subscribes and unsubscribes by connecting and disconnecting from the server.
+}
+
+// Users have to create a json object of this format and attach it to
+// the data field of their WebSocket message to interact with the server.
+export interface WebSocketRequest {
+ action: OrderWatcherAction;
+ signedOrder?: SignedOrder;
+ orderHash?: string;
+}
+
+// Users should expect a json object of this format in the data field
+// of the WebSocket messages that the server sends out.
+export interface WebSocketResponse {
+ action: OrderWatcherAction | null;
+ success: boolean;
+ result: any;
+}