@secondlayer/subgraphs 6.3.6 → 6.4.0
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/index.d.ts +82 -1
- package/dist/index.js +514 -9
- package/dist/index.js.map +6 -4
- package/dist/schema/index.d.ts +7 -0
- package/dist/schema/index.js +294 -6
- package/dist/schema/index.js.map +6 -5
- package/dist/testing/index.js +474 -2
- package/dist/testing/index.js.map +7 -5
- package/dist/verification.d.ts +426 -0
- package/dist/verification.js +272 -0
- package/dist/verification.js.map +10 -0
- package/package.json +6 -2
package/dist/index.d.ts
CHANGED
|
@@ -1038,6 +1038,81 @@ declare function camelizeKeys(obj: unknown): unknown;
|
|
|
1038
1038
|
* contribute nothing to typing.
|
|
1039
1039
|
*/
|
|
1040
1040
|
declare function inferPrintTopics(samples: PrintSample[]): InferredTopicSchema[];
|
|
1041
|
+
import { SubgraphVerification } from "@secondlayer/shared/schemas/subgraphs";
|
|
1042
|
+
/** Runtime identity baked into every pin: matcher, decode and flush semantics. */
|
|
1043
|
+
declare const SUBGRAPHS_RUNTIME: string;
|
|
1044
|
+
/**
|
|
1045
|
+
* One thing the deploy scan found in a bundled handler.
|
|
1046
|
+
*
|
|
1047
|
+
* - `nondeterministic`: breaks the determinism contract. Fails the deploy of
|
|
1048
|
+
* a state subgraph; advice for everything else.
|
|
1049
|
+
* - `needs-events`: deterministic, but reads something only re-execution proofs cover
|
|
1050
|
+
* (`ctx.client`). Raises the level instead of failing.
|
|
1051
|
+
*/
|
|
1052
|
+
interface HandlerFinding {
|
|
1053
|
+
kind: "nondeterministic" | "needs-events";
|
|
1054
|
+
/** What was used, e.g. `Date`, `Math.random`, `import()`, `ctx.client`. */
|
|
1055
|
+
name: string;
|
|
1056
|
+
reason: string;
|
|
1057
|
+
/** Original source file when a sourcemap was available, else the bundle. */
|
|
1058
|
+
file: string;
|
|
1059
|
+
/** 1-based. */
|
|
1060
|
+
line: number;
|
|
1061
|
+
/** 1-based. */
|
|
1062
|
+
column: number;
|
|
1063
|
+
}
|
|
1064
|
+
declare function formatFinding(f: HandlerFinding): string;
|
|
1065
|
+
/**
|
|
1066
|
+
* Derive how far a subgraph's rows can be checked. Level = the highest any
|
|
1067
|
+
* source or handler read needs. `reasons` lists everything standing between
|
|
1068
|
+
* the subgraph and checkable rows; a `state` subgraph with any reason is
|
|
1069
|
+
* refused at deploy, so every stored `state` row has none. Never configured,
|
|
1070
|
+
* never a flag.
|
|
1071
|
+
*/
|
|
1072
|
+
declare function deriveVerification(def: Pick<SubgraphDefinition, "sources" | "backfillMode">, findings?: readonly HandlerFinding[]): SubgraphVerification;
|
|
1073
|
+
/**
|
|
1074
|
+
* True when the deploy must be refused: the sources are provable (`state`), so
|
|
1075
|
+
* the determinism contract is enforced, and the scan broke it.
|
|
1076
|
+
*/
|
|
1077
|
+
declare function isDeterminismViolation(v: SubgraphVerification): boolean;
|
|
1078
|
+
interface PinInput {
|
|
1079
|
+
/** Existing `schema_hash` (name + schema + sources). */
|
|
1080
|
+
schemaHash: string;
|
|
1081
|
+
/** Bundled ESM exactly as stored in `subgraphs.handler_code`. */
|
|
1082
|
+
handlerCode: string;
|
|
1083
|
+
startBlock?: number | null;
|
|
1084
|
+
network: string;
|
|
1085
|
+
/** Defaults to {@link SUBGRAPHS_RUNTIME}. */
|
|
1086
|
+
runtime?: string;
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Content hash over everything that shapes a subgraph's rows. Unlike
|
|
1090
|
+
* `schema_hash`, it changes with the handler, `startBlock` and runtime, so
|
|
1091
|
+
* two deploys with the same pin produce the same rows from the same chain.
|
|
1092
|
+
*/
|
|
1093
|
+
declare function computePin(input: PinInput): string;
|
|
1094
|
+
/**
|
|
1095
|
+
* A handler broke the determinism contract at runtime. Infra-class: the
|
|
1096
|
+
* block aborts (rollback + retry) instead of skipping the event, because a
|
|
1097
|
+
* skip would commit output that depends on the run.
|
|
1098
|
+
*/
|
|
1099
|
+
declare class NondeterminismError extends Error {
|
|
1100
|
+
name: string;
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* A ctx read (DB, chain) failed under a verifiable subgraph. Infra-class like
|
|
1104
|
+
* {@link NondeterminismError}: skipping the event would make its rows depend
|
|
1105
|
+
* on whether the database was reachable.
|
|
1106
|
+
*/
|
|
1107
|
+
declare class HandlerReadError extends Error {
|
|
1108
|
+
name: string;
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Evaluate a bundled handler (ESM, as stored in `handler_code`) inside a
|
|
1112
|
+
* fresh deterministic realm and return its definition with every handler
|
|
1113
|
+
* wrapped to receive the {@link deterministicContext} facade.
|
|
1114
|
+
*/
|
|
1115
|
+
declare function loadDeterministicDefinition(handlerCode: string): Promise<SubgraphDefinition>;
|
|
1041
1116
|
interface GeneratedSQL {
|
|
1042
1117
|
statements: string[];
|
|
1043
1118
|
hash: string;
|
|
@@ -1178,10 +1253,16 @@ declare function deploySchema(db: AnyDb, def: SubgraphDefinition, handlerPath: s
|
|
|
1178
1253
|
schemaName?: string
|
|
1179
1254
|
handlerCode?: string
|
|
1180
1255
|
sourceCode?: string
|
|
1256
|
+
/** Derived level to store (see `deriveVerification`). */
|
|
1257
|
+
verification?: SubgraphVerification
|
|
1258
|
+
/** Network baked into the pin. Defaults to `NETWORK`, then mainnet. */
|
|
1259
|
+
network?: string
|
|
1181
1260
|
}): Promise<{
|
|
1182
1261
|
action: "created" | "unchanged" | "handler_updated" | "updated" | "reindexed"
|
|
1183
1262
|
subgraphId: string
|
|
1184
1263
|
version: string
|
|
1264
|
+
/** Present when the deploy carried a bundled handler. */
|
|
1265
|
+
pin?: string
|
|
1185
1266
|
diff?: DeployDiff
|
|
1186
1267
|
/** Non-fatal caveats the caller should surface (e.g. handler grafts at tip). */
|
|
1187
1268
|
warnings?: string[]
|
|
@@ -1229,4 +1310,4 @@ interface ReindexOptions {
|
|
|
1229
1310
|
operationId?: string;
|
|
1230
1311
|
signal?: AbortSignal;
|
|
1231
1312
|
}
|
|
1232
|
-
export { AggregateResult, AggregateSpec, AnyEvent, ChainReadCacheMode, ChainReadClient, ChainReadError, ChainReadMethods, ChainReadOptions, ColumnDiff, ColumnToTS, ColumnType, ComparisonFilter, ContractCallEvent, ContractCallFilter, ContractCallPayload, ContractDeployFilter, ContractDeployPayload, DeployDiff, DeployPlan, DrizzleGenOptions, ErasedChainReadClient, EventForFilter, FactoryScope, FindManyOptions, FindManyPage, FtBurnFilter, FtBurnPayload, FtMintFilter, FtMintPayload, FtTransferFilter, FtTransferPayload, GeneratedSQL, IndexCodegenOptions, IndexCodegenTarget, InferColumnType, InferContext, InferSubgraphClient, InferTableRow, InferredPrintField, InferredTopicSchema, KyselyGenOptions, MapDeletePayload, MapWritePayload, NestedContractCallPayload, NftBurnFilter, NftBurnPayload, NftMintFilter, NftMintPayload, NftTransferFilter, NftTransferPayload, PinnedPrintEventFilter, PrintDataOf, PrintEventFilter, PrintEventFor, PrintEventPayload, PrintEventPrints, PrintField, PrintFieldToTS, PrintSample, PrintValidationResult, PrismaGenOptions, ReindexOptions, RowValue, SparseProbeTarget, StxBurnFilter, StxBurnPayload, StxLockFilter, StxLockPayload, StxMintFilter, StxMintPayload, StxTransferFilter, StxTransferPayload, SubgraphColumn, SubgraphContext, SubgraphDefinition, SubgraphFilter, SubgraphHandler, SubgraphSchema, SubgraphTable, SubgraphTableClient, SubgraphTip, SubscribeOptions, SystemRow, TableDiff, TraitPrintEventFilter, TxMeta, TypedHandlers, TypedSubgraphContext, TypedSubgraphDefinition, UnpinnedPrintEventFilter, VarSetPayload, WhereInput, WriteRow, camelizeKeys, canSparseScan, defineSchema, defineSubgraph, deploySchema, diffSchema, filterFieldsByType, generateDrizzleSchema, generateIndexSchema, generateKyselySchema, generatePrismaSchema, generateSubgraphSQL, hasBreakingChanges, inferPrintTopics, isStreamsIndexEligible, pgSchemaName, readContractAt, renderDeployPlan, sparseProbeTargets, validateSubgraphDefinition };
|
|
1313
|
+
export { AggregateResult, AggregateSpec, AnyEvent, ChainReadCacheMode, ChainReadClient, ChainReadError, ChainReadMethods, ChainReadOptions, ColumnDiff, ColumnToTS, ColumnType, ComparisonFilter, ContractCallEvent, ContractCallFilter, ContractCallPayload, ContractDeployFilter, ContractDeployPayload, DeployDiff, DeployPlan, DrizzleGenOptions, ErasedChainReadClient, EventForFilter, FactoryScope, FindManyOptions, FindManyPage, FtBurnFilter, FtBurnPayload, FtMintFilter, FtMintPayload, FtTransferFilter, FtTransferPayload, GeneratedSQL, HandlerFinding, HandlerReadError, IndexCodegenOptions, IndexCodegenTarget, InferColumnType, InferContext, InferSubgraphClient, InferTableRow, InferredPrintField, InferredTopicSchema, KyselyGenOptions, MapDeletePayload, MapWritePayload, NestedContractCallPayload, NftBurnFilter, NftBurnPayload, NftMintFilter, NftMintPayload, NftTransferFilter, NftTransferPayload, NondeterminismError, PinInput, PinnedPrintEventFilter, PrintDataOf, PrintEventFilter, PrintEventFor, PrintEventPayload, PrintEventPrints, PrintField, PrintFieldToTS, PrintSample, PrintValidationResult, PrismaGenOptions, ReindexOptions, RowValue, SUBGRAPHS_RUNTIME, SparseProbeTarget, StxBurnFilter, StxBurnPayload, StxLockFilter, StxLockPayload, StxMintFilter, StxMintPayload, StxTransferFilter, StxTransferPayload, SubgraphColumn, SubgraphContext, SubgraphDefinition, SubgraphFilter, SubgraphHandler, SubgraphSchema, SubgraphTable, SubgraphTableClient, SubgraphTip, SubgraphVerification, SubscribeOptions, SystemRow, TableDiff, TraitPrintEventFilter, TxMeta, TypedHandlers, TypedSubgraphContext, TypedSubgraphDefinition, UnpinnedPrintEventFilter, VarSetPayload, WhereInput, WriteRow, camelizeKeys, canSparseScan, computePin, defineSchema, defineSubgraph, deploySchema, deriveVerification, diffSchema, filterFieldsByType, formatFinding, generateDrizzleSchema, generateIndexSchema, generateKyselySchema, generatePrismaSchema, generateSubgraphSQL, hasBreakingChanges, inferPrintTopics, isDeterminismViolation, isStreamsIndexEligible, loadDeterministicDefinition, pgSchemaName, readContractAt, renderDeployPlan, sparseProbeTargets, validateSubgraphDefinition };
|