@fangorn-network/sdk 2026.8.18-dev → 2026.10.1-9.0-dev
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 +191 -195
- package/lib/cli/cli.d.ts +0 -0
- package/lib/cli/cli.js +198 -164
- package/lib/cli/index.d.ts +3 -91
- package/lib/cli/index.js +5 -2
- package/lib/config.d.ts +349 -433
- package/lib/config.js +41 -28
- package/lib/contracts/app-registry/abi.d.ts +1064 -265
- package/lib/contracts/app-registry/abi.js +1233 -308
- package/lib/contracts/app-registry/index.d.ts +123 -102
- package/lib/contracts/app-registry/index.js +200 -198
- package/lib/contracts/data-registry/abi.d.ts +166 -187
- package/lib/contracts/data-registry/abi.js +207 -237
- package/lib/contracts/data-registry/index.d.ts +4 -160
- package/lib/contracts/data-registry/index.js +5 -294
- package/lib/contracts/index.d.ts +6 -7
- package/lib/contracts/index.js +6 -8
- package/lib/contracts/logs.d.ts +21 -0
- package/lib/contracts/logs.js +32 -0
- package/lib/contracts/membership-registry/abi.d.ts +1145 -0
- package/lib/contracts/membership-registry/abi.js +1333 -0
- package/lib/contracts/membership-registry/index.d.ts +79 -0
- package/lib/contracts/membership-registry/index.js +104 -0
- package/lib/contracts/types.d.ts +3 -1
- package/lib/contracts/types.js +3 -1
- package/lib/contracts/write.d.ts +34 -2
- package/lib/contracts/write.js +48 -1
- package/lib/crypto/encryption.js +4 -4
- package/lib/engine/car.d.ts +2 -2
- package/lib/engine/car.js +10 -5
- package/lib/engine/index.d.ts +99 -143
- package/lib/engine/index.js +156 -295
- package/lib/engine/records.d.ts +110 -0
- package/lib/engine/records.js +165 -0
- package/lib/engine/test-helpers.d.ts +7 -14
- package/lib/engine/test-helpers.js +7 -18
- package/lib/fangorn.d.ts +163 -155
- package/lib/fangorn.js +284 -248
- package/lib/feed.d.ts +7 -4
- package/lib/feed.js +4 -1
- package/lib/index.d.ts +9 -9
- package/lib/index.js +9 -10
- package/lib/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +77 -0
- package/lib/node_modules/@vitest/expect/dist/index.js +1414 -0
- package/lib/node_modules/@vitest/pretty-format/dist/index.js +858 -0
- package/lib/node_modules/@vitest/runner/dist/chunk-tasks.js +51 -0
- package/lib/node_modules/@vitest/runner/dist/index.js +1199 -0
- package/lib/node_modules/@vitest/runner/dist/utils.js +3 -0
- package/lib/node_modules/@vitest/snapshot/dist/index.js +1075 -0
- package/lib/node_modules/@vitest/spy/dist/index.js +353 -0
- package/lib/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js +7 -0
- package/lib/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js +81 -0
- package/lib/node_modules/@vitest/utils/dist/diff.js +1345 -0
- package/lib/node_modules/@vitest/utils/dist/display.js +534 -0
- package/lib/node_modules/@vitest/utils/dist/error.js +30 -0
- package/lib/node_modules/@vitest/utils/dist/helpers.js +118 -0
- package/lib/node_modules/@vitest/utils/dist/serialize.js +76 -0
- package/lib/node_modules/@vitest/utils/dist/source-map.js +93 -0
- package/lib/node_modules/@vitest/utils/dist/timers.js +36 -0
- package/lib/node_modules/chai/index.js +2874 -0
- package/lib/node_modules/magic-string/dist/magic-string.es.js +939 -0
- package/lib/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +81 -0
- package/lib/node_modules/tinyrainbow/dist/index.js +85 -0
- package/lib/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +5 -0
- package/lib/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js +50 -0
- package/lib/node_modules/vitest/dist/chunks/utils.DvEY5TfP.js +44 -0
- package/lib/node_modules/vitest/dist/chunks/vi.2VT5v0um.js +2578 -0
- package/lib/providers/storage/signed-url.d.ts +16 -6
- package/lib/providers/storage/signed-url.js +20 -8
- package/lib/registry.d.ts +116 -0
- package/lib/registry.js +182 -0
- package/lib/test/mem-registry.d.ts +51 -0
- package/lib/test/mem-registry.js +107 -0
- package/lib/test/sdk-suite.d.ts +13 -0
- package/lib/test/sdk-suite.js +226 -0
- package/lib/test/testbed.d.ts +16411 -61
- package/lib/test/testbed.js +190 -84
- package/lib/types/index.d.ts +13 -11
- package/package.json +89 -72
- package/lib/contracts/data-registry/test.d.ts +0 -1
- package/lib/contracts/data-registry/test.js +0 -1
- package/lib/contracts/settlement-registry/abi.d.ts +0 -466
- package/lib/contracts/settlement-registry/abi.js +0 -535
- package/lib/contracts/settlement-registry/index.d.ts +0 -163
- package/lib/contracts/settlement-registry/index.js +0 -264
- package/lib/contracts/subscription-registry/abi.d.ts +0 -179
- package/lib/contracts/subscription-registry/abi.js +0 -195
- package/lib/contracts/subscription-registry/index.d.ts +0 -59
- package/lib/contracts/subscription-registry/index.js +0 -116
- package/lib/engine/graph.d.ts +0 -70
- package/lib/engine/graph.js +0 -73
|
@@ -1,139 +1,160 @@
|
|
|
1
1
|
import { PublisherStatus } from "../types.js";
|
|
2
|
-
import { PreparedTx } from "../
|
|
2
|
+
import { PreparedTx } from "../write.js";
|
|
3
3
|
import { Address, Hash, Hex, PublicClient, WalletClient } from "viem";
|
|
4
4
|
|
|
5
5
|
//#region src/contracts/app-registry/index.d.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/** The terms hash this publisher actually accepted, or zero. */
|
|
22
|
-
acceptedTerms: Hex;
|
|
23
|
-
/** The protocol admin has taken the whole app down — nobody is registered. */
|
|
24
|
-
appSuspended: boolean;
|
|
6
|
+
/** What the upload gate needs to decide whether to serve a publisher under an app. */
|
|
7
|
+
interface AppAccess {
|
|
8
|
+
/** May publish to the app now (see `canPublish`). */
|
|
9
|
+
canPublish: boolean;
|
|
10
|
+
/** The app's owner, or the zero address for an unclaimed app. */
|
|
11
|
+
owner: Address;
|
|
12
|
+
/** Unix seconds the app's subscription expires at; 0 if unclaimed or cancelled. */
|
|
13
|
+
expiresAt: bigint;
|
|
14
|
+
}
|
|
15
|
+
/** One `AppAgentChanged` event: an app owner pointed their app at a card. */
|
|
16
|
+
interface AppAgentLog {
|
|
17
|
+
appId: Hex;
|
|
18
|
+
agentUri: string;
|
|
19
|
+
blockNumber: bigint;
|
|
20
|
+
transactionHash: Hash;
|
|
25
21
|
}
|
|
26
|
-
/** True when the publisher joined but the app's terms have since changed. */
|
|
27
|
-
declare function needsReacceptance(info: AppJoinInfo): boolean;
|
|
28
22
|
/**
|
|
29
|
-
* Client for the AppRegistry
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* live on the DataRegistry, which meant two contracts held partial opinions about
|
|
34
|
-
* apps and neither could enforce membership. The dependency now runs one way:
|
|
35
|
-
* `DataRegistry.commitStateRoot` cross-calls `isRegisteredForApp` here, so a
|
|
36
|
-
* publisher must join an app *before* they can write under it.
|
|
23
|
+
* Client for the AppRegistry's app management: apps and their ERC-5643
|
|
24
|
+
* subscriptions, the publishers each app accepts, the agent card, and the
|
|
25
|
+
* protocol admin's powers. What an app presents — its members, less exclusions — is
|
|
26
|
+
* read through the registry (`ChainRegistry`), not this client.
|
|
37
27
|
*
|
|
38
|
-
* Scoped to one
|
|
39
|
-
* client carries, not an argument every call repeats.
|
|
28
|
+
* Scoped to one app, which may be unset: then only the calls that take no app work.
|
|
40
29
|
*/
|
|
41
30
|
declare class AppRegistryClient {
|
|
42
31
|
private contractAddress;
|
|
43
32
|
private appId;
|
|
44
33
|
private publicClient;
|
|
45
34
|
private walletClient;
|
|
46
|
-
constructor(contractAddress: Address, appId: Hex, publicClient: PublicClient, walletClient: WalletClient);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/** Re-scope every subsequent call to a different app. */
|
|
50
|
-
setAppId(appId: Hex): void;
|
|
51
|
-
/** The deployed AppRegistry this client talks to. */
|
|
35
|
+
constructor(contractAddress: Address, appId: Hex | undefined, publicClient: PublicClient, walletClient: WalletClient);
|
|
36
|
+
getAppId(): Hex | undefined;
|
|
37
|
+
setAppId(appId: Hex | undefined): void;
|
|
52
38
|
getAddress(): Address;
|
|
53
|
-
/**
|
|
39
|
+
/** This client's app, or a clear error for a call that needs one. */
|
|
40
|
+
private app;
|
|
41
|
+
/** The app's subscription token: an app's token id is its app id. */
|
|
42
|
+
tokenId(appId?: Hex): bigint;
|
|
54
43
|
private executeWrite;
|
|
44
|
+
private read;
|
|
55
45
|
/**
|
|
56
|
-
* Claim this
|
|
57
|
-
*
|
|
58
|
-
*
|
|
46
|
+
* Claim this app, if nobody has. Claiming IS subscribing: it pays one period
|
|
47
|
+
* of `subscriptionFee()` in USDC and mints the app's token to the caller,
|
|
48
|
+
* who becomes the app's first accepted publisher.
|
|
59
49
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
50
|
+
* The fee read now is approved and passed as the most the claim may cost,
|
|
51
|
+
* so a fee raised in the meantime makes the claim revert instead of charging
|
|
52
|
+
* more.
|
|
62
53
|
*/
|
|
63
|
-
registerApp(
|
|
54
|
+
registerApp(): Promise<Hash>;
|
|
64
55
|
/**
|
|
65
|
-
*
|
|
56
|
+
* Pay for one more period (the owner, or an address they approved for the
|
|
57
|
+
* app's token). Allowed once less than a period is left; the period is added
|
|
58
|
+
* to the current expiry, or to now if it has passed.
|
|
66
59
|
*
|
|
67
|
-
*
|
|
68
|
-
* is
|
|
69
|
-
* act with a real consequence, not a copy edit. Re-accepting is free for them.
|
|
60
|
+
* The standard gives the contract no maximum-fee argument, so the allowance
|
|
61
|
+
* is the cap: exactly the fee read now is approved.
|
|
70
62
|
*/
|
|
71
|
-
|
|
72
|
-
/** Set what joining this app costs, in wei. Paid to the app owner. */
|
|
73
|
-
setAppFee(fee: bigint): Promise<Hash>;
|
|
63
|
+
renewSubscription(): Promise<Hash>;
|
|
74
64
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
65
|
+
* End this app's subscription now (owner only): the expiry becomes zero and
|
|
66
|
+
* nothing is refunded. Until it is renewed the app provides no storage and includes nothing.
|
|
77
67
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
cancelSubscription(): Promise<Hash>;
|
|
69
|
+
/** Unix seconds this app's subscription expires at; 0 once cancelled. Reverts for an unclaimed app. */
|
|
70
|
+
expiresAt(appId?: Hex): Promise<bigint>;
|
|
71
|
+
/** True while less than one period is left, or the subscription has expired. */
|
|
72
|
+
isRenewable(): Promise<boolean>;
|
|
73
|
+
/** How long one payment lasts, in seconds. */
|
|
74
|
+
subscriptionPeriod(): Promise<bigint>;
|
|
75
|
+
/** What claiming or renewing an app costs, in USDC base units (6 decimals), not wei. */
|
|
76
|
+
subscriptionFee(): Promise<bigint>;
|
|
77
|
+
/** The ERC-20 token (USDC) every fee is paid in. */
|
|
78
|
+
usdc(): Promise<Address>;
|
|
79
|
+
getAppOwner(appId?: Hex): Promise<Address>;
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* memberships underneath are left intact, so reinstating restores them exactly.
|
|
81
|
+
* Point this app at its ERC-8004 agent card.
|
|
82
|
+
*
|
|
83
|
+
* Safe to call whenever the card moves: it leaves the app's publishers alone.
|
|
85
84
|
*/
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
|
|
85
|
+
setAppAgentUri(agentUri: string): Promise<Hash>;
|
|
86
|
+
/** Send the join fees the caller is still owed, from the old join flow, to `to`. */
|
|
87
|
+
withdrawJoinFees(to?: Address): Promise<Hash>;
|
|
88
|
+
/** Join fees still owed to `owner` from the old join flow, in USDC base units. Nothing adds to it. */
|
|
89
|
+
joinFeesOwed(owner?: Address): Promise<bigint>;
|
|
90
|
+
isAppSuspended(): Promise<boolean>;
|
|
91
|
+
/** The agent card URI of this app, or of `appId`. Empty if none is set. */
|
|
92
|
+
appAgentUri(appId?: Hex): Promise<string>;
|
|
91
93
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
*
|
|
94
|
+
* Accept a publisher into this app (owner only). That is the whole
|
|
95
|
+
* membership: from here it uploads with storage the app provides, and the app
|
|
96
|
+
* includes its data, while `canPublish` holds. A suspended publisher comes
|
|
97
|
+
* back with `setPublisherSuspended(publisher, false)`.
|
|
98
|
+
*/
|
|
99
|
+
acceptPublisher(publisher: Address): Promise<Hash>;
|
|
100
|
+
/**
|
|
101
|
+
* Suspend an accepted publisher from this app, or reinstate them (owner
|
|
102
|
+
* only). An owner cannot suspend themselves.
|
|
103
|
+
*/
|
|
104
|
+
setPublisherSuspended(publisher: Address, suspended: boolean): Promise<Hash>;
|
|
105
|
+
/** `publisher`'s standing in this app. */
|
|
106
|
+
status(publisher: Address): Promise<PublisherStatus>;
|
|
107
|
+
/**
|
|
108
|
+
* May `publisher` publish to this app now: accepted and not suspended, not
|
|
109
|
+
* banned network-wide, and the app is live and paid up.
|
|
110
|
+
*/
|
|
111
|
+
canPublish(publisher: Address, appId?: Hex): Promise<boolean>;
|
|
112
|
+
/** The single oracle the upload gate reads for one publisher under this app. */
|
|
113
|
+
access(publisher: Address, appId?: Hex): Promise<AppAccess>;
|
|
114
|
+
/**
|
|
115
|
+
* `AppAgentChanged` events, oldest first. The last one for an app is its
|
|
116
|
+
* current card; an empty `agentUri` means the owner unset it.
|
|
100
117
|
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
118
|
+
* Leave `appId` out to list every app that has ever set a card. The chain is
|
|
119
|
+
* the directory: one windowed log scan, no indexer and no registry namespace.
|
|
120
|
+
* `fromBlock` is required because scanning from genesis on an L2 costs
|
|
121
|
+
* hundreds of thousands of RPC calls. Pass the AppRegistry's deploy block, or
|
|
122
|
+
* a block you know to be before the app's registration.
|
|
104
123
|
*/
|
|
105
|
-
|
|
124
|
+
getAppAgentLogs(opts: {
|
|
125
|
+
appId?: Hex;
|
|
126
|
+
fromBlock: bigint;
|
|
127
|
+
toBlock?: bigint;
|
|
128
|
+
}): Promise<AppAgentLog[]>;
|
|
129
|
+
admin(): Promise<Address>;
|
|
130
|
+
/** The DataRegistry this contract names. */
|
|
131
|
+
dataRegistry(): Promise<Address>;
|
|
132
|
+
/** Whether the protocol admin has banned `wallet` network-wide. */
|
|
133
|
+
isGloballySuspended(wallet: Address): Promise<boolean>;
|
|
106
134
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
135
|
+
* Ban `wallet` network-wide, or lift the ban. A banned wallet cannot claim an
|
|
136
|
+
* app or be accepted into one, and no app stores or includes it; a banned
|
|
137
|
+
* owner's app keeps running, but they cannot accept anyone or move its agent card.
|
|
109
138
|
*/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
139
|
+
setGlobalSuspension(wallet: Address, suspended: boolean): Promise<Hash>;
|
|
140
|
+
/** Take this app down for every publisher at once, or restore it. */
|
|
141
|
+
setAppSuspended(suspended: boolean): Promise<Hash>;
|
|
142
|
+
setDataRegistry(registry: Address): Promise<Hash>;
|
|
143
|
+
setSubscriptionFee(fee: bigint): Promise<Hash>;
|
|
144
|
+
/** Applies from each app's next payment. */
|
|
145
|
+
setSubscriptionPeriod(period: bigint): Promise<Hash>;
|
|
115
146
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* publish would revert.
|
|
147
|
+
* Send `amount` of `token` to `to`. Of USDC, only the protocol's share: what
|
|
148
|
+
* app owners are owed in join fees stays (`ExceedsProtocolBalance`).
|
|
119
149
|
*/
|
|
120
|
-
|
|
121
|
-
/** Has the protocol admin taken this app down? */
|
|
122
|
-
isAppSuspended(): Promise<boolean>;
|
|
123
|
-
/** This app's current terms hash, or the zero hash if it has published none. */
|
|
124
|
-
appTerms(): Promise<Hex>;
|
|
125
|
-
appTermsUri(): Promise<string>;
|
|
126
|
-
appFee(): Promise<bigint>;
|
|
127
|
-
/** The terms hash this publisher accepted, or the zero hash. */
|
|
128
|
-
acceptedTerms(publisher: Address): Promise<Hex>;
|
|
150
|
+
withdrawToken(token: Address, to: Address, amount: bigint): Promise<Hash>;
|
|
129
151
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
152
|
+
* Fees are pulled with `transferFrom`, so the registry needs an allowance.
|
|
153
|
+
* Without one the call reverts with a fee error that reads like a pricing
|
|
154
|
+
* problem but is really an allowance one. Approves exactly `amount`.
|
|
133
155
|
*/
|
|
134
|
-
|
|
135
|
-
private readJoinInfoTuple;
|
|
156
|
+
private approveUsdc;
|
|
136
157
|
private senderAddress;
|
|
137
158
|
}
|
|
138
159
|
//#endregion
|
|
139
|
-
export {
|
|
160
|
+
export { AppAccess, AppAgentLog, AppRegistryClient, type PreparedTx };
|