@fangorn-network/sdk 2026.8.12-dev → 2026.9.22-dev

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.
Files changed (40) hide show
  1. package/README.md +175 -62
  2. package/lib/cli/cli.d.ts +0 -0
  3. package/lib/cli/cli.js +348 -17
  4. package/lib/cli/index.d.ts +13 -13
  5. package/lib/config.d.ts +28 -352
  6. package/lib/config.js +11 -20
  7. package/lib/contracts/app-registry/abi.d.ts +509 -0
  8. package/lib/contracts/app-registry/abi.js +575 -0
  9. package/lib/contracts/app-registry/index.d.ts +120 -0
  10. package/lib/contracts/app-registry/index.js +266 -0
  11. package/lib/contracts/data-registry/abi.d.ts +124 -125
  12. package/lib/contracts/data-registry/abi.js +145 -142
  13. package/lib/contracts/data-registry/index.d.ts +20 -27
  14. package/lib/contracts/data-registry/index.js +32 -78
  15. package/lib/contracts/index.d.ts +8 -3
  16. package/lib/contracts/index.js +8 -3
  17. package/lib/contracts/logs.d.ts +18 -0
  18. package/lib/contracts/logs.js +25 -0
  19. package/lib/contracts/settlement-registry/abi.d.ts +430 -11
  20. package/lib/contracts/settlement-registry/abi.js +528 -41
  21. package/lib/contracts/settlement-registry/index.d.ts +148 -10
  22. package/lib/contracts/settlement-registry/index.js +233 -9
  23. package/lib/contracts/subscription-registry/abi.d.ts +179 -0
  24. package/lib/contracts/subscription-registry/abi.js +195 -0
  25. package/lib/contracts/subscription-registry/index.d.ts +59 -0
  26. package/lib/contracts/subscription-registry/index.js +116 -0
  27. package/lib/contracts/types.d.ts +8 -0
  28. package/lib/contracts/types.js +10 -0
  29. package/lib/contracts/write.d.ts +27 -0
  30. package/lib/contracts/write.js +55 -0
  31. package/lib/crypto/encryption.js +4 -4
  32. package/lib/engine/index.d.ts +14 -12
  33. package/lib/engine/index.js +13 -7
  34. package/lib/fangorn.d.ts +71 -6
  35. package/lib/fangorn.js +86 -7
  36. package/lib/index.d.ts +9 -4
  37. package/lib/index.js +9 -4
  38. package/lib/test/testbed.js +9 -3
  39. package/lib/types/index.d.ts +6 -0
  40. package/package.json +73 -85
package/lib/cli/cli.js CHANGED
@@ -1,7 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import { DEFAULT_APP, FangornConfig, toAppId } from "../config.js";
3
+ import { PublisherStatus } from "../contracts/types.js";
4
+ import { needsReacceptance } from "../contracts/app-registry/index.js";
5
+ import "../contracts/index.js";
3
6
  import { Fangorn } from "../fangorn.js";
4
7
  import { handleCancel } from "./index.js";
8
+ import { createPublicClient, formatEther, http } from "viem";
5
9
  import { privateKeyToAccount } from "viem/accounts";
6
10
  import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
7
11
  import { dirname, join } from "path";
@@ -58,7 +62,7 @@ function loadConfig() {
58
62
  };
59
63
  return _config;
60
64
  }
61
- throw new Error("No configuration found. Run `fangorn init` or set ETH_PRIVATE_KEY\n(with no config, uploads go to Fangorn's shared Pinata account — a best-effort testnet convenience; files may be unpinned without notice. Set PINATA_JWT + PINATA_GATEWAY to use your own storage).");
65
+ throw new Error("No configuration found. Run `fangorn init` or set ETH_PRIVATE_KEY\n(with no config, uploads go to Fangorn's shared Pinata account; files may be unpinned without notice. Set PINATA_JWT + PINATA_GATEWAY to use your own storage).");
62
66
  }
63
67
  function getAccount() {
64
68
  if (_account) return _account;
@@ -84,6 +88,12 @@ function getFangorn() {
84
88
  });
85
89
  return _fangorn;
86
90
  }
91
+ /**
92
+ * The currently configured app name
93
+ */
94
+ function currentAppName() {
95
+ return program.opts().app ?? loadConfig().appId;
96
+ }
87
97
  var LocalRepo = class LocalRepo {
88
98
  constructor(dir, state) {
89
99
  this.dir = dir;
@@ -130,6 +140,9 @@ var LocalRepo = class LocalRepo {
130
140
  }
131
141
  };
132
142
  const program = new Command();
143
+ const ZERO_HASH = `0x${"0".repeat(64)}`;
144
+ const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
145
+ const APP_TERMS_PLACEHOLDER = "0x0000000000000000000000000000000000000000000000000000000000000001";
133
146
  program.name("fangorn").description("Fangorn Network CLI").version("0.4.0");
134
147
  program.option("--app <name-or-id>", "App (global namespace) for this command — overrides the stored app (see `set-app`)");
135
148
  program.command("init").description("Configure your Fangorn credentials").action(async () => {
@@ -187,51 +200,223 @@ program.command("set-app").description("Set the app (global namespace) this CLI
187
200
  console.log(`App: ${app}`);
188
201
  console.log(`App id: ${toAppId(app)}`);
189
202
  if (process.env.FANGORN_APP_ID) console.log(`\nNote: FANGORN_APP_ID=${process.env.FANGORN_APP_ID} is set and overrides this.`);
190
- console.log(`\nSaved to ${CONFIG_PATH}. Run \`fangorn register-app\` if nobody has claimed it yet.`);
203
+ console.log(`\nSaved to ${CONFIG_PATH}. Run \`fangorn app info\` to see whether it is claimed and whether you have joined it.`);
191
204
  process.exit(0);
192
205
  } catch (err) {
193
206
  console.error("Failed:", err.message);
194
207
  process.exit(1);
195
208
  }
196
209
  });
197
- program.command("register-app").description("Claim the configured app (global namespace) on-chain").action(async () => {
210
+ /** The status word for a publisher in one app, and whether they can publish. */
211
+ function membershipLine(info) {
212
+ if (info.appSuspended) return "the whole app is suspended by the protocol admin — nobody can publish under it";
213
+ if (info.registered) return "joined";
214
+ if (needsReacceptance(info)) return "terms changed since you joined — run `fangorn app join` to re-accept (free)";
215
+ if (info.status === PublisherStatus.SUSPENDED) return "suspended from this app by its owner";
216
+ return "not joined — run `fangorn app join`";
217
+ }
218
+ const appCmd = program.command("app").description("Claim, join and manage apps (global namespaces)");
219
+ appCmd.command("info").description("Show this app's terms, fee, owner, and where you stand in it").action(async () => {
198
220
  try {
199
221
  const self = getAccount().address;
200
- const registry = getFangorn().getDataRegistry();
222
+ const fangorn = getFangorn();
223
+ const apps = fangorn.getAppRegistry();
224
+ const data = fangorn.getDataRegistry();
225
+ const s = spinner();
226
+ s.start("Reading registries...");
227
+ const [owner, info, registeredGlobally] = await Promise.all([
228
+ apps.getAppOwner(),
229
+ apps.joinInfo(self),
230
+ data.isRegistered(self)
231
+ ]);
232
+ s.stop();
233
+ console.log(`App: ${currentAppName()}`);
234
+ console.log(`App id: ${apps.getAppId()}`);
235
+ if (owner === ZERO_ADDRESS) console.log(`Owner: (unclaimed — \`fangorn app claim\` takes it)`);
236
+ else {
237
+ console.log(`Owner: ${owner}${owner.toLowerCase() === self.toLowerCase() ? " (you)" : ""}`);
238
+ console.log(`Terms: ${info.termsHash}`);
239
+ if (info.termsUri) console.log(`Terms uri: ${info.termsUri}`);
240
+ console.log(`Join fee: ${info.fee.toString()} wei`);
241
+ }
242
+ if (info.appSuspended) console.log(`Status: SUSPENDED by the protocol admin`);
243
+ console.log(`\nWallet: ${self}`);
244
+ console.log(`DataRegistry: ${registeredGlobally ? "registered" : "not registered — run `fangorn register`"}`);
245
+ console.log(`This app: ${owner === ZERO_ADDRESS ? "n/a (unclaimed)" : membershipLine(info)}`);
246
+ process.exit(0);
247
+ } catch (err) {
248
+ console.error("Failed:", err.message);
249
+ process.exit(1);
250
+ }
251
+ });
252
+ appCmd.command("claim").description("Claim the configured app on-chain (first come, first served)").option("--terms-hash <hash>", "32-byte hash of your terms document (default: a placeholder you should replace)").option("--terms-uri <uri>", "Where the terms document lives", "").option("--fee <wei>", "What joining this app costs, in wei", "0").action(async (opts) => {
253
+ try {
254
+ const self = getAccount().address;
255
+ const registry = getFangorn().getAppRegistry();
201
256
  const s = spinner();
202
257
  s.start("Checking app ownership...");
203
258
  const owner = await registry.getAppOwner();
204
259
  s.stop();
205
- if (owner !== "0x0000000000000000000000000000000000000000") {
206
- console.log(owner.toLowerCase() === self.toLowerCase() ? `Already registered to you: ${registry.getAppId()}` : `App ${registry.getAppId()} is already owned by ${owner}. Pick another name with \`fangorn set-app\`.`);
207
- process.exit(owner.toLowerCase() === self.toLowerCase() ? 0 : 1);
260
+ if (owner !== ZERO_ADDRESS) {
261
+ const mine = owner.toLowerCase() === self.toLowerCase();
262
+ console.log(mine ? `Already claimed by you: ${registry.getAppId()}` : `App ${registry.getAppId()} is already owned by ${owner}. Pick another name with \`fangorn set-app\`, or join this one with \`fangorn app join\`.`);
263
+ process.exit(mine ? 0 : 1);
208
264
  }
209
- s.start("Registering app...");
210
- const txHash = await registry.registerApp();
265
+ const termsHash = opts.termsHash ?? APP_TERMS_PLACEHOLDER;
266
+ s.start("Claiming app...");
267
+ const txHash = await registry.registerApp(termsHash, opts.termsUri, BigInt(opts.fee));
211
268
  s.stop();
212
- console.log(`App: ${loadConfig().appId}`);
269
+ console.log(`App: ${currentAppName()}`);
213
270
  console.log(`App id: ${registry.getAppId()}`);
214
271
  console.log(`Owner: ${self}`);
272
+ console.log(`Terms: ${termsHash}`);
215
273
  console.log(`Tx: ${txHash}`);
274
+ if (!opts.termsHash) console.log("\nThose are placeholder terms. Publish real ones with `fangorn app terms <hash> <uri>` —\nanyone who joined against the placeholder must then re-accept.");
275
+ console.log(`\nClaiming makes you your own first publisher; run \`fangorn register\` for global standing.`);
216
276
  process.exit(0);
217
277
  } catch (err) {
218
278
  console.error("Failed:", err.message);
219
279
  process.exit(1);
220
280
  }
221
281
  });
222
- program.command("register").description("Register your wallet as a data publisher on-chain").action(async () => {
282
+ appCmd.command("join").description("Join the configured app, accepting its current terms").action(async () => {
223
283
  try {
224
284
  const self = getAccount().address;
225
- const registry = getFangorn().getDataRegistry();
285
+ const registry = getFangorn().getAppRegistry();
226
286
  const s = spinner();
227
- if (await registry.isRegistered(self)) {
228
- console.log(`Already registered: ${self}`);
287
+ s.start("Reading terms...");
288
+ const info = await registry.joinInfo(self);
289
+ s.stop();
290
+ if (info.registered) {
291
+ console.log(`Already joined ${registry.getAppId()} as ${self}`);
229
292
  process.exit(0);
230
293
  }
231
- s.start("Registering publisher...");
232
- const txHash = await registry.register();
294
+ if (info.termsHash === ZERO_HASH) {
295
+ console.error(`App ${registry.getAppId()} has published no terms — it cannot be joined.\nIf it is unclaimed, \`fangorn app claim\` takes it; otherwise its owner must set terms.`);
296
+ process.exit(1);
297
+ }
298
+ if (info.status === PublisherStatus.SUSPENDED) {
299
+ console.error(`Suspended from this app by its owner — joining again will revert. Ask them to reinstate you.`);
300
+ process.exit(1);
301
+ }
302
+ if (info.appSuspended) {
303
+ console.error(`App ${registry.getAppId()} has been suspended by the protocol admin — joining will revert.`);
304
+ process.exit(1);
305
+ }
306
+ console.log(`Terms: ${info.termsHash}`);
307
+ if (info.termsUri) console.log(`Terms uri: ${info.termsUri}`);
308
+ console.log(`Join fee: ${info.fee.toString()} wei`);
309
+ const ok = await confirm({ message: needsReacceptance(info) ? "The terms changed since you joined. Accept the new ones?" : "Accept these terms and join?" });
310
+ handleCancel(ok);
311
+ if (!ok) process.exit(0);
312
+ s.start("Joining app...");
313
+ const txHash = await registry.registerForApp();
314
+ s.stop();
315
+ console.log(`Joined: ${registry.getAppId()}`);
316
+ console.log(`Tx: ${txHash}`);
317
+ process.exit(0);
318
+ } catch (err) {
319
+ console.error("Failed:", err.message);
320
+ process.exit(1);
321
+ }
322
+ });
323
+ appCmd.command("terms").description("Publish new terms for your app (owner only)").argument("<hash>", "32-byte hash of the terms document").argument("[uri]", "Where the document lives", "").action(async (hash, uri) => {
324
+ try {
325
+ const registry = getFangorn().getAppRegistry();
326
+ const ok = await confirm({ message: "New terms unregister every publisher until they re-accept (free). Continue?" });
327
+ handleCancel(ok);
328
+ if (!ok) process.exit(0);
329
+ const s = spinner();
330
+ s.start("Publishing terms...");
331
+ const txHash = await registry.setAppTerms(hash, uri);
233
332
  s.stop();
234
- console.log(`Publisher: ${self}`);
333
+ console.log(`Terms: ${hash}`);
334
+ console.log(`Tx: ${txHash}`);
335
+ process.exit(0);
336
+ } catch (err) {
337
+ console.error("Failed:", err.message);
338
+ process.exit(1);
339
+ }
340
+ });
341
+ appCmd.command("fee").description("Set what joining your app costs, in wei (owner only)").argument("<wei>", "Join fee in wei").action(async (wei) => {
342
+ try {
343
+ const s = spinner();
344
+ s.start("Setting join fee...");
345
+ const txHash = await getFangorn().getAppRegistry().setAppFee(BigInt(wei));
346
+ s.stop();
347
+ console.log(`Join fee: ${wei} wei`);
348
+ console.log(`Tx: ${txHash}`);
349
+ process.exit(0);
350
+ } catch (err) {
351
+ console.error("Failed:", err.message);
352
+ process.exit(1);
353
+ }
354
+ });
355
+ const ERC8004_ARBITRUM_SEPOLIA = {
356
+ IDENTITY: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
357
+ REPUTATION: "0x8004B663056A597Dffe9eCcC1965A193B7388713"
358
+ };
359
+ const ERC8004_SUBGRAPH = "https://api.studio.thegraph.com/query/1742225/erc-8004-arbitrum-sepolia/version/latest";
360
+ appCmd.command("agent").description("Register this app's gateway as an ERC-8004 agent and point the app at its card (owner only)").argument("[cardUrl]", "The agent card URL; defaults to the configured access worker's /.well-known/agent-card.json").option("--mcp <url>", "An MCP endpoint to index alongside the card").option("--skip-register", "Only set agent_uri on-chain — for a gateway already registered with ERC-8004").action(async (cardUrl, opts) => {
361
+ try {
362
+ const cfg = loadConfig();
363
+ const url = cardUrl ?? (cfg.accessWorkerUrl ? `${cfg.accessWorkerUrl.replace(/\/$/, "")}/.well-known/agent-card.json` : void 0);
364
+ if (!url) throw new Error("No card URL. Pass one, or set an access worker URL with `fangorn init`.");
365
+ const s = spinner();
366
+ s.start(`Reading ${url}`);
367
+ const res = await fetch(url);
368
+ if (!res.ok) {
369
+ s.stop();
370
+ throw new Error(`card at ${url} returned ${String(res.status)}`);
371
+ }
372
+ const card = await res.json();
373
+ s.stop(`Card: ${card.name ?? "(unnamed)"}`);
374
+ if (!card.name || !card.description) throw new Error("card is missing `name` or `description`");
375
+ let agentId;
376
+ if (!opts.skipRegister) {
377
+ if (!cfg.pinataJwt) throw new Error("ERC-8004 registration pins the registration file to IPFS — set PINATA_JWT, or pass --skip-register.");
378
+ const { SDK } = await import("agent0-sdk");
379
+ const agent = new SDK({
380
+ chainId: cfg.cfg.caip2,
381
+ rpcUrl: cfg.cfg.rpcUrl,
382
+ subgraphUrl: ERC8004_SUBGRAPH,
383
+ registryOverrides: { [cfg.cfg.caip2]: ERC8004_ARBITRUM_SEPOLIA },
384
+ subgraphOverrides: { [cfg.cfg.caip2]: ERC8004_SUBGRAPH },
385
+ ipfs: "pinata",
386
+ pinataJwt: cfg.pinataJwt,
387
+ privateKey: cfg.privateKey
388
+ }).createAgent(card.name, card.description);
389
+ s.start("Indexing skills and capabilities from the card");
390
+ await agent.setA2A(url);
391
+ if (opts.mcp) await agent.setMCP(opts.mcp);
392
+ s.stop();
393
+ agent.setTrust(true, false, false);
394
+ agent.setX402Support(card.skills?.some((sk) => sk.tags?.includes("x402")) ?? false);
395
+ agent.setActive(true);
396
+ s.start("Registering with the ERC-8004 identity registry");
397
+ const { result } = await (await agent.registerIPFS()).waitConfirmed();
398
+ s.stop();
399
+ agentId = String(result.agentId);
400
+ }
401
+ s.start("Pointing the app at its card");
402
+ const txHash = await getFangorn().getAppRegistry().setAppAgentUri(url);
403
+ s.stop();
404
+ if (agentId) console.log(`Agent ID: ${agentId}`);
405
+ console.log(`Card: ${url}`);
406
+ console.log(`Tx: ${txHash}`);
407
+ process.exit(0);
408
+ } catch (err) {
409
+ console.error("Failed:", err.message);
410
+ process.exit(1);
411
+ }
412
+ });
413
+ appCmd.command("suspend").description("Eject a publisher from your app (owner only)").argument("<publisher>", "Publisher address").action(async (publisher) => {
414
+ try {
415
+ const s = spinner();
416
+ s.start("Suspending publisher...");
417
+ const txHash = await getFangorn().getAppRegistry().suspendForApp(publisher);
418
+ s.stop();
419
+ console.log(`Suspended: ${publisher}`);
235
420
  console.log(`Tx: ${txHash}`);
236
421
  process.exit(0);
237
422
  } catch (err) {
@@ -239,6 +424,152 @@ program.command("register").description("Register your wallet as a data publishe
239
424
  process.exit(1);
240
425
  }
241
426
  });
427
+ appCmd.command("reinstate").description("Reinstate a suspended publisher in your app (owner only)").argument("<publisher>", "Publisher address").action(async (publisher) => {
428
+ try {
429
+ const s = spinner();
430
+ s.start("Reinstating publisher...");
431
+ const txHash = await getFangorn().getAppRegistry().reinstateForApp(publisher);
432
+ s.stop();
433
+ console.log(`Reinstated: ${publisher}`);
434
+ console.log(`Tx: ${txHash}`);
435
+ process.exit(0);
436
+ } catch (err) {
437
+ console.error("Failed:", err.message);
438
+ process.exit(1);
439
+ }
440
+ });
441
+ const appAdminCmd = appCmd.command("admin").description("Protocol-admin takedowns for the whole app (admin only)");
442
+ /** The AppRegistry client, refusing early if this wallet is not the protocol admin. */
443
+ async function requireAdmin() {
444
+ const registry = getFangorn().getAppRegistry();
445
+ const self = getAccount().address;
446
+ const admin = await registry.admin();
447
+ if (admin.toLowerCase() !== self.toLowerCase()) throw new Error(`Not the protocol admin: this registry's admin is ${admin}, you are ${self}.`);
448
+ return registry;
449
+ }
450
+ appAdminCmd.command("suspend").description("Suspend this entire app — nobody can publish under it (admin only)").action(async () => {
451
+ try {
452
+ const registry = await requireAdmin();
453
+ const ok = await confirm({ message: `Suspend the whole app ${registry.getAppId()}? Every publisher, including its owner, stops being registered.` });
454
+ handleCancel(ok);
455
+ if (!ok) process.exit(0);
456
+ const s = spinner();
457
+ s.start("Suspending app...");
458
+ const txHash = await registry.suspendApp();
459
+ s.stop();
460
+ console.log(`Suspended: ${registry.getAppId()}`);
461
+ console.log(`Tx: ${txHash}`);
462
+ console.log(`\nMemberships are kept — \`fangorn app admin reinstate\` restores them as they were.`);
463
+ process.exit(0);
464
+ } catch (err) {
465
+ console.error("Failed:", err.message);
466
+ process.exit(1);
467
+ }
468
+ });
469
+ appAdminCmd.command("reinstate").description("Lift the suspension on this entire app (admin only)").action(async () => {
470
+ try {
471
+ const registry = await requireAdmin();
472
+ const s = spinner();
473
+ s.start("Reinstating app...");
474
+ const txHash = await registry.reinstateApp();
475
+ s.stop();
476
+ console.log(`Reinstated: ${registry.getAppId()}`);
477
+ console.log(`Tx: ${txHash}`);
478
+ process.exit(0);
479
+ } catch (err) {
480
+ console.error("Failed:", err.message);
481
+ process.exit(1);
482
+ }
483
+ });
484
+ appAdminCmd.command("status").description("Who the protocol admin is, and whether this app is suspended").action(async () => {
485
+ try {
486
+ const registry = getFangorn().getAppRegistry();
487
+ const self = getAccount().address;
488
+ const s = spinner();
489
+ s.start("Reading registry...");
490
+ const [admin, suspended] = await Promise.all([registry.admin(), registry.isAppSuspended()]);
491
+ s.stop();
492
+ console.log(`App id: ${registry.getAppId()}`);
493
+ console.log(`Admin: ${admin}${admin.toLowerCase() === self.toLowerCase() ? " (you)" : ""}`);
494
+ console.log(`Suspended: ${suspended ? "yes — nobody can publish under this app" : "no"}`);
495
+ process.exit(0);
496
+ } catch (err) {
497
+ console.error("Failed:", err.message);
498
+ process.exit(1);
499
+ }
500
+ });
501
+ program.command("register-app", { hidden: true }).description("Deprecated alias for `fangorn app claim`").action(() => {
502
+ console.error("`register-app` is now `fangorn app claim`.");
503
+ process.exit(1);
504
+ });
505
+ program.command("register").description("Register as a publisher: global standing, then join this app").action(async () => {
506
+ try {
507
+ const self = getAccount().address;
508
+ const fangorn = getFangorn();
509
+ const data = fangorn.getDataRegistry();
510
+ const apps = fangorn.getAppRegistry();
511
+ const s = spinner();
512
+ s.start("Checking publisher registration...");
513
+ const already = await data.isRegistered(self);
514
+ s.stop();
515
+ if (already) console.log(`DataRegistry: already registered`);
516
+ else {
517
+ s.start("Registering publisher...");
518
+ const txHash = await data.register();
519
+ s.stop();
520
+ console.log(`DataRegistry: registered (tx ${txHash})`);
521
+ }
522
+ s.start("Checking app membership...");
523
+ if (await apps.getAppOwner() === ZERO_ADDRESS) {
524
+ s.stop();
525
+ console.log(`This app: ${apps.getAppId()} is unclaimed — nothing to join yet.\n Claim it with \`fangorn app claim\`, or point elsewhere with \`fangorn set-app\`.`);
526
+ process.exit(0);
527
+ }
528
+ const info = await apps.joinInfo(self);
529
+ s.stop();
530
+ if (info.registered) {
531
+ console.log(`This app: already joined`);
532
+ process.exit(0);
533
+ }
534
+ if (info.status === PublisherStatus.SUSPENDED) {
535
+ console.error(`This app: suspended by the app owner — cannot join.`);
536
+ process.exit(1);
537
+ }
538
+ s.start(needsReacceptance(info) ? "Re-accepting terms..." : "Joining app...");
539
+ const joinTx = await apps.registerForApp();
540
+ s.stop();
541
+ console.log(`This app: joined ${apps.getAppId()} (tx ${joinTx}, fee ${info.fee.toString()} wei)`);
542
+ console.log(`\nPublisher: ${self}`);
543
+ process.exit(0);
544
+ } catch (err) {
545
+ console.error("Failed:", err.message);
546
+ process.exit(1);
547
+ }
548
+ });
549
+ program.command("wallet").description("Show the wallet this CLI signs with").argument("[action]", "show", "show").option("--reveal", "Also print the PRIVATE key — it grants full control of this wallet").action(async (_action, opts) => {
550
+ try {
551
+ const cfg = loadConfig();
552
+ const account = getAccount();
553
+ const s = spinner();
554
+ s.start("Reading balance...");
555
+ const balance = await createPublicClient({ transport: http(cfg.cfg.rpcUrl) }).getBalance({ address: account.address });
556
+ s.stop();
557
+ console.log(`Address: ${account.address}`);
558
+ console.log(`Public key: ${account.publicKey}`);
559
+ console.log(`Balance: ${formatEther(balance)} ETH`);
560
+ console.log(`Network: ${cfg.cfg.chain.name} (${cfg.cfg.caip2.toString()})`);
561
+ console.log(`App: ${currentAppName()}`);
562
+ console.log(`Config: ${existsSync(CONFIG_PATH) ? CONFIG_PATH : "(from environment)"}`);
563
+ if (opts.reveal) {
564
+ console.log(`\nPrivate key: ${cfg.privateKey}`);
565
+ console.log(`Anyone with that key controls this wallet. Do not share it.`);
566
+ } else console.log(`\nPrivate key: hidden — pass --reveal to print it`);
567
+ process.exit(0);
568
+ } catch (err) {
569
+ console.error("Failed:", err.message);
570
+ process.exit(1);
571
+ }
572
+ });
242
573
  program.command("repo").description("Repository operations").command("init").description("Start tracking a namespace here (allocates it on-chain if new)").argument("<namespace>", "Namespace name").action(async (namespace) => {
243
574
  try {
244
575
  const fangorn = getFangorn();
@@ -1,5 +1,5 @@
1
1
  import "./cli.js";
2
- import * as viem89 from "viem";
2
+ import * as viem0 from "viem";
3
3
 
4
4
  //#region src/cli/index.d.ts
5
5
  declare const getChain: (chainStr: string) => {
@@ -35,17 +35,17 @@ declare const getChain: (chainStr: string) => {
35
35
  testnet: true;
36
36
  custom?: Record<string, unknown> | undefined;
37
37
  extendSchema?: Record<string, unknown> | undefined;
38
- fees?: viem89.ChainFees<undefined> | undefined;
38
+ fees?: viem0.ChainFees<undefined> | undefined;
39
39
  formatters?: undefined;
40
- prepareTransactionRequest?: ((args: viem89.PrepareTransactionRequestParameters, options: {
40
+ prepareTransactionRequest?: ((args: viem0.PrepareTransactionRequestParameters, options: {
41
41
  phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
42
- }) => Promise<viem89.PrepareTransactionRequestParameters>) | [fn: ((args: viem89.PrepareTransactionRequestParameters, options: {
42
+ }) => Promise<viem0.PrepareTransactionRequestParameters>) | [fn: ((args: viem0.PrepareTransactionRequestParameters, options: {
43
43
  phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
44
- }) => Promise<viem89.PrepareTransactionRequestParameters>) | undefined, options: {
44
+ }) => Promise<viem0.PrepareTransactionRequestParameters>) | undefined, options: {
45
45
  runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
46
46
  }] | undefined;
47
- serializers?: viem89.ChainSerializers<undefined, viem89.TransactionSerializable> | undefined;
48
- verifyHash?: ((client: viem89.Client, parameters: viem89.VerifyHashActionParameters) => Promise<viem89.VerifyHashActionReturnType>) | undefined;
47
+ serializers?: viem0.ChainSerializers<undefined, viem0.TransactionSerializable> | undefined;
48
+ verifyHash?: ((client: viem0.Client, parameters: viem0.VerifyHashActionParameters) => Promise<viem0.VerifyHashActionReturnType>) | undefined;
49
49
  };
50
50
  declare const handleCancel: (value: unknown) => void;
51
51
  declare const selectChain: () => Promise<{
@@ -81,17 +81,17 @@ declare const selectChain: () => Promise<{
81
81
  testnet: true;
82
82
  custom?: Record<string, unknown> | undefined;
83
83
  extendSchema?: Record<string, unknown> | undefined;
84
- fees?: viem89.ChainFees<undefined> | undefined;
84
+ fees?: viem0.ChainFees<undefined> | undefined;
85
85
  formatters?: undefined;
86
- prepareTransactionRequest?: ((args: viem89.PrepareTransactionRequestParameters, options: {
86
+ prepareTransactionRequest?: ((args: viem0.PrepareTransactionRequestParameters, options: {
87
87
  phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
88
- }) => Promise<viem89.PrepareTransactionRequestParameters>) | [fn: ((args: viem89.PrepareTransactionRequestParameters, options: {
88
+ }) => Promise<viem0.PrepareTransactionRequestParameters>) | [fn: ((args: viem0.PrepareTransactionRequestParameters, options: {
89
89
  phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
90
- }) => Promise<viem89.PrepareTransactionRequestParameters>) | undefined, options: {
90
+ }) => Promise<viem0.PrepareTransactionRequestParameters>) | undefined, options: {
91
91
  runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
92
92
  }] | undefined;
93
- serializers?: viem89.ChainSerializers<undefined, viem89.TransactionSerializable> | undefined;
94
- verifyHash?: ((client: viem89.Client, parameters: viem89.VerifyHashActionParameters) => Promise<viem89.VerifyHashActionReturnType>) | undefined;
93
+ serializers?: viem0.ChainSerializers<undefined, viem0.TransactionSerializable> | undefined;
94
+ verifyHash?: ((client: viem0.Client, parameters: viem0.VerifyHashActionParameters) => Promise<viem0.VerifyHashActionReturnType>) | undefined;
95
95
  }>;
96
96
  declare function parseGadgetArg(raw: string): {
97
97
  type: string;