@lightconexyz/lightcone-sdk 0.6.1 → 0.8.1-rc.2
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 +26 -2
- package/dist/auth/client.d.ts +3 -3
- package/dist/auth/client.d.ts.map +1 -1
- package/dist/auth/client.js +19 -36
- package/dist/auth/client.js.map +1 -1
- package/dist/auth/index.d.ts +102 -46
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +91 -7
- package/dist/auth/index.js.map +1 -1
- package/dist/client.d.ts +17 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +36 -17
- package/dist/client.js.map +1 -1
- package/dist/context.d.ts +7 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +60 -6
- package/dist/context.js.map +1 -1
- package/dist/domain/index.d.ts +0 -1
- package/dist/domain/index.d.ts.map +1 -1
- package/dist/domain/index.js +1 -2
- package/dist/domain/index.js.map +1 -1
- package/dist/domain/market/client.js +1 -1
- package/dist/domain/market/client.js.map +1 -1
- package/dist/domain/market/convert.js +1 -1
- package/dist/domain/market/convert.js.map +1 -1
- package/dist/domain/market/index.d.ts +8 -1
- package/dist/domain/market/index.d.ts.map +1 -1
- package/dist/domain/market/index.js +12 -0
- package/dist/domain/market/index.js.map +1 -1
- package/dist/domain/market/outcome.d.ts +1 -0
- package/dist/domain/market/outcome.d.ts.map +1 -1
- package/dist/domain/market/outcome.js +1 -0
- package/dist/domain/market/outcome.js.map +1 -1
- package/dist/domain/market/tokens.d.ts +4 -0
- package/dist/domain/market/tokens.d.ts.map +1 -1
- package/dist/domain/market/tokens.js +14 -1
- package/dist/domain/market/tokens.js.map +1 -1
- package/dist/domain/market/wire.d.ts +24 -2
- package/dist/domain/market/wire.d.ts.map +1 -1
- package/dist/domain/market/wire.js +5 -0
- package/dist/domain/market/wire.js.map +1 -1
- package/dist/domain/metrics/client.d.ts +11 -5
- package/dist/domain/metrics/client.d.ts.map +1 -1
- package/dist/domain/metrics/client.js +52 -5
- package/dist/domain/metrics/client.js.map +1 -1
- package/dist/domain/metrics/wire.d.ts +112 -5
- package/dist/domain/metrics/wire.d.ts.map +1 -1
- package/dist/domain/metrics/wire.js.map +1 -1
- package/dist/domain/notification/client.d.ts +2 -2
- package/dist/domain/notification/client.d.ts.map +1 -1
- package/dist/domain/notification/client.js +3 -3
- package/dist/domain/notification/client.js.map +1 -1
- package/dist/domain/notification/index.d.ts +3 -1
- package/dist/domain/notification/index.d.ts.map +1 -1
- package/dist/domain/notification/index.js.map +1 -1
- package/dist/domain/order/client.d.ts +14 -10
- package/dist/domain/order/client.d.ts.map +1 -1
- package/dist/domain/order/client.js +20 -13
- package/dist/domain/order/client.js.map +1 -1
- package/dist/domain/order/convert.d.ts +1 -1
- package/dist/domain/order/convert.d.ts.map +1 -1
- package/dist/domain/order/convert.js +2 -2
- package/dist/domain/order/convert.js.map +1 -1
- package/dist/domain/order/index.d.ts +2 -1
- package/dist/domain/order/index.d.ts.map +1 -1
- package/dist/domain/order/index.js +11 -3
- package/dist/domain/order/index.js.map +1 -1
- package/dist/domain/orderbook/aggregation.d.ts +50 -0
- package/dist/domain/orderbook/aggregation.d.ts.map +1 -0
- package/dist/domain/orderbook/aggregation.js +85 -0
- package/dist/domain/orderbook/aggregation.js.map +1 -0
- package/dist/domain/orderbook/client.d.ts +17 -3
- package/dist/domain/orderbook/client.d.ts.map +1 -1
- package/dist/domain/orderbook/client.js +41 -3
- package/dist/domain/orderbook/client.js.map +1 -1
- package/dist/domain/orderbook/index.d.ts +1 -0
- package/dist/domain/orderbook/index.d.ts.map +1 -1
- package/dist/domain/orderbook/index.js +1 -0
- package/dist/domain/orderbook/index.js.map +1 -1
- package/dist/domain/orderbook/state.d.ts +29 -31
- package/dist/domain/orderbook/state.d.ts.map +1 -1
- package/dist/domain/orderbook/state.js +20 -67
- package/dist/domain/orderbook/state.js.map +1 -1
- package/dist/domain/orderbook/wire.d.ts +32 -0
- package/dist/domain/orderbook/wire.d.ts.map +1 -1
- package/dist/domain/orderbook/wire.js.map +1 -1
- package/dist/domain/position/builders.d.ts +11 -8
- package/dist/domain/position/builders.d.ts.map +1 -1
- package/dist/domain/position/builders.js +31 -25
- package/dist/domain/position/builders.js.map +1 -1
- package/dist/domain/position/client.d.ts +21 -15
- package/dist/domain/position/client.d.ts.map +1 -1
- package/dist/domain/position/client.js +43 -22
- package/dist/domain/position/client.js.map +1 -1
- package/dist/domain/referral/client.d.ts +2 -2
- package/dist/domain/referral/client.d.ts.map +1 -1
- package/dist/domain/referral/client.js +3 -3
- package/dist/domain/referral/client.js.map +1 -1
- package/dist/domain/trade/client.d.ts +1 -0
- package/dist/domain/trade/client.d.ts.map +1 -1
- package/dist/domain/trade/client.js +14 -0
- package/dist/domain/trade/client.js.map +1 -1
- package/dist/domain/trade/wire.d.ts +6 -0
- package/dist/domain/trade/wire.d.ts.map +1 -1
- package/dist/domain/trade/wire.js.map +1 -1
- package/dist/env.d.ts +24 -4
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +47 -13
- package/dist/env.js.map +1 -1
- package/dist/http/client.d.ts +8 -11
- package/dist/http/client.d.ts.map +1 -1
- package/dist/http/client.js +71 -34
- package/dist/http/client.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/prelude.d.ts +15 -13
- package/dist/prelude.d.ts.map +1 -1
- package/dist/prelude.js +26 -9
- package/dist/prelude.js.map +1 -1
- package/dist/privy/index.d.ts +1 -1
- package/dist/privy/index.js.map +1 -1
- package/dist/program/accounts.d.ts +12 -7
- package/dist/program/accounts.d.ts.map +1 -1
- package/dist/program/accounts.js +38 -16
- package/dist/program/accounts.js.map +1 -1
- package/dist/program/builder.d.ts +0 -4
- package/dist/program/builder.d.ts.map +1 -1
- package/dist/program/builder.js +0 -8
- package/dist/program/builder.js.map +1 -1
- package/dist/program/constants.d.ts +20 -7
- package/dist/program/constants.d.ts.map +1 -1
- package/dist/program/constants.js +21 -8
- package/dist/program/constants.js.map +1 -1
- package/dist/program/error.d.ts +25 -1
- package/dist/program/error.d.ts.map +1 -1
- package/dist/program/error.js +72 -0
- package/dist/program/error.js.map +1 -1
- package/dist/program/index.d.ts +7 -7
- package/dist/program/index.d.ts.map +1 -1
- package/dist/program/index.js +36 -9
- package/dist/program/index.js.map +1 -1
- package/dist/program/instructions.d.ts +184 -71
- package/dist/program/instructions.d.ts.map +1 -1
- package/dist/program/instructions.js +573 -140
- package/dist/program/instructions.js.map +1 -1
- package/dist/program/orders.js +2 -2
- package/dist/program/orders.js.map +1 -1
- package/dist/program/pda.d.ts +21 -3
- package/dist/program/pda.d.ts.map +1 -1
- package/dist/program/pda.js +43 -6
- package/dist/program/pda.js.map +1 -1
- package/dist/program/types.d.ts +139 -21
- package/dist/program/types.d.ts.map +1 -1
- package/dist/program/types.js.map +1 -1
- package/dist/program/utils.d.ts +31 -2
- package/dist/program/utils.d.ts.map +1 -1
- package/dist/program/utils.js +132 -5
- package/dist/program/utils.js.map +1 -1
- package/dist/rpc.d.ts +6 -1
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +9 -7
- package/dist/rpc.js.map +1 -1
- package/dist/rpcFailover.d.ts +22 -0
- package/dist/rpcFailover.d.ts.map +1 -0
- package/dist/rpcFailover.js +71 -0
- package/dist/rpcFailover.js.map +1 -0
- package/dist/shared/fmt/constants.d.ts +5 -0
- package/dist/shared/fmt/constants.d.ts.map +1 -0
- package/dist/shared/fmt/constants.js +25 -0
- package/dist/shared/fmt/constants.js.map +1 -0
- package/dist/shared/fmt/decimal.d.ts +7 -0
- package/dist/shared/fmt/decimal.d.ts.map +1 -1
- package/dist/shared/fmt/decimal.js +28 -20
- package/dist/shared/fmt/decimal.js.map +1 -1
- package/dist/shared/fmt/index.d.ts +1 -0
- package/dist/shared/fmt/index.d.ts.map +1 -1
- package/dist/shared/fmt/index.js +2 -1
- package/dist/shared/fmt/index.js.map +1 -1
- package/dist/shared/fmt/num.d.ts +7 -0
- package/dist/shared/fmt/num.d.ts.map +1 -1
- package/dist/shared/fmt/num.js +27 -15
- package/dist/shared/fmt/num.js.map +1 -1
- package/dist/shared/fmt/str.d.ts +8 -0
- package/dist/shared/fmt/str.d.ts.map +1 -0
- package/dist/shared/fmt/str.js +17 -0
- package/dist/shared/fmt/str.js.map +1 -0
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +11 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/rejection.d.ts.map +1 -1
- package/dist/shared/rejection.js +11 -0
- package/dist/shared/rejection.js.map +1 -1
- package/dist/shared/types.d.ts +41 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/types.js +85 -1
- package/dist/shared/types.js.map +1 -1
- package/dist/ws/client.node.js +1 -1
- package/dist/ws/client.node.js.map +1 -1
- package/dist/ws/index.d.ts +25 -2
- package/dist/ws/index.d.ts.map +1 -1
- package/dist/ws/index.js +23 -2
- package/dist/ws/index.js.map +1 -1
- package/dist/ws/subscriptions.d.ts +12 -0
- package/dist/ws/subscriptions.d.ts.map +1 -1
- package/dist/ws/subscriptions.js +14 -4
- package/dist/ws/subscriptions.js.map +1 -1
- package/package.json +1 -1
- package/dist/domain/admin/client.d.ts +0 -53
- package/dist/domain/admin/client.d.ts.map +0 -1
- package/dist/domain/admin/client.js +0 -199
- package/dist/domain/admin/client.js.map +0 -1
- package/dist/domain/admin/index.d.ts +0 -16
- package/dist/domain/admin/index.d.ts.map +0 -1
- package/dist/domain/admin/index.js +0 -19
- package/dist/domain/admin/index.js.map +0 -1
- package/dist/domain/admin/wire.d.ts +0 -425
- package/dist/domain/admin/wire.d.ts.map +0 -1
- package/dist/domain/admin/wire.js +0 -3
- package/dist/domain/admin/wire.js.map +0 -1
package/dist/ws/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { MarketEvent } from "../domain/market";
|
|
2
2
|
import { type AuthUpdate, type UserUpdate } from "../domain/order/wire";
|
|
3
3
|
import type { OrderBook, WsTickerData } from "../domain/orderbook";
|
|
4
|
+
import { type BookAggregation } from "../domain/orderbook/aggregation";
|
|
4
5
|
import type { DepositAssetPriceEvent, DepositPrice, PriceHistory } from "../domain/price_history";
|
|
5
6
|
import type { WsTrade } from "../domain/trade";
|
|
6
7
|
import type { OrderBookId, PubkeyStr, Resolution } from "../shared";
|
|
@@ -66,6 +67,14 @@ export interface WsError {
|
|
|
66
67
|
error: string;
|
|
67
68
|
code?: string;
|
|
68
69
|
orderbook_id?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Aggregation of the affected book subscription on book-scoped errors
|
|
72
|
+
* (`ENGINE_UNAVAILABLE`, `SUBSCRIPTION_LIMIT_REACHED`,
|
|
73
|
+
* `INVALID_ORDERBOOK_SUBSCRIPTION`). Absent = full precision; pass to
|
|
74
|
+
* `aggregationFromFrame` to identify the `(orderbook, aggregation)` pair.
|
|
75
|
+
*/
|
|
76
|
+
n_sig_figs?: number;
|
|
77
|
+
mantissa?: number;
|
|
69
78
|
wallet_address?: string;
|
|
70
79
|
deposit_asset?: string;
|
|
71
80
|
hint?: string;
|
|
@@ -103,8 +112,22 @@ export declare enum ReadyState {
|
|
|
103
112
|
}
|
|
104
113
|
export declare function readyStateFrom(value: number): ReadyState;
|
|
105
114
|
export declare function ping(): MessageOut;
|
|
106
|
-
|
|
107
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Subscribe to book snapshots, optionally aggregated (Hyperliquid-style).
|
|
117
|
+
*
|
|
118
|
+
* Omit `aggregation` for the raw book. The aggregation is normalized before
|
|
119
|
+
* sending ((5, none) → (5, 1)); validate with `validateAggregation` first —
|
|
120
|
+
* invalid combinations are rejected server-side with
|
|
121
|
+
* `INVALID_ORDERBOOK_SUBSCRIPTION`. `undefined` fields are dropped by
|
|
122
|
+
* `JSON.stringify`, so full precision stays byte-identical to the
|
|
123
|
+
* pre-aggregation message.
|
|
124
|
+
*/
|
|
125
|
+
export declare function subscribeBooks(orderbookIds: OrderBookId[], aggregation?: BookAggregation): MessageOut;
|
|
126
|
+
/**
|
|
127
|
+
* Unsubscribe a book subscription. The aggregation must match the one
|
|
128
|
+
* subscribed (normalized) or the server removes nothing.
|
|
129
|
+
*/
|
|
130
|
+
export declare function unsubscribeBooks(orderbookIds: OrderBookId[], aggregation?: BookAggregation): MessageOut;
|
|
108
131
|
export declare function subscribeTrades(orderbookIds: OrderBookId[]): MessageOut;
|
|
109
132
|
export declare function unsubscribeTrades(orderbookIds: OrderBookId[]): MessageOut;
|
|
110
133
|
export declare function subscribeUser(walletAddress: PubkeyStr): MessageOut;
|
package/dist/ws/index.d.ts.map
CHANGED
|
@@ -1 +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,EAAuB,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EACV,sBAAsB,EACtB,YAAY,EACZ,YAAY,EACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEpE,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,MAAM,UAAU,GAClB;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,OAAO,iBAAiB,EAAE,eAAe,CAAA;CAAE,GAC1E;IAAE,MAAM,EAAE,aAAa,CAAC;IAA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AE,GAAG,UAAU,CAQzE;AAED,wBAAgB,aAAa,CAAC,aAAa,EAAE,SAAS,GAAG,UAAU,CAQlE;AAED,wBAAgB,eAAe,CAAC,aAAa,EAAE,SAAS,GAAG,UAAU,CAQpE;AAED,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,GAAG,UAAU,CAUlG;AAED,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,GAAG,UAAU,CASpG;AAED,wBAAgB,eAAe,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,UAAU,CAQvE;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,UAAU,CAQzE;AAED,wBAAgB,eAAe,CAAC,YAAY,EAAE,SAAS,GAAG,UAAU,CAQnE;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,SAAS,GAAG,UAAU,CAQrE;AAED,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,UAAU,CAS9F;AAED,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,UAAU,CAShG;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,CAK3E;AAED,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,CAK7E;AAgBD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAuBvD"}
|
package/dist/ws/index.js
CHANGED
|
@@ -35,6 +35,7 @@ exports.subscribeDepositAssetPrice = subscribeDepositAssetPrice;
|
|
|
35
35
|
exports.unsubscribeDepositAssetPrice = unsubscribeDepositAssetPrice;
|
|
36
36
|
exports.parseMessageIn = parseMessageIn;
|
|
37
37
|
const wire_1 = require("../domain/order/wire");
|
|
38
|
+
const aggregation_1 = require("../domain/orderbook/aggregation");
|
|
38
39
|
const error_1 = require("../error");
|
|
39
40
|
const env_1 = require("../env");
|
|
40
41
|
__exportStar(require("./client.node"), exports);
|
|
@@ -70,21 +71,41 @@ function readyStateFrom(value) {
|
|
|
70
71
|
function ping() {
|
|
71
72
|
return { method: "ping" };
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Subscribe to book snapshots, optionally aggregated (Hyperliquid-style).
|
|
76
|
+
*
|
|
77
|
+
* Omit `aggregation` for the raw book. The aggregation is normalized before
|
|
78
|
+
* sending ((5, none) → (5, 1)); validate with `validateAggregation` first —
|
|
79
|
+
* invalid combinations are rejected server-side with
|
|
80
|
+
* `INVALID_ORDERBOOK_SUBSCRIPTION`. `undefined` fields are dropped by
|
|
81
|
+
* `JSON.stringify`, so full precision stays byte-identical to the
|
|
82
|
+
* pre-aggregation message.
|
|
83
|
+
*/
|
|
84
|
+
function subscribeBooks(orderbookIds, aggregation = aggregation_1.FULL_PRECISION) {
|
|
85
|
+
const normalized = (0, aggregation_1.normalizeAggregation)(aggregation);
|
|
74
86
|
return {
|
|
75
87
|
method: "subscribe",
|
|
76
88
|
params: {
|
|
77
89
|
type: "book_update",
|
|
78
90
|
orderbook_ids: orderbookIds,
|
|
91
|
+
nSigFigs: normalized.nSigFigs,
|
|
92
|
+
mantissa: normalized.mantissa,
|
|
79
93
|
},
|
|
80
94
|
};
|
|
81
95
|
}
|
|
82
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Unsubscribe a book subscription. The aggregation must match the one
|
|
98
|
+
* subscribed (normalized) or the server removes nothing.
|
|
99
|
+
*/
|
|
100
|
+
function unsubscribeBooks(orderbookIds, aggregation = aggregation_1.FULL_PRECISION) {
|
|
101
|
+
const normalized = (0, aggregation_1.normalizeAggregation)(aggregation);
|
|
83
102
|
return {
|
|
84
103
|
method: "unsubscribe",
|
|
85
104
|
params: {
|
|
86
105
|
type: "book_update",
|
|
87
106
|
orderbook_ids: orderbookIds,
|
|
107
|
+
nSigFigs: normalized.nSigFigs,
|
|
108
|
+
mantissa: normalized.mantissa,
|
|
88
109
|
},
|
|
89
110
|
};
|
|
90
111
|
}
|
package/dist/ws/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ws/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA+EA,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,sDASC;AAED,0DASC;AAOD,gEAKC;AAED,oEAKC;AAgBD,wCAuBC;AAzSD,+CAA6F;AAQ7F,oCAAmD;AACnD,gCAA6C;AAG7C,gDAA8B;AAC9B,kDAAgC;AAiDnB,QAAA,iBAAiB,GAAa;IACzC,GAAG,EAAE,IAAA,WAAK,EAAC,kBAAY,CAAC,IAAI,CAAC;IAC7B,SAAS,EAAE,IAAI;IACf,oBAAoB,EAAE,EAAE;IACxB,oBAAoB,EAAE,KAAK;IAC3B,cAAc,EAAE,MAAM;IACtB,aAAa,EAAE,MAAM;CACtB,CAAC;AAEF,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,uDAAc,CAAA;IACd,2CAAQ,CAAA;IACR,iDAAW,CAAA;IACX,+CAAU,CAAA;AACZ,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB;AAED,SAAgB,cAAc,CAAC,KAAa;IAC1C,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,CAAC;YACJ,OAAO,UAAU,CAAC,UAAU,CAAC;QAC/B,KAAK,CAAC;YACJ,OAAO,UAAU,CAAC,IAAI,CAAC;QACzB,KAAK,CAAC;YACJ,OAAO,UAAU,CAAC,OAAO,CAAC;QAC5B,KAAK,CAAC,CAAC;QACP;YACE,OAAO,UAAU,CAAC,MAAM,CAAC;IAC7B,CAAC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AC;QAC3D,MAAM,IAAI,eAAY,CAAC,eAAe,EAAE,wDAAwD,CAAC,CAAC;IACpG,CAAC;IACD,IAAI,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QAC1E,MAAM,IAAI,eAAY,CAAC,eAAe,EAAE,qDAAqD,CAAC,CAAC;IACjG,CAAC;IACD,MAAM,OAAO,GAAG,MAAmB,CAAC;IACpC,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC5B,OAAO;YACL,GAAG,OAAO;YACV,IAAI,EAAE,IAAA,0BAAmB,EAAC,OAAO,CAAC,IAAiD,CAAC;SACrF,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { MarketEvent } from \"../domain/market\";\nimport { normalizeUserUpdate, type AuthUpdate, type UserUpdate } from \"../domain/order/wire\";\nimport type { OrderBook, WsTickerData } from \"../domain/orderbook\";\nimport type {\n DepositAssetPriceEvent,\n DepositPrice,\n PriceHistory,\n} from \"../domain/price_history\";\nimport type { WsTrade } from \"../domain/trade\";\nimport { WsError as WsErrorClass } from \"../error\";\nimport { LightconeEnv, wsUrl } from \"../env\";\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 | { type: \"deposit_price\"; version: number; data: DepositPrice }\n | { type: \"deposit_asset_price\"; version: number; data: DepositAssetPriceEvent };\n\nexport type Kind = MessageIn;\n\nexport interface WsError {\n error: string;\n code?: string;\n orderbook_id?: string;\n wallet_address?: string;\n deposit_asset?: 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: wsUrl(LightconeEnv.Prod),\n reconnect: true,\n maxReconnectAttempts: 10,\n baseReconnectDelayMs: 1_000,\n pingIntervalMs: 30_000,\n pongTimeoutMs: 10_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 subscribeDepositPrice(depositAsset: string, resolution: Resolution): MessageOut {\n return {\n method: \"subscribe\",\n params: {\n type: \"deposit_price\",\n deposit_asset: depositAsset,\n resolution,\n },\n };\n}\n\nexport function unsubscribeDepositPrice(depositAsset: string, resolution: Resolution): MessageOut {\n return {\n method: \"unsubscribe\",\n params: {\n type: \"deposit_price\",\n deposit_asset: depositAsset,\n resolution,\n },\n };\n}\n\n/**\n * Subscribe to the live spot price for one deposit asset (snapshot +\n * per-asset price ticks). Distinct from `subscribeDepositPrice`, which\n * carries OHLCV candles per resolution.\n */\nexport function subscribeDepositAssetPrice(depositAsset: string): MessageOut {\n return {\n method: \"subscribe\",\n params: { type: \"deposit_asset_price\", deposit_asset: depositAsset },\n };\n}\n\nexport function unsubscribeDepositAssetPrice(depositAsset: string): MessageOut {\n return {\n method: \"unsubscribe\",\n params: { type: \"deposit_asset_price\", deposit_asset: depositAsset },\n };\n}\n\nconst VALID_MESSAGE_TYPES = new Set([\n \"book_update\",\n \"pong\",\n \"user\",\n \"error\",\n \"price_history\",\n \"trades\",\n \"auth\",\n \"ticker\",\n \"market\",\n \"deposit_price\",\n \"deposit_asset_price\",\n]);\n\nexport function parseMessageIn(input: string): MessageIn {\n const parsed: unknown = JSON.parse(input);\n if (typeof parsed !== \"object\" || parsed === null || !(\"type\" in parsed)) {\n throw new WsErrorClass(\"ProtocolError\", `Invalid WS message: missing \"type\" field`);\n }\n const obj = parsed as Record<string, unknown>;\n if (typeof obj.type !== \"string\" || !VALID_MESSAGE_TYPES.has(obj.type)) {\n throw new WsErrorClass(\"ProtocolError\", `Invalid WS message type: \"${String(obj.type)}\"`);\n }\n if (!(\"version\" in obj) || typeof obj.version !== \"number\") {\n throw new WsErrorClass(\"ProtocolError\", `Invalid WS message: missing or invalid \"version\" field`);\n }\n if (!(\"data\" in obj) || typeof obj.data !== \"object\" || obj.data === null) {\n throw new WsErrorClass(\"ProtocolError\", `Invalid WS message: missing or invalid \"data\" field`);\n }\n const message = parsed as MessageIn;\n if (message.type === \"user\") {\n return {\n ...message,\n data: normalizeUserUpdate(message.data as Parameters<typeof normalizeUserUpdate>[0]),\n };\n }\n return message;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AAC,IAAI,CAAC,EAAE,CAAC;QACvE,MAAM,IAAI,eAAY,CAAC,eAAe,EAAE,6BAA6B,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5F,CAAC;IACD,IAAI,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC3D,MAAM,IAAI,eAAY,CAAC,eAAe,EAAE,wDAAwD,CAAC,CAAC;IACpG,CAAC;IACD,IAAI,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QAC1E,MAAM,IAAI,eAAY,CAAC,eAAe,EAAE,qDAAqD,CAAC,CAAC;IACjG,CAAC;IACD,MAAM,OAAO,GAAG,MAAmB,CAAC;IACpC,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC5B,OAAO;YACL,GAAG,OAAO;YACV,IAAI,EAAE,IAAA,0BAAmB,EAAC,OAAO,CAAC,IAAiD,CAAC;SACrF,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { MarketEvent } from \"../domain/market\";\nimport { normalizeUserUpdate, type AuthUpdate, type UserUpdate } from \"../domain/order/wire\";\nimport type { OrderBook, WsTickerData } from \"../domain/orderbook\";\nimport {\n FULL_PRECISION,\n normalizeAggregation,\n type BookAggregation,\n} from \"../domain/orderbook/aggregation\";\nimport type {\n DepositAssetPriceEvent,\n DepositPrice,\n PriceHistory,\n} from \"../domain/price_history\";\nimport type { WsTrade } from \"../domain/trade\";\nimport { WsError as WsErrorClass } from \"../error\";\nimport { LightconeEnv, wsUrl } from \"../env\";\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 | { type: \"deposit_price\"; version: number; data: DepositPrice }\n | { type: \"deposit_asset_price\"; version: number; data: DepositAssetPriceEvent };\n\nexport type Kind = MessageIn;\n\nexport interface WsError {\n error: string;\n code?: string;\n orderbook_id?: string;\n /**\n * Aggregation of the affected book subscription on book-scoped errors\n * (`ENGINE_UNAVAILABLE`, `SUBSCRIPTION_LIMIT_REACHED`,\n * `INVALID_ORDERBOOK_SUBSCRIPTION`). Absent = full precision; pass to\n * `aggregationFromFrame` to identify the `(orderbook, aggregation)` pair.\n */\n n_sig_figs?: number;\n mantissa?: number;\n wallet_address?: string;\n deposit_asset?: 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: wsUrl(LightconeEnv.Prod),\n reconnect: true,\n maxReconnectAttempts: 10,\n baseReconnectDelayMs: 1_000,\n pingIntervalMs: 30_000,\n pongTimeoutMs: 10_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\n/**\n * Subscribe to book snapshots, optionally aggregated (Hyperliquid-style).\n *\n * Omit `aggregation` for the raw book. The aggregation is normalized before\n * sending ((5, none) → (5, 1)); validate with `validateAggregation` first —\n * invalid combinations are rejected server-side with\n * `INVALID_ORDERBOOK_SUBSCRIPTION`. `undefined` fields are dropped by\n * `JSON.stringify`, so full precision stays byte-identical to the\n * pre-aggregation message.\n */\nexport function subscribeBooks(\n orderbookIds: OrderBookId[],\n aggregation: BookAggregation = FULL_PRECISION\n): MessageOut {\n const normalized = normalizeAggregation(aggregation);\n return {\n method: \"subscribe\",\n params: {\n type: \"book_update\",\n orderbook_ids: orderbookIds,\n nSigFigs: normalized.nSigFigs,\n mantissa: normalized.mantissa,\n },\n };\n}\n\n/**\n * Unsubscribe a book subscription. The aggregation must match the one\n * subscribed (normalized) or the server removes nothing.\n */\nexport function unsubscribeBooks(\n orderbookIds: OrderBookId[],\n aggregation: BookAggregation = FULL_PRECISION\n): MessageOut {\n const normalized = normalizeAggregation(aggregation);\n return {\n method: \"unsubscribe\",\n params: {\n type: \"book_update\",\n orderbook_ids: orderbookIds,\n nSigFigs: normalized.nSigFigs,\n mantissa: normalized.mantissa,\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 subscribeDepositPrice(depositAsset: string, resolution: Resolution): MessageOut {\n return {\n method: \"subscribe\",\n params: {\n type: \"deposit_price\",\n deposit_asset: depositAsset,\n resolution,\n },\n };\n}\n\nexport function unsubscribeDepositPrice(depositAsset: string, resolution: Resolution): MessageOut {\n return {\n method: \"unsubscribe\",\n params: {\n type: \"deposit_price\",\n deposit_asset: depositAsset,\n resolution,\n },\n };\n}\n\n/**\n * Subscribe to the live spot price for one deposit asset (snapshot +\n * per-asset price ticks). Distinct from `subscribeDepositPrice`, which\n * carries OHLCV candles per resolution.\n */\nexport function subscribeDepositAssetPrice(depositAsset: string): MessageOut {\n return {\n method: \"subscribe\",\n params: { type: \"deposit_asset_price\", deposit_asset: depositAsset },\n };\n}\n\nexport function unsubscribeDepositAssetPrice(depositAsset: string): MessageOut {\n return {\n method: \"unsubscribe\",\n params: { type: \"deposit_asset_price\", deposit_asset: depositAsset },\n };\n}\n\nconst VALID_MESSAGE_TYPES = new Set([\n \"book_update\",\n \"pong\",\n \"user\",\n \"error\",\n \"price_history\",\n \"trades\",\n \"auth\",\n \"ticker\",\n \"market\",\n \"deposit_price\",\n \"deposit_asset_price\",\n]);\n\nexport function parseMessageIn(input: string): MessageIn {\n const parsed: unknown = JSON.parse(input);\n if (typeof parsed !== \"object\" || parsed === null || !(\"type\" in parsed)) {\n throw new WsErrorClass(\"ProtocolError\", `Invalid WS message: missing \"type\" field`);\n }\n const obj = parsed as Record<string, unknown>;\n if (typeof obj.type !== \"string\" || !VALID_MESSAGE_TYPES.has(obj.type)) {\n throw new WsErrorClass(\"ProtocolError\", `Invalid WS message type: \"${String(obj.type)}\"`);\n }\n if (!(\"version\" in obj) || typeof obj.version !== \"number\") {\n throw new WsErrorClass(\"ProtocolError\", `Invalid WS message: missing or invalid \"version\" field`);\n }\n if (!(\"data\" in obj) || typeof obj.data !== \"object\" || obj.data === null) {\n throw new WsErrorClass(\"ProtocolError\", `Invalid WS message: missing or invalid \"data\" field`);\n }\n const message = parsed as MessageIn;\n if (message.type === \"user\") {\n return {\n ...message,\n data: normalizeUserUpdate(message.data as Parameters<typeof normalizeUserUpdate>[0]),\n };\n }\n return message;\n}\n"]}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import type { OrderBookId, PubkeyStr, Resolution } from "../shared";
|
|
2
|
+
/**
|
|
3
|
+
* Book subscriptions optionally carry a Hyperliquid-style aggregation
|
|
4
|
+
* (`nSigFigs`/`mantissa`, wire spelling — omit both for full precision; the
|
|
5
|
+
* backend rejects unknown/snake_case params). Each `(orderbook, aggregation)`
|
|
6
|
+
* pair is a distinct subscription: one connection may hold multiple
|
|
7
|
+
* aggregation views of the same orderbook, and unsubscribe must repeat the
|
|
8
|
+
* same (normalized) aggregation to match.
|
|
9
|
+
*/
|
|
2
10
|
export type SubscribeParams = {
|
|
3
11
|
type: "book_update";
|
|
4
12
|
orderbook_ids: OrderBookId[];
|
|
13
|
+
nSigFigs?: number;
|
|
14
|
+
mantissa?: number;
|
|
5
15
|
} | {
|
|
6
16
|
type: "trades";
|
|
7
17
|
orderbook_ids: OrderBookId[];
|
|
@@ -30,6 +40,8 @@ export type SubscribeParams = {
|
|
|
30
40
|
export type UnsubscribeParams = {
|
|
31
41
|
type: "book_update";
|
|
32
42
|
orderbook_ids: OrderBookId[];
|
|
43
|
+
nSigFigs?: number;
|
|
44
|
+
mantissa?: number;
|
|
33
45
|
} | {
|
|
34
46
|
type: "trades";
|
|
35
47
|
orderbook_ids: OrderBookId[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions.d.ts","sourceRoot":"","sources":["../../src/ws/subscriptions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subscriptions.d.ts","sourceRoot":"","sources":["../../src/ws/subscriptions.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEpE;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GACvB;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,aAAa,EAAE,WAAW,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GACD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,aAAa,EAAE,WAAW,EAAE,CAAA;CAAE,GAChD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,SAAS,CA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,MAAM,CAAA;CAAE,CAAC;AAE3D,MAAM,WAAW,YAAY;IAC3B,iBAAiB,IAAI,eAAe,CAAC;IACrC,mBAAmB,IAAI,iBAAiB,CAAC;IACzC,kBAAkB,CAAC,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAC5D,eAAe,IAAI,MAAM,CAAC;CAC3B;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAyB/D;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,eAAe,EAC1B,WAAW,EAAE,iBAAiB,GAC7B,OAAO,CAyCT"}
|
package/dist/ws/subscriptions.js
CHANGED
|
@@ -2,10 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.subscriptionKey = subscriptionKey;
|
|
4
4
|
exports.unsubscribeMatches = unsubscribeMatches;
|
|
5
|
+
const aggregation_1 = require("../domain/orderbook/aggregation");
|
|
5
6
|
function subscriptionKey(params) {
|
|
6
7
|
switch (params.type) {
|
|
7
|
-
case "book_update":
|
|
8
|
-
|
|
8
|
+
case "book_update": {
|
|
9
|
+
const aggregation = { nSigFigs: params.nSigFigs, mantissa: params.mantissa };
|
|
10
|
+
// Full precision keeps the pre-aggregation key shape so existing
|
|
11
|
+
// consumers' tracked subscriptions stay stable.
|
|
12
|
+
return (0, aggregation_1.isFullPrecision)(aggregation)
|
|
13
|
+
? `book:${idsKey(params.orderbook_ids)}`
|
|
14
|
+
: `book:${idsKey(params.orderbook_ids)}:${(0, aggregation_1.aggregationKeySuffix)(aggregation)}`;
|
|
15
|
+
}
|
|
9
16
|
case "trades":
|
|
10
17
|
return `trades:${idsKey(params.orderbook_ids)}`;
|
|
11
18
|
case "user":
|
|
@@ -27,8 +34,11 @@ function unsubscribeMatches(subscribe, unsubscribe) {
|
|
|
27
34
|
return false;
|
|
28
35
|
}
|
|
29
36
|
switch (subscribe.type) {
|
|
30
|
-
case "book_update":
|
|
31
|
-
|
|
37
|
+
case "book_update": {
|
|
38
|
+
const unsubscribeBooks = unsubscribe;
|
|
39
|
+
return (idsKey(subscribe.orderbook_ids) === idsKey(unsubscribeBooks.orderbook_ids) &&
|
|
40
|
+
(0, aggregation_1.aggregationsEqual)({ nSigFigs: subscribe.nSigFigs, mantissa: subscribe.mantissa }, { nSigFigs: unsubscribeBooks.nSigFigs, mantissa: unsubscribeBooks.mantissa }));
|
|
41
|
+
}
|
|
32
42
|
case "trades":
|
|
33
43
|
return idsKey(subscribe.orderbook_ids) === idsKey(unsubscribe.orderbook_ids);
|
|
34
44
|
case "ticker":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../../src/ws/subscriptions.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../../src/ws/subscriptions.ts"],"names":[],"mappings":";;AAyDA,0CAyBC;AAED,gDA4CC;AAhID,iEAIyC;AAqDzC,SAAgB,eAAe,CAAC,MAAuB;IACrD,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,MAAM,WAAW,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC7E,iEAAiE;YACjE,gDAAgD;YAChD,OAAO,IAAA,6BAAe,EAAC,WAAW,CAAC;gBACjC,CAAC,CAAC,QAAQ,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;gBACxC,CAAC,CAAC,QAAQ,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,IAAA,kCAAoB,EAAC,WAAW,CAAC,EAAE,CAAC;QAClF,CAAC;QACD,KAAK,QAAQ;YACX,OAAO,UAAU,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QAClD,KAAK,MAAM;YACT,OAAO,QAAQ,MAAM,CAAC,c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K,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;QACjG,KAAK,eAAe;YAClB,OAAO,CACL,SAAS,CAAC,aAAa,KAAM,WAAyC,CAAC,aAAa;gBACpF,SAAS,CAAC,UAAU,KAAM,WAA0C,CAAC,UAAU,CAChF,CAAC;QACJ,KAAK,qBAAqB;YACxB,OAAO,SAAS,CAAC,aAAa,KAAM,WAAyC,CAAC,aAAa,CAAC;IAChG,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 {\n aggregationKeySuffix,\n aggregationsEqual,\n isFullPrecision,\n} from \"../domain/orderbook/aggregation\";\nimport type { OrderBookId, PubkeyStr, Resolution } from \"../shared\";\n\n/**\n * Book subscriptions optionally carry a Hyperliquid-style aggregation\n * (`nSigFigs`/`mantissa`, wire spelling — omit both for full precision; the\n * backend rejects unknown/snake_case params). Each `(orderbook, aggregation)`\n * pair is a distinct subscription: one connection may hold multiple\n * aggregation views of the same orderbook, and unsubscribe must repeat the\n * same (normalized) aggregation to match.\n */\nexport type SubscribeParams =\n | {\n type: \"book_update\";\n orderbook_ids: OrderBookId[];\n nSigFigs?: number;\n mantissa?: number;\n }\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 | { type: \"deposit_price\"; deposit_asset: string; resolution: Resolution }\n | { type: \"deposit_asset_price\"; deposit_asset: string };\n\nexport type UnsubscribeParams =\n | {\n type: \"book_update\";\n orderbook_ids: OrderBookId[];\n nSigFigs?: number;\n mantissa?: number;\n }\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 | { type: \"deposit_price\"; deposit_asset: string; resolution: Resolution }\n | { type: \"deposit_asset_price\"; deposit_asset: string };\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 const aggregation = { nSigFigs: params.nSigFigs, mantissa: params.mantissa };\n // Full precision keeps the pre-aggregation key shape so existing\n // consumers' tracked subscriptions stay stable.\n return isFullPrecision(aggregation)\n ? `book:${idsKey(params.orderbook_ids)}`\n : `book:${idsKey(params.orderbook_ids)}:${aggregationKeySuffix(aggregation)}`;\n }\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 case \"deposit_price\":\n return `deposit_price:${params.deposit_asset}:${params.resolution}`;\n case \"deposit_asset_price\":\n return `deposit_asset_price:${params.deposit_asset}`;\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 const unsubscribeBooks = unsubscribe as {\n orderbook_ids: OrderBookId[];\n nSigFigs?: number;\n mantissa?: number;\n };\n return (\n idsKey(subscribe.orderbook_ids) === idsKey(unsubscribeBooks.orderbook_ids) &&\n aggregationsEqual(\n { nSigFigs: subscribe.nSigFigs, mantissa: subscribe.mantissa },\n { nSigFigs: unsubscribeBooks.nSigFigs, mantissa: unsubscribeBooks.mantissa }\n )\n );\n }\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 case \"deposit_price\":\n return (\n subscribe.deposit_asset === (unsubscribe as { deposit_asset: string }).deposit_asset &&\n subscribe.resolution === (unsubscribe as { resolution: Resolution }).resolution\n );\n case \"deposit_asset_price\":\n return subscribe.deposit_asset === (unsubscribe as { deposit_asset: string }).deposit_asset;\n }\n}\n\nfunction idsKey(ids: readonly string[]): string {\n return [...ids].sort().join(\",\");\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Transaction, type PublicKey, type TransactionInstruction } from "@solana/web3.js";
|
|
2
|
-
import type { ClientContext } from "../../context";
|
|
3
|
-
import type { CreateMarketParams, AddDepositMintParams, ActivateMarketParams, SettleMarketParams, SetAuthorityParams, WhitelistDepositTokenParams, CreateOrderbookParams, MatchOrdersMultiParams, DepositAndSwapParams } from "../../program/types";
|
|
4
|
-
import type { AdminLoginRequest, AdminLoginResponse, AdminNonceResponse } from "./index";
|
|
5
|
-
import type { AdminLogEvent, AdminLogEventsQuery, AdminLogEventsResponse, AdminLogMetricHistoryQuery, AdminLogMetricHistoryResponse, AdminLogMetricsQuery, AdminLogMetricsResponse, AllocateCodesRequest, AllocateCodesResponse, CreateNotificationRequest, CreateNotificationResponse, DismissNotificationRequest, DismissNotificationResponse, ListCodesRequest, ListCodesResponse, ReferralConfig, RevokeRequest, RevokeResponse, UnifiedMetadataRequest, UnifiedMetadataResponse, UnrevokeRequest, UnrevokeResponse, UpdateCodeRequest, UpdateCodeResponse, UpdateConfigRequest, UploadMarketDeploymentAssetsRequest, UploadMarketDeploymentAssetsResponse, WhitelistRequest, WhitelistResponse } from "./wire";
|
|
6
|
-
export declare class Admin {
|
|
7
|
-
private readonly client;
|
|
8
|
-
constructor(client: ClientContext);
|
|
9
|
-
getAdminNonce(): Promise<AdminNonceResponse>;
|
|
10
|
-
adminLogin(request: AdminLoginRequest): Promise<AdminLoginResponse>;
|
|
11
|
-
adminLogout(): Promise<void>;
|
|
12
|
-
upsertMetadata(request: UnifiedMetadataRequest): Promise<UnifiedMetadataResponse>;
|
|
13
|
-
uploadMarketDeploymentAssets(request: UploadMarketDeploymentAssetsRequest): Promise<UploadMarketDeploymentAssetsResponse>;
|
|
14
|
-
allocateCodes(request: AllocateCodesRequest): Promise<AllocateCodesResponse>;
|
|
15
|
-
whitelist(request: WhitelistRequest): Promise<WhitelistResponse>;
|
|
16
|
-
revoke(request: RevokeRequest): Promise<RevokeResponse>;
|
|
17
|
-
unrevoke(request: UnrevokeRequest): Promise<UnrevokeResponse>;
|
|
18
|
-
createNotification(request: CreateNotificationRequest): Promise<CreateNotificationResponse>;
|
|
19
|
-
dismissNotification(request: DismissNotificationRequest): Promise<DismissNotificationResponse>;
|
|
20
|
-
getReferralConfig(): Promise<ReferralConfig>;
|
|
21
|
-
updateReferralConfig(request: UpdateConfigRequest): Promise<ReferralConfig>;
|
|
22
|
-
listReferralCodes(request: ListCodesRequest): Promise<ListCodesResponse>;
|
|
23
|
-
updateReferralCode(request: UpdateCodeRequest): Promise<UpdateCodeResponse>;
|
|
24
|
-
listLogEvents(query: AdminLogEventsQuery): Promise<AdminLogEventsResponse>;
|
|
25
|
-
getLogEvent(publicId: string): Promise<AdminLogEvent>;
|
|
26
|
-
logMetrics(query: AdminLogMetricsQuery): Promise<AdminLogMetricsResponse>;
|
|
27
|
-
logMetricHistory(query: AdminLogMetricHistoryQuery): Promise<AdminLogMetricHistoryResponse>;
|
|
28
|
-
initializeIx(authority: PublicKey): TransactionInstruction;
|
|
29
|
-
createMarketIx(params: CreateMarketParams, marketId: bigint): TransactionInstruction;
|
|
30
|
-
addDepositMintIx(params: AddDepositMintParams, market: PublicKey, numOutcomes: number): TransactionInstruction;
|
|
31
|
-
activateMarketIx(params: ActivateMarketParams): TransactionInstruction;
|
|
32
|
-
settleMarketIx(params: SettleMarketParams): TransactionInstruction;
|
|
33
|
-
setPausedIx(authority: PublicKey, paused: boolean): TransactionInstruction;
|
|
34
|
-
setOperatorIx(authority: PublicKey, newOperator: PublicKey): TransactionInstruction;
|
|
35
|
-
setAuthorityIx(params: SetAuthorityParams): TransactionInstruction;
|
|
36
|
-
whitelistDepositTokenIx(params: WhitelistDepositTokenParams): TransactionInstruction;
|
|
37
|
-
createOrderbookIx(params: CreateOrderbookParams): TransactionInstruction;
|
|
38
|
-
matchOrdersMultiIx(params: MatchOrdersMultiParams): TransactionInstruction;
|
|
39
|
-
depositAndSwapIx(params: DepositAndSwapParams): TransactionInstruction;
|
|
40
|
-
initializeTx(authority: PublicKey): Transaction;
|
|
41
|
-
createMarketTx(params: CreateMarketParams, marketId: bigint): Transaction;
|
|
42
|
-
addDepositMintTx(params: AddDepositMintParams, market: PublicKey, numOutcomes: number): Transaction;
|
|
43
|
-
activateMarketTx(params: ActivateMarketParams): Transaction;
|
|
44
|
-
settleMarketTx(params: SettleMarketParams): Transaction;
|
|
45
|
-
setPausedTx(authority: PublicKey, paused: boolean): Transaction;
|
|
46
|
-
setOperatorTx(authority: PublicKey, newOperator: PublicKey): Transaction;
|
|
47
|
-
setAuthorityTx(params: SetAuthorityParams): Transaction;
|
|
48
|
-
whitelistDepositTokenTx(params: WhitelistDepositTokenParams): Transaction;
|
|
49
|
-
createOrderbookTx(params: CreateOrderbookParams): Transaction;
|
|
50
|
-
matchOrdersMultiTx(params: MatchOrdersMultiParams): Transaction;
|
|
51
|
-
depositAndSwapTx(params: DepositAndSwapParams): Transaction;
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/domain/admin/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAgBnD,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,EAC1B,6BAA6B,EAC7B,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,EAC3B,gBAAgB,EAChB,iBAAiB,EACjB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AAE,MAAM,GAAG,WAAW;IAKzE,gBAAgB,CACd,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,MAAM,GAClB,WAAW;IAKd,gBAAgB,CAAC,MAAM,EAAE,oBAAoB,GAAG,WAAW;IAK3D,cAAc,CAAC,MAAM,EAAE,kBAAkB,GAAG,WAAW;IAKvD,WAAW,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,GAAG,WAAW;IAK/D,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,GAAG,WAAW;IAKxE,cAAc,CAAC,MAAM,EAAE,kBAAkB,GAAG,WAAW;IAKvD,uBAAuB,CAAC,MAAM,EAAE,2BAA2B,GAAG,WAAW;IAKzE,iBAAiB,CAAC,MAAM,EAAE,qBAAqB,GAAG,WAAW;IAK7D,kBAAkB,CAAC,MAAM,EAAE,sBAAsB,GAAG,WAAW;IAK/D,gBAAgB,CAAC,MAAM,EAAE,oBAAoB,GAAG,WAAW;CAI5D"}
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Admin = void 0;
|
|
4
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
-
const http_1 = require("../../http");
|
|
6
|
-
const instructions_1 = require("../../program/instructions");
|
|
7
|
-
class Admin {
|
|
8
|
-
client;
|
|
9
|
-
constructor(client) {
|
|
10
|
-
this.client = client;
|
|
11
|
-
}
|
|
12
|
-
// ── Admin auth ───────────────────────────────────────────────────────
|
|
13
|
-
async getAdminNonce() {
|
|
14
|
-
const url = `${this.client.http.baseUrl()}/api/admin/nonce`;
|
|
15
|
-
return this.client.http.get(url, http_1.RetryPolicy.None);
|
|
16
|
-
}
|
|
17
|
-
async adminLogin(request) {
|
|
18
|
-
const url = `${this.client.http.baseUrl()}/api/admin/login`;
|
|
19
|
-
return this.client.http.post(url, request, http_1.RetryPolicy.None);
|
|
20
|
-
}
|
|
21
|
-
async adminLogout() {
|
|
22
|
-
const url = `${this.client.http.baseUrl()}/api/admin/logout`;
|
|
23
|
-
try {
|
|
24
|
-
await this.client.http.adminPost(url, {}, http_1.RetryPolicy.None);
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
// Backend cookie clear can fail in local/dev setups; still clear local state.
|
|
28
|
-
}
|
|
29
|
-
this.client.http.clearAdminToken();
|
|
30
|
-
}
|
|
31
|
-
// ── HTTP methods ─────────────────────────────────────────────────────
|
|
32
|
-
async upsertMetadata(request) {
|
|
33
|
-
const url = `${this.client.http.baseUrl()}/api/admin/metadata`;
|
|
34
|
-
return this.client.http.adminPost(url, request, http_1.RetryPolicy.None);
|
|
35
|
-
}
|
|
36
|
-
async uploadMarketDeploymentAssets(request) {
|
|
37
|
-
const url = `${this.client.http.baseUrl()}/api/admin/metadata/upload-market-deployment-assets`;
|
|
38
|
-
return this.client.http.adminPost(url, request, http_1.RetryPolicy.None);
|
|
39
|
-
}
|
|
40
|
-
async allocateCodes(request) {
|
|
41
|
-
const url = `${this.client.http.baseUrl()}/api/admin/referral/allocate`;
|
|
42
|
-
return this.client.http.adminPost(url, request, http_1.RetryPolicy.None);
|
|
43
|
-
}
|
|
44
|
-
async whitelist(request) {
|
|
45
|
-
const url = `${this.client.http.baseUrl()}/api/admin/referral/whitelist`;
|
|
46
|
-
return this.client.http.adminPost(url, request, http_1.RetryPolicy.None);
|
|
47
|
-
}
|
|
48
|
-
async revoke(request) {
|
|
49
|
-
const url = `${this.client.http.baseUrl()}/api/admin/referral/revoke`;
|
|
50
|
-
return this.client.http.adminPost(url, request, http_1.RetryPolicy.None);
|
|
51
|
-
}
|
|
52
|
-
async unrevoke(request) {
|
|
53
|
-
const url = `${this.client.http.baseUrl()}/api/admin/referral/unrevoke`;
|
|
54
|
-
return this.client.http.adminPost(url, request, http_1.RetryPolicy.None);
|
|
55
|
-
}
|
|
56
|
-
async createNotification(request) {
|
|
57
|
-
const url = `${this.client.http.baseUrl()}/api/admin/notifications`;
|
|
58
|
-
return this.client.http.adminPost(url, request, http_1.RetryPolicy.None);
|
|
59
|
-
}
|
|
60
|
-
async dismissNotification(request) {
|
|
61
|
-
const url = `${this.client.http.baseUrl()}/api/admin/notifications/dismiss`;
|
|
62
|
-
return this.client.http.adminPost(url, request, http_1.RetryPolicy.None);
|
|
63
|
-
}
|
|
64
|
-
// ── Referral config / codes ──────────────────────────────────────────
|
|
65
|
-
async getReferralConfig() {
|
|
66
|
-
const url = `${this.client.http.baseUrl()}/api/admin/referral/config/get`;
|
|
67
|
-
return this.client.http.adminPost(url, {}, http_1.RetryPolicy.None);
|
|
68
|
-
}
|
|
69
|
-
async updateReferralConfig(request) {
|
|
70
|
-
const url = `${this.client.http.baseUrl()}/api/admin/referral/config/update`;
|
|
71
|
-
return this.client.http.adminPost(url, request, http_1.RetryPolicy.None);
|
|
72
|
-
}
|
|
73
|
-
async listReferralCodes(request) {
|
|
74
|
-
const url = `${this.client.http.baseUrl()}/api/admin/referral/codes`;
|
|
75
|
-
return this.client.http.adminPost(url, request, http_1.RetryPolicy.None);
|
|
76
|
-
}
|
|
77
|
-
async updateReferralCode(request) {
|
|
78
|
-
const url = `${this.client.http.baseUrl()}/api/admin/referral/codes/update`;
|
|
79
|
-
return this.client.http.adminPost(url, request, http_1.RetryPolicy.None);
|
|
80
|
-
}
|
|
81
|
-
// ── Admin logs ───────────────────────────────────────────────────────
|
|
82
|
-
async listLogEvents(query) {
|
|
83
|
-
const qs = buildQueryString(query);
|
|
84
|
-
const url = `${this.client.http.baseUrl()}/api/admin/logs/events${qs}`;
|
|
85
|
-
return this.client.http.adminGet(url, http_1.RetryPolicy.Idempotent);
|
|
86
|
-
}
|
|
87
|
-
async getLogEvent(publicId) {
|
|
88
|
-
const url = `${this.client.http.baseUrl()}/api/admin/logs/events/${encodeURIComponent(publicId)}`;
|
|
89
|
-
return this.client.http.adminGet(url, http_1.RetryPolicy.Idempotent);
|
|
90
|
-
}
|
|
91
|
-
async logMetrics(query) {
|
|
92
|
-
const qs = buildQueryString(query);
|
|
93
|
-
const url = `${this.client.http.baseUrl()}/api/admin/logs/metrics${qs}`;
|
|
94
|
-
return this.client.http.adminGet(url, http_1.RetryPolicy.Idempotent);
|
|
95
|
-
}
|
|
96
|
-
async logMetricHistory(query) {
|
|
97
|
-
const qs = buildQueryString(query);
|
|
98
|
-
const url = `${this.client.http.baseUrl()}/api/admin/logs/metrics/history${qs}`;
|
|
99
|
-
return this.client.http.adminGet(url, http_1.RetryPolicy.Idempotent);
|
|
100
|
-
}
|
|
101
|
-
// ── On-chain transaction builders ────────────────────────────────────
|
|
102
|
-
initializeIx(authority) {
|
|
103
|
-
return (0, instructions_1.buildInitializeIx)({ authority }, this.client.programId);
|
|
104
|
-
}
|
|
105
|
-
createMarketIx(params, marketId) {
|
|
106
|
-
return (0, instructions_1.buildCreateMarketIx)(params, marketId, this.client.programId);
|
|
107
|
-
}
|
|
108
|
-
addDepositMintIx(params, market, numOutcomes) {
|
|
109
|
-
return (0, instructions_1.buildAddDepositMintIx)(params, market, numOutcomes, this.client.programId);
|
|
110
|
-
}
|
|
111
|
-
activateMarketIx(params) {
|
|
112
|
-
return (0, instructions_1.buildActivateMarketIx)(params, this.client.programId);
|
|
113
|
-
}
|
|
114
|
-
settleMarketIx(params) {
|
|
115
|
-
return (0, instructions_1.buildSettleMarketIx)(params, this.client.programId);
|
|
116
|
-
}
|
|
117
|
-
setPausedIx(authority, paused) {
|
|
118
|
-
return (0, instructions_1.buildSetPausedIx)(authority, paused, this.client.programId);
|
|
119
|
-
}
|
|
120
|
-
setOperatorIx(authority, newOperator) {
|
|
121
|
-
return (0, instructions_1.buildSetOperatorIx)(authority, newOperator, this.client.programId);
|
|
122
|
-
}
|
|
123
|
-
setAuthorityIx(params) {
|
|
124
|
-
return (0, instructions_1.buildSetAuthorityIx)(params, this.client.programId);
|
|
125
|
-
}
|
|
126
|
-
whitelistDepositTokenIx(params) {
|
|
127
|
-
return (0, instructions_1.buildWhitelistDepositTokenIx)(params, this.client.programId);
|
|
128
|
-
}
|
|
129
|
-
createOrderbookIx(params) {
|
|
130
|
-
return (0, instructions_1.buildCreateOrderbookIx)(params, this.client.programId);
|
|
131
|
-
}
|
|
132
|
-
matchOrdersMultiIx(params) {
|
|
133
|
-
return (0, instructions_1.buildMatchOrdersMultiIx)(params, this.client.programId);
|
|
134
|
-
}
|
|
135
|
-
depositAndSwapIx(params) {
|
|
136
|
-
return (0, instructions_1.buildDepositAndSwapIx)(params, this.client.programId);
|
|
137
|
-
}
|
|
138
|
-
// ── Transaction builders (_tx convenience wrappers) ─────────────────
|
|
139
|
-
initializeTx(authority) {
|
|
140
|
-
const ix = this.initializeIx(authority);
|
|
141
|
-
return new web3_js_1.Transaction({ feePayer: authority }).add(ix);
|
|
142
|
-
}
|
|
143
|
-
createMarketTx(params, marketId) {
|
|
144
|
-
const ix = this.createMarketIx(params, marketId);
|
|
145
|
-
return new web3_js_1.Transaction({ feePayer: params.authority }).add(ix);
|
|
146
|
-
}
|
|
147
|
-
addDepositMintTx(params, market, numOutcomes) {
|
|
148
|
-
const ix = this.addDepositMintIx(params, market, numOutcomes);
|
|
149
|
-
return new web3_js_1.Transaction({ feePayer: params.authority }).add(ix);
|
|
150
|
-
}
|
|
151
|
-
activateMarketTx(params) {
|
|
152
|
-
const ix = this.activateMarketIx(params);
|
|
153
|
-
return new web3_js_1.Transaction({ feePayer: params.authority }).add(ix);
|
|
154
|
-
}
|
|
155
|
-
settleMarketTx(params) {
|
|
156
|
-
const ix = this.settleMarketIx(params);
|
|
157
|
-
return new web3_js_1.Transaction({ feePayer: params.oracle }).add(ix);
|
|
158
|
-
}
|
|
159
|
-
setPausedTx(authority, paused) {
|
|
160
|
-
const ix = this.setPausedIx(authority, paused);
|
|
161
|
-
return new web3_js_1.Transaction({ feePayer: authority }).add(ix);
|
|
162
|
-
}
|
|
163
|
-
setOperatorTx(authority, newOperator) {
|
|
164
|
-
const ix = this.setOperatorIx(authority, newOperator);
|
|
165
|
-
return new web3_js_1.Transaction({ feePayer: authority }).add(ix);
|
|
166
|
-
}
|
|
167
|
-
setAuthorityTx(params) {
|
|
168
|
-
const ix = this.setAuthorityIx(params);
|
|
169
|
-
return new web3_js_1.Transaction({ feePayer: params.currentAuthority }).add(ix);
|
|
170
|
-
}
|
|
171
|
-
whitelistDepositTokenTx(params) {
|
|
172
|
-
const ix = this.whitelistDepositTokenIx(params);
|
|
173
|
-
return new web3_js_1.Transaction({ feePayer: params.authority }).add(ix);
|
|
174
|
-
}
|
|
175
|
-
createOrderbookTx(params) {
|
|
176
|
-
const ix = this.createOrderbookIx(params);
|
|
177
|
-
return new web3_js_1.Transaction({ feePayer: params.authority }).add(ix);
|
|
178
|
-
}
|
|
179
|
-
matchOrdersMultiTx(params) {
|
|
180
|
-
const ix = this.matchOrdersMultiIx(params);
|
|
181
|
-
return new web3_js_1.Transaction({ feePayer: params.operator }).add(ix);
|
|
182
|
-
}
|
|
183
|
-
depositAndSwapTx(params) {
|
|
184
|
-
const ix = this.depositAndSwapIx(params);
|
|
185
|
-
return new web3_js_1.Transaction({ feePayer: params.operator }).add(ix);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
exports.Admin = Admin;
|
|
189
|
-
function buildQueryString(query) {
|
|
190
|
-
const params = new URLSearchParams();
|
|
191
|
-
for (const [key, value] of Object.entries(query)) {
|
|
192
|
-
if (value === undefined || value === null)
|
|
193
|
-
continue;
|
|
194
|
-
params.append(key, String(value));
|
|
195
|
-
}
|
|
196
|
-
const qs = params.toString();
|
|
197
|
-
return qs ? `?${qs}` : "";
|
|
198
|
-
}
|
|
199
|
-
//# sourceMappingURL=client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/domain/admin/client.ts"],"names":[],"mappings":";;;AAAA,6CAA2F;AAE3F,qCAAyC;AACzC,6DAaoC;AAiDpC,MAAa,K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;IACrC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,SAAS;QACpD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACpC,CAAC;IACD,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC7B,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import { Transaction, type PublicKey, type TransactionInstruction } from \"@solana/web3.js\";\nimport type { ClientContext } from \"../../context\";\nimport { RetryPolicy } from \"../../http\";\nimport {\n buildInitializeIx,\n buildCreateMarketIx,\n buildAddDepositMintIx,\n buildActivateMarketIx,\n buildSettleMarketIx,\n buildSetPausedIx,\n buildSetOperatorIx,\n buildSetAuthorityIx,\n buildWhitelistDepositTokenIx,\n buildCreateOrderbookIx,\n buildMatchOrdersMultiIx,\n buildDepositAndSwapIx,\n} from \"../../program/instructions\";\nimport type {\n CreateMarketParams,\n AddDepositMintParams,\n ActivateMarketParams,\n SettleMarketParams,\n SetAuthorityParams,\n WhitelistDepositTokenParams,\n CreateOrderbookParams,\n MatchOrdersMultiParams,\n DepositAndSwapParams,\n} from \"../../program/types\";\nimport type {\n AdminLoginRequest,\n AdminLoginResponse,\n AdminNonceResponse,\n} from \"./index\";\nimport type {\n AdminLogEvent,\n AdminLogEventsQuery,\n AdminLogEventsResponse,\n AdminLogMetricHistoryQuery,\n AdminLogMetricHistoryResponse,\n AdminLogMetricsQuery,\n AdminLogMetricsResponse,\n AllocateCodesRequest,\n AllocateCodesResponse,\n CreateNotificationRequest,\n CreateNotificationResponse,\n DismissNotificationRequest,\n DismissNotificationResponse,\n ListCodesRequest,\n ListCodesResponse,\n ReferralConfig,\n RevokeRequest,\n RevokeResponse,\n UnifiedMetadataRequest,\n UnifiedMetadataResponse,\n UnrevokeRequest,\n UnrevokeResponse,\n UpdateCodeRequest,\n UpdateCodeResponse,\n UpdateConfigRequest,\n UploadMarketDeploymentAssetsRequest,\n UploadMarketDeploymentAssetsResponse,\n WhitelistRequest,\n WhitelistResponse,\n} from \"./wire\";\n\nexport class Admin {\n constructor(private readonly client: ClientContext) {}\n\n // ── Admin auth ───────────────────────────────────────────────────────\n\n async getAdminNonce(): Promise<AdminNonceResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/nonce`;\n return this.client.http.get<AdminNonceResponse>(url, RetryPolicy.None);\n }\n\n async adminLogin(request: AdminLoginRequest): Promise<AdminLoginResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/login`;\n return this.client.http.post<AdminLoginResponse, AdminLoginRequest>(\n url,\n request,\n RetryPolicy.None\n );\n }\n\n async adminLogout(): Promise<void> {\n const url = `${this.client.http.baseUrl()}/api/admin/logout`;\n try {\n await this.client.http.adminPost(url, {}, RetryPolicy.None);\n } catch {\n // Backend cookie clear can fail in local/dev setups; still clear local state.\n }\n this.client.http.clearAdminToken();\n }\n\n // ── HTTP methods ─────────────────────────────────────────────────────\n\n async upsertMetadata(\n request: UnifiedMetadataRequest\n ): Promise<UnifiedMetadataResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/metadata`;\n return this.client.http.adminPost<UnifiedMetadataResponse, UnifiedMetadataRequest>(\n url,\n request,\n RetryPolicy.None\n );\n }\n\n async uploadMarketDeploymentAssets(\n request: UploadMarketDeploymentAssetsRequest\n ): Promise<UploadMarketDeploymentAssetsResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/metadata/upload-market-deployment-assets`;\n return this.client.http.adminPost<\n UploadMarketDeploymentAssetsResponse,\n UploadMarketDeploymentAssetsRequest\n >(url, request, RetryPolicy.None);\n }\n\n async allocateCodes(\n request: AllocateCodesRequest\n ): Promise<AllocateCodesResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/referral/allocate`;\n return this.client.http.adminPost<AllocateCodesResponse, AllocateCodesRequest>(\n url,\n request,\n RetryPolicy.None\n );\n }\n\n async whitelist(request: WhitelistRequest): Promise<WhitelistResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/referral/whitelist`;\n return this.client.http.adminPost<WhitelistResponse, WhitelistRequest>(\n url,\n request,\n RetryPolicy.None\n );\n }\n\n async revoke(request: RevokeRequest): Promise<RevokeResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/referral/revoke`;\n return this.client.http.adminPost<RevokeResponse, RevokeRequest>(\n url,\n request,\n RetryPolicy.None\n );\n }\n\n async unrevoke(request: UnrevokeRequest): Promise<UnrevokeResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/referral/unrevoke`;\n return this.client.http.adminPost<UnrevokeResponse, UnrevokeRequest>(\n url,\n request,\n RetryPolicy.None\n );\n }\n\n async createNotification(\n request: CreateNotificationRequest\n ): Promise<CreateNotificationResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/notifications`;\n return this.client.http.adminPost<CreateNotificationResponse, CreateNotificationRequest>(\n url,\n request,\n RetryPolicy.None\n );\n }\n\n async dismissNotification(\n request: DismissNotificationRequest\n ): Promise<DismissNotificationResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/notifications/dismiss`;\n return this.client.http.adminPost<DismissNotificationResponse, DismissNotificationRequest>(\n url,\n request,\n RetryPolicy.None\n );\n }\n\n // ── Referral config / codes ──────────────────────────────────────────\n\n async getReferralConfig(): Promise<ReferralConfig> {\n const url = `${this.client.http.baseUrl()}/api/admin/referral/config/get`;\n return this.client.http.adminPost<ReferralConfig, Record<string, never>>(\n url,\n {},\n RetryPolicy.None\n );\n }\n\n async updateReferralConfig(\n request: UpdateConfigRequest\n ): Promise<ReferralConfig> {\n const url = `${this.client.http.baseUrl()}/api/admin/referral/config/update`;\n return this.client.http.adminPost<ReferralConfig, UpdateConfigRequest>(\n url,\n request,\n RetryPolicy.None\n );\n }\n\n async listReferralCodes(\n request: ListCodesRequest\n ): Promise<ListCodesResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/referral/codes`;\n return this.client.http.adminPost<ListCodesResponse, ListCodesRequest>(\n url,\n request,\n RetryPolicy.None\n );\n }\n\n async updateReferralCode(\n request: UpdateCodeRequest\n ): Promise<UpdateCodeResponse> {\n const url = `${this.client.http.baseUrl()}/api/admin/referral/codes/update`;\n return this.client.http.adminPost<UpdateCodeResponse, UpdateCodeRequest>(\n url,\n request,\n RetryPolicy.None\n );\n }\n\n // ── Admin logs ───────────────────────────────────────────────────────\n\n async listLogEvents(query: AdminLogEventsQuery): Promise<AdminLogEventsResponse> {\n const qs = buildQueryString(query);\n const url = `${this.client.http.baseUrl()}/api/admin/logs/events${qs}`;\n return this.client.http.adminGet<AdminLogEventsResponse>(url, RetryPolicy.Idempotent);\n }\n\n async getLogEvent(publicId: string): Promise<AdminLogEvent> {\n const url = `${this.client.http.baseUrl()}/api/admin/logs/events/${encodeURIComponent(publicId)}`;\n return this.client.http.adminGet<AdminLogEvent>(url, RetryPolicy.Idempotent);\n }\n\n async logMetrics(query: AdminLogMetricsQuery): Promise<AdminLogMetricsResponse> {\n const qs = buildQueryString(query);\n const url = `${this.client.http.baseUrl()}/api/admin/logs/metrics${qs}`;\n return this.client.http.adminGet<AdminLogMetricsResponse>(url, RetryPolicy.Idempotent);\n }\n\n async logMetricHistory(\n query: AdminLogMetricHistoryQuery\n ): Promise<AdminLogMetricHistoryResponse> {\n const qs = buildQueryString(query);\n const url = `${this.client.http.baseUrl()}/api/admin/logs/metrics/history${qs}`;\n return this.client.http.adminGet<AdminLogMetricHistoryResponse>(url, RetryPolicy.Idempotent);\n }\n\n // ── On-chain transaction builders ────────────────────────────────────\n\n initializeIx(authority: PublicKey): TransactionInstruction {\n return buildInitializeIx({ authority }, this.client.programId);\n }\n\n createMarketIx(params: CreateMarketParams, marketId: bigint): TransactionInstruction {\n return buildCreateMarketIx(params, marketId, this.client.programId);\n }\n\n addDepositMintIx(\n params: AddDepositMintParams,\n market: PublicKey,\n numOutcomes: number\n ): TransactionInstruction {\n return buildAddDepositMintIx(params, market, numOutcomes, this.client.programId);\n }\n\n activateMarketIx(params: ActivateMarketParams): TransactionInstruction {\n return buildActivateMarketIx(params, this.client.programId);\n }\n\n settleMarketIx(params: SettleMarketParams): TransactionInstruction {\n return buildSettleMarketIx(params, this.client.programId);\n }\n\n setPausedIx(authority: PublicKey, paused: boolean): TransactionInstruction {\n return buildSetPausedIx(authority, paused, this.client.programId);\n }\n\n setOperatorIx(authority: PublicKey, newOperator: PublicKey): TransactionInstruction {\n return buildSetOperatorIx(authority, newOperator, this.client.programId);\n }\n\n setAuthorityIx(params: SetAuthorityParams): TransactionInstruction {\n return buildSetAuthorityIx(params, this.client.programId);\n }\n\n whitelistDepositTokenIx(params: WhitelistDepositTokenParams): TransactionInstruction {\n return buildWhitelistDepositTokenIx(params, this.client.programId);\n }\n\n createOrderbookIx(params: CreateOrderbookParams): TransactionInstruction {\n return buildCreateOrderbookIx(params, this.client.programId);\n }\n\n matchOrdersMultiIx(params: MatchOrdersMultiParams): TransactionInstruction {\n return buildMatchOrdersMultiIx(params, this.client.programId);\n }\n\n depositAndSwapIx(params: DepositAndSwapParams): TransactionInstruction {\n return buildDepositAndSwapIx(params, this.client.programId);\n }\n\n // ── Transaction builders (_tx convenience wrappers) ─────────────────\n\n initializeTx(authority: PublicKey): Transaction {\n const ix = this.initializeIx(authority);\n return new Transaction({ feePayer: authority }).add(ix);\n }\n\n createMarketTx(params: CreateMarketParams, marketId: bigint): Transaction {\n const ix = this.createMarketIx(params, marketId);\n return new Transaction({ feePayer: params.authority }).add(ix);\n }\n\n addDepositMintTx(\n params: AddDepositMintParams,\n market: PublicKey,\n numOutcomes: number\n ): Transaction {\n const ix = this.addDepositMintIx(params, market, numOutcomes);\n return new Transaction({ feePayer: params.authority }).add(ix);\n }\n\n activateMarketTx(params: ActivateMarketParams): Transaction {\n const ix = this.activateMarketIx(params);\n return new Transaction({ feePayer: params.authority }).add(ix);\n }\n\n settleMarketTx(params: SettleMarketParams): Transaction {\n const ix = this.settleMarketIx(params);\n return new Transaction({ feePayer: params.oracle }).add(ix);\n }\n\n setPausedTx(authority: PublicKey, paused: boolean): Transaction {\n const ix = this.setPausedIx(authority, paused);\n return new Transaction({ feePayer: authority }).add(ix);\n }\n\n setOperatorTx(authority: PublicKey, newOperator: PublicKey): Transaction {\n const ix = this.setOperatorIx(authority, newOperator);\n return new Transaction({ feePayer: authority }).add(ix);\n }\n\n setAuthorityTx(params: SetAuthorityParams): Transaction {\n const ix = this.setAuthorityIx(params);\n return new Transaction({ feePayer: params.currentAuthority }).add(ix);\n }\n\n whitelistDepositTokenTx(params: WhitelistDepositTokenParams): Transaction {\n const ix = this.whitelistDepositTokenIx(params);\n return new Transaction({ feePayer: params.authority }).add(ix);\n }\n\n createOrderbookTx(params: CreateOrderbookParams): Transaction {\n const ix = this.createOrderbookIx(params);\n return new Transaction({ feePayer: params.authority }).add(ix);\n }\n\n matchOrdersMultiTx(params: MatchOrdersMultiParams): Transaction {\n const ix = this.matchOrdersMultiIx(params);\n return new Transaction({ feePayer: params.operator }).add(ix);\n }\n\n depositAndSwapTx(params: DepositAndSwapParams): Transaction {\n const ix = this.depositAndSwapIx(params);\n return new Transaction({ feePayer: params.operator }).add(ix);\n }\n}\n\nfunction buildQueryString(query: object): string {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) continue;\n params.append(key, String(value));\n }\n const qs = params.toString();\n return qs ? `?${qs}` : \"\";\n}\n"]}
|