@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,25 +1,16 @@
|
|
|
1
1
|
import { APP_REGISTRY_ABI } from "./abi.js";
|
|
2
2
|
import { requireWallet, sendWrite } from "../write.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { getLogsInWindows } from "../logs.js";
|
|
4
|
+
import { erc20Abi, hexToBigInt } from "viem";
|
|
5
5
|
|
|
6
6
|
//#region src/contracts/app-registry/index.ts
|
|
7
|
-
/** True when the publisher joined but the app's terms have since changed. */
|
|
8
|
-
function needsReacceptance(info) {
|
|
9
|
-
return !info.registered && info.status === PublisherStatus.ACTIVE && info.acceptedTerms !== info.termsHash;
|
|
10
|
-
}
|
|
11
7
|
/**
|
|
12
|
-
* Client for the AppRegistry
|
|
13
|
-
*
|
|
8
|
+
* Client for the AppRegistry's app management: apps and their ERC-5643
|
|
9
|
+
* subscriptions, the publishers each app accepts, the agent card, and the
|
|
10
|
+
* protocol admin's powers. What an app presents — its members, less exclusions — is
|
|
11
|
+
* read through the registry (`ChainRegistry`), not this client.
|
|
14
12
|
*
|
|
15
|
-
*
|
|
16
|
-
* live on the DataRegistry, which meant two contracts held partial opinions about
|
|
17
|
-
* apps and neither could enforce membership. The dependency now runs one way:
|
|
18
|
-
* `DataRegistry.commitStateRoot` cross-calls `isRegisteredForApp` here, so a
|
|
19
|
-
* publisher must join an app *before* they can write under it.
|
|
20
|
-
*
|
|
21
|
-
* Scoped to one `appId`, like `DataRegistryClient` — the app is an identity the
|
|
22
|
-
* client carries, not an argument every call repeats.
|
|
13
|
+
* Scoped to one app, which may be unset: then only the calls that take no app work.
|
|
23
14
|
*/
|
|
24
15
|
var AppRegistryClient = class {
|
|
25
16
|
constructor(contractAddress, appId, publicClient, walletClient) {
|
|
@@ -28,236 +19,248 @@ var AppRegistryClient = class {
|
|
|
28
19
|
this.publicClient = publicClient;
|
|
29
20
|
this.walletClient = walletClient;
|
|
30
21
|
}
|
|
31
|
-
/** The app every call on this client is scoped to. */
|
|
32
22
|
getAppId() {
|
|
33
23
|
return this.appId;
|
|
34
24
|
}
|
|
35
|
-
/** Re-scope every subsequent call to a different app. */
|
|
36
25
|
setAppId(appId) {
|
|
37
26
|
this.appId = appId;
|
|
38
27
|
}
|
|
39
|
-
/** The deployed AppRegistry this client talks to. */
|
|
40
28
|
getAddress() {
|
|
41
29
|
return this.contractAddress;
|
|
42
30
|
}
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
/** This client's app, or a clear error for a call that needs one. */
|
|
32
|
+
app() {
|
|
33
|
+
if (!this.appId) throw new Error("no app chosen: pass `appId` to Fangorn.create() or call setAppId()");
|
|
34
|
+
return this.appId;
|
|
35
|
+
}
|
|
36
|
+
/** The app's subscription token: an app's token id is its app id. */
|
|
37
|
+
tokenId(appId = this.app()) {
|
|
38
|
+
return hexToBigInt(appId);
|
|
39
|
+
}
|
|
40
|
+
executeWrite(functionName, args) {
|
|
41
|
+
return sendWrite(this.publicClient, requireWallet(this.walletClient, functionName), this.contractAddress, APP_REGISTRY_ABI, functionName, args);
|
|
42
|
+
}
|
|
43
|
+
read(functionName, args) {
|
|
44
|
+
return this.publicClient.readContract({
|
|
45
|
+
address: this.contractAddress,
|
|
46
|
+
abi: APP_REGISTRY_ABI,
|
|
47
|
+
functionName,
|
|
48
|
+
args
|
|
49
|
+
});
|
|
46
50
|
}
|
|
47
51
|
/**
|
|
48
|
-
* Claim this
|
|
49
|
-
*
|
|
50
|
-
*
|
|
52
|
+
* Claim this app, if nobody has. Claiming IS subscribing: it pays one period
|
|
53
|
+
* of `subscriptionFee()` in USDC and mints the app's token to the caller,
|
|
54
|
+
* who becomes the app's first accepted publisher.
|
|
51
55
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
56
|
+
* The fee read now is approved and passed as the most the claim may cost,
|
|
57
|
+
* so a fee raised in the meantime makes the claim revert instead of charging
|
|
58
|
+
* more.
|
|
54
59
|
*/
|
|
55
|
-
async registerApp(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
termsUri,
|
|
60
|
-
fee
|
|
61
|
-
]);
|
|
60
|
+
async registerApp() {
|
|
61
|
+
const fee = await this.subscriptionFee();
|
|
62
|
+
await this.approveUsdc(fee);
|
|
63
|
+
return this.executeWrite("registerApp", [this.app(), fee]);
|
|
62
64
|
}
|
|
63
65
|
/**
|
|
64
|
-
*
|
|
66
|
+
* Pay for one more period (the owner, or an address they approved for the
|
|
67
|
+
* app's token). Allowed once less than a period is left; the period is added
|
|
68
|
+
* to the current expiry, or to now if it has passed.
|
|
65
69
|
*
|
|
66
|
-
*
|
|
67
|
-
* is
|
|
68
|
-
* act with a real consequence, not a copy edit. Re-accepting is free for them.
|
|
70
|
+
* The standard gives the contract no maximum-fee argument, so the allowance
|
|
71
|
+
* is the cap: exactly the fee read now is approved.
|
|
69
72
|
*/
|
|
70
|
-
async
|
|
71
|
-
|
|
72
|
-
this.
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
async renewSubscription() {
|
|
74
|
+
const [renewable, period, fee] = await Promise.all([
|
|
75
|
+
this.isRenewable(),
|
|
76
|
+
this.subscriptionPeriod(),
|
|
77
|
+
this.subscriptionFee()
|
|
75
78
|
]);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
if (!renewable) {
|
|
80
|
+
const expiry = await this.expiresAt();
|
|
81
|
+
throw new Error(`app ${this.app()} cannot be renewed until less than one period is left — it expires ${(/* @__PURE__ */ new Date(Number(expiry) * 1e3)).toISOString()}`);
|
|
82
|
+
}
|
|
83
|
+
await this.approveUsdc(fee);
|
|
84
|
+
return this.executeWrite("renewSubscription", [this.tokenId(), period]);
|
|
80
85
|
}
|
|
81
86
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
87
|
+
* End this app's subscription now (owner only): the expiry becomes zero and
|
|
88
|
+
* nothing is refunded. Until it is renewed the app provides no storage and includes nothing.
|
|
84
89
|
*/
|
|
85
|
-
async
|
|
86
|
-
return this.executeWrite("
|
|
90
|
+
async cancelSubscription() {
|
|
91
|
+
return this.executeWrite("cancelSubscription", [this.tokenId()]);
|
|
92
|
+
}
|
|
93
|
+
/** Unix seconds this app's subscription expires at; 0 once cancelled. Reverts for an unclaimed app. */
|
|
94
|
+
async expiresAt(appId = this.app()) {
|
|
95
|
+
return this.read("expiresAt", [this.tokenId(appId)]);
|
|
96
|
+
}
|
|
97
|
+
/** True while less than one period is left, or the subscription has expired. */
|
|
98
|
+
async isRenewable() {
|
|
99
|
+
return this.read("isRenewable", [this.tokenId()]);
|
|
100
|
+
}
|
|
101
|
+
/** How long one payment lasts, in seconds. */
|
|
102
|
+
async subscriptionPeriod() {
|
|
103
|
+
return this.read("subscriptionPeriod", []);
|
|
87
104
|
}
|
|
88
|
-
|
|
89
|
-
|
|
105
|
+
/** What claiming or renewing an app costs, in USDC base units (6 decimals), not wei. */
|
|
106
|
+
async subscriptionFee() {
|
|
107
|
+
return this.read("subscriptionFee", []);
|
|
108
|
+
}
|
|
109
|
+
/** The ERC-20 token (USDC) every fee is paid in. */
|
|
110
|
+
async usdc() {
|
|
111
|
+
return this.read("usdc", []);
|
|
112
|
+
}
|
|
113
|
+
async getAppOwner(appId = this.app()) {
|
|
114
|
+
return this.read("getAppOwner", [appId]);
|
|
90
115
|
}
|
|
91
116
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* memberships underneath are left intact, so reinstating restores them exactly.
|
|
117
|
+
* Point this app at its ERC-8004 agent card.
|
|
118
|
+
*
|
|
119
|
+
* Safe to call whenever the card moves: it leaves the app's publishers alone.
|
|
96
120
|
*/
|
|
97
|
-
async
|
|
98
|
-
return this.executeWrite("
|
|
121
|
+
async setAppAgentUri(agentUri) {
|
|
122
|
+
return this.executeWrite("setAppAgentUri", [this.app(), agentUri]);
|
|
99
123
|
}
|
|
100
|
-
/**
|
|
101
|
-
async
|
|
102
|
-
return this.executeWrite("
|
|
124
|
+
/** Send the join fees the caller is still owed, from the old join flow, to `to`. */
|
|
125
|
+
async withdrawJoinFees(to = this.senderAddress()) {
|
|
126
|
+
return this.executeWrite("withdrawJoinFees", [to]);
|
|
103
127
|
}
|
|
104
|
-
/**
|
|
105
|
-
async
|
|
106
|
-
return this.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
128
|
+
/** Join fees still owed to `owner` from the old join flow, in USDC base units. Nothing adds to it. */
|
|
129
|
+
async joinFeesOwed(owner = this.senderAddress()) {
|
|
130
|
+
return this.read("joinFeesOwed", [owner]);
|
|
131
|
+
}
|
|
132
|
+
async isAppSuspended() {
|
|
133
|
+
return this.read("isAppSuspended", [this.app()]);
|
|
134
|
+
}
|
|
135
|
+
/** The agent card URI of this app, or of `appId`. Empty if none is set. */
|
|
136
|
+
async appAgentUri(appId = this.app()) {
|
|
137
|
+
return this.read("appAgentUri", [appId]);
|
|
111
138
|
}
|
|
112
139
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* point: the transaction is only valid against the exact version that was in
|
|
118
|
-
* front of the caller, so terms cannot change under a pending registration and
|
|
119
|
-
* land as agreement to something else. A race here is a revert, not a
|
|
120
|
-
* surprise obligation.
|
|
121
|
-
*
|
|
122
|
-
* The join fee is read from the chain rather than passed in, for the same
|
|
123
|
-
* reason `DataRegistryClient.register()` reads the registration fee: a caller
|
|
124
|
-
* who supplies it can supply the wrong one.
|
|
140
|
+
* Accept a publisher into this app (owner only). That is the whole
|
|
141
|
+
* membership: from here it uploads with storage the app provides, and the app
|
|
142
|
+
* includes its data, while `canPublish` holds. A suspended publisher comes
|
|
143
|
+
* back with `setPublisherSuspended(publisher, false)`.
|
|
125
144
|
*/
|
|
126
|
-
async
|
|
127
|
-
|
|
128
|
-
if (termsHash === ZERO_HASH) throw new Error(`app ${this.appId} has published no terms — it cannot be joined until its owner sets them`);
|
|
129
|
-
return this.executeWrite("registerForApp", [this.appId, termsHash], fee);
|
|
145
|
+
async acceptPublisher(publisher) {
|
|
146
|
+
return this.executeWrite("acceptPublisher", [this.app(), publisher]);
|
|
130
147
|
}
|
|
131
148
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
149
|
+
* Suspend an accepted publisher from this app, or reinstate them (owner
|
|
150
|
+
* only). An owner cannot suspend themselves.
|
|
134
151
|
*/
|
|
135
|
-
async
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
152
|
+
async setPublisherSuspended(publisher, suspended) {
|
|
153
|
+
return this.executeWrite("setPublisherSuspended", [
|
|
154
|
+
this.app(),
|
|
155
|
+
publisher,
|
|
156
|
+
suspended
|
|
157
|
+
]);
|
|
158
|
+
}
|
|
159
|
+
/** `publisher`'s standing in this app. */
|
|
160
|
+
async status(publisher) {
|
|
161
|
+
return await this.read("statusForApp", [this.app(), publisher]);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* May `publisher` publish to this app now: accepted and not suspended, not
|
|
165
|
+
* banned network-wide, and the app is live and paid up.
|
|
166
|
+
*/
|
|
167
|
+
async canPublish(publisher, appId = this.app()) {
|
|
168
|
+
return this.read("canPublish", [appId, publisher]);
|
|
169
|
+
}
|
|
170
|
+
/** The single oracle the upload gate reads for one publisher under this app. */
|
|
171
|
+
async access(publisher, appId = this.app()) {
|
|
172
|
+
const [canPublish, owner, expiresAt] = await this.read("access", [appId, publisher]);
|
|
157
173
|
return {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
gas: toHex(gas),
|
|
162
|
-
maxFeePerGas: toHex(fees.maxFeePerGas * 2n),
|
|
163
|
-
maxPriorityFeePerGas: toHex(fees.maxPriorityFeePerGas),
|
|
164
|
-
value: toHex(fee)
|
|
174
|
+
canPublish,
|
|
175
|
+
owner,
|
|
176
|
+
expiresAt
|
|
165
177
|
};
|
|
166
178
|
}
|
|
167
|
-
/** Owner of this client's app id, or the zero address if unclaimed. */
|
|
168
|
-
async getAppOwner() {
|
|
169
|
-
return this.publicClient.readContract({
|
|
170
|
-
address: this.contractAddress,
|
|
171
|
-
abi: APP_REGISTRY_ABI,
|
|
172
|
-
functionName: "getAppOwner",
|
|
173
|
-
args: [this.appId]
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
179
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
+
* `AppAgentChanged` events, oldest first. The last one for an app is its
|
|
181
|
+
* current card; an empty `agentUri` means the owner unset it.
|
|
182
|
+
*
|
|
183
|
+
* Leave `appId` out to list every app that has ever set a card. The chain is
|
|
184
|
+
* the directory: one windowed log scan, no indexer and no registry namespace.
|
|
185
|
+
* `fromBlock` is required because scanning from genesis on an L2 costs
|
|
186
|
+
* hundreds of thousands of RPC calls. Pass the AppRegistry's deploy block, or
|
|
187
|
+
* a block you know to be before the app's registration.
|
|
180
188
|
*/
|
|
181
|
-
async
|
|
182
|
-
return this.publicClient.
|
|
189
|
+
async getAppAgentLogs(opts) {
|
|
190
|
+
return (await getLogsInWindows(this.publicClient, opts.fromBlock, opts.toBlock, (from, to) => this.publicClient.getContractEvents({
|
|
183
191
|
address: this.contractAddress,
|
|
184
192
|
abi: APP_REGISTRY_ABI,
|
|
185
|
-
|
|
186
|
-
args:
|
|
187
|
-
|
|
193
|
+
eventName: "AppAgentChanged",
|
|
194
|
+
args: opts.appId ? { app_id: opts.appId } : {},
|
|
195
|
+
fromBlock: from,
|
|
196
|
+
toBlock: to,
|
|
197
|
+
strict: true
|
|
198
|
+
}))).map((log) => ({
|
|
199
|
+
appId: log.args.app_id,
|
|
200
|
+
agentUri: log.args.agent_uri,
|
|
201
|
+
blockNumber: log.blockNumber,
|
|
202
|
+
transactionHash: log.transactionHash
|
|
203
|
+
}));
|
|
188
204
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
return this.publicClient.readContract({
|
|
192
|
-
address: this.contractAddress,
|
|
193
|
-
abi: APP_REGISTRY_ABI,
|
|
194
|
-
functionName: "isAppSuspended",
|
|
195
|
-
args: [this.appId]
|
|
196
|
-
});
|
|
205
|
+
async admin() {
|
|
206
|
+
return this.read("admin", []);
|
|
197
207
|
}
|
|
198
|
-
/**
|
|
199
|
-
async
|
|
200
|
-
return this.
|
|
201
|
-
address: this.contractAddress,
|
|
202
|
-
abi: APP_REGISTRY_ABI,
|
|
203
|
-
functionName: "appTerms",
|
|
204
|
-
args: [this.appId]
|
|
205
|
-
});
|
|
208
|
+
/** The DataRegistry this contract names. */
|
|
209
|
+
async dataRegistry() {
|
|
210
|
+
return this.read("dataRegistry", []);
|
|
206
211
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
abi: APP_REGISTRY_ABI,
|
|
211
|
-
functionName: "appTermsUri",
|
|
212
|
-
args: [this.appId]
|
|
213
|
-
});
|
|
212
|
+
/** Whether the protocol admin has banned `wallet` network-wide. */
|
|
213
|
+
async isGloballySuspended(wallet) {
|
|
214
|
+
return this.read("globalSuspensions", [wallet]);
|
|
214
215
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
216
|
+
/**
|
|
217
|
+
* Ban `wallet` network-wide, or lift the ban. A banned wallet cannot claim an
|
|
218
|
+
* app or be accepted into one, and no app stores or includes it; a banned
|
|
219
|
+
* owner's app keeps running, but they cannot accept anyone or move its agent card.
|
|
220
|
+
*/
|
|
221
|
+
async setGlobalSuspension(wallet, suspended) {
|
|
222
|
+
return this.executeWrite("setGlobalSuspension", [wallet, suspended]);
|
|
222
223
|
}
|
|
223
|
-
/**
|
|
224
|
-
async
|
|
225
|
-
return this.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
224
|
+
/** Take this app down for every publisher at once, or restore it. */
|
|
225
|
+
async setAppSuspended(suspended) {
|
|
226
|
+
return this.executeWrite("setAppSuspended", [this.app(), suspended]);
|
|
227
|
+
}
|
|
228
|
+
async setDataRegistry(registry) {
|
|
229
|
+
return this.executeWrite("setDataRegistry", [registry]);
|
|
230
|
+
}
|
|
231
|
+
async setSubscriptionFee(fee) {
|
|
232
|
+
return this.executeWrite("setSubscriptionFee", [fee]);
|
|
233
|
+
}
|
|
234
|
+
/** Applies from each app's next payment. */
|
|
235
|
+
async setSubscriptionPeriod(period) {
|
|
236
|
+
return this.executeWrite("setSubscriptionPeriod", [period]);
|
|
231
237
|
}
|
|
232
238
|
/**
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* terms changed since you joined".
|
|
239
|
+
* Send `amount` of `token` to `to`. Of USDC, only the protocol's share: what
|
|
240
|
+
* app owners are owed in join fees stays (`ExceedsProtocolBalance`).
|
|
236
241
|
*/
|
|
237
|
-
async
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
async withdrawToken(token, to, amount) {
|
|
243
|
+
return this.executeWrite("withdrawToken", [
|
|
244
|
+
token,
|
|
245
|
+
to,
|
|
246
|
+
amount
|
|
242
247
|
]);
|
|
243
|
-
const [termsHash, termsUri, fee, status, registered] = tuple;
|
|
244
|
-
return {
|
|
245
|
-
termsHash,
|
|
246
|
-
termsUri,
|
|
247
|
-
fee,
|
|
248
|
-
status,
|
|
249
|
-
registered,
|
|
250
|
-
acceptedTerms,
|
|
251
|
-
appSuspended
|
|
252
|
-
};
|
|
253
248
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
249
|
+
/**
|
|
250
|
+
* Fees are pulled with `transferFrom`, so the registry needs an allowance.
|
|
251
|
+
* Without one the call reverts with a fee error that reads like a pricing
|
|
252
|
+
* problem but is really an allowance one. Approves exactly `amount`.
|
|
253
|
+
*/
|
|
254
|
+
async approveUsdc(amount) {
|
|
255
|
+
if (amount === 0n) return;
|
|
256
|
+
const token = await this.usdc();
|
|
257
|
+
if (await this.publicClient.readContract({
|
|
258
|
+
address: token,
|
|
259
|
+
abi: erc20Abi,
|
|
260
|
+
functionName: "allowance",
|
|
261
|
+
args: [this.senderAddress(), this.contractAddress]
|
|
262
|
+
}) >= amount) return;
|
|
263
|
+
await sendWrite(this.publicClient, requireWallet(this.walletClient, "approve"), token, erc20Abi, "approve", [this.contractAddress, amount]);
|
|
261
264
|
}
|
|
262
265
|
senderAddress() {
|
|
263
266
|
const account = this.walletClient.account;
|
|
@@ -265,7 +268,6 @@ var AppRegistryClient = class {
|
|
|
265
268
|
return account.address;
|
|
266
269
|
}
|
|
267
270
|
};
|
|
268
|
-
const ZERO_HASH = `0x${"0".repeat(64)}`;
|
|
269
271
|
|
|
270
272
|
//#endregion
|
|
271
|
-
export { AppRegistryClient
|
|
273
|
+
export { AppRegistryClient };
|