@fangorn-network/sdk 0.1.0 → 0.1.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/lib/cli/cli.js +128 -328
- package/lib/cli/index.d.ts +1 -4
- package/lib/cli/index.js +2 -20
- package/lib/cli/sell.d.ts +28 -0
- package/lib/cli/sell.js +95 -0
- package/lib/cli/stage.d.ts +19 -0
- package/lib/cli/stage.js +94 -0
- package/lib/config.d.ts +16 -79
- package/lib/config.js +11 -39
- package/lib/contracts/data-registry/abi.d.ts +195 -19
- package/lib/contracts/data-registry/abi.js +409 -206
- package/lib/contracts/data-registry/index.d.ts +126 -2
- package/lib/contracts/data-registry/index.js +174 -1
- package/lib/contracts/index.d.ts +4 -7
- package/lib/contracts/index.js +4 -7
- package/lib/contracts/logs.d.ts +1 -1
- package/lib/contracts/logs.js +1 -1
- package/lib/contracts/{membership-registry → settlement-registry}/abi.d.ts +301 -636
- package/lib/contracts/settlement-registry/abi.js +962 -0
- package/lib/contracts/settlement-registry/index.d.ts +143 -0
- package/lib/contracts/settlement-registry/index.js +213 -0
- package/lib/crypto/aes.d.ts +2 -2
- package/lib/crypto/aes.js +4 -4
- package/lib/crypto/encryption.d.ts +8 -109
- package/lib/crypto/encryption.js +16 -114
- package/lib/crypto/paid.d.ts +104 -0
- package/lib/crypto/paid.js +147 -0
- package/lib/engine/car.d.ts +5 -1
- package/lib/engine/car.js +2 -2
- package/lib/engine/index.d.ts +33 -14
- package/lib/engine/index.js +98 -41
- package/lib/engine/records.d.ts +19 -8
- package/lib/engine/records.js +81 -7
- package/lib/engine/test-helpers.d.ts +2 -3
- package/lib/engine/test-helpers.js +7 -5
- package/lib/erc8004.js +7 -10
- package/lib/fangorn.d.ts +65 -86
- package/lib/fangorn.js +115 -153
- package/lib/feed.d.ts +7 -8
- package/lib/feed.js +7 -8
- package/lib/index.d.ts +10 -13
- package/lib/index.js +10 -13
- package/lib/providers/storage/signed-url.d.ts +2 -10
- package/lib/providers/storage/signed-url.js +5 -15
- package/lib/providers/storage/types.d.ts +1 -1
- package/lib/providers/storage/utils.js +5 -3
- package/lib/test/key-server.d.ts +12 -0
- package/lib/test/key-server.js +30 -0
- package/lib/test/mem-registry.d.ts +14 -19
- package/lib/test/mem-registry.js +44 -37
- package/lib/test/sdk-suite.d.ts +1 -4
- package/lib/test/sdk-suite.js +16 -87
- package/lib/test/testbed.d.ts +5130 -5140
- package/lib/test/testbed.js +29 -56
- package/lib/types/index.d.ts +6 -11
- package/package.json +1 -1
- package/lib/contracts/app-registry/abi.d.ts +0 -1265
- package/lib/contracts/app-registry/abi.js +0 -1454
- package/lib/contracts/app-registry/index.d.ts +0 -161
- package/lib/contracts/app-registry/index.js +0 -274
- package/lib/contracts/membership-registry/abi.js +0 -1333
- package/lib/contracts/membership-registry/index.d.ts +0 -79
- package/lib/contracts/membership-registry/index.js +0 -104
- package/lib/contracts/types.d.ts +0 -10
- package/lib/contracts/types.js +0 -12
- package/lib/harness/examples/hackmd/build-markdown-graph.d.ts +0 -1
- package/lib/harness/examples/hackmd/build-markdown-graph.js +0 -17
- package/lib/harness/index.d.ts +0 -58
- package/lib/harness/index.js +0 -73
- package/lib/registry.d.ts +0 -118
- package/lib/registry.js +0 -184
package/lib/cli/index.js
CHANGED
|
@@ -1,28 +1,10 @@
|
|
|
1
|
-
import getNetwork from "../config.js";
|
|
2
1
|
import "./cli.js";
|
|
3
|
-
import { isCancel
|
|
2
|
+
import { isCancel } from "@clack/prompts";
|
|
4
3
|
|
|
5
4
|
//#region src/cli/index.ts
|
|
6
|
-
const getChain = (chainStr) => {
|
|
7
|
-
return getNetwork(chainStr).chain;
|
|
8
|
-
};
|
|
9
5
|
const handleCancel = (value) => {
|
|
10
6
|
if (isCancel(value)) process.exit(0);
|
|
11
7
|
};
|
|
12
|
-
const selectChain = async () => {
|
|
13
|
-
const chainChoice = await select({
|
|
14
|
-
message: "Pick your chain.",
|
|
15
|
-
options: [{
|
|
16
|
-
value: "baseSepolia",
|
|
17
|
-
label: "Base Sepolia"
|
|
18
|
-
}, {
|
|
19
|
-
value: "arbitrumSepolia",
|
|
20
|
-
label: "Arbitrum Sepolia"
|
|
21
|
-
}]
|
|
22
|
-
});
|
|
23
|
-
handleCancel(chainChoice);
|
|
24
|
-
return chainChoice.toString();
|
|
25
|
-
};
|
|
26
8
|
function parseGadgetArg(raw) {
|
|
27
9
|
const match = /^(\w+)\(([^)]*)\)$/.exec(raw);
|
|
28
10
|
if (!match) throw new Error(`Invalid gadget format: "${raw}". Expected e.g. Payment(0.00001)`);
|
|
@@ -33,4 +15,4 @@ function parseGadgetArg(raw) {
|
|
|
33
15
|
}
|
|
34
16
|
|
|
35
17
|
//#endregion
|
|
36
|
-
export {
|
|
18
|
+
export { handleCancel, parseGadgetArg };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RecordInput } from "../engine/index.js";
|
|
2
|
+
import { Fangorn } from "../fangorn.js";
|
|
3
|
+
|
|
4
|
+
//#region src/cli/sell.d.ts
|
|
5
|
+
interface SellOptions {
|
|
6
|
+
/** Payload fields to seal. A record with none of them is left as it is. */
|
|
7
|
+
fields: string[];
|
|
8
|
+
/** USDC base units (6 decimals). */
|
|
9
|
+
price: bigint;
|
|
10
|
+
/** The referrer's share, 0..10000. Through Barliman the referrer is Fangorn's treasury. */
|
|
11
|
+
shareBps: number;
|
|
12
|
+
/** Unix seconds after which the terms can't be bought. */
|
|
13
|
+
deadline: bigint;
|
|
14
|
+
/** Key server for a new deposit; the deposit names it for good. An existing deposit keeps its own. */
|
|
15
|
+
keyServer?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Make records sellable: seal `fields` of each record (as JSON, under `field-v1`), and add the
|
|
19
|
+
* publisher's signed terms under "@terms". Returns the records to commit, plus the repo's
|
|
20
|
+
* `@deposit/<generation>` record if the repo had none for this generation.
|
|
21
|
+
*
|
|
22
|
+
* The deposit is read from the repo's on-chain head. Commit and push this before sealing more:
|
|
23
|
+
* a second call before the push makes a second deposit, and the first commit's fields would
|
|
24
|
+
* only open under the deposit it replaced.
|
|
25
|
+
*/
|
|
26
|
+
declare function sealRecords(fangorn: Fangorn, repo: string, records: RecordInput[], o: SellOptions): Promise<RecordInput[]>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { SellOptions, sealRecords };
|
package/lib/cli/sell.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { repoId } from "../contracts/data-registry/index.js";
|
|
2
|
+
import { WHOLE_REPO, recordKey, termsToJson } from "../contracts/settlement-registry/index.js";
|
|
3
|
+
import { makeDeposit, newRepoKey, requestKey, sealField } from "../crypto/paid.js";
|
|
4
|
+
import { hexToBytes } from "viem";
|
|
5
|
+
|
|
6
|
+
//#region src/cli/sell.ts
|
|
7
|
+
/**
|
|
8
|
+
* Make records sellable: seal `fields` of each record (as JSON, under `field-v1`), and add the
|
|
9
|
+
* publisher's signed terms under "@terms". Returns the records to commit, plus the repo's
|
|
10
|
+
* `@deposit/<generation>` record if the repo had none for this generation.
|
|
11
|
+
*
|
|
12
|
+
* The deposit is read from the repo's on-chain head. Commit and push this before sealing more:
|
|
13
|
+
* a second call before the push makes a second deposit, and the first commit's fields would
|
|
14
|
+
* only open under the deposit it replaced.
|
|
15
|
+
*/
|
|
16
|
+
async function sealRecords(fangorn, repo, records, o) {
|
|
17
|
+
const settlement = fangorn.getSettlementRegistry();
|
|
18
|
+
const publisher = fangorn.getAddress();
|
|
19
|
+
const rid = repoId(repo);
|
|
20
|
+
const generation = await settlement.generationOf(publisher, rid);
|
|
21
|
+
const scope = {
|
|
22
|
+
chainId: fangorn.getConfig().chain.id,
|
|
23
|
+
registry: settlement.getAddress(),
|
|
24
|
+
publisher,
|
|
25
|
+
repo: rid,
|
|
26
|
+
generation
|
|
27
|
+
};
|
|
28
|
+
const depositId = `@deposit/${generation.toString()}`;
|
|
29
|
+
const wallet = fangorn.getWalletClient();
|
|
30
|
+
const signer = { signMessage: (m) => wallet.signMessage({
|
|
31
|
+
account: wallet.account ?? publisher,
|
|
32
|
+
...m
|
|
33
|
+
}) };
|
|
34
|
+
const out = [];
|
|
35
|
+
let kRepo;
|
|
36
|
+
const existing = (await fangorn.engine.readRecord(publisher, repo, depositId).catch(() => null))?.payload;
|
|
37
|
+
if (existing) kRepo = await requestKey({
|
|
38
|
+
deposit: existing,
|
|
39
|
+
key: WHOLE_REPO,
|
|
40
|
+
signer
|
|
41
|
+
});
|
|
42
|
+
else {
|
|
43
|
+
if (!o.keyServer) throw new Error("no key server: pass keyServer (CLI: --key-server)");
|
|
44
|
+
const res = await fetch(`${o.keyServer}/pubkey`);
|
|
45
|
+
if (!res.ok) throw new Error(`key server ${o.keyServer}/pubkey: HTTP ${res.status.toString()}`);
|
|
46
|
+
const { pubkey } = await res.json();
|
|
47
|
+
kRepo = newRepoKey();
|
|
48
|
+
const deposit = makeDeposit({
|
|
49
|
+
kRepo,
|
|
50
|
+
keyServerPubkey: hexToBytes(pubkey),
|
|
51
|
+
keyServer: o.keyServer,
|
|
52
|
+
scope
|
|
53
|
+
});
|
|
54
|
+
out.push({
|
|
55
|
+
id: depositId,
|
|
56
|
+
type: "deposit",
|
|
57
|
+
payload: deposit
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const enc = new TextEncoder();
|
|
61
|
+
for (const r of records) {
|
|
62
|
+
const payload = { ...r.payload };
|
|
63
|
+
const paid = o.fields.filter((f) => f in payload);
|
|
64
|
+
if (!paid.length) {
|
|
65
|
+
out.push(r);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (!r.id) throw new Error(`a record with paid fields needs an id (type ${r.type})`);
|
|
69
|
+
const key = recordKey(r.id);
|
|
70
|
+
for (const field of paid) payload[field] = await sealField({
|
|
71
|
+
plaintext: enc.encode(JSON.stringify(payload[field])),
|
|
72
|
+
kRepo,
|
|
73
|
+
scope,
|
|
74
|
+
key,
|
|
75
|
+
field,
|
|
76
|
+
storage: fangorn.getStorage()
|
|
77
|
+
});
|
|
78
|
+
payload["@terms"] = termsToJson(await settlement.signTerms({
|
|
79
|
+
repo: rid,
|
|
80
|
+
key,
|
|
81
|
+
price: o.price,
|
|
82
|
+
shareBps: o.shareBps,
|
|
83
|
+
deadline: o.deadline,
|
|
84
|
+
generation
|
|
85
|
+
}));
|
|
86
|
+
out.push({
|
|
87
|
+
...r,
|
|
88
|
+
payload
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
export { sealRecords };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RecordInput } from "../engine/index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/cli/stage.d.ts
|
|
4
|
+
interface Staged {
|
|
5
|
+
records: RecordInput[];
|
|
6
|
+
deletes: string[];
|
|
7
|
+
}
|
|
8
|
+
interface StageOpts {
|
|
9
|
+
type?: string;
|
|
10
|
+
idColumn?: string;
|
|
11
|
+
}
|
|
12
|
+
/** RFC 4180 CSV → one object per row, keyed by the header. */
|
|
13
|
+
declare function parseCsv(text: string): Record<string, string>[];
|
|
14
|
+
/** Files under `path` (file or dir) as root-relative posix paths; dot entries skipped. */
|
|
15
|
+
declare function walk(root: string, path: string): string[];
|
|
16
|
+
/** One file → records. null for binary files (no text to stage). */
|
|
17
|
+
declare function fileToRecords(root: string, rel: string, opts: StageOpts): Staged | null;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { StageOpts, Staged, fileToRecords, parseCsv, walk };
|
package/lib/cli/stage.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { readFileSync, readdirSync, statSync } from "fs";
|
|
2
|
+
import { basename, extname, join, relative, sep } from "path";
|
|
3
|
+
|
|
4
|
+
//#region src/cli/stage.ts
|
|
5
|
+
/** RFC 4180 CSV → one object per row, keyed by the header. */
|
|
6
|
+
function parseCsv(text) {
|
|
7
|
+
const rows = [];
|
|
8
|
+
let row = [];
|
|
9
|
+
let field = "";
|
|
10
|
+
let quoted = false;
|
|
11
|
+
for (let i = 0; i < text.length; i++) {
|
|
12
|
+
const c = text[i];
|
|
13
|
+
if (quoted) if (c === "\"" && text[i + 1] === "\"") field += text[++i];
|
|
14
|
+
else if (c === "\"") quoted = false;
|
|
15
|
+
else field += c;
|
|
16
|
+
else if (c === "\"") quoted = true;
|
|
17
|
+
else if (c === ",") {
|
|
18
|
+
row.push(field);
|
|
19
|
+
field = "";
|
|
20
|
+
} else if (c === "\n" || c === "\r") {
|
|
21
|
+
if (c === "\r" && text[i + 1] === "\n") i++;
|
|
22
|
+
row.push(field);
|
|
23
|
+
rows.push(row);
|
|
24
|
+
row = [];
|
|
25
|
+
field = "";
|
|
26
|
+
} else field += c;
|
|
27
|
+
}
|
|
28
|
+
if (field || row.length) rows.push([...row, field]);
|
|
29
|
+
const [header = [], ...body] = rows;
|
|
30
|
+
return body.map((r) => Object.fromEntries(header.map((h, i) => [h, r[i] ?? ""])));
|
|
31
|
+
}
|
|
32
|
+
const safeId = (s) => s.replace(/[^\x21-\x7e]/g, "_");
|
|
33
|
+
/** Files under `path` (file or dir) as root-relative posix paths; dot entries skipped. */
|
|
34
|
+
function walk(root, path) {
|
|
35
|
+
const rel = (p) => relative(root, p).split(sep).join("/");
|
|
36
|
+
if (!statSync(path).isDirectory()) return [rel(path)];
|
|
37
|
+
return readdirSync(path, {
|
|
38
|
+
recursive: true,
|
|
39
|
+
withFileTypes: true
|
|
40
|
+
}).filter((e) => e.isFile()).map((e) => rel(join(e.parentPath, e.name))).filter((p) => !p.split("/").some((s) => s.startsWith(".")));
|
|
41
|
+
}
|
|
42
|
+
/** One file → records. null for binary files (no text to stage). */
|
|
43
|
+
function fileToRecords(root, rel, opts) {
|
|
44
|
+
const bytes = readFileSync(join(root, rel));
|
|
45
|
+
if (bytes.subarray(0, 8192).includes(0)) return null;
|
|
46
|
+
const text = bytes.toString("utf-8");
|
|
47
|
+
const ext = extname(rel).toLowerCase();
|
|
48
|
+
const type = opts.type ?? basename(rel, extname(rel));
|
|
49
|
+
const idCol = opts.idColumn ?? "id";
|
|
50
|
+
const many = (rows) => ({
|
|
51
|
+
records: rows.map((payload, i) => {
|
|
52
|
+
const id = payload[idCol];
|
|
53
|
+
return {
|
|
54
|
+
id: safeId((typeof id === "string" || typeof id === "number") && id !== "" ? String(id) : `${rel}#${(i + 1).toString()}`),
|
|
55
|
+
type,
|
|
56
|
+
payload
|
|
57
|
+
};
|
|
58
|
+
}),
|
|
59
|
+
deletes: []
|
|
60
|
+
});
|
|
61
|
+
if (ext === ".csv") return many(parseCsv(text));
|
|
62
|
+
if (ext === ".jsonl" || ext === ".ndjson") return many(text.split("\n").filter((l) => l.trim()).map((l) => JSON.parse(l)));
|
|
63
|
+
if (ext === ".json") {
|
|
64
|
+
const data = JSON.parse(text);
|
|
65
|
+
if (Array.isArray(data)) return many(data);
|
|
66
|
+
const obj = data;
|
|
67
|
+
if (Array.isArray(obj.records) || Array.isArray(obj.deletes)) return {
|
|
68
|
+
records: obj.records ?? [],
|
|
69
|
+
deletes: obj.deletes ?? []
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
records: [{
|
|
73
|
+
id: safeId(rel),
|
|
74
|
+
type,
|
|
75
|
+
payload: data
|
|
76
|
+
}],
|
|
77
|
+
deletes: []
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
records: [{
|
|
82
|
+
id: safeId(rel),
|
|
83
|
+
type: opts.type ?? "file",
|
|
84
|
+
payload: {
|
|
85
|
+
path: rel,
|
|
86
|
+
text
|
|
87
|
+
}
|
|
88
|
+
}],
|
|
89
|
+
deletes: []
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { fileToRecords, parseCsv, walk };
|
package/lib/config.d.ts
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
|
+
import * as viem_chains0 from "viem/chains";
|
|
1
2
|
import * as viem0 from "viem";
|
|
2
3
|
import { Chain, Hex } from "viem";
|
|
3
|
-
import * as viem_chains0 from "viem/chains";
|
|
4
4
|
|
|
5
5
|
//#region src/config.d.ts
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
declare function appId(name: string): Hex;
|
|
10
|
-
/**
|
|
11
|
-
* Blank input means "not set", never an app called "". Returns the trimmed value,
|
|
8
|
+
* Blank input means "not set", never a value of "". Returns the trimmed value,
|
|
12
9
|
* or undefined when it is missing or only whitespace, so it can sit on the left of
|
|
13
10
|
* a `??` fallback. `??` on the raw value would let "" through: it is not nullish.
|
|
14
11
|
*/
|
|
15
12
|
declare function nonBlank(value: string | undefined): string | undefined;
|
|
16
|
-
|
|
17
|
-
interface AppConfig {
|
|
13
|
+
interface NetworkConfig {
|
|
18
14
|
dataRegistryContractAddress: Hex;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
appRegistryFromBlock: bigint;
|
|
15
|
+
settlementRegistryContractAddress?: Hex;
|
|
16
|
+
fromBlock: bigint;
|
|
22
17
|
chain: Chain;
|
|
23
18
|
rpcUrl: string;
|
|
24
19
|
caip2: number;
|
|
@@ -26,67 +21,10 @@ interface AppConfig {
|
|
|
26
21
|
logWindow?: bigint;
|
|
27
22
|
signedUrlWorker?: string;
|
|
28
23
|
}
|
|
29
|
-
declare const ArbitrumSepoliaConfig: {
|
|
30
|
-
dataRegistryContractAddress: "0x72B5f83526F3893aF9f1eE0f32A27218EA09f8aE";
|
|
31
|
-
appRegistryContractAddress: "0x55e6209ea1833ceD900989a3b3b22466934E04A5";
|
|
32
|
-
membershipRegistryContractAddress: "0xDF17030Cd65435C86eb043F31DDACa99E819E347";
|
|
33
|
-
appRegistryFromBlock: bigint;
|
|
34
|
-
chain: {
|
|
35
|
-
blockExplorers: {
|
|
36
|
-
readonly default: {
|
|
37
|
-
readonly name: "Arbiscan";
|
|
38
|
-
readonly url: "https://sepolia.arbiscan.io";
|
|
39
|
-
readonly apiUrl: "https://api-sepolia.arbiscan.io/api";
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
blockTime: 250;
|
|
43
|
-
contracts: {
|
|
44
|
-
readonly multicall3: {
|
|
45
|
-
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
46
|
-
readonly blockCreated: 81930;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
ensTlds?: readonly string[] | undefined;
|
|
50
|
-
id: 421614;
|
|
51
|
-
name: "Arbitrum Sepolia";
|
|
52
|
-
nativeCurrency: {
|
|
53
|
-
readonly name: "Arbitrum Sepolia Ether";
|
|
54
|
-
readonly symbol: "ETH";
|
|
55
|
-
readonly decimals: 18;
|
|
56
|
-
};
|
|
57
|
-
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
58
|
-
rpcUrls: {
|
|
59
|
-
readonly default: {
|
|
60
|
-
readonly http: readonly ["https://sepolia-rollup.arbitrum.io/rpc"];
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
sourceId?: number | undefined | undefined;
|
|
64
|
-
testnet: true;
|
|
65
|
-
custom?: Record<string, unknown> | undefined;
|
|
66
|
-
extendSchema?: Record<string, unknown> | undefined;
|
|
67
|
-
fees?: viem0.ChainFees<undefined> | undefined;
|
|
68
|
-
formatters?: undefined;
|
|
69
|
-
prepareTransactionRequest?: ((args: viem0.PrepareTransactionRequestParameters, options: {
|
|
70
|
-
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
71
|
-
}) => Promise<viem0.PrepareTransactionRequestParameters>) | [fn: ((args: viem0.PrepareTransactionRequestParameters, options: {
|
|
72
|
-
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
73
|
-
}) => Promise<viem0.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
74
|
-
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
75
|
-
}] | undefined;
|
|
76
|
-
serializers?: viem0.ChainSerializers<undefined, viem0.TransactionSerializable> | undefined;
|
|
77
|
-
verifyHash?: ((client: viem0.Client, parameters: viem0.VerifyHashActionParameters) => Promise<viem0.VerifyHashActionReturnType>) | undefined;
|
|
78
|
-
};
|
|
79
|
-
rpcUrl: string;
|
|
80
|
-
caip2: number;
|
|
81
|
-
ipfsGateway: string;
|
|
82
|
-
logWindow: bigint;
|
|
83
|
-
signedUrlWorker: string;
|
|
84
|
-
};
|
|
85
24
|
declare const BaseSepoliaConfig: {
|
|
86
|
-
dataRegistryContractAddress: "
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
appRegistryFromBlock: bigint;
|
|
25
|
+
dataRegistryContractAddress: "0x0F3eb0E62CF610dbaC6B3aD4Bf4cE38Ab50EBCC5";
|
|
26
|
+
settlementRegistryContractAddress: "0x61A5A195B54F57ada786Ba6689CdB04553cf7fBc";
|
|
27
|
+
fromBlock: bigint;
|
|
90
28
|
chain: {
|
|
91
29
|
blockExplorers: {
|
|
92
30
|
readonly default: {
|
|
@@ -418,10 +356,9 @@ declare const BaseSepoliaConfig: {
|
|
|
418
356
|
* built from.
|
|
419
357
|
*/
|
|
420
358
|
declare const FangornConfig: {
|
|
421
|
-
dataRegistryContractAddress: "
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
appRegistryFromBlock: bigint;
|
|
359
|
+
dataRegistryContractAddress: "0x0F3eb0E62CF610dbaC6B3aD4Bf4cE38Ab50EBCC5";
|
|
360
|
+
settlementRegistryContractAddress: "0x61A5A195B54F57ada786Ba6689CdB04553cf7fBc";
|
|
361
|
+
fromBlock: bigint;
|
|
425
362
|
chain: {
|
|
426
363
|
blockExplorers: {
|
|
427
364
|
readonly default: {
|
|
@@ -750,11 +687,11 @@ declare const FangornConfig: {
|
|
|
750
687
|
/**
|
|
751
688
|
* The networks supported by Fangorn, by the name `CHAIN_NAME` takes.
|
|
752
689
|
*/
|
|
753
|
-
declare const SupportedNetworks: Record<string,
|
|
690
|
+
declare const SupportedNetworks: Record<string, NetworkConfig>;
|
|
754
691
|
/**
|
|
755
|
-
* Get a network's deployment by name ("
|
|
692
|
+
* Get a network's deployment by name ("baseSepolia").
|
|
756
693
|
* @returns The corresponding config if it is supported, otherwise an error
|
|
757
694
|
*/
|
|
758
|
-
declare function getNetwork(name: string):
|
|
695
|
+
declare function getNetwork(name: string): NetworkConfig;
|
|
759
696
|
//#endregion
|
|
760
|
-
export {
|
|
697
|
+
export { BaseSepoliaConfig, FangornConfig, NetworkConfig, SupportedNetworks, getNetwork as default, nonBlank };
|
package/lib/config.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { arbitrumSepolia, baseSepolia } from "viem/chains";
|
|
1
|
+
import { baseSepolia } from "viem/chains";
|
|
3
2
|
|
|
4
3
|
//#region src/config.ts
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
function appId(name) {
|
|
9
|
-
return keccak256(toHex(name));
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Blank input means "not set", never an app called "". Returns the trimmed value,
|
|
5
|
+
* Blank input means "not set", never a value of "". Returns the trimmed value,
|
|
13
6
|
* or undefined when it is missing or only whitespace, so it can sit on the left of
|
|
14
7
|
* a `??` fallback. `??` on the raw value would let "" through: it is not nullish.
|
|
15
8
|
*/
|
|
@@ -17,34 +10,16 @@ function nonBlank(value) {
|
|
|
17
10
|
const trimmed = value?.trim();
|
|
18
11
|
return trimmed === "" ? void 0 : trimmed;
|
|
19
12
|
}
|
|
20
|
-
function toAppId(nameOrId) {
|
|
21
|
-
const name = nameOrId.trim();
|
|
22
|
-
if (!name) throw new Error("App name or id must not be blank.");
|
|
23
|
-
return /^0x[0-9a-fA-F]{64}$/.test(name) ? name : appId(name);
|
|
24
|
-
}
|
|
25
|
-
const ArbitrumSepoliaConfig = {
|
|
26
|
-
dataRegistryContractAddress: "0x72B5f83526F3893aF9f1eE0f32A27218EA09f8aE",
|
|
27
|
-
appRegistryContractAddress: "0x55e6209ea1833ceD900989a3b3b22466934E04A5",
|
|
28
|
-
membershipRegistryContractAddress: "0xDF17030Cd65435C86eb043F31DDACa99E819E347",
|
|
29
|
-
appRegistryFromBlock: 319536642n,
|
|
30
|
-
chain: arbitrumSepolia,
|
|
31
|
-
rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
32
|
-
caip2: 421614,
|
|
33
|
-
ipfsGateway: "https://ipfs.io",
|
|
34
|
-
logWindow: 100000n,
|
|
35
|
-
signedUrlWorker: "https://pinata-url-provider.fangorn-0be.workers.dev"
|
|
36
|
-
};
|
|
37
13
|
const BaseSepoliaConfig = {
|
|
38
|
-
dataRegistryContractAddress: "
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
appRegistryFromBlock: 48340483n,
|
|
14
|
+
dataRegistryContractAddress: "0x0F3eb0E62CF610dbaC6B3aD4Bf4cE38Ab50EBCC5",
|
|
15
|
+
settlementRegistryContractAddress: "0x61A5A195B54F57ada786Ba6689CdB04553cf7fBc",
|
|
16
|
+
fromBlock: 53592845n,
|
|
42
17
|
chain: baseSepolia,
|
|
43
18
|
rpcUrl: "https://base-sepolia-rpc.publicnode.com",
|
|
44
19
|
caip2: 84532,
|
|
45
|
-
ipfsGateway: "https://ipfs.
|
|
46
|
-
logWindow:
|
|
47
|
-
signedUrlWorker: "https://
|
|
20
|
+
ipfsGateway: "https://ipfs-test.fangorn.network",
|
|
21
|
+
logWindow: 50000n,
|
|
22
|
+
signedUrlWorker: "https://base-sepolia.storage-worker.fangorn.network"
|
|
48
23
|
};
|
|
49
24
|
/**
|
|
50
25
|
* The default network: what `Fangorn.create` uses without a `config`, and the CLI
|
|
@@ -55,12 +30,9 @@ const FangornConfig = BaseSepoliaConfig;
|
|
|
55
30
|
/**
|
|
56
31
|
* The networks supported by Fangorn, by the name `CHAIN_NAME` takes.
|
|
57
32
|
*/
|
|
58
|
-
const SupportedNetworks = {
|
|
59
|
-
arbitrumSepolia: ArbitrumSepoliaConfig,
|
|
60
|
-
baseSepolia: BaseSepoliaConfig
|
|
61
|
-
};
|
|
33
|
+
const SupportedNetworks = { baseSepolia: BaseSepoliaConfig };
|
|
62
34
|
/**
|
|
63
|
-
* Get a network's deployment by name ("
|
|
35
|
+
* Get a network's deployment by name ("baseSepolia").
|
|
64
36
|
* @returns The corresponding config if it is supported, otherwise an error
|
|
65
37
|
*/
|
|
66
38
|
function getNetwork(name) {
|
|
@@ -70,4 +42,4 @@ function getNetwork(name) {
|
|
|
70
42
|
}
|
|
71
43
|
|
|
72
44
|
//#endregion
|
|
73
|
-
export {
|
|
45
|
+
export { BaseSepoliaConfig, FangornConfig, SupportedNetworks, getNetwork as default, nonBlank };
|