@secondlayer/stacks 2.21.1 → 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.
Files changed (72) hide show
  1. package/README.md +6 -5
  2. package/dist/shared/stacks-2p9cazp7.cjs +263 -0
  3. package/dist/shared/stacks-2p9cazp7.cjs.map +12 -0
  4. package/dist/shared/stacks-9mqveyjv.cjs.map +2 -2
  5. package/dist/shared/{stacks-cdvn8qbh.cjs → stacks-b221qkst.cjs} +4 -3
  6. package/dist/shared/stacks-b221qkst.cjs.map +10 -0
  7. package/dist/shared/{stacks-0x50nn01.cjs → stacks-byyex2zk.cjs} +3 -2
  8. package/dist/shared/{stacks-0x50nn01.cjs.map → stacks-byyex2zk.cjs.map} +2 -2
  9. package/dist/shared/{stacks-rb9shyk8.js → stacks-ch5vshcd.js} +4 -4
  10. package/dist/shared/stacks-ch5vshcd.js.map +10 -0
  11. package/dist/shared/{stacks-f0hfqaj5.js → stacks-cyeajysa.js} +2 -2
  12. package/dist/shared/{stacks-msmgyerb.js → stacks-r2yw4xzb.js} +4 -3
  13. package/dist/shared/stacks-r2yw4xzb.js.map +10 -0
  14. package/dist/shared/stacks-tqrws7kd.js +252 -0
  15. package/dist/shared/stacks-tqrws7kd.js.map +12 -0
  16. package/dist/src/accounts/index.js +1 -2
  17. package/dist/src/accounts/index.js.map +2 -2
  18. package/dist/src/actions/index.cjs +3 -1
  19. package/dist/src/actions/index.cjs.map +1 -1
  20. package/dist/src/actions/index.d.cts +16 -1
  21. package/dist/src/actions/index.d.ts +16 -1
  22. package/dist/src/actions/index.js +9 -6
  23. package/dist/src/actions/index.js.map +1 -1
  24. package/dist/src/bitcoin/index.js +2 -3
  25. package/dist/src/bitcoin/index.js.map +2 -2
  26. package/dist/src/bns/index.js +3 -4
  27. package/dist/src/bns/index.js.map +2 -2
  28. package/dist/src/chains/index.js +1 -2
  29. package/dist/src/chains/index.js.map +1 -1
  30. package/dist/src/clarity/index.d.cts +3 -1
  31. package/dist/src/clarity/index.d.ts +3 -1
  32. package/dist/src/clarity/index.js +3 -2
  33. package/dist/src/clarity/index.js.map +1 -1
  34. package/dist/src/filters/index.cjs +1 -261
  35. package/dist/src/filters/index.cjs.map +3 -6
  36. package/dist/src/filters/index.js +13 -249
  37. package/dist/src/filters/index.js.map +3 -6
  38. package/dist/src/index.cjs +2 -75
  39. package/dist/src/index.cjs.map +3 -8
  40. package/dist/src/index.d.cts +389 -164
  41. package/dist/src/index.d.ts +389 -164
  42. package/dist/src/index.js +7 -80
  43. package/dist/src/index.js.map +3 -8
  44. package/dist/src/postconditions/index.js +1 -2
  45. package/dist/src/postconditions/index.js.map +1 -1
  46. package/dist/src/pox/index.js +3 -4
  47. package/dist/src/pox/index.js.map +2 -2
  48. package/dist/src/pox5/index.js +4 -5
  49. package/dist/src/pox5/index.js.map +2 -2
  50. package/dist/src/sbtc/index.js +3 -4
  51. package/dist/src/sbtc/index.js.map +2 -2
  52. package/dist/src/stackingdao/index.js +3 -4
  53. package/dist/src/stackingdao/index.js.map +2 -2
  54. package/dist/src/subscriptions/index.js +1 -2
  55. package/dist/src/subscriptions/index.js.map +1 -1
  56. package/dist/src/tools/index.cjs +3 -2
  57. package/dist/src/tools/index.cjs.map +4 -4
  58. package/dist/src/tools/index.js +3 -2
  59. package/dist/src/tools/index.js.map +4 -4
  60. package/dist/src/transactions/index.js +1 -2
  61. package/dist/src/transactions/index.js.map +1 -1
  62. package/dist/src/utils/index.js +1 -2
  63. package/dist/src/utils/index.js.map +2 -2
  64. package/dist/src/x402/index.js +1 -2
  65. package/dist/src/x402/index.js.map +2 -2
  66. package/package.json +4 -2
  67. package/dist/shared/stacks-cdvn8qbh.cjs.map +0 -10
  68. package/dist/shared/stacks-cfazrteq.js +0 -20
  69. package/dist/shared/stacks-cfazrteq.js.map +0 -9
  70. package/dist/shared/stacks-msmgyerb.js.map +0 -10
  71. package/dist/shared/stacks-rb9shyk8.js.map +0 -10
  72. /package/dist/shared/{stacks-f0hfqaj5.js.map → stacks-cyeajysa.js.map} +0 -0
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/actions/getContract.ts"],
4
+ "sourcesContent": [
5
+ "import type {\n\tAbiContract,\n\tAbiFunction,\n\tAbiMap,\n\tAbiType,\n\tAbiTypesOf,\n\tContractTypes,\n\tExtractFunctionArgs,\n\tExtractFunctionOutput,\n\tExtractMapKey,\n\tExtractMapNames,\n\tExtractMapValue,\n\tExtractPublicFunctions,\n\tExtractReadOnlyFunctions,\n} from \"../clarity/abi/index.ts\";\nimport { type ToCamelCase, toCamelCase } from \"../clarity/abi/utils.ts\";\nimport {\n\tclarityValueToJSUntyped,\n\tjsToClarityValue,\n} from \"../clarity/bridge.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport type { Client } from \"../clients/types.ts\";\nimport type { PostCondition } from \"../postconditions/types.ts\";\nimport { buildContractCall } from \"../transactions/build.ts\";\nimport type { StacksTransaction } from \"../transactions/types.ts\";\nimport { publicKeyToAddress } from \"../utils/address.ts\";\nimport type { IntegerType } from \"../utils/encoding.ts\";\nimport { estimateFee } from \"./public/estimateFee.ts\";\nimport { getMapEntry } from \"./public/getMapEntry.ts\";\nimport { readContract } from \"./public/readContract.ts\";\nimport { callContract } from \"./wallet/callContract.ts\";\nimport { resolveNonce } from \"./wallet/nonceManager.ts\";\nimport { setUnsignedFee } from \"./wallet/utils.ts\";\n\n// --- Type helpers for unwrapping response types ---\n\n/**\n * Unwrap `(response ok err)` → just the `ok` branch type. Distributes over the\n * `{ ok } | { err }` union: the `err` branch maps to `never` (it throws\n * `ContractResponseError` at runtime, so it never reaches the caller).\n */\nexport type UnwrapResponse<T> = T extends { ok: infer O }\n\t? O\n\t: T extends { err: unknown }\n\t\t? never\n\t\t: T;\n\ntype ReadMethodReturn<\n\tC extends AbiContract,\n\tN extends ExtractReadOnlyFunctions<C>,\n> = UnwrapResponse<ExtractFunctionOutput<C, N>>;\n\n// --- Public type for the contract instance ---\n\n/**\n * When the ABI carries a codegen brand (`TypedAbi`), method types resolve to\n * the generated named aliases — cleaner hovers and error messages. Un-branded\n * ABIs fall back to structural inference over the as-const literal.\n */\ntype TypedReadMethods<T extends ContractTypes> = {\n\t[K in keyof T[\"functions\"] as T[\"functions\"][K][\"access\"] extends \"read-only\"\n\t\t? K\n\t\t: never]: (\n\t\targs: T[\"functions\"][K][\"args\"],\n\t) => Promise<UnwrapResponse<T[\"functions\"][K][\"ret\"]>>;\n};\n\ntype TypedCallMethods<T extends ContractTypes> = {\n\t[K in keyof T[\"functions\"] as T[\"functions\"][K][\"access\"] extends \"public\"\n\t\t? K\n\t\t: never]: (\n\t\targs: T[\"functions\"][K][\"args\"],\n\t\toptions?: ContractCallOptions,\n\t) => Promise<string>;\n};\n\ntype TypedMapMethods<T extends ContractTypes> = {\n\t[K in keyof NonNullable<T[\"maps\"]>]: (\n\t\tkey: NonNullable<T[\"maps\"]>[K][\"key\"],\n\t) => Promise<NonNullable<T[\"maps\"]>[K][\"value\"] | null>;\n};\n\ntype ReadMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>]: (\n\t\t\t\targs: ExtractFunctionArgs<C, N>,\n\t\t\t) => Promise<ReadMethodReturn<C, N>>;\n\t\t}\n\t: TypedReadMethods<AbiTypesOf<C>>;\n\ntype CallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractPublicFunctions<C> as ToCamelCase<N>]: (\n\t\t\t\targs: ExtractFunctionArgs<C, N>,\n\t\t\t\toptions?: ContractCallOptions,\n\t\t\t) => Promise<string>;\n\t\t}\n\t: TypedCallMethods<AbiTypesOf<C>>;\n\ntype MapMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractMapNames<C> as ToCamelCase<N>]: (\n\t\t\t\tkey: ExtractMapKey<C, N>,\n\t\t\t) => Promise<ExtractMapValue<C, N> | null>;\n\t\t}\n\t: TypedMapMethods<AbiTypesOf<C>>;\n\nexport type ContractCallOptions = {\n\tfee?: IntegerType;\n\tnonce?: IntegerType;\n\tpostConditionMode?: \"allow\" | \"deny\";\n\tpostConditions?: PostCondition[];\n};\n\n/**\n * Options for `buildCall.*` — building an unsigned transaction for\n * wallet-signs-later flows. `publicKey` defaults to the client account's\n * public key; `fee`/`nonce` are resolved from the network when omitted.\n */\nexport type ContractBuildCallOptions = ContractCallOptions & {\n\tpublicKey?: string;\n\tsponsored?: boolean;\n};\n\ntype TypedBuildCallMethods<T extends ContractTypes> = {\n\t[K in keyof T[\"functions\"] as T[\"functions\"][K][\"access\"] extends \"public\"\n\t\t? K\n\t\t: never]: (\n\t\targs: T[\"functions\"][K][\"args\"],\n\t\toptions?: ContractBuildCallOptions,\n\t) => Promise<StacksTransaction>;\n};\n\ntype BuildCallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractPublicFunctions<C> as ToCamelCase<N>]: (\n\t\t\t\targs: ExtractFunctionArgs<C, N>,\n\t\t\t\toptions?: ContractBuildCallOptions,\n\t\t\t) => Promise<StacksTransaction>;\n\t\t}\n\t: TypedBuildCallMethods<AbiTypesOf<C>>;\n\nexport type ContractInstance<C extends AbiContract> = {\n\tread: ReadMethods<C>;\n\tcall: CallMethods<C>;\n\t/** Build unsigned transactions (wallet-signs-later) — never broadcasts. */\n\tbuildCall: BuildCallMethods<C>;\n\tmaps: MapMethods<C>;\n};\n\nexport type GetContractParams<C extends AbiContract> = {\n\tclient: Client;\n\taddress: string;\n\tname: string;\n\tabi: C;\n};\n\nexport function getContract<const TAbi extends AbiContract>(\n\tparams: GetContractParams<TAbi>,\n): ContractInstance<TAbi> {\n\tconst { client, address, name: contractName, abi } = params;\n\tconst contractId = `${address}.${contractName}`;\n\n\t// Index functions/maps by name for fast lookup\n\tconst fnByName = new Map<string, AbiFunction>();\n\tfor (const fn of abi.functions) {\n\t\tfnByName.set(fn.name, fn as AbiFunction);\n\t}\n\n\tconst mapByName = new Map<string, AbiMap>();\n\tif (abi.maps) {\n\t\tfor (const m of abi.maps) {\n\t\t\tmapByName.set(m.name, m as AbiMap);\n\t\t}\n\t}\n\n\t// Build kebab→camel reverse map for function/map names\n\tconst camelToKebab = new Map<string, string>();\n\tfor (const fn of abi.functions) {\n\t\tcamelToKebab.set(toCamelCase(fn.name), fn.name);\n\t}\n\tif (abi.maps) {\n\t\tfor (const m of abi.maps) {\n\t\t\tcamelToKebab.set(toCamelCase(m.name), m.name);\n\t\t}\n\t}\n\n\tconst read = new Proxy({} as ReadMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst fnName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst fn = fnByName.get(fnName);\n\t\t\tif (!fn || fn.access !== \"read-only\") return undefined;\n\n\t\t\treturn async (args: Record<string, unknown>) => {\n\t\t\t\tconst clarityArgs = buildFunctionArgs(fn, args);\n\t\t\t\tconst result = await readContract(client, {\n\t\t\t\t\tcontract: contractId,\n\t\t\t\t\tfunctionName: fn.name,\n\t\t\t\t\targs: clarityArgs,\n\t\t\t\t});\n\n\t\t\t\tconst jsValue = clarityValueToJSUntyped(fn.outputs as AbiType, result);\n\n\t\t\t\t// Auto-unwrap: if output is response type, unwrap ok / throw on err\n\t\t\t\tif (isResponseOutput(fn.outputs as AbiType)) {\n\t\t\t\t\tconst resp = jsValue as { ok?: unknown; err?: unknown };\n\t\t\t\t\tif (\"ok\" in resp) return resp.ok;\n\t\t\t\t\tthrow new ContractResponseError(\n\t\t\t\t\t\t`${contractId}::${fn.name} returned (err ${formatErrValue(resp.err)})`,\n\t\t\t\t\t\tresp.err,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn jsValue;\n\t\t\t};\n\t\t},\n\t});\n\n\tconst call = new Proxy({} as CallMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst fnName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst fn = fnByName.get(fnName);\n\t\t\tif (!fn || fn.access !== \"public\") return undefined;\n\n\t\t\treturn async (\n\t\t\t\targs: Record<string, unknown>,\n\t\t\t\toptions?: ContractCallOptions,\n\t\t\t) => {\n\t\t\t\tconst clarityArgs = buildFunctionArgs(fn, args);\n\t\t\t\treturn callContract(client, {\n\t\t\t\t\tcontract: contractId,\n\t\t\t\t\tfunctionName: fn.name,\n\t\t\t\t\tfunctionArgs: clarityArgs,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\t\t},\n\t});\n\n\tconst buildCall = new Proxy({} as BuildCallMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst fnName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst fn = fnByName.get(fnName);\n\t\t\tif (!fn || fn.access !== \"public\") return undefined;\n\n\t\t\treturn async (\n\t\t\t\targs: Record<string, unknown>,\n\t\t\t\toptions?: ContractBuildCallOptions,\n\t\t\t) => {\n\t\t\t\tconst publicKey = options?.publicKey ?? client.account?.publicKey;\n\t\t\t\tif (!publicKey) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"buildCall requires a publicKey (pass options.publicKey or configure a client account)\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst functionArgs = buildFunctionArgs(fn, args);\n\t\t\t\tconst network = client.chain?.network ?? \"mainnet\";\n\t\t\t\tconst nonce =\n\t\t\t\t\toptions?.nonce ??\n\t\t\t\t\t(await resolveNonce(client, publicKeyToAddress(publicKey, network)));\n\n\t\t\t\tconst unsigned = buildContractCall({\n\t\t\t\t\tcontractAddress: address,\n\t\t\t\t\tcontractName,\n\t\t\t\t\tfunctionName: fn.name,\n\t\t\t\t\tfunctionArgs,\n\t\t\t\t\tfee: options?.fee ?? 0n,\n\t\t\t\t\tnonce,\n\t\t\t\t\tpublicKey,\n\t\t\t\t\tchain: client.chain,\n\t\t\t\t\tpostConditionMode: options?.postConditionMode,\n\t\t\t\t\tpostConditions: options?.postConditions,\n\t\t\t\t\tsponsored: options?.sponsored,\n\t\t\t\t});\n\n\t\t\t\tif (options?.fee === undefined) {\n\t\t\t\t\tconst estimates = await estimateFee(client, {\n\t\t\t\t\t\ttransaction: unsigned,\n\t\t\t\t\t});\n\t\t\t\t\tconst mid = estimates[1] ?? estimates[0];\n\t\t\t\t\tif (mid) {\n\t\t\t\t\t\tsetUnsignedFee(unsigned, BigInt(mid.fee));\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn unsigned;\n\t\t\t};\n\t\t},\n\t});\n\n\tconst maps = new Proxy({} as MapMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst mapName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst map = mapByName.get(mapName);\n\t\t\tif (!map) return undefined;\n\n\t\t\treturn async (key: unknown) => {\n\t\t\t\tconst clarityKey = jsToClarityValue(map.key as AbiType, key);\n\t\t\t\tconst result = await getMapEntry(client, {\n\t\t\t\t\tcontract: contractId,\n\t\t\t\t\tmapName: map.name,\n\t\t\t\t\tkey: clarityKey,\n\t\t\t\t});\n\n\t\t\t\t// Map entries come back as (optional ...). If none, return null.\n\t\t\t\tif (result.type === \"none\") return null;\n\t\t\t\tif (result.type === \"some\") {\n\t\t\t\t\treturn clarityValueToJSUntyped(map.value as AbiType, result.value);\n\t\t\t\t}\n\t\t\t\t// Direct value (shouldn't normally happen, but handle gracefully)\n\t\t\t\treturn clarityValueToJSUntyped(map.value as AbiType, result);\n\t\t\t};\n\t\t},\n\t});\n\n\treturn { read, call, buildCall, maps };\n}\n\n/**\n * Resolve a network-keyed contract config for the client's chain. The contracts\n * map is keyed by network (\"mainnet\" | \"testnet\"), so selection is a direct\n * index — no per-call ternary. Throws if the client has no chain configured.\n */\nexport function resolveNetworkContract<\n\tT extends Record<\"mainnet\" | \"testnet\", { address: string }>,\n>(client: Client, contracts: T): T[\"mainnet\"] | T[\"testnet\"] {\n\tif (!client.chain) {\n\t\tthrow new Error(\"Client must have a chain configured\");\n\t}\n\treturn contracts[client.chain.network];\n}\n\n// --- Helpers ---\n\n/**\n * Encode an ABI function's named args into positional ClarityValues. Exported\n * so a caller that needs the raw ClarityValue result (to cache or re-serialize\n * it) can reuse the same encoding this module's read methods use, instead of\n * maintaining a second one that drifts.\n */\nexport function buildFunctionArgs(\n\tfn: AbiFunction,\n\targs: Record<string, unknown>,\n): ClarityValue[] {\n\treturn fn.args.map((arg) => {\n\t\tconst camelKey = toCamelCase(arg.name);\n\t\tconst hasOriginal = arg.name in args;\n\t\tconst hasCamel = camelKey in args;\n\t\tconst value = hasOriginal\n\t\t\t? args[arg.name]\n\t\t\t: hasCamel\n\t\t\t\t? args[camelKey]\n\t\t\t\t: undefined;\n\t\tif (value === undefined) throw new Error(`Missing argument: ${arg.name}`);\n\t\treturn jsToClarityValue(arg.type as AbiType, value);\n\t});\n}\n\n/** True when an ABI output is a `(response ok err)` and needs unwrapping. */\nexport function isResponseOutput(type: AbiType): boolean {\n\treturn typeof type === \"object\" && type !== null && \"response\" in type;\n}\n\nfunction formatErrValue(value: unknown): string {\n\tif (typeof value === \"bigint\") return value.toString();\n\tif (typeof value === \"string\") return `\"${value}\"`;\n\treturn String(value);\n}\n\nexport class ContractResponseError extends Error {\n\toverride name = \"ContractResponseError\";\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly errorValue: unknown,\n\t) {\n\t\tsuper(message);\n\t}\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AA6JO,SAAS,WAA2C,CAC1D,QACyB;AAAA,EACzB,QAAQ,QAAQ,SAAS,MAAM,cAAc,QAAQ;AAAA,EACrD,MAAM,aAAa,GAAG,WAAW;AAAA,EAGjC,MAAM,WAAW,IAAI;AAAA,EACrB,WAAW,MAAM,IAAI,WAAW;AAAA,IAC/B,SAAS,IAAI,GAAG,MAAM,EAAiB;AAAA,EACxC;AAAA,EAEA,MAAM,YAAY,IAAI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AAK,IAAI,CAAC,QAAQ;AAAA,IAC3B,MAAM,WAAW,YAAY,IAAI,IAAI;AAAA,IACrC,MAAM,cAAc,IAAI,QAAQ;AAAA,IAChC,MAAM,WAAW,YAAY;AAAA,IAC7B,MAAM,QAAQ,cACX,KAAK,IAAI,QACT,WACC,KAAK,YACL;AAAA,IACJ,IAAI,UAAU;AAAA,MAAW,MAAM,IAAI,MAAM,qBAAqB,IAAI,MAAM;AAAA,IACxE,OAAO,iBAAiB,IAAI,MAAiB,KAAK;AAAA,GAClD;AAAA;AAIK,SAAS,gBAAgB,CAAC,MAAwB;AAAA,EACxD,OAAO,OAAO,SAAS,YAAY,SAAS,QAAQ,cAAc;AAAA;AAGnE,SAAS,cAAc,CAAC,OAAwB;AAAA,EAC/C,IAAI,OAAO,UAAU;AAAA,IAAU,OAAO,MAAM,SAAS;AAAA,EACrD,IAAI,OAAO,UAAU;AAAA,IAAU,OAAO,IAAI;AAAA,EAC1C,OAAO,OAAO,KAAK;AAAA;AAAA;AAGb,MAAM,8BAA8B,MAAM;AAAA,EAI/B;AAAA,EAHR,OAAO;AAAA,EAChB,WAAW,CACV,SACgB,YACf;AAAA,IACD,MAAM,OAAO;AAAA,IAFG;AAAA;AAIlB;",
8
+ "debugId": "2BB182838FE177F864756E2164756E21",
9
+ "names": []
10
+ }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readContract
3
- } from "./stacks-msmgyerb.js";
3
+ } from "./stacks-r2yw4xzb.js";
4
4
 
5
5
  // src/actions/public/multicall.ts
6
6
  async function multicall(client, params) {
@@ -19,4 +19,4 @@ async function multicall(client, params) {
19
19
  export { multicall };
20
20
 
21
21
  //# debugId=7B700090E4A219F464756E2164756E21
22
- //# sourceMappingURL=stacks-f0hfqaj5.js.map
22
+ //# sourceMappingURL=stacks-cyeajysa.js.map
@@ -15,7 +15,8 @@ async function readContract(client, params) {
15
15
  const [address, name] = parseContractId(params.contract);
16
16
  const sender = params.sender ?? address;
17
17
  const serializedArgs = (params.args ?? []).map((arg) => with0x(bytesToHex(serializeCVBytes(arg))));
18
- const data = await client.request(`/v2/contracts/call-read/${address}/${name}/${params.functionName}`, {
18
+ const path = `/v2/contracts/call-read/${address}/${name}/${params.functionName}`;
19
+ const data = await client.request(params.tip ? `${path}?tip=${params.tip}` : path, {
19
20
  method: "POST",
20
21
  body: {
21
22
  sender,
@@ -30,5 +31,5 @@ async function readContract(client, params) {
30
31
 
31
32
  export { readContract };
32
33
 
33
- //# debugId=46B15CD66C8EE3CB64756E2164756E21
34
- //# sourceMappingURL=stacks-msmgyerb.js.map
34
+ //# debugId=0C52945E9698380964756E2164756E21
35
+ //# sourceMappingURL=stacks-r2yw4xzb.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/actions/public/readContract.ts"],
4
+ "sourcesContent": [
5
+ "import { deserializeCVBytes } from \"../../clarity/deserialize.ts\";\nimport { serializeCVBytes } from \"../../clarity/serialize.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\nimport { bytesToHex, with0x } from \"../../utils/encoding.ts\";\n\nexport type ReadContractParams = {\n\tcontract: string; // \"address.name\"\n\tfunctionName: string;\n\targs?: ClarityValue[];\n\tsender?: string;\n\t/**\n\t * Nakamoto StacksBlockId to evaluate against. Without it the node answers\n\t * at its own moving tip, which makes a read non-deterministic — the same\n\t * reindex of the same block can return a different value.\n\t */\n\ttip?: string;\n};\n\nexport async function readContract<T extends ClarityValue = ClarityValue>(\n\tclient: Client,\n\tparams: ReadContractParams,\n): Promise<T> {\n\tconst [address, name] = parseContractId(params.contract);\n\tconst sender = params.sender ?? address;\n\n\tconst serializedArgs = (params.args ?? []).map((arg) =>\n\t\twith0x(bytesToHex(serializeCVBytes(arg))),\n\t);\n\n\tconst path = `/v2/contracts/call-read/${address}/${name}/${params.functionName}`;\n\tconst data = await client.request(\n\t\tparams.tip ? `${path}?tip=${params.tip}` : path,\n\t\t{\n\t\t\tmethod: \"POST\",\n\t\t\tbody: {\n\t\t\t\tsender,\n\t\t\t\targuments: serializedArgs,\n\t\t\t},\n\t\t},\n\t);\n\n\tif (data.okay) {\n\t\treturn deserializeCVBytes<T>(data.result);\n\t}\n\tthrow new Error(data.cause ?? \"Read-only call failed\");\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;;;;;;;AAoBA,eAAsB,YAAmD,CACxE,QACA,QACa;AAAA,EACb,OAAO,SAAS,QAAQ,gBAAgB,OAAO,QAAQ;AAAA,EACvD,MAAM,SAAS,OAAO,UAAU;AAAA,EAEhC,MAAM,kBAAkB,OAAO,QAAQ,CAAC,GAAG,IAAI,CAAC,QAC/C,OAAO,WAAW,iBAAiB,GAAG,CAAC,CAAC,CACzC;AAAA,EAEA,MAAM,OAAO,2BAA2B,WAAW,QAAQ,OAAO;AAAA,EAClE,MAAM,OAAO,MAAM,OAAO,QACzB,OAAO,MAAM,GAAG,YAAY,OAAO,QAAQ,MAC3C;AAAA,IACC,QAAQ;AAAA,IACR,MAAM;AAAA,MACL;AAAA,MACA,WAAW;AAAA,IACZ;AAAA,EACD,CACD;AAAA,EAEA,IAAI,KAAK,MAAM;AAAA,IACd,OAAO,mBAAsB,KAAK,MAAM;AAAA,EACzC;AAAA,EACA,MAAM,IAAI,MAAM,KAAK,SAAS,uBAAuB;AAAA;",
8
+ "debugId": "0C52945E9698380964756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,252 @@
1
+ import {
2
+ isValidAddress
3
+ } from "./stacks-azp00pve.js";
4
+
5
+ // src/filters/event-types.ts
6
+ var DECODED_EVENT_TYPES = [
7
+ "stx_transfer",
8
+ "stx_mint",
9
+ "stx_burn",
10
+ "stx_lock",
11
+ "ft_transfer",
12
+ "ft_mint",
13
+ "ft_burn",
14
+ "nft_transfer",
15
+ "nft_mint",
16
+ "nft_burn",
17
+ "print"
18
+ ];
19
+ var CHAIN_EVENT_FILTER_TYPES = [
20
+ "stx_transfer",
21
+ "stx_mint",
22
+ "stx_burn",
23
+ "stx_lock",
24
+ "ft_transfer",
25
+ "ft_mint",
26
+ "ft_burn",
27
+ "nft_transfer",
28
+ "nft_mint",
29
+ "nft_burn",
30
+ "contract_call",
31
+ "contract_deploy",
32
+ "print_event",
33
+ "sbtc_deposit",
34
+ "sbtc_withdrawal_create",
35
+ "sbtc_withdrawal_accept",
36
+ "sbtc_withdrawal_reject",
37
+ "sbtc_withdrawal_swept_confirmed"
38
+ ];
39
+ // src/filters/validate.ts
40
+ function isPrincipal(value) {
41
+ const parts = value.split(".");
42
+ if (parts.length > 2)
43
+ return false;
44
+ const [addr, contractName] = parts;
45
+ if (!addr || !isValidAddress(addr))
46
+ return false;
47
+ if (parts.length === 2 && !contractName)
48
+ return false;
49
+ return true;
50
+ }
51
+ function hasWildcard(value) {
52
+ return value.includes("*");
53
+ }
54
+ function assertPrincipalish(field, value) {
55
+ if (hasWildcard(value))
56
+ return;
57
+ if (!isPrincipal(value)) {
58
+ throw new Error(`${field} "${value}" is not a valid Stacks principal (SP…/ST…, optionally .contract-name).`);
59
+ }
60
+ }
61
+ function assertAssetIdentifier(field, value) {
62
+ if (hasWildcard(value))
63
+ return;
64
+ const [contractId, assetName, ...rest] = value.split("::");
65
+ if (!contractId || !assetName || rest.length > 0 || !contractId.includes(".") || !isPrincipal(contractId)) {
66
+ 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.`);
67
+ }
68
+ }
69
+ function assertContractId(field, value) {
70
+ if (hasWildcard(value))
71
+ return;
72
+ if (value.includes("::")) {
73
+ throw new Error(`${field} "${value}" is an asset identifier, not a contract id — use assetIdentifier for that.`);
74
+ }
75
+ if (!value.includes(".") || !isPrincipal(value)) {
76
+ throw new Error(`${field} "${value}" is not a valid contract id (SP….contract-name).`);
77
+ }
78
+ }
79
+
80
+ // src/filters/factories.ts
81
+ var PRINCIPAL_FIELDS = new Set([
82
+ "sender",
83
+ "recipient",
84
+ "caller",
85
+ "deployer",
86
+ "lockedAddress"
87
+ ]);
88
+ var AMOUNT_FIELDS = new Set(["minAmount", "maxAmount"]);
89
+ var DECORATIVE_FIELDS = new Set(["abi", "prints"]);
90
+ function specEntries(spec) {
91
+ return Object.entries(spec).filter(([key, value]) => key !== "type" && value !== undefined);
92
+ }
93
+ function validateSpec(spec) {
94
+ for (const [key, value] of specEntries(spec)) {
95
+ if (PRINCIPAL_FIELDS.has(key)) {
96
+ assertPrincipalish(key, value);
97
+ } else if (key === "assetIdentifier") {
98
+ assertAssetIdentifier(key, value);
99
+ } else if (key === "contractId") {
100
+ for (const id of Array.isArray(value) ? value : [value]) {
101
+ assertContractId(key, id);
102
+ }
103
+ }
104
+ }
105
+ }
106
+ function unsupported(surface, field, hint) {
107
+ throw new Error(`${field} cannot be expressed on ${surface} — ${hint}. Drop the field from the filter or use the surface that supports it.`);
108
+ }
109
+ function assertNoWildcards(surface, spec) {
110
+ for (const [key, value] of specEntries(spec)) {
111
+ if (typeof value === "string" && hasWildcard(value)) {
112
+ unsupported(surface, `${key} wildcard "${value}"`, "wildcard patterns are Subscriptions-only");
113
+ }
114
+ }
115
+ }
116
+ function toChainTrigger(spec) {
117
+ const out = {};
118
+ for (const [key, value] of specEntries(spec)) {
119
+ if (DECORATIVE_FIELDS.has(key))
120
+ continue;
121
+ if (Array.isArray(value)) {
122
+ unsupported("Subscriptions", `${key} set`, "a chain trigger targets ONE contract — create one subscription per contract, or use Index/Subgraphs which accept the set");
123
+ }
124
+ out[key] = typeof value === "bigint" ? value.toString() : value;
125
+ }
126
+ return { type: spec.type, ...out };
127
+ }
128
+ function toIndexParams(spec, extra = {}) {
129
+ assertNoWildcards("Index events", spec);
130
+ const out = {
131
+ eventType: spec.type === "print_event" ? "print" : spec.type
132
+ };
133
+ for (const [key, value] of specEntries(spec)) {
134
+ if (DECORATIVE_FIELDS.has(key))
135
+ continue;
136
+ if (AMOUNT_FIELDS.has(key)) {
137
+ unsupported("Index events", key, "amount predicates are Subscriptions/Subgraphs-only; filter client-side on the decoded rows");
138
+ }
139
+ if (key === "topic") {
140
+ unsupported("Index events", "topic", "per-topic reads are Subgraphs/Subscriptions-only (or read the contract's print feed and switch on topic)");
141
+ }
142
+ if (key === "lockedAddress") {
143
+ unsupported("Index events", "lockedAddress", "stx_lock address filtering is Subscriptions/Subgraphs-only");
144
+ }
145
+ if (key === "caller") {
146
+ unsupported("Index events", "caller", "contract-call fields live on index.contractCalls");
147
+ }
148
+ out[key] = value;
149
+ }
150
+ return { ...out, ...extra };
151
+ }
152
+ function toStreamsParams(spec, extra = {}) {
153
+ assertNoWildcards("Streams", spec);
154
+ const out = {
155
+ types: [spec.type === "print_event" ? "print" : spec.type]
156
+ };
157
+ for (const [key, value] of specEntries(spec)) {
158
+ if (DECORATIVE_FIELDS.has(key))
159
+ continue;
160
+ if (AMOUNT_FIELDS.has(key)) {
161
+ unsupported("Streams", key, "amount predicates are Subscriptions/Subgraphs-only");
162
+ }
163
+ if (key === "trait") {
164
+ unsupported("Streams", "trait", "Streams has no trait resolution — Index and Subgraphs do");
165
+ }
166
+ if (key === "topic") {
167
+ unsupported("Streams", "topic", "per-topic filtering is Subgraphs/Subscriptions-only");
168
+ }
169
+ if (key === "lockedAddress") {
170
+ unsupported("Streams", "lockedAddress", "stx_lock address filtering is Subscriptions/Subgraphs-only");
171
+ }
172
+ out[key] = value;
173
+ }
174
+ return { ...out, ...extra };
175
+ }
176
+ function toContractCallsParams(spec, extra = {}) {
177
+ assertNoWildcards("Index contract-calls", spec);
178
+ const out = {};
179
+ for (const [key, value] of specEntries(spec)) {
180
+ if (DECORATIVE_FIELDS.has(key))
181
+ continue;
182
+ if (key === "caller") {
183
+ unsupported("Index contract-calls", "caller", "caller filtering is Subscriptions/Subgraphs-only (the endpoint filters by tx sender)");
184
+ }
185
+ out[key] = value;
186
+ }
187
+ return { ...out, ...extra };
188
+ }
189
+ function toSubgraphSource(spec) {
190
+ return Object.fromEntries([
191
+ ["type", spec.type],
192
+ ...specEntries(spec)
193
+ ]);
194
+ }
195
+ var DECODED_MEMBERS = new Set([
196
+ "stx_transfer",
197
+ "stx_mint",
198
+ "stx_burn",
199
+ "stx_lock",
200
+ "ft_transfer",
201
+ "ft_mint",
202
+ "ft_burn",
203
+ "nft_transfer",
204
+ "nft_mint",
205
+ "nft_burn",
206
+ "print_event"
207
+ ]);
208
+ function makeChainEventFilter(type, fields) {
209
+ const spec = { type, ...fields };
210
+ validateSpec(spec);
211
+ const filter = { ...spec };
212
+ filter.toChainTrigger = () => toChainTrigger(spec);
213
+ if (DECODED_MEMBERS.has(type)) {
214
+ filter.toIndexParams = (extra) => toIndexParams(spec, extra);
215
+ filter.toStreamsParams = (extra) => toStreamsParams(spec, extra);
216
+ }
217
+ if (type === "contract_call") {
218
+ filter.toContractCallsParams = (extra) => toContractCallsParams(spec, extra);
219
+ }
220
+ if (!type.startsWith("sbtc_")) {
221
+ filter.toSubgraphSource = () => toSubgraphSource(spec);
222
+ }
223
+ return filter;
224
+ }
225
+ function fromSubgraphSource(source) {
226
+ const { type, ...fields } = source;
227
+ return makeChainEventFilter(type, fields);
228
+ }
229
+ var on = {
230
+ stxTransfer: (fields = {}) => makeChainEventFilter("stx_transfer", fields),
231
+ stxMint: (fields = {}) => makeChainEventFilter("stx_mint", fields),
232
+ stxBurn: (fields = {}) => makeChainEventFilter("stx_burn", fields),
233
+ stxLock: (fields = {}) => makeChainEventFilter("stx_lock", fields),
234
+ ftTransfer: (fields = {}) => makeChainEventFilter("ft_transfer", fields),
235
+ ftMint: (fields = {}) => makeChainEventFilter("ft_mint", fields),
236
+ ftBurn: (fields = {}) => makeChainEventFilter("ft_burn", fields),
237
+ nftTransfer: (fields = {}) => makeChainEventFilter("nft_transfer", fields),
238
+ nftMint: (fields = {}) => makeChainEventFilter("nft_mint", fields),
239
+ nftBurn: (fields = {}) => makeChainEventFilter("nft_burn", fields),
240
+ contractCall: (fields = {}) => makeChainEventFilter("contract_call", fields),
241
+ contractDeploy: (fields = {}) => makeChainEventFilter("contract_deploy", fields),
242
+ print: (fields = {}) => makeChainEventFilter("print_event", fields),
243
+ sbtcDeposit: (fields = {}) => makeChainEventFilter("sbtc_deposit", fields),
244
+ sbtcWithdrawalCreate: (fields = {}) => makeChainEventFilter("sbtc_withdrawal_create", fields),
245
+ sbtcWithdrawalAccept: (fields = {}) => makeChainEventFilter("sbtc_withdrawal_accept", fields),
246
+ sbtcWithdrawalReject: (fields = {}) => makeChainEventFilter("sbtc_withdrawal_reject", fields),
247
+ sbtcWithdrawalSweptConfirmed: (fields = {}) => makeChainEventFilter("sbtc_withdrawal_swept_confirmed", fields)
248
+ };
249
+ export { DECODED_EVENT_TYPES, CHAIN_EVENT_FILTER_TYPES, isPrincipal, hasWildcard, assertPrincipalish, assertAssetIdentifier, assertContractId, makeChainEventFilter, fromSubgraphSource, on };
250
+
251
+ //# debugId=422B5FA8F2B0610E64756E2164756E21
252
+ //# sourceMappingURL=stacks-tqrws7kd.js.map
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/filters/event-types.ts", "../src/filters/validate.ts", "../src/filters/factories.ts"],
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
+ ],
9
+ "mappings": ";;;;;AAKO,IAAM,sBAAsB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAQO,IAAM,2BAA2B;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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,CACb,SAAuE,CAAC,MACpE,qBAAqB,iBAAiB,MAAM;AAAA,EACjD,gBAAgB,CAAC,SAAoC,CAAC,MACrD,qBAAqB,mBAAmB,MAAM;AAAA,EAG/C,OAAO,CAKN,SAEI,CAAC,MACD,qBAAqB,eAAe,MAAM;AAAA,EAC/C,aAAa,CAAC,SAAiC,CAAC,MAC/C,qBAAqB,gBAAgB,MAAM;AAAA,EAC5C,sBAAsB,CAAC,SAA2C,CAAC,MAClE,qBAAqB,0BAA0B,MAAM;AAAA,EACtD,sBAAsB,CAAC,SAA2C,CAAC,MAClE,qBAAqB,0BAA0B,MAAM;AAAA,EACtD,sBAAsB,CAAC,SAA2C,CAAC,MAClE,qBAAqB,0BAA0B,MAAM;AAAA,EACtD,8BAA8B,CAC7B,SAAoD,CAAC,MACjD,qBAAqB,mCAAmC,MAAM;AACpE;",
10
+ "debugId": "422B5FA8F2B0610E64756E2164756E21",
11
+ "names": []
12
+ }
@@ -13,7 +13,6 @@ import {
13
13
  hexToBytes,
14
14
  without0x
15
15
  } from "../../shared/stacks-qs5fzts5.js";
16
- import"../../shared/stacks-cfazrteq.js";
17
16
 
18
17
  // src/accounts/privateKeyToAccount.ts
19
18
  import { hmac } from "@noble/hashes/hmac.js";
@@ -127,5 +126,5 @@ export {
127
126
  compressPrivateKey
128
127
  };
129
128
 
130
- //# debugId=D63669131B82ABCA64756E2164756E21
129
+ //# debugId=7F0329B0DCCE54ED64756E2164756E21
131
130
  //# sourceMappingURL=index.js.map
@@ -7,7 +7,7 @@
7
7
  "import { HDKey } from \"@scure/bip32\";\nimport { mnemonicToSeedSync } from \"@scure/bip39\";\nimport {\n\tpublicKeyToP2trAddress,\n\tpublicKeyToP2wpkhAddress,\n} from \"../bitcoin/address.ts\";\nimport type { BitcoinNetwork } from \"../bitcoin/constants.ts\";\nimport { bytesToHex } from \"../utils/encoding.ts\";\n\nexport type BitcoinKeyType = \"p2wpkh\" | \"p2tr\";\n\nexport type MnemonicToBitcoinKeysOptions = {\n\t/** `'p2wpkh'` (BIP84, `bc1q…`) or `'p2tr'` (BIP86, `bc1p…`). */\n\ttype: BitcoinKeyType;\n\tnetwork?: BitcoinNetwork;\n\taccountIndex?: number;\n\t/** 0 = receive chain, 1 = change chain. */\n\tchangeIndex?: number;\n\taddressIndex?: number;\n};\n\nexport type BitcoinKeys = {\n\t/** 32-byte private key, hex. */\n\tprivateKey: string;\n\t/** 33-byte compressed public key, hex. */\n\tpublicKey: string;\n\taddress: string;\n\t/** Full BIP84/BIP86 derivation path. */\n\tpath: string;\n};\n\nconst PURPOSE: Record<BitcoinKeyType, number> = { p2wpkh: 84, p2tr: 86 };\n\n/**\n * Derive Bitcoin keys + address from the same mnemonic that backs a Stacks\n * account — BIP84 (native segwit) or BIP86 (taproot) paths, matching what\n * Leather/Xverse derive for the paired BTC account. Pure derivation: no\n * Bitcoin transaction building or signing.\n *\n * @example\n * const btc = mnemonicToBitcoinKeys(mnemonic, { type: \"p2tr\" });\n * btc.address; // bc1p…\n * btc.path; // m/86'/0'/0'/0/0\n */\nexport function mnemonicToBitcoinKeys(\n\tmnemonic: string,\n\toptions: MnemonicToBitcoinKeysOptions,\n): BitcoinKeys {\n\tconst {\n\t\ttype,\n\t\tnetwork = \"mainnet\",\n\t\taccountIndex = 0,\n\t\tchangeIndex = 0,\n\t\taddressIndex = 0,\n\t} = options;\n\n\t// BIP44 coin type: 0' mainnet, 1' testnet/regtest.\n\tconst coinType = network === \"mainnet\" ? 0 : 1;\n\tconst path = `m/${PURPOSE[type]}'/${coinType}'/${accountIndex}'/${changeIndex}/${addressIndex}`;\n\n\tconst seed = mnemonicToSeedSync(mnemonic);\n\tconst child = HDKey.fromMasterSeed(seed).derive(path);\n\tif (!child.privateKey || !child.publicKey)\n\t\tthrow new Error(\"Failed to derive Bitcoin key\");\n\n\tconst address =\n\t\ttype === \"p2wpkh\"\n\t\t\t? publicKeyToP2wpkhAddress(child.publicKey, network)\n\t\t\t: publicKeyToP2trAddress(child.publicKey, network);\n\n\treturn {\n\t\tprivateKey: bytesToHex(child.privateKey),\n\t\tpublicKey: bytesToHex(child.publicKey),\n\t\taddress,\n\t\tpath,\n\t};\n}\n",
8
8
  "import type { AccountSource, CustomAccount } from \"./types.ts\";\n\nexport function toAccount(source: AccountSource): CustomAccount {\n\treturn {\n\t\ttype: \"custom\",\n\t\taddress: source.address,\n\t\tpublicKey: source.publicKey,\n\t\tsign: source.sign,\n\t};\n}\n"
9
9
  ],
10
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AACA;AACA,8BAAc;AAMd,SAAS,iBAAiB,GAAG;AAAA,EAC5B,IAAI,CAAC,IAAI,gBAAgB;AAAA,IACxB,IAAI,iBAAiB,CAAC,QAAoB,SAAuB;AAAA,MAChE,MAAM,IAAI,KAAK,OAAO,QAAQ,GAAG;AAAA,MACjC,WAAW,OAAO;AAAA,QAAM,EAAE,OAAO,GAAG;AAAA,MACpC,OAAO,EAAE,OAAO;AAAA;AAAA,EAElB;AAAA;AAGD,IAAM,gCAAgC;AAE/B,SAAS,mBAAmB,CAClC,YACA,SACe;AAAA,EACf,kBAAkB;AAAA,EAClB,MAAM,WAAW,oBAAoB,UAAU;AAAA,EAC/C,MAAM,SAAS,SAAS,MAAM,GAAG,EAAE;AAAA,EAGnC,MAAM,iBAAiB,kBAAkB,QAAQ,IAAI;AAAA,EACrD,MAAM,eAAe,WAAW,cAAc;AAAA,EAG9C,MAAM,iBAAiB,SAAS,kBAAkB;AAAA,EAClD,MAAM,UAAU,WACf,gBACA,WAAW,QAAQ,cAAc,CAAC,CACnC;AAAA,EAEA,OAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,WAAW;AAAA,IAEX,IAAI,CAAC,MAA8B;AAAA,MAClC,MAAM,MAAM,KAAK,MAAM,QAAQ,EAAE,MAAM,KAAK,CAAC;AAAA,MAC7C,MAAM,SAAS,IAAI,WAAW,EAAE;AAAA,MAChC,OAAO,KAAK,IAAI;AAAA,MAChB,OAAO,IAAI,IAA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AA,EACd;AAAA;",
11
+ "debugId": "7F0329B0DCCE54ED64756E2164756E21",
12
12
  "names": []
13
13
  }
@@ -19,6 +19,7 @@ __export(exports_actions, {
19
19
  readContract: () => readContract,
20
20
  multicall: () => multicall,
21
21
  minimumFee: () => minimumFee,
22
+ isResponseOutput: () => isResponseOutput,
22
23
  isProviderAccount: () => isProviderAccount,
23
24
  isFeeTier: () => isFeeTier,
24
25
  indexTxSource: () => indexTxSource,
@@ -40,9 +41,10 @@ __export(exports_actions, {
40
41
  estimateFee: () => estimateFee,
41
42
  deployContract: () => deployContract,
42
43
  callContract: () => callContract,
44
+ buildFunctionArgs: () => buildFunctionArgs,
43
45
  ContractResponseError: () => ContractResponseError
44
46
  });
45
47
  module.exports = __toCommonJS(exports_actions);
46
48
 
47
- //# debugId=096C166E216C663864756E2164756E21
49
+ //# debugId=E48B5A351123157A64756E2164756E21
48
50
  //# sourceMappingURL=index.cjs.map
@@ -4,6 +4,6 @@
4
4
  "sourcesContent": [
5
5
  ],
6
6
  "mappings": "",
7
- "debugId": "096C166E216C663864756E2164756E21",
7
+ "debugId": "E48B5A351123157A64756E2164756E21",
8
8
  "names": []
9
9
  }
@@ -454,6 +454,12 @@ type ReadContractParams = {
454
454
  functionName: string
455
455
  args?: ClarityValue[]
456
456
  sender?: string
457
+ /**
458
+ * Nakamoto StacksBlockId to evaluate against. Without it the node answers
459
+ * at its own moving tip, which makes a read non-deterministic — the same
460
+ * reindex of the same block can return a different value.
461
+ */
462
+ tip?: string
457
463
  };
458
464
  declare function readContract<T extends ClarityValue = ClarityValue>(client: Client, params: ReadContractParams): Promise<T>;
459
465
  type GetContractAbiParams = {
@@ -1232,9 +1238,18 @@ type GetContractParams<C extends AbiContract> = {
1232
1238
  abi: C
1233
1239
  };
1234
1240
  declare function getContract<const TAbi extends AbiContract>(params: GetContractParams<TAbi>): ContractInstance<TAbi>;
1241
+ /**
1242
+ * Encode an ABI function's named args into positional ClarityValues. Exported
1243
+ * so a caller that needs the raw ClarityValue result (to cache or re-serialize
1244
+ * it) can reuse the same encoding this module's read methods use, instead of
1245
+ * maintaining a second one that drifts.
1246
+ */
1247
+ declare function buildFunctionArgs(fn: AbiFunction, args: Record<string, unknown>): ClarityValue[];
1248
+ /** True when an ABI output is a `(response ok err)` and needs unwrapping. */
1249
+ declare function isResponseOutput(type: AbiType): boolean;
1235
1250
  declare class ContractResponseError extends Error {
1236
1251
  readonly errorValue: unknown;
1237
1252
  name: string;
1238
1253
  constructor(message: string, errorValue: unknown);
1239
1254
  }
1240
- export { watchTransaction, watchNftEvent, watchMempool, watchBlocks, watchAddressBalance, watchAddress, waitForTransactionReceipt, transferStx, sponsorTransaction, simulateTransaction, simulateCall, signTransactionAction, signMessage2 as signMessage, sendTransaction, resolveFee, readContract, multicall, minimumFee, isProviderAccount, isFeeTier, indexTxSource, getTransaction, getRawBlock, getNonce, getNftHoldings, getMempoolStats, getMapEntry, getContractSource, getContractAbi, getContract, getBlockHeight, getBlock, getBalance, getAccountInfo, getAccountHistory, extendedApiSource, estimateFee, deployContract, callContract, WatchTransactionParams, WatchNftEventParams, WatchMempoolParams, WatchBlocksParams, WatchAddressParams, WatchAddressBalanceParams, WaitForTransactionReceiptParams, TransferStxParams, TransactionStatusSource, TransactionStatus, TransactionSnapshot, TransactionReceipt, SponsorTransactionParams, SimulateTransferResult, SimulateTransactionResult, SimulateTransactionParams, SimulateDeployResult, SimulateContractCallResult, SimulateCallSuccess, SimulateCallResult, SimulateCallParams, SimulateCallFailure, SignTransactionParams, SignMessageParams, SendTransactionResult, SendTransactionParams, ReadContractParams, RawBlockResponse, NftHoldingsResponse, MulticallSuccessResult, MulticallResult, MulticallParams, MulticallFailureResult, MulticallCall, IndexTxSourceParams, GetTransactionParams, GetRawBlockParams, GetNonceParams, GetNftHoldingsParams, GetMapEntryParams, GetContractSourceParams, GetContractParams, GetContractAbiParams, GetBlockParams, GetBalanceParams, GetAccountInfoParams, GetAccountHistoryParams, FeeTier, FeeParam, FeeEstimation, EstimateFeeParams, DeployContractParams, ContractSourceResponse, ContractResponseError, ContractInstance, ContractCallOptions, ContractBuildCallOptions, CallContractParams, AccountInfo, AccountHistoryResponse };
1255
+ export { watchTransaction, watchNftEvent, watchMempool, watchBlocks, watchAddressBalance, watchAddress, waitForTransactionReceipt, transferStx, sponsorTransaction, simulateTransaction, simulateCall, signTransactionAction, signMessage2 as signMessage, sendTransaction, resolveFee, readContract, multicall, minimumFee, isResponseOutput, isProviderAccount, isFeeTier, indexTxSource, getTransaction, getRawBlock, getNonce, getNftHoldings, getMempoolStats, getMapEntry, getContractSource, getContractAbi, getContract, getBlockHeight, getBlock, getBalance, getAccountInfo, getAccountHistory, extendedApiSource, estimateFee, deployContract, callContract, buildFunctionArgs, WatchTransactionParams, WatchNftEventParams, WatchMempoolParams, WatchBlocksParams, WatchAddressParams, WatchAddressBalanceParams, WaitForTransactionReceiptParams, UnwrapResponse, TransferStxParams, TransactionStatusSource, TransactionStatus, TransactionSnapshot, TransactionReceipt, SponsorTransactionParams, SimulateTransferResult, SimulateTransactionResult, SimulateTransactionParams, SimulateDeployResult, SimulateContractCallResult, SimulateCallSuccess, SimulateCallResult, SimulateCallParams, SimulateCallFailure, SignTransactionParams, SignMessageParams, SendTransactionResult, SendTransactionParams, ReadContractParams, RawBlockResponse, NftHoldingsResponse, MulticallSuccessResult, MulticallResult, MulticallParams, MulticallFailureResult, MulticallCall, IndexTxSourceParams, GetTransactionParams, GetRawBlockParams, GetNonceParams, GetNftHoldingsParams, GetMapEntryParams, GetContractSourceParams, GetContractParams, GetContractAbiParams, GetBlockParams, GetBalanceParams, GetAccountInfoParams, GetAccountHistoryParams, FeeTier, FeeParam, FeeEstimation, EstimateFeeParams, DeployContractParams, ContractSourceResponse, ContractResponseError, ContractInstance, ContractCallOptions, ContractBuildCallOptions, CallContractParams, AccountInfo, AccountHistoryResponse };
@@ -454,6 +454,12 @@ type ReadContractParams = {
454
454
  functionName: string
455
455
  args?: ClarityValue[]
456
456
  sender?: string
457
+ /**
458
+ * Nakamoto StacksBlockId to evaluate against. Without it the node answers
459
+ * at its own moving tip, which makes a read non-deterministic — the same
460
+ * reindex of the same block can return a different value.
461
+ */
462
+ tip?: string
457
463
  };
458
464
  declare function readContract<T extends ClarityValue = ClarityValue>(client: Client, params: ReadContractParams): Promise<T>;
459
465
  type GetContractAbiParams = {
@@ -1232,9 +1238,18 @@ type GetContractParams<C extends AbiContract> = {
1232
1238
  abi: C
1233
1239
  };
1234
1240
  declare function getContract<const TAbi extends AbiContract>(params: GetContractParams<TAbi>): ContractInstance<TAbi>;
1241
+ /**
1242
+ * Encode an ABI function's named args into positional ClarityValues. Exported
1243
+ * so a caller that needs the raw ClarityValue result (to cache or re-serialize
1244
+ * it) can reuse the same encoding this module's read methods use, instead of
1245
+ * maintaining a second one that drifts.
1246
+ */
1247
+ declare function buildFunctionArgs(fn: AbiFunction, args: Record<string, unknown>): ClarityValue[];
1248
+ /** True when an ABI output is a `(response ok err)` and needs unwrapping. */
1249
+ declare function isResponseOutput(type: AbiType): boolean;
1235
1250
  declare class ContractResponseError extends Error {
1236
1251
  readonly errorValue: unknown;
1237
1252
  name: string;
1238
1253
  constructor(message: string, errorValue: unknown);
1239
1254
  }
1240
- export { watchTransaction, watchNftEvent, watchMempool, watchBlocks, watchAddressBalance, watchAddress, waitForTransactionReceipt, transferStx, sponsorTransaction, simulateTransaction, simulateCall, signTransactionAction, signMessage2 as signMessage, sendTransaction, resolveFee, readContract, multicall, minimumFee, isProviderAccount, isFeeTier, indexTxSource, getTransaction, getRawBlock, getNonce, getNftHoldings, getMempoolStats, getMapEntry, getContractSource, getContractAbi, getContract, getBlockHeight, getBlock, getBalance, getAccountInfo, getAccountHistory, extendedApiSource, estimateFee, deployContract, callContract, WatchTransactionParams, WatchNftEventParams, WatchMempoolParams, WatchBlocksParams, WatchAddressParams, WatchAddressBalanceParams, WaitForTransactionReceiptParams, TransferStxParams, TransactionStatusSource, TransactionStatus, TransactionSnapshot, TransactionReceipt, SponsorTransactionParams, SimulateTransferResult, SimulateTransactionResult, SimulateTransactionParams, SimulateDeployResult, SimulateContractCallResult, SimulateCallSuccess, SimulateCallResult, SimulateCallParams, SimulateCallFailure, SignTransactionParams, SignMessageParams, SendTransactionResult, SendTransactionParams, ReadContractParams, RawBlockResponse, NftHoldingsResponse, MulticallSuccessResult, MulticallResult, MulticallParams, MulticallFailureResult, MulticallCall, IndexTxSourceParams, GetTransactionParams, GetRawBlockParams, GetNonceParams, GetNftHoldingsParams, GetMapEntryParams, GetContractSourceParams, GetContractParams, GetContractAbiParams, GetBlockParams, GetBalanceParams, GetAccountInfoParams, GetAccountHistoryParams, FeeTier, FeeParam, FeeEstimation, EstimateFeeParams, DeployContractParams, ContractSourceResponse, ContractResponseError, ContractInstance, ContractCallOptions, ContractBuildCallOptions, CallContractParams, AccountInfo, AccountHistoryResponse };
1255
+ export { watchTransaction, watchNftEvent, watchMempool, watchBlocks, watchAddressBalance, watchAddress, waitForTransactionReceipt, transferStx, sponsorTransaction, simulateTransaction, simulateCall, signTransactionAction, signMessage2 as signMessage, sendTransaction, resolveFee, readContract, multicall, minimumFee, isResponseOutput, isProviderAccount, isFeeTier, indexTxSource, getTransaction, getRawBlock, getNonce, getNftHoldings, getMempoolStats, getMapEntry, getContractSource, getContractAbi, getContract, getBlockHeight, getBlock, getBalance, getAccountInfo, getAccountHistory, extendedApiSource, estimateFee, deployContract, callContract, buildFunctionArgs, WatchTransactionParams, WatchNftEventParams, WatchMempoolParams, WatchBlocksParams, WatchAddressParams, WatchAddressBalanceParams, WaitForTransactionReceiptParams, UnwrapResponse, TransferStxParams, TransactionStatusSource, TransactionStatus, TransactionSnapshot, TransactionReceipt, SponsorTransactionParams, SimulateTransferResult, SimulateTransactionResult, SimulateTransactionParams, SimulateDeployResult, SimulateContractCallResult, SimulateCallSuccess, SimulateCallResult, SimulateCallParams, SimulateCallFailure, SignTransactionParams, SignMessageParams, SendTransactionResult, SendTransactionParams, ReadContractParams, RawBlockResponse, NftHoldingsResponse, MulticallSuccessResult, MulticallResult, MulticallParams, MulticallFailureResult, MulticallCall, IndexTxSourceParams, GetTransactionParams, GetRawBlockParams, GetNonceParams, GetNftHoldingsParams, GetMapEntryParams, GetContractSourceParams, GetContractParams, GetContractAbiParams, GetBlockParams, GetBalanceParams, GetAccountInfoParams, GetAccountHistoryParams, FeeTier, FeeParam, FeeEstimation, EstimateFeeParams, DeployContractParams, ContractSourceResponse, ContractResponseError, ContractInstance, ContractCallOptions, ContractBuildCallOptions, CallContractParams, AccountInfo, AccountHistoryResponse };
@@ -1,7 +1,9 @@
1
1
  import {
2
2
  ContractResponseError,
3
- getContract
4
- } from "../../shared/stacks-rb9shyk8.js";
3
+ buildFunctionArgs,
4
+ getContract,
5
+ isResponseOutput
6
+ } from "../../shared/stacks-ch5vshcd.js";
5
7
  import {
6
8
  deployContract,
7
9
  getAccountHistory,
@@ -22,14 +24,14 @@ import {
22
24
  } from "../../shared/stacks-1x9b2k5y.js";
23
25
  import {
24
26
  multicall
25
- } from "../../shared/stacks-f0hfqaj5.js";
27
+ } from "../../shared/stacks-cyeajysa.js";
26
28
  import {
27
29
  callContract,
28
30
  getMapEntry
29
31
  } from "../../shared/stacks-bq0weg6n.js";
30
32
  import {
31
33
  readContract
32
- } from "../../shared/stacks-msmgyerb.js";
34
+ } from "../../shared/stacks-r2yw4xzb.js";
33
35
  import {
34
36
  watchAddress,
35
37
  watchAddressBalance,
@@ -62,7 +64,6 @@ import"../../shared/stacks-sd9sc71n.js";
62
64
  import"../../shared/stacks-2mm20wqf.js";
63
65
  import"../../shared/stacks-azp00pve.js";
64
66
  import"../../shared/stacks-qs5fzts5.js";
65
- import"../../shared/stacks-cfazrteq.js";
66
67
  export {
67
68
  watchTransaction,
68
69
  watchNftEvent,
@@ -82,6 +83,7 @@ export {
82
83
  readContract,
83
84
  multicall,
84
85
  minimumFee,
86
+ isResponseOutput,
85
87
  isProviderAccount,
86
88
  isFeeTier,
87
89
  indexTxSource,
@@ -103,8 +105,9 @@ export {
103
105
  estimateFee,
104
106
  deployContract,
105
107
  callContract,
108
+ buildFunctionArgs,
106
109
  ContractResponseError
107
110
  };
108
111
 
109
- //# debugId=CE7A1E715DCF580964756E2164756E21
112
+ //# debugId=0DAED5A4DFB64BD264756E2164756E21
110
113
  //# sourceMappingURL=index.js.map
@@ -4,6 +4,6 @@
4
4
  "sourcesContent": [
5
5
  ],
6
6
  "mappings": "",
7
- "debugId": "CE7A1E715DCF580964756E2164756E21",
7
+ "debugId": "0DAED5A4DFB64BD264756E2164756E21",
8
8
  "names": []
9
9
  }