@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
package/dist/bin.js
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
renderReport,
|
|
4
|
+
reportJson
|
|
5
|
+
} from "./chunks/chunk-GOEFQ62Z.js";
|
|
6
|
+
import {
|
|
7
|
+
CliError
|
|
8
|
+
} from "./chunks/chunk-MOZ4BFSB.js";
|
|
9
|
+
|
|
10
|
+
// packages/cli/src/cli.ts
|
|
11
|
+
import { parseArgs } from "node:util";
|
|
12
|
+
|
|
13
|
+
// packages/cli/package.json
|
|
14
|
+
var package_default = { name: "@useopentab/cli", version: "0.1.0" };
|
|
15
|
+
|
|
16
|
+
// packages/cli/src/version.ts
|
|
17
|
+
var NAME = package_default.name;
|
|
18
|
+
var VERSION = package_default.version;
|
|
19
|
+
|
|
20
|
+
// packages/cli/src/cli.ts
|
|
21
|
+
var USAGE = `usage: opentab <command> [options] [--json]
|
|
22
|
+
|
|
23
|
+
verify tx <hash> decode and check any OpenTab transaction
|
|
24
|
+
verify settlement <txHash> TabSettled + transfer to the snapshot seller wallet, bureau balance 0
|
|
25
|
+
verify line <id> [--tx <openLine>] LineOpened, attestation, allow-listed attestor, CCDVRA/CCDVAA anchors
|
|
26
|
+
verify tab <id> [--tx <openTab>] [--settlement <hash>]...
|
|
27
|
+
verify receipts <file> [--offline] every voucher and receipt signature, lane rules, hash chain
|
|
28
|
+
verify demo [--bundle <path-or-url>] [--timeout <s>]
|
|
29
|
+
|
|
30
|
+
init --role buyer|seller --name <n> --owner <acct> --wallet <acct> [--base-url <https>]
|
|
31
|
+
[--owner-key <export>] [--wallet-key <export>] [--step <s> --tx <hash>] [--wallet-signature <hex>]
|
|
32
|
+
[--prices <json>] [--max-tab-ccd <n>] [--min-tier <0-2>] [--min-k <n>] [--tabs-per-day <n>]
|
|
33
|
+
[--admit-badge-invalid] [--key-name <k>] [--plan <file>] [--cards-dir <dir>] [--no-mcp] [--yes]
|
|
34
|
+
line open --token <id> --owner <acct> --session-key <hex>
|
|
35
|
+
line status <id>
|
|
36
|
+
line close <id> --owner <acct> [--owner-key <export>]
|
|
37
|
+
tab status <id>
|
|
38
|
+
tab settle <id> --url <seller origin> --wallet-key <export> --key <keyd buyer key> [--max-price <microCCD>] [--through auto|previous|current]
|
|
39
|
+
notary repair <badge> [--host-at <url>] [--out <file>]
|
|
40
|
+
gate up --seller-token <id> --upstream <url> [--public-url <https>] [--prices <json>] [--mode full|passthrough] [--exact-price <microCCD>]
|
|
41
|
+
|
|
42
|
+
--help this text
|
|
43
|
+
--version the version of this CLI
|
|
44
|
+
|
|
45
|
+
Environment: OPENTAB_GRPC_HOST, OPENTAB_GRPC_PORT, OPENTAB_BUREAU, OPENTAB_ANCHOR_ACCOUNT, OPENTAB_DRP_ANCHOR_ACCOUNTS, INDEXER_URL,
|
|
46
|
+
PUBLIC_BASE_URL, NOTARY_URL, FACILITATOR_URL, KEYD_SOCKET, KEYD_KEY_DIR (see packages/cli/README.md).
|
|
47
|
+
`;
|
|
48
|
+
var OPTIONS = {
|
|
49
|
+
json: { type: "boolean", default: false },
|
|
50
|
+
help: { type: "boolean", default: false },
|
|
51
|
+
version: { type: "boolean", default: false },
|
|
52
|
+
tx: { type: "string" },
|
|
53
|
+
settlement: { type: "string", multiple: true },
|
|
54
|
+
bundle: { type: "string" },
|
|
55
|
+
offline: { type: "boolean", default: false },
|
|
56
|
+
timeout: { type: "string", default: "60" },
|
|
57
|
+
role: { type: "string" },
|
|
58
|
+
name: { type: "string" },
|
|
59
|
+
description: { type: "string" },
|
|
60
|
+
owner: { type: "string" },
|
|
61
|
+
wallet: { type: "string" },
|
|
62
|
+
"base-url": { type: "string" },
|
|
63
|
+
"key-name": { type: "string" },
|
|
64
|
+
plan: { type: "string" },
|
|
65
|
+
"cards-dir": { type: "string" },
|
|
66
|
+
"owner-key": { type: "string" },
|
|
67
|
+
"wallet-key": { type: "string" },
|
|
68
|
+
step: { type: "string" },
|
|
69
|
+
"wallet-signature": { type: "string" },
|
|
70
|
+
prices: { type: "string" },
|
|
71
|
+
"max-tab-ccd": { type: "string", default: "100" },
|
|
72
|
+
"min-tier": { type: "string", default: "0" },
|
|
73
|
+
"min-k": { type: "string", default: "0" },
|
|
74
|
+
"tabs-per-day": { type: "string", default: "20" },
|
|
75
|
+
"admit-badge-invalid": { type: "boolean", default: false },
|
|
76
|
+
yes: { type: "boolean", default: false },
|
|
77
|
+
"no-mcp": { type: "boolean", default: false },
|
|
78
|
+
token: { type: "string" },
|
|
79
|
+
"session-key": { type: "string" },
|
|
80
|
+
url: { type: "string" },
|
|
81
|
+
key: { type: "string" },
|
|
82
|
+
"max-price": { type: "string", default: "1000000" },
|
|
83
|
+
through: { type: "string", default: "auto" },
|
|
84
|
+
out: { type: "string" },
|
|
85
|
+
"host-at": { type: "string" },
|
|
86
|
+
"seller-token": { type: "string" },
|
|
87
|
+
upstream: { type: "string" },
|
|
88
|
+
"public-url": { type: "string" },
|
|
89
|
+
mode: { type: "string", default: "full" },
|
|
90
|
+
"exact-price": { type: "string" },
|
|
91
|
+
image: { type: "string", default: "opentab-tab-gate" }
|
|
92
|
+
};
|
|
93
|
+
function u64(text, what) {
|
|
94
|
+
if (text === void 0 || !/^(0|[1-9][0-9]{0,19})$/.test(text) || BigInt(text) >= 1n << 64n) throw new CliError("usage", `${what} must be a u64 decimal`);
|
|
95
|
+
return BigInt(text);
|
|
96
|
+
}
|
|
97
|
+
async function account(text, what) {
|
|
98
|
+
if (text === void 0) throw new CliError("usage", `${what} is required`);
|
|
99
|
+
const { accountAddressFromBase58 } = await import("./chunks/src-RIOYQO2J.js");
|
|
100
|
+
try {
|
|
101
|
+
accountAddressFromBase58(text);
|
|
102
|
+
} catch {
|
|
103
|
+
throw new CliError("usage", `${what} is not an account address`);
|
|
104
|
+
}
|
|
105
|
+
return text;
|
|
106
|
+
}
|
|
107
|
+
async function dispatch(env, positionals, v) {
|
|
108
|
+
const [command, sub, target] = positionals;
|
|
109
|
+
switch (command) {
|
|
110
|
+
case "verify": {
|
|
111
|
+
const timeoutS = Number(v.timeout);
|
|
112
|
+
if (!Number.isInteger(timeoutS) || timeoutS < 1 || timeoutS > 3600) throw new CliError("usage", "--timeout must be whole seconds");
|
|
113
|
+
const { runVerify } = await import("./chunks/verify-Z7BGKZOB.js");
|
|
114
|
+
return { report: await runVerify(env, { sub, target, tx: v.tx, settlements: v.settlement ?? [], bundle: v.bundle, offline: v.offline, timeoutS }) };
|
|
115
|
+
}
|
|
116
|
+
case "init": {
|
|
117
|
+
if (sub !== void 0) throw new CliError("usage", "init takes options only");
|
|
118
|
+
const { init } = await import("./chunks/init-JSZX6AF5.js");
|
|
119
|
+
return init(env, {
|
|
120
|
+
role: v.role,
|
|
121
|
+
name: v.name,
|
|
122
|
+
description: v.description,
|
|
123
|
+
owner: v.owner,
|
|
124
|
+
wallet: v.wallet,
|
|
125
|
+
baseUrl: v["base-url"],
|
|
126
|
+
keyName: v["key-name"],
|
|
127
|
+
plan: v.plan,
|
|
128
|
+
cardsDir: v["cards-dir"],
|
|
129
|
+
ownerKey: v["owner-key"],
|
|
130
|
+
walletKey: v["wallet-key"],
|
|
131
|
+
step: v.step,
|
|
132
|
+
tx: v.tx,
|
|
133
|
+
walletSignature: v["wallet-signature"],
|
|
134
|
+
prices: v.prices,
|
|
135
|
+
maxTabCcd: v["max-tab-ccd"],
|
|
136
|
+
minTier: v["min-tier"],
|
|
137
|
+
minK: v["min-k"],
|
|
138
|
+
tabsPerDay: v["tabs-per-day"],
|
|
139
|
+
admitBadgeInvalid: v["admit-badge-invalid"],
|
|
140
|
+
yes: v.yes,
|
|
141
|
+
noMcp: v["no-mcp"]
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
case "line":
|
|
145
|
+
if (sub === "open") {
|
|
146
|
+
const key = v["session-key"]?.toLowerCase();
|
|
147
|
+
if (key === void 0 || !/^[0-9a-f]{64}$/.test(key)) throw new CliError("usage", "--session-key must be the 32-byte session public key in hex");
|
|
148
|
+
const args = { tokenId: u64(v.token, "--token"), owner: await account(v.owner, "--owner"), sessionKeyHex: key };
|
|
149
|
+
const { lineOpen } = await import("./chunks/line-2QBTLAUN.js");
|
|
150
|
+
return { report: lineOpen(env, args) };
|
|
151
|
+
}
|
|
152
|
+
if (sub === "status") {
|
|
153
|
+
const lineId = u64(target, "the line id");
|
|
154
|
+
const { lineStatus } = await import("./chunks/line-2QBTLAUN.js");
|
|
155
|
+
return { report: await lineStatus(env, lineId) };
|
|
156
|
+
}
|
|
157
|
+
if (sub === "close") {
|
|
158
|
+
const args = { lineId: u64(target, "the line id"), owner: await account(v.owner, "--owner"), ownerKeyFile: v["owner-key"] ?? null };
|
|
159
|
+
const { lineClose } = await import("./chunks/line-2QBTLAUN.js");
|
|
160
|
+
return { report: await lineClose(env, args) };
|
|
161
|
+
}
|
|
162
|
+
throw new CliError("usage", "line open|status|close");
|
|
163
|
+
case "tab":
|
|
164
|
+
if (sub === "status") {
|
|
165
|
+
const tabId = u64(target, "the tab id");
|
|
166
|
+
const { tabStatus } = await import("./chunks/tab-QPO2545T.js");
|
|
167
|
+
return { report: await tabStatus(env, tabId) };
|
|
168
|
+
}
|
|
169
|
+
if (sub === "settle") {
|
|
170
|
+
if (v.url === void 0 || v["wallet-key"] === void 0 || v.key === void 0) throw new CliError("usage", "tab settle needs --url, --wallet-key and --key");
|
|
171
|
+
if (v.through !== "auto" && v.through !== "previous" && v.through !== "current") throw new CliError("usage", "--through must be auto, previous or current");
|
|
172
|
+
let origin;
|
|
173
|
+
try {
|
|
174
|
+
origin = new URL(v.url);
|
|
175
|
+
} catch {
|
|
176
|
+
throw new CliError("usage", "--url is not a URL");
|
|
177
|
+
}
|
|
178
|
+
if (origin.protocol !== "https:") throw new CliError("usage", "--url must be https");
|
|
179
|
+
const args = {
|
|
180
|
+
tabId: u64(target, "the tab id"),
|
|
181
|
+
origin: origin.origin,
|
|
182
|
+
walletKeyFile: v["wallet-key"],
|
|
183
|
+
keyName: v.key,
|
|
184
|
+
maxPricePerCall: u64(v["max-price"], "--max-price"),
|
|
185
|
+
through: v.through
|
|
186
|
+
};
|
|
187
|
+
const { tabSettle } = await import("./chunks/tab-QPO2545T.js");
|
|
188
|
+
return { report: await tabSettle(env, args) };
|
|
189
|
+
}
|
|
190
|
+
throw new CliError("usage", "tab status|settle");
|
|
191
|
+
case "notary": {
|
|
192
|
+
if (sub !== "repair" || target === void 0) throw new CliError("usage", "notary repair <badge>");
|
|
193
|
+
const { notaryRepair } = await import("./chunks/notary-PQDSEOVV.js");
|
|
194
|
+
return { report: await notaryRepair(env, { badge: target, out: v.out ?? null, hostAt: v["host-at"] ?? null }) };
|
|
195
|
+
}
|
|
196
|
+
case "gate": {
|
|
197
|
+
if (sub !== "up") throw new CliError("usage", "gate up");
|
|
198
|
+
const { gateUp } = await import("./chunks/gate-53O3YCXE.js");
|
|
199
|
+
return {
|
|
200
|
+
report: gateUp(env, {
|
|
201
|
+
sellerToken: v["seller-token"],
|
|
202
|
+
upstream: v.upstream,
|
|
203
|
+
publicUrl: v["public-url"],
|
|
204
|
+
prices: v.prices ?? '{"GET /*":"1000000"}',
|
|
205
|
+
mode: v.mode,
|
|
206
|
+
keydKey: v.key ?? "seller",
|
|
207
|
+
exactPrice: v["exact-price"],
|
|
208
|
+
image: v.image
|
|
209
|
+
})
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
default:
|
|
213
|
+
throw new CliError("usage", command === void 0 ? "a command is required" : `unknown command ${command}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
async function errorCode(err) {
|
|
217
|
+
if (err instanceof CliError) return err.code;
|
|
218
|
+
if (err instanceof Error && err.name === "OnboardError") {
|
|
219
|
+
const { errorCode: onboardCode } = await import("./chunks/onboardError-RLJPEEFU.js");
|
|
220
|
+
return onboardCode(err);
|
|
221
|
+
}
|
|
222
|
+
return err?.code === "ERR_PARSE_ARGS_UNKNOWN_OPTION" ? "usage" : "error";
|
|
223
|
+
}
|
|
224
|
+
async function runCli(argv, io, makeEnv) {
|
|
225
|
+
let json = argv.includes("--json");
|
|
226
|
+
let env;
|
|
227
|
+
try {
|
|
228
|
+
const { values, positionals } = parseArgs({ args: [...argv], options: OPTIONS, allowPositionals: true, strict: true });
|
|
229
|
+
json = values.json;
|
|
230
|
+
if (values.version) {
|
|
231
|
+
io.stdout(json ? `${JSON.stringify({ name: NAME, version: VERSION })}
|
|
232
|
+
` : `${VERSION}
|
|
233
|
+
`);
|
|
234
|
+
return 0;
|
|
235
|
+
}
|
|
236
|
+
if (values.help || positionals.length === 0) {
|
|
237
|
+
io.stdout(USAGE);
|
|
238
|
+
return values.help ? 0 : 2;
|
|
239
|
+
}
|
|
240
|
+
const { cliConfig } = await import("./chunks/config-OPZLVTYX.js");
|
|
241
|
+
env = makeEnv(io, cliConfig(io.env));
|
|
242
|
+
const { report, exitCode } = await dispatch(env, positionals, values);
|
|
243
|
+
io.stdout(`${json ? reportJson(report) : renderReport(report)}
|
|
244
|
+
`);
|
|
245
|
+
return exitCode ?? (report.ok ? 0 : 1);
|
|
246
|
+
} catch (err) {
|
|
247
|
+
const code2 = await errorCode(err);
|
|
248
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
249
|
+
io.stderr(json ? `${JSON.stringify({ error: code2, message })}
|
|
250
|
+
` : `opentab: ${code2}: ${message}
|
|
251
|
+
`);
|
|
252
|
+
if (code2 === "usage" && !json) io.stderr("run `opentab --help` for usage\n");
|
|
253
|
+
return code2 === "usage" ? 2 : 1;
|
|
254
|
+
} finally {
|
|
255
|
+
await env?.close();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// packages/cli/src/io.ts
|
|
260
|
+
import { promises as fsp } from "node:fs";
|
|
261
|
+
import { createInterface } from "node:readline/promises";
|
|
262
|
+
function processIo() {
|
|
263
|
+
return {
|
|
264
|
+
stdout: (t) => void process.stdout.write(t),
|
|
265
|
+
stderr: (t) => void process.stderr.write(t),
|
|
266
|
+
env: process.env,
|
|
267
|
+
readFile: async (p) => new Uint8Array(await fsp.readFile(p)),
|
|
268
|
+
writeFile: async (p, bytes) => fsp.writeFile(p, bytes, { flag: "wx", mode: 420 }),
|
|
269
|
+
fetch: (input, init) => fetch(input, init),
|
|
270
|
+
now: () => Date.now(),
|
|
271
|
+
prompt: async (question) => {
|
|
272
|
+
if (!process.stdin.isTTY) return "";
|
|
273
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
274
|
+
try {
|
|
275
|
+
return await rl.question(question);
|
|
276
|
+
} finally {
|
|
277
|
+
rl.close();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
async function exitAfterFlush(code2, streams, exit, timeoutMs = 1e4) {
|
|
283
|
+
let timer;
|
|
284
|
+
const limit = new Promise((resolve) => {
|
|
285
|
+
timer = setTimeout(resolve, timeoutMs);
|
|
286
|
+
timer.unref?.();
|
|
287
|
+
});
|
|
288
|
+
const flushed = streams.map(
|
|
289
|
+
(s) => new Promise((resolve) => {
|
|
290
|
+
try {
|
|
291
|
+
s.write("", () => resolve());
|
|
292
|
+
} catch {
|
|
293
|
+
resolve();
|
|
294
|
+
}
|
|
295
|
+
})
|
|
296
|
+
);
|
|
297
|
+
await Promise.race([Promise.all(flushed), limit]);
|
|
298
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
299
|
+
exit(code2);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// packages/cli/src/live.ts
|
|
303
|
+
function liveEnv(io, config) {
|
|
304
|
+
let grpc;
|
|
305
|
+
let hosted;
|
|
306
|
+
let cards;
|
|
307
|
+
const client = () => {
|
|
308
|
+
grpc ??= import("./chunks/liveNode-SLQN4XRB.js").then(
|
|
309
|
+
({ createTestnetGrpcClient }) => createTestnetGrpcClient({ host: config.grpcHost, port: config.grpcPort, timeoutMs: 3e4 })
|
|
310
|
+
);
|
|
311
|
+
return grpc;
|
|
312
|
+
};
|
|
313
|
+
const settler = {
|
|
314
|
+
settle: async (req) => {
|
|
315
|
+
const [{ settleLive }, node] = await Promise.all([import("./chunks/liveSettle-V5W7D2U5.js"), client()]);
|
|
316
|
+
return settleLive({ config, io, grpc: node }, req);
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
const indexerUrl = config.indexerUrl;
|
|
320
|
+
let indexer;
|
|
321
|
+
const indexerPort = indexerUrl === null ? null : {
|
|
322
|
+
events: async (kind, id) => {
|
|
323
|
+
indexer ??= import("./chunks/indexer-OLIWEEFT.js").then(({ HttpIndexer }) => new HttpIndexer(indexerUrl, io.fetch));
|
|
324
|
+
return (await indexer).events(kind, id);
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
const cardFetcher = {
|
|
328
|
+
fetch: async (url) => {
|
|
329
|
+
cards ??= import("./chunks/liveOnboard-Z4GRTSHR.js").then(({ SafeCardFetcher }) => new SafeCardFetcher());
|
|
330
|
+
return (await cards).fetch(url);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
return {
|
|
334
|
+
io,
|
|
335
|
+
config,
|
|
336
|
+
verifyChain: async (opts) => {
|
|
337
|
+
const [{ GrpcVerifyChain }, node] = await Promise.all([import("./chunks/liveNode-SLQN4XRB.js"), client()]);
|
|
338
|
+
return new GrpcVerifyChain(node, config.bureau, { retry: { now: () => io.now(), ...opts?.deadlineAt === void 0 ? {} : { deadlineAt: opts.deadlineAt } } });
|
|
339
|
+
},
|
|
340
|
+
indexer: () => indexerPort,
|
|
341
|
+
onboardChain: async () => {
|
|
342
|
+
const [{ GrpcOnboardChain, RegistryReader }, node] = await Promise.all([import("./chunks/liveOnboard-Z4GRTSHR.js"), client()]);
|
|
343
|
+
return new GrpcOnboardChain(node, new RegistryReader(node));
|
|
344
|
+
},
|
|
345
|
+
mcp: async () => {
|
|
346
|
+
hosted ??= import("./chunks/liveOnboard-Z4GRTSHR.js").then(({ HostedRegistry }) => new HostedRegistry());
|
|
347
|
+
const [{ HostedRegistryMcp }, registry] = await Promise.all([import("./chunks/liveOnboard-Z4GRTSHR.js"), hosted]);
|
|
348
|
+
return new HostedRegistryMcp(registry);
|
|
349
|
+
},
|
|
350
|
+
settler: () => settler,
|
|
351
|
+
cardFetcher: () => cardFetcher,
|
|
352
|
+
close: async () => {
|
|
353
|
+
const registry = await hosted?.catch(() => void 0);
|
|
354
|
+
await registry?.close();
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// packages/cli/src/bin.ts
|
|
360
|
+
var code = await runCli(process.argv.slice(2), processIo(), liveEnv);
|
|
361
|
+
await exitAfterFlush(code, [process.stdout, process.stderr], (c) => process.exit(c));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TESTNET_GENESIS,
|
|
3
|
+
TESTNET_GRPC_HOST,
|
|
4
|
+
TESTNET_GRPC_PORT,
|
|
5
|
+
WrongNetworkError
|
|
6
|
+
} from "./chunk-S5IAH7CT.js";
|
|
7
|
+
|
|
8
|
+
// packages/registry/src/grpc.ts
|
|
9
|
+
import { BlockHash } from "@concordium/web-sdk";
|
|
10
|
+
import { ConcordiumGRPCNodeClient, credentials } from "@concordium/web-sdk/nodejs";
|
|
11
|
+
function createTestnetGrpcClient(opts = {}) {
|
|
12
|
+
return new ConcordiumGRPCNodeClient(
|
|
13
|
+
opts.host ?? TESTNET_GRPC_HOST,
|
|
14
|
+
opts.port ?? TESTNET_GRPC_PORT,
|
|
15
|
+
credentials.createSsl(),
|
|
16
|
+
{ timeout: opts.timeoutMs ?? 15e3 }
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
async function assertTestnet(client) {
|
|
20
|
+
const status = await client.getConsensusStatus();
|
|
21
|
+
const genesis = BlockHash.toHexString(status.genesisBlock);
|
|
22
|
+
if (genesis !== TESTNET_GENESIS) throw new WrongNetworkError(TESTNET_GENESIS, genesis);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
createTestnetGrpcClient,
|
|
27
|
+
assertTestnet
|
|
28
|
+
};
|