@fangorn-network/sdk 2026.10.28 → 2026.11.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 +37 -653
- package/lib/cli/cli.js +46 -357
- 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/config.d.ts +163 -226
- package/lib/config.js +8 -35
- package/lib/contracts/data-registry/abi.d.ts +206 -6
- package/lib/contracts/data-registry/abi.js +415 -186
- 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 +288 -637
- package/lib/contracts/settlement-registry/abi.js +947 -0
- package/lib/contracts/settlement-registry/index.d.ts +141 -0
- package/lib/contracts/settlement-registry/index.js +209 -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/index.d.ts +23 -12
- package/lib/engine/index.js +68 -29
- package/lib/engine/records.d.ts +4 -7
- package/lib/engine/records.js +6 -6
- 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 -96
- package/lib/fangorn.js +110 -168
- 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 +35 -45
- package/lib/test/testbed.js +29 -56
- package/lib/types/index.d.ts +6 -11
- package/package.json +2 -5
- package/lib/contracts/app-registry/abi.d.ts +0 -1306
- package/lib/contracts/app-registry/abi.js +0 -1493
- package/lib/contracts/app-registry/index.d.ts +0 -200
- package/lib/contracts/app-registry/index.js +0 -325
- 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 -8
- package/lib/contracts/types.js +0 -10
- 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/test/testbed.d.ts
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
import { AppConfig } from "../config.js";
|
|
2
1
|
import { MetadataStorage } from "../providers/storage/types.js";
|
|
2
|
+
import { NetworkConfig } from "../config.js";
|
|
3
|
+
import { Fangorn } from "../fangorn.js";
|
|
3
4
|
import { MemLedger, MemRegistry } from "./mem-registry.js";
|
|
4
5
|
import { MemStorage } from "../engine/test-helpers.js";
|
|
5
|
-
import { Fangorn } from "../fangorn.js";
|
|
6
6
|
import * as viem0 from "viem";
|
|
7
7
|
import { Abi, Address, Hex } from "viem";
|
|
8
8
|
import * as abitype0 from "abitype";
|
|
9
9
|
|
|
10
10
|
//#region src/test/testbed.d.ts
|
|
11
|
-
/** The app every client is accepted into unless told otherwise. */
|
|
12
|
-
declare const TEST_APP = "test-app";
|
|
13
11
|
/** What a suite needs of a network: clients on one ordering and one storage. */
|
|
14
12
|
interface Network {
|
|
15
13
|
name: string;
|
|
16
14
|
storage: MetadataStorage;
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
* `null`. On chain it is a joined member of the app: the first client of an
|
|
20
|
-
* app claims it, and the claimer accepts each later one.
|
|
21
|
-
*/
|
|
22
|
-
client(app?: string | null, sk?: Hex): Promise<Fangorn>;
|
|
15
|
+
/** A client for a fresh wallet, or for `sk`. */
|
|
16
|
+
client(sk?: Hex): Promise<Fangorn>;
|
|
23
17
|
/** The ordering's clock (a block number on chain). */
|
|
24
18
|
clock(): Promise<bigint>;
|
|
25
19
|
stop(): void;
|
|
@@ -28,8 +22,7 @@ declare function memoryNetwork(Registry?: typeof MemRegistry): {
|
|
|
28
22
|
name: string;
|
|
29
23
|
ledger: MemLedger;
|
|
30
24
|
storage: MemStorage;
|
|
31
|
-
|
|
32
|
-
client(app?: string | null, sk?: Hex, R?: typeof MemRegistry): Promise<Fangorn>;
|
|
25
|
+
client(sk?: Hex, R?: typeof MemRegistry): Promise<Fangorn>;
|
|
33
26
|
clock: () => Promise<bigint>;
|
|
34
27
|
stop: () => undefined;
|
|
35
28
|
};
|
|
@@ -40,13 +33,13 @@ declare function memoryNetwork(Registry?: typeof MemRegistry): {
|
|
|
40
33
|
declare const skipChain: boolean;
|
|
41
34
|
/**
|
|
42
35
|
* A fresh anvil with the contracts deployed from source, each behind its
|
|
43
|
-
* ERC-1967 proxy as Deploy.s.sol does, and wired to each other.
|
|
36
|
+
* ERC-1967 proxy as Deploy.s.sol does, and wired to each other.
|
|
44
37
|
* Call `stop` from `afterAll`.
|
|
45
38
|
*/
|
|
46
39
|
declare function chainNetwork(): Promise<{
|
|
47
40
|
name: string;
|
|
48
41
|
storage: MetadataStorage;
|
|
49
|
-
config:
|
|
42
|
+
config: NetworkConfig;
|
|
50
43
|
chain: viem0.Client<viem0.HttpTransport<undefined, false>, {
|
|
51
44
|
id: 84532;
|
|
52
45
|
blockExplorers?: {
|
|
@@ -8603,12 +8596,12 @@ declare function chainNetwork(): Promise<{
|
|
|
8603
8596
|
[x: `address[${string}]`]: undefined;
|
|
8604
8597
|
[x: `bool[${string}]`]: undefined;
|
|
8605
8598
|
[x: `bytes[${string}]`]: undefined;
|
|
8599
|
+
[x: `bytes32[${string}]`]: undefined;
|
|
8606
8600
|
[x: `bytes1[${string}]`]: undefined;
|
|
8607
|
-
[x: `
|
|
8601
|
+
[x: `bytes4[${string}]`]: undefined;
|
|
8608
8602
|
[x: `bytes18[${string}]`]: undefined;
|
|
8609
|
-
[x: `
|
|
8603
|
+
[x: `bytes2[${string}]`]: undefined;
|
|
8610
8604
|
[x: `bytes3[${string}]`]: undefined;
|
|
8611
|
-
[x: `bytes4[${string}]`]: undefined;
|
|
8612
8605
|
[x: `bytes5[${string}]`]: undefined;
|
|
8613
8606
|
[x: `bytes6[${string}]`]: undefined;
|
|
8614
8607
|
[x: `bytes7[${string}]`]: undefined;
|
|
@@ -8636,8 +8629,8 @@ declare function chainNetwork(): Promise<{
|
|
|
8636
8629
|
[x: `bytes30[${string}]`]: undefined;
|
|
8637
8630
|
[x: `bytes31[${string}]`]: undefined;
|
|
8638
8631
|
[x: `int[${string}]`]: undefined;
|
|
8639
|
-
[x: `int112[${string}]`]: undefined;
|
|
8640
8632
|
[x: `int32[${string}]`]: undefined;
|
|
8633
|
+
[x: `int256[${string}]`]: undefined;
|
|
8641
8634
|
[x: `int8[${string}]`]: undefined;
|
|
8642
8635
|
[x: `int16[${string}]`]: undefined;
|
|
8643
8636
|
[x: `int24[${string}]`]: undefined;
|
|
@@ -8650,6 +8643,7 @@ declare function chainNetwork(): Promise<{
|
|
|
8650
8643
|
[x: `int88[${string}]`]: undefined;
|
|
8651
8644
|
[x: `int96[${string}]`]: undefined;
|
|
8652
8645
|
[x: `int104[${string}]`]: undefined;
|
|
8646
|
+
[x: `int112[${string}]`]: undefined;
|
|
8653
8647
|
[x: `int120[${string}]`]: undefined;
|
|
8654
8648
|
[x: `int128[${string}]`]: undefined;
|
|
8655
8649
|
[x: `int136[${string}]`]: undefined;
|
|
@@ -8667,10 +8661,9 @@ declare function chainNetwork(): Promise<{
|
|
|
8667
8661
|
[x: `int232[${string}]`]: undefined;
|
|
8668
8662
|
[x: `int240[${string}]`]: undefined;
|
|
8669
8663
|
[x: `int248[${string}]`]: undefined;
|
|
8670
|
-
[x: `int256[${string}]`]: undefined;
|
|
8671
8664
|
[x: `uint[${string}]`]: undefined;
|
|
8672
|
-
[x: `uint112[${string}]`]: undefined;
|
|
8673
8665
|
[x: `uint32[${string}]`]: undefined;
|
|
8666
|
+
[x: `uint256[${string}]`]: undefined;
|
|
8674
8667
|
[x: `uint8[${string}]`]: undefined;
|
|
8675
8668
|
[x: `uint16[${string}]`]: undefined;
|
|
8676
8669
|
[x: `uint24[${string}]`]: undefined;
|
|
@@ -8683,6 +8676,7 @@ declare function chainNetwork(): Promise<{
|
|
|
8683
8676
|
[x: `uint88[${string}]`]: undefined;
|
|
8684
8677
|
[x: `uint96[${string}]`]: undefined;
|
|
8685
8678
|
[x: `uint104[${string}]`]: undefined;
|
|
8679
|
+
[x: `uint112[${string}]`]: undefined;
|
|
8686
8680
|
[x: `uint120[${string}]`]: undefined;
|
|
8687
8681
|
[x: `uint128[${string}]`]: undefined;
|
|
8688
8682
|
[x: `uint136[${string}]`]: undefined;
|
|
@@ -8700,17 +8694,16 @@ declare function chainNetwork(): Promise<{
|
|
|
8700
8694
|
[x: `uint232[${string}]`]: undefined;
|
|
8701
8695
|
[x: `uint240[${string}]`]: undefined;
|
|
8702
8696
|
[x: `uint248[${string}]`]: undefined;
|
|
8703
|
-
[x: `uint256[${string}]`]: undefined;
|
|
8704
8697
|
string?: undefined;
|
|
8705
8698
|
address?: undefined;
|
|
8706
8699
|
bool?: undefined;
|
|
8707
8700
|
bytes?: undefined;
|
|
8701
|
+
bytes32?: undefined;
|
|
8708
8702
|
bytes1?: undefined;
|
|
8709
|
-
|
|
8703
|
+
bytes4?: undefined;
|
|
8710
8704
|
bytes18?: undefined;
|
|
8711
|
-
|
|
8705
|
+
bytes2?: undefined;
|
|
8712
8706
|
bytes3?: undefined;
|
|
8713
|
-
bytes4?: undefined;
|
|
8714
8707
|
bytes5?: undefined;
|
|
8715
8708
|
bytes6?: undefined;
|
|
8716
8709
|
bytes7?: undefined;
|
|
@@ -8737,8 +8730,8 @@ declare function chainNetwork(): Promise<{
|
|
|
8737
8730
|
bytes29?: undefined;
|
|
8738
8731
|
bytes30?: undefined;
|
|
8739
8732
|
bytes31?: undefined;
|
|
8740
|
-
int112?: undefined;
|
|
8741
8733
|
int32?: undefined;
|
|
8734
|
+
int256?: undefined;
|
|
8742
8735
|
int8?: undefined;
|
|
8743
8736
|
int16?: undefined;
|
|
8744
8737
|
int24?: undefined;
|
|
@@ -8751,6 +8744,7 @@ declare function chainNetwork(): Promise<{
|
|
|
8751
8744
|
int88?: undefined;
|
|
8752
8745
|
int96?: undefined;
|
|
8753
8746
|
int104?: undefined;
|
|
8747
|
+
int112?: undefined;
|
|
8754
8748
|
int120?: undefined;
|
|
8755
8749
|
int128?: undefined;
|
|
8756
8750
|
int136?: undefined;
|
|
@@ -8768,9 +8762,8 @@ declare function chainNetwork(): Promise<{
|
|
|
8768
8762
|
int232?: undefined;
|
|
8769
8763
|
int240?: undefined;
|
|
8770
8764
|
int248?: undefined;
|
|
8771
|
-
int256?: undefined;
|
|
8772
|
-
uint112?: undefined;
|
|
8773
8765
|
uint32?: undefined;
|
|
8766
|
+
uint256?: undefined;
|
|
8774
8767
|
uint8?: undefined;
|
|
8775
8768
|
uint16?: undefined;
|
|
8776
8769
|
uint24?: undefined;
|
|
@@ -8783,6 +8776,7 @@ declare function chainNetwork(): Promise<{
|
|
|
8783
8776
|
uint88?: undefined;
|
|
8784
8777
|
uint96?: undefined;
|
|
8785
8778
|
uint104?: undefined;
|
|
8779
|
+
uint112?: undefined;
|
|
8786
8780
|
uint120?: undefined;
|
|
8787
8781
|
uint128?: undefined;
|
|
8788
8782
|
uint136?: undefined;
|
|
@@ -8800,7 +8794,6 @@ declare function chainNetwork(): Promise<{
|
|
|
8800
8794
|
uint232?: undefined;
|
|
8801
8795
|
uint240?: undefined;
|
|
8802
8796
|
uint248?: undefined;
|
|
8803
|
-
uint256?: undefined;
|
|
8804
8797
|
} | {
|
|
8805
8798
|
[key: string]: unknown;
|
|
8806
8799
|
}, primaryType extends string>(args: viem0.SignTypedDataParameters<typedData, primaryType, undefined>) => Promise<viem0.SignTypedDataReturnType>;
|
|
@@ -9223,7 +9216,6 @@ declare function chainNetwork(): Promise<{
|
|
|
9223
9216
|
withdrawals?: viem0.Withdrawal[] | undefined | undefined;
|
|
9224
9217
|
withdrawalsRoot?: `0x${string}` | undefined;
|
|
9225
9218
|
transactions: includeTransactions extends true ? ({
|
|
9226
|
-
value: bigint;
|
|
9227
9219
|
yParity?: undefined | undefined;
|
|
9228
9220
|
from: Address;
|
|
9229
9221
|
gas: bigint;
|
|
@@ -9235,6 +9227,7 @@ declare function chainNetwork(): Promise<{
|
|
|
9235
9227
|
to: Address | null;
|
|
9236
9228
|
typeHex: Hex | null;
|
|
9237
9229
|
v: bigint;
|
|
9230
|
+
value: bigint;
|
|
9238
9231
|
accessList?: undefined | undefined;
|
|
9239
9232
|
authorizationList?: undefined | undefined;
|
|
9240
9233
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -9248,7 +9241,6 @@ declare function chainNetwork(): Promise<{
|
|
|
9248
9241
|
blockNumber: (blockTag extends "pending" ? true : false) extends infer T_1 ? T_1 extends (blockTag extends "pending" ? true : false) ? T_1 extends true ? null : bigint : never : never;
|
|
9249
9242
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_2 ? T_2 extends (blockTag extends "pending" ? true : false) ? T_2 extends true ? null : number : never : never;
|
|
9250
9243
|
} | {
|
|
9251
|
-
value: bigint;
|
|
9252
9244
|
yParity: number;
|
|
9253
9245
|
from: Address;
|
|
9254
9246
|
gas: bigint;
|
|
@@ -9260,6 +9252,7 @@ declare function chainNetwork(): Promise<{
|
|
|
9260
9252
|
to: Address | null;
|
|
9261
9253
|
typeHex: Hex | null;
|
|
9262
9254
|
v: bigint;
|
|
9255
|
+
value: bigint;
|
|
9263
9256
|
accessList: viem0.AccessList;
|
|
9264
9257
|
authorizationList?: undefined | undefined;
|
|
9265
9258
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -9273,7 +9266,6 @@ declare function chainNetwork(): Promise<{
|
|
|
9273
9266
|
blockNumber: (blockTag extends "pending" ? true : false) extends infer T_4 ? T_4 extends (blockTag extends "pending" ? true : false) ? T_4 extends true ? null : bigint : never : never;
|
|
9274
9267
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_5 ? T_5 extends (blockTag extends "pending" ? true : false) ? T_5 extends true ? null : number : never : never;
|
|
9275
9268
|
} | {
|
|
9276
|
-
value: bigint;
|
|
9277
9269
|
yParity: number;
|
|
9278
9270
|
from: Address;
|
|
9279
9271
|
gas: bigint;
|
|
@@ -9285,6 +9277,7 @@ declare function chainNetwork(): Promise<{
|
|
|
9285
9277
|
to: Address | null;
|
|
9286
9278
|
typeHex: Hex | null;
|
|
9287
9279
|
v: bigint;
|
|
9280
|
+
value: bigint;
|
|
9288
9281
|
accessList: viem0.AccessList;
|
|
9289
9282
|
authorizationList?: undefined | undefined;
|
|
9290
9283
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -9298,7 +9291,6 @@ declare function chainNetwork(): Promise<{
|
|
|
9298
9291
|
blockNumber: (blockTag extends "pending" ? true : false) extends infer T_7 ? T_7 extends (blockTag extends "pending" ? true : false) ? T_7 extends true ? null : bigint : never : never;
|
|
9299
9292
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_8 ? T_8 extends (blockTag extends "pending" ? true : false) ? T_8 extends true ? null : number : never : never;
|
|
9300
9293
|
} | {
|
|
9301
|
-
value: bigint;
|
|
9302
9294
|
yParity: number;
|
|
9303
9295
|
from: Address;
|
|
9304
9296
|
gas: bigint;
|
|
@@ -9310,6 +9302,7 @@ declare function chainNetwork(): Promise<{
|
|
|
9310
9302
|
to: Address | null;
|
|
9311
9303
|
typeHex: Hex | null;
|
|
9312
9304
|
v: bigint;
|
|
9305
|
+
value: bigint;
|
|
9313
9306
|
accessList: viem0.AccessList;
|
|
9314
9307
|
authorizationList?: undefined | undefined;
|
|
9315
9308
|
blobVersionedHashes: readonly Hex[];
|
|
@@ -9323,7 +9316,6 @@ declare function chainNetwork(): Promise<{
|
|
|
9323
9316
|
blockNumber: (blockTag extends "pending" ? true : false) extends infer T_10 ? T_10 extends (blockTag extends "pending" ? true : false) ? T_10 extends true ? null : bigint : never : never;
|
|
9324
9317
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_11 ? T_11 extends (blockTag extends "pending" ? true : false) ? T_11 extends true ? null : number : never : never;
|
|
9325
9318
|
} | {
|
|
9326
|
-
value: bigint;
|
|
9327
9319
|
yParity: number;
|
|
9328
9320
|
from: Address;
|
|
9329
9321
|
gas: bigint;
|
|
@@ -9335,6 +9327,7 @@ declare function chainNetwork(): Promise<{
|
|
|
9335
9327
|
to: Address | null;
|
|
9336
9328
|
typeHex: Hex | null;
|
|
9337
9329
|
v: bigint;
|
|
9330
|
+
value: bigint;
|
|
9338
9331
|
accessList: viem0.AccessList;
|
|
9339
9332
|
authorizationList: viem0.SignedAuthorizationList;
|
|
9340
9333
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -9427,7 +9420,6 @@ declare function chainNetwork(): Promise<{
|
|
|
9427
9420
|
} | undefined) => Promise<viem0.EstimateMaxPriorityFeePerGasReturnType>;
|
|
9428
9421
|
getStorageAt: (args: viem0.GetStorageAtParameters) => Promise<viem0.GetStorageAtReturnType>;
|
|
9429
9422
|
getTransaction: <blockTag extends viem0.BlockTag = "latest">(args: viem0.GetTransactionParameters<blockTag>) => Promise<{
|
|
9430
|
-
value: bigint;
|
|
9431
9423
|
yParity?: undefined | undefined;
|
|
9432
9424
|
from: Address;
|
|
9433
9425
|
gas: bigint;
|
|
@@ -9439,6 +9431,7 @@ declare function chainNetwork(): Promise<{
|
|
|
9439
9431
|
to: Address | null;
|
|
9440
9432
|
typeHex: Hex | null;
|
|
9441
9433
|
v: bigint;
|
|
9434
|
+
value: bigint;
|
|
9442
9435
|
accessList?: undefined | undefined;
|
|
9443
9436
|
authorizationList?: undefined | undefined;
|
|
9444
9437
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -9452,7 +9445,6 @@ declare function chainNetwork(): Promise<{
|
|
|
9452
9445
|
blockNumber: (blockTag extends "pending" ? true : false) extends infer T_1 ? T_1 extends (blockTag extends "pending" ? true : false) ? T_1 extends true ? null : bigint : never : never;
|
|
9453
9446
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_2 ? T_2 extends (blockTag extends "pending" ? true : false) ? T_2 extends true ? null : number : never : never;
|
|
9454
9447
|
} | {
|
|
9455
|
-
value: bigint;
|
|
9456
9448
|
yParity: number;
|
|
9457
9449
|
from: Address;
|
|
9458
9450
|
gas: bigint;
|
|
@@ -9464,6 +9456,7 @@ declare function chainNetwork(): Promise<{
|
|
|
9464
9456
|
to: Address | null;
|
|
9465
9457
|
typeHex: Hex | null;
|
|
9466
9458
|
v: bigint;
|
|
9459
|
+
value: bigint;
|
|
9467
9460
|
accessList: viem0.AccessList;
|
|
9468
9461
|
authorizationList?: undefined | undefined;
|
|
9469
9462
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -9477,7 +9470,6 @@ declare function chainNetwork(): Promise<{
|
|
|
9477
9470
|
blockNumber: (blockTag extends "pending" ? true : false) extends infer T_4 ? T_4 extends (blockTag extends "pending" ? true : false) ? T_4 extends true ? null : bigint : never : never;
|
|
9478
9471
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_5 ? T_5 extends (blockTag extends "pending" ? true : false) ? T_5 extends true ? null : number : never : never;
|
|
9479
9472
|
} | {
|
|
9480
|
-
value: bigint;
|
|
9481
9473
|
yParity: number;
|
|
9482
9474
|
from: Address;
|
|
9483
9475
|
gas: bigint;
|
|
@@ -9489,6 +9481,7 @@ declare function chainNetwork(): Promise<{
|
|
|
9489
9481
|
to: Address | null;
|
|
9490
9482
|
typeHex: Hex | null;
|
|
9491
9483
|
v: bigint;
|
|
9484
|
+
value: bigint;
|
|
9492
9485
|
accessList: viem0.AccessList;
|
|
9493
9486
|
authorizationList?: undefined | undefined;
|
|
9494
9487
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -9502,7 +9495,6 @@ declare function chainNetwork(): Promise<{
|
|
|
9502
9495
|
blockNumber: (blockTag extends "pending" ? true : false) extends infer T_7 ? T_7 extends (blockTag extends "pending" ? true : false) ? T_7 extends true ? null : bigint : never : never;
|
|
9503
9496
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_8 ? T_8 extends (blockTag extends "pending" ? true : false) ? T_8 extends true ? null : number : never : never;
|
|
9504
9497
|
} | {
|
|
9505
|
-
value: bigint;
|
|
9506
9498
|
yParity: number;
|
|
9507
9499
|
from: Address;
|
|
9508
9500
|
gas: bigint;
|
|
@@ -9514,6 +9506,7 @@ declare function chainNetwork(): Promise<{
|
|
|
9514
9506
|
to: Address | null;
|
|
9515
9507
|
typeHex: Hex | null;
|
|
9516
9508
|
v: bigint;
|
|
9509
|
+
value: bigint;
|
|
9517
9510
|
accessList: viem0.AccessList;
|
|
9518
9511
|
authorizationList?: undefined | undefined;
|
|
9519
9512
|
blobVersionedHashes: readonly Hex[];
|
|
@@ -9527,7 +9520,6 @@ declare function chainNetwork(): Promise<{
|
|
|
9527
9520
|
blockNumber: (blockTag extends "pending" ? true : false) extends infer T_10 ? T_10 extends (blockTag extends "pending" ? true : false) ? T_10 extends true ? null : bigint : never : never;
|
|
9528
9521
|
transactionIndex: (blockTag extends "pending" ? true : false) extends infer T_11 ? T_11 extends (blockTag extends "pending" ? true : false) ? T_11 extends true ? null : number : never : never;
|
|
9529
9522
|
} | {
|
|
9530
|
-
value: bigint;
|
|
9531
9523
|
yParity: number;
|
|
9532
9524
|
from: Address;
|
|
9533
9525
|
gas: bigint;
|
|
@@ -9539,6 +9531,7 @@ declare function chainNetwork(): Promise<{
|
|
|
9539
9531
|
to: Address | null;
|
|
9540
9532
|
typeHex: Hex | null;
|
|
9541
9533
|
v: bigint;
|
|
9534
|
+
value: bigint;
|
|
9542
9535
|
accessList: viem0.AccessList;
|
|
9543
9536
|
authorizationList: viem0.SignedAuthorizationList;
|
|
9544
9537
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -16781,16 +16774,13 @@ declare function chainNetwork(): Promise<{
|
|
|
16781
16774
|
} & {
|
|
16782
16775
|
mode: "anvil";
|
|
16783
16776
|
} & viem0.TestActions>;
|
|
16784
|
-
/**
|
|
16785
|
-
|
|
16777
|
+
/** MockUSDC: `balanceOf` is what each address has been paid. */
|
|
16778
|
+
usdc: `0x${string}`;
|
|
16786
16779
|
wallet: (sk?: Hex) => Promise<Hex>;
|
|
16787
|
-
|
|
16788
|
-
/** The client that claimed `app` through `client`. */
|
|
16789
|
-
owner: (app?: string) => Fangorn | undefined;
|
|
16790
|
-
client(app?: string | null, sk?: Hex): Promise<Fangorn>;
|
|
16780
|
+
client: (sk?: Hex) => Promise<Fangorn>;
|
|
16791
16781
|
clock: () => Promise<bigint>;
|
|
16792
16782
|
stop: () => boolean;
|
|
16793
16783
|
}>;
|
|
16794
16784
|
type ChainNetwork = Awaited<ReturnType<typeof chainNetwork>>;
|
|
16795
16785
|
//#endregion
|
|
16796
|
-
export { ChainNetwork, MemLedger, MemRegistry, Network,
|
|
16786
|
+
export { ChainNetwork, MemLedger, MemRegistry, Network, chainNetwork, memoryNetwork, skipChain };
|
package/lib/test/testbed.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { FangornConfig } from "../config.js";
|
|
2
2
|
import { PinataBackend } from "../providers/storage/pinata.js";
|
|
3
|
-
import { APP_REGISTRY_ABI } from "../contracts/app-registry/abi.js";
|
|
4
3
|
import { DATA_REGISTRY_ABI } from "../contracts/data-registry/abi.js";
|
|
4
|
+
import { SETTLEMENT_REGISTRY_ABI } from "../contracts/settlement-registry/abi.js";
|
|
5
5
|
import "../contracts/index.js";
|
|
6
6
|
import { Fangorn } from "../fangorn.js";
|
|
7
7
|
import { MemLedger, MemRegistry } from "./mem-registry.js";
|
|
8
8
|
import { MemStorage } from "../engine/test-helpers.js";
|
|
9
|
-
import { createTestClient, encodeFunctionData, getAddress, http, parseEther, publicActions, walletActions } from "viem";
|
|
10
9
|
import { foundry } from "viem/chains";
|
|
10
|
+
import { createTestClient, encodeFunctionData, getAddress, http, parseEther, publicActions, walletActions } from "viem";
|
|
11
11
|
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
|
|
12
12
|
import { spawn, spawnSync } from "node:child_process";
|
|
13
13
|
import { existsSync, readFileSync } from "node:fs";
|
|
14
14
|
import { resolve } from "node:path";
|
|
15
15
|
|
|
16
16
|
//#region src/test/testbed.ts
|
|
17
|
-
/** The app every client is accepted into unless told otherwise. */
|
|
18
|
-
const TEST_APP = "test-app";
|
|
19
17
|
function memoryNetwork(Registry = MemRegistry) {
|
|
20
18
|
const ledger = new MemLedger();
|
|
21
19
|
const storage = new MemStorage();
|
|
@@ -23,20 +21,16 @@ function memoryNetwork(Registry = MemRegistry) {
|
|
|
23
21
|
name: "memory",
|
|
24
22
|
ledger,
|
|
25
23
|
storage,
|
|
26
|
-
client(
|
|
27
|
-
|
|
24
|
+
client(sk = generatePrivateKey(), R = Registry) {
|
|
25
|
+
return Promise.resolve(Fangorn.create({
|
|
28
26
|
privateKey: sk,
|
|
29
|
-
appId: app ?? void 0,
|
|
30
27
|
config: {
|
|
31
28
|
...FangornConfig,
|
|
32
|
-
|
|
29
|
+
fromBlock: 0n
|
|
33
30
|
},
|
|
34
31
|
storage: { backend: storage },
|
|
35
32
|
registry: new R(privateKeyToAccount(sk).address, ledger)
|
|
36
|
-
});
|
|
37
|
-
const id = f.getAppId();
|
|
38
|
-
if (id) ledger.members.add(`${id}/${f.getAddress().toLowerCase()}`);
|
|
39
|
-
return Promise.resolve(f);
|
|
33
|
+
}));
|
|
40
34
|
},
|
|
41
35
|
clock: () => Promise.resolve(ledger.t),
|
|
42
36
|
stop: () => void 0
|
|
@@ -52,8 +46,6 @@ const has = (cmd) => spawnSync(cmd, ["--version"]).status === 0;
|
|
|
52
46
|
const skipChain = !(has("anvil") && has("forge") && existsSync(CONTRACTS)) && !process.env.CI;
|
|
53
47
|
/** anvil's first prefunded account: the deployer, and the protocol admin. */
|
|
54
48
|
const ADMIN_KEY = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
|
|
55
|
-
/** No contract: fees are zero, so the token is never called. */
|
|
56
|
-
const NO_TOKEN = "0x000000000000000000000000000000000000dEaD";
|
|
57
49
|
async function startAnvil(chainId) {
|
|
58
50
|
const anvil = spawn("anvil", [
|
|
59
51
|
"--port",
|
|
@@ -81,8 +73,9 @@ async function startAnvil(chainId) {
|
|
|
81
73
|
anvil
|
|
82
74
|
};
|
|
83
75
|
}
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
/** `file`: the .sol it is in, when that isn't `name`.sol. */
|
|
77
|
+
function artifact(name, file = name) {
|
|
78
|
+
const json = JSON.parse(readFileSync(`${CONTRACTS}/out/${file}.sol/${name}.json`, "utf-8"));
|
|
86
79
|
return {
|
|
87
80
|
abi: json.abi,
|
|
88
81
|
bytecode: json.bytecode.object
|
|
@@ -97,7 +90,7 @@ function e2eStorage() {
|
|
|
97
90
|
}
|
|
98
91
|
/**
|
|
99
92
|
* A fresh anvil with the contracts deployed from source, each behind its
|
|
100
|
-
* ERC-1967 proxy as Deploy.s.sol does, and wired to each other.
|
|
93
|
+
* ERC-1967 proxy as Deploy.s.sol does, and wired to each other.
|
|
101
94
|
* Call `stop` from `afterAll`.
|
|
102
95
|
*/
|
|
103
96
|
async function chainNetwork() {
|
|
@@ -115,8 +108,8 @@ async function chainNetwork() {
|
|
|
115
108
|
transport: http(rpcUrl)
|
|
116
109
|
}).extend(publicActions).extend(walletActions);
|
|
117
110
|
const admin = privateKeyToAccount(ADMIN_KEY);
|
|
118
|
-
const deploy = async (name, args) => {
|
|
119
|
-
const { abi, bytecode } = artifact(name);
|
|
111
|
+
const deploy = async (name, args, file) => {
|
|
112
|
+
const { abi, bytecode } = artifact(name, file);
|
|
120
113
|
const hash = await chain.deployContract({
|
|
121
114
|
account: admin,
|
|
122
115
|
abi,
|
|
@@ -128,34 +121,27 @@ async function chainNetwork() {
|
|
|
128
121
|
return getAddress(contractAddress);
|
|
129
122
|
};
|
|
130
123
|
const proxied = async (name, init) => deploy("ERC1967Proxy", [await deploy(name, []), init]);
|
|
131
|
-
const apps = await proxied("AppRegistry", encodeFunctionData({
|
|
132
|
-
abi: APP_REGISTRY_ABI,
|
|
133
|
-
functionName: "initialize",
|
|
134
|
-
args: [
|
|
135
|
-
admin.address,
|
|
136
|
-
NO_TOKEN,
|
|
137
|
-
0n,
|
|
138
|
-
30n * 24n * 3600n
|
|
139
|
-
]
|
|
140
|
-
}));
|
|
141
124
|
const data = await proxied("DataRegistry", encodeFunctionData({
|
|
142
125
|
abi: DATA_REGISTRY_ABI,
|
|
143
126
|
functionName: "initialize",
|
|
144
127
|
args: [admin.address]
|
|
145
128
|
}));
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
129
|
+
const usdc = await deploy("MockUSDC", [], "Mocks");
|
|
130
|
+
const settlement = await proxied("SettlementRegistry", encodeFunctionData({
|
|
131
|
+
abi: SETTLEMENT_REGISTRY_ABI,
|
|
132
|
+
functionName: "initialize",
|
|
133
|
+
args: [
|
|
134
|
+
admin.address,
|
|
135
|
+
usdc,
|
|
136
|
+
await deploy("MockSemaphore", [], "Mocks")
|
|
137
|
+
]
|
|
138
|
+
}));
|
|
153
139
|
const config = {
|
|
154
140
|
...FangornConfig,
|
|
155
141
|
rpcUrl,
|
|
156
|
-
appRegistryContractAddress: apps,
|
|
157
142
|
dataRegistryContractAddress: data,
|
|
158
|
-
|
|
143
|
+
settlementRegistryContractAddress: settlement,
|
|
144
|
+
fromBlock: 0n
|
|
159
145
|
};
|
|
160
146
|
const storage = e2eStorage();
|
|
161
147
|
/** A wallet with gas: `sk`, or a new one. */
|
|
@@ -166,37 +152,24 @@ async function chainNetwork() {
|
|
|
166
152
|
});
|
|
167
153
|
return sk;
|
|
168
154
|
};
|
|
169
|
-
/** A client
|
|
170
|
-
const
|
|
155
|
+
/** A client with gas. */
|
|
156
|
+
const client = async (sk) => Fangorn.create({
|
|
171
157
|
privateKey: await wallet(sk),
|
|
172
158
|
config,
|
|
173
|
-
appId: app,
|
|
174
159
|
storage: { backend: storage }
|
|
175
160
|
});
|
|
176
|
-
const owners = /* @__PURE__ */ new Map();
|
|
177
161
|
return {
|
|
178
162
|
name: "chain",
|
|
179
163
|
storage,
|
|
180
164
|
config,
|
|
181
165
|
chain,
|
|
182
|
-
|
|
166
|
+
usdc,
|
|
183
167
|
wallet,
|
|
184
|
-
|
|
185
|
-
owner: (app = TEST_APP) => owners.get(app),
|
|
186
|
-
async client(app = TEST_APP, sk) {
|
|
187
|
-
const f = await raw(app ?? void 0, sk);
|
|
188
|
-
if (app === null) return f;
|
|
189
|
-
const owner = owners.get(app);
|
|
190
|
-
if (!owner) {
|
|
191
|
-
await f.getAppRegistry().registerApp();
|
|
192
|
-
owners.set(app, f);
|
|
193
|
-
} else await owner.getAppRegistry().acceptPublisher(f.getAddress());
|
|
194
|
-
return f;
|
|
195
|
-
},
|
|
168
|
+
client,
|
|
196
169
|
clock: () => chain.getBlockNumber({ cacheTime: 0 }),
|
|
197
170
|
stop: () => anvil.kill()
|
|
198
171
|
};
|
|
199
172
|
}
|
|
200
173
|
|
|
201
174
|
//#endregion
|
|
202
|
-
export { MemLedger, MemRegistry,
|
|
175
|
+
export { MemLedger, MemRegistry, chainNetwork, memoryNetwork, skipChain };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Registry } from "../contracts/data-registry/index.js";
|
|
2
|
+
import "../contracts/index.js";
|
|
3
3
|
import { MetadataStorage } from "../providers/storage/types.js";
|
|
4
|
+
import { NetworkConfig } from "../config.js";
|
|
4
5
|
import { Hex, PublicClient, WalletClient } from "viem";
|
|
5
6
|
|
|
6
7
|
//#region src/types/index.d.ts
|
|
7
8
|
interface FangornContext {
|
|
8
|
-
config:
|
|
9
|
+
config: NetworkConfig;
|
|
9
10
|
walletClient: WalletClient;
|
|
10
11
|
publicClient: PublicClient;
|
|
11
12
|
metadataStorage: MetadataStorage | undefined;
|
|
12
|
-
/** Heads
|
|
13
|
+
/** Heads and the update log (WHITEPAPER_1 §3.2). */
|
|
13
14
|
registry: Registry;
|
|
14
|
-
/**
|
|
15
|
-
* The app this client reads and publishes under (the paper's context). Unset,
|
|
16
|
-
* reads are each publisher's latest head, and hosted uploads are refused.
|
|
17
|
-
*/
|
|
18
|
-
appId: Hex | undefined;
|
|
19
15
|
}
|
|
20
16
|
type StorageConfig = {
|
|
21
17
|
pinata: {
|
|
@@ -32,8 +28,7 @@ type StorageConfig = {
|
|
|
32
28
|
};
|
|
33
29
|
interface FangornCreateOptions {
|
|
34
30
|
storage?: StorageConfig;
|
|
35
|
-
config?:
|
|
36
|
-
appId?: string;
|
|
31
|
+
config?: NetworkConfig;
|
|
37
32
|
privateKey?: Hex;
|
|
38
33
|
walletClient?: WalletClient;
|
|
39
34
|
registry?: Registry;
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
1
|
{
|
|
3
2
|
"name": "@fangorn-network/sdk",
|
|
4
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.11.03",
|
|
5
4
|
"description": "decentralized, verifiable and platformless content management framework",
|
|
6
5
|
"repository": {
|
|
7
6
|
"type": "git",
|
|
@@ -23,7 +22,6 @@
|
|
|
23
22
|
"prepare": "husky",
|
|
24
23
|
"test": "dotenvx run -f .env -- vitest run",
|
|
25
24
|
"test:e2e": "dotenvx run -f .env -- vitest run --config vitest.e2e.config.ts",
|
|
26
|
-
"test:admin": "vitest run --config vitest.e2e.config.ts src/e2e/admin.e2e.test.ts",
|
|
27
25
|
"test:live": "vitest run --config vitest.e2e.config.ts src/e2e/live.e2e.test.ts",
|
|
28
26
|
"abis": "scripts/gen-abis.sh",
|
|
29
27
|
"tsc": "tsc",
|
|
@@ -70,7 +68,6 @@
|
|
|
70
68
|
"dotenv": "^17.2.3",
|
|
71
69
|
"multiformats": "^14.0.0",
|
|
72
70
|
"pinata": "^2.5.2",
|
|
73
|
-
"solc": "^0.8.28",
|
|
74
71
|
"viem": "^2.47.1"
|
|
75
72
|
},
|
|
76
73
|
"overrides": {
|
|
@@ -87,4 +84,4 @@
|
|
|
87
84
|
}
|
|
88
85
|
}
|
|
89
86
|
}
|
|
90
|
-
}
|
|
87
|
+
}
|