@fangorn-network/sdk 0.1.0 → 0.1.2
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 +1 -1
- package/lib/cli/cli.js +126 -325
- package/lib/cli/index.d.ts +2 -3
- package/lib/cli/index.js +10 -15
- 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 +71 -81
- package/lib/config.js +22 -38
- 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 +6 -6
- 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 +12 -22
- 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,27 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SupportedNetworks } from "../config.js";
|
|
2
2
|
import "./cli.js";
|
|
3
3
|
import { isCancel, select } from "@clack/prompts";
|
|
4
4
|
|
|
5
5
|
//#region src/cli/index.ts
|
|
6
|
-
const getChain = (chainStr) => {
|
|
7
|
-
return getNetwork(chainStr).chain;
|
|
8
|
-
};
|
|
9
6
|
const handleCancel = (value) => {
|
|
10
7
|
if (isCancel(value)) process.exit(0);
|
|
11
8
|
};
|
|
9
|
+
/** Asks which supported network to use, and returns its name ("baseSepolia", ...). */
|
|
12
10
|
const selectChain = async () => {
|
|
13
|
-
const
|
|
11
|
+
const choice = await select({
|
|
14
12
|
message: "Pick your chain.",
|
|
15
|
-
options: [{
|
|
16
|
-
value
|
|
17
|
-
label:
|
|
18
|
-
}
|
|
19
|
-
value: "arbitrumSepolia",
|
|
20
|
-
label: "Arbitrum Sepolia"
|
|
21
|
-
}]
|
|
13
|
+
options: Object.entries(SupportedNetworks).map(([value, c]) => ({
|
|
14
|
+
value,
|
|
15
|
+
label: c.chain.name
|
|
16
|
+
}))
|
|
22
17
|
});
|
|
23
|
-
handleCancel(
|
|
24
|
-
return
|
|
18
|
+
handleCancel(choice);
|
|
19
|
+
return String(choice);
|
|
25
20
|
};
|
|
26
21
|
function parseGadgetArg(raw) {
|
|
27
22
|
const match = /^(\w+)\(([^)]*)\)$/.exec(raw);
|
|
@@ -33,4 +28,4 @@ function parseGadgetArg(raw) {
|
|
|
33
28
|
}
|
|
34
29
|
|
|
35
30
|
//#endregion
|
|
36
|
-
export {
|
|
31
|
+
export { handleCancel, parseGadgetArg, selectChain };
|
|
@@ -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: {
|
|
@@ -412,16 +350,68 @@ declare const BaseSepoliaConfig: {
|
|
|
412
350
|
logWindow: bigint;
|
|
413
351
|
signedUrlWorker: string;
|
|
414
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
|
+
};
|
|
415
407
|
/**
|
|
416
408
|
* The default network: what `Fangorn.create` uses without a `config`, and the CLI
|
|
417
|
-
* without `CHAIN_NAME`. Base Sepolia
|
|
418
|
-
* built from.
|
|
409
|
+
* without `CHAIN_NAME`. Base Sepolia; Arbitrum Sepolia runs the same contracts.
|
|
419
410
|
*/
|
|
420
411
|
declare const FangornConfig: {
|
|
421
|
-
dataRegistryContractAddress: "
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
appRegistryFromBlock: bigint;
|
|
412
|
+
dataRegistryContractAddress: "0x0F3eb0E62CF610dbaC6B3aD4Bf4cE38Ab50EBCC5";
|
|
413
|
+
settlementRegistryContractAddress: "0x61A5A195B54F57ada786Ba6689CdB04553cf7fBc";
|
|
414
|
+
fromBlock: bigint;
|
|
425
415
|
chain: {
|
|
426
416
|
blockExplorers: {
|
|
427
417
|
readonly default: {
|
|
@@ -750,11 +740,11 @@ declare const FangornConfig: {
|
|
|
750
740
|
/**
|
|
751
741
|
* The networks supported by Fangorn, by the name `CHAIN_NAME` takes.
|
|
752
742
|
*/
|
|
753
|
-
declare const SupportedNetworks: Record<string,
|
|
743
|
+
declare const SupportedNetworks: Record<string, NetworkConfig>;
|
|
754
744
|
/**
|
|
755
|
-
* Get a network's deployment by name ("
|
|
745
|
+
* Get a network's deployment by name ("baseSepolia" or "arbitrumSepolia").
|
|
756
746
|
* @returns The corresponding config if it is supported, otherwise an error
|
|
757
747
|
*/
|
|
758
|
-
declare function getNetwork(name: string):
|
|
748
|
+
declare function getNetwork(name: string): NetworkConfig;
|
|
759
749
|
//#endregion
|
|
760
|
-
export {
|
|
750
|
+
export { ArbitrumSepoliaConfig, BaseSepoliaConfig, FangornConfig, NetworkConfig, SupportedNetworks, getNetwork as default, nonBlank };
|
package/lib/config.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import { keccak256, toHex } from "viem";
|
|
2
1
|
import { arbitrumSepolia, 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,50 +10,41 @@ 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"
|
|
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
|
|
48
33
|
};
|
|
49
34
|
/**
|
|
50
35
|
* The default network: what `Fangorn.create` uses without a `config`, and the CLI
|
|
51
|
-
* without `CHAIN_NAME`. Base Sepolia
|
|
52
|
-
* built from.
|
|
36
|
+
* without `CHAIN_NAME`. Base Sepolia; Arbitrum Sepolia runs the same contracts.
|
|
53
37
|
*/
|
|
54
38
|
const FangornConfig = BaseSepoliaConfig;
|
|
55
39
|
/**
|
|
56
40
|
* The networks supported by Fangorn, by the name `CHAIN_NAME` takes.
|
|
57
41
|
*/
|
|
58
42
|
const SupportedNetworks = {
|
|
59
|
-
|
|
60
|
-
|
|
43
|
+
baseSepolia: BaseSepoliaConfig,
|
|
44
|
+
arbitrumSepolia: ArbitrumSepoliaConfig
|
|
61
45
|
};
|
|
62
46
|
/**
|
|
63
|
-
* Get a network's deployment by name ("
|
|
47
|
+
* Get a network's deployment by name ("baseSepolia" or "arbitrumSepolia").
|
|
64
48
|
* @returns The corresponding config if it is supported, otherwise an error
|
|
65
49
|
*/
|
|
66
50
|
function getNetwork(name) {
|
|
@@ -70,4 +54,4 @@ function getNetwork(name) {
|
|
|
70
54
|
}
|
|
71
55
|
|
|
72
56
|
//#endregion
|
|
73
|
-
export { ArbitrumSepoliaConfig, BaseSepoliaConfig, FangornConfig, SupportedNetworks,
|
|
57
|
+
export { ArbitrumSepoliaConfig, BaseSepoliaConfig, FangornConfig, SupportedNetworks, getNetwork as default, nonBlank };
|