@fangorn-network/sdk 2026.9.22-dev → 2026.10.19-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 +177 -192
- package/lib/cli/cli.d.ts +0 -0
- package/lib/cli/cli.js +165 -194
- package/lib/config.d.ts +32 -27
- package/lib/config.js +17 -7
- package/lib/contracts/app-registry/abi.d.ts +1033 -277
- package/lib/contracts/app-registry/abi.js +1214 -335
- package/lib/contracts/app-registry/index.d.ts +105 -65
- package/lib/contracts/app-registry/index.js +182 -175
- 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 -151
- package/lib/contracts/data-registry/index.js +5 -279
- package/lib/contracts/index.d.ts +6 -7
- package/lib/contracts/index.js +6 -8
- package/lib/contracts/logs.d.ts +4 -1
- package/lib/contracts/logs.js +9 -2
- 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 +129 -156
- package/lib/fangorn.js +250 -250
- package/lib/feed.d.ts +7 -4
- package/lib/feed.js +4 -1
- package/lib/index.d.ts +9 -9
- package/lib/index.js +8 -9
- 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 -73
- 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,535 +0,0 @@
|
|
|
1
|
-
//#region src/contracts/settlement-registry/abi.ts
|
|
2
|
-
/**
|
|
3
|
-
* The SettlementRegistry: the on-chain payment + access rail for a priced resource.
|
|
4
|
-
*
|
|
5
|
-
* One resource is one Semaphore group. A consumer `register`s into the group by
|
|
6
|
-
* paying (an EIP-3009 USDC authorization the facilitator relays, so the consumer
|
|
7
|
-
* spends no gas), then `settle`s with a zero-knowledge proof of membership from a
|
|
8
|
-
* fresh stealth address. The two steps are deliberately unlinkable: the address that
|
|
9
|
-
* paid and the address that reads are different, and only the group ties them.
|
|
10
|
-
*
|
|
11
|
-
* `isSettled(stealthAddress, resourceId)` is the question the access worker asks
|
|
12
|
-
* before releasing bytes. `getPrice(resourceId) === 0` means the resource is free.
|
|
13
|
-
*
|
|
14
|
-
* Generated from `cargo stylus export-abi --json`; the events are appended by hand
|
|
15
|
-
* because export-abi does not emit `sol!` event definitions.
|
|
16
|
-
*/
|
|
17
|
-
const SETTLEMENT_REGISTRY_ABI = [
|
|
18
|
-
{
|
|
19
|
-
"inputs": [
|
|
20
|
-
{
|
|
21
|
-
"internalType": "bytes32",
|
|
22
|
-
"name": "uid",
|
|
23
|
-
"type": "bytes32"
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"internalType": "uint256",
|
|
27
|
-
"name": "price",
|
|
28
|
-
"type": "uint256"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"internalType": "string",
|
|
32
|
-
"name": "uri",
|
|
33
|
-
"type": "string"
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
"name": "createResource",
|
|
37
|
-
"outputs": [{
|
|
38
|
-
"internalType": "bytes32",
|
|
39
|
-
"name": "",
|
|
40
|
-
"type": "bytes32"
|
|
41
|
-
}],
|
|
42
|
-
"stateMutability": "nonpayable",
|
|
43
|
-
"type": "function"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"inputs": [],
|
|
47
|
-
"name": "getAdmin",
|
|
48
|
-
"outputs": [{
|
|
49
|
-
"internalType": "address",
|
|
50
|
-
"name": "",
|
|
51
|
-
"type": "address"
|
|
52
|
-
}],
|
|
53
|
-
"stateMutability": "view",
|
|
54
|
-
"type": "function"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"inputs": [{
|
|
58
|
-
"internalType": "bytes32",
|
|
59
|
-
"name": "resource_id",
|
|
60
|
-
"type": "bytes32"
|
|
61
|
-
}],
|
|
62
|
-
"name": "getGroupId",
|
|
63
|
-
"outputs": [{
|
|
64
|
-
"internalType": "uint256",
|
|
65
|
-
"name": "",
|
|
66
|
-
"type": "uint256"
|
|
67
|
-
}],
|
|
68
|
-
"stateMutability": "view",
|
|
69
|
-
"type": "function"
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"inputs": [{
|
|
73
|
-
"internalType": "bytes32",
|
|
74
|
-
"name": "resource_id",
|
|
75
|
-
"type": "bytes32"
|
|
76
|
-
}],
|
|
77
|
-
"name": "getOwner",
|
|
78
|
-
"outputs": [{
|
|
79
|
-
"internalType": "address",
|
|
80
|
-
"name": "",
|
|
81
|
-
"type": "address"
|
|
82
|
-
}],
|
|
83
|
-
"stateMutability": "view",
|
|
84
|
-
"type": "function"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"inputs": [{
|
|
88
|
-
"internalType": "bytes32",
|
|
89
|
-
"name": "resource_id",
|
|
90
|
-
"type": "bytes32"
|
|
91
|
-
}],
|
|
92
|
-
"name": "getPrice",
|
|
93
|
-
"outputs": [{
|
|
94
|
-
"internalType": "uint256",
|
|
95
|
-
"name": "",
|
|
96
|
-
"type": "uint256"
|
|
97
|
-
}],
|
|
98
|
-
"stateMutability": "view",
|
|
99
|
-
"type": "function"
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
"inputs": [],
|
|
103
|
-
"name": "getSemaphore",
|
|
104
|
-
"outputs": [{
|
|
105
|
-
"internalType": "address",
|
|
106
|
-
"name": "",
|
|
107
|
-
"type": "address"
|
|
108
|
-
}],
|
|
109
|
-
"stateMutability": "view",
|
|
110
|
-
"type": "function"
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
"inputs": [{
|
|
114
|
-
"internalType": "bytes32",
|
|
115
|
-
"name": "resource_id",
|
|
116
|
-
"type": "bytes32"
|
|
117
|
-
}],
|
|
118
|
-
"name": "getUri",
|
|
119
|
-
"outputs": [{
|
|
120
|
-
"internalType": "string",
|
|
121
|
-
"name": "",
|
|
122
|
-
"type": "string"
|
|
123
|
-
}],
|
|
124
|
-
"stateMutability": "view",
|
|
125
|
-
"type": "function"
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
"inputs": [],
|
|
129
|
-
"name": "getUsdc",
|
|
130
|
-
"outputs": [{
|
|
131
|
-
"internalType": "address",
|
|
132
|
-
"name": "",
|
|
133
|
-
"type": "address"
|
|
134
|
-
}],
|
|
135
|
-
"stateMutability": "view",
|
|
136
|
-
"type": "function"
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
"inputs": [{
|
|
140
|
-
"internalType": "bytes32",
|
|
141
|
-
"name": "resource_id",
|
|
142
|
-
"type": "bytes32"
|
|
143
|
-
}],
|
|
144
|
-
"name": "isDisabled",
|
|
145
|
-
"outputs": [{
|
|
146
|
-
"internalType": "bool",
|
|
147
|
-
"name": "",
|
|
148
|
-
"type": "bool"
|
|
149
|
-
}],
|
|
150
|
-
"stateMutability": "view",
|
|
151
|
-
"type": "function"
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
"inputs": [{
|
|
155
|
-
"internalType": "bytes32",
|
|
156
|
-
"name": "resource_id",
|
|
157
|
-
"type": "bytes32"
|
|
158
|
-
}, {
|
|
159
|
-
"internalType": "uint256",
|
|
160
|
-
"name": "identity_commitment",
|
|
161
|
-
"type": "uint256"
|
|
162
|
-
}],
|
|
163
|
-
"name": "isRegistered",
|
|
164
|
-
"outputs": [{
|
|
165
|
-
"internalType": "bool",
|
|
166
|
-
"name": "",
|
|
167
|
-
"type": "bool"
|
|
168
|
-
}],
|
|
169
|
-
"stateMutability": "view",
|
|
170
|
-
"type": "function"
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
"inputs": [{
|
|
174
|
-
"internalType": "address",
|
|
175
|
-
"name": "stealth_address",
|
|
176
|
-
"type": "address"
|
|
177
|
-
}, {
|
|
178
|
-
"internalType": "bytes32",
|
|
179
|
-
"name": "resource_id",
|
|
180
|
-
"type": "bytes32"
|
|
181
|
-
}],
|
|
182
|
-
"name": "isSettled",
|
|
183
|
-
"outputs": [{
|
|
184
|
-
"internalType": "bool",
|
|
185
|
-
"name": "",
|
|
186
|
-
"type": "bool"
|
|
187
|
-
}],
|
|
188
|
-
"stateMutability": "view",
|
|
189
|
-
"type": "function"
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
"inputs": [
|
|
193
|
-
{
|
|
194
|
-
"internalType": "bytes32",
|
|
195
|
-
"name": "resource_id",
|
|
196
|
-
"type": "bytes32"
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
"internalType": "uint256",
|
|
200
|
-
"name": "identity_commitment",
|
|
201
|
-
"type": "uint256"
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
"internalType": "address",
|
|
205
|
-
"name": "from",
|
|
206
|
-
"type": "address"
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
"internalType": "uint256",
|
|
210
|
-
"name": "amount",
|
|
211
|
-
"type": "uint256"
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
"internalType": "uint256",
|
|
215
|
-
"name": "valid_after",
|
|
216
|
-
"type": "uint256"
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
"internalType": "uint256",
|
|
220
|
-
"name": "valid_before",
|
|
221
|
-
"type": "uint256"
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
"internalType": "bytes32",
|
|
225
|
-
"name": "nonce",
|
|
226
|
-
"type": "bytes32"
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
"internalType": "uint8",
|
|
230
|
-
"name": "v",
|
|
231
|
-
"type": "uint8"
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
"internalType": "bytes32",
|
|
235
|
-
"name": "r",
|
|
236
|
-
"type": "bytes32"
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
"internalType": "bytes32",
|
|
240
|
-
"name": "s",
|
|
241
|
-
"type": "bytes32"
|
|
242
|
-
}
|
|
243
|
-
],
|
|
244
|
-
"name": "register",
|
|
245
|
-
"outputs": [],
|
|
246
|
-
"stateMutability": "nonpayable",
|
|
247
|
-
"type": "function"
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
"inputs": [{
|
|
251
|
-
"internalType": "bytes32",
|
|
252
|
-
"name": "resource_id",
|
|
253
|
-
"type": "bytes32"
|
|
254
|
-
}, {
|
|
255
|
-
"internalType": "address",
|
|
256
|
-
"name": "hook",
|
|
257
|
-
"type": "address"
|
|
258
|
-
}],
|
|
259
|
-
"name": "registerHook",
|
|
260
|
-
"outputs": [],
|
|
261
|
-
"stateMutability": "nonpayable",
|
|
262
|
-
"type": "function"
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
"inputs": [{
|
|
266
|
-
"internalType": "address",
|
|
267
|
-
"name": "publisher",
|
|
268
|
-
"type": "address"
|
|
269
|
-
}, {
|
|
270
|
-
"internalType": "bytes32",
|
|
271
|
-
"name": "uid",
|
|
272
|
-
"type": "bytes32"
|
|
273
|
-
}],
|
|
274
|
-
"name": "resourceIdFor",
|
|
275
|
-
"outputs": [{
|
|
276
|
-
"internalType": "bytes32",
|
|
277
|
-
"name": "",
|
|
278
|
-
"type": "bytes32"
|
|
279
|
-
}],
|
|
280
|
-
"stateMutability": "view",
|
|
281
|
-
"type": "function"
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
"inputs": [{
|
|
285
|
-
"internalType": "address",
|
|
286
|
-
"name": "new_admin",
|
|
287
|
-
"type": "address"
|
|
288
|
-
}],
|
|
289
|
-
"name": "setAdmin",
|
|
290
|
-
"outputs": [],
|
|
291
|
-
"stateMutability": "nonpayable",
|
|
292
|
-
"type": "function"
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
"inputs": [{
|
|
296
|
-
"internalType": "bytes32",
|
|
297
|
-
"name": "resource_id",
|
|
298
|
-
"type": "bytes32"
|
|
299
|
-
}, {
|
|
300
|
-
"internalType": "bool",
|
|
301
|
-
"name": "disabled",
|
|
302
|
-
"type": "bool"
|
|
303
|
-
}],
|
|
304
|
-
"name": "setDisabled",
|
|
305
|
-
"outputs": [],
|
|
306
|
-
"stateMutability": "nonpayable",
|
|
307
|
-
"type": "function"
|
|
308
|
-
},
|
|
309
|
-
{
|
|
310
|
-
"inputs": [
|
|
311
|
-
{
|
|
312
|
-
"internalType": "bytes32",
|
|
313
|
-
"name": "resource_id",
|
|
314
|
-
"type": "bytes32"
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
"internalType": "address",
|
|
318
|
-
"name": "stealth_address",
|
|
319
|
-
"type": "address"
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
"internalType": "uint256",
|
|
323
|
-
"name": "merkle_tree_depth",
|
|
324
|
-
"type": "uint256"
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
"internalType": "uint256",
|
|
328
|
-
"name": "merkle_tree_root",
|
|
329
|
-
"type": "uint256"
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
"internalType": "uint256",
|
|
333
|
-
"name": "nullifier",
|
|
334
|
-
"type": "uint256"
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
"internalType": "uint256",
|
|
338
|
-
"name": "message",
|
|
339
|
-
"type": "uint256"
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
"internalType": "uint256[8]",
|
|
343
|
-
"name": "points",
|
|
344
|
-
"type": "uint256[8]"
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
"internalType": "uint8[]",
|
|
348
|
-
"name": "hook_data",
|
|
349
|
-
"type": "uint8[]"
|
|
350
|
-
}
|
|
351
|
-
],
|
|
352
|
-
"name": "settle",
|
|
353
|
-
"outputs": [],
|
|
354
|
-
"stateMutability": "nonpayable",
|
|
355
|
-
"type": "function"
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
"inputs": [{
|
|
359
|
-
"internalType": "bytes32",
|
|
360
|
-
"name": "resource_id",
|
|
361
|
-
"type": "bytes32"
|
|
362
|
-
}, {
|
|
363
|
-
"internalType": "uint256",
|
|
364
|
-
"name": "price",
|
|
365
|
-
"type": "uint256"
|
|
366
|
-
}],
|
|
367
|
-
"name": "updatePrice",
|
|
368
|
-
"outputs": [],
|
|
369
|
-
"stateMutability": "nonpayable",
|
|
370
|
-
"type": "function"
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
"type": "event",
|
|
374
|
-
"name": "ResourceCreated",
|
|
375
|
-
"anonymous": false,
|
|
376
|
-
"inputs": [
|
|
377
|
-
{
|
|
378
|
-
"type": "bytes32",
|
|
379
|
-
"name": "resourceId",
|
|
380
|
-
"internalType": "bytes32",
|
|
381
|
-
"indexed": true
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
"type": "address",
|
|
385
|
-
"name": "owner",
|
|
386
|
-
"internalType": "address",
|
|
387
|
-
"indexed": false
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
"type": "uint256",
|
|
391
|
-
"name": "price",
|
|
392
|
-
"internalType": "uint256",
|
|
393
|
-
"indexed": false
|
|
394
|
-
},
|
|
395
|
-
{
|
|
396
|
-
"type": "uint256",
|
|
397
|
-
"name": "groupId",
|
|
398
|
-
"internalType": "uint256",
|
|
399
|
-
"indexed": false
|
|
400
|
-
},
|
|
401
|
-
{
|
|
402
|
-
"type": "string",
|
|
403
|
-
"name": "uri",
|
|
404
|
-
"internalType": "string",
|
|
405
|
-
"indexed": false
|
|
406
|
-
}
|
|
407
|
-
]
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
"type": "event",
|
|
411
|
-
"name": "MemberRegistered",
|
|
412
|
-
"anonymous": false,
|
|
413
|
-
"inputs": [{
|
|
414
|
-
"type": "bytes32",
|
|
415
|
-
"name": "resourceId",
|
|
416
|
-
"internalType": "bytes32",
|
|
417
|
-
"indexed": true
|
|
418
|
-
}, {
|
|
419
|
-
"type": "uint256",
|
|
420
|
-
"name": "identityCommitment",
|
|
421
|
-
"internalType": "uint256",
|
|
422
|
-
"indexed": false
|
|
423
|
-
}]
|
|
424
|
-
},
|
|
425
|
-
{
|
|
426
|
-
"type": "event",
|
|
427
|
-
"name": "SettlementFinalized",
|
|
428
|
-
"anonymous": false,
|
|
429
|
-
"inputs": [
|
|
430
|
-
{
|
|
431
|
-
"type": "bytes32",
|
|
432
|
-
"name": "resourceId",
|
|
433
|
-
"internalType": "bytes32",
|
|
434
|
-
"indexed": true
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
"type": "uint256",
|
|
438
|
-
"name": "nullifierHash",
|
|
439
|
-
"internalType": "uint256",
|
|
440
|
-
"indexed": true
|
|
441
|
-
},
|
|
442
|
-
{
|
|
443
|
-
"type": "uint256",
|
|
444
|
-
"name": "message",
|
|
445
|
-
"internalType": "uint256",
|
|
446
|
-
"indexed": false
|
|
447
|
-
}
|
|
448
|
-
]
|
|
449
|
-
},
|
|
450
|
-
{
|
|
451
|
-
"type": "event",
|
|
452
|
-
"name": "PriceUpdated",
|
|
453
|
-
"anonymous": false,
|
|
454
|
-
"inputs": [
|
|
455
|
-
{
|
|
456
|
-
"type": "bytes32",
|
|
457
|
-
"name": "resourceId",
|
|
458
|
-
"internalType": "bytes32",
|
|
459
|
-
"indexed": true
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
"type": "address",
|
|
463
|
-
"name": "owner",
|
|
464
|
-
"internalType": "address",
|
|
465
|
-
"indexed": false
|
|
466
|
-
},
|
|
467
|
-
{
|
|
468
|
-
"type": "uint256",
|
|
469
|
-
"name": "price",
|
|
470
|
-
"internalType": "uint256",
|
|
471
|
-
"indexed": false
|
|
472
|
-
}
|
|
473
|
-
]
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
"type": "event",
|
|
477
|
-
"name": "ResourceDisabled",
|
|
478
|
-
"anonymous": false,
|
|
479
|
-
"inputs": [
|
|
480
|
-
{
|
|
481
|
-
"type": "bytes32",
|
|
482
|
-
"name": "resourceId",
|
|
483
|
-
"internalType": "bytes32",
|
|
484
|
-
"indexed": true
|
|
485
|
-
},
|
|
486
|
-
{
|
|
487
|
-
"type": "bool",
|
|
488
|
-
"name": "disabled",
|
|
489
|
-
"internalType": "bool",
|
|
490
|
-
"indexed": false
|
|
491
|
-
},
|
|
492
|
-
{
|
|
493
|
-
"type": "address",
|
|
494
|
-
"name": "by",
|
|
495
|
-
"internalType": "address",
|
|
496
|
-
"indexed": false
|
|
497
|
-
}
|
|
498
|
-
]
|
|
499
|
-
},
|
|
500
|
-
{
|
|
501
|
-
"type": "event",
|
|
502
|
-
"name": "HookRegistered",
|
|
503
|
-
"anonymous": false,
|
|
504
|
-
"inputs": [{
|
|
505
|
-
"type": "bytes32",
|
|
506
|
-
"name": "resourceId",
|
|
507
|
-
"internalType": "bytes32",
|
|
508
|
-
"indexed": true
|
|
509
|
-
}, {
|
|
510
|
-
"type": "address",
|
|
511
|
-
"name": "hook",
|
|
512
|
-
"internalType": "address",
|
|
513
|
-
"indexed": false
|
|
514
|
-
}]
|
|
515
|
-
},
|
|
516
|
-
{
|
|
517
|
-
"type": "event",
|
|
518
|
-
"name": "AdminChanged",
|
|
519
|
-
"anonymous": false,
|
|
520
|
-
"inputs": [{
|
|
521
|
-
"type": "address",
|
|
522
|
-
"name": "previousAdmin",
|
|
523
|
-
"internalType": "address",
|
|
524
|
-
"indexed": false
|
|
525
|
-
}, {
|
|
526
|
-
"type": "address",
|
|
527
|
-
"name": "newAdmin",
|
|
528
|
-
"internalType": "address",
|
|
529
|
-
"indexed": false
|
|
530
|
-
}]
|
|
531
|
-
}
|
|
532
|
-
];
|
|
533
|
-
|
|
534
|
-
//#endregion
|
|
535
|
-
export { SETTLEMENT_REGISTRY_ABI };
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { Address, Hash, Hex, PublicClient, WalletClient } from "viem";
|
|
2
|
-
|
|
3
|
-
//#region src/contracts/settlement-registry/index.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* `keccak256(publisher ++ uid)` — the same derivation the registry does in
|
|
7
|
-
* `resource_id_of`, and the same one `resourceIdOf` in `@fangorn-network/fetch`
|
|
8
|
-
* does on the buyer side. Pinned against the deployed contract by an e2e case.
|
|
9
|
-
*
|
|
10
|
-
* The id is derived rather than chosen, so a uid cannot be squatted or
|
|
11
|
-
* front-run. Deriving it locally means a publisher knows the id before
|
|
12
|
-
* `createResource` lands, and a buyer needs no RPC to name what they are buying;
|
|
13
|
-
* `resourceIdFor` asks the chain the same question and exists for parity checks.
|
|
14
|
-
*/
|
|
15
|
-
declare const resourceIdOf: (publisher: Address, uid: Hex) => Hex;
|
|
16
|
-
/**
|
|
17
|
-
* The on-chain `uri` is not free-form: it packs the access worker to fetch from
|
|
18
|
-
* and the sha256 of the plaintext to verify against, as `${workerUrl}#${hash}`.
|
|
19
|
-
*
|
|
20
|
-
* The hash is what makes a read more than a download — without it a worker can
|
|
21
|
-
* serve any bytes that happen to decrypt. `unpackUri` in `@fangorn-network/fetch`
|
|
22
|
-
* is the other side of this, and a publisher who lists a bare URL produces a
|
|
23
|
-
* resource that buyer cannot verify.
|
|
24
|
-
*/
|
|
25
|
-
declare const packResourceUri: (workerUrl: string, plaintextHash: Hex) => string;
|
|
26
|
-
/** Everything the registry knows about a priced resource. */
|
|
27
|
-
interface Resource {
|
|
28
|
-
owner: Address;
|
|
29
|
-
/** In the settlement token's smallest unit. Zero means free. */
|
|
30
|
-
price: bigint;
|
|
31
|
-
/** The Semaphore group minted for this resource when it was created. */
|
|
32
|
-
groupId: bigint;
|
|
33
|
-
uri: string;
|
|
34
|
-
disabled: boolean;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* An EIP-3009 `transferWithAuthorization` signature: what lets a consumer pay in
|
|
38
|
-
* USDC without ever holding gas, because someone else relays it for them.
|
|
39
|
-
*/
|
|
40
|
-
interface TransferAuthorization {
|
|
41
|
-
from: Address;
|
|
42
|
-
amount: bigint;
|
|
43
|
-
validAfter: bigint;
|
|
44
|
-
validBefore: bigint;
|
|
45
|
-
nonce: Hex;
|
|
46
|
-
v: number;
|
|
47
|
-
r: Hex;
|
|
48
|
-
s: Hex;
|
|
49
|
-
}
|
|
50
|
-
/** A Semaphore membership proof, as the contract wants it. */
|
|
51
|
-
interface SemaphoreProof {
|
|
52
|
-
merkleTreeDepth: bigint;
|
|
53
|
-
merkleTreeRoot: bigint;
|
|
54
|
-
nullifier: bigint;
|
|
55
|
-
message: bigint;
|
|
56
|
-
/** The eight field elements of the Groth16 proof. */
|
|
57
|
-
points: readonly [bigint, bigint, bigint, bigint, bigint, bigint, bigint, bigint];
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Client for the SettlementRegistry — the pay-then-read rail.
|
|
61
|
-
*
|
|
62
|
-
* The two consumer calls are separate on purpose, and the separation is the whole
|
|
63
|
-
* privacy property:
|
|
64
|
-
*
|
|
65
|
-
* 1. `register` — pay for `resourceId` and join its Semaphore group with an
|
|
66
|
-
* identity commitment. This transaction is linked to the payer.
|
|
67
|
-
* 2. `settle` — prove group membership in zero knowledge from a *fresh stealth
|
|
68
|
-
* address*, which is then the address `isSettled` answers for.
|
|
69
|
-
*
|
|
70
|
-
* Nothing on-chain connects the payer to the reader beyond membership of the same
|
|
71
|
-
* group, so a publisher can verify a reader paid without learning who they are.
|
|
72
|
-
* Both are normally relayed by a facilitator, so the consumer needs no gas at all —
|
|
73
|
-
* which is why `register` takes a signed authorization rather than moving funds
|
|
74
|
-
* from `msg.sender`.
|
|
75
|
-
*
|
|
76
|
-
* Constructing without a wallet client gives a read-only client: that is the access
|
|
77
|
-
* worker's usage, which only ever asks `isSettled` and `getPrice`.
|
|
78
|
-
*
|
|
79
|
-
* The publisher half of the flow is here. The BUYER half — deriving a Semaphore
|
|
80
|
-
* identity, signing the EIP-3009 authorization, rebuilding the resource's group
|
|
81
|
-
* from `MemberRegistered` logs and proving membership — already lives in
|
|
82
|
-
* `@fangorn-network/fetch` (x402f), which relays both writes through a facilitator
|
|
83
|
-
* so the buyer never needs gas. Do not reimplement it here: this SDK deliberately
|
|
84
|
-
* carries no Semaphore proving dependency (see the note in the wiki's gotchas).
|
|
85
|
-
*/
|
|
86
|
-
declare class SettlementRegistryClient {
|
|
87
|
-
private contractAddress;
|
|
88
|
-
private publicClient;
|
|
89
|
-
private walletClient?;
|
|
90
|
-
constructor(contractAddress: Address, publicClient: PublicClient, walletClient?: WalletClient | undefined);
|
|
91
|
-
getAddress(): Address;
|
|
92
|
-
private executeWrite;
|
|
93
|
-
/**
|
|
94
|
-
* List a resource for sale and mint its Semaphore group in one transaction.
|
|
95
|
-
*
|
|
96
|
-
* `uid` is the publisher's own identifier for the item; the on-chain
|
|
97
|
-
* `resourceId` is `resourceIdFor(owner, uid)`, so two publishers can use the
|
|
98
|
-
* same uid without collision and a publisher can compute the id before the
|
|
99
|
-
* transaction lands. Claiming the same uid twice reverts `AlreadyRegistered`.
|
|
100
|
-
*/
|
|
101
|
-
createResource(uid: Hex, price: bigint, uri: string): Promise<Hash>;
|
|
102
|
-
/** Reprice a resource. Does not affect anyone who already settled. */
|
|
103
|
-
updatePrice(resourceId: Hex, price: bigint): Promise<Hash>;
|
|
104
|
-
/**
|
|
105
|
-
* Take a resource off the market. Existing settlements still read — disabling
|
|
106
|
-
* blocks new registrations, it does not revoke access that was paid for.
|
|
107
|
-
*/
|
|
108
|
-
setDisabled(resourceId: Hex, disabled: boolean): Promise<Hash>;
|
|
109
|
-
/**
|
|
110
|
-
* Attach a contract called after each successful `settle`.
|
|
111
|
-
*
|
|
112
|
-
* No funds pass through it and it cannot change the payment: it fires after
|
|
113
|
-
* settlement is already recorded, and a revert inside it surfaces as
|
|
114
|
-
* `HookFailed`. It is a notification, not a fee lever.
|
|
115
|
-
*/
|
|
116
|
-
registerHook(resourceId: Hex, hook: Address): Promise<Hash>;
|
|
117
|
-
/**
|
|
118
|
-
* Step 1: pay for `resourceId` and join its group.
|
|
119
|
-
*
|
|
120
|
-
* The USDC moves via the caller's EIP-3009 authorization, not from
|
|
121
|
-
* `msg.sender`, so this is safe (and intended) to relay. `amount` must equal
|
|
122
|
-
* the current price exactly, or it reverts `IncorrectPaymentAmount` — quote
|
|
123
|
-
* `getPrice` immediately before signing, since the owner can reprice.
|
|
124
|
-
*/
|
|
125
|
-
register(resourceId: Hex, identityCommitment: bigint, auth: TransferAuthorization): Promise<Hash>;
|
|
126
|
-
/**
|
|
127
|
-
* Step 2: prove membership from `stealthAddress`, which is the address
|
|
128
|
-
* `isSettled` will answer for afterwards.
|
|
129
|
-
*
|
|
130
|
-
* The proof's nullifier makes this once-per-identity: a second settle reverts
|
|
131
|
-
* `AlreadySettled`. Send it from an address with no history, or the
|
|
132
|
-
* unlinkability that `register`/`settle` exist to provide is spent for nothing.
|
|
133
|
-
*
|
|
134
|
-
* `hookData` is `uint8[]`, not `bytes` — the contract declares it `Vec<u8>`, and
|
|
135
|
-
* Stylus maps that to a dynamic array of words. Every byte costs a full 32-byte
|
|
136
|
-
* slot in calldata, so keep it empty unless a hook actually reads it.
|
|
137
|
-
*/
|
|
138
|
-
settle(resourceId: Hex, stealthAddress: Address, proof: SemaphoreProof, hookData?: readonly number[]): Promise<Hash>;
|
|
139
|
-
/** True if `stealthAddress` has settled for `resourceId`. */
|
|
140
|
-
isSettled(stealthAddress: Address, resourceId: Hex): Promise<boolean>;
|
|
141
|
-
/** Price of `resourceId` in the settlement token's smallest unit; 0 = free. */
|
|
142
|
-
getPrice(resourceId: Hex): Promise<bigint>;
|
|
143
|
-
/** The id a `uid` will get under `publisher` — computable before listing. */
|
|
144
|
-
resourceIdFor(publisher: Address, uid: Hex): Promise<Hex>;
|
|
145
|
-
/** Whether this identity commitment already joined the resource's group. */
|
|
146
|
-
isRegistered(resourceId: Hex, identityCommitment: bigint): Promise<boolean>;
|
|
147
|
-
getOwner(resourceId: Hex): Promise<Address>;
|
|
148
|
-
getGroupId(resourceId: Hex): Promise<bigint>;
|
|
149
|
-
getUri(resourceId: Hex): Promise<string>;
|
|
150
|
-
isDisabled(resourceId: Hex): Promise<boolean>;
|
|
151
|
-
/**
|
|
152
|
-
* Everything a listing page needs, in one round trip. An unlisted resource
|
|
153
|
-
* comes back with a zero owner rather than throwing — `getPrice` alone cannot
|
|
154
|
-
* tell "free" from "does not exist".
|
|
155
|
-
*/
|
|
156
|
-
getResource(resourceId: Hex): Promise<Resource>;
|
|
157
|
-
getUsdc(): Promise<Address>;
|
|
158
|
-
getSemaphore(): Promise<Address>;
|
|
159
|
-
getAdmin(): Promise<Address>;
|
|
160
|
-
setAdmin(admin: Address): Promise<Hash>;
|
|
161
|
-
}
|
|
162
|
-
//#endregion
|
|
163
|
-
export { Resource, SemaphoreProof, SettlementRegistryClient, TransferAuthorization, packResourceUri, resourceIdOf };
|