@secondlayer/subgraphs 3.22.0 → 3.23.1
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/dist/src/index.d.ts +118 -9
- package/dist/src/index.js +159 -14
- package/dist/src/index.js.map +7 -6
- package/dist/src/runtime/block-processor.d.ts +43 -2
- package/dist/src/runtime/block-processor.js +155 -12
- package/dist/src/runtime/block-processor.js.map +7 -6
- package/dist/src/runtime/catchup.d.ts +43 -2
- package/dist/src/runtime/catchup.js +155 -12
- package/dist/src/runtime/catchup.js.map +7 -6
- package/dist/src/runtime/context.d.ts +77 -3
- package/dist/src/runtime/context.js +142 -1
- package/dist/src/runtime/context.js.map +6 -5
- package/dist/src/runtime/processor.js +159 -16
- package/dist/src/runtime/processor.js.map +7 -6
- package/dist/src/runtime/reindex.d.ts +43 -2
- package/dist/src/runtime/reindex.js +155 -12
- package/dist/src/runtime/reindex.js.map +7 -6
- package/dist/src/runtime/reorg.d.ts +43 -2
- package/dist/src/runtime/reorg.js +155 -12
- package/dist/src/runtime/reorg.js.map +7 -6
- package/dist/src/runtime/replay.d.ts +3 -3
- package/dist/src/runtime/replay.js +2 -1
- package/dist/src/runtime/replay.js.map +3 -3
- package/dist/src/runtime/runner.d.ts +102 -5
- package/dist/src/runtime/source-matcher.d.ts +2 -2
- package/dist/src/runtime/stats.d.ts +3 -3
- package/dist/src/schema/index.d.ts +46 -5
- package/dist/src/service.js +159 -16
- package/dist/src/service.js.map +7 -6
- package/dist/src/testing/index.d.ts +52 -5
- package/dist/src/testing/index.js +172 -6
- package/dist/src/testing/index.js.map +6 -5
- package/dist/src/triggers/index.d.ts +2 -2
- package/dist/src/types.d.ts +43 -2
- package/dist/src/validate.d.ts +43 -2
- package/package.json +6 -4
package/dist/src/types.d.ts
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
|
-
import { AbiContract } from "@secondlayer/stacks/clarity";
|
|
1
|
+
import { AbiContract as AbiContract2 } from "@secondlayer/stacks/clarity";
|
|
2
|
+
/**
|
|
3
|
+
* How long a read stays valid.
|
|
4
|
+
*
|
|
5
|
+
* - `per-block` (default): pinned to the block being processed, cached under
|
|
6
|
+
* its `index_block_hash`. Sound for any read-only function — reindexing the
|
|
7
|
+
* same block always returns the same value, and a reorg-replaced block has a
|
|
8
|
+
* different id so it can't inherit the orphaned answer.
|
|
9
|
+
* - `contract-constant`: the caller asserts the value cannot change for this
|
|
10
|
+
* contract and these args (SIP-010 `get-decimals`/`get-symbol`), so it is
|
|
11
|
+
* resolved ONCE instead of once per block. This is the mode that makes a
|
|
12
|
+
* backfill affordable — under `per-block` every block is a distinct key and
|
|
13
|
+
* therefore a distinct RPC. Declaring it on a value that does change pins the
|
|
14
|
+
* first answer forever, so it is opt-in and never inferred.
|
|
15
|
+
*/
|
|
16
|
+
type ChainReadCacheMode = "per-block" | "contract-constant";
|
|
17
|
+
type ChainReadOptions = {
|
|
18
|
+
cache?: ChainReadCacheMode
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* `ChainReadClient` with the ABI generic erased. Structurally cheap, so the
|
|
22
|
+
* base `SubgraphContext` can carry it; `TypedSubgraphContext` uses the real
|
|
23
|
+
* one and handlers get full inference.
|
|
24
|
+
*/
|
|
25
|
+
interface ErasedChainReadClient {
|
|
26
|
+
contract(contractId: string, abi: unknown, options?: ChainReadOptions): {
|
|
27
|
+
read: Record<string, (args?: Record<string, unknown>) => Promise<unknown>>
|
|
28
|
+
};
|
|
29
|
+
}
|
|
2
30
|
/** Supported column types for subgraph schemas */
|
|
3
31
|
type ColumnType = "text" | "uint" | "int" | "principal" | "boolean" | "timestamp" | "jsonb";
|
|
4
32
|
/** Column definition in a subgraph table */
|
|
@@ -216,7 +244,7 @@ interface ContractCallFilter extends TraitScope, FactoryScope {
|
|
|
216
244
|
* definition and used at runtime to decode args by name. Omit to keep
|
|
217
245
|
* `event.args` as a positional `unknown[]`.
|
|
218
246
|
*/
|
|
219
|
-
abi?:
|
|
247
|
+
abi?: AbiContract2;
|
|
220
248
|
}
|
|
221
249
|
interface ContractDeployFilter {
|
|
222
250
|
type: "contract_deploy";
|
|
@@ -287,8 +315,21 @@ interface SubgraphContext {
|
|
|
287
315
|
hash: string
|
|
288
316
|
timestamp: number
|
|
289
317
|
burnBlockHeight: number
|
|
318
|
+
/** Nakamoto StacksBlockId, when the block row carries one. */
|
|
319
|
+
indexBlockHash?: string | null
|
|
290
320
|
};
|
|
291
321
|
tx: TxMeta;
|
|
322
|
+
/**
|
|
323
|
+
* Read-only contract calls pinned to this block. Cached, so the same
|
|
324
|
+
* (contract, function, args) is fetched once per block rather than once
|
|
325
|
+
* per event.
|
|
326
|
+
*
|
|
327
|
+
* Erased here on purpose: this interface is compared structurally wherever
|
|
328
|
+
* a subgraph definition is passed around, and carrying an ABI-generic
|
|
329
|
+
* method pushes those comparisons past TS's instantiation depth. Handlers
|
|
330
|
+
* receive `TypedSubgraphContext`, which exposes the fully typed version.
|
|
331
|
+
*/
|
|
332
|
+
client: ErasedChainReadClient;
|
|
292
333
|
insert(table: string, row: Record<string, unknown>): void;
|
|
293
334
|
update(table: string, where: Record<string, unknown>, set: Record<string, unknown>): void;
|
|
294
335
|
upsert(table: string, key: Record<string, unknown>, row: Record<string, unknown>): void;
|
package/dist/src/validate.d.ts
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
|
-
import { AbiContract } from "@secondlayer/stacks/clarity";
|
|
1
|
+
import { AbiContract as AbiContract2 } from "@secondlayer/stacks/clarity";
|
|
2
|
+
/**
|
|
3
|
+
* How long a read stays valid.
|
|
4
|
+
*
|
|
5
|
+
* - `per-block` (default): pinned to the block being processed, cached under
|
|
6
|
+
* its `index_block_hash`. Sound for any read-only function — reindexing the
|
|
7
|
+
* same block always returns the same value, and a reorg-replaced block has a
|
|
8
|
+
* different id so it can't inherit the orphaned answer.
|
|
9
|
+
* - `contract-constant`: the caller asserts the value cannot change for this
|
|
10
|
+
* contract and these args (SIP-010 `get-decimals`/`get-symbol`), so it is
|
|
11
|
+
* resolved ONCE instead of once per block. This is the mode that makes a
|
|
12
|
+
* backfill affordable — under `per-block` every block is a distinct key and
|
|
13
|
+
* therefore a distinct RPC. Declaring it on a value that does change pins the
|
|
14
|
+
* first answer forever, so it is opt-in and never inferred.
|
|
15
|
+
*/
|
|
16
|
+
type ChainReadCacheMode = "per-block" | "contract-constant";
|
|
17
|
+
type ChainReadOptions = {
|
|
18
|
+
cache?: ChainReadCacheMode
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* `ChainReadClient` with the ABI generic erased. Structurally cheap, so the
|
|
22
|
+
* base `SubgraphContext` can carry it; `TypedSubgraphContext` uses the real
|
|
23
|
+
* one and handlers get full inference.
|
|
24
|
+
*/
|
|
25
|
+
interface ErasedChainReadClient {
|
|
26
|
+
contract(contractId: string, abi: unknown, options?: ChainReadOptions): {
|
|
27
|
+
read: Record<string, (args?: Record<string, unknown>) => Promise<unknown>>
|
|
28
|
+
};
|
|
29
|
+
}
|
|
2
30
|
/** Supported column types for subgraph schemas */
|
|
3
31
|
type ColumnType = "text" | "uint" | "int" | "principal" | "boolean" | "timestamp" | "jsonb";
|
|
4
32
|
/** Column definition in a subgraph table */
|
|
@@ -175,7 +203,7 @@ interface ContractCallFilter extends TraitScope, FactoryScope {
|
|
|
175
203
|
* definition and used at runtime to decode args by name. Omit to keep
|
|
176
204
|
* `event.args` as a positional `unknown[]`.
|
|
177
205
|
*/
|
|
178
|
-
abi?:
|
|
206
|
+
abi?: AbiContract2;
|
|
179
207
|
}
|
|
180
208
|
interface ContractDeployFilter {
|
|
181
209
|
type: "contract_deploy";
|
|
@@ -246,8 +274,21 @@ interface SubgraphContext {
|
|
|
246
274
|
hash: string
|
|
247
275
|
timestamp: number
|
|
248
276
|
burnBlockHeight: number
|
|
277
|
+
/** Nakamoto StacksBlockId, when the block row carries one. */
|
|
278
|
+
indexBlockHash?: string | null
|
|
249
279
|
};
|
|
250
280
|
tx: TxMeta;
|
|
281
|
+
/**
|
|
282
|
+
* Read-only contract calls pinned to this block. Cached, so the same
|
|
283
|
+
* (contract, function, args) is fetched once per block rather than once
|
|
284
|
+
* per event.
|
|
285
|
+
*
|
|
286
|
+
* Erased here on purpose: this interface is compared structurally wherever
|
|
287
|
+
* a subgraph definition is passed around, and carrying an ABI-generic
|
|
288
|
+
* method pushes those comparisons past TS's instantiation depth. Handlers
|
|
289
|
+
* receive `TypedSubgraphContext`, which exposes the fully typed version.
|
|
290
|
+
*/
|
|
291
|
+
client: ErasedChainReadClient;
|
|
251
292
|
insert(table: string, row: Record<string, unknown>): void;
|
|
252
293
|
update(table: string, where: Record<string, unknown>, set: Record<string, unknown>): void;
|
|
253
294
|
upsert(table: string, key: Record<string, unknown>, row: Record<string, unknown>): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secondlayer/subgraphs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.23.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -49,7 +49,9 @@
|
|
|
49
49
|
"import": "./dist/src/testing/index.js"
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
|
-
"files": [
|
|
52
|
+
"files": [
|
|
53
|
+
"dist"
|
|
54
|
+
],
|
|
53
55
|
"scripts": {
|
|
54
56
|
"build": "bunup",
|
|
55
57
|
"dev": "bunup --watch",
|
|
@@ -58,8 +60,8 @@
|
|
|
58
60
|
"prepublishOnly": "bun run build"
|
|
59
61
|
},
|
|
60
62
|
"dependencies": {
|
|
61
|
-
"@secondlayer/shared": "^7.
|
|
62
|
-
"@secondlayer/stacks": "^
|
|
63
|
+
"@secondlayer/shared": "^7.3.1",
|
|
64
|
+
"@secondlayer/stacks": "^3.0.0",
|
|
63
65
|
"esbuild": "^0.27.4",
|
|
64
66
|
"kysely": "0.28.17",
|
|
65
67
|
"zod": "^4.3.6"
|