@fangorn-network/sdk 0.2.0 → 0.2.1

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 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).
65
+ Fangorn runs on **Base Sepolia** (the default) and **Arbitrum Sepolia**. Each has its own DataRegistry, SettlementRegistry, hosted upload worker and key server. **Base** mainnet has a DataRegistry only: repos read and publish there, but there are no paid records, and no hosted upload worker yet, so publishing needs your own Pinata JWT. Addresses are in [`src/config.ts`](src/config.ts) (`BaseSepoliaConfig`, `ArbitrumSepoliaConfig`, `BaseConfig`). The CLI asks for the network in `fangorn init`, and `CHAIN_NAME` (`baseSepolia`, `arbitrumSepolia` or `base`) 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
@@ -9,7 +9,7 @@ import { createRequire } from "node:module";
9
9
  import { createPublicClient, formatEther, http, isAddress, parseUnits } from "viem";
10
10
  import { privateKeyToAccount } from "viem/accounts";
11
11
  import { Command } from "commander";
12
- import { confirm, intro, outro, password, spinner, text } from "@clack/prompts";
12
+ import { confirm, intro, log, outro, password, spinner, text } from "@clack/prompts";
13
13
  import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
14
14
  import { dirname, join, resolve } from "path";
15
15
  import { homedir } from "os";
@@ -209,6 +209,8 @@ program.command("init").description("Configure your Fangorn credentials").action
209
209
  placeholder: "https://pinata-url-provider.your-subdomain.workers.dev"
210
210
  });
211
211
  handleCancel(signedUrlWorkerUrl);
212
+ const net = getNetwork(chainName);
213
+ if (!net.signedUrlWorker && !nonBlank(pinataJwt) && !nonBlank(signedUrlWorkerUrl)) log.warn(`No hosted upload worker exists for ${net.chain.name}. If publishing data, include your own Pinata JWT (rerun \`fangorn init\`, or set PINATA_JWT).`);
212
214
  writeStoredConfig({
213
215
  privateKey,
214
216
  chainName,
package/lib/cli/index.js CHANGED
@@ -12,7 +12,7 @@ const selectChain = async () => {
12
12
  message: "Pick your chain.",
13
13
  options: Object.entries(SupportedNetworks).map(([value, c]) => ({
14
14
  value,
15
- label: c.chain.name
15
+ label: c.chain.testnet ? c.chain.name : `${c.chain.name} (mainnet)`
16
16
  }))
17
17
  });
18
18
  handleCancel(choice);
package/lib/config.d.ts CHANGED
@@ -409,7 +409,7 @@ declare const ArbitrumSepoliaConfig: {
409
409
  keyServer: string;
410
410
  };
411
411
  declare const BaseConfig: {
412
- dataRegistryContractAddress: "0x3206C1FBb8fD62DEDBCBdc2eDa09cDff3039Db2B";
412
+ dataRegistryContractAddress: "0x543D559Cf7583FE7003d4A19E26BF3A4DB75fbC8";
413
413
  fromBlock: bigint;
414
414
  chain: {
415
415
  blockExplorers: {
@@ -1073,7 +1073,7 @@ declare const FangornConfig: {
1073
1073
  */
1074
1074
  declare const SupportedNetworks: Record<string, NetworkConfig>;
1075
1075
  /**
1076
- * Get a network's deployment by name ("baseSepolia" or "arbitrumSepolia").
1076
+ * Get a network's deployment by name ("baseSepolia", "arbitrumSepolia" or "base").
1077
1077
  * @returns The corresponding config if it is supported, otherwise an error
1078
1078
  */
1079
1079
  declare function getNetwork(name: string): NetworkConfig;
package/lib/config.js CHANGED
@@ -35,7 +35,7 @@ const ArbitrumSepoliaConfig = {
35
35
  keyServer: "https://arbitrum-sepolia.keys-test.fangorn.network"
36
36
  };
37
37
  const BaseConfig = {
38
- dataRegistryContractAddress: "0x3206C1FBb8fD62DEDBCBdc2eDa09cDff3039Db2B",
38
+ dataRegistryContractAddress: "0x543D559Cf7583FE7003d4A19E26BF3A4DB75fbC8",
39
39
  fromBlock: 59598762n,
40
40
  chain: base,
41
41
  rpcUrl: "https://base-rpc.publicnode.com",
@@ -53,10 +53,11 @@ const FangornConfig = BaseSepoliaConfig;
53
53
  */
54
54
  const SupportedNetworks = {
55
55
  baseSepolia: BaseSepoliaConfig,
56
- arbitrumSepolia: ArbitrumSepoliaConfig
56
+ arbitrumSepolia: ArbitrumSepoliaConfig,
57
+ base: BaseConfig
57
58
  };
58
59
  /**
59
- * Get a network's deployment by name ("baseSepolia" or "arbitrumSepolia").
60
+ * Get a network's deployment by name ("baseSepolia", "arbitrumSepolia" or "base").
60
61
  * @returns The corresponding config if it is supported, otherwise an error
61
62
  */
62
63
  function getNetwork(name) {
package/lib/fangorn.js CHANGED
@@ -29,11 +29,7 @@ function resolveStorage(storage, walletClient, config) {
29
29
  if (!storage) return void 0;
30
30
  if ("backend" in storage) return storage.backend;
31
31
  if ("pinata" in storage) return new PinataBackend(storage.pinata.jwt, nonBlank(storage.pinata.gateway) ?? config.ipfsGateway);
32
- if ("signedUrl" in storage) {
33
- const workerUrl = nonBlank(storage.signedUrl.workerUrl) ?? nonBlank(config.signedUrlWorker);
34
- if (!workerUrl) throw new Error(`no hosted upload worker on chain ${config.caip2.toString()}: pass storage.signedUrl.workerUrl, or bring your own storage ({ pinata } or { backend })`);
35
- return new SignedUrlBackend(workerUrl, walletSigner(walletClient), nonBlank(storage.signedUrl.gateway) ?? config.ipfsGateway);
36
- }
32
+ if ("signedUrl" in storage) return new SignedUrlBackend(nonBlank(storage.signedUrl.workerUrl) ?? nonBlank(config.signedUrlWorker) ?? null, walletSigner(walletClient), nonBlank(storage.signedUrl.gateway) ?? config.ipfsGateway);
37
33
  throw new Error(`Invalid storage config: must be { pinata: … }, { signedUrl: … } or { backend: … }, got ${JSON.stringify(storage)}`);
38
34
  }
39
35
  /**
@@ -35,7 +35,7 @@ declare class SignedUrlBackend implements MetadataStorage {
35
35
  private readonly signer;
36
36
  private readonly gateway;
37
37
  private readonly workerUrl;
38
- constructor(workerUrl: string | undefined, signer: SignedUrlSigner, gateway: string);
38
+ constructor(workerUrl: string | null | undefined, signer: SignedUrlSigner, gateway: string);
39
39
  /** Run the worker challenge handshake → one-time presigned upload URL + network. */
40
40
  private requestUploadUrl;
41
41
  private workerJson;
@@ -38,7 +38,7 @@ var SignedUrlBackend = class {
38
38
  constructor(workerUrl, signer, gateway) {
39
39
  this.signer = signer;
40
40
  this.gateway = gateway;
41
- this.workerUrl = workerUrl?.trim() ? workerUrl : DEFAULT_SIGNED_URL_WORKER;
41
+ this.workerUrl = workerUrl === null ? null : workerUrl?.trim() ? workerUrl : DEFAULT_SIGNED_URL_WORKER;
42
42
  }
43
43
  /** Run the worker challenge handshake → one-time presigned upload URL + network. */
44
44
  async requestUploadUrl(size, uploadId) {
@@ -64,6 +64,7 @@ var SignedUrlBackend = class {
64
64
  };
65
65
  }
66
66
  async workerJson(body) {
67
+ if (!this.workerUrl) throw new Error("no hosted upload worker on this chain: pass storage.signedUrl.workerUrl, or bring your own storage ({ pinata } or { backend })");
67
68
  const res = await fetch(this.workerUrl, {
68
69
  method: "POST",
69
70
  headers: { "content-type": "application/json" },
@@ -3,12 +3,12 @@ import { CommitUpdate, LogFilter, Registry, RepoRef, UpdateEntry } from "../cont
3
3
  import { Mmr } from "../contracts/data-registry/mmr.js";
4
4
  import "../contracts/index.js";
5
5
  import "../index.js";
6
- import * as viem237 from "viem";
6
+ import * as viem6075 from "viem";
7
7
  import { Address, Hash, Hex, LocalAccount } from "viem";
8
8
 
9
9
  //#region src/test/mem-registry.d.ts
10
10
  /** The EIP-712 domain a MemRegistry signs under. */
11
- declare const MEM_DOMAIN: viem237.TypedDataDomain;
11
+ declare const MEM_DOMAIN: viem6075.TypedDataDomain;
12
12
  /** One ordering and the registry state over it, shared by every signer of a MemRegistry. */
13
13
  declare class MemLedger {
14
14
  /** H: position and head */