@pod-network/trade-sdk 0.3.0 → 0.4.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 +99 -2
- package/dist/client.d.ts +45 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +63 -2
- package/dist/client.js.map +1 -1
- package/dist/codec/bridge.d.ts +82 -0
- package/dist/codec/bridge.d.ts.map +1 -0
- package/dist/codec/bridge.js +114 -0
- package/dist/codec/bridge.js.map +1 -0
- package/dist/codec/decode.d.ts +15 -2
- package/dist/codec/decode.d.ts.map +1 -1
- package/dist/codec/decode.js +39 -0
- package/dist/codec/decode.js.map +1 -1
- package/dist/codec/resolution.d.ts +4 -1
- package/dist/codec/resolution.d.ts.map +1 -1
- package/dist/codec/resolution.js +6 -3
- package/dist/codec/resolution.js.map +1 -1
- package/dist/codec/units.d.ts.map +1 -1
- package/dist/codec/units.js +9 -1
- package/dist/codec/units.js.map +1 -1
- package/dist/datafeed.d.ts.map +1 -1
- package/dist/datafeed.js +15 -9
- package/dist/datafeed.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/stores/resource.d.ts +14 -1
- package/dist/stores/resource.d.ts.map +1 -1
- package/dist/stores/resource.js +7 -1
- package/dist/stores/resource.js.map +1 -1
- package/dist/sync/candles.d.ts +62 -4
- package/dist/sync/candles.d.ts.map +1 -1
- package/dist/sync/candles.js +259 -42
- package/dist/sync/candles.js.map +1 -1
- package/dist/sync/sources.d.ts +5 -1
- package/dist/sync/sources.d.ts.map +1 -1
- package/dist/sync/sources.js +16 -0
- package/dist/sync/sources.js.map +1 -1
- package/dist/sync/withdrawals.d.ts +5 -0
- package/dist/sync/withdrawals.d.ts.map +1 -0
- package/dist/sync/withdrawals.js +172 -0
- package/dist/sync/withdrawals.js.map +1 -0
- package/dist/transport/claim.d.ts +160 -0
- package/dist/transport/claim.d.ts.map +1 -0
- package/dist/transport/claim.js +341 -0
- package/dist/transport/claim.js.map +1 -0
- package/dist/transport/jsonrpc.d.ts +16 -0
- package/dist/transport/jsonrpc.d.ts.map +1 -0
- package/dist/transport/jsonrpc.js +42 -0
- package/dist/transport/jsonrpc.js.map +1 -0
- package/dist/transport/rest.d.ts +23 -1
- package/dist/transport/rest.d.ts.map +1 -1
- package/dist/transport/rest.js +33 -2
- package/dist/transport/rest.js.map +1 -1
- package/dist/transport/ws.d.ts +4 -1
- package/dist/transport/ws.d.ts.map +1 -1
- package/dist/transport/ws.js.map +1 -1
- package/dist/types/public.d.ts +87 -0
- package/dist/types/public.d.ts.map +1 -1
- package/dist/types/wire.d.ts +43 -1
- package/dist/types/wire.d.ts.map +1 -1
- package/dist/write/delegation.d.ts.map +1 -1
- package/dist/write/delegation.js +2 -12
- package/dist/write/delegation.js.map +1 -1
- package/dist/write/index.d.ts +25 -0
- package/dist/write/index.d.ts.map +1 -1
- package/dist/write/index.js +20 -13
- package/dist/write/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +77 -5
- package/src/codec/bridge.ts +138 -0
- package/src/codec/decode.ts +47 -4
- package/src/codec/resolution.ts +6 -3
- package/src/codec/units.ts +8 -1
- package/src/datafeed.ts +15 -9
- package/src/index.ts +16 -0
- package/src/stores/resource.ts +14 -1
- package/src/sync/candles.ts +297 -45
- package/src/sync/sources.ts +16 -1
- package/src/sync/withdrawals.ts +177 -0
- package/src/transport/claim.ts +434 -0
- package/src/transport/jsonrpc.ts +54 -0
- package/src/transport/rest.ts +50 -8
- package/src/transport/ws.ts +4 -1
- package/src/types/public.ts +94 -0
- package/src/types/wire.ts +47 -1
- package/src/write/delegation.ts +2 -12
- package/src/write/index.ts +58 -12
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
// Following a withdrawal from pod onto the claim chain (ADR 0033).
|
|
2
|
+
//
|
|
3
|
+
// Two stages, because the claim hash is not known when the withdrawal resolves:
|
|
4
|
+
// ask the pod node for it, then watch the claim chain for the bridge's `Claim`
|
|
5
|
+
// event carrying it. Both live here rather than in a consumer because the event
|
|
6
|
+
// ABI, the topic filter and the log-range policy are protocol knowledge that
|
|
7
|
+
// has to track the bridge contract, not application code.
|
|
8
|
+
//
|
|
9
|
+
// Stage 1 is REST (`GET /v1/bridge/withdrawals/by-id/{id}`), stage 2 is JSON-RPC
|
|
10
|
+
// against the claim chain — the asymmetry is just where each fact lives.
|
|
11
|
+
//
|
|
12
|
+
// **The claim hash is fetched, never recomputed.** It folds in the pod chain id
|
|
13
|
+
// and the bridge version, so a local derivation is a second copy of a
|
|
14
|
+
// consensus-critical hash that silently stops matching after a version bump —
|
|
15
|
+
// the node serves it so that callers don't (ADR 0033 §4.6). Everything else in
|
|
16
|
+
// this module is a consequence of that: it is why stage 1 exists at all.
|
|
17
|
+
import { tryRpc } from "./jsonrpc.js";
|
|
18
|
+
/**
|
|
19
|
+
* topic0 of `Claim(bytes32 indexed txHash, address token, address mirrorToken,
|
|
20
|
+
* uint256 amount, address indexed to)` — protocol/src/Bridge.sol.
|
|
21
|
+
*
|
|
22
|
+
* A literal rather than a derivation so the read path doesn't pull in an ABI
|
|
23
|
+
* encoder; `claim.test.ts` pins it against viem's `toEventSelector`, so it
|
|
24
|
+
* cannot drift from the signature above without failing a test.
|
|
25
|
+
*/
|
|
26
|
+
export const CLAIM_TOPIC = "0xa0b99c0fdfc395724d7b81a88a6d74852461f7691371afe2839bb8688475788c";
|
|
27
|
+
/**
|
|
28
|
+
* Resolve one withdrawal's claim state from the pod node.
|
|
29
|
+
*
|
|
30
|
+
* **The precedence is deliberate and is the forward-compatibility contract — do
|
|
31
|
+
* not "simplify" it into a switch on `status`:**
|
|
32
|
+
*
|
|
33
|
+
* 1. A present `proof.claim_hash` wins, whatever `status` says. The money is in
|
|
34
|
+
* the certificate, not in the word beside it, and a status this build has
|
|
35
|
+
* never heard of must not veto one sitting in the same response.
|
|
36
|
+
* 2. Only then may `status` be terminal, and only `refused` is — meaning the
|
|
37
|
+
* withdrawal was rejected at execution with nothing debited.
|
|
38
|
+
* 3. Everything else is `pending`, i.e. "ask again": an unfamiliar status, a
|
|
39
|
+
* 404 (this node has no outcome row yet, normal right after submitting), any
|
|
40
|
+
* other HTTP failure, and a transport error. None of them is information
|
|
41
|
+
* about the withdrawal, and guessing `refused` would tell a user their funds
|
|
42
|
+
* were never taken when they may well have been.
|
|
43
|
+
*
|
|
44
|
+
* This mirrors the two properties the node's own `WithdrawalDetail` documents
|
|
45
|
+
* for consumers (node/src/rpc/bridge_rest.rs), which its producer type
|
|
46
|
+
* deliberately does not provide.
|
|
47
|
+
*/
|
|
48
|
+
export async function fetchClaimStatus(restUrl, withdrawalId, opts) {
|
|
49
|
+
const doFetch = opts?.fetch ?? fetch;
|
|
50
|
+
try {
|
|
51
|
+
// Trailing slashes are stripped because `PodRestClient` accepts a base with
|
|
52
|
+
// one and this helper is handed the same value. `https://host/v1/` would
|
|
53
|
+
// otherwise request `/v1//bridge/...`, and a 404 from that is indistinguishable
|
|
54
|
+
// here from a certificate that has not assembled yet — so the watch would
|
|
55
|
+
// poll a misspelled URL forever without surfacing anything.
|
|
56
|
+
const base = restUrl.replace(/\/+$/, "");
|
|
57
|
+
const res = await doFetch(`${base}/bridge/withdrawals/by-id/${withdrawalId}`, {
|
|
58
|
+
headers: { accept: "application/json" },
|
|
59
|
+
signal: opts?.signal,
|
|
60
|
+
});
|
|
61
|
+
// Anything non-OK, 404 included, is "ask again": the row may not be written
|
|
62
|
+
// yet, and no HTTP status carries terminality — only `status` does.
|
|
63
|
+
if (!res.ok)
|
|
64
|
+
return { state: "pending" };
|
|
65
|
+
const body = (await res.json());
|
|
66
|
+
// The proof is read FIRST and believed on its presence alone, whatever
|
|
67
|
+
// `status` says. That ordering is the node's own consumer contract
|
|
68
|
+
// (`WithdrawalDetail`, node/src/rpc/bridge_rest.rs): a node that adds a
|
|
69
|
+
// fourth status while still attaching a certificate must not have that
|
|
70
|
+
// certificate vetoed by a label this client has never heard of. The money
|
|
71
|
+
// is in the proof, not in the word next to it.
|
|
72
|
+
const claimHash = body.proof?.claim_hash;
|
|
73
|
+
if (claimHash)
|
|
74
|
+
return { state: "claimable", claimHash };
|
|
75
|
+
// Only now may a status be terminal, and only this one. Anything unfamiliar
|
|
76
|
+
// falls through to `pending` — "ask again", never terminal.
|
|
77
|
+
if (body.status === "refused")
|
|
78
|
+
return { state: "refused" };
|
|
79
|
+
return { state: "pending" };
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// A transport failure is not information about the withdrawal. Guessing
|
|
83
|
+
// `refused` here would tell a user their funds were never taken when they may
|
|
84
|
+
// well have been.
|
|
85
|
+
return { state: "pending" };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Follow one withdrawal to the claim chain: resolve its claim hash, then watch
|
|
90
|
+
* for the `Claim` event carrying it.
|
|
91
|
+
*
|
|
92
|
+
* Matching on the hash rather than the recipient is what makes this exact —
|
|
93
|
+
* `Claim` indexes `to` as well, but that identifies the *user*, so two
|
|
94
|
+
* withdrawals of the same amount to the same address would be indistinguishable.
|
|
95
|
+
*
|
|
96
|
+
* Returns rather than throws on every expected ending, so a caller renders an
|
|
97
|
+
* outcome instead of catching. Pass `signal` to stop the polling when whatever
|
|
98
|
+
* asked for it goes away.
|
|
99
|
+
*/
|
|
100
|
+
export async function waitForClaim(opts) {
|
|
101
|
+
const { restUrl, claimRpcUrl, withdrawalId, bridge, signal } = opts;
|
|
102
|
+
const pollMs = opts.pollMs ?? 5_000;
|
|
103
|
+
const lookback = opts.lookbackBlocks ?? 5_000;
|
|
104
|
+
const deadline = Date.now() + (opts.timeoutMs ?? 10 * 60_000);
|
|
105
|
+
const rest = { fetch: opts.fetch, signal };
|
|
106
|
+
const live = () => !signal?.aborted && Date.now() < deadline;
|
|
107
|
+
const sleep = () => new Promise((resolve) => {
|
|
108
|
+
const timer = setTimeout(done, pollMs);
|
|
109
|
+
function done() { signal?.removeEventListener("abort", done); clearTimeout(timer); resolve(); }
|
|
110
|
+
signal?.addEventListener("abort", done, { once: true });
|
|
111
|
+
});
|
|
112
|
+
// Anchor the scan window before stage 1, so the range stays bounded however
|
|
113
|
+
// long the certificate takes to assemble. This same reading is the first
|
|
114
|
+
// scan's upper bound, so stage 2 costs no extra round trip to start.
|
|
115
|
+
const tip = await tryRpc(claimRpcUrl, "eth_blockNumber", [], rest);
|
|
116
|
+
if (tip === undefined)
|
|
117
|
+
return { state: "pending" };
|
|
118
|
+
let head = BigInt(tip);
|
|
119
|
+
let fromBlock = head > BigInt(lookback) ? head - BigInt(lookback) : 0n;
|
|
120
|
+
let claimHash;
|
|
121
|
+
while (!claimHash && live()) {
|
|
122
|
+
const status = await fetchClaimStatus(restUrl, withdrawalId, rest);
|
|
123
|
+
if (status.state === "refused")
|
|
124
|
+
return { state: "refused" };
|
|
125
|
+
if (status.state === "claimable")
|
|
126
|
+
claimHash = status.claimHash;
|
|
127
|
+
else
|
|
128
|
+
await sleep();
|
|
129
|
+
}
|
|
130
|
+
if (!claimHash)
|
|
131
|
+
return { state: "pending" };
|
|
132
|
+
while (live()) {
|
|
133
|
+
// The upper bound is pinned BEFORE the scan and named explicitly. With
|
|
134
|
+
// `toBlock: "latest"` the node picks the end itself, and any block mined
|
|
135
|
+
// between that choice and a later head read would be stepped over by the
|
|
136
|
+
// advance below — permanently, since the window only moves forward. On a
|
|
137
|
+
// 250ms-block chain that silently loses the claim a few percent of the time.
|
|
138
|
+
if (head === undefined) {
|
|
139
|
+
const latest = await tryRpc(claimRpcUrl, "eth_blockNumber", [], rest);
|
|
140
|
+
if (latest === undefined) {
|
|
141
|
+
await sleep();
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
head = BigInt(latest);
|
|
145
|
+
}
|
|
146
|
+
const toBlock = head;
|
|
147
|
+
head = undefined; // re-read on the next pass; this one is now spent
|
|
148
|
+
if (toBlock >= fromBlock) {
|
|
149
|
+
const filter = {
|
|
150
|
+
fromBlock: `0x${fromBlock.toString(16)}`,
|
|
151
|
+
toBlock: `0x${toBlock.toString(16)}`,
|
|
152
|
+
topics: [CLAIM_TOPIC, claimHash],
|
|
153
|
+
};
|
|
154
|
+
if (bridge)
|
|
155
|
+
filter.address = bridge;
|
|
156
|
+
const logs = await tryRpc(claimRpcUrl, "eth_getLogs", [filter], rest);
|
|
157
|
+
const hit = logs?.[0];
|
|
158
|
+
if (hit)
|
|
159
|
+
return { state: "claimed", claimHash, transactionHash: hit.transactionHash };
|
|
160
|
+
// Only advance on a scan that actually completed. `tryRpc` maps a 429, a
|
|
161
|
+
// 5xx or "query returned more than 10000 results" to undefined, which is
|
|
162
|
+
// indistinguishable from an empty result — advancing there would skip the
|
|
163
|
+
// range unread, and the lookback window is the one covering a relayer that
|
|
164
|
+
// claimed before this watch began.
|
|
165
|
+
if (logs !== undefined)
|
|
166
|
+
fromBlock = toBlock + 1n;
|
|
167
|
+
}
|
|
168
|
+
await sleep();
|
|
169
|
+
}
|
|
170
|
+
return { state: "pending", claimHash };
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Follow many withdrawals on one pair of loops instead of one pair each.
|
|
174
|
+
*
|
|
175
|
+
* The saving is on the claim chain, which is the half that costs: a `Claim`
|
|
176
|
+
* topic filter is an OR set at `topics[1]`, so a single `eth_getLogs` covers
|
|
177
|
+
* every outstanding hash and that query's count stops scaling with the number of
|
|
178
|
+
* withdrawals. Stage 1 still costs one REST read per unresolved id, issued
|
|
179
|
+
* concurrently rather than in series — those go to pod's own node, not to a
|
|
180
|
+
* metered provider, so the thing worth collapsing is the log scan.
|
|
181
|
+
*
|
|
182
|
+
* **Each id carries its own scan floor, and the shared query starts at the
|
|
183
|
+
* oldest of them.** This is the part that is easy to get wrong: a withdrawal
|
|
184
|
+
* still waiting for its certificate has no hash to search for yet, so it
|
|
185
|
+
* contributes nothing to the topic set — but the blocks passing meanwhile are
|
|
186
|
+
* exactly where its `Claim` may land, because a relayer can claim from a
|
|
187
|
+
* certificate this node has not finished assembling. Advancing the floor on the
|
|
188
|
+
* strength of the ids that *do* have hashes would step over that window for
|
|
189
|
+
* good. So a floor is only raised for an id whose hash was actually in the query
|
|
190
|
+
* that covered it.
|
|
191
|
+
*
|
|
192
|
+
* Settlement arrives through `onSettled` rather than a promise per id, so a
|
|
193
|
+
* caller hears about each outcome when it happens rather than when the slowest
|
|
194
|
+
* one does.
|
|
195
|
+
*/
|
|
196
|
+
export function watchClaims(opts) {
|
|
197
|
+
const { restUrl, claimRpcUrl, bridge, signal, onSettled } = opts;
|
|
198
|
+
const pollMs = opts.pollMs ?? 5_000;
|
|
199
|
+
const rest = { fetch: opts.fetch, signal };
|
|
200
|
+
const pending = new Map();
|
|
201
|
+
let stopped = false;
|
|
202
|
+
let wake;
|
|
203
|
+
/**
|
|
204
|
+
* The newest head this watcher has seen. Kept so `add` can anchor immediately
|
|
205
|
+
* rather than waiting for the next tick to do it: an id added while a scan is
|
|
206
|
+
* in flight is not covered by `wake` (the watcher is not sleeping) and would
|
|
207
|
+
* otherwise be anchored at the FOLLOWING head, silently skipping every block
|
|
208
|
+
* between the call and that read — the exact window a per-id floor exists to
|
|
209
|
+
* preserve. Undefined only before the first head read, where nothing has been
|
|
210
|
+
* scanned yet and the first tick anchors it correctly.
|
|
211
|
+
*/
|
|
212
|
+
let lastHead;
|
|
213
|
+
const live = () => !stopped && !signal?.aborted;
|
|
214
|
+
/** The oldest block an id joining at `head` still needs searched. */
|
|
215
|
+
const anchorFrom = (head, lookback) => {
|
|
216
|
+
const back = BigInt(lookback);
|
|
217
|
+
return head > back ? head - back : 0n;
|
|
218
|
+
};
|
|
219
|
+
const sleep = () => new Promise((resolve) => {
|
|
220
|
+
const timer = setTimeout(done, pollMs);
|
|
221
|
+
wake = done;
|
|
222
|
+
function done() {
|
|
223
|
+
signal?.removeEventListener("abort", done);
|
|
224
|
+
clearTimeout(timer);
|
|
225
|
+
wake = undefined;
|
|
226
|
+
resolve();
|
|
227
|
+
}
|
|
228
|
+
signal?.addEventListener("abort", done, { once: true });
|
|
229
|
+
});
|
|
230
|
+
/** Terminal for one id. Silent once stopped: `stop()` cannot cancel an
|
|
231
|
+
* in-flight request, and a caller that has torn down its state must not be
|
|
232
|
+
* told about an outcome afterwards — it would announce a claim for an account
|
|
233
|
+
* the user has left, and un-mark an id its own cleanup had just released. */
|
|
234
|
+
const settle = (id, outcome) => {
|
|
235
|
+
if (!live())
|
|
236
|
+
return;
|
|
237
|
+
pending.delete(id);
|
|
238
|
+
onSettled(id, outcome);
|
|
239
|
+
};
|
|
240
|
+
async function tick() {
|
|
241
|
+
// Stage 1, concurrently: the reads share no state until their results are
|
|
242
|
+
// written back, so in series they would simply add up one RTT at a time.
|
|
243
|
+
const unresolved = [...pending].filter(([, e]) => !e.claimHash);
|
|
244
|
+
const statuses = await Promise.all(unresolved.map(([id]) => fetchClaimStatus(restUrl, id, rest)));
|
|
245
|
+
unresolved.forEach(([id, entry], i) => {
|
|
246
|
+
const status = statuses[i];
|
|
247
|
+
if (status.state === "refused")
|
|
248
|
+
settle(id, { state: "refused" });
|
|
249
|
+
else if (status.state === "claimable")
|
|
250
|
+
entry.claimHash = status.claimHash.toLowerCase();
|
|
251
|
+
});
|
|
252
|
+
if (!live() || pending.size === 0)
|
|
253
|
+
return;
|
|
254
|
+
// The tip is read every tick, even with nothing to search for yet, because
|
|
255
|
+
// it is what pins a newcomer's floor. Deferring that until a hash exists
|
|
256
|
+
// would anchor it at a later block than the one it joined at, losing the
|
|
257
|
+
// window in between — the same mistake as advancing past an unresolved id.
|
|
258
|
+
const head = await tryRpc(claimRpcUrl, "eth_blockNumber", [], rest);
|
|
259
|
+
if (head === undefined)
|
|
260
|
+
return;
|
|
261
|
+
const toBlock = BigInt(head);
|
|
262
|
+
lastHead = toBlock;
|
|
263
|
+
for (const entry of pending.values()) {
|
|
264
|
+
if (entry.floor === undefined)
|
|
265
|
+
entry.floor = anchorFrom(toBlock, entry.lookback);
|
|
266
|
+
}
|
|
267
|
+
const hashes = [...pending.values()].map((e) => e.claimHash).filter((h) => !!h);
|
|
268
|
+
if (hashes.length === 0)
|
|
269
|
+
return; // nothing to look for; floors are pinned
|
|
270
|
+
let fromBlock = toBlock;
|
|
271
|
+
for (const entry of pending.values()) {
|
|
272
|
+
if (entry.floor !== undefined && entry.floor < fromBlock)
|
|
273
|
+
fromBlock = entry.floor;
|
|
274
|
+
}
|
|
275
|
+
if (toBlock < fromBlock)
|
|
276
|
+
return;
|
|
277
|
+
const filter = {
|
|
278
|
+
fromBlock: `0x${fromBlock.toString(16)}`,
|
|
279
|
+
toBlock: `0x${toBlock.toString(16)}`,
|
|
280
|
+
// An array at `topics[1]` is an OR over claim hashes — the whole reason
|
|
281
|
+
// one query can serve every outstanding withdrawal.
|
|
282
|
+
topics: [CLAIM_TOPIC, hashes],
|
|
283
|
+
};
|
|
284
|
+
if (bridge)
|
|
285
|
+
filter.address = bridge;
|
|
286
|
+
const logs = await tryRpc(claimRpcUrl, "eth_getLogs", [filter], rest);
|
|
287
|
+
// Undefined is a failed query, not an empty range, so no floor may move.
|
|
288
|
+
if (logs === undefined)
|
|
289
|
+
return;
|
|
290
|
+
for (const log of logs) {
|
|
291
|
+
const claimHash = log.topics[1]?.toLowerCase();
|
|
292
|
+
if (!claimHash)
|
|
293
|
+
continue;
|
|
294
|
+
for (const [id, entry] of [...pending]) {
|
|
295
|
+
if (entry.claimHash === claimHash) {
|
|
296
|
+
settle(id, { state: "claimed", claimHash, transactionHash: log.transactionHash });
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// Raise the floor ONLY for ids whose hash this query carried. One that is
|
|
301
|
+
// still waiting on its certificate keeps its original floor, so the blocks
|
|
302
|
+
// that passed while it waited are searched once its hash appears.
|
|
303
|
+
const searched = new Set(hashes);
|
|
304
|
+
for (const entry of pending.values()) {
|
|
305
|
+
if (entry.claimHash && searched.has(entry.claimHash))
|
|
306
|
+
entry.floor = toBlock + 1n;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
async function run() {
|
|
310
|
+
while (live()) {
|
|
311
|
+
if (pending.size > 0)
|
|
312
|
+
await tick();
|
|
313
|
+
await sleep();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
void run();
|
|
317
|
+
return {
|
|
318
|
+
add(withdrawalId, addOpts) {
|
|
319
|
+
if (stopped || pending.has(withdrawalId))
|
|
320
|
+
return;
|
|
321
|
+
const lookback = addOpts?.lookbackBlocks ?? 0;
|
|
322
|
+
// Anchor from the last head seen, NOT from whatever the next tick reads.
|
|
323
|
+
// `wake` only helps while the watcher is sleeping; an id added during an
|
|
324
|
+
// in-flight scan would otherwise be pinned at a later head and lose every
|
|
325
|
+
// block in between.
|
|
326
|
+
pending.set(withdrawalId, {
|
|
327
|
+
lookback,
|
|
328
|
+
floor: lastHead === undefined ? undefined : anchorFrom(lastHead, lookback),
|
|
329
|
+
});
|
|
330
|
+
wake?.(); // and start looking now rather than after the current sleep
|
|
331
|
+
},
|
|
332
|
+
get size() {
|
|
333
|
+
return pending.size;
|
|
334
|
+
},
|
|
335
|
+
stop() {
|
|
336
|
+
stopped = true;
|
|
337
|
+
wake?.();
|
|
338
|
+
},
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
//# sourceMappingURL=claim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claim.js","sourceRoot":"","sources":["../../src/transport/claim.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,gFAAgF;AAChF,6EAA6E;AAC7E,0DAA0D;AAC1D,EAAE;AACF,iFAAiF;AACjF,yEAAyE;AACzE,EAAE;AACF,gFAAgF;AAChF,sEAAsE;AACtE,8EAA8E;AAC9E,+EAA+E;AAC/E,yEAAyE;AAGzE,OAAO,EAAE,MAAM,EAAmB,MAAM,cAAc,CAAC;AAGvD;;;;;;;GAOG;AACH,MAAM,CAAC,MA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AAQ;gBACR,KAAK,EAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC;aAC3E,CAAC,CAAC;YACH,IAAI,EAAE,EAAE,CAAC,CAAC,4DAA4D;QACxE,CAAC;QACD,IAAI,IAAI;YACN,OAAO,OAAO,CAAC,IAAI,CAAC;QACtB,CAAC;QACD,IAAI;YACF,OAAO,GAAG,IAAI,CAAC;YACf,IAAI,EAAE,EAAE,CAAC;QACX,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface RpcOptions {
|
|
2
|
+
fetch?: typeof fetch;
|
|
3
|
+
signal?: AbortSignal;
|
|
4
|
+
}
|
|
5
|
+
export declare class PodRpcError extends Error {
|
|
6
|
+
code: number | undefined;
|
|
7
|
+
constructor(code: number | undefined, message: string);
|
|
8
|
+
}
|
|
9
|
+
/** Call `method` and return its result, throwing {@link PodRpcError} on an
|
|
10
|
+
* error response. Use {@link tryRpc} where an error is an expected state. */
|
|
11
|
+
export declare function rpc<T>(rpcUrl: string, method: string, params?: unknown[], opts?: RpcOptions): Promise<T>;
|
|
12
|
+
/** {@link rpc}, but an error response (or a transport failure) yields
|
|
13
|
+
* `undefined` instead of throwing — for methods whose failure is a state the
|
|
14
|
+
* caller expects and handles, not an exception. */
|
|
15
|
+
export declare function tryRpc<T>(rpcUrl: string, method: string, params?: unknown[], opts?: RpcOptions): Promise<T | undefined>;
|
|
16
|
+
//# sourceMappingURL=jsonrpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonrpc.d.ts","sourceRoot":"","sources":["../../src/transport/jsonrpc.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,qBAAa,WAAY,SAAQ,KAAK;IACjB,IAAI,EAAE,MAAM,GAAG,SAAS;gBAAxB,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM;CAI7D;AAED;6EAC6E;AAC7E,wBAAsB,GAAG,CAAC,CAAC,EACzB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,OAAO,EAAO,EACtB,IAAI,CAAC,EAAE,UAAU,GAChB,OAAO,CAAC,CAAC,CAAC,CAYZ;AAED;;mDAEmD;AACnD,wBAAsB,MAAM,CAAC,CAAC,EAC5B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,OAAO,EAAO,EACtB,IAAI,CAAC,EAAE,UAAU,GAChB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAMxB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// One JSON-RPC POST, shared by every raw-RPC caller in the SDK.
|
|
2
|
+
//
|
|
3
|
+
// Deliberately not viem: this is reachable from the main entry, and read-only
|
|
4
|
+
// consumers should not pull a signing library in to read a block number. The
|
|
5
|
+
// `/write` entry uses viem because it must.
|
|
6
|
+
export class PodRpcError extends Error {
|
|
7
|
+
code;
|
|
8
|
+
constructor(code, message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.name = "PodRpcError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Call `method` and return its result, throwing {@link PodRpcError} on an
|
|
15
|
+
* error response. Use {@link tryRpc} where an error is an expected state. */
|
|
16
|
+
export async function rpc(rpcUrl, method, params = [], opts) {
|
|
17
|
+
const doFetch = opts?.fetch ?? fetch;
|
|
18
|
+
const res = await doFetch(rpcUrl, {
|
|
19
|
+
method: "POST",
|
|
20
|
+
headers: { "content-type": "application/json" },
|
|
21
|
+
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
|
|
22
|
+
signal: opts?.signal,
|
|
23
|
+
});
|
|
24
|
+
const json = (await res.json());
|
|
25
|
+
if (json.error)
|
|
26
|
+
throw new PodRpcError(json.error.code, json.error.message ?? `${method} failed`);
|
|
27
|
+
if (json.result === undefined)
|
|
28
|
+
throw new PodRpcError(undefined, `${method} returned no result`);
|
|
29
|
+
return json.result;
|
|
30
|
+
}
|
|
31
|
+
/** {@link rpc}, but an error response (or a transport failure) yields
|
|
32
|
+
* `undefined` instead of throwing — for methods whose failure is a state the
|
|
33
|
+
* caller expects and handles, not an exception. */
|
|
34
|
+
export async function tryRpc(rpcUrl, method, params = [], opts) {
|
|
35
|
+
try {
|
|
36
|
+
return await rpc(rpcUrl, method, params, opts);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=jsonrpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonrpc.js","sourceRoot":"","sources":["../../src/transport/jsonrpc.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,4CAA4C;AAO5C,MAAM,OAAO,WAAY,SAAQ,KAAK;IACjB;IAAnB,YAAmB,IAAwB,EAAE,OAAe;QAC1D,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,SAAI,GAAJ,IAAI,CAAoB;QAEzC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAED;6EAC6E;AAC7E,MAAM,CAAC,KAAK,UAAU,GAAG,CACvB,MAAc,EACd,MAAc,EACd,SAAoB,EAAE,EACtB,IAAiB;IAEjB,MAAM,OAAO,GAAG,IAAI,EAAE,KAAK,IAAI,KAAK,CAAC;IACrC,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE;QAChC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAC/D,MAAM,EAAE,IAAI,EAAE,MAAM;KACrB,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAgE,CAAC;IAC/F,IAAI,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,GAAG,MAAM,SAAS,CAAC,CAAC;IACjG,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;QAAE,MAAM,IAAI,WAAW,CAAC,SAAS,EAAE,GAAG,MAAM,qBAAqB,CAAC,CAAC;IAChG,OAAO,IAAI,CAAC,MAAM,CAAC;AACrB,CAAC;AAED;;mDAEmD;AACnD,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,MAAc,EACd,MAAc,EACd,SAAoB,EAAE,EACtB,IAAiB;IAEjB,IAAI,CAAC;QACH,OAAO,MAAM,GAAG,CAAI,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACpD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/transport/rest.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Address, BackstopTransfer, Balances, Bar, CandleQuery, LeaderboardPage, LeaderboardQuery, Market, MarketId, Order, Orderbook, PositionsSnapshot, Resolution, Status, Trigger, TxExplorer } from "../types/public.js";
|
|
1
|
+
import type { Address, BackstopTransfer, Balances, Bar, BridgeConfig, CandleQuery, LeaderboardPage, LeaderboardQuery, Market, MarketId, Order, Orderbook, PositionsSnapshot, Resolution, Status, Trigger, TxExplorer, Withdrawal, WithdrawalsQuery } from "../types/public.js";
|
|
2
2
|
export type MarketDynamicsPatch = Partial<Market> & {
|
|
3
3
|
id: string;
|
|
4
4
|
};
|
|
@@ -49,10 +49,18 @@ type FetchFn = typeof fetch;
|
|
|
49
49
|
export interface RestClientOptions {
|
|
50
50
|
restUrl: string;
|
|
51
51
|
fetch?: FetchFn;
|
|
52
|
+
/**
|
|
53
|
+
* Per-request timeout (ms, default 15s). A request that never settles is
|
|
54
|
+
* worse than one that fails: it holds its slot in `inflight`, so retries of
|
|
55
|
+
* the same URL join the hang instead of trying again. Cold candle windows on
|
|
56
|
+
* a busy node have taken tens of seconds and then answered in half a second.
|
|
57
|
+
*/
|
|
58
|
+
timeoutMs?: number;
|
|
52
59
|
}
|
|
53
60
|
export declare class PodRestClient {
|
|
54
61
|
private readonly base;
|
|
55
62
|
private readonly fetchFn;
|
|
63
|
+
private readonly timeoutMs;
|
|
56
64
|
private readonly inflight;
|
|
57
65
|
constructor(opts: RestClientOptions);
|
|
58
66
|
private get;
|
|
@@ -77,6 +85,20 @@ export declare class PodRestClient {
|
|
|
77
85
|
/** Accounts ranked by net PnL (realized + unrealized), descending. Paginate
|
|
78
86
|
* with `{ limit, offset }`; ranks are 1-based over the full ordering. */
|
|
79
87
|
leaderboard(q?: LeaderboardQuery): Promise<LeaderboardPage>;
|
|
88
|
+
/** Static bridge config: the claim chain, the bridge contract, and every
|
|
89
|
+
* bridged token's L1 address, decimals and withdraw window (ADR 0033 §5).
|
|
90
|
+
* Served unconditionally — it is not behind the CLOB indexer's gate. */
|
|
91
|
+
bridgeConfig(): Promise<BridgeConfig>;
|
|
92
|
+
/**
|
|
93
|
+
* Terminal withdrawal outcomes, newest cursor last. Omit `account` for every
|
|
94
|
+
* account (what a relayer wants); pass one to scope it to a single user.
|
|
95
|
+
*
|
|
96
|
+
* This is the reconnect backfill behind the `pod_withdrawals` subscription:
|
|
97
|
+
* the rows decode to exactly the same shape the stream pushes, so a client
|
|
98
|
+
* cannot tell which one an outcome arrived on. Page with `since` (the tick
|
|
99
|
+
* cursor) plus `sinceId` to resume *inside* a tick that spanned a page.
|
|
100
|
+
*/
|
|
101
|
+
bridgeWithdrawals(account?: Address, q?: WithdrawalsQuery): Promise<Withdrawal[]>;
|
|
80
102
|
triggers(account: Address, q?: TriggersQueryRest): Promise<TriggersPage>;
|
|
81
103
|
}
|
|
82
104
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../src/transport/rest.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../src/transport/rest.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,GAAG,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EACpF,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAC3F,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAClD,MAAM,oBAAoB,CAAC;AAa5B,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,mBAAmB,EAAE,CAAC;CAChC;AACD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AACD,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,M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 +1,7 @@
|
|
|
1
1
|
// Layer 1: typed one-shot REST reads of `/clob/*`. Plain fetch so the browser /
|
|
2
2
|
// CDN honor the server's Cache-Control; identical concurrent GETs are deduped.
|
|
3
3
|
// ms in, decoded (bigint / ms) out.
|
|
4
|
-
import { decodeBackstopTransfer, decodeBalances, decodeCandle, decodeLeaderboard, decodeMarketDynamics, decodeMarketStatic, decodeOrder, decodeOrderbook, decodePositions, decodeStatus, decodeTrigger, } from "../codec/decode.js";
|
|
4
|
+
import { decodeBackstopTransfer, decodeBalances, decodeBridgeConfig, decodeCandle, decodeLeaderboard, decodeMarketDynamics, decodeMarketStatic, decodeOrder, decodeOrderbook, decodePositions, decodeStatus, decodeTrigger, decodeWithdrawal, } from "../codec/decode.js";
|
|
5
5
|
import { msToSecs, usToMs } from "../codec/units.js";
|
|
6
6
|
export class PodHttpError extends Error {
|
|
7
7
|
status;
|
|
@@ -16,10 +16,12 @@ export class PodHttpError extends Error {
|
|
|
16
16
|
export class PodRestClient {
|
|
17
17
|
base;
|
|
18
18
|
fetchFn;
|
|
19
|
+
timeoutMs;
|
|
19
20
|
inflight = new Map();
|
|
20
21
|
constructor(opts) {
|
|
21
22
|
this.base = opts.restUrl.replace(/\/$/, "");
|
|
22
23
|
this.fetchFn = opts.fetch ?? globalThis.fetch.bind(globalThis);
|
|
24
|
+
this.timeoutMs = opts.timeoutMs ?? 15_000;
|
|
23
25
|
}
|
|
24
26
|
async get(path, query) {
|
|
25
27
|
const url = this.buildUrl(path, query);
|
|
@@ -44,7 +46,12 @@ export class PodRestClient {
|
|
|
44
46
|
return u.toString();
|
|
45
47
|
}
|
|
46
48
|
async doGet(url) {
|
|
47
|
-
const res = await this.fetchFn(url, {
|
|
49
|
+
const res = await this.fetchFn(url, {
|
|
50
|
+
headers: { accept: "application/json" },
|
|
51
|
+
// `AbortSignal.timeout` everywhere current; omitted rather than polyfilled
|
|
52
|
+
// where it is missing, which only loses the timeout.
|
|
53
|
+
signal: AbortSignal.timeout?.(this.timeoutMs),
|
|
54
|
+
});
|
|
48
55
|
if (!res.ok) {
|
|
49
56
|
let body = "";
|
|
50
57
|
try {
|
|
@@ -131,6 +138,30 @@ export class PodRestClient {
|
|
|
131
138
|
});
|
|
132
139
|
return decodeLeaderboard(w, q?.offset ?? 0);
|
|
133
140
|
}
|
|
141
|
+
/** Static bridge config: the claim chain, the bridge contract, and every
|
|
142
|
+
* bridged token's L1 address, decimals and withdraw window (ADR 0033 §5).
|
|
143
|
+
* Served unconditionally — it is not behind the CLOB indexer's gate. */
|
|
144
|
+
async bridgeConfig() {
|
|
145
|
+
return decodeBridgeConfig(await this.get("/bridge/config"));
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Terminal withdrawal outcomes, newest cursor last. Omit `account` for every
|
|
149
|
+
* account (what a relayer wants); pass one to scope it to a single user.
|
|
150
|
+
*
|
|
151
|
+
* This is the reconnect backfill behind the `pod_withdrawals` subscription:
|
|
152
|
+
* the rows decode to exactly the same shape the stream pushes, so a client
|
|
153
|
+
* cannot tell which one an outcome arrived on. Page with `since` (the tick
|
|
154
|
+
* cursor) plus `sinceId` to resume *inside* a tick that spanned a page.
|
|
155
|
+
*/
|
|
156
|
+
async bridgeWithdrawals(account, q) {
|
|
157
|
+
const path = account ? `/bridge/withdrawals/${account}` : "/bridge/withdrawals";
|
|
158
|
+
const w = await this.get(path, {
|
|
159
|
+
since: q?.since,
|
|
160
|
+
since_id: q?.sinceId,
|
|
161
|
+
limit: q?.limit,
|
|
162
|
+
});
|
|
163
|
+
return w.map(decodeWithdrawal);
|
|
164
|
+
}
|
|
134
165
|
async triggers(account, q) {
|
|
135
166
|
const w = await this.get(`/clob/triggers/${account}`, {
|
|
136
167
|
orderbook: q?.orderbook,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../src/transport/rest.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+EAA+E;AAC/E,oCAAoC;
|
|
1
|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AE,CAAC,CAAC,WAAW;SAC1B,CAAC;IACJ,CAAC;CACF"}
|
package/dist/transport/ws.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { Address, MarketId } from "../types/public.js";
|
|
2
|
-
export type Channel = "pod_orderbook" | "pod_orders_v2" | "pod_candles" | "pod_markets" | "pod_positions" | "pod_triggers"
|
|
2
|
+
export type Channel = "pod_orderbook" | "pod_orders_v2" | "pod_candles" | "pod_markets" | "pod_positions" | "pod_triggers"
|
|
3
|
+
/** Terminal withdrawal outcomes; one array per tick, `account`-filtered on the
|
|
4
|
+
* debited account (the master, under delegation). ADR 0033 §6. */
|
|
5
|
+
| "pod_withdrawals";
|
|
3
6
|
export interface SubParams {
|
|
4
7
|
clobIds?: MarketId[];
|
|
5
8
|
account?: Address;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/transport/ws.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,MAAM,OAAO,GACf,eAAe,GAAG,eAAe,GAAG,aAAa,GACjD,aAAa,GAAG,eAAe,GAAG,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/transport/ws.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,MAAM,OAAO,GACf,eAAe,GAAG,eAAe,GAAG,aAAa,GACjD,aAAa,GAAG,eAAe,GAAG,cAAc;AAClD;kEACkE;GAChE,iBAAiB,CAAC;AAEtB,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;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