@fangorn-network/sdk 2026.8.12-dev → 2026.8.18-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.
- package/README.md +175 -62
- package/lib/cli/cli.d.ts +0 -0
- package/lib/cli/cli.js +290 -17
- package/lib/config.d.ts +9 -8
- package/lib/config.js +6 -8
- package/lib/contracts/app-registry/abi.d.ts +466 -0
- package/lib/contracts/app-registry/abi.js +529 -0
- package/lib/contracts/app-registry/index.d.ts +139 -0
- package/lib/contracts/app-registry/index.js +271 -0
- package/lib/contracts/data-registry/abi.d.ts +124 -125
- package/lib/contracts/data-registry/abi.js +145 -142
- package/lib/contracts/data-registry/index.d.ts +16 -14
- package/lib/contracts/data-registry/index.js +19 -50
- package/lib/contracts/index.d.ts +8 -3
- package/lib/contracts/index.js +8 -3
- package/lib/contracts/settlement-registry/abi.d.ts +430 -11
- package/lib/contracts/settlement-registry/abi.js +528 -41
- package/lib/contracts/settlement-registry/index.d.ts +148 -10
- package/lib/contracts/settlement-registry/index.js +233 -9
- package/lib/contracts/subscription-registry/abi.d.ts +179 -0
- package/lib/contracts/subscription-registry/abi.js +195 -0
- package/lib/contracts/subscription-registry/index.d.ts +59 -0
- package/lib/contracts/subscription-registry/index.js +116 -0
- package/lib/contracts/types.d.ts +8 -0
- package/lib/contracts/types.js +10 -0
- package/lib/contracts/write.d.ts +27 -0
- package/lib/contracts/write.js +55 -0
- package/lib/crypto/encryption.js +4 -4
- package/lib/engine/index.d.ts +14 -12
- package/lib/engine/index.js +13 -7
- package/lib/fangorn.d.ts +35 -5
- package/lib/fangorn.js +49 -6
- package/lib/index.d.ts +8 -3
- package/lib/index.js +8 -3
- package/lib/test/testbed.js +9 -3
- package/lib/types/index.d.ts +6 -0
- package/package.json +72 -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
|
|
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,52 +200,312 @@ 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
|
|
203
|
+
console.log(`\nSaved to ${CONFIG_PATH}. Run \`fangorn app info\` to see whether it is claimed and whether you have joined it.`);
|
|
204
|
+
process.exit(0);
|
|
205
|
+
} catch (err) {
|
|
206
|
+
console.error("Failed:", err.message);
|
|
207
|
+
process.exit(1);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
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 () => {
|
|
220
|
+
try {
|
|
221
|
+
const self = getAccount().address;
|
|
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)}`);
|
|
191
246
|
process.exit(0);
|
|
192
247
|
} catch (err) {
|
|
193
248
|
console.error("Failed:", err.message);
|
|
194
249
|
process.exit(1);
|
|
195
250
|
}
|
|
196
251
|
});
|
|
197
|
-
|
|
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) => {
|
|
198
253
|
try {
|
|
199
254
|
const self = getAccount().address;
|
|
200
|
-
const registry = getFangorn().
|
|
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 !==
|
|
206
|
-
|
|
207
|
-
|
|
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
|
-
|
|
210
|
-
|
|
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: ${
|
|
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
|
-
|
|
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().
|
|
285
|
+
const registry = getFangorn().getAppRegistry();
|
|
226
286
|
const s = spinner();
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
|
|
232
|
-
|
|
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);
|
|
332
|
+
s.stop();
|
|
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
|
+
appCmd.command("suspend").description("Eject a publisher from your app (owner only)").argument("<publisher>", "Publisher address").action(async (publisher) => {
|
|
356
|
+
try {
|
|
357
|
+
const s = spinner();
|
|
358
|
+
s.start("Suspending publisher...");
|
|
359
|
+
const txHash = await getFangorn().getAppRegistry().suspendForApp(publisher);
|
|
360
|
+
s.stop();
|
|
361
|
+
console.log(`Suspended: ${publisher}`);
|
|
362
|
+
console.log(`Tx: ${txHash}`);
|
|
363
|
+
process.exit(0);
|
|
364
|
+
} catch (err) {
|
|
365
|
+
console.error("Failed:", err.message);
|
|
366
|
+
process.exit(1);
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
appCmd.command("reinstate").description("Reinstate a suspended publisher in your app (owner only)").argument("<publisher>", "Publisher address").action(async (publisher) => {
|
|
370
|
+
try {
|
|
371
|
+
const s = spinner();
|
|
372
|
+
s.start("Reinstating publisher...");
|
|
373
|
+
const txHash = await getFangorn().getAppRegistry().reinstateForApp(publisher);
|
|
374
|
+
s.stop();
|
|
375
|
+
console.log(`Reinstated: ${publisher}`);
|
|
376
|
+
console.log(`Tx: ${txHash}`);
|
|
377
|
+
process.exit(0);
|
|
378
|
+
} catch (err) {
|
|
379
|
+
console.error("Failed:", err.message);
|
|
380
|
+
process.exit(1);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
const appAdminCmd = appCmd.command("admin").description("Protocol-admin takedowns for the whole app (admin only)");
|
|
384
|
+
/** The AppRegistry client, refusing early if this wallet is not the protocol admin. */
|
|
385
|
+
async function requireAdmin() {
|
|
386
|
+
const registry = getFangorn().getAppRegistry();
|
|
387
|
+
const self = getAccount().address;
|
|
388
|
+
const admin = await registry.admin();
|
|
389
|
+
if (admin.toLowerCase() !== self.toLowerCase()) throw new Error(`Not the protocol admin: this registry's admin is ${admin}, you are ${self}.`);
|
|
390
|
+
return registry;
|
|
391
|
+
}
|
|
392
|
+
appAdminCmd.command("suspend").description("Suspend this entire app — nobody can publish under it (admin only)").action(async () => {
|
|
393
|
+
try {
|
|
394
|
+
const registry = await requireAdmin();
|
|
395
|
+
const ok = await confirm({ message: `Suspend the whole app ${registry.getAppId()}? Every publisher, including its owner, stops being registered.` });
|
|
396
|
+
handleCancel(ok);
|
|
397
|
+
if (!ok) process.exit(0);
|
|
398
|
+
const s = spinner();
|
|
399
|
+
s.start("Suspending app...");
|
|
400
|
+
const txHash = await registry.suspendApp();
|
|
233
401
|
s.stop();
|
|
234
|
-
console.log(`
|
|
402
|
+
console.log(`Suspended: ${registry.getAppId()}`);
|
|
235
403
|
console.log(`Tx: ${txHash}`);
|
|
404
|
+
console.log(`\nMemberships are kept — \`fangorn app admin reinstate\` restores them as they were.`);
|
|
405
|
+
process.exit(0);
|
|
406
|
+
} catch (err) {
|
|
407
|
+
console.error("Failed:", err.message);
|
|
408
|
+
process.exit(1);
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
appAdminCmd.command("reinstate").description("Lift the suspension on this entire app (admin only)").action(async () => {
|
|
412
|
+
try {
|
|
413
|
+
const registry = await requireAdmin();
|
|
414
|
+
const s = spinner();
|
|
415
|
+
s.start("Reinstating app...");
|
|
416
|
+
const txHash = await registry.reinstateApp();
|
|
417
|
+
s.stop();
|
|
418
|
+
console.log(`Reinstated: ${registry.getAppId()}`);
|
|
419
|
+
console.log(`Tx: ${txHash}`);
|
|
420
|
+
process.exit(0);
|
|
421
|
+
} catch (err) {
|
|
422
|
+
console.error("Failed:", err.message);
|
|
423
|
+
process.exit(1);
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
appAdminCmd.command("status").description("Who the protocol admin is, and whether this app is suspended").action(async () => {
|
|
427
|
+
try {
|
|
428
|
+
const registry = getFangorn().getAppRegistry();
|
|
429
|
+
const self = getAccount().address;
|
|
430
|
+
const s = spinner();
|
|
431
|
+
s.start("Reading registry...");
|
|
432
|
+
const [admin, suspended] = await Promise.all([registry.admin(), registry.isAppSuspended()]);
|
|
433
|
+
s.stop();
|
|
434
|
+
console.log(`App id: ${registry.getAppId()}`);
|
|
435
|
+
console.log(`Admin: ${admin}${admin.toLowerCase() === self.toLowerCase() ? " (you)" : ""}`);
|
|
436
|
+
console.log(`Suspended: ${suspended ? "yes — nobody can publish under this app" : "no"}`);
|
|
437
|
+
process.exit(0);
|
|
438
|
+
} catch (err) {
|
|
439
|
+
console.error("Failed:", err.message);
|
|
440
|
+
process.exit(1);
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
program.command("register-app", { hidden: true }).description("Deprecated alias for `fangorn app claim`").action(() => {
|
|
444
|
+
console.error("`register-app` is now `fangorn app claim`.");
|
|
445
|
+
process.exit(1);
|
|
446
|
+
});
|
|
447
|
+
program.command("register").description("Register as a publisher: global standing, then join this app").action(async () => {
|
|
448
|
+
try {
|
|
449
|
+
const self = getAccount().address;
|
|
450
|
+
const fangorn = getFangorn();
|
|
451
|
+
const data = fangorn.getDataRegistry();
|
|
452
|
+
const apps = fangorn.getAppRegistry();
|
|
453
|
+
const s = spinner();
|
|
454
|
+
s.start("Checking publisher registration...");
|
|
455
|
+
const already = await data.isRegistered(self);
|
|
456
|
+
s.stop();
|
|
457
|
+
if (already) console.log(`DataRegistry: already registered`);
|
|
458
|
+
else {
|
|
459
|
+
s.start("Registering publisher...");
|
|
460
|
+
const txHash = await data.register();
|
|
461
|
+
s.stop();
|
|
462
|
+
console.log(`DataRegistry: registered (tx ${txHash})`);
|
|
463
|
+
}
|
|
464
|
+
s.start("Checking app membership...");
|
|
465
|
+
if (await apps.getAppOwner() === ZERO_ADDRESS) {
|
|
466
|
+
s.stop();
|
|
467
|
+
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\`.`);
|
|
468
|
+
process.exit(0);
|
|
469
|
+
}
|
|
470
|
+
const info = await apps.joinInfo(self);
|
|
471
|
+
s.stop();
|
|
472
|
+
if (info.registered) {
|
|
473
|
+
console.log(`This app: already joined`);
|
|
474
|
+
process.exit(0);
|
|
475
|
+
}
|
|
476
|
+
if (info.status === PublisherStatus.SUSPENDED) {
|
|
477
|
+
console.error(`This app: suspended by the app owner — cannot join.`);
|
|
478
|
+
process.exit(1);
|
|
479
|
+
}
|
|
480
|
+
s.start(needsReacceptance(info) ? "Re-accepting terms..." : "Joining app...");
|
|
481
|
+
const joinTx = await apps.registerForApp();
|
|
482
|
+
s.stop();
|
|
483
|
+
console.log(`This app: joined ${apps.getAppId()} (tx ${joinTx}, fee ${info.fee.toString()} wei)`);
|
|
484
|
+
console.log(`\nPublisher: ${self}`);
|
|
485
|
+
process.exit(0);
|
|
486
|
+
} catch (err) {
|
|
487
|
+
console.error("Failed:", err.message);
|
|
488
|
+
process.exit(1);
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
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) => {
|
|
492
|
+
try {
|
|
493
|
+
const cfg = loadConfig();
|
|
494
|
+
const account = getAccount();
|
|
495
|
+
const s = spinner();
|
|
496
|
+
s.start("Reading balance...");
|
|
497
|
+
const balance = await createPublicClient({ transport: http(cfg.cfg.rpcUrl) }).getBalance({ address: account.address });
|
|
498
|
+
s.stop();
|
|
499
|
+
console.log(`Address: ${account.address}`);
|
|
500
|
+
console.log(`Public key: ${account.publicKey}`);
|
|
501
|
+
console.log(`Balance: ${formatEther(balance)} ETH`);
|
|
502
|
+
console.log(`Network: ${cfg.cfg.chain.name} (${cfg.cfg.caip2.toString()})`);
|
|
503
|
+
console.log(`App: ${currentAppName()}`);
|
|
504
|
+
console.log(`Config: ${existsSync(CONFIG_PATH) ? CONFIG_PATH : "(from environment)"}`);
|
|
505
|
+
if (opts.reveal) {
|
|
506
|
+
console.log(`\nPrivate key: ${cfg.privateKey}`);
|
|
507
|
+
console.log(`Anyone with that key controls this wallet. Do not share it.`);
|
|
508
|
+
} else console.log(`\nPrivate key: hidden — pass --reveal to print it`);
|
|
236
509
|
process.exit(0);
|
|
237
510
|
} catch (err) {
|
|
238
511
|
console.error("Failed:", err.message);
|
package/lib/config.d.ts
CHANGED
|
@@ -5,16 +5,11 @@ import * as abitype0 from "abitype";
|
|
|
5
5
|
|
|
6
6
|
//#region src/config.d.ts
|
|
7
7
|
/**
|
|
8
|
-
* Derive an app id from a human-readable name.
|
|
9
|
-
*
|
|
8
|
+
* Derive an app id from a human-readable name (keccak256(hex(name)).
|
|
9
|
+
* Apps are claim one of these on-chain with `AppRegistry.registerApp`
|
|
10
10
|
*/
|
|
11
11
|
declare function appId(name: string): Hex;
|
|
12
|
-
/** The app every client publishes under until told otherwise. */
|
|
13
12
|
declare const DEFAULT_APP = "fangorn";
|
|
14
|
-
/**
|
|
15
|
-
* Accept either form callers have on hand: a human-readable app name, or an
|
|
16
|
-
* already-derived app id (32-byte hex), which is what an app owner sees on-chain.
|
|
17
|
-
*/
|
|
18
13
|
declare function toAppId(nameOrId: string): Hex;
|
|
19
14
|
/**
|
|
20
15
|
* The networks supproted by Fangorn currently
|
|
@@ -443,13 +438,19 @@ declare function getNetwork(name: string): {
|
|
|
443
438
|
};
|
|
444
439
|
interface AppConfig {
|
|
445
440
|
dataRegistryContractAddress: Hex;
|
|
441
|
+
appRegistryContractAddress: Hex;
|
|
442
|
+
subscriptionRegistryContractAddress: Hex;
|
|
443
|
+
settlementRegistryContractAddress: Hex;
|
|
446
444
|
chain: Chain;
|
|
447
445
|
rpcUrl: string;
|
|
448
446
|
caip2: number;
|
|
449
447
|
ipfsGateway: string;
|
|
450
448
|
}
|
|
451
449
|
declare const FangornConfig: {
|
|
452
|
-
dataRegistryContractAddress: "
|
|
450
|
+
dataRegistryContractAddress: "0x97d63259bd91e386322c12fa7e923e5e1c0ddf91";
|
|
451
|
+
appRegistryContractAddress: "0xeb1309d4607ffbe2051d296de72d3ca4d2795731";
|
|
452
|
+
subscriptionRegistryContractAddress: "0x81681e4f89a24cb46112480f63404fdc35ee4cec";
|
|
453
|
+
settlementRegistryContractAddress: "0x480d54411d77820701fd80f42b81fb6e20176d12";
|
|
453
454
|
chain: {
|
|
454
455
|
blockExplorers: {
|
|
455
456
|
readonly default: {
|
package/lib/config.js
CHANGED
|
@@ -3,18 +3,13 @@ import { arbitrumSepolia, baseSepolia } from "viem/chains";
|
|
|
3
3
|
|
|
4
4
|
//#region src/config.ts
|
|
5
5
|
/**
|
|
6
|
-
* Derive an app id from a human-readable name.
|
|
7
|
-
*
|
|
6
|
+
* Derive an app id from a human-readable name (keccak256(hex(name)).
|
|
7
|
+
* Apps are claim one of these on-chain with `AppRegistry.registerApp`
|
|
8
8
|
*/
|
|
9
9
|
function appId(name) {
|
|
10
10
|
return keccak256(toHex(name));
|
|
11
11
|
}
|
|
12
|
-
/** The app every client publishes under until told otherwise. */
|
|
13
12
|
const DEFAULT_APP = "fangorn";
|
|
14
|
-
/**
|
|
15
|
-
* Accept either form callers have on hand: a human-readable app name, or an
|
|
16
|
-
* already-derived app id (32-byte hex), which is what an app owner sees on-chain.
|
|
17
|
-
*/
|
|
18
13
|
function toAppId(nameOrId) {
|
|
19
14
|
return /^0x[0-9a-fA-F]{64}$/.test(nameOrId) ? nameOrId : appId(nameOrId);
|
|
20
15
|
}
|
|
@@ -41,7 +36,10 @@ function getNetwork(name) {
|
|
|
41
36
|
throw new Error(`Chain ${name} is not supported`);
|
|
42
37
|
}
|
|
43
38
|
const FangornConfig = {
|
|
44
|
-
dataRegistryContractAddress: "
|
|
39
|
+
dataRegistryContractAddress: "0x97d63259bd91e386322c12fa7e923e5e1c0ddf91",
|
|
40
|
+
appRegistryContractAddress: "0xeb1309d4607ffbe2051d296de72d3ca4d2795731",
|
|
41
|
+
subscriptionRegistryContractAddress: "0x81681e4f89a24cb46112480f63404fdc35ee4cec",
|
|
42
|
+
settlementRegistryContractAddress: "0x480d54411d77820701fd80f42b81fb6e20176d12",
|
|
45
43
|
chain: arbitrumSepolia,
|
|
46
44
|
rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
47
45
|
caip2: 421614,
|