@secondlayer/stacks 2.22.0 → 3.0.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/shared/stacks-2p9cazp7.cjs +263 -0
- package/dist/shared/stacks-2p9cazp7.cjs.map +12 -0
- package/dist/shared/stacks-tqrws7kd.js +252 -0
- package/dist/shared/stacks-tqrws7kd.js.map +12 -0
- package/dist/src/accounts/index.js +1 -2
- package/dist/src/accounts/index.js.map +2 -2
- package/dist/src/actions/index.js +1 -2
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bitcoin/index.js +1 -2
- package/dist/src/bitcoin/index.js.map +2 -2
- package/dist/src/bns/index.js +1 -2
- package/dist/src/bns/index.js.map +2 -2
- package/dist/src/chains/index.js +1 -2
- package/dist/src/chains/index.js.map +1 -1
- package/dist/src/clarity/index.js +1 -2
- package/dist/src/clarity/index.js.map +1 -1
- package/dist/src/filters/index.cjs +1 -261
- package/dist/src/filters/index.cjs.map +3 -6
- package/dist/src/filters/index.js +13 -249
- package/dist/src/filters/index.js.map +3 -6
- package/dist/src/index.cjs +2 -75
- package/dist/src/index.cjs.map +3 -8
- package/dist/src/index.d.cts +383 -164
- package/dist/src/index.d.ts +383 -164
- package/dist/src/index.js +5 -78
- package/dist/src/index.js.map +3 -8
- package/dist/src/postconditions/index.js +1 -2
- package/dist/src/postconditions/index.js.map +1 -1
- package/dist/src/pox/index.js +1 -2
- package/dist/src/pox/index.js.map +2 -2
- package/dist/src/pox5/index.js +1 -2
- package/dist/src/pox5/index.js.map +2 -2
- package/dist/src/sbtc/index.js +1 -2
- package/dist/src/sbtc/index.js.map +2 -2
- package/dist/src/stackingdao/index.js +1 -2
- package/dist/src/stackingdao/index.js.map +2 -2
- package/dist/src/subscriptions/index.js +1 -2
- package/dist/src/subscriptions/index.js.map +1 -1
- package/dist/src/transactions/index.js +1 -2
- package/dist/src/transactions/index.js.map +1 -1
- package/dist/src/utils/index.js +1 -2
- package/dist/src/utils/index.js.map +2 -2
- package/dist/src/x402/index.js +1 -2
- package/dist/src/x402/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/shared/stacks-cfazrteq.js +0 -20
- package/dist/shared/stacks-cfazrteq.js.map +0 -9
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
3
|
+
"sources": [],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"// The decoded event-type vocabulary — canonical home. Index (decoded layer)\n// and Streams (canonical firehose) expose the SAME set. This lives in\n// @secondlayer/stacks because it is the leaf of the dependency graph\n// (shared → stacks), so no package can drift a private copy upward:\n// @secondlayer/shared re-exports it for back-compat.\nexport const DECODED_EVENT_TYPES = [\n\t\"stx_transfer\",\n\t\"stx_mint\",\n\t\"stx_burn\",\n\t\"stx_lock\",\n\t\"ft_transfer\",\n\t\"ft_mint\",\n\t\"ft_burn\",\n\t\"nft_transfer\",\n\t\"nft_mint\",\n\t\"nft_burn\",\n\t\"print\",\n] as const;\n\nexport type DecodedEventType = (typeof DECODED_EVENT_TYPES)[number];\n\n/** Every chain-event filter member across all four surfaces: the 10 decoded\n * token/STX types, the three contract-shaped types (spelled as subgraphs and\n * triggers spell them — Index/Streams project `print_event` → `print`), and\n * the five sBTC lifecycle types (Subscriptions-only). */\nexport const CHAIN_EVENT_FILTER_TYPES = [\n\t\"stx_transfer\",\n\t\"stx_mint\",\n\t\"stx_burn\",\n\t\"stx_lock\",\n\t\"ft_transfer\",\n\t\"ft_mint\",\n\t\"ft_burn\",\n\t\"nft_transfer\",\n\t\"nft_mint\",\n\t\"nft_burn\",\n\t\"contract_call\",\n\t\"contract_deploy\",\n\t\"print_event\",\n\t\"sbtc_deposit\",\n\t\"sbtc_withdrawal_create\",\n\t\"sbtc_withdrawal_accept\",\n\t\"sbtc_withdrawal_reject\",\n\t\"sbtc_withdrawal_swept_confirmed\",\n] as const;\n\nexport type ChainEventFilterType = (typeof CHAIN_EVENT_FILTER_TYPES)[number];\n",
|
|
6
|
-
"import { isValidAddress } from \"../utils/address.ts\";\n\n/** A validated Stacks principal (standard or contract). Branded so downstream\n * code can require \"already validated\" without re-checking. */\nexport type Principal = string & { readonly __principal: unique symbol };\n\n/** `true` for a standard (`SP…`/`ST…`) or contract (`SP….name`) principal. */\nexport function isPrincipal(value: string): value is Principal {\n\tconst parts = value.split(\".\");\n\tif (parts.length > 2) return false;\n\tconst [addr, contractName] = parts;\n\tif (!addr || !isValidAddress(addr)) return false;\n\tif (parts.length === 2 && !contractName) return false;\n\treturn true;\n}\n\n/** Subscriptions match `*` wildcards in principal/identifier patterns; every\n * other surface treats the value literally. */\nexport function hasWildcard(value: string): boolean {\n\treturn value.includes(\"*\");\n}\n\n/** Throw unless `value` is a principal or a wildcard pattern. The factories\n * call this so a swapped argument (asset id where a sender belongs, typo'd\n * address) fails at construction — not as a silent zero-row query. */\nexport function assertPrincipalish(field: string, value: string): void {\n\tif (hasWildcard(value)) return;\n\tif (!isPrincipal(value)) {\n\t\tthrow new Error(\n\t\t\t`${field} \"${value}\" is not a valid Stacks principal (SP…/ST…, optionally .contract-name).`,\n\t\t);\n\t}\n}\n\n/** Throw unless `value` looks like `SP….contract::asset` (or a wildcard). */\nexport function assertAssetIdentifier(field: string, value: string): void {\n\tif (hasWildcard(value)) return;\n\tconst [contractId, assetName, ...rest] = value.split(\"::\");\n\tif (\n\t\t!contractId ||\n\t\t!assetName ||\n\t\trest.length > 0 ||\n\t\t!contractId.includes(\".\") ||\n\t\t!isPrincipal(contractId)\n\t) {\n\t\tthrow new Error(\n\t\t\t`${field} \"${value}\" is not a valid asset identifier (SP….contract-name::asset-name). Passing a bare contract id here matches zero rows — use contractId for that.`,\n\t\t);\n\t}\n}\n\n/** Throw unless `value` is a contract id `SP….name` (or a wildcard). */\nexport function assertContractId(field: string, value: string): void {\n\tif (hasWildcard(value)) return;\n\tif (value.includes(\"::\")) {\n\t\tthrow new Error(\n\t\t\t`${field} \"${value}\" is an asset identifier, not a contract id — use assetIdentifier for that.`,\n\t\t);\n\t}\n\tif (!value.includes(\".\") || !isPrincipal(value)) {\n\t\tthrow new Error(\n\t\t\t`${field} \"${value}\" is not a valid contract id (SP….contract-name).`,\n\t\t);\n\t}\n}\n",
|
|
7
|
-
"import type { AbiContract } from \"../clarity/abi/contract.ts\";\nimport type { ChainEventFilterType } from \"./event-types.ts\";\nimport type { SubgraphMemberType, SubgraphSourceSpec } from \"./types.ts\";\nimport type {\n\tChainEventFilter,\n\tChainEventFilterSpec,\n\tChainTriggerShape,\n\tContractCallsParamsShape,\n\tIndexEventsParamsShape,\n\tPrintFieldType,\n\tSpecFor,\n\tStreamsParamsShape,\n} from \"./types.ts\";\nimport {\n\tassertAssetIdentifier,\n\tassertContractId,\n\tassertPrincipalish,\n\thasWildcard,\n} from \"./validate.ts\";\n\n// ── Field metadata driving validation and projections ────────────────────\n\nconst PRINCIPAL_FIELDS = new Set([\n\t\"sender\",\n\t\"recipient\",\n\t\"caller\",\n\t\"deployer\",\n\t\"lockedAddress\",\n]);\nconst AMOUNT_FIELDS = new Set([\"minAmount\", \"maxAmount\"]);\n/** Fields with no filtering semantics — safe to drop in a projection. */\nconst DECORATIVE_FIELDS = new Set([\"abi\", \"prints\"]);\n\nfunction specEntries(spec: ChainEventFilterSpec): Array<[string, unknown]> {\n\treturn Object.entries(spec).filter(\n\t\t([key, value]) => key !== \"type\" && value !== undefined,\n\t);\n}\n\nfunction validateSpec(spec: ChainEventFilterSpec): void {\n\tfor (const [key, value] of specEntries(spec)) {\n\t\tif (PRINCIPAL_FIELDS.has(key)) {\n\t\t\tassertPrincipalish(key, value as string);\n\t\t} else if (key === \"assetIdentifier\") {\n\t\t\tassertAssetIdentifier(key, value as string);\n\t\t} else if (key === \"contractId\") {\n\t\t\t// A contract SET validates member-wise — one bad id in a router+pools\n\t\t\t// list must fail as loudly as a bad single id.\n\t\t\tfor (const id of Array.isArray(value) ? value : [value]) {\n\t\t\t\tassertContractId(key, id as string);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Throw for a field the target surface cannot express — dropping it would\n * silently widen the match, which is the exact bug this module exists to\n * kill. Names the surface that CAN express it. */\nfunction unsupported(surface: string, field: string, hint: string): never {\n\tthrow new Error(\n\t\t`${field} cannot be expressed on ${surface} — ${hint}. Drop the field from the filter or use the surface that supports it.`,\n\t);\n}\n\nfunction assertNoWildcards(surface: string, spec: ChainEventFilterSpec): void {\n\tfor (const [key, value] of specEntries(spec)) {\n\t\tif (typeof value === \"string\" && hasWildcard(value)) {\n\t\t\tunsupported(\n\t\t\t\tsurface,\n\t\t\t\t`${key} wildcard \"${value}\"`,\n\t\t\t\t\"wildcard patterns are Subscriptions-only\",\n\t\t\t);\n\t\t}\n\t}\n}\n\n// ── Projections ──────────────────────────────────────────────────────────\n\nfunction toChainTrigger(spec: ChainEventFilterSpec): ChainTriggerShape {\n\tconst out: Record<string, string | number> = {};\n\tfor (const [key, value] of specEntries(spec)) {\n\t\tif (DECORATIVE_FIELDS.has(key)) continue;\n\t\tif (Array.isArray(value)) {\n\t\t\t// One trigger, one contract: silently taking the first would watch\n\t\t\t// a fraction of what the filter says. Create one subscription per\n\t\t\t// contract instead.\n\t\t\tunsupported(\n\t\t\t\t\"Subscriptions\",\n\t\t\t\t`${key} set`,\n\t\t\t\t\"a chain trigger targets ONE contract — create one subscription per contract, or use Index/Subgraphs which accept the set\",\n\t\t\t);\n\t\t}\n\t\t// The one sanctioned bigint→string boundary.\n\t\tout[key] =\n\t\t\ttypeof value === \"bigint\" ? value.toString() : (value as string | number);\n\t}\n\treturn { type: spec.type, ...out };\n}\n\nfunction toIndexParams(\n\tspec: ChainEventFilterSpec,\n\textra: Record<string, unknown> = {},\n): IndexEventsParamsShape {\n\tassertNoWildcards(\"Index events\", spec);\n\tconst out: Record<string, unknown> = {\n\t\teventType: spec.type === \"print_event\" ? \"print\" : spec.type,\n\t};\n\tfor (const [key, value] of specEntries(spec)) {\n\t\tif (DECORATIVE_FIELDS.has(key)) continue;\n\t\tif (AMOUNT_FIELDS.has(key)) {\n\t\t\tunsupported(\n\t\t\t\t\"Index events\",\n\t\t\t\tkey,\n\t\t\t\t\"amount predicates are Subscriptions/Subgraphs-only; filter client-side on the decoded rows\",\n\t\t\t);\n\t\t}\n\t\tif (key === \"topic\") {\n\t\t\tunsupported(\n\t\t\t\t\"Index events\",\n\t\t\t\t\"topic\",\n\t\t\t\t\"per-topic reads are Subgraphs/Subscriptions-only (or read the contract's print feed and switch on topic)\",\n\t\t\t);\n\t\t}\n\t\tif (key === \"lockedAddress\") {\n\t\t\tunsupported(\n\t\t\t\t\"Index events\",\n\t\t\t\t\"lockedAddress\",\n\t\t\t\t\"stx_lock address filtering is Subscriptions/Subgraphs-only\",\n\t\t\t);\n\t\t}\n\t\tif (key === \"caller\") {\n\t\t\tunsupported(\n\t\t\t\t\"Index events\",\n\t\t\t\t\"caller\",\n\t\t\t\t\"contract-call fields live on index.contractCalls\",\n\t\t\t);\n\t\t}\n\t\tout[key] = value;\n\t}\n\treturn { ...out, ...extra } as IndexEventsParamsShape;\n}\n\nfunction toStreamsParams(\n\tspec: ChainEventFilterSpec,\n\textra: Record<string, unknown> = {},\n): StreamsParamsShape {\n\tassertNoWildcards(\"Streams\", spec);\n\tconst out: Record<string, unknown> = {\n\t\ttypes: [spec.type === \"print_event\" ? \"print\" : spec.type],\n\t};\n\tfor (const [key, value] of specEntries(spec)) {\n\t\tif (DECORATIVE_FIELDS.has(key)) continue;\n\t\tif (AMOUNT_FIELDS.has(key)) {\n\t\t\tunsupported(\n\t\t\t\t\"Streams\",\n\t\t\t\tkey,\n\t\t\t\t\"amount predicates are Subscriptions/Subgraphs-only\",\n\t\t\t);\n\t\t}\n\t\tif (key === \"trait\") {\n\t\t\tunsupported(\n\t\t\t\t\"Streams\",\n\t\t\t\t\"trait\",\n\t\t\t\t\"Streams has no trait resolution — Index and Subgraphs do\",\n\t\t\t);\n\t\t}\n\t\tif (key === \"topic\") {\n\t\t\tunsupported(\n\t\t\t\t\"Streams\",\n\t\t\t\t\"topic\",\n\t\t\t\t\"per-topic filtering is Subgraphs/Subscriptions-only\",\n\t\t\t);\n\t\t}\n\t\tif (key === \"lockedAddress\") {\n\t\t\tunsupported(\n\t\t\t\t\"Streams\",\n\t\t\t\t\"lockedAddress\",\n\t\t\t\t\"stx_lock address filtering is Subscriptions/Subgraphs-only\",\n\t\t\t);\n\t\t}\n\t\tout[key] = value;\n\t}\n\treturn { ...out, ...extra } as StreamsParamsShape;\n}\n\nfunction toContractCallsParams(\n\tspec: ChainEventFilterSpec,\n\textra: Record<string, unknown> = {},\n): ContractCallsParamsShape {\n\tassertNoWildcards(\"Index contract-calls\", spec);\n\tconst out: Record<string, unknown> = {};\n\tfor (const [key, value] of specEntries(spec)) {\n\t\tif (DECORATIVE_FIELDS.has(key)) continue;\n\t\tif (key === \"caller\") {\n\t\t\tunsupported(\n\t\t\t\t\"Index contract-calls\",\n\t\t\t\t\"caller\",\n\t\t\t\t\"caller filtering is Subscriptions/Subgraphs-only (the endpoint filters by tx sender)\",\n\t\t\t);\n\t\t}\n\t\tout[key] = value;\n\t}\n\treturn { ...out, ...extra } as ContractCallsParamsShape;\n}\n\nfunction toSubgraphSource(spec: ChainEventFilterSpec): ChainEventFilterSpec {\n\t// The spec IS the subgraph source shape (camelCase, bigint amounts,\n\t// literal prints/abi preserved). Strip the projection methods by copying\n\t// data fields only.\n\treturn Object.fromEntries([\n\t\t[\"type\", spec.type],\n\t\t...specEntries(spec),\n\t]) as unknown as ChainEventFilterSpec;\n}\n\n// ── Factory ──────────────────────────────────────────────────────────────\n\nconst DECODED_MEMBERS = new Set<ChainEventFilterType>([\n\t\"stx_transfer\",\n\t\"stx_mint\",\n\t\"stx_burn\",\n\t\"stx_lock\",\n\t\"ft_transfer\",\n\t\"ft_mint\",\n\t\"ft_burn\",\n\t\"nft_transfer\",\n\t\"nft_mint\",\n\t\"nft_burn\",\n\t\"print_event\",\n]);\n\n/** Build a canonical filter: validated spec + the projections its member\n * supports (methods are attached per member at runtime, matching the\n * type-level gating exactly). `const F` preserves field literals — a\n * `prints`/`abi` declaration keeps its exact type through\n * `toSubgraphSource()`, which is what feeds `defineSubgraph` narrowing. */\nexport function makeChainEventFilter<\n\tT extends ChainEventFilterType,\n\tconst F extends Omit<SpecFor<T>, \"type\">,\n>(type: T, fields: F): ChainEventFilter<T, { type: T } & F> {\n\tconst spec = { type, ...fields } as unknown as SpecFor<T>;\n\tvalidateSpec(spec);\n\n\tconst filter = { ...spec } as unknown as Record<string, unknown>;\n\tfilter.toChainTrigger = () => toChainTrigger(spec);\n\tif (DECODED_MEMBERS.has(type)) {\n\t\tfilter.toIndexParams = (extra?: Record<string, unknown>) =>\n\t\t\ttoIndexParams(spec, extra);\n\t\tfilter.toStreamsParams = (extra?: Record<string, unknown>) =>\n\t\t\ttoStreamsParams(spec, extra);\n\t}\n\tif (type === \"contract_call\") {\n\t\tfilter.toContractCallsParams = (extra?: Record<string, unknown>) =>\n\t\t\ttoContractCallsParams(spec, extra);\n\t}\n\tif (!type.startsWith(\"sbtc_\")) {\n\t\tfilter.toSubgraphSource = () => toSubgraphSource(spec);\n\t}\n\treturn filter as unknown as ChainEventFilter<T, { type: T } & F>;\n}\n\n/**\n * Rehydrate a canonical filter from a subgraph-source-shaped object (the\n * inverse of `toSubgraphSource`). Powers migration and the round-trip\n * property gate: `toSubgraphSource(fromSubgraphSource(f))` must deep-equal\n * `f` for every production subgraph source.\n */\nexport function fromSubgraphSource(\n\tsource: SubgraphSourceSpec,\n): ChainEventFilter<SubgraphMemberType> {\n\tconst { type, ...fields } = source;\n\treturn makeChainEventFilter(\n\t\ttype,\n\t\tfields as Omit<SpecFor<typeof type>, \"type\">,\n\t) as unknown as ChainEventFilter<SubgraphMemberType>;\n}\n\ntype Fields<T extends ChainEventFilterType> = Omit<SpecFor<T>, \"type\">;\n\n/** The `on.*` namespace, annotated explicitly — bunup's dts emitter needs an\n * annotation on exported values (an inferred object of generic factories\n * collapses to `{}` in the emitted declarations). */\nexport interface OnNamespace {\n\tstxTransfer(\n\t\tfields?: Fields<\"stx_transfer\">,\n\t): ChainEventFilter<\"stx_transfer\">;\n\tstxMint(fields?: Fields<\"stx_mint\">): ChainEventFilter<\"stx_mint\">;\n\tstxBurn(fields?: Fields<\"stx_burn\">): ChainEventFilter<\"stx_burn\">;\n\tstxLock(fields?: Fields<\"stx_lock\">): ChainEventFilter<\"stx_lock\">;\n\tftTransfer(fields?: Fields<\"ft_transfer\">): ChainEventFilter<\"ft_transfer\">;\n\tftMint(fields?: Fields<\"ft_mint\">): ChainEventFilter<\"ft_mint\">;\n\tftBurn(fields?: Fields<\"ft_burn\">): ChainEventFilter<\"ft_burn\">;\n\tnftTransfer(\n\t\tfields?: Fields<\"nft_transfer\">,\n\t): ChainEventFilter<\"nft_transfer\">;\n\tnftMint(fields?: Fields<\"nft_mint\">): ChainEventFilter<\"nft_mint\">;\n\tnftBurn(fields?: Fields<\"nft_burn\">): ChainEventFilter<\"nft_burn\">;\n\t/** `abi` literals are preserved (`const A`) so `toSubgraphSource()` keeps\n\t * typing `event.input` inside `defineSubgraph`. */\n\tcontractCall<const A extends AbiContract | undefined = undefined>(\n\t\tfields?: Omit<SpecFor<\"contract_call\">, \"type\" | \"abi\"> & { abi?: A },\n\t): ChainEventFilter<\n\t\t\"contract_call\",\n\t\t{ type: \"contract_call\" } & Omit<\n\t\t\tSpecFor<\"contract_call\">,\n\t\t\t\"type\" | \"abi\"\n\t\t> & {\n\t\t\t\tabi?: A;\n\t\t\t}\n\t>;\n\tcontractDeploy(\n\t\tfields?: Fields<\"contract_deploy\">,\n\t): ChainEventFilter<\"contract_deploy\">;\n\t/** Canonical member is `print_event` (as Subgraphs and Subscriptions spell\n\t * it); `toIndexParams`/`toStreamsParams` project to `print`. `prints`\n\t * literals are preserved (`const P`) for per-topic `event.data` narrowing. */\n\tprint<\n\t\tconst P extends\n\t\t\t| Record<string, Record<string, PrintFieldType>>\n\t\t\t| undefined = undefined,\n\t>(\n\t\tfields?: Omit<SpecFor<\"print_event\">, \"type\" | \"prints\"> & { prints?: P },\n\t): ChainEventFilter<\n\t\t\"print_event\",\n\t\t{ type: \"print_event\" } & Omit<\n\t\t\tSpecFor<\"print_event\">,\n\t\t\t\"type\" | \"prints\"\n\t\t> & {\n\t\t\t\tprints?: P;\n\t\t\t}\n\t>;\n\tsbtcDeposit(\n\t\tfields?: Fields<\"sbtc_deposit\">,\n\t): ChainEventFilter<\"sbtc_deposit\">;\n\tsbtcWithdrawalCreate(\n\t\tfields?: Fields<\"sbtc_withdrawal_create\">,\n\t): ChainEventFilter<\"sbtc_withdrawal_create\">;\n\tsbtcWithdrawalAccept(\n\t\tfields?: Fields<\"sbtc_withdrawal_accept\">,\n\t): ChainEventFilter<\"sbtc_withdrawal_accept\">;\n\tsbtcWithdrawalReject(\n\t\tfields?: Fields<\"sbtc_withdrawal_reject\">,\n\t): ChainEventFilter<\"sbtc_withdrawal_reject\">;\n\tsbtcWithdrawalSweptConfirmed(\n\t\tfields?: Fields<\"sbtc_withdrawal_swept_confirmed\">,\n\t): ChainEventFilter<\"sbtc_withdrawal_swept_confirmed\">;\n}\n\n/**\n * `on.*` — one filter vocabulary for every surface.\n *\n * ```ts\n * import { on } from \"@secondlayer/stacks/filters\";\n *\n * const usdc = on.ftTransfer({ assetIdentifier: USDC, minAmount: 1_000_000n });\n *\n * sl.index.events.list(usdc.toIndexParams({ limit: 100 })); // pull\n * sl.streams.events.consume({ ...usdc.toStreamsParams(), onBatch });\n * sl.subscriptions.create({ name, url, triggers: [usdc.toChainTrigger()] });\n * defineSubgraph({ sources: { usdc: usdc.toSubgraphSource() }, schema, handlers });\n * ```\n *\n * A surface a member can't reach is a missing method (compile error), and a\n * field a surface can't express throws at projection time — never a silent\n * zero-row or over-wide match.\n */\nexport const on: OnNamespace = {\n\tstxTransfer: (fields: Fields<\"stx_transfer\"> = {}) =>\n\t\tmakeChainEventFilter(\"stx_transfer\", fields),\n\tstxMint: (fields: Fields<\"stx_mint\"> = {}) =>\n\t\tmakeChainEventFilter(\"stx_mint\", fields),\n\tstxBurn: (fields: Fields<\"stx_burn\"> = {}) =>\n\t\tmakeChainEventFilter(\"stx_burn\", fields),\n\tstxLock: (fields: Fields<\"stx_lock\"> = {}) =>\n\t\tmakeChainEventFilter(\"stx_lock\", fields),\n\tftTransfer: (fields: Fields<\"ft_transfer\"> = {}) =>\n\t\tmakeChainEventFilter(\"ft_transfer\", fields),\n\tftMint: (fields: Fields<\"ft_mint\"> = {}) =>\n\t\tmakeChainEventFilter(\"ft_mint\", fields),\n\tftBurn: (fields: Fields<\"ft_burn\"> = {}) =>\n\t\tmakeChainEventFilter(\"ft_burn\", fields),\n\tnftTransfer: (fields: Fields<\"nft_transfer\"> = {}) =>\n\t\tmakeChainEventFilter(\"nft_transfer\", fields),\n\tnftMint: (fields: Fields<\"nft_mint\"> = {}) =>\n\t\tmakeChainEventFilter(\"nft_mint\", fields),\n\tnftBurn: (fields: Fields<\"nft_burn\"> = {}) =>\n\t\tmakeChainEventFilter(\"nft_burn\", fields),\n\tcontractCall: <const A extends AbiContract | undefined = undefined>(\n\t\tfields: Omit<SpecFor<\"contract_call\">, \"type\" | \"abi\"> & { abi?: A } = {},\n\t) => makeChainEventFilter(\"contract_call\", fields),\n\tcontractDeploy: (fields: Fields<\"contract_deploy\"> = {}) =>\n\t\tmakeChainEventFilter(\"contract_deploy\", fields),\n\t/** Canonical member is `print_event` (as Subgraphs and Subscriptions spell\n\t * it); `toIndexParams`/`toStreamsParams` project to `print`. */\n\tprint: <\n\t\tconst P extends\n\t\t\t| Record<string, Record<string, PrintFieldType>>\n\t\t\t| undefined = undefined,\n\t>(\n\t\tfields: Omit<SpecFor<\"print_event\">, \"type\" | \"prints\"> & {\n\t\t\tprints?: P;\n\t\t} = {},\n\t) => makeChainEventFilter(\"print_event\", fields),\n\tsbtcDeposit: (fields: Fields<\"sbtc_deposit\"> = {}) =>\n\t\tmakeChainEventFilter(\"sbtc_deposit\", fields),\n\tsbtcWithdrawalCreate: (fields: Fields<\"sbtc_withdrawal_create\"> = {}) =>\n\t\tmakeChainEventFilter(\"sbtc_withdrawal_create\", fields),\n\tsbtcWithdrawalAccept: (fields: Fields<\"sbtc_withdrawal_accept\"> = {}) =>\n\t\tmakeChainEventFilter(\"sbtc_withdrawal_accept\", fields),\n\tsbtcWithdrawalReject: (fields: Fields<\"sbtc_withdrawal_reject\"> = {}) =>\n\t\tmakeChainEventFilter(\"sbtc_withdrawal_reject\", fields),\n\tsbtcWithdrawalSweptConfirmed: (\n\t\tfields: Fields<\"sbtc_withdrawal_swept_confirmed\"> = {},\n\t) => makeChainEventFilter(\"sbtc_withdrawal_swept_confirmed\", fields),\n};\n"
|
|
8
5
|
],
|
|
9
|
-
"mappings": "
|
|
10
|
-
"debugId": "
|
|
6
|
+
"mappings": "",
|
|
7
|
+
"debugId": "DDDF1E5FDE06A0EC64756E2164756E21",
|
|
11
8
|
"names": []
|
|
12
9
|
}
|
|
@@ -1,253 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
CHAIN_EVENT_FILTER_TYPES,
|
|
3
|
+
DECODED_EVENT_TYPES,
|
|
4
|
+
assertAssetIdentifier,
|
|
5
|
+
assertContractId,
|
|
6
|
+
assertPrincipalish,
|
|
7
|
+
fromSubgraphSource,
|
|
8
|
+
hasWildcard,
|
|
9
|
+
isPrincipal,
|
|
10
|
+
makeChainEventFilter,
|
|
11
|
+
on
|
|
12
|
+
} from "../../shared/stacks-tqrws7kd.js";
|
|
13
|
+
import"../../shared/stacks-azp00pve.js";
|
|
4
14
|
import"../../shared/stacks-qs5fzts5.js";
|
|
5
|
-
import"../../shared/stacks-cfazrteq.js";
|
|
6
|
-
|
|
7
|
-
// src/filters/event-types.ts
|
|
8
|
-
var DECODED_EVENT_TYPES = [
|
|
9
|
-
"stx_transfer",
|
|
10
|
-
"stx_mint",
|
|
11
|
-
"stx_burn",
|
|
12
|
-
"stx_lock",
|
|
13
|
-
"ft_transfer",
|
|
14
|
-
"ft_mint",
|
|
15
|
-
"ft_burn",
|
|
16
|
-
"nft_transfer",
|
|
17
|
-
"nft_mint",
|
|
18
|
-
"nft_burn",
|
|
19
|
-
"print"
|
|
20
|
-
];
|
|
21
|
-
var CHAIN_EVENT_FILTER_TYPES = [
|
|
22
|
-
"stx_transfer",
|
|
23
|
-
"stx_mint",
|
|
24
|
-
"stx_burn",
|
|
25
|
-
"stx_lock",
|
|
26
|
-
"ft_transfer",
|
|
27
|
-
"ft_mint",
|
|
28
|
-
"ft_burn",
|
|
29
|
-
"nft_transfer",
|
|
30
|
-
"nft_mint",
|
|
31
|
-
"nft_burn",
|
|
32
|
-
"contract_call",
|
|
33
|
-
"contract_deploy",
|
|
34
|
-
"print_event",
|
|
35
|
-
"sbtc_deposit",
|
|
36
|
-
"sbtc_withdrawal_create",
|
|
37
|
-
"sbtc_withdrawal_accept",
|
|
38
|
-
"sbtc_withdrawal_reject",
|
|
39
|
-
"sbtc_withdrawal_swept_confirmed"
|
|
40
|
-
];
|
|
41
|
-
// src/filters/validate.ts
|
|
42
|
-
function isPrincipal(value) {
|
|
43
|
-
const parts = value.split(".");
|
|
44
|
-
if (parts.length > 2)
|
|
45
|
-
return false;
|
|
46
|
-
const [addr, contractName] = parts;
|
|
47
|
-
if (!addr || !isValidAddress(addr))
|
|
48
|
-
return false;
|
|
49
|
-
if (parts.length === 2 && !contractName)
|
|
50
|
-
return false;
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
function hasWildcard(value) {
|
|
54
|
-
return value.includes("*");
|
|
55
|
-
}
|
|
56
|
-
function assertPrincipalish(field, value) {
|
|
57
|
-
if (hasWildcard(value))
|
|
58
|
-
return;
|
|
59
|
-
if (!isPrincipal(value)) {
|
|
60
|
-
throw new Error(`${field} "${value}" is not a valid Stacks principal (SP…/ST…, optionally .contract-name).`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function assertAssetIdentifier(field, value) {
|
|
64
|
-
if (hasWildcard(value))
|
|
65
|
-
return;
|
|
66
|
-
const [contractId, assetName, ...rest] = value.split("::");
|
|
67
|
-
if (!contractId || !assetName || rest.length > 0 || !contractId.includes(".") || !isPrincipal(contractId)) {
|
|
68
|
-
throw new Error(`${field} "${value}" is not a valid asset identifier (SP….contract-name::asset-name). Passing a bare contract id here matches zero rows — use contractId for that.`);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function assertContractId(field, value) {
|
|
72
|
-
if (hasWildcard(value))
|
|
73
|
-
return;
|
|
74
|
-
if (value.includes("::")) {
|
|
75
|
-
throw new Error(`${field} "${value}" is an asset identifier, not a contract id — use assetIdentifier for that.`);
|
|
76
|
-
}
|
|
77
|
-
if (!value.includes(".") || !isPrincipal(value)) {
|
|
78
|
-
throw new Error(`${field} "${value}" is not a valid contract id (SP….contract-name).`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// src/filters/factories.ts
|
|
83
|
-
var PRINCIPAL_FIELDS = new Set([
|
|
84
|
-
"sender",
|
|
85
|
-
"recipient",
|
|
86
|
-
"caller",
|
|
87
|
-
"deployer",
|
|
88
|
-
"lockedAddress"
|
|
89
|
-
]);
|
|
90
|
-
var AMOUNT_FIELDS = new Set(["minAmount", "maxAmount"]);
|
|
91
|
-
var DECORATIVE_FIELDS = new Set(["abi", "prints"]);
|
|
92
|
-
function specEntries(spec) {
|
|
93
|
-
return Object.entries(spec).filter(([key, value]) => key !== "type" && value !== undefined);
|
|
94
|
-
}
|
|
95
|
-
function validateSpec(spec) {
|
|
96
|
-
for (const [key, value] of specEntries(spec)) {
|
|
97
|
-
if (PRINCIPAL_FIELDS.has(key)) {
|
|
98
|
-
assertPrincipalish(key, value);
|
|
99
|
-
} else if (key === "assetIdentifier") {
|
|
100
|
-
assertAssetIdentifier(key, value);
|
|
101
|
-
} else if (key === "contractId") {
|
|
102
|
-
for (const id of Array.isArray(value) ? value : [value]) {
|
|
103
|
-
assertContractId(key, id);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
function unsupported(surface, field, hint) {
|
|
109
|
-
throw new Error(`${field} cannot be expressed on ${surface} — ${hint}. Drop the field from the filter or use the surface that supports it.`);
|
|
110
|
-
}
|
|
111
|
-
function assertNoWildcards(surface, spec) {
|
|
112
|
-
for (const [key, value] of specEntries(spec)) {
|
|
113
|
-
if (typeof value === "string" && hasWildcard(value)) {
|
|
114
|
-
unsupported(surface, `${key} wildcard "${value}"`, "wildcard patterns are Subscriptions-only");
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function toChainTrigger(spec) {
|
|
119
|
-
const out = {};
|
|
120
|
-
for (const [key, value] of specEntries(spec)) {
|
|
121
|
-
if (DECORATIVE_FIELDS.has(key))
|
|
122
|
-
continue;
|
|
123
|
-
if (Array.isArray(value)) {
|
|
124
|
-
unsupported("Subscriptions", `${key} set`, "a chain trigger targets ONE contract — create one subscription per contract, or use Index/Subgraphs which accept the set");
|
|
125
|
-
}
|
|
126
|
-
out[key] = typeof value === "bigint" ? value.toString() : value;
|
|
127
|
-
}
|
|
128
|
-
return { type: spec.type, ...out };
|
|
129
|
-
}
|
|
130
|
-
function toIndexParams(spec, extra = {}) {
|
|
131
|
-
assertNoWildcards("Index events", spec);
|
|
132
|
-
const out = {
|
|
133
|
-
eventType: spec.type === "print_event" ? "print" : spec.type
|
|
134
|
-
};
|
|
135
|
-
for (const [key, value] of specEntries(spec)) {
|
|
136
|
-
if (DECORATIVE_FIELDS.has(key))
|
|
137
|
-
continue;
|
|
138
|
-
if (AMOUNT_FIELDS.has(key)) {
|
|
139
|
-
unsupported("Index events", key, "amount predicates are Subscriptions/Subgraphs-only; filter client-side on the decoded rows");
|
|
140
|
-
}
|
|
141
|
-
if (key === "topic") {
|
|
142
|
-
unsupported("Index events", "topic", "per-topic reads are Subgraphs/Subscriptions-only (or read the contract's print feed and switch on topic)");
|
|
143
|
-
}
|
|
144
|
-
if (key === "lockedAddress") {
|
|
145
|
-
unsupported("Index events", "lockedAddress", "stx_lock address filtering is Subscriptions/Subgraphs-only");
|
|
146
|
-
}
|
|
147
|
-
if (key === "caller") {
|
|
148
|
-
unsupported("Index events", "caller", "contract-call fields live on index.contractCalls");
|
|
149
|
-
}
|
|
150
|
-
out[key] = value;
|
|
151
|
-
}
|
|
152
|
-
return { ...out, ...extra };
|
|
153
|
-
}
|
|
154
|
-
function toStreamsParams(spec, extra = {}) {
|
|
155
|
-
assertNoWildcards("Streams", spec);
|
|
156
|
-
const out = {
|
|
157
|
-
types: [spec.type === "print_event" ? "print" : spec.type]
|
|
158
|
-
};
|
|
159
|
-
for (const [key, value] of specEntries(spec)) {
|
|
160
|
-
if (DECORATIVE_FIELDS.has(key))
|
|
161
|
-
continue;
|
|
162
|
-
if (AMOUNT_FIELDS.has(key)) {
|
|
163
|
-
unsupported("Streams", key, "amount predicates are Subscriptions/Subgraphs-only");
|
|
164
|
-
}
|
|
165
|
-
if (key === "trait") {
|
|
166
|
-
unsupported("Streams", "trait", "Streams has no trait resolution — Index and Subgraphs do");
|
|
167
|
-
}
|
|
168
|
-
if (key === "topic") {
|
|
169
|
-
unsupported("Streams", "topic", "per-topic filtering is Subgraphs/Subscriptions-only");
|
|
170
|
-
}
|
|
171
|
-
if (key === "lockedAddress") {
|
|
172
|
-
unsupported("Streams", "lockedAddress", "stx_lock address filtering is Subscriptions/Subgraphs-only");
|
|
173
|
-
}
|
|
174
|
-
out[key] = value;
|
|
175
|
-
}
|
|
176
|
-
return { ...out, ...extra };
|
|
177
|
-
}
|
|
178
|
-
function toContractCallsParams(spec, extra = {}) {
|
|
179
|
-
assertNoWildcards("Index contract-calls", spec);
|
|
180
|
-
const out = {};
|
|
181
|
-
for (const [key, value] of specEntries(spec)) {
|
|
182
|
-
if (DECORATIVE_FIELDS.has(key))
|
|
183
|
-
continue;
|
|
184
|
-
if (key === "caller") {
|
|
185
|
-
unsupported("Index contract-calls", "caller", "caller filtering is Subscriptions/Subgraphs-only (the endpoint filters by tx sender)");
|
|
186
|
-
}
|
|
187
|
-
out[key] = value;
|
|
188
|
-
}
|
|
189
|
-
return { ...out, ...extra };
|
|
190
|
-
}
|
|
191
|
-
function toSubgraphSource(spec) {
|
|
192
|
-
return Object.fromEntries([
|
|
193
|
-
["type", spec.type],
|
|
194
|
-
...specEntries(spec)
|
|
195
|
-
]);
|
|
196
|
-
}
|
|
197
|
-
var DECODED_MEMBERS = new Set([
|
|
198
|
-
"stx_transfer",
|
|
199
|
-
"stx_mint",
|
|
200
|
-
"stx_burn",
|
|
201
|
-
"stx_lock",
|
|
202
|
-
"ft_transfer",
|
|
203
|
-
"ft_mint",
|
|
204
|
-
"ft_burn",
|
|
205
|
-
"nft_transfer",
|
|
206
|
-
"nft_mint",
|
|
207
|
-
"nft_burn",
|
|
208
|
-
"print_event"
|
|
209
|
-
]);
|
|
210
|
-
function makeChainEventFilter(type, fields) {
|
|
211
|
-
const spec = { type, ...fields };
|
|
212
|
-
validateSpec(spec);
|
|
213
|
-
const filter = { ...spec };
|
|
214
|
-
filter.toChainTrigger = () => toChainTrigger(spec);
|
|
215
|
-
if (DECODED_MEMBERS.has(type)) {
|
|
216
|
-
filter.toIndexParams = (extra) => toIndexParams(spec, extra);
|
|
217
|
-
filter.toStreamsParams = (extra) => toStreamsParams(spec, extra);
|
|
218
|
-
}
|
|
219
|
-
if (type === "contract_call") {
|
|
220
|
-
filter.toContractCallsParams = (extra) => toContractCallsParams(spec, extra);
|
|
221
|
-
}
|
|
222
|
-
if (!type.startsWith("sbtc_")) {
|
|
223
|
-
filter.toSubgraphSource = () => toSubgraphSource(spec);
|
|
224
|
-
}
|
|
225
|
-
return filter;
|
|
226
|
-
}
|
|
227
|
-
function fromSubgraphSource(source) {
|
|
228
|
-
const { type, ...fields } = source;
|
|
229
|
-
return makeChainEventFilter(type, fields);
|
|
230
|
-
}
|
|
231
|
-
var on = {
|
|
232
|
-
stxTransfer: (fields = {}) => makeChainEventFilter("stx_transfer", fields),
|
|
233
|
-
stxMint: (fields = {}) => makeChainEventFilter("stx_mint", fields),
|
|
234
|
-
stxBurn: (fields = {}) => makeChainEventFilter("stx_burn", fields),
|
|
235
|
-
stxLock: (fields = {}) => makeChainEventFilter("stx_lock", fields),
|
|
236
|
-
ftTransfer: (fields = {}) => makeChainEventFilter("ft_transfer", fields),
|
|
237
|
-
ftMint: (fields = {}) => makeChainEventFilter("ft_mint", fields),
|
|
238
|
-
ftBurn: (fields = {}) => makeChainEventFilter("ft_burn", fields),
|
|
239
|
-
nftTransfer: (fields = {}) => makeChainEventFilter("nft_transfer", fields),
|
|
240
|
-
nftMint: (fields = {}) => makeChainEventFilter("nft_mint", fields),
|
|
241
|
-
nftBurn: (fields = {}) => makeChainEventFilter("nft_burn", fields),
|
|
242
|
-
contractCall: (fields = {}) => makeChainEventFilter("contract_call", fields),
|
|
243
|
-
contractDeploy: (fields = {}) => makeChainEventFilter("contract_deploy", fields),
|
|
244
|
-
print: (fields = {}) => makeChainEventFilter("print_event", fields),
|
|
245
|
-
sbtcDeposit: (fields = {}) => makeChainEventFilter("sbtc_deposit", fields),
|
|
246
|
-
sbtcWithdrawalCreate: (fields = {}) => makeChainEventFilter("sbtc_withdrawal_create", fields),
|
|
247
|
-
sbtcWithdrawalAccept: (fields = {}) => makeChainEventFilter("sbtc_withdrawal_accept", fields),
|
|
248
|
-
sbtcWithdrawalReject: (fields = {}) => makeChainEventFilter("sbtc_withdrawal_reject", fields),
|
|
249
|
-
sbtcWithdrawalSweptConfirmed: (fields = {}) => makeChainEventFilter("sbtc_withdrawal_swept_confirmed", fields)
|
|
250
|
-
};
|
|
251
15
|
export {
|
|
252
16
|
on,
|
|
253
17
|
makeChainEventFilter,
|
|
@@ -261,5 +25,5 @@ export {
|
|
|
261
25
|
CHAIN_EVENT_FILTER_TYPES
|
|
262
26
|
};
|
|
263
27
|
|
|
264
|
-
//# debugId=
|
|
28
|
+
//# debugId=0BF4319B462244F964756E2164756E21
|
|
265
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
3
|
+
"sources": [],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"// The decoded event-type vocabulary — canonical home. Index (decoded layer)\n// and Streams (canonical firehose) expose the SAME set. This lives in\n// @secondlayer/stacks because it is the leaf of the dependency graph\n// (shared → stacks), so no package can drift a private copy upward:\n// @secondlayer/shared re-exports it for back-compat.\nexport const DECODED_EVENT_TYPES = [\n\t\"stx_transfer\",\n\t\"stx_mint\",\n\t\"stx_burn\",\n\t\"stx_lock\",\n\t\"ft_transfer\",\n\t\"ft_mint\",\n\t\"ft_burn\",\n\t\"nft_transfer\",\n\t\"nft_mint\",\n\t\"nft_burn\",\n\t\"print\",\n] as const;\n\nexport type DecodedEventType = (typeof DECODED_EVENT_TYPES)[number];\n\n/** Every chain-event filter member across all four surfaces: the 10 decoded\n * token/STX types, the three contract-shaped types (spelled as subgraphs and\n * triggers spell them — Index/Streams project `print_event` → `print`), and\n * the five sBTC lifecycle types (Subscriptions-only). */\nexport const CHAIN_EVENT_FILTER_TYPES = [\n\t\"stx_transfer\",\n\t\"stx_mint\",\n\t\"stx_burn\",\n\t\"stx_lock\",\n\t\"ft_transfer\",\n\t\"ft_mint\",\n\t\"ft_burn\",\n\t\"nft_transfer\",\n\t\"nft_mint\",\n\t\"nft_burn\",\n\t\"contract_call\",\n\t\"contract_deploy\",\n\t\"print_event\",\n\t\"sbtc_deposit\",\n\t\"sbtc_withdrawal_create\",\n\t\"sbtc_withdrawal_accept\",\n\t\"sbtc_withdrawal_reject\",\n\t\"sbtc_withdrawal_swept_confirmed\",\n] as const;\n\nexport type ChainEventFilterType = (typeof CHAIN_EVENT_FILTER_TYPES)[number];\n",
|
|
6
|
-
"import { isValidAddress } from \"../utils/address.ts\";\n\n/** A validated Stacks principal (standard or contract). Branded so downstream\n * code can require \"already validated\" without re-checking. */\nexport type Principal = string & { readonly __principal: unique symbol };\n\n/** `true` for a standard (`SP…`/`ST…`) or contract (`SP….name`) principal. */\nexport function isPrincipal(value: string): value is Principal {\n\tconst parts = value.split(\".\");\n\tif (parts.length > 2) return false;\n\tconst [addr, contractName] = parts;\n\tif (!addr || !isValidAddress(addr)) return false;\n\tif (parts.length === 2 && !contractName) return false;\n\treturn true;\n}\n\n/** Subscriptions match `*` wildcards in principal/identifier patterns; every\n * other surface treats the value literally. */\nexport function hasWildcard(value: string): boolean {\n\treturn value.includes(\"*\");\n}\n\n/** Throw unless `value` is a principal or a wildcard pattern. The factories\n * call this so a swapped argument (asset id where a sender belongs, typo'd\n * address) fails at construction — not as a silent zero-row query. */\nexport function assertPrincipalish(field: string, value: string): void {\n\tif (hasWildcard(value)) return;\n\tif (!isPrincipal(value)) {\n\t\tthrow new Error(\n\t\t\t`${field} \"${value}\" is not a valid Stacks principal (SP…/ST…, optionally .contract-name).`,\n\t\t);\n\t}\n}\n\n/** Throw unless `value` looks like `SP….contract::asset` (or a wildcard). */\nexport function assertAssetIdentifier(field: string, value: string): void {\n\tif (hasWildcard(value)) return;\n\tconst [contractId, assetName, ...rest] = value.split(\"::\");\n\tif (\n\t\t!contractId ||\n\t\t!assetName ||\n\t\trest.length > 0 ||\n\t\t!contractId.includes(\".\") ||\n\t\t!isPrincipal(contractId)\n\t) {\n\t\tthrow new Error(\n\t\t\t`${field} \"${value}\" is not a valid asset identifier (SP….contract-name::asset-name). Passing a bare contract id here matches zero rows — use contractId for that.`,\n\t\t);\n\t}\n}\n\n/** Throw unless `value` is a contract id `SP….name` (or a wildcard). */\nexport function assertContractId(field: string, value: string): void {\n\tif (hasWildcard(value)) return;\n\tif (value.includes(\"::\")) {\n\t\tthrow new Error(\n\t\t\t`${field} \"${value}\" is an asset identifier, not a contract id — use assetIdentifier for that.`,\n\t\t);\n\t}\n\tif (!value.includes(\".\") || !isPrincipal(value)) {\n\t\tthrow new Error(\n\t\t\t`${field} \"${value}\" is not a valid contract id (SP….contract-name).`,\n\t\t);\n\t}\n}\n",
|
|
7
|
-
"import type { AbiContract } from \"../clarity/abi/contract.ts\";\nimport type { ChainEventFilterType } from \"./event-types.ts\";\nimport type { SubgraphMemberType, SubgraphSourceSpec } from \"./types.ts\";\nimport type {\n\tChainEventFilter,\n\tChainEventFilterSpec,\n\tChainTriggerShape,\n\tContractCallsParamsShape,\n\tIndexEventsParamsShape,\n\tPrintFieldType,\n\tSpecFor,\n\tStreamsParamsShape,\n} from \"./types.ts\";\nimport {\n\tassertAssetIdentifier,\n\tassertContractId,\n\tassertPrincipalish,\n\thasWildcard,\n} from \"./validate.ts\";\n\n// ── Field metadata driving validation and projections ────────────────────\n\nconst PRINCIPAL_FIELDS = new Set([\n\t\"sender\",\n\t\"recipient\",\n\t\"caller\",\n\t\"deployer\",\n\t\"lockedAddress\",\n]);\nconst AMOUNT_FIELDS = new Set([\"minAmount\", \"maxAmount\"]);\n/** Fields with no filtering semantics — safe to drop in a projection. */\nconst DECORATIVE_FIELDS = new Set([\"abi\", \"prints\"]);\n\nfunction specEntries(spec: ChainEventFilterSpec): Array<[string, unknown]> {\n\treturn Object.entries(spec).filter(\n\t\t([key, value]) => key !== \"type\" && value !== undefined,\n\t);\n}\n\nfunction validateSpec(spec: ChainEventFilterSpec): void {\n\tfor (const [key, value] of specEntries(spec)) {\n\t\tif (PRINCIPAL_FIELDS.has(key)) {\n\t\t\tassertPrincipalish(key, value as string);\n\t\t} else if (key === \"assetIdentifier\") {\n\t\t\tassertAssetIdentifier(key, value as string);\n\t\t} else if (key === \"contractId\") {\n\t\t\t// A contract SET validates member-wise — one bad id in a router+pools\n\t\t\t// list must fail as loudly as a bad single id.\n\t\t\tfor (const id of Array.isArray(value) ? value : [value]) {\n\t\t\t\tassertContractId(key, id as string);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Throw for a field the target surface cannot express — dropping it would\n * silently widen the match, which is the exact bug this module exists to\n * kill. Names the surface that CAN express it. */\nfunction unsupported(surface: string, field: string, hint: string): never {\n\tthrow new Error(\n\t\t`${field} cannot be expressed on ${surface} — ${hint}. Drop the field from the filter or use the surface that supports it.`,\n\t);\n}\n\nfunction assertNoWildcards(surface: string, spec: ChainEventFilterSpec): void {\n\tfor (const [key, value] of specEntries(spec)) {\n\t\tif (typeof value === \"string\" && hasWildcard(value)) {\n\t\t\tunsupported(\n\t\t\t\tsurface,\n\t\t\t\t`${key} wildcard \"${value}\"`,\n\t\t\t\t\"wildcard patterns are Subscriptions-only\",\n\t\t\t);\n\t\t}\n\t}\n}\n\n// ── Projections ──────────────────────────────────────────────────────────\n\nfunction toChainTrigger(spec: ChainEventFilterSpec): ChainTriggerShape {\n\tconst out: Record<string, string | number> = {};\n\tfor (const [key, value] of specEntries(spec)) {\n\t\tif (DECORATIVE_FIELDS.has(key)) continue;\n\t\tif (Array.isArray(value)) {\n\t\t\t// One trigger, one contract: silently taking the first would watch\n\t\t\t// a fraction of what the filter says. Create one subscription per\n\t\t\t// contract instead.\n\t\t\tunsupported(\n\t\t\t\t\"Subscriptions\",\n\t\t\t\t`${key} set`,\n\t\t\t\t\"a chain trigger targets ONE contract — create one subscription per contract, or use Index/Subgraphs which accept the set\",\n\t\t\t);\n\t\t}\n\t\t// The one sanctioned bigint→string boundary.\n\t\tout[key] =\n\t\t\ttypeof value === \"bigint\" ? value.toString() : (value as string | number);\n\t}\n\treturn { type: spec.type, ...out };\n}\n\nfunction toIndexParams(\n\tspec: ChainEventFilterSpec,\n\textra: Record<string, unknown> = {},\n): IndexEventsParamsShape {\n\tassertNoWildcards(\"Index events\", spec);\n\tconst out: Record<string, unknown> = {\n\t\teventType: spec.type === \"print_event\" ? \"print\" : spec.type,\n\t};\n\tfor (const [key, value] of specEntries(spec)) {\n\t\tif (DECORATIVE_FIELDS.has(key)) continue;\n\t\tif (AMOUNT_FIELDS.has(key)) {\n\t\t\tunsupported(\n\t\t\t\t\"Index events\",\n\t\t\t\tkey,\n\t\t\t\t\"amount predicates are Subscriptions/Subgraphs-only; filter client-side on the decoded rows\",\n\t\t\t);\n\t\t}\n\t\tif (key === \"topic\") {\n\t\t\tunsupported(\n\t\t\t\t\"Index events\",\n\t\t\t\t\"topic\",\n\t\t\t\t\"per-topic reads are Subgraphs/Subscriptions-only (or read the contract's print feed and switch on topic)\",\n\t\t\t);\n\t\t}\n\t\tif (key === \"lockedAddress\") {\n\t\t\tunsupported(\n\t\t\t\t\"Index events\",\n\t\t\t\t\"lockedAddress\",\n\t\t\t\t\"stx_lock address filtering is Subscriptions/Subgraphs-only\",\n\t\t\t);\n\t\t}\n\t\tif (key === \"caller\") {\n\t\t\tunsupported(\n\t\t\t\t\"Index events\",\n\t\t\t\t\"caller\",\n\t\t\t\t\"contract-call fields live on index.contractCalls\",\n\t\t\t);\n\t\t}\n\t\tout[key] = value;\n\t}\n\treturn { ...out, ...extra } as IndexEventsParamsShape;\n}\n\nfunction toStreamsParams(\n\tspec: ChainEventFilterSpec,\n\textra: Record<string, unknown> = {},\n): StreamsParamsShape {\n\tassertNoWildcards(\"Streams\", spec);\n\tconst out: Record<string, unknown> = {\n\t\ttypes: [spec.type === \"print_event\" ? \"print\" : spec.type],\n\t};\n\tfor (const [key, value] of specEntries(spec)) {\n\t\tif (DECORATIVE_FIELDS.has(key)) continue;\n\t\tif (AMOUNT_FIELDS.has(key)) {\n\t\t\tunsupported(\n\t\t\t\t\"Streams\",\n\t\t\t\tkey,\n\t\t\t\t\"amount predicates are Subscriptions/Subgraphs-only\",\n\t\t\t);\n\t\t}\n\t\tif (key === \"trait\") {\n\t\t\tunsupported(\n\t\t\t\t\"Streams\",\n\t\t\t\t\"trait\",\n\t\t\t\t\"Streams has no trait resolution — Index and Subgraphs do\",\n\t\t\t);\n\t\t}\n\t\tif (key === \"topic\") {\n\t\t\tunsupported(\n\t\t\t\t\"Streams\",\n\t\t\t\t\"topic\",\n\t\t\t\t\"per-topic filtering is Subgraphs/Subscriptions-only\",\n\t\t\t);\n\t\t}\n\t\tif (key === \"lockedAddress\") {\n\t\t\tunsupported(\n\t\t\t\t\"Streams\",\n\t\t\t\t\"lockedAddress\",\n\t\t\t\t\"stx_lock address filtering is Subscriptions/Subgraphs-only\",\n\t\t\t);\n\t\t}\n\t\tout[key] = value;\n\t}\n\treturn { ...out, ...extra } as StreamsParamsShape;\n}\n\nfunction toContractCallsParams(\n\tspec: ChainEventFilterSpec,\n\textra: Record<string, unknown> = {},\n): ContractCallsParamsShape {\n\tassertNoWildcards(\"Index contract-calls\", spec);\n\tconst out: Record<string, unknown> = {};\n\tfor (const [key, value] of specEntries(spec)) {\n\t\tif (DECORATIVE_FIELDS.has(key)) continue;\n\t\tif (key === \"caller\") {\n\t\t\tunsupported(\n\t\t\t\t\"Index contract-calls\",\n\t\t\t\t\"caller\",\n\t\t\t\t\"caller filtering is Subscriptions/Subgraphs-only (the endpoint filters by tx sender)\",\n\t\t\t);\n\t\t}\n\t\tout[key] = value;\n\t}\n\treturn { ...out, ...extra } as ContractCallsParamsShape;\n}\n\nfunction toSubgraphSource(spec: ChainEventFilterSpec): ChainEventFilterSpec {\n\t// The spec IS the subgraph source shape (camelCase, bigint amounts,\n\t// literal prints/abi preserved). Strip the projection methods by copying\n\t// data fields only.\n\treturn Object.fromEntries([\n\t\t[\"type\", spec.type],\n\t\t...specEntries(spec),\n\t]) as unknown as ChainEventFilterSpec;\n}\n\n// ── Factory ──────────────────────────────────────────────────────────────\n\nconst DECODED_MEMBERS = new Set<ChainEventFilterType>([\n\t\"stx_transfer\",\n\t\"stx_mint\",\n\t\"stx_burn\",\n\t\"stx_lock\",\n\t\"ft_transfer\",\n\t\"ft_mint\",\n\t\"ft_burn\",\n\t\"nft_transfer\",\n\t\"nft_mint\",\n\t\"nft_burn\",\n\t\"print_event\",\n]);\n\n/** Build a canonical filter: validated spec + the projections its member\n * supports (methods are attached per member at runtime, matching the\n * type-level gating exactly). `const F` preserves field literals — a\n * `prints`/`abi` declaration keeps its exact type through\n * `toSubgraphSource()`, which is what feeds `defineSubgraph` narrowing. */\nexport function makeChainEventFilter<\n\tT extends ChainEventFilterType,\n\tconst F extends Omit<SpecFor<T>, \"type\">,\n>(type: T, fields: F): ChainEventFilter<T, { type: T } & F> {\n\tconst spec = { type, ...fields } as unknown as SpecFor<T>;\n\tvalidateSpec(spec);\n\n\tconst filter = { ...spec } as unknown as Record<string, unknown>;\n\tfilter.toChainTrigger = () => toChainTrigger(spec);\n\tif (DECODED_MEMBERS.has(type)) {\n\t\tfilter.toIndexParams = (extra?: Record<string, unknown>) =>\n\t\t\ttoIndexParams(spec, extra);\n\t\tfilter.toStreamsParams = (extra?: Record<string, unknown>) =>\n\t\t\ttoStreamsParams(spec, extra);\n\t}\n\tif (type === \"contract_call\") {\n\t\tfilter.toContractCallsParams = (extra?: Record<string, unknown>) =>\n\t\t\ttoContractCallsParams(spec, extra);\n\t}\n\tif (!type.startsWith(\"sbtc_\")) {\n\t\tfilter.toSubgraphSource = () => toSubgraphSource(spec);\n\t}\n\treturn filter as unknown as ChainEventFilter<T, { type: T } & F>;\n}\n\n/**\n * Rehydrate a canonical filter from a subgraph-source-shaped object (the\n * inverse of `toSubgraphSource`). Powers migration and the round-trip\n * property gate: `toSubgraphSource(fromSubgraphSource(f))` must deep-equal\n * `f` for every production subgraph source.\n */\nexport function fromSubgraphSource(\n\tsource: SubgraphSourceSpec,\n): ChainEventFilter<SubgraphMemberType> {\n\tconst { type, ...fields } = source;\n\treturn makeChainEventFilter(\n\t\ttype,\n\t\tfields as Omit<SpecFor<typeof type>, \"type\">,\n\t) as unknown as ChainEventFilter<SubgraphMemberType>;\n}\n\ntype Fields<T extends ChainEventFilterType> = Omit<SpecFor<T>, \"type\">;\n\n/** The `on.*` namespace, annotated explicitly — bunup's dts emitter needs an\n * annotation on exported values (an inferred object of generic factories\n * collapses to `{}` in the emitted declarations). */\nexport interface OnNamespace {\n\tstxTransfer(\n\t\tfields?: Fields<\"stx_transfer\">,\n\t): ChainEventFilter<\"stx_transfer\">;\n\tstxMint(fields?: Fields<\"stx_mint\">): ChainEventFilter<\"stx_mint\">;\n\tstxBurn(fields?: Fields<\"stx_burn\">): ChainEventFilter<\"stx_burn\">;\n\tstxLock(fields?: Fields<\"stx_lock\">): ChainEventFilter<\"stx_lock\">;\n\tftTransfer(fields?: Fields<\"ft_transfer\">): ChainEventFilter<\"ft_transfer\">;\n\tftMint(fields?: Fields<\"ft_mint\">): ChainEventFilter<\"ft_mint\">;\n\tftBurn(fields?: Fields<\"ft_burn\">): ChainEventFilter<\"ft_burn\">;\n\tnftTransfer(\n\t\tfields?: Fields<\"nft_transfer\">,\n\t): ChainEventFilter<\"nft_transfer\">;\n\tnftMint(fields?: Fields<\"nft_mint\">): ChainEventFilter<\"nft_mint\">;\n\tnftBurn(fields?: Fields<\"nft_burn\">): ChainEventFilter<\"nft_burn\">;\n\t/** `abi` literals are preserved (`const A`) so `toSubgraphSource()` keeps\n\t * typing `event.input` inside `defineSubgraph`. */\n\tcontractCall<const A extends AbiContract | undefined = undefined>(\n\t\tfields?: Omit<SpecFor<\"contract_call\">, \"type\" | \"abi\"> & { abi?: A },\n\t): ChainEventFilter<\n\t\t\"contract_call\",\n\t\t{ type: \"contract_call\" } & Omit<\n\t\t\tSpecFor<\"contract_call\">,\n\t\t\t\"type\" | \"abi\"\n\t\t> & {\n\t\t\t\tabi?: A;\n\t\t\t}\n\t>;\n\tcontractDeploy(\n\t\tfields?: Fields<\"contract_deploy\">,\n\t): ChainEventFilter<\"contract_deploy\">;\n\t/** Canonical member is `print_event` (as Subgraphs and Subscriptions spell\n\t * it); `toIndexParams`/`toStreamsParams` project to `print`. `prints`\n\t * literals are preserved (`const P`) for per-topic `event.data` narrowing. */\n\tprint<\n\t\tconst P extends\n\t\t\t| Record<string, Record<string, PrintFieldType>>\n\t\t\t| undefined = undefined,\n\t>(\n\t\tfields?: Omit<SpecFor<\"print_event\">, \"type\" | \"prints\"> & { prints?: P },\n\t): ChainEventFilter<\n\t\t\"print_event\",\n\t\t{ type: \"print_event\" } & Omit<\n\t\t\tSpecFor<\"print_event\">,\n\t\t\t\"type\" | \"prints\"\n\t\t> & {\n\t\t\t\tprints?: P;\n\t\t\t}\n\t>;\n\tsbtcDeposit(\n\t\tfields?: Fields<\"sbtc_deposit\">,\n\t): ChainEventFilter<\"sbtc_deposit\">;\n\tsbtcWithdrawalCreate(\n\t\tfields?: Fields<\"sbtc_withdrawal_create\">,\n\t): ChainEventFilter<\"sbtc_withdrawal_create\">;\n\tsbtcWithdrawalAccept(\n\t\tfields?: Fields<\"sbtc_withdrawal_accept\">,\n\t): ChainEventFilter<\"sbtc_withdrawal_accept\">;\n\tsbtcWithdrawalReject(\n\t\tfields?: Fields<\"sbtc_withdrawal_reject\">,\n\t): ChainEventFilter<\"sbtc_withdrawal_reject\">;\n\tsbtcWithdrawalSweptConfirmed(\n\t\tfields?: Fields<\"sbtc_withdrawal_swept_confirmed\">,\n\t): ChainEventFilter<\"sbtc_withdrawal_swept_confirmed\">;\n}\n\n/**\n * `on.*` — one filter vocabulary for every surface.\n *\n * ```ts\n * import { on } from \"@secondlayer/stacks/filters\";\n *\n * const usdc = on.ftTransfer({ assetIdentifier: USDC, minAmount: 1_000_000n });\n *\n * sl.index.events.list(usdc.toIndexParams({ limit: 100 })); // pull\n * sl.streams.events.consume({ ...usdc.toStreamsParams(), onBatch });\n * sl.subscriptions.create({ name, url, triggers: [usdc.toChainTrigger()] });\n * defineSubgraph({ sources: { usdc: usdc.toSubgraphSource() }, schema, handlers });\n * ```\n *\n * A surface a member can't reach is a missing method (compile error), and a\n * field a surface can't express throws at projection time — never a silent\n * zero-row or over-wide match.\n */\nexport const on: OnNamespace = {\n\tstxTransfer: (fields: Fields<\"stx_transfer\"> = {}) =>\n\t\tmakeChainEventFilter(\"stx_transfer\", fields),\n\tstxMint: (fields: Fields<\"stx_mint\"> = {}) =>\n\t\tmakeChainEventFilter(\"stx_mint\", fields),\n\tstxBurn: (fields: Fields<\"stx_burn\"> = {}) =>\n\t\tmakeChainEventFilter(\"stx_burn\", fields),\n\tstxLock: (fields: Fields<\"stx_lock\"> = {}) =>\n\t\tmakeChainEventFilter(\"stx_lock\", fields),\n\tftTransfer: (fields: Fields<\"ft_transfer\"> = {}) =>\n\t\tmakeChainEventFilter(\"ft_transfer\", fields),\n\tftMint: (fields: Fields<\"ft_mint\"> = {}) =>\n\t\tmakeChainEventFilter(\"ft_mint\", fields),\n\tftBurn: (fields: Fields<\"ft_burn\"> = {}) =>\n\t\tmakeChainEventFilter(\"ft_burn\", fields),\n\tnftTransfer: (fields: Fields<\"nft_transfer\"> = {}) =>\n\t\tmakeChainEventFilter(\"nft_transfer\", fields),\n\tnftMint: (fields: Fields<\"nft_mint\"> = {}) =>\n\t\tmakeChainEventFilter(\"nft_mint\", fields),\n\tnftBurn: (fields: Fields<\"nft_burn\"> = {}) =>\n\t\tmakeChainEventFilter(\"nft_burn\", fields),\n\tcontractCall: <const A extends AbiContract | undefined = undefined>(\n\t\tfields: Omit<SpecFor<\"contract_call\">, \"type\" | \"abi\"> & { abi?: A } = {},\n\t) => makeChainEventFilter(\"contract_call\", fields),\n\tcontractDeploy: (fields: Fields<\"contract_deploy\"> = {}) =>\n\t\tmakeChainEventFilter(\"contract_deploy\", fields),\n\t/** Canonical member is `print_event` (as Subgraphs and Subscriptions spell\n\t * it); `toIndexParams`/`toStreamsParams` project to `print`. */\n\tprint: <\n\t\tconst P extends\n\t\t\t| Record<string, Record<string, PrintFieldType>>\n\t\t\t| undefined = undefined,\n\t>(\n\t\tfields: Omit<SpecFor<\"print_event\">, \"type\" | \"prints\"> & {\n\t\t\tprints?: P;\n\t\t} = {},\n\t) => makeChainEventFilter(\"print_event\", fields),\n\tsbtcDeposit: (fields: Fields<\"sbtc_deposit\"> = {}) =>\n\t\tmakeChainEventFilter(\"sbtc_deposit\", fields),\n\tsbtcWithdrawalCreate: (fields: Fields<\"sbtc_withdrawal_create\"> = {}) =>\n\t\tmakeChainEventFilter(\"sbtc_withdrawal_create\", fields),\n\tsbtcWithdrawalAccept: (fields: Fields<\"sbtc_withdrawal_accept\"> = {}) =>\n\t\tmakeChainEventFilter(\"sbtc_withdrawal_accept\", fields),\n\tsbtcWithdrawalReject: (fields: Fields<\"sbtc_withdrawal_reject\"> = {}) =>\n\t\tmakeChainEventFilter(\"sbtc_withdrawal_reject\", fields),\n\tsbtcWithdrawalSweptConfirmed: (\n\t\tfields: Fields<\"sbtc_withdrawal_swept_confirmed\"> = {},\n\t) => makeChainEventFilter(\"sbtc_withdrawal_swept_confirmed\", fields),\n};\n"
|
|
8
5
|
],
|
|
9
|
-
"mappings": "
|
|
10
|
-
"debugId": "
|
|
6
|
+
"mappings": "",
|
|
7
|
+
"debugId": "0BF4319B462244F964756E2164756E21",
|
|
11
8
|
"names": []
|
|
12
9
|
}
|
package/dist/src/index.cjs
CHANGED
|
@@ -13,7 +13,7 @@ __export(exports_src, {
|
|
|
13
13
|
providerToAccount: () => providerToAccount,
|
|
14
14
|
postgresStore: () => postgresStore,
|
|
15
15
|
parseStx: () => parseStx,
|
|
16
|
-
on: () =>
|
|
16
|
+
on: () => on,
|
|
17
17
|
nextFreeNonce: () => nextFreeNonce,
|
|
18
18
|
multisigActions: () => multisigActions,
|
|
19
19
|
mocknet: () => mocknet,
|
|
@@ -779,79 +779,6 @@ function webSocket(url, config) {
|
|
|
779
779
|
return transport;
|
|
780
780
|
};
|
|
781
781
|
}
|
|
782
|
-
// src/on/index.ts
|
|
783
|
-
var exports_on = {};
|
|
784
|
-
__export(exports_on, {
|
|
785
|
-
transferTo: () => transferTo,
|
|
786
|
-
sip010Transfer: () => sip010Transfer,
|
|
787
|
-
sip009Transfer: () => sip009Transfer,
|
|
788
|
-
sbtcWithdrawal: () => sbtcWithdrawal,
|
|
789
|
-
sbtcDeposit: () => sbtcDeposit,
|
|
790
|
-
poxStack: () => poxStack,
|
|
791
|
-
makeSpec: () => makeSpec,
|
|
792
|
-
bnsName: () => bnsName
|
|
793
|
-
});
|
|
794
|
-
|
|
795
|
-
// src/on/spec.ts
|
|
796
|
-
function makeSpec(target, filter) {
|
|
797
|
-
return {
|
|
798
|
-
subgraphName: target.subgraph,
|
|
799
|
-
tableName: target.table,
|
|
800
|
-
filter
|
|
801
|
-
};
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
// src/on/bns.ts
|
|
805
|
-
function bnsName(target, action, opts) {
|
|
806
|
-
return makeSpec(target, {
|
|
807
|
-
...action && { topic: action },
|
|
808
|
-
...opts?.namespace && { namespace: opts.namespace },
|
|
809
|
-
...opts?.owner && { owner: opts.owner }
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
// src/on/pox.ts
|
|
813
|
-
function poxStack(target, fn, opts) {
|
|
814
|
-
return makeSpec(target, {
|
|
815
|
-
...fn && { function_name: fn },
|
|
816
|
-
...opts?.stacker && { stacker: opts.stacker },
|
|
817
|
-
...opts?.signerKey && { signer_key: opts.signerKey }
|
|
818
|
-
});
|
|
819
|
-
}
|
|
820
|
-
// src/on/sbtc.ts
|
|
821
|
-
function sbtcDeposit(target, opts) {
|
|
822
|
-
return makeSpec(target, {
|
|
823
|
-
topic: "completed-deposit",
|
|
824
|
-
...opts?.sender && { sender: opts.sender },
|
|
825
|
-
...opts?.bitcoinTxid && { bitcoin_txid: opts.bitcoinTxid }
|
|
826
|
-
});
|
|
827
|
-
}
|
|
828
|
-
function sbtcWithdrawal(target, opts) {
|
|
829
|
-
return makeSpec(target, {
|
|
830
|
-
topic: opts?.phase ? { eq: `withdrawal-${opts.phase}` } : { in: ["withdrawal-create", "withdrawal-accept", "withdrawal-reject"] },
|
|
831
|
-
...opts?.sender && { sender: opts.sender },
|
|
832
|
-
...opts?.requestId !== undefined && { request_id: opts.requestId }
|
|
833
|
-
});
|
|
834
|
-
}
|
|
835
|
-
// src/on/transfer.ts
|
|
836
|
-
function transferTo(target, recipient, opts) {
|
|
837
|
-
return makeSpec(target, {
|
|
838
|
-
recipient,
|
|
839
|
-
...opts?.asset && { asset_identifier: opts.asset }
|
|
840
|
-
});
|
|
841
|
-
}
|
|
842
|
-
function sip010Transfer(target, asset, opts) {
|
|
843
|
-
return makeSpec(target, {
|
|
844
|
-
...asset && { asset_identifier: asset },
|
|
845
|
-
...opts?.recipient && { recipient: opts.recipient }
|
|
846
|
-
});
|
|
847
|
-
}
|
|
848
|
-
function sip009Transfer(target, asset, opts) {
|
|
849
|
-
return makeSpec(target, {
|
|
850
|
-
...asset && { asset_identifier: asset },
|
|
851
|
-
...opts?.recipient && { recipient: opts.recipient },
|
|
852
|
-
...opts?.tokenId !== undefined && { token_id: String(opts.tokenId) }
|
|
853
|
-
});
|
|
854
|
-
}
|
|
855
782
|
// src/errors/contract.ts
|
|
856
783
|
class ContractCallError extends BaseError {
|
|
857
784
|
name = "ContractCallError";
|
|
@@ -861,5 +788,5 @@ class ReadOnlyCallError extends BaseError {
|
|
|
861
788
|
name = "ReadOnlyCallError";
|
|
862
789
|
}
|
|
863
790
|
|
|
864
|
-
//# debugId=
|
|
791
|
+
//# debugId=7BE4D94BBB473A9364756E2164756E21
|
|
865
792
|
//# sourceMappingURL=index.cjs.map
|