@useopentab/cli 0.0.0-stage → 0.1.0
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/LICENSE +202 -0
- package/README.md +147 -2
- package/dist/bin.js +361 -0
- package/dist/chunks/chunk-4R3NAR3C.js +28 -0
- package/dist/chunks/chunk-D3C7KAMJ.js +2221 -0
- package/dist/chunks/chunk-EKJH2AJS.js +371 -0
- package/dist/chunks/chunk-GOEFQ62Z.js +53 -0
- package/dist/chunks/chunk-HTU7QRDF.js +223 -0
- package/dist/chunks/chunk-HZHOKJIM.js +360 -0
- package/dist/chunks/chunk-IRXOU25X.js +1856 -0
- package/dist/chunks/chunk-MOZ4BFSB.js +13 -0
- package/dist/chunks/chunk-Q776JIO3.js +1821 -0
- package/dist/chunks/chunk-QTI2WM44.js +68 -0
- package/dist/chunks/chunk-S5IAH7CT.js +84 -0
- package/dist/chunks/config-OPZLVTYX.js +73 -0
- package/dist/chunks/gate-53O3YCXE.js +74 -0
- package/dist/chunks/indexer-OLIWEEFT.js +491 -0
- package/dist/chunks/init-JSZX6AF5.js +176 -0
- package/dist/chunks/line-2QBTLAUN.js +95 -0
- package/dist/chunks/liveNode-SLQN4XRB.js +299 -0
- package/dist/chunks/liveOnboard-Z4GRTSHR.js +400 -0
- package/dist/chunks/liveSettle-V5W7D2U5.js +1398 -0
- package/dist/chunks/notary-PQDSEOVV.js +122 -0
- package/dist/chunks/onboardError-RLJPEEFU.js +10 -0
- package/dist/chunks/src-RIOYQO2J.js +556 -0
- package/dist/chunks/tab-QPO2545T.js +59 -0
- package/dist/chunks/verify-Z7BGKZOB.js +719 -0
- package/package.json +66 -3
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RegistryReader
|
|
3
|
+
} from "./chunk-EKJH2AJS.js";
|
|
4
|
+
import "./chunk-4R3NAR3C.js";
|
|
5
|
+
import {
|
|
6
|
+
GrpcOnboardChain,
|
|
7
|
+
HostedRegistryMcp,
|
|
8
|
+
SafeCardFetcher
|
|
9
|
+
} from "./chunk-Q776JIO3.js";
|
|
10
|
+
import "./chunk-IRXOU25X.js";
|
|
11
|
+
import {
|
|
12
|
+
agentBadge,
|
|
13
|
+
decodeTokenAddress,
|
|
14
|
+
isAccountAddress,
|
|
15
|
+
toU64
|
|
16
|
+
} from "./chunk-HZHOKJIM.js";
|
|
17
|
+
import {
|
|
18
|
+
HOSTED_MCP_URL,
|
|
19
|
+
HOSTED_NETWORK,
|
|
20
|
+
HOSTED_REST_BASE,
|
|
21
|
+
InvalidInputError,
|
|
22
|
+
WrongNetworkError
|
|
23
|
+
} from "./chunk-S5IAH7CT.js";
|
|
24
|
+
import "./chunk-D3C7KAMJ.js";
|
|
25
|
+
|
|
26
|
+
// packages/registry/src/lru.ts
|
|
27
|
+
var LruCache = class {
|
|
28
|
+
#max;
|
|
29
|
+
#ttl;
|
|
30
|
+
#now;
|
|
31
|
+
#map = /* @__PURE__ */ new Map();
|
|
32
|
+
constructor(opts) {
|
|
33
|
+
if (!Number.isInteger(opts.max) || opts.max < 1) throw new RangeError("LRU max must be a positive integer");
|
|
34
|
+
this.#max = opts.max;
|
|
35
|
+
this.#ttl = opts.ttlMs;
|
|
36
|
+
this.#now = opts.now ?? Date.now;
|
|
37
|
+
}
|
|
38
|
+
get size() {
|
|
39
|
+
return this.#map.size;
|
|
40
|
+
}
|
|
41
|
+
/** The value, refreshed as most recently used; `undefined` when absent or expired. */
|
|
42
|
+
get(key) {
|
|
43
|
+
const hit = this.#map.get(key);
|
|
44
|
+
if (hit === void 0) return void 0;
|
|
45
|
+
this.#map.delete(key);
|
|
46
|
+
if (hit.expires <= this.#now()) return void 0;
|
|
47
|
+
this.#map.set(key, hit);
|
|
48
|
+
return hit.value;
|
|
49
|
+
}
|
|
50
|
+
has(key) {
|
|
51
|
+
return this.get(key) !== void 0;
|
|
52
|
+
}
|
|
53
|
+
set(key, value, ttlMs = this.#ttl) {
|
|
54
|
+
this.#map.delete(key);
|
|
55
|
+
this.#map.set(key, { value, expires: this.#now() + ttlMs });
|
|
56
|
+
while (this.#map.size > this.#max) {
|
|
57
|
+
const oldest = this.#map.keys().next().value;
|
|
58
|
+
if (oldest === void 0) break;
|
|
59
|
+
this.#map.delete(oldest);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
delete(key) {
|
|
63
|
+
return this.#map.delete(key);
|
|
64
|
+
}
|
|
65
|
+
clear() {
|
|
66
|
+
this.#map.clear();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// packages/registry/src/retryAfter.ts
|
|
71
|
+
function parseRetryAfter(value, now = Date.now(), maxMs = 36e5) {
|
|
72
|
+
if (value === null || value === void 0) return void 0;
|
|
73
|
+
const v = value.trim();
|
|
74
|
+
if (/^[0-9]+$/.test(v)) return Math.min(Number(v) * 1e3, maxMs);
|
|
75
|
+
if (!/[a-zA-Z]/.test(v)) return void 0;
|
|
76
|
+
const at = Date.parse(v);
|
|
77
|
+
if (Number.isNaN(at)) return void 0;
|
|
78
|
+
return Math.min(Math.max(0, at - now), maxMs);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// packages/registry/src/hosted.ts
|
|
82
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
83
|
+
import { StreamableHTTPClientTransport, StreamableHTTPError } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
84
|
+
var NETWORKLESS_TOOLS = /* @__PURE__ */ new Set(["parse_token_address", "token_address"]);
|
|
85
|
+
var RateLimitedError = class extends Error {
|
|
86
|
+
name = "RateLimitedError";
|
|
87
|
+
/** How long the service asked us to wait, in ms. */
|
|
88
|
+
retryAfterMs;
|
|
89
|
+
constructor(retryAfterMs, cause) {
|
|
90
|
+
super(`hosted registry is rate limiting; retry in ${Math.ceil(retryAfterMs / 1e3)} s`, cause === void 0 ? void 0 : { cause });
|
|
91
|
+
this.retryAfterMs = retryAfterMs;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var HostedToolError = class extends Error {
|
|
95
|
+
name = "HostedToolError";
|
|
96
|
+
tool;
|
|
97
|
+
constructor(tool, message) {
|
|
98
|
+
super(`${tool}: ${message}`);
|
|
99
|
+
this.tool = tool;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var HostedHttpError = class extends Error {
|
|
103
|
+
name = "HostedHttpError";
|
|
104
|
+
status;
|
|
105
|
+
body;
|
|
106
|
+
constructor(status, message, body) {
|
|
107
|
+
super(`HTTP ${status}: ${message}`);
|
|
108
|
+
this.status = status;
|
|
109
|
+
this.body = body;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
var CLIENT_INFO = { name: "opentab-registry", version: "0.0.0" };
|
|
113
|
+
function stableJson(v) {
|
|
114
|
+
if (Array.isArray(v)) return `[${v.map(stableJson).join(",")}]`;
|
|
115
|
+
if (v !== null && typeof v === "object") {
|
|
116
|
+
const o = v;
|
|
117
|
+
return `{${Object.keys(o).sort().map((k) => `${JSON.stringify(k)}:${stableJson(o[k])}`).join(",")}}`;
|
|
118
|
+
}
|
|
119
|
+
return JSON.stringify(v) ?? "null";
|
|
120
|
+
}
|
|
121
|
+
function httpStatusOf(e) {
|
|
122
|
+
if (e instanceof StreamableHTTPError) return e.code;
|
|
123
|
+
if (e instanceof HostedHttpError) return e.status;
|
|
124
|
+
return void 0;
|
|
125
|
+
}
|
|
126
|
+
function isObject(v) {
|
|
127
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
128
|
+
}
|
|
129
|
+
function assertTestnetPayload(v) {
|
|
130
|
+
if (isObject(v) && "network" in v && v.network !== HOSTED_NETWORK) {
|
|
131
|
+
throw new WrongNetworkError(HOSTED_NETWORK, String(v.network));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function optString(o, k) {
|
|
135
|
+
const v = o[k];
|
|
136
|
+
if (v === null || v === void 0) return null;
|
|
137
|
+
if (typeof v !== "string") throw new InvalidInputError(`hosted field ${k} is not a string`);
|
|
138
|
+
return v;
|
|
139
|
+
}
|
|
140
|
+
function reqString(o, k) {
|
|
141
|
+
const v = optString(o, k);
|
|
142
|
+
if (v === null) throw new InvalidInputError(`hosted field ${k} is missing`);
|
|
143
|
+
return v;
|
|
144
|
+
}
|
|
145
|
+
function parseHostedAgent(v) {
|
|
146
|
+
if (!isObject(v)) throw new InvalidInputError("hosted agent_of: not an object");
|
|
147
|
+
assertTestnetPayload(v);
|
|
148
|
+
const status = reqString(v, "status");
|
|
149
|
+
if (status !== "Active" && status !== "Revoked") throw new InvalidInputError(`hosted agent_of: unknown status ${status}`);
|
|
150
|
+
const tokenId = toU64(typeof v.token_id === "number" ? String(v.token_id) : reqString(v, "token_id"), "token_id");
|
|
151
|
+
return {
|
|
152
|
+
tokenId,
|
|
153
|
+
tokenAddress: reqString(v, "token_address"),
|
|
154
|
+
ownerAccount: reqString(v, "owner_account"),
|
|
155
|
+
agentUri: optString(v, "agent_uri"),
|
|
156
|
+
metadataHash: optString(v, "metadata_hash_hex"),
|
|
157
|
+
agentWallet: optString(v, "agent_wallet"),
|
|
158
|
+
status,
|
|
159
|
+
raw: v
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function parseHostedBadgeCheck(v) {
|
|
163
|
+
if (!isObject(v)) throw new InvalidInputError("check-badge: not an object");
|
|
164
|
+
assertTestnetPayload(v);
|
|
165
|
+
if (typeof v.badge_valid !== "boolean") throw new InvalidInputError("check-badge: badge_valid is not a boolean");
|
|
166
|
+
const checks = isObject(v.checks) ? v.checks : {};
|
|
167
|
+
const issues = Array.isArray(v.issues) ? v.issues : [];
|
|
168
|
+
const rawId = v.token_id;
|
|
169
|
+
const tokenId = typeof rawId === "number" || typeof rawId === "string" ? toU64(typeof rawId === "number" ? String(rawId) : rawId, "token_id") : null;
|
|
170
|
+
return {
|
|
171
|
+
badgeValid: v.badge_valid,
|
|
172
|
+
tokenId,
|
|
173
|
+
tokenAddress: optString(v, "token_address"),
|
|
174
|
+
cardSha256: optString(v, "card_sha256"),
|
|
175
|
+
checks,
|
|
176
|
+
issues,
|
|
177
|
+
network: typeof v.network === "string" ? v.network : HOSTED_NETWORK,
|
|
178
|
+
raw: v
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function textOf(result) {
|
|
182
|
+
const content = "content" in result && Array.isArray(result.content) ? result.content : [];
|
|
183
|
+
return content.filter((c) => isObject(c) && c.type === "text" && typeof c.text === "string").map((c) => c.text).join("");
|
|
184
|
+
}
|
|
185
|
+
var HostedRegistry = class {
|
|
186
|
+
network = HOSTED_NETWORK;
|
|
187
|
+
#mcpUrl;
|
|
188
|
+
#restBase;
|
|
189
|
+
#maxRetries;
|
|
190
|
+
#maxWaitMs;
|
|
191
|
+
#defaultBackoffMs;
|
|
192
|
+
#timeoutMs;
|
|
193
|
+
#baseFetch;
|
|
194
|
+
#transportFactory;
|
|
195
|
+
#now;
|
|
196
|
+
#sleep;
|
|
197
|
+
#cache;
|
|
198
|
+
#inflight = /* @__PURE__ */ new Map();
|
|
199
|
+
#client;
|
|
200
|
+
#connecting;
|
|
201
|
+
#blockedUntil = 0;
|
|
202
|
+
constructor(opts = {}) {
|
|
203
|
+
this.#mcpUrl = opts.mcpUrl ?? HOSTED_MCP_URL;
|
|
204
|
+
this.#restBase = (opts.restBase ?? HOSTED_REST_BASE).replace(/\/+$/, "");
|
|
205
|
+
this.#maxRetries = opts.maxRetries ?? 2;
|
|
206
|
+
this.#maxWaitMs = opts.maxWaitMs ?? 1e4;
|
|
207
|
+
this.#defaultBackoffMs = opts.defaultBackoffMs ?? 1e3;
|
|
208
|
+
this.#timeoutMs = opts.timeoutMs ?? 15e3;
|
|
209
|
+
this.#baseFetch = opts.fetch ?? ((url, init) => fetch(url, init));
|
|
210
|
+
this.#transportFactory = opts.transportFactory;
|
|
211
|
+
this.#now = opts.now ?? Date.now;
|
|
212
|
+
this.#sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
213
|
+
this.#cache = new LruCache({ max: opts.cacheSize ?? 256, ttlMs: opts.cacheTtlMs ?? 6e4, now: this.#now });
|
|
214
|
+
}
|
|
215
|
+
/** Milliseconds until the rate-limit gate opens (0 when open). */
|
|
216
|
+
get retryAfterMs() {
|
|
217
|
+
return Math.max(0, this.#blockedUntil - this.#now());
|
|
218
|
+
}
|
|
219
|
+
/** fetch wrapper shared by MCP and REST: records 429/503 `Retry-After` in the gate. */
|
|
220
|
+
#fetch = async (url, init) => {
|
|
221
|
+
const res = await this.#baseFetch(url, init);
|
|
222
|
+
if (res.status === 429 || res.status === 503) {
|
|
223
|
+
const wait = parseRetryAfter(res.headers.get("retry-after"), this.#now()) ?? this.#defaultBackoffMs;
|
|
224
|
+
this.#blockedUntil = Math.max(this.#blockedUntil, this.#now() + wait);
|
|
225
|
+
}
|
|
226
|
+
return res;
|
|
227
|
+
};
|
|
228
|
+
async #waitForGate() {
|
|
229
|
+
const wait = this.#blockedUntil - this.#now();
|
|
230
|
+
if (wait <= 0) return;
|
|
231
|
+
if (wait > this.#maxWaitMs) throw new RateLimitedError(wait);
|
|
232
|
+
await this.#sleep(wait);
|
|
233
|
+
}
|
|
234
|
+
async #withRetry(op) {
|
|
235
|
+
for (let attempt = 0; ; attempt++) {
|
|
236
|
+
await this.#waitForGate();
|
|
237
|
+
try {
|
|
238
|
+
return await op();
|
|
239
|
+
} catch (e) {
|
|
240
|
+
const status = httpStatusOf(e);
|
|
241
|
+
if (status !== 429 && status !== 503) throw e;
|
|
242
|
+
if (attempt >= this.#maxRetries) throw new RateLimitedError(Math.max(this.retryAfterMs, 0), e);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
async #cached(key, useCache, op) {
|
|
247
|
+
if (useCache) {
|
|
248
|
+
const hit = this.#cache.get(key);
|
|
249
|
+
if (hit !== void 0) return hit.value;
|
|
250
|
+
const pending = this.#inflight.get(key);
|
|
251
|
+
if (pending !== void 0) return pending;
|
|
252
|
+
}
|
|
253
|
+
const p = this.#withRetry(op).then((value) => {
|
|
254
|
+
this.#cache.set(key, { value });
|
|
255
|
+
return value;
|
|
256
|
+
});
|
|
257
|
+
if (useCache) {
|
|
258
|
+
this.#inflight.set(key, p);
|
|
259
|
+
void p.then(
|
|
260
|
+
() => this.#inflight.delete(key),
|
|
261
|
+
() => this.#inflight.delete(key)
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
return p;
|
|
265
|
+
}
|
|
266
|
+
#connect() {
|
|
267
|
+
if (this.#client) return Promise.resolve(this.#client);
|
|
268
|
+
this.#connecting ??= (async () => {
|
|
269
|
+
const transport = this.#transportFactory?.() ?? new StreamableHTTPClientTransport(new URL(this.#mcpUrl), { fetch: this.#fetch });
|
|
270
|
+
const client = new Client(CLIENT_INFO, { capabilities: {} });
|
|
271
|
+
await client.connect(transport, { timeout: this.#timeoutMs });
|
|
272
|
+
this.#client = client;
|
|
273
|
+
return client;
|
|
274
|
+
})().finally(() => {
|
|
275
|
+
this.#connecting = void 0;
|
|
276
|
+
});
|
|
277
|
+
return this.#connecting;
|
|
278
|
+
}
|
|
279
|
+
async #callOnce(name, args) {
|
|
280
|
+
const client = await this.#connect();
|
|
281
|
+
let result;
|
|
282
|
+
try {
|
|
283
|
+
result = await client.callTool({ name, arguments: args }, void 0, { timeout: this.#timeoutMs });
|
|
284
|
+
} catch (e) {
|
|
285
|
+
if (httpStatusOf(e) === 404 || httpStatusOf(e) === 400) await this.#reset();
|
|
286
|
+
throw e;
|
|
287
|
+
}
|
|
288
|
+
if ("isError" in result && result.isError === true) throw new HostedToolError(name, textOf(result) || "tool error");
|
|
289
|
+
let value;
|
|
290
|
+
if ("structuredContent" in result && result.structuredContent !== void 0) value = result.structuredContent;
|
|
291
|
+
else {
|
|
292
|
+
const text = textOf(result);
|
|
293
|
+
try {
|
|
294
|
+
value = JSON.parse(text);
|
|
295
|
+
} catch {
|
|
296
|
+
value = text;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
assertTestnetPayload(value);
|
|
300
|
+
return value;
|
|
301
|
+
}
|
|
302
|
+
async #reset() {
|
|
303
|
+
const c = this.#client;
|
|
304
|
+
this.#client = void 0;
|
|
305
|
+
await c?.close().catch(() => void 0);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Call any hosted tool with `network: "testnet"` added. Returns the parsed JSON payload (or the
|
|
309
|
+
* text when it is not JSON). Cached unless `cache: false`.
|
|
310
|
+
*/
|
|
311
|
+
async callTool(name, args = {}, opts = {}) {
|
|
312
|
+
if (!/^[a-z][a-z0-9_]*$/.test(name)) throw new InvalidInputError(`bad tool name ${name}`);
|
|
313
|
+
if (NETWORKLESS_TOOLS.has(name)) {
|
|
314
|
+
throw new InvalidInputError(`${name} takes no network; use the local encoders in address.ts`);
|
|
315
|
+
}
|
|
316
|
+
if ("network" in args && args.network !== HOSTED_NETWORK) {
|
|
317
|
+
throw new InvalidInputError(`refusing network ${String(args.network)}: this client only queries testnet`);
|
|
318
|
+
}
|
|
319
|
+
const full = { ...args, network: HOSTED_NETWORK };
|
|
320
|
+
return this.#cached(`mcp:${name}:${stableJson(full)}`, opts.cache ?? true, () => this.#callOnce(name, full));
|
|
321
|
+
}
|
|
322
|
+
/** MCP `agent_of` on testnet; `null` when the agent does not exist. */
|
|
323
|
+
async agentOf(tokenId) {
|
|
324
|
+
const v = await this.callTool("agent_of", { token_id: toU64(tokenId, "token id").toString() });
|
|
325
|
+
return v === null ? null : parseHostedAgent(v);
|
|
326
|
+
}
|
|
327
|
+
/** MCP `get_agent_wallet` on testnet. */
|
|
328
|
+
async getAgentWallet(tokenId) {
|
|
329
|
+
const v = await this.callTool("get_agent_wallet", { token_id: toU64(tokenId, "token id").toString() });
|
|
330
|
+
if (v === null) return null;
|
|
331
|
+
if (!isObject(v)) throw new InvalidInputError("get_agent_wallet: not an object");
|
|
332
|
+
return optString(v, "agent_wallet");
|
|
333
|
+
}
|
|
334
|
+
/** MCP `owner_of_key` on testnet (raw payload; `null` when unbound). */
|
|
335
|
+
ownerOfKey(key) {
|
|
336
|
+
return this.callTool("owner_of_key", {
|
|
337
|
+
external_key: { namespace: key.namespace, key_type: key.keyType, public_key_hex: key.publicKey }
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/** MCP `contract_info` on testnet (addresses, module refs, admins). */
|
|
341
|
+
contractInfo() {
|
|
342
|
+
return this.callTool("contract_info");
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* REST `GET /v1/check-badge/<badge>?network=testnet`. The badge is validated locally first: it
|
|
346
|
+
* must be a token address of the testnet CIS-8004 registry.
|
|
347
|
+
*/
|
|
348
|
+
async checkBadge(badge, opts = {}) {
|
|
349
|
+
const t = decodeTokenAddress(badge);
|
|
350
|
+
if (t.tokenId === null || agentBadge(t.tokenId) !== badge) throw new InvalidInputError("not a testnet CIS-8004 badge");
|
|
351
|
+
const url = `${this.#restBase}/v1/check-badge/${badge}?network=${HOSTED_NETWORK}`;
|
|
352
|
+
return this.#cached(`rest:check-badge:${badge}`, opts.cache ?? true, async () => {
|
|
353
|
+
const raw = await this.#getJson(url);
|
|
354
|
+
const verdict = parseHostedBadgeCheck(raw);
|
|
355
|
+
if (verdict.tokenAddress !== null && verdict.tokenAddress !== badge) {
|
|
356
|
+
throw new InvalidInputError(`check-badge answered for ${verdict.tokenAddress}, asked ${badge}`);
|
|
357
|
+
}
|
|
358
|
+
return verdict;
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
/** REST check of every badge an account owns (`/v1/check-badge/<account>?network=testnet`), raw payload. */
|
|
362
|
+
async checkAccountBadges(account, opts = {}) {
|
|
363
|
+
if (!isAccountAddress(account)) throw new InvalidInputError("not an account address");
|
|
364
|
+
const url = `${this.#restBase}/v1/check-badge/${account}?network=${HOSTED_NETWORK}`;
|
|
365
|
+
return this.#cached(`rest:check-badge:${account}`, opts.cache ?? true, () => this.#getJson(url));
|
|
366
|
+
}
|
|
367
|
+
async #getJson(url) {
|
|
368
|
+
const res = await this.#fetch(url, {
|
|
369
|
+
method: "GET",
|
|
370
|
+
headers: { accept: "application/json" },
|
|
371
|
+
signal: AbortSignal.timeout(this.#timeoutMs)
|
|
372
|
+
});
|
|
373
|
+
const text = await res.text();
|
|
374
|
+
let body = text;
|
|
375
|
+
try {
|
|
376
|
+
body = JSON.parse(text);
|
|
377
|
+
} catch {
|
|
378
|
+
}
|
|
379
|
+
if (!res.ok) {
|
|
380
|
+
const msg = isObject(body) && typeof body.message === "string" ? body.message : res.statusText;
|
|
381
|
+
throw new HostedHttpError(res.status, msg, body);
|
|
382
|
+
}
|
|
383
|
+
assertTestnetPayload(body);
|
|
384
|
+
return body;
|
|
385
|
+
}
|
|
386
|
+
/** Drop every cached result. */
|
|
387
|
+
clearCache() {
|
|
388
|
+
this.#cache.clear();
|
|
389
|
+
}
|
|
390
|
+
async close() {
|
|
391
|
+
await this.#reset();
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
export {
|
|
395
|
+
GrpcOnboardChain,
|
|
396
|
+
HostedRegistry,
|
|
397
|
+
HostedRegistryMcp,
|
|
398
|
+
RegistryReader,
|
|
399
|
+
SafeCardFetcher
|
|
400
|
+
};
|