@secondlayer/subgraphs 2.0.2 → 2.0.4
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 +43 -2
- package/dist/src/index.js +11 -5
- package/dist/src/index.js.map +4 -4
- package/dist/src/runtime/block-processor.js +5 -3
- package/dist/src/runtime/block-processor.js.map +3 -3
- package/dist/src/runtime/catchup.js +5 -3
- package/dist/src/runtime/catchup.js.map +3 -3
- package/dist/src/runtime/processor.js +5 -3
- package/dist/src/runtime/processor.js.map +3 -3
- package/dist/src/runtime/reindex.js +5 -3
- package/dist/src/runtime/reindex.js.map +3 -3
- package/dist/src/runtime/reorg.js +5 -3
- package/dist/src/runtime/reorg.js.map +3 -3
- package/dist/src/runtime/runner.js +5 -3
- package/dist/src/runtime/runner.js.map +3 -3
- package/dist/src/schema/index.d.ts +1 -1
- package/dist/src/schema/index.js +7 -3
- package/dist/src/schema/index.js.map +3 -3
- package/dist/src/service.js +5 -3
- package/dist/src/service.js.map +3 -3
- package/dist/src/triggers/index.d.ts +3 -3
- package/dist/src/types.d.ts +42 -1
- package/package.json +2 -2
package/dist/src/index.d.ts
CHANGED
|
@@ -78,6 +78,47 @@ interface NftBurnFilter {
|
|
|
78
78
|
assetIdentifier?: string;
|
|
79
79
|
sender?: string;
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Event shape passed to contract_call handlers.
|
|
83
|
+
*
|
|
84
|
+
* `args` is a **positional array** of decoded Clarity values matching the
|
|
85
|
+
* contract function's parameter list in declaration order. Use the ABI
|
|
86
|
+
* (or Clarity contract source) to map positions to names:
|
|
87
|
+
*
|
|
88
|
+
* ```ts
|
|
89
|
+
* // pox-4 stack-stx args: (amount-ustx uint) (pox-addr tuple) (start-burn-ht uint) (lock-period uint)
|
|
90
|
+
* const [amountUstx, , , lockPeriod] = event.args;
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* Bigints come out as `bigint`. Buffers as `Uint8Array`. Principals as
|
|
94
|
+
* strings (`"SP..."`). Tuples as `Record<string, unknown>`.
|
|
95
|
+
*
|
|
96
|
+
* Historical transactions indexed before the function_args column was added
|
|
97
|
+
* will have `args = []` — always guard with `args.length > 0` when reading
|
|
98
|
+
* args from pre-Nakamoto history.
|
|
99
|
+
*/
|
|
100
|
+
interface ContractCallEvent {
|
|
101
|
+
type: "contract_call";
|
|
102
|
+
/** Transaction sender (the principal who signed the tx). Always non-null. */
|
|
103
|
+
sender: string;
|
|
104
|
+
contractId: string;
|
|
105
|
+
functionName: string;
|
|
106
|
+
/** Positional decoded Clarity values — order matches the ABI parameter list. */
|
|
107
|
+
args: unknown[];
|
|
108
|
+
/** Decoded return value from the contract function, or null. */
|
|
109
|
+
result: unknown;
|
|
110
|
+
/** Raw hex-encoded result value. */
|
|
111
|
+
resultHex: string | null;
|
|
112
|
+
/** Transaction metadata. */
|
|
113
|
+
tx: {
|
|
114
|
+
txId: string
|
|
115
|
+
sender: string
|
|
116
|
+
type: string
|
|
117
|
+
status: string
|
|
118
|
+
contractId: string | null
|
|
119
|
+
functionName: string | null
|
|
120
|
+
};
|
|
121
|
+
}
|
|
81
122
|
/** Contract event filters */
|
|
82
123
|
interface ContractCallFilter {
|
|
83
124
|
type: "contract_call";
|
|
@@ -279,7 +320,7 @@ declare function deploySchema(db: AnyDb, def: SubgraphDefinition, handlerPath: s
|
|
|
279
320
|
handlerCode?: string
|
|
280
321
|
sourceCode?: string
|
|
281
322
|
}): Promise<{
|
|
282
|
-
action: "created" | "unchanged" | "updated" | "reindexed"
|
|
323
|
+
action: "created" | "unchanged" | "handler_updated" | "updated" | "reindexed"
|
|
283
324
|
subgraphId: string
|
|
284
325
|
version: string
|
|
285
326
|
diff?: DeployDiff
|
|
@@ -339,4 +380,4 @@ interface SubgraphTableClient<TRow> {
|
|
|
339
380
|
type InferSubgraphClient<T> = T extends {
|
|
340
381
|
schema: infer S
|
|
341
382
|
} ? { [K in keyof S] : S[K] extends SubgraphTable ? SubgraphTableClient<InferTableRow<S[K]>> : never } : never;
|
|
342
|
-
export { validateSubgraphDefinition, resumeReindex, reindexSubgraph, pgSchemaName, generateSubgraphSQL, diffSchema, deploySchema, defineSubgraph, backfillSubgraph, WhereInput, TxMeta, TableDiff, SystemRow, SubgraphTableClient, SubgraphTable, SubgraphSchema, SubgraphHandler, SubgraphFilter, SubgraphDefinition, SubgraphContext, SubgraphColumn, StxTransferFilter, StxMintFilter, StxLockFilter, StxBurnFilter, RowValue, ReindexOptions, PrintEventFilter, NftTransferFilter, NftMintFilter, NftBurnFilter, InferTableRow, InferSubgraphClient, InferColumnType, GeneratedSQL, FtTransferFilter, FtMintFilter, FtBurnFilter, FindManyOptions, ContractDeployFilter, ContractCallFilter, ComputedValue, ComparisonFilter, ColumnType, ColumnToTS, ColumnDiff };
|
|
383
|
+
export { validateSubgraphDefinition, resumeReindex, reindexSubgraph, pgSchemaName, generateSubgraphSQL, diffSchema, deploySchema, defineSubgraph, backfillSubgraph, WhereInput, TxMeta, TableDiff, SystemRow, SubgraphTableClient, SubgraphTable, SubgraphSchema, SubgraphHandler, SubgraphFilter, SubgraphDefinition, SubgraphContext, SubgraphColumn, StxTransferFilter, StxMintFilter, StxLockFilter, StxBurnFilter, RowValue, ReindexOptions, PrintEventFilter, NftTransferFilter, NftMintFilter, NftBurnFilter, InferTableRow, InferSubgraphClient, InferColumnType, GeneratedSQL, FtTransferFilter, FtMintFilter, FtBurnFilter, FindManyOptions, ContractDeployFilter, ContractCallFilter, ContractCallEvent, ComputedValue, ComparisonFilter, ColumnType, ColumnToTS, ColumnDiff };
|
package/dist/src/index.js
CHANGED
|
@@ -490,9 +490,10 @@ function buildEventPayload(filter, tx, event) {
|
|
|
490
490
|
switch (filter.type) {
|
|
491
491
|
case "contract_call":
|
|
492
492
|
return {
|
|
493
|
+
type: "contract_call",
|
|
493
494
|
contractId: tx.contract_id ?? "",
|
|
494
495
|
functionName: tx.function_name ?? "",
|
|
495
|
-
|
|
496
|
+
sender: tx.sender,
|
|
496
497
|
args: decodedArgs,
|
|
497
498
|
result: decodedResult,
|
|
498
499
|
resultHex: tx.raw_result ?? null,
|
|
@@ -598,10 +599,11 @@ function buildEventPayload(filter, tx, event) {
|
|
|
598
599
|
case "contract_call":
|
|
599
600
|
return {
|
|
600
601
|
...decoded,
|
|
602
|
+
type: "contract_call",
|
|
601
603
|
_eventType: event.type,
|
|
602
604
|
contractId: tx.contract_id ?? "",
|
|
603
605
|
functionName: tx.function_name ?? "",
|
|
604
|
-
|
|
606
|
+
sender: tx.sender,
|
|
605
607
|
args: decodedArgs,
|
|
606
608
|
result: decodedResult,
|
|
607
609
|
resultHex: tx.raw_result ?? null,
|
|
@@ -2002,10 +2004,14 @@ async function deploySchema(db, def, handlerPath, opts) {
|
|
|
2002
2004
|
};
|
|
2003
2005
|
if (existing) {
|
|
2004
2006
|
if (existing.schema_hash === hash && !opts?.forceReindex) {
|
|
2007
|
+
const handlerChanged = opts?.handlerCode != null && opts.handlerCode !== existing.handler_code;
|
|
2005
2008
|
const { updateSubgraphHandlerPath } = await import("@secondlayer/shared/db/queries/subgraphs");
|
|
2006
|
-
await updateSubgraphHandlerPath(db, def.name, handlerPath
|
|
2009
|
+
await updateSubgraphHandlerPath(db, def.name, handlerPath, {
|
|
2010
|
+
handlerCode: opts?.handlerCode,
|
|
2011
|
+
sourceCode: opts?.sourceCode
|
|
2012
|
+
});
|
|
2007
2013
|
return {
|
|
2008
|
-
action: "unchanged",
|
|
2014
|
+
action: handlerChanged ? "handler_updated" : "unchanged",
|
|
2009
2015
|
subgraphId: existing.id,
|
|
2010
2016
|
version: existing.version
|
|
2011
2017
|
};
|
|
@@ -2153,5 +2159,5 @@ export {
|
|
|
2153
2159
|
backfillSubgraph
|
|
2154
2160
|
};
|
|
2155
2161
|
|
|
2156
|
-
//# debugId=
|
|
2162
|
+
//# debugId=3710F19F792D1C7E64756E2164756E21
|
|
2157
2163
|
//# sourceMappingURL=index.js.map
|