@lightconexyz/lightcone-sdk 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -206
- package/dist/auth/client.d.ts +25 -0
- package/dist/auth/client.d.ts.map +1 -0
- package/dist/auth/client.js +120 -0
- package/dist/auth/client.js.map +1 -0
- package/dist/auth/index.d.ts +73 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +42 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/native.d.ts +8 -0
- package/dist/auth/native.d.ts.map +1 -0
- package/dist/auth/native.js +19 -0
- package/dist/auth/native.js.map +1 -0
- package/dist/auth.d.ts +1 -79
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +15 -145
- package/dist/auth.js.map +1 -1
- package/dist/client.d.ts +69 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +158 -0
- package/dist/client.js.map +1 -0
- package/dist/domain/admin/client.d.ts +17 -0
- package/dist/domain/admin/client.d.ts.map +1 -0
- package/dist/domain/admin/client.js +32 -0
- package/dist/domain/admin/client.js.map +1 -0
- package/dist/domain/admin/index.d.ts +7 -0
- package/dist/domain/admin/index.d.ts.map +1 -0
- package/dist/domain/admin/index.js +19 -0
- package/dist/domain/admin/index.js.map +1 -0
- package/dist/domain/admin/wire.d.ts +117 -0
- package/dist/domain/admin/wire.d.ts.map +1 -0
- package/dist/domain/admin/wire.js +3 -0
- package/dist/domain/admin/wire.js.map +1 -0
- package/dist/domain/index.d.ts +9 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +45 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/market/client.d.ts +21 -0
- package/dist/domain/market/client.d.ts.map +1 -0
- package/dist/domain/market/client.js +70 -0
- package/dist/domain/market/client.js.map +1 -0
- package/dist/domain/market/convert.d.ts +8 -0
- package/dist/domain/market/convert.d.ts.map +1 -0
- package/dist/domain/market/convert.js +96 -0
- package/dist/domain/market/convert.js.map +1 -0
- package/dist/domain/market/index.d.ts +47 -0
- package/dist/domain/market/index.d.ts.map +1 -0
- package/dist/domain/market/index.js +58 -0
- package/dist/domain/market/index.js.map +1 -0
- package/dist/domain/market/outcome.d.ts +12 -0
- package/dist/domain/market/outcome.d.ts.map +1 -0
- package/dist/domain/market/outcome.js +28 -0
- package/dist/domain/market/outcome.js.map +1 -0
- package/dist/domain/market/tokens.d.ts +42 -0
- package/dist/domain/market/tokens.d.ts.map +1 -0
- package/dist/domain/market/tokens.js +106 -0
- package/dist/domain/market/tokens.js.map +1 -0
- package/dist/domain/market/wire.d.ts +116 -0
- package/dist/domain/market/wire.d.ts.map +1 -0
- package/dist/domain/market/wire.js +3 -0
- package/dist/domain/market/wire.js.map +1 -0
- package/dist/domain/order/client.d.ts +187 -0
- package/dist/domain/order/client.d.ts.map +1 -0
- package/dist/domain/order/client.js +122 -0
- package/dist/domain/order/client.js.map +1 -0
- package/dist/domain/order/convert.d.ts +8 -0
- package/dist/domain/order/convert.d.ts.map +1 -0
- package/dist/domain/order/convert.js +80 -0
- package/dist/domain/order/convert.js.map +1 -0
- package/dist/domain/order/index.d.ts +48 -0
- package/dist/domain/order/index.d.ts.map +1 -0
- package/dist/domain/order/index.js +41 -0
- package/dist/domain/order/index.js.map +1 -0
- package/dist/domain/order/state.d.ts +26 -0
- package/dist/domain/order/state.d.ts.map +1 -0
- package/dist/domain/order/state.js +85 -0
- package/dist/domain/order/state.js.map +1 -0
- package/dist/domain/order/wire.d.ts +123 -0
- package/dist/domain/order/wire.d.ts.map +1 -0
- package/dist/domain/order/wire.js +3 -0
- package/dist/domain/order/wire.js.map +1 -0
- package/dist/domain/orderbook/client.d.ts +20 -0
- package/dist/domain/orderbook/client.d.ts.map +1 -0
- package/dist/domain/orderbook/client.js +30 -0
- package/dist/domain/orderbook/client.js.map +1 -0
- package/dist/domain/orderbook/convert.d.ts +5 -0
- package/dist/domain/orderbook/convert.d.ts.map +1 -0
- package/dist/domain/orderbook/convert.js +34 -0
- package/dist/domain/orderbook/convert.js.map +1 -0
- package/dist/domain/orderbook/index.d.ts +36 -0
- package/dist/domain/orderbook/index.d.ts.map +1 -0
- package/dist/domain/orderbook/index.js +63 -0
- package/dist/domain/orderbook/index.js.map +1 -0
- package/dist/domain/orderbook/state.d.ts +19 -0
- package/dist/domain/orderbook/state.d.ts.map +1 -0
- package/dist/domain/orderbook/state.js +86 -0
- package/dist/domain/orderbook/state.js.map +1 -0
- package/dist/domain/orderbook/ticker.d.ts +8 -0
- package/dist/domain/orderbook/ticker.d.ts.map +1 -0
- package/dist/domain/orderbook/ticker.js +3 -0
- package/dist/domain/orderbook/ticker.js.map +1 -0
- package/dist/domain/orderbook/wire.d.ts +63 -0
- package/dist/domain/orderbook/wire.d.ts.map +1 -0
- package/dist/domain/orderbook/wire.js +3 -0
- package/dist/domain/orderbook/wire.js.map +1 -0
- package/dist/domain/position/client.d.ts +13 -0
- package/dist/domain/position/client.d.ts.map +1 -0
- package/dist/domain/position/client.js +20 -0
- package/dist/domain/position/client.js.map +1 -0
- package/dist/domain/position/index.d.ts +66 -0
- package/dist/domain/position/index.d.ts.map +1 -0
- package/dist/domain/position/index.js +19 -0
- package/dist/domain/position/index.js.map +1 -0
- package/dist/domain/position/wire.d.ts +29 -0
- package/dist/domain/position/wire.d.ts.map +1 -0
- package/dist/domain/position/wire.js +3 -0
- package/dist/domain/position/wire.js.map +1 -0
- package/dist/domain/price_history/client.d.ts +12 -0
- package/dist/domain/price_history/client.d.ts.map +1 -0
- package/dist/domain/price_history/client.js +24 -0
- package/dist/domain/price_history/client.js.map +1 -0
- package/dist/domain/price_history/index.d.ts +14 -0
- package/dist/domain/price_history/index.d.ts.map +1 -0
- package/dist/domain/price_history/index.js +27 -0
- package/dist/domain/price_history/index.js.map +1 -0
- package/dist/domain/price_history/state.d.ts +11 -0
- package/dist/domain/price_history/state.d.ts.map +1 -0
- package/dist/domain/price_history/state.js +35 -0
- package/dist/domain/price_history/state.js.map +1 -0
- package/dist/domain/price_history/wire.d.ts +45 -0
- package/dist/domain/price_history/wire.d.ts.map +1 -0
- package/dist/domain/price_history/wire.js +3 -0
- package/dist/domain/price_history/wire.js.map +1 -0
- package/dist/domain/referral/client.d.ts +13 -0
- package/dist/domain/referral/client.d.ts.map +1 -0
- package/dist/domain/referral/client.js +34 -0
- package/dist/domain/referral/client.js.map +1 -0
- package/dist/domain/referral/index.d.ts +17 -0
- package/dist/domain/referral/index.d.ts.map +1 -0
- package/dist/domain/referral/index.js +19 -0
- package/dist/domain/referral/index.js.map +1 -0
- package/dist/domain/referral/wire.d.ts +22 -0
- package/dist/domain/referral/wire.d.ts.map +1 -0
- package/dist/domain/referral/wire.js +3 -0
- package/dist/domain/referral/wire.js.map +1 -0
- package/dist/domain/trade/client.d.ts +12 -0
- package/dist/domain/trade/client.d.ts.map +1 -0
- package/dist/domain/trade/client.js +27 -0
- package/dist/domain/trade/client.js.map +1 -0
- package/dist/domain/trade/convert.d.ts +5 -0
- package/dist/domain/trade/convert.d.ts.map +1 -0
- package/dist/domain/trade/convert.js +25 -0
- package/dist/domain/trade/convert.js.map +1 -0
- package/dist/domain/trade/index.d.ts +19 -0
- package/dist/domain/trade/index.d.ts.map +1 -0
- package/dist/domain/trade/index.js +24 -0
- package/dist/domain/trade/index.js.map +1 -0
- package/dist/domain/trade/state.d.ts +16 -0
- package/dist/domain/trade/state.d.ts.map +1 -0
- package/dist/domain/trade/state.js +40 -0
- package/dist/domain/trade/state.js.map +1 -0
- package/dist/domain/trade/wire.d.ts +34 -0
- package/dist/domain/trade/wire.d.ts.map +1 -0
- package/dist/domain/trade/wire.js +3 -0
- package/dist/domain/trade/wire.js.map +1 -0
- package/dist/error.d.ts +44 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +126 -0
- package/dist/error.js.map +1 -0
- package/dist/http/client.d.ts +16 -0
- package/dist/http/client.d.ts.map +1 -0
- package/dist/http/client.js +146 -0
- package/dist/http/client.js.map +1 -0
- package/dist/http/index.d.ts +3 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +12 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/retry.d.ts +30 -0
- package/dist/http/retry.d.ts.map +1 -0
- package/dist/http/retry.js +48 -0
- package/dist/http/retry.js.map +1 -0
- package/dist/index.d.ts +13 -51
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -68
- package/dist/index.js.map +1 -1
- package/dist/network.d.ts +4 -4
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +4 -4
- package/dist/network.js.map +1 -1
- package/dist/prelude.d.ts +41 -0
- package/dist/prelude.d.ts.map +1 -0
- package/dist/prelude.js +55 -0
- package/dist/prelude.js.map +1 -0
- package/dist/privy/client.d.ts +17 -0
- package/dist/privy/client.d.ts.map +1 -0
- package/dist/privy/client.js +66 -0
- package/dist/privy/client.js.map +1 -0
- package/dist/privy/index.d.ts +57 -0
- package/dist/privy/index.d.ts.map +1 -0
- package/dist/privy/index.js +80 -0
- package/dist/privy/index.js.map +1 -0
- package/dist/program/accounts.d.ts +16 -1
- package/dist/program/accounts.d.ts.map +1 -1
- package/dist/program/accounts.js +41 -0
- package/dist/program/accounts.js.map +1 -1
- package/dist/program/builder.d.ts +15 -11
- package/dist/program/builder.d.ts.map +1 -1
- package/dist/program/builder.js +30 -22
- package/dist/program/builder.js.map +1 -1
- package/dist/program/client.d.ts +37 -1
- package/dist/program/client.d.ts.map +1 -1
- package/dist/program/client.js +82 -2
- package/dist/program/client.js.map +1 -1
- package/dist/program/constants.d.ts +9 -1
- package/dist/program/constants.d.ts.map +1 -1
- package/dist/program/constants.js +9 -1
- package/dist/program/constants.js.map +1 -1
- package/dist/program/envelope.d.ts +94 -0
- package/dist/program/envelope.d.ts.map +1 -0
- package/dist/program/envelope.js +258 -0
- package/dist/program/envelope.js.map +1 -0
- package/dist/program/error.d.ts +8 -0
- package/dist/program/error.d.ts.map +1 -0
- package/dist/program/error.js +20 -0
- package/dist/program/error.js.map +1 -0
- package/dist/program/index.d.ts +8 -5
- package/dist/program/index.d.ts.map +1 -1
- package/dist/program/index.js +28 -3
- package/dist/program/index.js.map +1 -1
- package/dist/program/instructions.d.ts +78 -1
- package/dist/program/instructions.d.ts.map +1 -1
- package/dist/program/instructions.js +277 -3
- package/dist/program/instructions.js.map +1 -1
- package/dist/program/orders.d.ts +26 -8
- package/dist/program/orders.d.ts.map +1 -1
- package/dist/program/orders.js +58 -31
- package/dist/program/orders.js.map +1 -1
- package/dist/program/pda.d.ts +19 -0
- package/dist/program/pda.d.ts.map +1 -1
- package/dist/program/pda.js +28 -0
- package/dist/program/pda.js.map +1 -1
- package/dist/program/types.d.ts +72 -9
- package/dist/program/types.d.ts.map +1 -1
- package/dist/program/types.js.map +1 -1
- package/dist/shared/fmt/decimal.d.ts +5 -0
- package/dist/shared/fmt/decimal.d.ts.map +1 -0
- package/dist/shared/fmt/decimal.js +54 -0
- package/dist/shared/fmt/decimal.js.map +1 -0
- package/dist/shared/fmt/index.d.ts +3 -0
- package/dist/shared/fmt/index.d.ts.map +1 -0
- package/dist/shared/fmt/index.js +39 -0
- package/dist/shared/fmt/index.js.map +1 -0
- package/dist/shared/fmt/num.d.ts +6 -0
- package/dist/shared/fmt/num.d.ts.map +1 -0
- package/dist/shared/fmt/num.js +44 -0
- package/dist/shared/fmt/num.js.map +1 -0
- package/dist/shared/index.d.ts +4 -7
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +19 -7
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/price.d.ts +5 -33
- package/dist/shared/price.d.ts.map +1 -1
- package/dist/shared/price.js +11 -39
- package/dist/shared/price.js.map +1 -1
- package/dist/shared/scaling.d.ts +17 -30
- package/dist/shared/scaling.d.ts.map +1 -1
- package/dist/shared/scaling.js +88 -57
- package/dist/shared/scaling.js.map +1 -1
- package/dist/shared/types.d.ts +66 -16
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/types.js +81 -17
- package/dist/shared/types.js.map +1 -1
- package/dist/ws/client.browser.d.ts +46 -0
- package/dist/ws/client.browser.d.ts.map +1 -0
- package/dist/ws/client.browser.js +245 -0
- package/dist/ws/client.browser.js.map +1 -0
- package/dist/ws/client.node.d.ts +36 -0
- package/dist/ws/client.node.d.ts.map +1 -0
- package/dist/ws/client.node.js +226 -0
- package/dist/ws/client.node.js.map +1 -0
- package/dist/ws/index.d.ts +110 -0
- package/dist/ws/index.d.ts.map +1 -0
- package/dist/ws/index.js +181 -0
- package/dist/ws/index.js.map +1 -0
- package/dist/ws/subscriptions.d.ts +51 -0
- package/dist/ws/subscriptions.d.ts.map +1 -0
- package/dist/ws/subscriptions.js +44 -0
- package/dist/ws/subscriptions.js.map +1 -0
- package/dist/ws/types.d.ts +23 -0
- package/dist/ws/types.d.ts.map +1 -0
- package/dist/ws/types.js +3 -0
- package/dist/ws/types.js.map +1 -0
- package/package.json +10 -13
- package/dist/api/client.d.ts +0 -225
- package/dist/api/client.d.ts.map +0 -1
- package/dist/api/client.js +0 -452
- package/dist/api/client.js.map +0 -1
- package/dist/api/error.d.ts +0 -58
- package/dist/api/error.d.ts.map +0 -1
- package/dist/api/error.js +0 -98
- package/dist/api/error.js.map +0 -1
- package/dist/api/index.d.ts +0 -23
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -51
- package/dist/api/index.js.map +0 -1
- package/dist/api/types/admin.d.ts +0 -49
- package/dist/api/types/admin.d.ts.map +0 -1
- package/dist/api/types/admin.js +0 -13
- package/dist/api/types/admin.js.map +0 -1
- package/dist/api/types/index.d.ts +0 -14
- package/dist/api/types/index.d.ts.map +0 -1
- package/dist/api/types/index.js +0 -13
- package/dist/api/types/index.js.map +0 -1
- package/dist/api/types/market.d.ts +0 -186
- package/dist/api/types/market.d.ts.map +0 -1
- package/dist/api/types/market.js +0 -6
- package/dist/api/types/market.js.map +0 -1
- package/dist/api/types/order.d.ts +0 -190
- package/dist/api/types/order.d.ts.map +0 -1
- package/dist/api/types/order.js +0 -6
- package/dist/api/types/order.js.map +0 -1
- package/dist/api/types/orderbook.d.ts +0 -36
- package/dist/api/types/orderbook.d.ts.map +0 -1
- package/dist/api/types/orderbook.js +0 -6
- package/dist/api/types/orderbook.js.map +0 -1
- package/dist/api/types/position.d.ts +0 -60
- package/dist/api/types/position.d.ts.map +0 -1
- package/dist/api/types/position.js +0 -6
- package/dist/api/types/position.js.map +0 -1
- package/dist/api/types/price_history.d.ts +0 -68
- package/dist/api/types/price_history.d.ts.map +0 -1
- package/dist/api/types/price_history.js +0 -13
- package/dist/api/types/price_history.js.map +0 -1
- package/dist/api/types/trade.d.ts +0 -67
- package/dist/api/types/trade.d.ts.map +0 -1
- package/dist/api/types/trade.js +0 -13
- package/dist/api/types/trade.js.map +0 -1
- package/dist/api/validation.d.ts +0 -24
- package/dist/api/validation.d.ts.map +0 -1
- package/dist/api/validation.js +0 -53
- package/dist/api/validation.js.map +0 -1
- package/dist/websocket/client.d.ts +0 -238
- package/dist/websocket/client.d.ts.map +0 -1
- package/dist/websocket/client.js +0 -580
- package/dist/websocket/client.js.map +0 -1
- package/dist/websocket/error.d.ts +0 -47
- package/dist/websocket/error.d.ts.map +0 -1
- package/dist/websocket/error.js +0 -83
- package/dist/websocket/error.js.map +0 -1
- package/dist/websocket/handlers.d.ts +0 -97
- package/dist/websocket/handlers.d.ts.map +0 -1
- package/dist/websocket/handlers.js +0 -277
- package/dist/websocket/handlers.js.map +0 -1
- package/dist/websocket/index.d.ts +0 -38
- package/dist/websocket/index.d.ts.map +0 -1
- package/dist/websocket/index.js +0 -75
- package/dist/websocket/index.js.map +0 -1
- package/dist/websocket/state/index.d.ts +0 -7
- package/dist/websocket/state/index.d.ts.map +0 -1
- package/dist/websocket/state/index.js +0 -14
- package/dist/websocket/state/index.js.map +0 -1
- package/dist/websocket/state/orderbook.d.ts +0 -107
- package/dist/websocket/state/orderbook.d.ts.map +0 -1
- package/dist/websocket/state/orderbook.js +0 -293
- package/dist/websocket/state/orderbook.js.map +0 -1
- package/dist/websocket/state/price.d.ts +0 -108
- package/dist/websocket/state/price.d.ts.map +0 -1
- package/dist/websocket/state/price.js +0 -243
- package/dist/websocket/state/price.js.map +0 -1
- package/dist/websocket/state/user.d.ts +0 -83
- package/dist/websocket/state/user.d.ts.map +0 -1
- package/dist/websocket/state/user.js +0 -228
- package/dist/websocket/state/user.js.map +0 -1
- package/dist/websocket/subscriptions.d.ts +0 -143
- package/dist/websocket/subscriptions.d.ts.map +0 -1
- package/dist/websocket/subscriptions.js +0 -244
- package/dist/websocket/subscriptions.js.map +0 -1
- package/dist/websocket/types.d.ts +0 -417
- package/dist/websocket/types.d.ts.map +0 -1
- package/dist/websocket/types.js +0 -195
- package/dist/websocket/types.js.map +0 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { MarketEvent } from "../domain/market";
|
|
2
|
+
import type { AuthUpdate, UserUpdate } from "../domain/order";
|
|
3
|
+
import type { OrderBook, WsTickerData } from "../domain/orderbook";
|
|
4
|
+
import type { PriceHistory } from "../domain/price_history";
|
|
5
|
+
import type { WsTrade } from "../domain/trade";
|
|
6
|
+
import type { OrderBookId, PubkeyStr, Resolution } from "../shared";
|
|
7
|
+
export * from "./client.node";
|
|
8
|
+
export * from "./subscriptions";
|
|
9
|
+
export type { IWsClient } from "./types";
|
|
10
|
+
export type MessageOut = {
|
|
11
|
+
method: "subscribe";
|
|
12
|
+
params: import("./subscriptions").SubscribeParams;
|
|
13
|
+
} | {
|
|
14
|
+
method: "unsubscribe";
|
|
15
|
+
params: import("./subscriptions").UnsubscribeParams;
|
|
16
|
+
} | {
|
|
17
|
+
method: "ping";
|
|
18
|
+
};
|
|
19
|
+
export type MessageIn = {
|
|
20
|
+
type: "book_update";
|
|
21
|
+
version: number;
|
|
22
|
+
data: OrderBook;
|
|
23
|
+
} | {
|
|
24
|
+
type: "pong";
|
|
25
|
+
version: number;
|
|
26
|
+
data: Record<string, never>;
|
|
27
|
+
} | {
|
|
28
|
+
type: "user";
|
|
29
|
+
version: number;
|
|
30
|
+
data: UserUpdate;
|
|
31
|
+
} | {
|
|
32
|
+
type: "error";
|
|
33
|
+
version: number;
|
|
34
|
+
data: WsError;
|
|
35
|
+
} | {
|
|
36
|
+
type: "price_history";
|
|
37
|
+
version: number;
|
|
38
|
+
data: PriceHistory;
|
|
39
|
+
} | {
|
|
40
|
+
type: "trades";
|
|
41
|
+
version: number;
|
|
42
|
+
data: WsTrade;
|
|
43
|
+
} | {
|
|
44
|
+
type: "auth";
|
|
45
|
+
version: number;
|
|
46
|
+
data: AuthUpdate;
|
|
47
|
+
} | {
|
|
48
|
+
type: "ticker";
|
|
49
|
+
version: number;
|
|
50
|
+
data: WsTickerData;
|
|
51
|
+
} | {
|
|
52
|
+
type: "market";
|
|
53
|
+
version: number;
|
|
54
|
+
data: MarketEvent;
|
|
55
|
+
};
|
|
56
|
+
export type Kind = MessageIn;
|
|
57
|
+
export interface WsError {
|
|
58
|
+
error: string;
|
|
59
|
+
code?: string;
|
|
60
|
+
orderbook_id?: string;
|
|
61
|
+
wallet_address?: string;
|
|
62
|
+
hint?: string;
|
|
63
|
+
details?: string;
|
|
64
|
+
}
|
|
65
|
+
export type WsEvent = {
|
|
66
|
+
type: "Message";
|
|
67
|
+
message: MessageIn;
|
|
68
|
+
} | {
|
|
69
|
+
type: "Connected";
|
|
70
|
+
} | {
|
|
71
|
+
type: "Disconnected";
|
|
72
|
+
code?: number;
|
|
73
|
+
reason: string;
|
|
74
|
+
} | {
|
|
75
|
+
type: "Error";
|
|
76
|
+
error: string;
|
|
77
|
+
} | {
|
|
78
|
+
type: "MaxReconnectReached";
|
|
79
|
+
};
|
|
80
|
+
export interface WsConfig {
|
|
81
|
+
url: string;
|
|
82
|
+
reconnect: boolean;
|
|
83
|
+
maxReconnectAttempts: number;
|
|
84
|
+
baseReconnectDelayMs: number;
|
|
85
|
+
pingIntervalMs: number;
|
|
86
|
+
pongTimeoutMs: number;
|
|
87
|
+
}
|
|
88
|
+
export declare const WS_DEFAULT_CONFIG: WsConfig;
|
|
89
|
+
export declare enum ReadyState {
|
|
90
|
+
Connecting = 0,
|
|
91
|
+
Open = 1,
|
|
92
|
+
Closing = 2,
|
|
93
|
+
Closed = 3
|
|
94
|
+
}
|
|
95
|
+
export declare function readyStateFrom(value: number): ReadyState;
|
|
96
|
+
export declare function ping(): MessageOut;
|
|
97
|
+
export declare function subscribeBooks(orderbookIds: OrderBookId[]): MessageOut;
|
|
98
|
+
export declare function unsubscribeBooks(orderbookIds: OrderBookId[]): MessageOut;
|
|
99
|
+
export declare function subscribeTrades(orderbookIds: OrderBookId[]): MessageOut;
|
|
100
|
+
export declare function unsubscribeTrades(orderbookIds: OrderBookId[]): MessageOut;
|
|
101
|
+
export declare function subscribeUser(walletAddress: PubkeyStr): MessageOut;
|
|
102
|
+
export declare function unsubscribeUser(walletAddress: PubkeyStr): MessageOut;
|
|
103
|
+
export declare function subscribePriceHistory(orderbookId: OrderBookId, resolution: Resolution): MessageOut;
|
|
104
|
+
export declare function unsubscribePriceHistory(orderbookId: OrderBookId, resolution: Resolution): MessageOut;
|
|
105
|
+
export declare function subscribeTicker(orderbookIds: OrderBookId[]): MessageOut;
|
|
106
|
+
export declare function unsubscribeTicker(orderbookIds: OrderBookId[]): MessageOut;
|
|
107
|
+
export declare function subscribeMarket(marketPubkey: PubkeyStr): MessageOut;
|
|
108
|
+
export declare function unsubscribeMarket(marketPubkey: PubkeyStr): MessageOut;
|
|
109
|
+
export declare function parseMessageIn(input: string): MessageIn;
|
|
110
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ws/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAA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&& this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ReadyState = exports.WS_DEFAULT_CONFIG = void 0;
|
|
18
|
+
exports.readyStateFrom = readyStateFrom;
|
|
19
|
+
exports.ping = ping;
|
|
20
|
+
exports.subscribeBooks = subscribeBooks;
|
|
21
|
+
exports.unsubscribeBooks = unsubscribeBooks;
|
|
22
|
+
exports.subscribeTrades = subscribeTrades;
|
|
23
|
+
exports.unsubscribeTrades = unsubscribeTrades;
|
|
24
|
+
exports.subscribeUser = subscribeUser;
|
|
25
|
+
exports.unsubscribeUser = unsubscribeUser;
|
|
26
|
+
exports.subscribePriceHistory = subscribePriceHistory;
|
|
27
|
+
exports.unsubscribePriceHistory = unsubscribePriceHistory;
|
|
28
|
+
exports.subscribeTicker = subscribeTicker;
|
|
29
|
+
exports.unsubscribeTicker = unsubscribeTicker;
|
|
30
|
+
exports.subscribeMarket = subscribeMarket;
|
|
31
|
+
exports.unsubscribeMarket = unsubscribeMarket;
|
|
32
|
+
exports.parseMessageIn = parseMessageIn;
|
|
33
|
+
const network_1 = require("../network");
|
|
34
|
+
__exportStar(require("./client.node"), exports);
|
|
35
|
+
__exportStar(require("./subscriptions"), exports);
|
|
36
|
+
exports.WS_DEFAULT_CONFIG = {
|
|
37
|
+
url: network_1.DEFAULT_WS_URL,
|
|
38
|
+
reconnect: true,
|
|
39
|
+
maxReconnectAttempts: 10,
|
|
40
|
+
baseReconnectDelayMs: 1_000,
|
|
41
|
+
pingIntervalMs: 30_000,
|
|
42
|
+
pongTimeoutMs: 1_000,
|
|
43
|
+
};
|
|
44
|
+
var ReadyState;
|
|
45
|
+
(function (ReadyState) {
|
|
46
|
+
ReadyState[ReadyState["Connecting"] = 0] = "Connecting";
|
|
47
|
+
ReadyState[ReadyState["Open"] = 1] = "Open";
|
|
48
|
+
ReadyState[ReadyState["Closing"] = 2] = "Closing";
|
|
49
|
+
ReadyState[ReadyState["Closed"] = 3] = "Closed";
|
|
50
|
+
})(ReadyState || (exports.ReadyState = ReadyState = {}));
|
|
51
|
+
function readyStateFrom(value) {
|
|
52
|
+
switch (value) {
|
|
53
|
+
case 0:
|
|
54
|
+
return ReadyState.Connecting;
|
|
55
|
+
case 1:
|
|
56
|
+
return ReadyState.Open;
|
|
57
|
+
case 2:
|
|
58
|
+
return ReadyState.Closing;
|
|
59
|
+
case 3:
|
|
60
|
+
default:
|
|
61
|
+
return ReadyState.Closed;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function ping() {
|
|
65
|
+
return { method: "ping" };
|
|
66
|
+
}
|
|
67
|
+
function subscribeBooks(orderbookIds) {
|
|
68
|
+
return {
|
|
69
|
+
method: "subscribe",
|
|
70
|
+
params: {
|
|
71
|
+
type: "book_update",
|
|
72
|
+
orderbook_ids: orderbookIds,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function unsubscribeBooks(orderbookIds) {
|
|
77
|
+
return {
|
|
78
|
+
method: "unsubscribe",
|
|
79
|
+
params: {
|
|
80
|
+
type: "book_update",
|
|
81
|
+
orderbook_ids: orderbookIds,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function subscribeTrades(orderbookIds) {
|
|
86
|
+
return {
|
|
87
|
+
method: "subscribe",
|
|
88
|
+
params: {
|
|
89
|
+
type: "trades",
|
|
90
|
+
orderbook_ids: orderbookIds,
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function unsubscribeTrades(orderbookIds) {
|
|
95
|
+
return {
|
|
96
|
+
method: "unsubscribe",
|
|
97
|
+
params: {
|
|
98
|
+
type: "trades",
|
|
99
|
+
orderbook_ids: orderbookIds,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function subscribeUser(walletAddress) {
|
|
104
|
+
return {
|
|
105
|
+
method: "subscribe",
|
|
106
|
+
params: {
|
|
107
|
+
type: "user",
|
|
108
|
+
wallet_address: walletAddress,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function unsubscribeUser(walletAddress) {
|
|
113
|
+
return {
|
|
114
|
+
method: "unsubscribe",
|
|
115
|
+
params: {
|
|
116
|
+
type: "user",
|
|
117
|
+
wallet_address: walletAddress,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function subscribePriceHistory(orderbookId, resolution) {
|
|
122
|
+
return {
|
|
123
|
+
method: "subscribe",
|
|
124
|
+
params: {
|
|
125
|
+
type: "price_history",
|
|
126
|
+
orderbook_id: orderbookId,
|
|
127
|
+
resolution,
|
|
128
|
+
include_ohlcv: false,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function unsubscribePriceHistory(orderbookId, resolution) {
|
|
133
|
+
return {
|
|
134
|
+
method: "unsubscribe",
|
|
135
|
+
params: {
|
|
136
|
+
type: "price_history",
|
|
137
|
+
orderbook_id: orderbookId,
|
|
138
|
+
resolution,
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function subscribeTicker(orderbookIds) {
|
|
143
|
+
return {
|
|
144
|
+
method: "subscribe",
|
|
145
|
+
params: {
|
|
146
|
+
type: "ticker",
|
|
147
|
+
orderbook_ids: orderbookIds,
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function unsubscribeTicker(orderbookIds) {
|
|
152
|
+
return {
|
|
153
|
+
method: "unsubscribe",
|
|
154
|
+
params: {
|
|
155
|
+
type: "ticker",
|
|
156
|
+
orderbook_ids: orderbookIds,
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function subscribeMarket(marketPubkey) {
|
|
161
|
+
return {
|
|
162
|
+
method: "subscribe",
|
|
163
|
+
params: {
|
|
164
|
+
type: "market",
|
|
165
|
+
market_pubkey: marketPubkey,
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function unsubscribeMarket(marketPubkey) {
|
|
170
|
+
return {
|
|
171
|
+
method: "unsubscribe",
|
|
172
|
+
params: {
|
|
173
|
+
type: "market",
|
|
174
|
+
market_pubkey: marketPubkey,
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function parseMessageIn(input) {
|
|
179
|
+
return JSON.parse(input);
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ws/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAuEA,wCAYC;AAED,oBAEC;AAED,wCAQC;AAED,4CAQC;AAED,0CAQC;AAED,8CAQC;AAED,sCAQC;AAED,0CAQC;AAED,sDAUC;AAED,0DASC;AAED,0CAQC;AAED,8CAQC;AAED,0CAQC;AAED,8CAQC;AAED,wCAEC;AAjND,wCAA4C;AAG5C,gDAA8B;AAC9B,kDAAgC;AA8CnB,QAAA,iBAAiB,GAAa;IACzC,GAAG,EAAE,wBAAc;IACnB,SAAS,EAAE,IAAI;IACf,oBAAoB,E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AE,YAAY;SAC5B;KACF,CAAC;AACJ,CAAC;AAED,SAAgB,iBAAiB,CAAC,YAAuB;IACvD,OAAO;QACL,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,aAAa,EAAE,YAAY;SAC5B;KACF,CAAC;AACJ,CAAC;AAED,SAAgB,cAAc,CAAC,KAAa;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAc,CAAC;AACxC,CAAC","sourcesContent":["import type { MarketEvent } from \"../domain/market\";\nimport type { AuthUpdate, UserUpdate } from \"../domain/order\";\nimport type { OrderBook, WsTickerData } from \"../domain/orderbook\";\nimport type { PriceHistory } from \"../domain/price_history\";\nimport type { WsTrade } from \"../domain/trade\";\nimport { DEFAULT_WS_URL } from \"../network\";\nimport type { OrderBookId, PubkeyStr, Resolution } from \"../shared\";\n\nexport * from \"./client.node\";\nexport * from \"./subscriptions\";\nexport type { IWsClient } from \"./types\";\n\nexport type MessageOut =\n | { method: \"subscribe\"; params: import(\"./subscriptions\").SubscribeParams }\n | { method: \"unsubscribe\"; params: import(\"./subscriptions\").UnsubscribeParams }\n | { method: \"ping\" };\n\nexport type MessageIn =\n | { type: \"book_update\"; version: number; data: OrderBook }\n | { type: \"pong\"; version: number; data: Record<string, never> }\n | { type: \"user\"; version: number; data: UserUpdate }\n | { type: \"error\"; version: number; data: WsError }\n | { type: \"price_history\"; version: number; data: PriceHistory }\n | { type: \"trades\"; version: number; data: WsTrade }\n | { type: \"auth\"; version: number; data: AuthUpdate }\n | { type: \"ticker\"; version: number; data: WsTickerData }\n | { type: \"market\"; version: number; data: MarketEvent };\n\nexport type Kind = MessageIn;\n\nexport interface WsError {\n error: string;\n code?: string;\n orderbook_id?: string;\n wallet_address?: string;\n hint?: string;\n details?: string;\n}\n\nexport type WsEvent =\n | { type: \"Message\"; message: MessageIn }\n | { type: \"Connected\" }\n | { type: \"Disconnected\"; code?: number; reason: string }\n | { type: \"Error\"; error: string }\n | { type: \"MaxReconnectReached\" };\n\nexport interface WsConfig {\n url: string;\n reconnect: boolean;\n maxReconnectAttempts: number;\n baseReconnectDelayMs: number;\n pingIntervalMs: number;\n pongTimeoutMs: number;\n}\n\nexport const WS_DEFAULT_CONFIG: WsConfig = {\n url: DEFAULT_WS_URL,\n reconnect: true,\n maxReconnectAttempts: 10,\n baseReconnectDelayMs: 1_000,\n pingIntervalMs: 30_000,\n pongTimeoutMs: 1_000,\n};\n\nexport enum ReadyState {\n Connecting = 0,\n Open = 1,\n Closing = 2,\n Closed = 3,\n}\n\nexport function readyStateFrom(value: number): ReadyState {\n switch (value) {\n case 0:\n return ReadyState.Connecting;\n case 1:\n return ReadyState.Open;\n case 2:\n return ReadyState.Closing;\n case 3:\n default:\n return ReadyState.Closed;\n }\n}\n\nexport function ping(): MessageOut {\n return { method: \"ping\" };\n}\n\nexport function subscribeBooks(orderbookIds: OrderBookId[]): MessageOut {\n return {\n method: \"subscribe\",\n params: {\n type: \"book_update\",\n orderbook_ids: orderbookIds,\n },\n };\n}\n\nexport function unsubscribeBooks(orderbookIds: OrderBookId[]): MessageOut {\n return {\n method: \"unsubscribe\",\n params: {\n type: \"book_update\",\n orderbook_ids: orderbookIds,\n },\n };\n}\n\nexport function subscribeTrades(orderbookIds: OrderBookId[]): MessageOut {\n return {\n method: \"subscribe\",\n params: {\n type: \"trades\",\n orderbook_ids: orderbookIds,\n },\n };\n}\n\nexport function unsubscribeTrades(orderbookIds: OrderBookId[]): MessageOut {\n return {\n method: \"unsubscribe\",\n params: {\n type: \"trades\",\n orderbook_ids: orderbookIds,\n },\n };\n}\n\nexport function subscribeUser(walletAddress: PubkeyStr): MessageOut {\n return {\n method: \"subscribe\",\n params: {\n type: \"user\",\n wallet_address: walletAddress,\n },\n };\n}\n\nexport function unsubscribeUser(walletAddress: PubkeyStr): MessageOut {\n return {\n method: \"unsubscribe\",\n params: {\n type: \"user\",\n wallet_address: walletAddress,\n },\n };\n}\n\nexport function subscribePriceHistory(orderbookId: OrderBookId, resolution: Resolution): MessageOut {\n return {\n method: \"subscribe\",\n params: {\n type: \"price_history\",\n orderbook_id: orderbookId,\n resolution,\n include_ohlcv: false,\n },\n };\n}\n\nexport function unsubscribePriceHistory(orderbookId: OrderBookId, resolution: Resolution): MessageOut {\n return {\n method: \"unsubscribe\",\n params: {\n type: \"price_history\",\n orderbook_id: orderbookId,\n resolution,\n },\n };\n}\n\nexport function subscribeTicker(orderbookIds: OrderBookId[]): MessageOut {\n return {\n method: \"subscribe\",\n params: {\n type: \"ticker\",\n orderbook_ids: orderbookIds,\n },\n };\n}\n\nexport function unsubscribeTicker(orderbookIds: OrderBookId[]): MessageOut {\n return {\n method: \"unsubscribe\",\n params: {\n type: \"ticker\",\n orderbook_ids: orderbookIds,\n },\n };\n}\n\nexport function subscribeMarket(marketPubkey: PubkeyStr): MessageOut {\n return {\n method: \"subscribe\",\n params: {\n type: \"market\",\n market_pubkey: marketPubkey,\n },\n };\n}\n\nexport function unsubscribeMarket(marketPubkey: PubkeyStr): MessageOut {\n return {\n method: \"unsubscribe\",\n params: {\n type: \"market\",\n market_pubkey: marketPubkey,\n },\n };\n}\n\nexport function parseMessageIn(input: string): MessageIn {\n return JSON.parse(input) as MessageIn;\n}\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { OrderBookId, PubkeyStr, Resolution } from "../shared";
|
|
2
|
+
export type SubscribeParams = {
|
|
3
|
+
type: "book_update";
|
|
4
|
+
orderbook_ids: OrderBookId[];
|
|
5
|
+
} | {
|
|
6
|
+
type: "trades";
|
|
7
|
+
orderbook_ids: OrderBookId[];
|
|
8
|
+
} | {
|
|
9
|
+
type: "user";
|
|
10
|
+
wallet_address: PubkeyStr;
|
|
11
|
+
} | {
|
|
12
|
+
type: "price_history";
|
|
13
|
+
orderbook_id: OrderBookId;
|
|
14
|
+
resolution: Resolution;
|
|
15
|
+
include_ohlcv?: boolean;
|
|
16
|
+
} | {
|
|
17
|
+
type: "ticker";
|
|
18
|
+
orderbook_ids: OrderBookId[];
|
|
19
|
+
} | {
|
|
20
|
+
type: "market";
|
|
21
|
+
market_pubkey: PubkeyStr;
|
|
22
|
+
};
|
|
23
|
+
export type UnsubscribeParams = {
|
|
24
|
+
type: "book_update";
|
|
25
|
+
orderbook_ids: OrderBookId[];
|
|
26
|
+
} | {
|
|
27
|
+
type: "trades";
|
|
28
|
+
orderbook_ids: OrderBookId[];
|
|
29
|
+
} | {
|
|
30
|
+
type: "user";
|
|
31
|
+
wallet_address: PubkeyStr;
|
|
32
|
+
} | {
|
|
33
|
+
type: "price_history";
|
|
34
|
+
orderbook_id: OrderBookId;
|
|
35
|
+
resolution: Resolution;
|
|
36
|
+
} | {
|
|
37
|
+
type: "ticker";
|
|
38
|
+
orderbook_ids: OrderBookId[];
|
|
39
|
+
} | {
|
|
40
|
+
type: "market";
|
|
41
|
+
market_pubkey: PubkeyStr;
|
|
42
|
+
};
|
|
43
|
+
export interface Subscription {
|
|
44
|
+
toSubscribeParams(): SubscribeParams;
|
|
45
|
+
toUnsubscribeParams(): UnsubscribeParams;
|
|
46
|
+
matchesUnsubscribe(unsubscribe: UnsubscribeParams): boolean;
|
|
47
|
+
subscriptionKey(): string;
|
|
48
|
+
}
|
|
49
|
+
export declare function subscriptionKey(params: SubscribeParams): string;
|
|
50
|
+
export declare function unsubscribeMatches(subscribe: SubscribeParams, unsubscribe: UnsubscribeParams): boolean;
|
|
51
|
+
//# sourceMappingURL=subscriptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptions.d.ts","sourceRoot":"","sources":["../../src/ws/subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEpE,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,aAAa,EAAE,WAAW,EAAE,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE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S,EAAE,eAAe,EAC1B,WAAW,EAAE,iBAAiB,GAC7B,OAAO,CAsBT"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.subscriptionKey = subscriptionKey;
|
|
4
|
+
exports.unsubscribeMatches = unsubscribeMatches;
|
|
5
|
+
function subscriptionKey(params) {
|
|
6
|
+
switch (params.type) {
|
|
7
|
+
case "book_update":
|
|
8
|
+
return `book:${idsKey(params.orderbook_ids)}`;
|
|
9
|
+
case "trades":
|
|
10
|
+
return `trades:${idsKey(params.orderbook_ids)}`;
|
|
11
|
+
case "user":
|
|
12
|
+
return `user:${params.wallet_address}`;
|
|
13
|
+
case "price_history":
|
|
14
|
+
return `price_history:${params.orderbook_id}:${params.resolution}`;
|
|
15
|
+
case "ticker":
|
|
16
|
+
return `ticker:${idsKey(params.orderbook_ids)}`;
|
|
17
|
+
case "market":
|
|
18
|
+
return `market:${params.market_pubkey}`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function unsubscribeMatches(subscribe, unsubscribe) {
|
|
22
|
+
if (subscribe.type !== unsubscribe.type) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
switch (subscribe.type) {
|
|
26
|
+
case "book_update":
|
|
27
|
+
return idsKey(subscribe.orderbook_ids) === idsKey(unsubscribe.orderbook_ids);
|
|
28
|
+
case "trades":
|
|
29
|
+
return idsKey(subscribe.orderbook_ids) === idsKey(unsubscribe.orderbook_ids);
|
|
30
|
+
case "ticker":
|
|
31
|
+
return idsKey(subscribe.orderbook_ids) === idsKey(unsubscribe.orderbook_ids);
|
|
32
|
+
case "user":
|
|
33
|
+
return subscribe.wallet_address === unsubscribe.wallet_address;
|
|
34
|
+
case "price_history":
|
|
35
|
+
return (subscribe.orderbook_id === unsubscribe.orderbook_id &&
|
|
36
|
+
subscribe.resolution === unsubscribe.resolution);
|
|
37
|
+
case "market":
|
|
38
|
+
return subscribe.market_pubkey === unsubscribe.market_pubkey;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function idsKey(ids) {
|
|
42
|
+
return [...ids].sort().join(",");
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=subscriptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../../src/ws/subscriptions.ts"],"names":[],"mappings":";;AA8BA,0CAeC;AAED,gDAyBC;AA1CD,SAAgB,eAAe,CAAC,MAAuB;IACrD,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,aAAa;YAChB,OAAO,QAAQ,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QAChD,KAAK,QAAQ;YACX,OAAO,UAAU,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QAClD,KAAK,MAAM;YACT,OAAO,QAAQ,MAAM,CAAC,cAAc,EAAE,CAAC;QACzC,KAAK,eAAe;YAClB,OAAO,iBAAiB,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACrE,KAAK,QAAQ;YACX,OAAO,UAAU,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QAClD,KAAK,QAAQ;YACX,OAAO,UAAU,MAAM,CAAC,aAAa,EAAE,CAAC;IAC5C,CAAC;AACH,CAAC;AAED,SAAgB,kBAAkB,CAChC,SAA0B,EAC1B,WAA8B;IAE9B,IAAI,SAAS,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,aAAa;YAChB,OAAO,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,MAAM,CAAE,WAAgD,CAAC,aAAa,CAAC,CAAC;QACrH,KAAK,QAAQ;YACX,OAAO,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,MAAM,CAAE,WAAgD,CAAC,aAAa,CAAC,CAAC;QACrH,KAAK,QAAQ;YACX,OAAO,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,MAAM,CAAE,WAAgD,CAAC,aAAa,CAAC,CAAC;QACrH,KAAK,MAAM;YACT,OAAO,SAAS,CAAC,cAAc,KAAM,WAA6C,CAAC,cAAc,CAAC;QACpG,KAAK,eAAe;YAClB,OAAO,CACL,SAAS,CAAC,YAAY,KAAM,WAA6C,CAAC,YAAY;gBACtF,SAAS,CAAC,UAAU,KAAM,WAA0C,CAAC,UAAU,CAChF,CAAC;QACJ,KAAK,QAAQ;YACX,OAAO,SAAS,CAAC,aAAa,KAAM,WAA4C,CAAC,aAAa,CAAC;IACnG,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,GAAsB;IACpC,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC","sourcesContent":["import type { OrderBookId, PubkeyStr, Resolution } from \"../shared\";\n\nexport type SubscribeParams =\n | { type: \"book_update\"; orderbook_ids: OrderBookId[] }\n | { type: \"trades\"; orderbook_ids: OrderBookId[] }\n | { type: \"user\"; wallet_address: PubkeyStr }\n | {\n type: \"price_history\";\n orderbook_id: OrderBookId;\n resolution: Resolution;\n include_ohlcv?: boolean;\n }\n | { type: \"ticker\"; orderbook_ids: OrderBookId[] }\n | { type: \"market\"; market_pubkey: PubkeyStr };\n\nexport type UnsubscribeParams =\n | { type: \"book_update\"; orderbook_ids: OrderBookId[] }\n | { type: \"trades\"; orderbook_ids: OrderBookId[] }\n | { type: \"user\"; wallet_address: PubkeyStr }\n | { type: \"price_history\"; orderbook_id: OrderBookId; resolution: Resolution }\n | { type: \"ticker\"; orderbook_ids: OrderBookId[] }\n | { type: \"market\"; market_pubkey: PubkeyStr };\n\nexport interface Subscription {\n toSubscribeParams(): SubscribeParams;\n toUnsubscribeParams(): UnsubscribeParams;\n matchesUnsubscribe(unsubscribe: UnsubscribeParams): boolean;\n subscriptionKey(): string;\n}\n\nexport function subscriptionKey(params: SubscribeParams): string {\n switch (params.type) {\n case \"book_update\":\n return `book:${idsKey(params.orderbook_ids)}`;\n case \"trades\":\n return `trades:${idsKey(params.orderbook_ids)}`;\n case \"user\":\n return `user:${params.wallet_address}`;\n case \"price_history\":\n return `price_history:${params.orderbook_id}:${params.resolution}`;\n case \"ticker\":\n return `ticker:${idsKey(params.orderbook_ids)}`;\n case \"market\":\n return `market:${params.market_pubkey}`;\n }\n}\n\nexport function unsubscribeMatches(\n subscribe: SubscribeParams,\n unsubscribe: UnsubscribeParams\n): boolean {\n if (subscribe.type !== unsubscribe.type) {\n return false;\n }\n\n switch (subscribe.type) {\n case \"book_update\":\n return idsKey(subscribe.orderbook_ids) === idsKey((unsubscribe as { orderbook_ids: OrderBookId[] }).orderbook_ids);\n case \"trades\":\n return idsKey(subscribe.orderbook_ids) === idsKey((unsubscribe as { orderbook_ids: OrderBookId[] }).orderbook_ids);\n case \"ticker\":\n return idsKey(subscribe.orderbook_ids) === idsKey((unsubscribe as { orderbook_ids: OrderBookId[] }).orderbook_ids);\n case \"user\":\n return subscribe.wallet_address === (unsubscribe as { wallet_address: PubkeyStr }).wallet_address;\n case \"price_history\":\n return (\n subscribe.orderbook_id === (unsubscribe as { orderbook_id: OrderBookId }).orderbook_id &&\n subscribe.resolution === (unsubscribe as { resolution: Resolution }).resolution\n );\n case \"market\":\n return subscribe.market_pubkey === (unsubscribe as { market_pubkey: PubkeyStr }).market_pubkey;\n }\n}\n\nfunction idsKey(ids: readonly string[]): string {\n return [...ids].sort().join(\",\");\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { MessageOut, ReadyState, WsEvent } from "./index";
|
|
2
|
+
import type { SubscribeParams, UnsubscribeParams } from "./subscriptions";
|
|
3
|
+
/**
|
|
4
|
+
* Shared interface for WebSocket clients.
|
|
5
|
+
*
|
|
6
|
+
* Two implementations exist:
|
|
7
|
+
* - `client.node.ts` — Node.js, backed by the `ws` npm module
|
|
8
|
+
* - `client.browser.ts` — Browser, backed by native `globalThis.WebSocket`
|
|
9
|
+
*
|
|
10
|
+
* The active implementation is selected at build time via the `"browser"`
|
|
11
|
+
* field in package.json.
|
|
12
|
+
*/
|
|
13
|
+
export interface IWsClient {
|
|
14
|
+
connect(): Promise<void>;
|
|
15
|
+
disconnect(): Promise<void>;
|
|
16
|
+
send(message: MessageOut): void;
|
|
17
|
+
subscribe(params: SubscribeParams): void;
|
|
18
|
+
unsubscribe(params: UnsubscribeParams): void;
|
|
19
|
+
isConnected(): boolean;
|
|
20
|
+
readyState(): ReadyState;
|
|
21
|
+
on(callback: (event: WsEvent) => void): () => void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ws/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE1E;;;;;;;;;GASG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAC;IAChC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IACzC,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC7C,WAAW,IAAI,OAAO,CAAC;IACvB,UAAU,IAAI,UAAU,CAAC;IACzB,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACpD"}
|
package/dist/ws/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ws/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { MessageOut, ReadyState, WsEvent } from \"./index\";\nimport type { SubscribeParams, UnsubscribeParams } from \"./subscriptions\";\n\n/**\n * Shared interface for WebSocket clients.\n *\n * Two implementations exist:\n * - `client.node.ts` — Node.js, backed by the `ws` npm module\n * - `client.browser.ts` — Browser, backed by native `globalThis.WebSocket`\n *\n * The active implementation is selected at build time via the `\"browser\"`\n * field in package.json.\n */\nexport interface IWsClient {\n connect(): Promise<void>;\n disconnect(): Promise<void>;\n send(message: MessageOut): void;\n subscribe(params: SubscribeParams): void;\n unsubscribe(params: UnsubscribeParams): void;\n isConnected(): boolean;\n readyState(): ReadyState;\n on(callback: (event: WsEvent) => void): () => void;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightconexyz/lightcone-sdk",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "TypeScript SDK for
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "TypeScript SDK for Lightcone",
|
|
5
5
|
"author": "Lightcone",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -24,19 +24,16 @@
|
|
|
24
24
|
"default": "./dist/index.js"
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
|
+
"browser": {
|
|
28
|
+
"./dist/ws/client.node.js": "./dist/ws/client.browser.js"
|
|
29
|
+
},
|
|
27
30
|
"scripts": {
|
|
28
31
|
"build": "tsc",
|
|
29
32
|
"clean": "rm -rf dist",
|
|
30
33
|
"lint": "eslint src",
|
|
31
34
|
"lint:fix": "eslint src --fix",
|
|
32
|
-
"test": "vitest run",
|
|
33
|
-
"test:watch": "vitest",
|
|
34
|
-
"test:coverage": "vitest run --coverage",
|
|
35
|
-
"test:legacy": "ts-node test/unit.test.ts",
|
|
36
|
-
"test:devnet": "ts-node test/devnet.test.ts",
|
|
37
|
-
"test:stress": "ts-node test/stress.test.ts",
|
|
38
35
|
"typecheck": "tsc --noEmit",
|
|
39
|
-
"prepublishOnly": "npm run clean && npm run lint && npm run
|
|
36
|
+
"prepublishOnly": "npm run clean && npm run lint && npm run typecheck && npm run build"
|
|
40
37
|
},
|
|
41
38
|
"dependencies": {
|
|
42
39
|
"@solana/spl-token": "^0.4.14",
|
|
@@ -44,7 +41,9 @@
|
|
|
44
41
|
"bs58": "^5.0.0",
|
|
45
42
|
"decimal.js": "^10.6.0",
|
|
46
43
|
"js-sha3": "^0.9.3",
|
|
47
|
-
"tweetnacl": "^1.0.3"
|
|
44
|
+
"tweetnacl": "^1.0.3"
|
|
45
|
+
},
|
|
46
|
+
"optionalDependencies": {
|
|
48
47
|
"ws": "^8.0.0"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
@@ -53,9 +52,7 @@
|
|
|
53
52
|
"@typescript-eslint/parser": "^7.0.0",
|
|
54
53
|
"dotenv": "^17.2.3",
|
|
55
54
|
"eslint": "^8.57.0",
|
|
56
|
-
"
|
|
57
|
-
"typescript": "^5.9.3",
|
|
58
|
-
"vitest": "^1.6.0"
|
|
55
|
+
"typescript": "^5.9.3"
|
|
59
56
|
},
|
|
60
57
|
"peerDependencies": {
|
|
61
58
|
"@solana/web3.js": "^1.90.0"
|