@fangorn-network/sdk 0.1.1 → 0.1.3

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 CHANGED
@@ -62,7 +62,7 @@ The [Guide](docs/GUIDE.md) covers the full flow: commit vs push, epochs, history
62
62
 
63
63
  ## Network
64
64
 
65
- Fangorn runs on **Base Sepolia**. The DataRegistry, SettlementRegistry, and hosted upload worker are all deployed there. Addresses are in [`src/config.ts`](src/config.ts) (`BaseSepoliaConfig`). To use a local anvil or a private deployment, pass your own `NetworkConfig` to `Fangorn.create`, or set the `FANGORN_*` overrides for the CLI (see the [Guide](docs/GUIDE.md#configure)). Contract sources are in [fangorn-network/contracts](https://github.com/fangorn-network/contracts).
65
+ Fangorn runs on **Base Sepolia** (the default) and **Arbitrum Sepolia**. Each has its own DataRegistry, SettlementRegistry, hosted upload worker and key server. Addresses are in [`src/config.ts`](src/config.ts) (`BaseSepoliaConfig`, `ArbitrumSepoliaConfig`). The CLI asks for the network in `fangorn init`, and `CHAIN_NAME=arbitrumSepolia` overrides it. To use a local anvil or a private deployment, pass your own `NetworkConfig` to `Fangorn.create`, or set the `FANGORN_*` overrides for the CLI (see the [Guide](docs/GUIDE.md#configure)). Contract sources are in [fangorn-network/contracts](https://github.com/fangorn-network/contracts).
66
66
 
67
67
  ## Development
68
68
 
package/lib/cli/cli.js CHANGED
@@ -4,7 +4,7 @@ import { agentCardUrl, parseAgentId } from "../erc8004.js";
4
4
  import { Fangorn } from "../fangorn.js";
5
5
  import { sealRecords } from "./sell.js";
6
6
  import { fileToRecords, walk } from "./stage.js";
7
- import { handleCancel } from "./index.js";
7
+ import { handleCancel, selectChain } from "./index.js";
8
8
  import { createPublicClient, formatEther, http, isAddress, parseUnits } from "viem";
9
9
  import { privateKeyToAccount } from "viem/accounts";
10
10
  import { Command } from "commander";
@@ -37,9 +37,10 @@ function loadConfig() {
37
37
  const envChain = nonBlank(process.env.CHAIN_NAME);
38
38
  if (existsSync(CONFIG_PATH)) {
39
39
  const stored = readStoredConfig();
40
+ const storedChain = stored.chainName === "Arbitrum Sepolia" ? "arbitrumSepolia" : stored.chainName;
40
41
  _config = {
41
42
  privateKey: stored.privateKey,
42
- cfg: network(envChain ?? stored.chainName),
43
+ cfg: network(envChain ?? storedChain),
43
44
  pinataJwt: stored.pinataJwt,
44
45
  pinataGateway: stored.pinataGateway,
45
46
  signedUrlWorkerUrl: stored.signedUrlWorkerUrl ?? ""
@@ -163,7 +164,7 @@ const program = new Command();
163
164
  program.name("fangorn").description("Fangorn Network CLI").version("0.4.0");
164
165
  program.command("init").description("Configure your Fangorn credentials").action(async () => {
165
166
  intro("Fangorn Setup");
166
- const chainName = "baseSepolia";
167
+ const chainName = await selectChain();
167
168
  const privateKey = await text({
168
169
  message: "Wallet private key (stored locally, never transmitted):",
169
170
  placeholder: "0x...",
@@ -2,9 +2,11 @@ import "./cli.js";
2
2
 
3
3
  //#region src/cli/index.d.ts
4
4
  declare const handleCancel: (value: unknown) => void;
5
+ /** Asks which supported network to use, and returns its name ("baseSepolia", ...). */
6
+ declare const selectChain: () => Promise<string>;
5
7
  declare function parseGadgetArg(raw: string): {
6
8
  type: string;
7
9
  args: string[];
8
10
  };
9
11
  //#endregion
10
- export { handleCancel, parseGadgetArg };
12
+ export { handleCancel, parseGadgetArg, selectChain };
package/lib/cli/index.js CHANGED
@@ -1,10 +1,23 @@
1
+ import { SupportedNetworks } from "../config.js";
1
2
  import "./cli.js";
2
- import { isCancel } from "@clack/prompts";
3
+ import { isCancel, select } from "@clack/prompts";
3
4
 
4
5
  //#region src/cli/index.ts
5
6
  const handleCancel = (value) => {
6
7
  if (isCancel(value)) process.exit(0);
7
8
  };
9
+ /** Asks which supported network to use, and returns its name ("baseSepolia", ...). */
10
+ const selectChain = async () => {
11
+ const choice = await select({
12
+ message: "Pick your chain.",
13
+ options: Object.entries(SupportedNetworks).map(([value, c]) => ({
14
+ value,
15
+ label: c.chain.name
16
+ }))
17
+ });
18
+ handleCancel(choice);
19
+ return String(choice);
20
+ };
8
21
  function parseGadgetArg(raw) {
9
22
  const match = /^(\w+)\(([^)]*)\)$/.exec(raw);
10
23
  if (!match) throw new Error(`Invalid gadget format: "${raw}". Expected e.g. Payment(0.00001)`);
@@ -15,4 +28,4 @@ function parseGadgetArg(raw) {
15
28
  }
16
29
 
17
30
  //#endregion
18
- export { handleCancel, parseGadgetArg };
31
+ export { handleCancel, parseGadgetArg, selectChain };
package/lib/config.d.ts CHANGED
@@ -350,10 +350,63 @@ declare const BaseSepoliaConfig: {
350
350
  logWindow: bigint;
351
351
  signedUrlWorker: string;
352
352
  };
353
+ declare const ArbitrumSepoliaConfig: {
354
+ dataRegistryContractAddress: "0x44B5a9C43F5905699747e062A126a588816436C4";
355
+ settlementRegistryContractAddress: "0xC248Ef78e38bCa33708B3Fd9A21375E0AA10cf27";
356
+ fromBlock: bigint;
357
+ chain: {
358
+ blockExplorers: {
359
+ readonly default: {
360
+ readonly name: "Arbiscan";
361
+ readonly url: "https://sepolia.arbiscan.io";
362
+ readonly apiUrl: "https://api-sepolia.arbiscan.io/api";
363
+ };
364
+ };
365
+ blockTime: 250;
366
+ contracts: {
367
+ readonly multicall3: {
368
+ readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
369
+ readonly blockCreated: 81930;
370
+ };
371
+ };
372
+ ensTlds?: readonly string[] | undefined;
373
+ id: 421614;
374
+ name: "Arbitrum Sepolia";
375
+ nativeCurrency: {
376
+ readonly name: "Arbitrum Sepolia Ether";
377
+ readonly symbol: "ETH";
378
+ readonly decimals: 18;
379
+ };
380
+ experimental_preconfirmationTime?: number | undefined | undefined;
381
+ rpcUrls: {
382
+ readonly default: {
383
+ readonly http: readonly ["https://sepolia-rollup.arbitrum.io/rpc"];
384
+ };
385
+ };
386
+ sourceId?: number | undefined | undefined;
387
+ testnet: true;
388
+ custom?: Record<string, unknown> | undefined;
389
+ extendSchema?: Record<string, unknown> | undefined;
390
+ fees?: viem0.ChainFees<undefined> | undefined;
391
+ formatters?: undefined;
392
+ prepareTransactionRequest?: ((args: viem0.PrepareTransactionRequestParameters, options: {
393
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
394
+ }) => Promise<viem0.PrepareTransactionRequestParameters>) | [fn: ((args: viem0.PrepareTransactionRequestParameters, options: {
395
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
396
+ }) => Promise<viem0.PrepareTransactionRequestParameters>) | undefined, options: {
397
+ runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
398
+ }] | undefined;
399
+ serializers?: viem0.ChainSerializers<undefined, viem0.TransactionSerializable> | undefined;
400
+ verifyHash?: ((client: viem0.Client, parameters: viem0.VerifyHashActionParameters) => Promise<viem0.VerifyHashActionReturnType>) | undefined;
401
+ };
402
+ rpcUrl: string;
403
+ caip2: number;
404
+ ipfsGateway: string;
405
+ logWindow: bigint;
406
+ };
353
407
  /**
354
408
  * The default network: what `Fangorn.create` uses without a `config`, and the CLI
355
- * without `CHAIN_NAME`. Base Sepolia, which runs the contracts this SDK's ABIs are
356
- * built from.
409
+ * without `CHAIN_NAME`. Base Sepolia; Arbitrum Sepolia runs the same contracts.
357
410
  */
358
411
  declare const FangornConfig: {
359
412
  dataRegistryContractAddress: "0x0F3eb0E62CF610dbaC6B3aD4Bf4cE38Ab50EBCC5";
@@ -689,9 +742,9 @@ declare const FangornConfig: {
689
742
  */
690
743
  declare const SupportedNetworks: Record<string, NetworkConfig>;
691
744
  /**
692
- * Get a network's deployment by name ("baseSepolia").
745
+ * Get a network's deployment by name ("baseSepolia" or "arbitrumSepolia").
693
746
  * @returns The corresponding config if it is supported, otherwise an error
694
747
  */
695
748
  declare function getNetwork(name: string): NetworkConfig;
696
749
  //#endregion
697
- export { BaseSepoliaConfig, FangornConfig, NetworkConfig, SupportedNetworks, getNetwork as default, nonBlank };
750
+ export { ArbitrumSepoliaConfig, BaseSepoliaConfig, FangornConfig, NetworkConfig, SupportedNetworks, getNetwork as default, nonBlank };
package/lib/config.js CHANGED
@@ -1,4 +1,4 @@
1
- import { baseSepolia } from "viem/chains";
1
+ import { arbitrumSepolia, baseSepolia } from "viem/chains";
2
2
 
3
3
  //#region src/config.ts
4
4
  /**
@@ -21,18 +21,30 @@ const BaseSepoliaConfig = {
21
21
  logWindow: 50000n,
22
22
  signedUrlWorker: "https://base-sepolia.storage-worker.fangorn.network"
23
23
  };
24
+ const ArbitrumSepoliaConfig = {
25
+ dataRegistryContractAddress: "0x44B5a9C43F5905699747e062A126a588816436C4",
26
+ settlementRegistryContractAddress: "0xC248Ef78e38bCa33708B3Fd9A21375E0AA10cf27",
27
+ fromBlock: 328303800n,
28
+ chain: arbitrumSepolia,
29
+ rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
30
+ caip2: 421614,
31
+ ipfsGateway: "https://ipfs-test.fangorn.network",
32
+ logWindow: 100000n
33
+ };
24
34
  /**
25
35
  * The default network: what `Fangorn.create` uses without a `config`, and the CLI
26
- * without `CHAIN_NAME`. Base Sepolia, which runs the contracts this SDK's ABIs are
27
- * built from.
36
+ * without `CHAIN_NAME`. Base Sepolia; Arbitrum Sepolia runs the same contracts.
28
37
  */
29
38
  const FangornConfig = BaseSepoliaConfig;
30
39
  /**
31
40
  * The networks supported by Fangorn, by the name `CHAIN_NAME` takes.
32
41
  */
33
- const SupportedNetworks = { baseSepolia: BaseSepoliaConfig };
42
+ const SupportedNetworks = {
43
+ baseSepolia: BaseSepoliaConfig,
44
+ arbitrumSepolia: ArbitrumSepoliaConfig
45
+ };
34
46
  /**
35
- * Get a network's deployment by name ("baseSepolia").
47
+ * Get a network's deployment by name ("baseSepolia" or "arbitrumSepolia").
36
48
  * @returns The corresponding config if it is supported, otherwise an error
37
49
  */
38
50
  function getNetwork(name) {
@@ -42,4 +54,4 @@ function getNetwork(name) {
42
54
  }
43
55
 
44
56
  //#endregion
45
- export { BaseSepoliaConfig, FangornConfig, SupportedNetworks, getNetwork as default, nonBlank };
57
+ export { ArbitrumSepoliaConfig, BaseSepoliaConfig, FangornConfig, SupportedNetworks, getNetwork as default, nonBlank };
package/lib/erc8004.js CHANGED
@@ -2,7 +2,10 @@ import { parseAbi, parseEventLogs } from "viem";
2
2
 
3
3
  //#region src/erc8004.ts
4
4
  /** The ERC-8004 identity registry by chain id */
5
- const IDENTITY_REGISTRY = { 84532: "0x8004A818BFB912233c491871b3d84c89A494BD9e" };
5
+ const IDENTITY_REGISTRY = {
6
+ 84532: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
7
+ 421614: "0x8004A818BFB912233c491871b3d84c89A494BD9e"
8
+ };
6
9
  const ABI = parseAbi([
7
10
  "function register(string agentURI, (string metadataKey, bytes metadataValue)[] metadata) returns (uint256 agentId)",
8
11
  "function setAgentURI(uint256 agentId, string newURI)",
package/lib/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { DATA_REGISTRY_ABI } from "./contracts/data-registry/abi.js";
4
4
  import { RegisterArgs, SettleArgs, SettlementPayment, SettlementRegistryClient, TERMS_TYPES, Terms, TermsJson, WHOLE_REPO, recordKey, registerNonce, settlementDomain, subjectOf, termsFromJson, termsToJson } from "./contracts/settlement-registry/index.js";
5
5
  import { SETTLEMENT_REGISTRY_ABI } from "./contracts/settlement-registry/abi.js";
6
6
  import "./contracts/index.js";
7
- import { BaseSepoliaConfig, FangornConfig, NetworkConfig, SupportedNetworks, nonBlank } from "./config.js";
7
+ import { ArbitrumSepoliaConfig, BaseSepoliaConfig, FangornConfig, NetworkConfig, SupportedNetworks, nonBlank } from "./config.js";
8
8
  import { FangornContext, FangornCreateOptions, StorageConfig } from "./types/index.js";
9
9
  import { CommitFeed } from "./feed.js";
10
10
  import { AgentCard, CARD_RECORD, FANGORN_REPO_EXTENSION, Fangorn, RepoChange, SubscribeOptions } from "./fangorn.js";
@@ -14,4 +14,4 @@ import { AccessRequest, Deposit, FieldHandle, GADGET_FIELD_V1, PaidScope, access
14
14
  import { PinataBackend } from "./providers/storage/pinata.js";
15
15
  import { DEFAULT_SIGNED_URL_WORKER, SignedUrlBackend, SignedUrlSigner } from "./providers/storage/signed-url.js";
16
16
  import { MAX_UPLOAD_ATTEMPTS, deserialize, fetchRawByCid, isTransientUpload, retrieveByCid, serialize, withUploadRetry } from "./providers/storage/utils.js";
17
- export { AccessRequest, AccessSigner, AgentCard, BaseSepoliaConfig, CARD_RECORD, ChainRegistry, ChainRegistryConfig, CommitFeed, CommitUpdate, DATA_REGISTRY_ABI, DEFAULT_SIGNED_URL_WORKER, Deposit, EPOCH_SECONDS, FANGORN_REPO_EXTENSION, Fangorn, FangornConfig, FangornContext, FangornCreateOptions, FieldHandle, GADGET_FIELD_V1, GADGET_SELF_HKDF_V1, LogFilter, MAX_UPLOAD_ATTEMPTS, NetworkConfig, PaidScope, PinataBackend, PreparedTx, RegisterArgs, Registry, RepoChange, RepoRef, SETTLEMENT_REGISTRY_ABI, SellOptions, SettleArgs, SettlementPayment, SettlementRegistryClient, SignedUrlBackend, SignedUrlSigner, StorageConfig, SubscribeOptions, SupportedNetworks, TERMS_TYPES, Terms, TermsJson, UPDATE_TYPES, UpdateEntry, WHOLE_REPO, WINDOW, X25519_PUBKEY_LENGTH, ZERO_HEAD, accessMessage, buildAccessRequest, dataDomain, decryptField, deriveRecordKey, deserialize, encryptField, epochOf, fetchRawByCid, isTransientUpload, makeDeposit, newRepoKey, nonBlank, openField, recordKey, registerNonce, repoId, requestKey, retrieveByCid, seal, sealField, sealRecords, sealSelf, serialize, settlementDomain, statement, subjectOf, termsFromJson, termsToJson, unseal, unsealSelf, updateMessage, withUploadRetry };
17
+ export { AccessRequest, AccessSigner, AgentCard, ArbitrumSepoliaConfig, BaseSepoliaConfig, CARD_RECORD, ChainRegistry, ChainRegistryConfig, CommitFeed, CommitUpdate, DATA_REGISTRY_ABI, DEFAULT_SIGNED_URL_WORKER, Deposit, EPOCH_SECONDS, FANGORN_REPO_EXTENSION, Fangorn, FangornConfig, FangornContext, FangornCreateOptions, FieldHandle, GADGET_FIELD_V1, GADGET_SELF_HKDF_V1, LogFilter, MAX_UPLOAD_ATTEMPTS, NetworkConfig, PaidScope, PinataBackend, PreparedTx, RegisterArgs, Registry, RepoChange, RepoRef, SETTLEMENT_REGISTRY_ABI, SellOptions, SettleArgs, SettlementPayment, SettlementRegistryClient, SignedUrlBackend, SignedUrlSigner, StorageConfig, SubscribeOptions, SupportedNetworks, TERMS_TYPES, Terms, TermsJson, UPDATE_TYPES, UpdateEntry, WHOLE_REPO, WINDOW, X25519_PUBKEY_LENGTH, ZERO_HEAD, accessMessage, buildAccessRequest, dataDomain, decryptField, deriveRecordKey, deserialize, encryptField, epochOf, fetchRawByCid, isTransientUpload, makeDeposit, newRepoKey, nonBlank, openField, recordKey, registerNonce, repoId, requestKey, retrieveByCid, seal, sealField, sealRecords, sealSelf, serialize, settlementDomain, statement, subjectOf, termsFromJson, termsToJson, unseal, unsealSelf, updateMessage, withUploadRetry };
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseSepoliaConfig, FangornConfig, SupportedNetworks, nonBlank } from "./config.js";
1
+ import { ArbitrumSepoliaConfig, BaseSepoliaConfig, FangornConfig, SupportedNetworks, nonBlank } from "./config.js";
2
2
  import { DEFAULT_SIGNED_URL_WORKER, SignedUrlBackend } from "./providers/storage/signed-url.js";
3
3
  import { MAX_UPLOAD_ATTEMPTS, deserialize, fetchRawByCid, isTransientUpload, retrieveByCid, serialize, withUploadRetry } from "./providers/storage/utils.js";
4
4
  import { PinataBackend } from "./providers/storage/pinata.js";
@@ -13,4 +13,4 @@ import { GADGET_SELF_HKDF_V1, X25519_PUBKEY_LENGTH, seal, sealSelf, unseal, unse
13
13
  import { GADGET_FIELD_V1, accessMessage, buildAccessRequest, decryptField, deriveRecordKey, encryptField, makeDeposit, newRepoKey, openField, requestKey, sealField, statement } from "./crypto/paid.js";
14
14
  import { sealRecords } from "./cli/sell.js";
15
15
 
16
- export { BaseSepoliaConfig, CARD_RECORD, ChainRegistry, CommitFeed, DATA_REGISTRY_ABI, DEFAULT_SIGNED_URL_WORKER, EPOCH_SECONDS, FANGORN_REPO_EXTENSION, Fangorn, FangornConfig, GADGET_FIELD_V1, GADGET_SELF_HKDF_V1, MAX_UPLOAD_ATTEMPTS, PinataBackend, SETTLEMENT_REGISTRY_ABI, SettlementRegistryClient, SignedUrlBackend, SupportedNetworks, TERMS_TYPES, UPDATE_TYPES, WHOLE_REPO, WINDOW, X25519_PUBKEY_LENGTH, ZERO_HEAD, accessMessage, buildAccessRequest, dataDomain, decryptField, deriveRecordKey, deserialize, encryptField, epochOf, fetchRawByCid, isTransientUpload, makeDeposit, newRepoKey, nonBlank, openField, recordKey, registerNonce, repoId, requestKey, retrieveByCid, seal, sealField, sealRecords, sealSelf, serialize, settlementDomain, statement, subjectOf, termsFromJson, termsToJson, unseal, unsealSelf, updateMessage, withUploadRetry };
16
+ export { ArbitrumSepoliaConfig, BaseSepoliaConfig, CARD_RECORD, ChainRegistry, CommitFeed, DATA_REGISTRY_ABI, DEFAULT_SIGNED_URL_WORKER, EPOCH_SECONDS, FANGORN_REPO_EXTENSION, Fangorn, FangornConfig, GADGET_FIELD_V1, GADGET_SELF_HKDF_V1, MAX_UPLOAD_ATTEMPTS, PinataBackend, SETTLEMENT_REGISTRY_ABI, SettlementRegistryClient, SignedUrlBackend, SupportedNetworks, TERMS_TYPES, UPDATE_TYPES, WHOLE_REPO, WINDOW, X25519_PUBKEY_LENGTH, ZERO_HEAD, accessMessage, buildAccessRequest, dataDomain, decryptField, deriveRecordKey, deserialize, encryptField, epochOf, fetchRawByCid, isTransientUpload, makeDeposit, newRepoKey, nonBlank, openField, recordKey, registerNonce, repoId, requestKey, retrieveByCid, seal, sealField, sealRecords, sealSelf, serialize, settlementDomain, statement, subjectOf, termsFromJson, termsToJson, unseal, unsealSelf, updateMessage, withUploadRetry };
@@ -1,12 +1,12 @@
1
1
  import { PreparedTx } from "../contracts/write.js";
2
2
  import { CommitUpdate, LogFilter, Registry, RepoRef, UpdateEntry } from "../contracts/data-registry/index.js";
3
3
  import "../contracts/index.js";
4
- import * as viem5989 from "viem";
4
+ import * as viem161 from "viem";
5
5
  import { Address, Hash, Hex, LocalAccount } from "viem";
6
6
 
7
7
  //#region src/test/mem-registry.d.ts
8
8
  /** The EIP-712 domain a MemRegistry signs under. */
9
- declare const MEM_DOMAIN: viem5989.TypedDataDomain;
9
+ declare const MEM_DOMAIN: viem161.TypedDataDomain;
10
10
  /** One ordering and the registry state over it, shared by every signer of a MemRegistry. */
11
11
  declare class MemLedger {
12
12
  /** H: position and head */