@fangorn-network/sdk 2026.10.19-dev → 2026.10.20-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 +18 -2
- package/lib/cli/cli.js +13 -8
- package/lib/cli/index.d.ts +2 -90
- package/lib/cli/index.js +5 -2
- package/lib/config.d.ts +350 -111
- package/lib/config.js +31 -19
- package/lib/contracts/app-registry/index.d.ts +2 -1
- package/lib/contracts/app-registry/index.js +3 -2
- package/lib/contracts/logs.d.ts +6 -10
- package/lib/contracts/logs.js +5 -9
- package/lib/fangorn.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/registry.d.ts +2 -0
- package/lib/registry.js +3 -1
- package/lib/test/testbed.d.ts +5012 -5012
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ You can also configure via environment variables (these take precedence over the
|
|
|
56
56
|
ETH_PRIVATE_KEY=0x...
|
|
57
57
|
PINATA_JWT=...
|
|
58
58
|
PINATA_GATEWAY=https://your-gateway.mypinata.cloud
|
|
59
|
-
CHAIN_NAME=arbitrumSepolia
|
|
59
|
+
CHAIN_NAME=arbitrumSepolia # or baseSepolia
|
|
60
60
|
ACCESS_WORKER_URL=https://access-worker.your-subdomain.workers.dev # optional (sealed fields)
|
|
61
61
|
SIGNED_URL_WORKER_URL=https://pinata-url-provider.your-subdomain.workers.dev # optional
|
|
62
62
|
```
|
|
@@ -598,7 +598,23 @@ gadget_ behind the same handle shape, so committed data doesn't change form.
|
|
|
598
598
|
| AppRegistry | `0x55e6209ea1833ceD900989a3b3b22466934E04A5` | Apps: owner, accepted publishers, bans, storage subscription (ERC-5643, USDC); what each app excludes |
|
|
599
599
|
| MembershipRegistry | `0xDF17030Cd65435C86eb043F31DDACa99E819E347` | Time-limited, unlinkable access to an app's paid records (USDC + Semaphore) |
|
|
600
600
|
|
|
601
|
-
|
|
601
|
+
### Base Sepolia
|
|
602
|
+
|
|
603
|
+
| Contract | Address |
|
|
604
|
+
| -------------------- | -------------------------------------------- |
|
|
605
|
+
| DataRegistry | `0xE9183f768865dd2Cde5f1B71F8446F0Cd798ebe0` |
|
|
606
|
+
| AppRegistry | `0x0D3e98399df41b558048Cdd7D71723c37A3A9D6F` |
|
|
607
|
+
| MembershipRegistry | `0x0e96C012b5c53622EcDAA82F342E31C2623A04f5` |
|
|
608
|
+
|
|
609
|
+
Use it from the SDK with `Fangorn.create({ config: BaseSepoliaConfig, ... })`, or
|
|
610
|
+
from the CLI with `CHAIN_NAME=baseSepolia` (or pick it in `fangorn init`).
|
|
611
|
+
|
|
612
|
+
Its default RPC is `base-sepolia-rpc.publicnode.com`, not `sepolia.base.org`: the
|
|
613
|
+
official endpoint caps `eth_getLogs` at 200 blocks, too narrow to scan the registry's
|
|
614
|
+
history. Each config's `logWindow` is the most blocks one log query spans on its RPC
|
|
615
|
+
(Base 10,000, Arbitrum 100,000); `FANGORN_LOG_WINDOW` overrides it for a private RPC.
|
|
616
|
+
|
|
617
|
+
`FangornConfig` (Arbitrum Sepolia) and `BaseSepoliaConfig` in `src/config.ts` are the authoritative list and what the SDK
|
|
602
618
|
uses by default — prefer it over any address copied out of a document,
|
|
603
619
|
including this table. The sources are `fangorn-network/contracts`
|
|
604
620
|
(`solidity/script/Deployments.sol`); regenerate the ABIs with `pnpm abis`.
|
package/lib/cli/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import getNetwork, { nonBlank, toAppId } from "../config.js";
|
|
3
3
|
import { PublisherStatus } from "../contracts/types.js";
|
|
4
4
|
import "../contracts/index.js";
|
|
5
5
|
import { Fangorn } from "../fangorn.js";
|
|
6
|
-
import { handleCancel } from "./index.js";
|
|
6
|
+
import { handleCancel, selectChain } from "./index.js";
|
|
7
7
|
import { createPublicClient, formatEther, formatUnits, http } from "viem";
|
|
8
8
|
import { privateKeyToAccount } from "viem/accounts";
|
|
9
9
|
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
@@ -35,11 +35,13 @@ function loadConfig() {
|
|
|
35
35
|
const accessWorkerUrl = process.env.ACCESS_WORKER_URL;
|
|
36
36
|
const signedUrlWorkerUrl = process.env.SIGNED_URL_WORKER_URL;
|
|
37
37
|
const envAppId = nonBlank(process.env.FANGORN_APP_ID);
|
|
38
|
+
const envChain = nonBlank(process.env.CHAIN_NAME);
|
|
38
39
|
if (existsSync(CONFIG_PATH)) {
|
|
39
40
|
const stored = readStoredConfig();
|
|
41
|
+
const storedChain = stored.chainName === "Arbitrum Sepolia" ? "arbitrumSepolia" : stored.chainName;
|
|
40
42
|
_config = {
|
|
41
43
|
privateKey: stored.privateKey,
|
|
42
|
-
cfg:
|
|
44
|
+
cfg: getNetwork(envChain ?? storedChain),
|
|
43
45
|
appId: envAppId ?? nonBlank(stored.appId),
|
|
44
46
|
pinataJwt: stored.pinataJwt,
|
|
45
47
|
pinataGateway: stored.pinataGateway,
|
|
@@ -52,7 +54,7 @@ function loadConfig() {
|
|
|
52
54
|
if (!privateKey) throw new Error("Incomplete environment configuration. Missing: ETH_PRIVATE_KEY\nSet it or run `fangorn init` to use a config file.");
|
|
53
55
|
_config = {
|
|
54
56
|
privateKey,
|
|
55
|
-
cfg:
|
|
57
|
+
cfg: getNetwork(envChain ?? "arbitrumSepolia"),
|
|
56
58
|
appId: envAppId,
|
|
57
59
|
pinataJwt: pinataJwt ?? "",
|
|
58
60
|
pinataGateway: pinataGateway ?? "",
|
|
@@ -153,6 +155,7 @@ program.name("fangorn").description("Fangorn Network CLI").version("0.4.0");
|
|
|
153
155
|
program.option("--app <name-or-id>", "App (global namespace) for this command — overrides the stored app (see `set-app`)");
|
|
154
156
|
program.command("init").description("Configure your Fangorn credentials").action(async () => {
|
|
155
157
|
intro("Fangorn Setup");
|
|
158
|
+
const chainName = await selectChain();
|
|
156
159
|
const privateKey = await text({
|
|
157
160
|
message: "Wallet private key (stored locally, never transmitted):",
|
|
158
161
|
placeholder: "0x...",
|
|
@@ -181,7 +184,7 @@ program.command("init").description("Configure your Fangorn credentials").action
|
|
|
181
184
|
handleCancel(signedUrlWorkerUrl);
|
|
182
185
|
writeStoredConfig({
|
|
183
186
|
privateKey,
|
|
184
|
-
chainName
|
|
187
|
+
chainName,
|
|
185
188
|
pinataJwt,
|
|
186
189
|
pinataGateway,
|
|
187
190
|
accessWorkerUrl,
|
|
@@ -319,9 +322,11 @@ appCmd.command("agent").description("Register this app's gateway as an ERC-8004
|
|
|
319
322
|
const agent = new SDK({
|
|
320
323
|
chainId: cfg.cfg.caip2,
|
|
321
324
|
rpcUrl: cfg.cfg.rpcUrl,
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
+
...cfg.cfg.caip2 === 421614 && {
|
|
326
|
+
subgraphUrl: ERC8004_SUBGRAPH,
|
|
327
|
+
registryOverrides: { [cfg.cfg.caip2]: ERC8004_ARBITRUM_SEPOLIA },
|
|
328
|
+
subgraphOverrides: { [cfg.cfg.caip2]: ERC8004_SUBGRAPH }
|
|
329
|
+
},
|
|
325
330
|
ipfs: "pinata",
|
|
326
331
|
pinataJwt: cfg.pinataJwt,
|
|
327
332
|
privateKey: cfg.privateKey
|
package/lib/cli/index.d.ts
CHANGED
|
@@ -2,97 +2,9 @@ import "./cli.js";
|
|
|
2
2
|
import * as viem0 from "viem";
|
|
3
3
|
|
|
4
4
|
//#region src/cli/index.d.ts
|
|
5
|
-
declare const getChain: (chainStr: string) =>
|
|
6
|
-
blockExplorers: {
|
|
7
|
-
readonly default: {
|
|
8
|
-
readonly name: "Arbiscan";
|
|
9
|
-
readonly url: "https://sepolia.arbiscan.io";
|
|
10
|
-
readonly apiUrl: "https://api-sepolia.arbiscan.io/api";
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
blockTime: 250;
|
|
14
|
-
contracts: {
|
|
15
|
-
readonly multicall3: {
|
|
16
|
-
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
17
|
-
readonly blockCreated: 81930;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
ensTlds?: readonly string[] | undefined;
|
|
21
|
-
id: 421614;
|
|
22
|
-
name: "Arbitrum Sepolia";
|
|
23
|
-
nativeCurrency: {
|
|
24
|
-
readonly name: "Arbitrum Sepolia Ether";
|
|
25
|
-
readonly symbol: "ETH";
|
|
26
|
-
readonly decimals: 18;
|
|
27
|
-
};
|
|
28
|
-
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
29
|
-
rpcUrls: {
|
|
30
|
-
readonly default: {
|
|
31
|
-
readonly http: readonly ["https://sepolia-rollup.arbitrum.io/rpc"];
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
sourceId?: number | undefined | undefined;
|
|
35
|
-
testnet: true;
|
|
36
|
-
custom?: Record<string, unknown> | undefined;
|
|
37
|
-
extendSchema?: Record<string, unknown> | undefined;
|
|
38
|
-
fees?: viem0.ChainFees<undefined> | undefined;
|
|
39
|
-
formatters?: undefined;
|
|
40
|
-
prepareTransactionRequest?: ((args: viem0.PrepareTransactionRequestParameters, options: {
|
|
41
|
-
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
42
|
-
}) => Promise<viem0.PrepareTransactionRequestParameters>) | [fn: ((args: viem0.PrepareTransactionRequestParameters, options: {
|
|
43
|
-
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
44
|
-
}) => Promise<viem0.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
45
|
-
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
46
|
-
}] | undefined;
|
|
47
|
-
serializers?: viem0.ChainSerializers<undefined, viem0.TransactionSerializable> | undefined;
|
|
48
|
-
verifyHash?: ((client: viem0.Client, parameters: viem0.VerifyHashActionParameters) => Promise<viem0.VerifyHashActionReturnType>) | undefined;
|
|
49
|
-
};
|
|
5
|
+
declare const getChain: (chainStr: string) => viem0.Chain;
|
|
50
6
|
declare const handleCancel: (value: unknown) => void;
|
|
51
|
-
declare const selectChain: () => Promise<
|
|
52
|
-
blockExplorers: {
|
|
53
|
-
readonly default: {
|
|
54
|
-
readonly name: "Arbiscan";
|
|
55
|
-
readonly url: "https://sepolia.arbiscan.io";
|
|
56
|
-
readonly apiUrl: "https://api-sepolia.arbiscan.io/api";
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
blockTime: 250;
|
|
60
|
-
contracts: {
|
|
61
|
-
readonly multicall3: {
|
|
62
|
-
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
63
|
-
readonly blockCreated: 81930;
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
ensTlds?: readonly string[] | undefined;
|
|
67
|
-
id: 421614;
|
|
68
|
-
name: "Arbitrum Sepolia";
|
|
69
|
-
nativeCurrency: {
|
|
70
|
-
readonly name: "Arbitrum Sepolia Ether";
|
|
71
|
-
readonly symbol: "ETH";
|
|
72
|
-
readonly decimals: 18;
|
|
73
|
-
};
|
|
74
|
-
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
75
|
-
rpcUrls: {
|
|
76
|
-
readonly default: {
|
|
77
|
-
readonly http: readonly ["https://sepolia-rollup.arbitrum.io/rpc"];
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
sourceId?: number | undefined | undefined;
|
|
81
|
-
testnet: true;
|
|
82
|
-
custom?: Record<string, unknown> | undefined;
|
|
83
|
-
extendSchema?: Record<string, unknown> | undefined;
|
|
84
|
-
fees?: viem0.ChainFees<undefined> | undefined;
|
|
85
|
-
formatters?: undefined;
|
|
86
|
-
prepareTransactionRequest?: ((args: viem0.PrepareTransactionRequestParameters, options: {
|
|
87
|
-
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
88
|
-
}) => Promise<viem0.PrepareTransactionRequestParameters>) | [fn: ((args: viem0.PrepareTransactionRequestParameters, options: {
|
|
89
|
-
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
90
|
-
}) => Promise<viem0.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
91
|
-
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
92
|
-
}] | undefined;
|
|
93
|
-
serializers?: viem0.ChainSerializers<undefined, viem0.TransactionSerializable> | undefined;
|
|
94
|
-
verifyHash?: ((client: viem0.Client, parameters: viem0.VerifyHashActionParameters) => Promise<viem0.VerifyHashActionReturnType>) | undefined;
|
|
95
|
-
}>;
|
|
7
|
+
declare const selectChain: () => Promise<string>;
|
|
96
8
|
declare function parseGadgetArg(raw: string): {
|
|
97
9
|
type: string;
|
|
98
10
|
args: string[];
|
package/lib/cli/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { isCancel, select } from "@clack/prompts";
|
|
|
4
4
|
|
|
5
5
|
//#region src/cli/index.ts
|
|
6
6
|
const getChain = (chainStr) => {
|
|
7
|
-
return getNetwork(chainStr);
|
|
7
|
+
return getNetwork(chainStr).chain;
|
|
8
8
|
};
|
|
9
9
|
const handleCancel = (value) => {
|
|
10
10
|
if (isCancel(value)) process.exit(0);
|
|
@@ -15,10 +15,13 @@ const selectChain = async () => {
|
|
|
15
15
|
options: [{
|
|
16
16
|
value: "arbitrumSepolia",
|
|
17
17
|
label: "Arbitrum Sepolia"
|
|
18
|
+
}, {
|
|
19
|
+
value: "baseSepolia",
|
|
20
|
+
label: "Base Sepolia"
|
|
18
21
|
}]
|
|
19
22
|
});
|
|
20
23
|
handleCancel(chainChoice);
|
|
21
|
-
return
|
|
24
|
+
return chainChoice.toString();
|
|
22
25
|
};
|
|
23
26
|
function parseGadgetArg(raw) {
|
|
24
27
|
const match = /^(\w+)\(([^)]*)\)$/.exec(raw);
|