@fangorn-network/sdk 2026.10.1-9.0-dev → 2026.10.20-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 +5 -0
- package/lib/cli/index.d.ts +2 -2
- package/lib/config.d.ts +67 -64
- package/lib/config.js +5 -3
- package/lib/contracts/app-registry/index.d.ts +2 -1
- package/lib/contracts/app-registry/index.js +3 -2
- package/lib/contracts/logs.d.ts +6 -10
- package/lib/contracts/logs.js +5 -9
- package/lib/fangorn.js +1 -1
- package/lib/registry.d.ts +2 -0
- package/lib/registry.js +3 -1
- package/lib/test/testbed.d.ts +4922 -4922
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -609,6 +609,11 @@ gadget_ behind the same handle shape, so committed data doesn't change form.
|
|
|
609
609
|
Use it from the SDK with `Fangorn.create({ config: BaseSepoliaConfig, ... })`, or
|
|
610
610
|
from the CLI with `CHAIN_NAME=baseSepolia` (or pick it in `fangorn init`).
|
|
611
611
|
|
|
612
|
+
Its default RPC is `base-sepolia-rpc.publicnode.com`, not `sepolia.base.org`: the
|
|
613
|
+
official endpoint caps `eth_getLogs` at 200 blocks, too narrow to scan the registry's
|
|
614
|
+
history. Each config's `logWindow` is the most blocks one log query spans on its RPC
|
|
615
|
+
(Base 10,000, Arbitrum 100,000); `FANGORN_LOG_WINDOW` overrides it for a private RPC.
|
|
616
|
+
|
|
612
617
|
`FangornConfig` (Arbitrum Sepolia) and `BaseSepoliaConfig` in `src/config.ts` are the authoritative list and what the SDK
|
|
613
618
|
uses by default — prefer it over any address copied out of a document,
|
|
614
619
|
including this table. The sources are `fangorn-network/contracts`
|
package/lib/cli/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./cli.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as viem0 from "viem";
|
|
3
3
|
|
|
4
4
|
//#region src/cli/index.d.ts
|
|
5
|
-
declare const getChain: (chainStr: string) =>
|
|
5
|
+
declare const getChain: (chainStr: string) => viem0.Chain;
|
|
6
6
|
declare const handleCancel: (value: unknown) => void;
|
|
7
7
|
declare const selectChain: () => Promise<string>;
|
|
8
8
|
declare function parseGadgetArg(raw: string): {
|
package/lib/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as viem1 from "viem";
|
|
2
2
|
import { Chain, Hex } from "viem";
|
|
3
3
|
import * as viem_chains0 from "viem/chains";
|
|
4
4
|
import * as abitype0 from "abitype";
|
|
@@ -24,6 +24,7 @@ interface AppConfig {
|
|
|
24
24
|
rpcUrl: string;
|
|
25
25
|
caip2: number;
|
|
26
26
|
ipfsGateway: string;
|
|
27
|
+
logWindow?: bigint;
|
|
27
28
|
}
|
|
28
29
|
declare const FangornConfig: {
|
|
29
30
|
dataRegistryContractAddress: "0x72B5f83526F3893aF9f1eE0f32A27218EA09f8aE";
|
|
@@ -63,21 +64,22 @@ declare const FangornConfig: {
|
|
|
63
64
|
testnet: true;
|
|
64
65
|
custom?: Record<string, unknown> | undefined;
|
|
65
66
|
extendSchema?: Record<string, unknown> | undefined;
|
|
66
|
-
fees?:
|
|
67
|
+
fees?: viem1.ChainFees<undefined> | undefined;
|
|
67
68
|
formatters?: undefined;
|
|
68
|
-
prepareTransactionRequest?: ((args:
|
|
69
|
+
prepareTransactionRequest?: ((args: viem1.PrepareTransactionRequestParameters, options: {
|
|
69
70
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
70
|
-
}) => Promise<
|
|
71
|
+
}) => Promise<viem1.PrepareTransactionRequestParameters>) | [fn: ((args: viem1.PrepareTransactionRequestParameters, options: {
|
|
71
72
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
72
|
-
}) => Promise<
|
|
73
|
+
}) => Promise<viem1.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
73
74
|
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
74
75
|
}] | undefined;
|
|
75
|
-
serializers?:
|
|
76
|
-
verifyHash?: ((client:
|
|
76
|
+
serializers?: viem1.ChainSerializers<undefined, viem1.TransactionSerializable> | undefined;
|
|
77
|
+
verifyHash?: ((client: viem1.Client, parameters: viem1.VerifyHashActionParameters) => Promise<viem1.VerifyHashActionReturnType>) | undefined;
|
|
77
78
|
};
|
|
78
79
|
rpcUrl: string;
|
|
79
80
|
caip2: number;
|
|
80
81
|
ipfsGateway: string;
|
|
82
|
+
logWindow: bigint;
|
|
81
83
|
};
|
|
82
84
|
declare const BaseSepoliaConfig: {
|
|
83
85
|
dataRegistryContractAddress: "0xE9183f768865dd2Cde5f1B71F8446F0Cd798ebe0";
|
|
@@ -157,7 +159,7 @@ declare const BaseSepoliaConfig: {
|
|
|
157
159
|
testnet: true;
|
|
158
160
|
custom?: Record<string, unknown> | undefined;
|
|
159
161
|
extendSchema?: Record<string, unknown> | undefined;
|
|
160
|
-
fees?:
|
|
162
|
+
fees?: viem1.ChainFees<undefined> | undefined;
|
|
161
163
|
formatters: {
|
|
162
164
|
readonly block: {
|
|
163
165
|
exclude: [] | undefined;
|
|
@@ -166,28 +168,28 @@ declare const BaseSepoliaConfig: {
|
|
|
166
168
|
blobGasUsed: bigint;
|
|
167
169
|
difficulty: bigint;
|
|
168
170
|
excessBlobGas: bigint;
|
|
169
|
-
extraData:
|
|
171
|
+
extraData: viem1.Hex;
|
|
170
172
|
gasLimit: bigint;
|
|
171
173
|
gasUsed: bigint;
|
|
172
174
|
hash: `0x${string}` | null;
|
|
173
175
|
logsBloom: `0x${string}` | null;
|
|
174
176
|
miner: abitype0.Address;
|
|
175
|
-
mixHash:
|
|
177
|
+
mixHash: viem1.Hash;
|
|
176
178
|
nonce: `0x${string}` | null;
|
|
177
179
|
number: bigint | null;
|
|
178
180
|
parentBeaconBlockRoot?: `0x${string}` | undefined;
|
|
179
|
-
parentHash:
|
|
180
|
-
receiptsRoot:
|
|
181
|
-
sealFields:
|
|
182
|
-
sha3Uncles:
|
|
181
|
+
parentHash: viem1.Hash;
|
|
182
|
+
receiptsRoot: viem1.Hex;
|
|
183
|
+
sealFields: viem1.Hex[];
|
|
184
|
+
sha3Uncles: viem1.Hash;
|
|
183
185
|
size: bigint;
|
|
184
|
-
stateRoot:
|
|
186
|
+
stateRoot: viem1.Hash;
|
|
185
187
|
timestamp: bigint;
|
|
186
188
|
totalDifficulty: bigint | null;
|
|
187
189
|
transactions: `0x${string}`[] | viem_chains0.OpStackTransaction<boolean>[];
|
|
188
|
-
transactionsRoot:
|
|
189
|
-
uncles:
|
|
190
|
-
withdrawals?:
|
|
190
|
+
transactionsRoot: viem1.Hash;
|
|
191
|
+
uncles: viem1.Hash[];
|
|
192
|
+
withdrawals?: viem1.Withdrawal[] | undefined | undefined;
|
|
191
193
|
withdrawalsRoot?: `0x${string}` | undefined;
|
|
192
194
|
} & {};
|
|
193
195
|
type: "block";
|
|
@@ -199,14 +201,14 @@ declare const BaseSepoliaConfig: {
|
|
|
199
201
|
blockNumber: bigint | null;
|
|
200
202
|
from: abitype0.Address;
|
|
201
203
|
gas: bigint;
|
|
202
|
-
hash:
|
|
203
|
-
input:
|
|
204
|
+
hash: viem1.Hash;
|
|
205
|
+
input: viem1.Hex;
|
|
204
206
|
nonce: number;
|
|
205
|
-
r:
|
|
206
|
-
s:
|
|
207
|
+
r: viem1.Hex;
|
|
208
|
+
s: viem1.Hex;
|
|
207
209
|
to: abitype0.Address | null;
|
|
208
210
|
transactionIndex: number | null;
|
|
209
|
-
typeHex:
|
|
211
|
+
typeHex: viem1.Hex | null;
|
|
210
212
|
v: bigint;
|
|
211
213
|
value: bigint;
|
|
212
214
|
yParity: number;
|
|
@@ -216,11 +218,11 @@ declare const BaseSepoliaConfig: {
|
|
|
216
218
|
maxPriorityFeePerGas: bigint;
|
|
217
219
|
isSystemTx?: boolean;
|
|
218
220
|
mint?: bigint | undefined | undefined;
|
|
219
|
-
sourceHash:
|
|
221
|
+
sourceHash: viem1.Hex;
|
|
220
222
|
type: "deposit";
|
|
221
223
|
} | {
|
|
222
|
-
r:
|
|
223
|
-
s:
|
|
224
|
+
r: viem1.Hex;
|
|
225
|
+
s: viem1.Hex;
|
|
224
226
|
v: bigint;
|
|
225
227
|
to: abitype0.Address | null;
|
|
226
228
|
from: abitype0.Address;
|
|
@@ -229,10 +231,10 @@ declare const BaseSepoliaConfig: {
|
|
|
229
231
|
value: bigint;
|
|
230
232
|
blockHash: `0x${string}` | null;
|
|
231
233
|
blockNumber: bigint | null;
|
|
232
|
-
hash:
|
|
233
|
-
input:
|
|
234
|
+
hash: viem1.Hash;
|
|
235
|
+
input: viem1.Hex;
|
|
234
236
|
transactionIndex: number | null;
|
|
235
|
-
typeHex:
|
|
237
|
+
typeHex: viem1.Hex | null;
|
|
236
238
|
accessList?: undefined | undefined;
|
|
237
239
|
authorizationList?: undefined | undefined;
|
|
238
240
|
blobVersionedHashes?: undefined | undefined;
|
|
@@ -251,18 +253,18 @@ declare const BaseSepoliaConfig: {
|
|
|
251
253
|
blockNumber: bigint | null;
|
|
252
254
|
from: abitype0.Address;
|
|
253
255
|
gas: bigint;
|
|
254
|
-
hash:
|
|
255
|
-
input:
|
|
256
|
+
hash: viem1.Hash;
|
|
257
|
+
input: viem1.Hex;
|
|
256
258
|
nonce: number;
|
|
257
|
-
r:
|
|
258
|
-
s:
|
|
259
|
+
r: viem1.Hex;
|
|
260
|
+
s: viem1.Hex;
|
|
259
261
|
to: abitype0.Address | null;
|
|
260
262
|
transactionIndex: number | null;
|
|
261
|
-
typeHex:
|
|
263
|
+
typeHex: viem1.Hex | null;
|
|
262
264
|
v: bigint;
|
|
263
265
|
value: bigint;
|
|
264
266
|
yParity: number;
|
|
265
|
-
accessList:
|
|
267
|
+
accessList: viem1.AccessList;
|
|
266
268
|
authorizationList?: undefined | undefined;
|
|
267
269
|
blobVersionedHashes?: undefined | undefined;
|
|
268
270
|
chainId: number;
|
|
@@ -279,18 +281,18 @@ declare const BaseSepoliaConfig: {
|
|
|
279
281
|
blockNumber: bigint | null;
|
|
280
282
|
from: abitype0.Address;
|
|
281
283
|
gas: bigint;
|
|
282
|
-
hash:
|
|
283
|
-
input:
|
|
284
|
+
hash: viem1.Hash;
|
|
285
|
+
input: viem1.Hex;
|
|
284
286
|
nonce: number;
|
|
285
|
-
r:
|
|
286
|
-
s:
|
|
287
|
+
r: viem1.Hex;
|
|
288
|
+
s: viem1.Hex;
|
|
287
289
|
to: abitype0.Address | null;
|
|
288
290
|
transactionIndex: number | null;
|
|
289
|
-
typeHex:
|
|
291
|
+
typeHex: viem1.Hex | null;
|
|
290
292
|
v: bigint;
|
|
291
293
|
value: bigint;
|
|
292
294
|
yParity: number;
|
|
293
|
-
accessList:
|
|
295
|
+
accessList: viem1.AccessList;
|
|
294
296
|
authorizationList?: undefined | undefined;
|
|
295
297
|
blobVersionedHashes?: undefined | undefined;
|
|
296
298
|
chainId: number;
|
|
@@ -307,20 +309,20 @@ declare const BaseSepoliaConfig: {
|
|
|
307
309
|
blockNumber: bigint | null;
|
|
308
310
|
from: abitype0.Address;
|
|
309
311
|
gas: bigint;
|
|
310
|
-
hash:
|
|
311
|
-
input:
|
|
312
|
+
hash: viem1.Hash;
|
|
313
|
+
input: viem1.Hex;
|
|
312
314
|
nonce: number;
|
|
313
|
-
r:
|
|
314
|
-
s:
|
|
315
|
+
r: viem1.Hex;
|
|
316
|
+
s: viem1.Hex;
|
|
315
317
|
to: abitype0.Address | null;
|
|
316
318
|
transactionIndex: number | null;
|
|
317
|
-
typeHex:
|
|
319
|
+
typeHex: viem1.Hex | null;
|
|
318
320
|
v: bigint;
|
|
319
321
|
value: bigint;
|
|
320
322
|
yParity: number;
|
|
321
|
-
accessList:
|
|
323
|
+
accessList: viem1.AccessList;
|
|
322
324
|
authorizationList?: undefined | undefined;
|
|
323
|
-
blobVersionedHashes: readonly
|
|
325
|
+
blobVersionedHashes: readonly viem1.Hex[];
|
|
324
326
|
chainId: number;
|
|
325
327
|
type: "eip4844";
|
|
326
328
|
gasPrice?: undefined | undefined;
|
|
@@ -335,19 +337,19 @@ declare const BaseSepoliaConfig: {
|
|
|
335
337
|
blockNumber: bigint | null;
|
|
336
338
|
from: abitype0.Address;
|
|
337
339
|
gas: bigint;
|
|
338
|
-
hash:
|
|
339
|
-
input:
|
|
340
|
+
hash: viem1.Hash;
|
|
341
|
+
input: viem1.Hex;
|
|
340
342
|
nonce: number;
|
|
341
|
-
r:
|
|
342
|
-
s:
|
|
343
|
+
r: viem1.Hex;
|
|
344
|
+
s: viem1.Hex;
|
|
343
345
|
to: abitype0.Address | null;
|
|
344
346
|
transactionIndex: number | null;
|
|
345
|
-
typeHex:
|
|
347
|
+
typeHex: viem1.Hex | null;
|
|
346
348
|
v: bigint;
|
|
347
349
|
value: bigint;
|
|
348
350
|
yParity: number;
|
|
349
|
-
accessList:
|
|
350
|
-
authorizationList:
|
|
351
|
+
accessList: viem1.AccessList;
|
|
352
|
+
authorizationList: viem1.SignedAuthorizationList;
|
|
351
353
|
blobVersionedHashes?: undefined | undefined;
|
|
352
354
|
chainId: number;
|
|
353
355
|
type: "eip7702";
|
|
@@ -366,7 +368,7 @@ declare const BaseSepoliaConfig: {
|
|
|
366
368
|
format: (args: viem_chains0.OpStackRpcTransactionReceipt, action?: string | undefined) => {
|
|
367
369
|
blobGasPrice?: bigint | undefined;
|
|
368
370
|
blobGasUsed?: bigint | undefined;
|
|
369
|
-
blockHash:
|
|
371
|
+
blockHash: viem1.Hash;
|
|
370
372
|
blockNumber: bigint;
|
|
371
373
|
blockTimestamp?: bigint | undefined;
|
|
372
374
|
contractAddress: abitype0.Address | null | undefined;
|
|
@@ -374,14 +376,14 @@ declare const BaseSepoliaConfig: {
|
|
|
374
376
|
effectiveGasPrice: bigint;
|
|
375
377
|
from: abitype0.Address;
|
|
376
378
|
gasUsed: bigint;
|
|
377
|
-
logs:
|
|
378
|
-
logsBloom:
|
|
379
|
+
logs: viem1.Log<bigint, number, false>[];
|
|
380
|
+
logsBloom: viem1.Hex;
|
|
379
381
|
root?: `0x${string}` | undefined;
|
|
380
382
|
status: "success" | "reverted";
|
|
381
383
|
to: abitype0.Address | null;
|
|
382
|
-
transactionHash:
|
|
384
|
+
transactionHash: viem1.Hash;
|
|
383
385
|
transactionIndex: number;
|
|
384
|
-
type:
|
|
386
|
+
type: viem1.TransactionType;
|
|
385
387
|
l1GasPrice: bigint | null;
|
|
386
388
|
l1GasUsed: bigint | null;
|
|
387
389
|
l1Fee: bigint | null;
|
|
@@ -390,22 +392,23 @@ declare const BaseSepoliaConfig: {
|
|
|
390
392
|
type: "transactionReceipt";
|
|
391
393
|
};
|
|
392
394
|
};
|
|
393
|
-
prepareTransactionRequest?: ((args:
|
|
395
|
+
prepareTransactionRequest?: ((args: viem1.PrepareTransactionRequestParameters, options: {
|
|
394
396
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
395
|
-
}) => Promise<
|
|
397
|
+
}) => Promise<viem1.PrepareTransactionRequestParameters>) | [fn: ((args: viem1.PrepareTransactionRequestParameters, options: {
|
|
396
398
|
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
397
|
-
}) => Promise<
|
|
399
|
+
}) => Promise<viem1.PrepareTransactionRequestParameters>) | undefined, options: {
|
|
398
400
|
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
399
401
|
}] | undefined;
|
|
400
402
|
serializers: {
|
|
401
403
|
readonly transaction: typeof viem_chains0.serializeTransactionOpStack;
|
|
402
404
|
};
|
|
403
|
-
verifyHash?: ((client:
|
|
405
|
+
verifyHash?: ((client: viem1.Client, parameters: viem1.VerifyHashActionParameters) => Promise<viem1.VerifyHashActionReturnType>) | undefined;
|
|
404
406
|
readonly network: "base-sepolia";
|
|
405
407
|
};
|
|
406
408
|
rpcUrl: string;
|
|
407
409
|
caip2: number;
|
|
408
410
|
ipfsGateway: string;
|
|
411
|
+
logWindow: bigint;
|
|
409
412
|
};
|
|
410
413
|
/**
|
|
411
414
|
* The networks supported by Fangorn, by the name `CHAIN_NAME` takes.
|
package/lib/config.js
CHANGED
|
@@ -30,7 +30,8 @@ const FangornConfig = {
|
|
|
30
30
|
chain: arbitrumSepolia,
|
|
31
31
|
rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
32
32
|
caip2: 421614,
|
|
33
|
-
ipfsGateway: "https://ipfs.io"
|
|
33
|
+
ipfsGateway: "https://ipfs.io",
|
|
34
|
+
logWindow: 100000n
|
|
34
35
|
};
|
|
35
36
|
const BaseSepoliaConfig = {
|
|
36
37
|
dataRegistryContractAddress: "0xE9183f768865dd2Cde5f1B71F8446F0Cd798ebe0",
|
|
@@ -38,9 +39,10 @@ const BaseSepoliaConfig = {
|
|
|
38
39
|
membershipRegistryContractAddress: "0x0e96C012b5c53622EcDAA82F342E31C2623A04f5",
|
|
39
40
|
appRegistryFromBlock: 48340483n,
|
|
40
41
|
chain: baseSepolia,
|
|
41
|
-
rpcUrl: "https://sepolia.
|
|
42
|
+
rpcUrl: "https://base-sepolia-rpc.publicnode.com",
|
|
42
43
|
caip2: 84532,
|
|
43
|
-
ipfsGateway: "https://ipfs.io"
|
|
44
|
+
ipfsGateway: "https://ipfs.io",
|
|
45
|
+
logWindow: 10000n
|
|
44
46
|
};
|
|
45
47
|
/**
|
|
46
48
|
* The networks supported by Fangorn, by the name `CHAIN_NAME` takes.
|
|
@@ -32,7 +32,8 @@ declare class AppRegistryClient {
|
|
|
32
32
|
private appId;
|
|
33
33
|
private publicClient;
|
|
34
34
|
private walletClient;
|
|
35
|
-
|
|
35
|
+
private logWindow?;
|
|
36
|
+
constructor(contractAddress: Address, appId: Hex | undefined, publicClient: PublicClient, walletClient: WalletClient, logWindow?: bigint | undefined);
|
|
36
37
|
getAppId(): Hex | undefined;
|
|
37
38
|
setAppId(appId: Hex | undefined): void;
|
|
38
39
|
getAddress(): Address;
|
|
@@ -13,11 +13,12 @@ import { erc20Abi, hexToBigInt } from "viem";
|
|
|
13
13
|
* Scoped to one app, which may be unset: then only the calls that take no app work.
|
|
14
14
|
*/
|
|
15
15
|
var AppRegistryClient = class {
|
|
16
|
-
constructor(contractAddress, appId, publicClient, walletClient) {
|
|
16
|
+
constructor(contractAddress, appId, publicClient, walletClient, logWindow) {
|
|
17
17
|
this.contractAddress = contractAddress;
|
|
18
18
|
this.appId = appId;
|
|
19
19
|
this.publicClient = publicClient;
|
|
20
20
|
this.walletClient = walletClient;
|
|
21
|
+
this.logWindow = logWindow;
|
|
21
22
|
}
|
|
22
23
|
getAppId() {
|
|
23
24
|
return this.appId;
|
|
@@ -195,7 +196,7 @@ var AppRegistryClient = class {
|
|
|
195
196
|
fromBlock: from,
|
|
196
197
|
toBlock: to,
|
|
197
198
|
strict: true
|
|
198
|
-
}))).map((log) => ({
|
|
199
|
+
}), this.logWindow)).map((log) => ({
|
|
199
200
|
appId: log.args.app_id,
|
|
200
201
|
agentUri: log.args.agent_uri,
|
|
201
202
|
blockNumber: log.blockNumber,
|
package/lib/contracts/logs.d.ts
CHANGED
|
@@ -6,16 +6,12 @@ import { PublicClient } from "viem";
|
|
|
6
6
|
* Run `fetch` over [fromBlock, toBlock] in consecutive block windows and
|
|
7
7
|
* concatenate the results, oldest window first.
|
|
8
8
|
*
|
|
9
|
-
* RPC providers limit how many blocks one `eth_getLogs` call can cover
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* more.
|
|
15
|
-
*
|
|
16
|
-
* `defaultWindow` is for a query the endpoint is known to serve over a wider
|
|
17
|
-
* range. `FANGORN_LOG_WINDOW` still overrides it.
|
|
9
|
+
* RPC providers limit how many blocks one `eth_getLogs` call can cover (the
|
|
10
|
+
* Base Sepolia one 50,000, sepolia.base.org 200), and a call past the limit fails
|
|
11
|
+
* outright, taking whatever depends on it (a catch-up, a directory listing) with
|
|
12
|
+
* it. Each network's config says what its RPC takes (`AppConfig.logWindow`, passed
|
|
13
|
+
* here as `defaultWindow`); `FANGORN_LOG_WINDOW` overrides it, for a private RPC.
|
|
18
14
|
*/
|
|
19
|
-
declare function getLogsInWindows<T>(publicClient: PublicClient, fromBlock: bigint, toBlock: bigint | undefined, fetch: (fromBlock: bigint, toBlock: bigint) => Promise<T[]>, defaultWindow?: bigint): Promise<T[]>;
|
|
15
|
+
declare function getLogsInWindows<T>(publicClient: PublicClient, fromBlock: bigint, toBlock: bigint | undefined, fetch: (fromBlock: bigint, toBlock: bigint) => Promise<T[]>, defaultWindow?: bigint | undefined): Promise<T[]>;
|
|
20
16
|
//#endregion
|
|
21
17
|
export { getLogsInWindows };
|
package/lib/contracts/logs.js
CHANGED
|
@@ -5,15 +5,11 @@ import { nonBlank } from "../config.js";
|
|
|
5
5
|
* Run `fetch` over [fromBlock, toBlock] in consecutive block windows and
|
|
6
6
|
* concatenate the results, oldest window first.
|
|
7
7
|
*
|
|
8
|
-
* RPC providers limit how many blocks one `eth_getLogs` call can cover
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* more.
|
|
14
|
-
*
|
|
15
|
-
* `defaultWindow` is for a query the endpoint is known to serve over a wider
|
|
16
|
-
* range. `FANGORN_LOG_WINDOW` still overrides it.
|
|
8
|
+
* RPC providers limit how many blocks one `eth_getLogs` call can cover (the
|
|
9
|
+
* Base Sepolia one 50,000, sepolia.base.org 200), and a call past the limit fails
|
|
10
|
+
* outright, taking whatever depends on it (a catch-up, a directory listing) with
|
|
11
|
+
* it. Each network's config says what its RPC takes (`AppConfig.logWindow`, passed
|
|
12
|
+
* here as `defaultWindow`); `FANGORN_LOG_WINDOW` overrides it, for a private RPC.
|
|
17
13
|
*/
|
|
18
14
|
async function getLogsInWindows(publicClient, fromBlock, toBlock, fetch, defaultWindow = 1000n) {
|
|
19
15
|
const tuned = typeof process !== "undefined" ? nonBlank(process.env.FANGORN_LOG_WINDOW) : void 0;
|
package/lib/fangorn.js
CHANGED
|
@@ -560,7 +560,7 @@ var Fangorn = class Fangorn {
|
|
|
560
560
|
* bill the app's subscription, and the app presents its repos.
|
|
561
561
|
*/
|
|
562
562
|
getAppRegistry() {
|
|
563
|
-
this._apps ??= new AppRegistryClient(this.ctx.config.appRegistryContractAddress, this.ctx.appId, this.ctx.publicClient, this.ctx.walletClient);
|
|
563
|
+
this._apps ??= new AppRegistryClient(this.ctx.config.appRegistryContractAddress, this.ctx.appId, this.ctx.publicClient, this.ctx.walletClient, this.ctx.config.logWindow);
|
|
564
564
|
return this._apps;
|
|
565
565
|
}
|
|
566
566
|
getMembershipRegistry() {
|
package/lib/registry.d.ts
CHANGED
|
@@ -75,6 +75,7 @@ declare function exclusionId(x: Exclusion): Hex;
|
|
|
75
75
|
interface ChainRegistryConfig {
|
|
76
76
|
dataRegistryContractAddress: Address;
|
|
77
77
|
appRegistryContractAddress: Address;
|
|
78
|
+
logWindow?: bigint;
|
|
78
79
|
}
|
|
79
80
|
/**
|
|
80
81
|
* The registry on the contracts: H and U in the DataRegistry; membership, X and C
|
|
@@ -96,6 +97,7 @@ declare class ChainRegistry implements Registry {
|
|
|
96
97
|
private walletClient?;
|
|
97
98
|
private readonly data;
|
|
98
99
|
private readonly apps;
|
|
100
|
+
private readonly logWindow?;
|
|
99
101
|
constructor(config: ChainRegistryConfig, publicClient: PublicClient, walletClient?: WalletClient | undefined);
|
|
100
102
|
epoch(): Promise<number>;
|
|
101
103
|
head(ref: RepoRef): Promise<Hex>;
|
package/lib/registry.js
CHANGED
|
@@ -58,11 +58,13 @@ function exclusionId(x) {
|
|
|
58
58
|
var ChainRegistry = class {
|
|
59
59
|
data;
|
|
60
60
|
apps;
|
|
61
|
+
logWindow;
|
|
61
62
|
constructor(config, publicClient, walletClient) {
|
|
62
63
|
this.publicClient = publicClient;
|
|
63
64
|
this.walletClient = walletClient;
|
|
64
65
|
this.data = config.dataRegistryContractAddress;
|
|
65
66
|
this.apps = config.appRegistryContractAddress;
|
|
67
|
+
this.logWindow = config.logWindow;
|
|
66
68
|
}
|
|
67
69
|
async epoch() {
|
|
68
70
|
return epochOf((await this.publicClient.getBlock()).timestamp);
|
|
@@ -141,7 +143,7 @@ var ChainRegistry = class {
|
|
|
141
143
|
fromBlock,
|
|
142
144
|
toBlock,
|
|
143
145
|
strict: true
|
|
144
|
-
}))).sort((a, b) => a.blockNumber === b.blockNumber ? a.logIndex - b.logIndex : a.blockNumber < b.blockNumber ? -1 : 1).map(toEntry);
|
|
146
|
+
}), this.logWindow)).sort((a, b) => a.blockNumber === b.blockNumber ? a.logIndex - b.logIndex : a.blockNumber < b.blockNumber ? -1 : 1).map(toEntry);
|
|
145
147
|
}
|
|
146
148
|
watch(filter, onEntry, onError, pollingInterval) {
|
|
147
149
|
return this.publicClient.watchContractEvent({
|