@fangorn-network/sdk 2026.3.28 → 2026.4.7
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 +24 -31
- package/lib/cli/cli.d.ts +0 -0
- package/lib/cli/index.d.ts +159 -159
- package/lib/fangorn.js +1 -1
- package/lib/registries/datasource-registry/index.d.ts +2 -2
- package/lib/registries/schema-registry/index.d.ts +2 -2
- package/lib/registries/settlement-registry/index.d.ts +2 -2
- package/lib/roles/publisher/index.d.ts +11 -3
- package/lib/roles/publisher/index.js +29 -6
- package/lib/roles/publisher/types.d.ts +1 -7
- package/lib/test/testbed.d.ts +1 -1
- package/lib/test/testbed.js +7 -6
- package/package.json +72 -85
package/README.md
CHANGED
|
@@ -123,11 +123,11 @@ const fangorn = await Fangorn.create({
|
|
|
123
123
|
|
|
124
124
|
**Storage options:**
|
|
125
125
|
|
|
126
|
-
| Config
|
|
127
|
-
|
|
128
|
-
| `{ pinata: { jwt, gateway } }`
|
|
129
|
-
| `{ storacha: { email } }`
|
|
130
|
-
| `{ storacha: { readOnly: true } }` | Read only
|
|
126
|
+
| Config | Mode |
|
|
127
|
+
| ---------------------------------- | ------------ |
|
|
128
|
+
| `{ pinata: { jwt, gateway } }` | Read + write |
|
|
129
|
+
| `{ storacha: { email } }` | Read + write |
|
|
130
|
+
| `{ storacha: { readOnly: true } }` | Read only |
|
|
131
131
|
|
|
132
132
|
### Schemas
|
|
133
133
|
|
|
@@ -210,22 +210,15 @@ import { SettlementRegistry } from "@fangorn-network/sdk/registries";
|
|
|
210
210
|
|
|
211
211
|
const owner = fangorn.getAddress();
|
|
212
212
|
|
|
213
|
+
// Default gadget = payment settled
|
|
213
214
|
await fangorn.publisher.upload(
|
|
214
215
|
{
|
|
215
216
|
records: [
|
|
216
217
|
{ tag: "track1", field: "audio", data: audioBytes, extension: ".mp3", fileType: "audio/mpeg" },
|
|
217
218
|
{ tag: "track1", field: "cover", data: imageBytes, extension: ".png", fileType: "image/png" },
|
|
218
219
|
],
|
|
219
|
-
|
|
220
|
-
schemaId,
|
|
220
|
+
schemaName: 'schema.name.v1'
|
|
221
221
|
gateway: "https://your-gateway.mypinata.cloud",
|
|
222
|
-
gadgetFactory: (tag) =>
|
|
223
|
-
new SettledGadget({
|
|
224
|
-
resourceId: SettlementRegistry.deriveResourceId(owner, schemaId, tag),
|
|
225
|
-
settlementRegistryAddress: FangornConfig.ArbitrumSepolia.settlementRegistryContractAddress,
|
|
226
|
-
chainName: "arbitrumSepolia",
|
|
227
|
-
pinataJwt: "...",
|
|
228
|
-
}),
|
|
229
222
|
},
|
|
230
223
|
1n, // price in smallest USDC units
|
|
231
224
|
);
|
|
@@ -313,8 +306,8 @@ const plaintext = await fangorn.consumer.decrypt({
|
|
|
313
306
|
|
|
314
307
|
Gadgets define the access control condition baked into encryption. Built-in gadgets:
|
|
315
308
|
|
|
316
|
-
| Gadget
|
|
317
|
-
|
|
309
|
+
| Gadget | Condition |
|
|
310
|
+
| --------------- | --------------------------------------------------- |
|
|
318
311
|
| `SettledGadget` | Caller must complete a USDC payment + ZK claim flow |
|
|
319
312
|
|
|
320
313
|
More coming soon ;)
|
|
@@ -327,10 +320,10 @@ See the [gadgets](./src/modules/gadgets/README.md) docs for details on implement
|
|
|
327
320
|
|
|
328
321
|
### Arbitrum Sepolia
|
|
329
322
|
|
|
330
|
-
| Contract
|
|
331
|
-
|
|
323
|
+
| Contract | Address |
|
|
324
|
+
| ------------------- | -------------------------------------------- |
|
|
332
325
|
| DataSource Registry | `0x3941c7d50caa56f7f676554bc4e78d77aaf27ebb` |
|
|
333
|
-
| Schema Registry
|
|
326
|
+
| Schema Registry | `0x49ab3d52b997e63ad56c91178df48263fd80b2dc` |
|
|
334
327
|
| Settlement Registry | `0x4536881306ee355c2f18ae81658771c4488139a3` |
|
|
335
328
|
|
|
336
329
|
---
|
|
@@ -354,19 +347,19 @@ pnpm test:e2e
|
|
|
354
347
|
|
|
355
348
|
Required variables:
|
|
356
349
|
|
|
357
|
-
| Variable
|
|
358
|
-
|
|
350
|
+
| Variable | Description |
|
|
351
|
+
| --------------------------- | ----------------------------------------- |
|
|
359
352
|
| `DELEGATOR_ETH_PRIVATE_KEY` | Publisher private key (needs testnet ETH) |
|
|
360
|
-
| `DELEGATEE_ETH_PRIVATE_KEY` | Consumer private key
|
|
361
|
-
| `PINATA_JWT`
|
|
362
|
-
| `PINATA_GATEWAY`
|
|
363
|
-
| `CHAIN_NAME`
|
|
364
|
-
| `CAIP2`
|
|
365
|
-
| `CHAIN_RPC_URL`
|
|
366
|
-
| `USDC_CONTRACT_ADDRESS`
|
|
367
|
-
| `DS_REGISTRY_ADDR`
|
|
368
|
-
| `SCHEMA_REGISTRY_ADDR`
|
|
369
|
-
| `SETTLEMENT_TRACKER_ADDR`
|
|
353
|
+
| `DELEGATEE_ETH_PRIVATE_KEY` | Consumer private key |
|
|
354
|
+
| `PINATA_JWT` | Pinata API JWT |
|
|
355
|
+
| `PINATA_GATEWAY` | Pinata gateway URL |
|
|
356
|
+
| `CHAIN_NAME` | `arbitrumSepolia` |
|
|
357
|
+
| `CAIP2` | `421614` |
|
|
358
|
+
| `CHAIN_RPC_URL` | RPC endpoint |
|
|
359
|
+
| `USDC_CONTRACT_ADDRESS` | USDC contract address |
|
|
360
|
+
| `DS_REGISTRY_ADDR` | DataSourceRegistry address |
|
|
361
|
+
| `SCHEMA_REGISTRY_ADDR` | SchemaRegistry address |
|
|
362
|
+
| `SETTLEMENT_TRACKER_ADDR` | SettlementTracker address |
|
|
370
363
|
|
|
371
364
|
Sample `.env` for Arbitrum Sepolia:
|
|
372
365
|
|
package/lib/cli/cli.d.ts
CHANGED
|
File without changes
|
package/lib/cli/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./cli.js";
|
|
2
2
|
import * as viem_chains14 from "viem/chains";
|
|
3
|
-
import * as
|
|
3
|
+
import * as viem259 from "viem";
|
|
4
4
|
|
|
5
5
|
//#region src/cli/index.d.ts
|
|
6
6
|
declare const getChain: (chainStr: string) => {
|
|
@@ -36,17 +36,17 @@ declare const getChain: (chainStr: string) => {
|
|
|
36
36
|
testnet: true;
|
|
37
37
|
custom?: Record<string, unknown> | undefined;
|
|
38
38
|
extendSchema?: Record<string, unknown> | undefined;
|
|
39
|
-
fees?:
|
|
39
|
+
fees?: viem259.ChainFees<undefined> | undefined;
|
|
40
40
|
formatters?: undefined;
|
|
41
|
-
prepareTransactionRequest?: ((args:
|
|
41
|
+
prepareTransactionRequest?: ((args: viem259.PrepareTransactionRequestParameters, options: {
|
|
42
42
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
43
|
-
}) => Promise<
|
|
43
|
+
}) => Promise<viem259.PrepareTransactionRequestParameters>) | [fn: ((args: viem259.PrepareTransactionRequestParameters, options: {
|
|
44
44
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
45
|
-
}) => Promise<
|
|
45
|
+
}) => Promise<viem259.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
46
46
|
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
47
47
|
}] | undefined;
|
|
48
|
-
serializers?:
|
|
49
|
-
verifyHash?: ((client:
|
|
48
|
+
serializers?: viem259.ChainSerializers<undefined, viem259.TransactionSerializable> | undefined;
|
|
49
|
+
verifyHash?: ((client: viem259.Client, parameters: viem259.VerifyHashActionParameters) => Promise<viem259.VerifyHashActionReturnType>) | undefined;
|
|
50
50
|
} | {
|
|
51
51
|
blockExplorers: {
|
|
52
52
|
readonly default: {
|
|
@@ -120,7 +120,7 @@ declare const getChain: (chainStr: string) => {
|
|
|
120
120
|
testnet: true;
|
|
121
121
|
custom?: Record<string, unknown> | undefined;
|
|
122
122
|
extendSchema?: Record<string, unknown> | undefined;
|
|
123
|
-
fees?:
|
|
123
|
+
fees?: viem259.ChainFees<undefined> | undefined;
|
|
124
124
|
formatters: {
|
|
125
125
|
readonly block: {
|
|
126
126
|
exclude: [] | undefined;
|
|
@@ -129,28 +129,28 @@ declare const getChain: (chainStr: string) => {
|
|
|
129
129
|
blobGasUsed: bigint;
|
|
130
130
|
difficulty: bigint;
|
|
131
131
|
excessBlobGas: bigint;
|
|
132
|
-
extraData:
|
|
132
|
+
extraData: viem259.Hex;
|
|
133
133
|
gasLimit: bigint;
|
|
134
134
|
gasUsed: bigint;
|
|
135
135
|
hash: `0x${string}` | null;
|
|
136
136
|
logsBloom: `0x${string}` | null;
|
|
137
|
-
miner:
|
|
138
|
-
mixHash:
|
|
137
|
+
miner: viem259.Address;
|
|
138
|
+
mixHash: viem259.Hash;
|
|
139
139
|
nonce: `0x${string}` | null;
|
|
140
140
|
number: bigint | null;
|
|
141
141
|
parentBeaconBlockRoot?: `0x${string}` | undefined;
|
|
142
|
-
parentHash:
|
|
143
|
-
receiptsRoot:
|
|
144
|
-
sealFields:
|
|
145
|
-
sha3Uncles:
|
|
142
|
+
parentHash: viem259.Hash;
|
|
143
|
+
receiptsRoot: viem259.Hex;
|
|
144
|
+
sealFields: viem259.Hex[];
|
|
145
|
+
sha3Uncles: viem259.Hash;
|
|
146
146
|
size: bigint;
|
|
147
|
-
stateRoot:
|
|
147
|
+
stateRoot: viem259.Hash;
|
|
148
148
|
timestamp: bigint;
|
|
149
149
|
totalDifficulty: bigint | null;
|
|
150
150
|
transactions: `0x${string}`[] | viem_chains14.OpStackTransaction<boolean>[];
|
|
151
|
-
transactionsRoot:
|
|
152
|
-
uncles:
|
|
153
|
-
withdrawals?:
|
|
151
|
+
transactionsRoot: viem259.Hash;
|
|
152
|
+
uncles: viem259.Hash[];
|
|
153
|
+
withdrawals?: viem259.Withdrawal[] | undefined | undefined;
|
|
154
154
|
withdrawalsRoot?: `0x${string}` | undefined;
|
|
155
155
|
} & {};
|
|
156
156
|
type: "block";
|
|
@@ -160,16 +160,16 @@ declare const getChain: (chainStr: string) => {
|
|
|
160
160
|
format: (args: viem_chains14.OpStackRpcTransaction, action?: string | undefined) => ({
|
|
161
161
|
blockHash: `0x${string}` | null;
|
|
162
162
|
blockNumber: bigint | null;
|
|
163
|
-
from:
|
|
163
|
+
from: viem259.Address;
|
|
164
164
|
gas: bigint;
|
|
165
|
-
hash:
|
|
166
|
-
input:
|
|
165
|
+
hash: viem259.Hash;
|
|
166
|
+
input: viem259.Hex;
|
|
167
167
|
nonce: number;
|
|
168
|
-
r:
|
|
169
|
-
s:
|
|
170
|
-
to:
|
|
168
|
+
r: viem259.Hex;
|
|
169
|
+
s: viem259.Hex;
|
|
170
|
+
to: viem259.Address | null;
|
|
171
171
|
transactionIndex: number | null;
|
|
172
|
-
typeHex:
|
|
172
|
+
typeHex: viem259.Hex | null;
|
|
173
173
|
v: bigint;
|
|
174
174
|
value: bigint;
|
|
175
175
|
yParity: number;
|
|
@@ -179,23 +179,23 @@ declare const getChain: (chainStr: string) => {
|
|
|
179
179
|
maxPriorityFeePerGas: bigint;
|
|
180
180
|
isSystemTx?: boolean;
|
|
181
181
|
mint?: bigint | undefined | undefined;
|
|
182
|
-
sourceHash:
|
|
182
|
+
sourceHash: viem259.Hex;
|
|
183
183
|
type: "deposit";
|
|
184
184
|
} | {
|
|
185
|
-
r:
|
|
186
|
-
s:
|
|
185
|
+
r: viem259.Hex;
|
|
186
|
+
s: viem259.Hex;
|
|
187
187
|
v: bigint;
|
|
188
|
-
to:
|
|
189
|
-
from:
|
|
188
|
+
to: viem259.Address | null;
|
|
189
|
+
from: viem259.Address;
|
|
190
190
|
gas: bigint;
|
|
191
191
|
nonce: number;
|
|
192
192
|
value: bigint;
|
|
193
193
|
blockHash: `0x${string}` | null;
|
|
194
194
|
blockNumber: bigint | null;
|
|
195
|
-
hash:
|
|
196
|
-
input:
|
|
195
|
+
hash: viem259.Hash;
|
|
196
|
+
input: viem259.Hex;
|
|
197
197
|
transactionIndex: number | null;
|
|
198
|
-
typeHex:
|
|
198
|
+
typeHex: viem259.Hex | null;
|
|
199
199
|
accessList?: undefined | undefined;
|
|
200
200
|
authorizationList?: undefined | undefined;
|
|
201
201
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -212,20 +212,20 @@ declare const getChain: (chainStr: string) => {
|
|
|
212
212
|
} | {
|
|
213
213
|
blockHash: `0x${string}` | null;
|
|
214
214
|
blockNumber: bigint | null;
|
|
215
|
-
from:
|
|
215
|
+
from: viem259.Address;
|
|
216
216
|
gas: bigint;
|
|
217
|
-
hash:
|
|
218
|
-
input:
|
|
217
|
+
hash: viem259.Hash;
|
|
218
|
+
input: viem259.Hex;
|
|
219
219
|
nonce: number;
|
|
220
|
-
r:
|
|
221
|
-
s:
|
|
222
|
-
to:
|
|
220
|
+
r: viem259.Hex;
|
|
221
|
+
s: viem259.Hex;
|
|
222
|
+
to: viem259.Address | null;
|
|
223
223
|
transactionIndex: number | null;
|
|
224
|
-
typeHex:
|
|
224
|
+
typeHex: viem259.Hex | null;
|
|
225
225
|
v: bigint;
|
|
226
226
|
value: bigint;
|
|
227
227
|
yParity: number;
|
|
228
|
-
accessList:
|
|
228
|
+
accessList: viem259.AccessList;
|
|
229
229
|
authorizationList?: undefined | undefined;
|
|
230
230
|
blobVersionedHashes?: undefined | undefined;
|
|
231
231
|
chainId: number;
|
|
@@ -240,20 +240,20 @@ declare const getChain: (chainStr: string) => {
|
|
|
240
240
|
} | {
|
|
241
241
|
blockHash: `0x${string}` | null;
|
|
242
242
|
blockNumber: bigint | null;
|
|
243
|
-
from:
|
|
243
|
+
from: viem259.Address;
|
|
244
244
|
gas: bigint;
|
|
245
|
-
hash:
|
|
246
|
-
input:
|
|
245
|
+
hash: viem259.Hash;
|
|
246
|
+
input: viem259.Hex;
|
|
247
247
|
nonce: number;
|
|
248
|
-
r:
|
|
249
|
-
s:
|
|
250
|
-
to:
|
|
248
|
+
r: viem259.Hex;
|
|
249
|
+
s: viem259.Hex;
|
|
250
|
+
to: viem259.Address | null;
|
|
251
251
|
transactionIndex: number | null;
|
|
252
|
-
typeHex:
|
|
252
|
+
typeHex: viem259.Hex | null;
|
|
253
253
|
v: bigint;
|
|
254
254
|
value: bigint;
|
|
255
255
|
yParity: number;
|
|
256
|
-
accessList:
|
|
256
|
+
accessList: viem259.AccessList;
|
|
257
257
|
authorizationList?: undefined | undefined;
|
|
258
258
|
blobVersionedHashes?: undefined | undefined;
|
|
259
259
|
chainId: number;
|
|
@@ -268,22 +268,22 @@ declare const getChain: (chainStr: string) => {
|
|
|
268
268
|
} | {
|
|
269
269
|
blockHash: `0x${string}` | null;
|
|
270
270
|
blockNumber: bigint | null;
|
|
271
|
-
from:
|
|
271
|
+
from: viem259.Address;
|
|
272
272
|
gas: bigint;
|
|
273
|
-
hash:
|
|
274
|
-
input:
|
|
273
|
+
hash: viem259.Hash;
|
|
274
|
+
input: viem259.Hex;
|
|
275
275
|
nonce: number;
|
|
276
|
-
r:
|
|
277
|
-
s:
|
|
278
|
-
to:
|
|
276
|
+
r: viem259.Hex;
|
|
277
|
+
s: viem259.Hex;
|
|
278
|
+
to: viem259.Address | null;
|
|
279
279
|
transactionIndex: number | null;
|
|
280
|
-
typeHex:
|
|
280
|
+
typeHex: viem259.Hex | null;
|
|
281
281
|
v: bigint;
|
|
282
282
|
value: bigint;
|
|
283
283
|
yParity: number;
|
|
284
|
-
accessList:
|
|
284
|
+
accessList: viem259.AccessList;
|
|
285
285
|
authorizationList?: undefined | undefined;
|
|
286
|
-
blobVersionedHashes: readonly
|
|
286
|
+
blobVersionedHashes: readonly viem259.Hex[];
|
|
287
287
|
chainId: number;
|
|
288
288
|
type: "eip4844";
|
|
289
289
|
gasPrice?: undefined | undefined;
|
|
@@ -296,21 +296,21 @@ declare const getChain: (chainStr: string) => {
|
|
|
296
296
|
} | {
|
|
297
297
|
blockHash: `0x${string}` | null;
|
|
298
298
|
blockNumber: bigint | null;
|
|
299
|
-
from:
|
|
299
|
+
from: viem259.Address;
|
|
300
300
|
gas: bigint;
|
|
301
|
-
hash:
|
|
302
|
-
input:
|
|
301
|
+
hash: viem259.Hash;
|
|
302
|
+
input: viem259.Hex;
|
|
303
303
|
nonce: number;
|
|
304
|
-
r:
|
|
305
|
-
s:
|
|
306
|
-
to:
|
|
304
|
+
r: viem259.Hex;
|
|
305
|
+
s: viem259.Hex;
|
|
306
|
+
to: viem259.Address | null;
|
|
307
307
|
transactionIndex: number | null;
|
|
308
|
-
typeHex:
|
|
308
|
+
typeHex: viem259.Hex | null;
|
|
309
309
|
v: bigint;
|
|
310
310
|
value: bigint;
|
|
311
311
|
yParity: number;
|
|
312
|
-
accessList:
|
|
313
|
-
authorizationList:
|
|
312
|
+
accessList: viem259.AccessList;
|
|
313
|
+
authorizationList: viem259.SignedAuthorizationList;
|
|
314
314
|
blobVersionedHashes?: undefined | undefined;
|
|
315
315
|
chainId: number;
|
|
316
316
|
type: "eip7702";
|
|
@@ -329,22 +329,22 @@ declare const getChain: (chainStr: string) => {
|
|
|
329
329
|
format: (args: viem_chains14.OpStackRpcTransactionReceipt, action?: string | undefined) => {
|
|
330
330
|
blobGasPrice?: bigint | undefined;
|
|
331
331
|
blobGasUsed?: bigint | undefined;
|
|
332
|
-
blockHash:
|
|
332
|
+
blockHash: viem259.Hash;
|
|
333
333
|
blockNumber: bigint;
|
|
334
334
|
blockTimestamp?: bigint | undefined;
|
|
335
|
-
contractAddress:
|
|
335
|
+
contractAddress: viem259.Address | null | undefined;
|
|
336
336
|
cumulativeGasUsed: bigint;
|
|
337
337
|
effectiveGasPrice: bigint;
|
|
338
|
-
from:
|
|
338
|
+
from: viem259.Address;
|
|
339
339
|
gasUsed: bigint;
|
|
340
|
-
logs:
|
|
341
|
-
logsBloom:
|
|
340
|
+
logs: viem259.Log<bigint, number, false>[];
|
|
341
|
+
logsBloom: viem259.Hex;
|
|
342
342
|
root?: `0x${string}` | undefined;
|
|
343
343
|
status: "success" | "reverted";
|
|
344
|
-
to:
|
|
345
|
-
transactionHash:
|
|
344
|
+
to: viem259.Address | null;
|
|
345
|
+
transactionHash: viem259.Hash;
|
|
346
346
|
transactionIndex: number;
|
|
347
|
-
type:
|
|
347
|
+
type: viem259.TransactionType;
|
|
348
348
|
l1GasPrice: bigint | null;
|
|
349
349
|
l1GasUsed: bigint | null;
|
|
350
350
|
l1Fee: bigint | null;
|
|
@@ -353,17 +353,17 @@ declare const getChain: (chainStr: string) => {
|
|
|
353
353
|
type: "transactionReceipt";
|
|
354
354
|
};
|
|
355
355
|
};
|
|
356
|
-
prepareTransactionRequest?: ((args:
|
|
356
|
+
prepareTransactionRequest?: ((args: viem259.PrepareTransactionRequestParameters, options: {
|
|
357
357
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
358
|
-
}) => Promise<
|
|
358
|
+
}) => Promise<viem259.PrepareTransactionRequestParameters>) | [fn: ((args: viem259.PrepareTransactionRequestParameters, options: {
|
|
359
359
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
360
|
-
}) => Promise<
|
|
360
|
+
}) => Promise<viem259.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
361
361
|
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
362
362
|
}] | undefined;
|
|
363
363
|
serializers: {
|
|
364
364
|
readonly transaction: typeof viem_chains14.serializeTransactionOpStack;
|
|
365
365
|
};
|
|
366
|
-
verifyHash?: ((client:
|
|
366
|
+
verifyHash?: ((client: viem259.Client, parameters: viem259.VerifyHashActionParameters) => Promise<viem259.VerifyHashActionReturnType>) | undefined;
|
|
367
367
|
readonly network: "base-sepolia";
|
|
368
368
|
};
|
|
369
369
|
declare const handleCancel: (value: unknown) => void;
|
|
@@ -400,17 +400,17 @@ declare const selectChain: () => Promise<{
|
|
|
400
400
|
testnet: true;
|
|
401
401
|
custom?: Record<string, unknown> | undefined;
|
|
402
402
|
extendSchema?: Record<string, unknown> | undefined;
|
|
403
|
-
fees?:
|
|
403
|
+
fees?: viem259.ChainFees<undefined> | undefined;
|
|
404
404
|
formatters?: undefined;
|
|
405
|
-
prepareTransactionRequest?: ((args:
|
|
405
|
+
prepareTransactionRequest?: ((args: viem259.PrepareTransactionRequestParameters, options: {
|
|
406
406
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
407
|
-
}) => Promise<
|
|
407
|
+
}) => Promise<viem259.PrepareTransactionRequestParameters>) | [fn: ((args: viem259.PrepareTransactionRequestParameters, options: {
|
|
408
408
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
409
|
-
}) => Promise<
|
|
409
|
+
}) => Promise<viem259.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
410
410
|
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
411
411
|
}] | undefined;
|
|
412
|
-
serializers?:
|
|
413
|
-
verifyHash?: ((client:
|
|
412
|
+
serializers?: viem259.ChainSerializers<undefined, viem259.TransactionSerializable> | undefined;
|
|
413
|
+
verifyHash?: ((client: viem259.Client, parameters: viem259.VerifyHashActionParameters) => Promise<viem259.VerifyHashActionReturnType>) | undefined;
|
|
414
414
|
} | {
|
|
415
415
|
blockExplorers: {
|
|
416
416
|
readonly default: {
|
|
@@ -484,7 +484,7 @@ declare const selectChain: () => Promise<{
|
|
|
484
484
|
testnet: true;
|
|
485
485
|
custom?: Record<string, unknown> | undefined;
|
|
486
486
|
extendSchema?: Record<string, unknown> | undefined;
|
|
487
|
-
fees?:
|
|
487
|
+
fees?: viem259.ChainFees<undefined> | undefined;
|
|
488
488
|
formatters: {
|
|
489
489
|
readonly block: {
|
|
490
490
|
exclude: [] | undefined;
|
|
@@ -493,28 +493,28 @@ declare const selectChain: () => Promise<{
|
|
|
493
493
|
blobGasUsed: bigint;
|
|
494
494
|
difficulty: bigint;
|
|
495
495
|
excessBlobGas: bigint;
|
|
496
|
-
extraData:
|
|
496
|
+
extraData: viem259.Hex;
|
|
497
497
|
gasLimit: bigint;
|
|
498
498
|
gasUsed: bigint;
|
|
499
499
|
hash: `0x${string}` | null;
|
|
500
500
|
logsBloom: `0x${string}` | null;
|
|
501
|
-
miner:
|
|
502
|
-
mixHash:
|
|
501
|
+
miner: viem259.Address;
|
|
502
|
+
mixHash: viem259.Hash;
|
|
503
503
|
nonce: `0x${string}` | null;
|
|
504
504
|
number: bigint | null;
|
|
505
505
|
parentBeaconBlockRoot?: `0x${string}` | undefined;
|
|
506
|
-
parentHash:
|
|
507
|
-
receiptsRoot:
|
|
508
|
-
sealFields:
|
|
509
|
-
sha3Uncles:
|
|
506
|
+
parentHash: viem259.Hash;
|
|
507
|
+
receiptsRoot: viem259.Hex;
|
|
508
|
+
sealFields: viem259.Hex[];
|
|
509
|
+
sha3Uncles: viem259.Hash;
|
|
510
510
|
size: bigint;
|
|
511
|
-
stateRoot:
|
|
511
|
+
stateRoot: viem259.Hash;
|
|
512
512
|
timestamp: bigint;
|
|
513
513
|
totalDifficulty: bigint | null;
|
|
514
514
|
transactions: `0x${string}`[] | viem_chains14.OpStackTransaction<boolean>[];
|
|
515
|
-
transactionsRoot:
|
|
516
|
-
uncles:
|
|
517
|
-
withdrawals?:
|
|
515
|
+
transactionsRoot: viem259.Hash;
|
|
516
|
+
uncles: viem259.Hash[];
|
|
517
|
+
withdrawals?: viem259.Withdrawal[] | undefined | undefined;
|
|
518
518
|
withdrawalsRoot?: `0x${string}` | undefined;
|
|
519
519
|
} & {};
|
|
520
520
|
type: "block";
|
|
@@ -524,16 +524,16 @@ declare const selectChain: () => Promise<{
|
|
|
524
524
|
format: (args: viem_chains14.OpStackRpcTransaction, action?: string | undefined) => ({
|
|
525
525
|
blockHash: `0x${string}` | null;
|
|
526
526
|
blockNumber: bigint | null;
|
|
527
|
-
from:
|
|
527
|
+
from: viem259.Address;
|
|
528
528
|
gas: bigint;
|
|
529
|
-
hash:
|
|
530
|
-
input:
|
|
529
|
+
hash: viem259.Hash;
|
|
530
|
+
input: viem259.Hex;
|
|
531
531
|
nonce: number;
|
|
532
|
-
r:
|
|
533
|
-
s:
|
|
534
|
-
to:
|
|
532
|
+
r: viem259.Hex;
|
|
533
|
+
s: viem259.Hex;
|
|
534
|
+
to: viem259.Address | null;
|
|
535
535
|
transactionIndex: number | null;
|
|
536
|
-
typeHex:
|
|
536
|
+
typeHex: viem259.Hex | null;
|
|
537
537
|
v: bigint;
|
|
538
538
|
value: bigint;
|
|
539
539
|
yParity: number;
|
|
@@ -543,23 +543,23 @@ declare const selectChain: () => Promise<{
|
|
|
543
543
|
maxPriorityFeePerGas: bigint;
|
|
544
544
|
isSystemTx?: boolean;
|
|
545
545
|
mint?: bigint | undefined | undefined;
|
|
546
|
-
sourceHash:
|
|
546
|
+
sourceHash: viem259.Hex;
|
|
547
547
|
type: "deposit";
|
|
548
548
|
} | {
|
|
549
|
-
r:
|
|
550
|
-
s:
|
|
549
|
+
r: viem259.Hex;
|
|
550
|
+
s: viem259.Hex;
|
|
551
551
|
v: bigint;
|
|
552
|
-
to:
|
|
553
|
-
from:
|
|
552
|
+
to: viem259.Address | null;
|
|
553
|
+
from: viem259.Address;
|
|
554
554
|
gas: bigint;
|
|
555
555
|
nonce: number;
|
|
556
556
|
value: bigint;
|
|
557
557
|
blockHash: `0x${string}` | null;
|
|
558
558
|
blockNumber: bigint | null;
|
|
559
|
-
hash:
|
|
560
|
-
input:
|
|
559
|
+
hash: viem259.Hash;
|
|
560
|
+
input: viem259.Hex;
|
|
561
561
|
transactionIndex: number | null;
|
|
562
|
-
typeHex:
|
|
562
|
+
typeHex: viem259.Hex | null;
|
|
563
563
|
accessList?: undefined | undefined;
|
|
564
564
|
authorizationList?: undefined | undefined;
|
|
565
565
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -576,20 +576,20 @@ declare const selectChain: () => Promise<{
|
|
|
576
576
|
} | {
|
|
577
577
|
blockHash: `0x${string}` | null;
|
|
578
578
|
blockNumber: bigint | null;
|
|
579
|
-
from:
|
|
579
|
+
from: viem259.Address;
|
|
580
580
|
gas: bigint;
|
|
581
|
-
hash:
|
|
582
|
-
input:
|
|
581
|
+
hash: viem259.Hash;
|
|
582
|
+
input: viem259.Hex;
|
|
583
583
|
nonce: number;
|
|
584
|
-
r:
|
|
585
|
-
s:
|
|
586
|
-
to:
|
|
584
|
+
r: viem259.Hex;
|
|
585
|
+
s: viem259.Hex;
|
|
586
|
+
to: viem259.Address | null;
|
|
587
587
|
transactionIndex: number | null;
|
|
588
|
-
typeHex:
|
|
588
|
+
typeHex: viem259.Hex | null;
|
|
589
589
|
v: bigint;
|
|
590
590
|
value: bigint;
|
|
591
591
|
yParity: number;
|
|
592
|
-
accessList:
|
|
592
|
+
accessList: viem259.AccessList;
|
|
593
593
|
authorizationList?: undefined | undefined;
|
|
594
594
|
blobVersionedHashes?: undefined | undefined;
|
|
595
595
|
chainId: number;
|
|
@@ -604,20 +604,20 @@ declare const selectChain: () => Promise<{
|
|
|
604
604
|
} | {
|
|
605
605
|
blockHash: `0x${string}` | null;
|
|
606
606
|
blockNumber: bigint | null;
|
|
607
|
-
from:
|
|
607
|
+
from: viem259.Address;
|
|
608
608
|
gas: bigint;
|
|
609
|
-
hash:
|
|
610
|
-
input:
|
|
609
|
+
hash: viem259.Hash;
|
|
610
|
+
input: viem259.Hex;
|
|
611
611
|
nonce: number;
|
|
612
|
-
r:
|
|
613
|
-
s:
|
|
614
|
-
to:
|
|
612
|
+
r: viem259.Hex;
|
|
613
|
+
s: viem259.Hex;
|
|
614
|
+
to: viem259.Address | null;
|
|
615
615
|
transactionIndex: number | null;
|
|
616
|
-
typeHex:
|
|
616
|
+
typeHex: viem259.Hex | null;
|
|
617
617
|
v: bigint;
|
|
618
618
|
value: bigint;
|
|
619
619
|
yParity: number;
|
|
620
|
-
accessList:
|
|
620
|
+
accessList: viem259.AccessList;
|
|
621
621
|
authorizationList?: undefined | undefined;
|
|
622
622
|
blobVersionedHashes?: undefined | undefined;
|
|
623
623
|
chainId: number;
|
|
@@ -632,22 +632,22 @@ declare const selectChain: () => Promise<{
|
|
|
632
632
|
} | {
|
|
633
633
|
blockHash: `0x${string}` | null;
|
|
634
634
|
blockNumber: bigint | null;
|
|
635
|
-
from:
|
|
635
|
+
from: viem259.Address;
|
|
636
636
|
gas: bigint;
|
|
637
|
-
hash:
|
|
638
|
-
input:
|
|
637
|
+
hash: viem259.Hash;
|
|
638
|
+
input: viem259.Hex;
|
|
639
639
|
nonce: number;
|
|
640
|
-
r:
|
|
641
|
-
s:
|
|
642
|
-
to:
|
|
640
|
+
r: viem259.Hex;
|
|
641
|
+
s: viem259.Hex;
|
|
642
|
+
to: viem259.Address | null;
|
|
643
643
|
transactionIndex: number | null;
|
|
644
|
-
typeHex:
|
|
644
|
+
typeHex: viem259.Hex | null;
|
|
645
645
|
v: bigint;
|
|
646
646
|
value: bigint;
|
|
647
647
|
yParity: number;
|
|
648
|
-
accessList:
|
|
648
|
+
accessList: viem259.AccessList;
|
|
649
649
|
authorizationList?: undefined | undefined;
|
|
650
|
-
blobVersionedHashes: readonly
|
|
650
|
+
blobVersionedHashes: readonly viem259.Hex[];
|
|
651
651
|
chainId: number;
|
|
652
652
|
type: "eip4844";
|
|
653
653
|
gasPrice?: undefined | undefined;
|
|
@@ -660,21 +660,21 @@ declare const selectChain: () => Promise<{
|
|
|
660
660
|
} | {
|
|
661
661
|
blockHash: `0x${string}` | null;
|
|
662
662
|
blockNumber: bigint | null;
|
|
663
|
-
from:
|
|
663
|
+
from: viem259.Address;
|
|
664
664
|
gas: bigint;
|
|
665
|
-
hash:
|
|
666
|
-
input:
|
|
665
|
+
hash: viem259.Hash;
|
|
666
|
+
input: viem259.Hex;
|
|
667
667
|
nonce: number;
|
|
668
|
-
r:
|
|
669
|
-
s:
|
|
670
|
-
to:
|
|
668
|
+
r: viem259.Hex;
|
|
669
|
+
s: viem259.Hex;
|
|
670
|
+
to: viem259.Address | null;
|
|
671
671
|
transactionIndex: number | null;
|
|
672
|
-
typeHex:
|
|
672
|
+
typeHex: viem259.Hex | null;
|
|
673
673
|
v: bigint;
|
|
674
674
|
value: bigint;
|
|
675
675
|
yParity: number;
|
|
676
|
-
accessList:
|
|
677
|
-
authorizationList:
|
|
676
|
+
accessList: viem259.AccessList;
|
|
677
|
+
authorizationList: viem259.SignedAuthorizationList;
|
|
678
678
|
blobVersionedHashes?: undefined | undefined;
|
|
679
679
|
chainId: number;
|
|
680
680
|
type: "eip7702";
|
|
@@ -693,22 +693,22 @@ declare const selectChain: () => Promise<{
|
|
|
693
693
|
format: (args: viem_chains14.OpStackRpcTransactionReceipt, action?: string | undefined) => {
|
|
694
694
|
blobGasPrice?: bigint | undefined;
|
|
695
695
|
blobGasUsed?: bigint | undefined;
|
|
696
|
-
blockHash:
|
|
696
|
+
blockHash: viem259.Hash;
|
|
697
697
|
blockNumber: bigint;
|
|
698
698
|
blockTimestamp?: bigint | undefined;
|
|
699
|
-
contractAddress:
|
|
699
|
+
contractAddress: viem259.Address | null | undefined;
|
|
700
700
|
cumulativeGasUsed: bigint;
|
|
701
701
|
effectiveGasPrice: bigint;
|
|
702
|
-
from:
|
|
702
|
+
from: viem259.Address;
|
|
703
703
|
gasUsed: bigint;
|
|
704
|
-
logs:
|
|
705
|
-
logsBloom:
|
|
704
|
+
logs: viem259.Log<bigint, number, false>[];
|
|
705
|
+
logsBloom: viem259.Hex;
|
|
706
706
|
root?: `0x${string}` | undefined;
|
|
707
707
|
status: "success" | "reverted";
|
|
708
|
-
to:
|
|
709
|
-
transactionHash:
|
|
708
|
+
to: viem259.Address | null;
|
|
709
|
+
transactionHash: viem259.Hash;
|
|
710
710
|
transactionIndex: number;
|
|
711
|
-
type:
|
|
711
|
+
type: viem259.TransactionType;
|
|
712
712
|
l1GasPrice: bigint | null;
|
|
713
713
|
l1GasUsed: bigint | null;
|
|
714
714
|
l1Fee: bigint | null;
|
|
@@ -717,17 +717,17 @@ declare const selectChain: () => Promise<{
|
|
|
717
717
|
type: "transactionReceipt";
|
|
718
718
|
};
|
|
719
719
|
};
|
|
720
|
-
prepareTransactionRequest?: ((args:
|
|
720
|
+
prepareTransactionRequest?: ((args: viem259.PrepareTransactionRequestParameters, options: {
|
|
721
721
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
722
|
-
}) => Promise<
|
|
722
|
+
}) => Promise<viem259.PrepareTransactionRequestParameters>) | [fn: ((args: viem259.PrepareTransactionRequestParameters, options: {
|
|
723
723
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
724
|
-
}) => Promise<
|
|
724
|
+
}) => Promise<viem259.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
725
725
|
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
726
726
|
}] | undefined;
|
|
727
727
|
serializers: {
|
|
728
728
|
readonly transaction: typeof viem_chains14.serializeTransactionOpStack;
|
|
729
729
|
};
|
|
730
|
-
verifyHash?: ((client:
|
|
730
|
+
verifyHash?: ((client: viem259.Client, parameters: viem259.VerifyHashActionParameters) => Promise<viem259.VerifyHashActionReturnType>) | undefined;
|
|
731
731
|
readonly network: "base-sepolia";
|
|
732
732
|
}>;
|
|
733
733
|
declare function parseGadgetArg(raw: string): {
|
package/lib/fangorn.js
CHANGED
|
@@ -58,7 +58,7 @@ var Fangorn = class Fangorn {
|
|
|
58
58
|
*/
|
|
59
59
|
get publisher() {
|
|
60
60
|
if (!isWritable(this.ctx.storage)) throw new Error("fangorn.publisher requires writable storage. Use { storacha: { email } } or { pinata: { ... } }");
|
|
61
|
-
return this._publisher ??= new PublisherRole(this.ctx.dataSourceRegistry, this.ctx.settlementRegistry, this.ctx.storage, this.ctx.encryption, this.ctx.walletClient, this.ctx.config);
|
|
61
|
+
return this._publisher ??= new PublisherRole(this.ctx.dataSourceRegistry, this.ctx.settlementRegistry, this.ctx.schemaRegistry, this.ctx.storage, this.ctx.encryption, this.ctx.walletClient, this.ctx.config);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Consumer: purchase, claim, and decrypt data.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as viem257 from "viem";
|
|
2
2
|
import { Address, Hash, Hex, PublicClient, WalletClient } from "viem";
|
|
3
3
|
|
|
4
4
|
//#region src/registries/datasource-registry/index.d.ts
|
|
@@ -18,7 +18,7 @@ declare class DataSourceRegistry {
|
|
|
18
18
|
publishManifest(manifestCid: string, schemaId: Hex): Promise<Hash>;
|
|
19
19
|
getManifest(owner: Address, schemaId: Hex): Promise<DataSource>;
|
|
20
20
|
getVersion(owner: Address, schemaId: Hex): Promise<bigint>;
|
|
21
|
-
waitForTransaction(hash: Hash): Promise<
|
|
21
|
+
waitForTransaction(hash: Hash): Promise<viem257.TransactionReceipt>;
|
|
22
22
|
}
|
|
23
23
|
//#endregion
|
|
24
24
|
export { DataSource, DataSourceRegistry };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as viem258 from "viem";
|
|
2
2
|
import { Address, Hash, Hex, PublicClient, WalletClient } from "viem";
|
|
3
3
|
|
|
4
4
|
//#region src/registries/schema-registry/index.d.ts
|
|
@@ -22,7 +22,7 @@ declare class SchemaRegistry {
|
|
|
22
22
|
updateSchema(nameOrId: string, newSpecCid: string, newAgentId: string): Promise<Hash>;
|
|
23
23
|
getSchema(nameOrId: string): Promise<Schema>;
|
|
24
24
|
schemaExists(nameOrId: string): Promise<boolean>;
|
|
25
|
-
waitForTransaction(hash: Hash): Promise<
|
|
25
|
+
waitForTransaction(hash: Hash): Promise<viem258.TransactionReceipt>;
|
|
26
26
|
private resolveId;
|
|
27
27
|
}
|
|
28
28
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PrepareSettleParams, PrepareSettleResult, RegisterParams, SettleParams, TransferWithAuthParams, TransferWithAuthPayload } from "./types.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as viem431 from "viem";
|
|
3
3
|
import { Address, Hex, PublicClient, WalletClient } from "viem";
|
|
4
4
|
|
|
5
5
|
//#region src/registries/settlement-registry/index.d.ts
|
|
@@ -66,7 +66,7 @@ declare class SettlementRegistry {
|
|
|
66
66
|
* viem topic-encoding edge cases with indexed params.
|
|
67
67
|
*/
|
|
68
68
|
private fetchGroup;
|
|
69
|
-
waitForTransaction(hash: Hex): Promise<
|
|
69
|
+
waitForTransaction(hash: Hex): Promise<viem431.TransactionReceipt>;
|
|
70
70
|
}
|
|
71
71
|
//#endregion
|
|
72
72
|
export { SettlementRegistry };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AppConfig } from "../../config.js";
|
|
2
|
+
import { SchemaRegistry } from "../../registries/schema-registry/index.js";
|
|
2
3
|
import { WritableStorage } from "../../providers/storage/index.js";
|
|
3
4
|
import { DataSourceRegistry } from "../../registries/datasource-registry/index.js";
|
|
4
5
|
import { SettlementRegistry } from "../../registries/settlement-registry/index.js";
|
|
@@ -10,12 +11,14 @@ import { Hex, WalletClient } from "viem";
|
|
|
10
11
|
declare class PublisherRole {
|
|
11
12
|
private readonly dataSourceRegistry;
|
|
12
13
|
private readonly settlementRegistry;
|
|
14
|
+
private readonly schemaRegistry;
|
|
13
15
|
private readonly storage;
|
|
14
16
|
private readonly encryptionService;
|
|
15
17
|
private readonly walletClient;
|
|
16
18
|
private readonly config;
|
|
17
19
|
private pendingEntries;
|
|
18
|
-
|
|
20
|
+
private readonly schemaCache;
|
|
21
|
+
constructor(dataSourceRegistry: DataSourceRegistry, settlementRegistry: SettlementRegistry, schemaRegistry: SchemaRegistry, storage: WritableStorage<unknown>, encryptionService: EncryptionService, walletClient: WalletClient, config: AppConfig);
|
|
19
22
|
/**
|
|
20
23
|
* Encrypt and Upload data with Fangorn
|
|
21
24
|
* Validate records against the schema, encrypt encrypted
|
|
@@ -44,12 +47,17 @@ declare class PublisherRole {
|
|
|
44
47
|
getManifest(schemaId: Hex): Promise<Manifest | undefined>;
|
|
45
48
|
getEntry(schemaId: Hex, tag: string): Promise<ManifestEntry>;
|
|
46
49
|
private requireAccount;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve the schema def and id by name
|
|
52
|
+
* @param name The name of the schema
|
|
53
|
+
* @returns The schema and id if they exist
|
|
54
|
+
*/
|
|
55
|
+
private resolveSchema;
|
|
47
56
|
/**
|
|
48
57
|
* Resolve a PublishRecord into a ManifestEntry by processing each field
|
|
49
58
|
* according to the schema definition:
|
|
50
59
|
* - plain fields are stored as-is
|
|
51
|
-
* - encrypted fields are AES+Lit encrypted, pinned to IPFS, and replaced
|
|
52
|
-
* with a handle + gadgetDescriptor
|
|
60
|
+
* - encrypted fields are AES+Lit encrypted, pinned to IPFS, and replaced with a handle + gadgetDescriptor
|
|
53
61
|
*/
|
|
54
62
|
private resolveRecord;
|
|
55
63
|
/**
|
|
@@ -4,9 +4,11 @@ import { makeSettledGadgetFactory } from "../../modules/gadgets/settledGadget.js
|
|
|
4
4
|
//#region src/roles/publisher/index.ts
|
|
5
5
|
var PublisherRole = class {
|
|
6
6
|
pendingEntries = /* @__PURE__ */ new Map();
|
|
7
|
-
|
|
7
|
+
schemaCache = /* @__PURE__ */ new Map();
|
|
8
|
+
constructor(dataSourceRegistry, settlementRegistry, schemaRegistry, storage, encryptionService, walletClient, config) {
|
|
8
9
|
this.dataSourceRegistry = dataSourceRegistry;
|
|
9
10
|
this.settlementRegistry = settlementRegistry;
|
|
11
|
+
this.schemaRegistry = schemaRegistry;
|
|
10
12
|
this.storage = storage;
|
|
11
13
|
this.encryptionService = encryptionService;
|
|
12
14
|
this.walletClient = walletClient;
|
|
@@ -23,10 +25,12 @@ var PublisherRole = class {
|
|
|
23
25
|
* only need to purchase + decrypt for encrypted fields.
|
|
24
26
|
*/
|
|
25
27
|
async upload(params, price) {
|
|
26
|
-
const { records,
|
|
28
|
+
const { records, schemaName, gateway, options } = params;
|
|
27
29
|
const address = this.requireAccount();
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
+
const { schema, schemaId } = await this.resolveSchema(schemaName);
|
|
31
|
+
console.log("got the schemaId " + schemaId);
|
|
32
|
+
console.log("got the schema " + JSON.stringify(schema));
|
|
33
|
+
const gadgetFactory = params.gadgetFactory ?? ((resourceId) => {
|
|
30
34
|
return makeSettledGadgetFactory(this.config)(resourceId);
|
|
31
35
|
});
|
|
32
36
|
for (const record of records) {
|
|
@@ -113,11 +117,30 @@ var PublisherRole = class {
|
|
|
113
117
|
return address;
|
|
114
118
|
}
|
|
115
119
|
/**
|
|
120
|
+
* Resolve the schema def and id by name
|
|
121
|
+
* @param name The name of the schema
|
|
122
|
+
* @returns The schema and id if they exist
|
|
123
|
+
*/
|
|
124
|
+
resolveSchema(name) {
|
|
125
|
+
if (!this.schemaCache.has(name)) {
|
|
126
|
+
const p = Promise.all([this.schemaRegistry.getSchema(name), this.schemaRegistry.schemaId(name)]).then(async ([{ cid }, schemaId]) => {
|
|
127
|
+
return {
|
|
128
|
+
schema: (await this.storage.retrieve(cid)).definition,
|
|
129
|
+
schemaId
|
|
130
|
+
};
|
|
131
|
+
}).catch((err) => {
|
|
132
|
+
this.schemaCache.delete(name);
|
|
133
|
+
throw err;
|
|
134
|
+
});
|
|
135
|
+
this.schemaCache.set(name, p);
|
|
136
|
+
}
|
|
137
|
+
return this.schemaCache.get(name);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
116
140
|
* Resolve a PublishRecord into a ManifestEntry by processing each field
|
|
117
141
|
* according to the schema definition:
|
|
118
142
|
* - plain fields are stored as-is
|
|
119
|
-
* - encrypted fields are AES+Lit encrypted, pinned to IPFS, and replaced
|
|
120
|
-
* with a handle + gadgetDescriptor
|
|
143
|
+
* - encrypted fields are AES+Lit encrypted, pinned to IPFS, and replaced with a handle + gadgetDescriptor
|
|
121
144
|
*/
|
|
122
145
|
async resolveRecord(record, schema, gadget, gateway) {
|
|
123
146
|
const resolvedFields = {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SchemaDefinition } from "../schema/types.js";
|
|
2
1
|
import { Gadget, GadgetDescriptor } from "../../modules/gadgets/types.js";
|
|
3
2
|
import "../../modules/gadgets/index.js";
|
|
4
3
|
import { Address, Hex } from "viem";
|
|
@@ -57,12 +56,7 @@ interface Manifest {
|
|
|
57
56
|
}
|
|
58
57
|
interface UploadParams {
|
|
59
58
|
records: PublishRecord[];
|
|
60
|
-
|
|
61
|
-
* The schema the records must conform to. Required — field-level encryption
|
|
62
|
-
* decisions are driven by the schema definition.
|
|
63
|
-
*/
|
|
64
|
-
schema: SchemaDefinition;
|
|
65
|
-
schemaId: Hex;
|
|
59
|
+
schemaName: string;
|
|
66
60
|
/**
|
|
67
61
|
* Called once per record to produce the gadget for that record's encrypted
|
|
68
62
|
* fields. All encrypted fields within a record share the same gadget —
|
package/lib/test/testbed.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ declare class TestBed {
|
|
|
43
43
|
* which is baked into the ACC at encryption time. A buyer must complete the
|
|
44
44
|
* full purchase → claim flow for each specific tag before decrypting.
|
|
45
45
|
*/
|
|
46
|
-
fileUpload(records: PublishRecord[],
|
|
46
|
+
fileUpload(records: PublishRecord[], schemaName: string, gateway: string, price: bigint): Promise<string>;
|
|
47
47
|
prepareRegister(burnerPrivateKey: Hex, paymentRecipient: Address, amount: bigint): Promise<TransferWithAuthPayload>;
|
|
48
48
|
register(owner: Address, schemaId: Hex, tag: string, identityCommitment: bigint, relayerPrivateKey: Hex, preparedRegister: TransferWithAuthPayload): Promise<Hex>;
|
|
49
49
|
prepareSettle(owner: Address, schemaId: Hex, tag: string, identity: Identity, stealthAddress: Address): Promise<PrepareSettleResult>;
|
package/lib/test/testbed.js
CHANGED
|
@@ -42,14 +42,16 @@ var TestBed = class TestBed {
|
|
|
42
42
|
rpcUrl,
|
|
43
43
|
caip2
|
|
44
44
|
};
|
|
45
|
-
const agentConfig = void 0;
|
|
46
45
|
const delegatorFangorn = await Fangorn.create({
|
|
47
46
|
privateKey: process.env.DELEGATOR_ETH_PRIVATE_KEY ?? "0x0",
|
|
48
|
-
storage: {
|
|
47
|
+
storage: { pinata: {
|
|
48
|
+
jwt: process.env.PINATA_JWT ?? "",
|
|
49
|
+
gateway: process.env.PINATA_GATEWAY ?? ""
|
|
50
|
+
} },
|
|
49
51
|
encryption: { lit: true },
|
|
50
52
|
config,
|
|
51
53
|
domain: "localhost",
|
|
52
|
-
agentConfig
|
|
54
|
+
agentConfig: void 0
|
|
53
55
|
});
|
|
54
56
|
const delegateeFangorn = await Fangorn.create({
|
|
55
57
|
privateKey: process.env.DELEGATEE_ETH_PRIVATE_KEY ?? "0x0",
|
|
@@ -79,11 +81,10 @@ var TestBed = class TestBed {
|
|
|
79
81
|
* which is baked into the ACC at encryption time. A buyer must complete the
|
|
80
82
|
* full purchase → claim flow for each specific tag before decrypting.
|
|
81
83
|
*/
|
|
82
|
-
async fileUpload(records,
|
|
84
|
+
async fileUpload(records, schemaName, gateway, price) {
|
|
83
85
|
const { manifestCid } = await this.delegatorFangorn.publisher.upload({
|
|
84
86
|
records,
|
|
85
|
-
|
|
86
|
-
schemaId,
|
|
87
|
+
schemaName,
|
|
87
88
|
gateway
|
|
88
89
|
}, price);
|
|
89
90
|
return manifestCid;
|
package/package.json
CHANGED
|
@@ -1,87 +1,74 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"viem": "$viem"
|
|
75
|
-
},
|
|
76
|
-
"pnpm": {
|
|
77
|
-
"overrides": {
|
|
78
|
-
"write-file-atomic": "7.0.0"
|
|
79
|
-
},
|
|
80
|
-
"peerDependencyRules": {
|
|
81
|
-
"allowedVersions": {
|
|
82
|
-
"viem": ">=2.38.3",
|
|
83
|
-
"ethers": ">=5.7.2"
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
2
|
+
"name": "@fangorn-network/sdk",
|
|
3
|
+
"version": "2026.04.07",
|
|
4
|
+
"description": "A zero-knowledge conditional access control framework",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/fangorn-network/fangorn.git"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"fangorn": "lib/cli/cli.js"
|
|
11
|
+
},
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"files": [
|
|
16
|
+
"lib/"
|
|
17
|
+
],
|
|
18
|
+
"lint-staged": {
|
|
19
|
+
"*": "prettier --ignore-unknown --write"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@dotenvx/dotenvx": "^1.51.1",
|
|
23
|
+
"@eslint/js": "9.39.1",
|
|
24
|
+
"@types/node": "24.10.1",
|
|
25
|
+
"@vitest/coverage-v8": "4.0.15",
|
|
26
|
+
"@vitest/eslint-plugin": "1.5.1",
|
|
27
|
+
"eslint": "9.39.1",
|
|
28
|
+
"husky": "9.1.7",
|
|
29
|
+
"lint-staged": "16.2.7",
|
|
30
|
+
"prettier": "3.7.3",
|
|
31
|
+
"tsdown": "0.16.8",
|
|
32
|
+
"tsx": "^4.21.0",
|
|
33
|
+
"typescript": "5.8.3",
|
|
34
|
+
"typescript-eslint": "8.48.1",
|
|
35
|
+
"vitest": "^4.0.18"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=20.19.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@a2a-js/sdk": "^0.3.10",
|
|
42
|
+
"@clack/prompts": "^1.0.1",
|
|
43
|
+
"@lit-protocol/access-control-conditions": "^8.0.2",
|
|
44
|
+
"@lit-protocol/auth": "^8.2.2",
|
|
45
|
+
"@lit-protocol/auth-helpers": "^8.2.1",
|
|
46
|
+
"@lit-protocol/lit-client": "^8.3.1",
|
|
47
|
+
"@lit-protocol/networks": "^8.4.1",
|
|
48
|
+
"@semaphore-protocol/group": "^4.14.2",
|
|
49
|
+
"@semaphore-protocol/identity": "^4.14.2",
|
|
50
|
+
"@semaphore-protocol/proof": "^4.14.2",
|
|
51
|
+
"@storacha/client": "^2.1.3",
|
|
52
|
+
"agent0-sdk": "^1.5.3",
|
|
53
|
+
"commander": "^14.0.3",
|
|
54
|
+
"dotenv": "^17.2.3",
|
|
55
|
+
"ethers": "^6.16.0",
|
|
56
|
+
"pinata": "^2.5.2",
|
|
57
|
+
"solc": "^0.8.28",
|
|
58
|
+
"viem": "^2.47.1"
|
|
59
|
+
},
|
|
60
|
+
"overrides": {
|
|
61
|
+
"viem": "$viem"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsdown",
|
|
65
|
+
"format": "prettier . --write",
|
|
66
|
+
"lint": "eslint . --max-warnings 0",
|
|
67
|
+
"test": "dotenvx run -f .env -- vitest run",
|
|
68
|
+
"test:e2e": "dotenvx run -f .env -- vitest run --config vitest.e2e.config.ts",
|
|
69
|
+
"tsc": "tsc",
|
|
70
|
+
"deploy": "dotenvx run -f .env -- tsx deploy.ts",
|
|
71
|
+
"prepare:cli": "npm run build",
|
|
72
|
+
"fangorn": "dotenvx run -f .env -- node dist/src/cli/cli.js"
|
|
73
|
+
}
|
|
87
74
|
}
|