@secondlayer/stacks 3.3.1 → 4.1.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 (130) hide show
  1. package/README.md +4 -0
  2. package/dist/shared/stacks-1arrcd11.js +48 -0
  3. package/dist/shared/stacks-1arrcd11.js.map +10 -0
  4. package/dist/shared/{stacks-6bgh2c9h.js → stacks-27fmgajb.js} +11 -3
  5. package/dist/shared/{stacks-b221qkst.cjs.map → stacks-27fmgajb.js.map} +4 -3
  6. package/dist/shared/{stacks-jknrzd6v.js → stacks-2evvn48s.js} +2 -2
  7. package/dist/shared/stacks-9mqveyjv.cjs.map +2 -2
  8. package/dist/shared/{stacks-8e5atbps.cjs → stacks-9qcr921s.cjs} +49 -5
  9. package/dist/shared/stacks-9qcr921s.cjs.map +10 -0
  10. package/dist/shared/{stacks-r1m1r72q.js → stacks-bw8qvqd1.js} +49 -23
  11. package/dist/shared/stacks-bw8qvqd1.js.map +27 -0
  12. package/dist/shared/stacks-enpj9krt.cjs +38 -0
  13. package/dist/shared/stacks-enpj9krt.cjs.map +10 -0
  14. package/dist/shared/{stacks-s361pmzs.cjs → stacks-fb75yew8.js} +86 -2
  15. package/dist/shared/{stacks-9d2d0qjc.js.map → stacks-fb75yew8.js.map} +6 -4
  16. package/dist/shared/{stacks-rw2xbtdv.js → stacks-gxq2pbky.js} +2 -2
  17. package/dist/shared/{stacks-rw2xbtdv.js.map → stacks-gxq2pbky.js.map} +1 -1
  18. package/dist/shared/{stacks-jx146qf1.js → stacks-hnqt5rz4.js} +27 -377
  19. package/dist/shared/stacks-hnqt5rz4.js.map +13 -0
  20. package/dist/shared/{stacks-v1hzk599.js → stacks-jpt52csy.js} +8 -10
  21. package/dist/shared/stacks-jpt52csy.js.map +10 -0
  22. package/dist/shared/{stacks-b221qkst.cjs → stacks-nyaw1z2a.cjs} +7 -2
  23. package/dist/shared/{stacks-6bgh2c9h.js.map → stacks-nyaw1z2a.cjs.map} +4 -3
  24. package/dist/shared/{stacks-bm49tsh0.js → stacks-rpqtgpyj.js} +42 -9
  25. package/dist/shared/stacks-rpqtgpyj.js.map +10 -0
  26. package/dist/shared/{stacks-g2qnr5qn.cjs → stacks-rryme9bv.cjs} +11 -364
  27. package/dist/shared/stacks-rryme9bv.cjs.map +13 -0
  28. package/dist/shared/{stacks-byyex2zk.cjs → stacks-ta1gar0b.cjs} +7 -2
  29. package/dist/shared/{stacks-byyex2zk.cjs.map → stacks-ta1gar0b.cjs.map} +2 -2
  30. package/dist/shared/{stacks-9d2d0qjc.js → stacks-tdsp5gsb.cjs} +54 -23
  31. package/dist/shared/{stacks-s361pmzs.cjs.map → stacks-tdsp5gsb.cjs.map} +6 -4
  32. package/dist/shared/stacks-vea7nde7.cjs +731 -0
  33. package/dist/shared/stacks-vea7nde7.cjs.map +13 -0
  34. package/dist/shared/stacks-w23294am.js +760 -0
  35. package/dist/shared/stacks-w23294am.js.map +13 -0
  36. package/dist/shared/{stacks-fvnxj77s.cjs → stacks-y4f7fm03.cjs} +33 -13
  37. package/dist/shared/{stacks-fvnxj77s.cjs.map → stacks-y4f7fm03.cjs.map} +7 -6
  38. package/dist/src/accounts/index.d.cts +1 -1
  39. package/dist/src/accounts/index.d.ts +1 -1
  40. package/dist/src/actions/index.d.cts +15 -11
  41. package/dist/src/actions/index.d.ts +15 -11
  42. package/dist/src/actions/index.js +21 -25
  43. package/dist/src/actions/index.js.map +1 -1
  44. package/dist/src/bitcoin/index.d.cts +29 -29
  45. package/dist/src/bitcoin/index.d.ts +29 -29
  46. package/dist/src/bitcoin/index.js +5 -6
  47. package/dist/src/bitcoin/index.js.map +2 -2
  48. package/dist/src/bns/index.d.cts +1 -1
  49. package/dist/src/bns/index.d.ts +1 -1
  50. package/dist/src/bns/index.js +9 -10
  51. package/dist/src/bns/index.js.map +2 -2
  52. package/dist/src/clarity/index.d.cts +37 -1
  53. package/dist/src/clarity/index.d.ts +37 -1
  54. package/dist/src/clarity/index.js +14 -2
  55. package/dist/src/clarity/index.js.map +1 -1
  56. package/dist/src/index.cjs.map +2 -2
  57. package/dist/src/index.d.cts +18 -14
  58. package/dist/src/index.d.ts +18 -14
  59. package/dist/src/index.js +22 -27
  60. package/dist/src/index.js.map +3 -3
  61. package/dist/src/postconditions/index.d.cts +66 -3
  62. package/dist/src/postconditions/index.d.ts +66 -3
  63. package/dist/src/postconditions/index.js +13 -3
  64. package/dist/src/postconditions/index.js.map +1 -1
  65. package/dist/src/pox/index.d.cts +1 -1
  66. package/dist/src/pox/index.d.ts +1 -1
  67. package/dist/src/pox/index.js +7 -9
  68. package/dist/src/pox/index.js.map +2 -2
  69. package/dist/src/pox5/index.cjs +213 -14
  70. package/dist/src/pox5/index.cjs.map +8 -7
  71. package/dist/src/pox5/index.d.cts +88 -5
  72. package/dist/src/pox5/index.d.ts +88 -5
  73. package/dist/src/pox5/index.js +222 -21
  74. package/dist/src/pox5/index.js.map +8 -7
  75. package/dist/src/sbtc/index.d.cts +1 -1
  76. package/dist/src/sbtc/index.d.ts +1 -1
  77. package/dist/src/sbtc/index.js +6 -7
  78. package/dist/src/sbtc/index.js.map +2 -2
  79. package/dist/src/stackingdao/index.d.cts +1 -1
  80. package/dist/src/stackingdao/index.d.ts +1 -1
  81. package/dist/src/stackingdao/index.js +7 -9
  82. package/dist/src/stackingdao/index.js.map +2 -2
  83. package/dist/src/subscriptions/index.d.cts +1 -1
  84. package/dist/src/subscriptions/index.d.ts +1 -1
  85. package/dist/src/tools/index.cjs +494 -367
  86. package/dist/src/tools/index.cjs.map +11 -9
  87. package/dist/src/tools/index.d.cts +1 -1
  88. package/dist/src/tools/index.d.ts +1 -1
  89. package/dist/src/tools/index.js +494 -367
  90. package/dist/src/tools/index.js.map +11 -9
  91. package/dist/src/transactions/index.cjs +3 -1
  92. package/dist/src/transactions/index.cjs.map +1 -1
  93. package/dist/src/transactions/index.d.cts +16 -9
  94. package/dist/src/transactions/index.d.ts +16 -9
  95. package/dist/src/transactions/index.js +31 -27
  96. package/dist/src/transactions/index.js.map +1 -1
  97. package/package.json +2 -7
  98. package/dist/shared/stacks-1mpmzzyp.js +0 -85
  99. package/dist/shared/stacks-1mpmzzyp.js.map +0 -11
  100. package/dist/shared/stacks-44y18a8e.cjs +0 -28
  101. package/dist/shared/stacks-44y18a8e.cjs.map +0 -10
  102. package/dist/shared/stacks-8e5atbps.cjs.map +0 -10
  103. package/dist/shared/stacks-8khy9v27.cjs +0 -7
  104. package/dist/shared/stacks-8khy9v27.cjs.map +0 -10
  105. package/dist/shared/stacks-bm49tsh0.js.map +0 -10
  106. package/dist/shared/stacks-d6pgp4qk.cjs +0 -9
  107. package/dist/shared/stacks-d6pgp4qk.cjs.map +0 -9
  108. package/dist/shared/stacks-fh48neva.js +0 -13
  109. package/dist/shared/stacks-fh48neva.js.map +0 -10
  110. package/dist/shared/stacks-fjrpnkt3.cjs +0 -55
  111. package/dist/shared/stacks-fjrpnkt3.cjs.map +0 -11
  112. package/dist/shared/stacks-g2qnr5qn.cjs.map +0 -15
  113. package/dist/shared/stacks-gkf9tsws.js +0 -285
  114. package/dist/shared/stacks-gkf9tsws.js.map +0 -10
  115. package/dist/shared/stacks-jx146qf1.js.map +0 -15
  116. package/dist/shared/stacks-qjgh6pqr.cjs +0 -258
  117. package/dist/shared/stacks-qjgh6pqr.cjs.map +0 -10
  118. package/dist/shared/stacks-r1m1r72q.js.map +0 -26
  119. package/dist/shared/stacks-v1hzk599.js.map +0 -10
  120. package/dist/shared/stacks-w8tt1fmt.js +0 -44
  121. package/dist/shared/stacks-w8tt1fmt.js.map +0 -10
  122. package/dist/shared/stacks-z53fwfcm.js +0 -3
  123. package/dist/shared/stacks-z53fwfcm.js.map +0 -9
  124. package/dist/src/x402/index.cjs +0 -65
  125. package/dist/src/x402/index.cjs.map +0 -11
  126. package/dist/src/x402/index.d.cts +0 -501
  127. package/dist/src/x402/index.d.ts +0 -501
  128. package/dist/src/x402/index.js +0 -90
  129. package/dist/src/x402/index.js.map +0 -11
  130. /package/dist/shared/{stacks-jknrzd6v.js.map → stacks-2evvn48s.js.map} +0 -0
@@ -1,10 +0,0 @@
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,YAA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GAAG,KAAK,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,44 +0,0 @@
1
- import {
2
- isProviderAccount,
3
- resolveFee,
4
- resolveNonce
5
- } from "./stacks-9d2d0qjc.js";
6
- import {
7
- AuthType,
8
- createSingleSigSpendingCondition,
9
- signSponsorWithAccount
10
- } from "./stacks-jx146qf1.js";
11
- import {
12
- intToBigInt
13
- } from "./stacks-qs5fzts5.js";
14
-
15
- // src/actions/wallet/sponsorTransaction.ts
16
- async function sponsorTransaction(client, params) {
17
- const { transaction } = params;
18
- if (transaction.auth.authType !== AuthType.Sponsored) {
19
- throw new Error("Transaction must have sponsored authorization");
20
- }
21
- const account = client.account;
22
- if (!account)
23
- throw new Error("Account required");
24
- if (isProviderAccount(account)) {
25
- throw new Error("Provider accounts cannot sponsor transactions");
26
- }
27
- const nonce = params.nonce != null ? intToBigInt(params.nonce) : await resolveNonce(client, account.address);
28
- const fee = await resolveFee(client, transaction, params.fee);
29
- const sponsorCondition = createSingleSigSpendingCondition(account.publicKey, nonce, fee);
30
- const auth = transaction.auth;
31
- const sponsored = {
32
- ...transaction,
33
- auth: {
34
- ...auth,
35
- sponsorSpendingCondition: sponsorCondition
36
- }
37
- };
38
- return signSponsorWithAccount(sponsored, account);
39
- }
40
-
41
- export { sponsorTransaction };
42
-
43
- //# debugId=AD4711CB97F1F3EB64756E2164756E21
44
- //# sourceMappingURL=stacks-w8tt1fmt.js.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/actions/wallet/sponsorTransaction.ts"],
4
- "sourcesContent": [
5
- "import type { Client } from \"../../clients/types.ts\";\nimport { createSingleSigSpendingCondition } from \"../../transactions/authorization.ts\";\nimport { signSponsorWithAccount } from \"../../transactions/signer.ts\";\nimport {\n\tAuthType,\n\ttype SponsoredAuthorization,\n\ttype StacksTransaction,\n} from \"../../transactions/types.ts\";\nimport type { IntegerType } from \"../../utils/encoding.ts\";\nimport { intToBigInt } from \"../../utils/encoding.ts\";\nimport { resolveNonce } from \"./nonceManager.ts\";\nimport { type FeeParam, isProviderAccount, resolveFee } from \"./utils.ts\";\n\nexport type SponsorTransactionParams = {\n\ttransaction: StacksTransaction;\n\tfee?: FeeParam;\n\tnonce?: IntegerType;\n};\n\n/** Sponsor a transaction: set sponsor spending condition, sign as sponsor */\nexport async function sponsorTransaction(\n\tclient: Client,\n\tparams: SponsorTransactionParams,\n): Promise<StacksTransaction> {\n\tconst { transaction } = params;\n\n\tif (transaction.auth.authType !== AuthType.Sponsored) {\n\t\tthrow new Error(\"Transaction must have sponsored authorization\");\n\t}\n\n\tconst account = client.account;\n\tif (!account) throw new Error(\"Account required\");\n\tif (isProviderAccount(account)) {\n\t\tthrow new Error(\"Provider accounts cannot sponsor transactions\");\n\t}\n\n\t// Resolve sponsor nonce\n\tconst nonce =\n\t\tparams.nonce != null\n\t\t\t? intToBigInt(params.nonce)\n\t\t\t: await resolveNonce(client, account.address);\n\n\t// Resolve sponsor fee. Estimation failure falls back to the minimum relay\n\t// fee instead of 0 (a 0-fee tx would be rejected at broadcast).\n\tconst fee = await resolveFee(client, transaction, params.fee);\n\n\t// Create sponsor spending condition\n\tconst sponsorCondition = createSingleSigSpendingCondition(\n\t\taccount.publicKey,\n\t\tnonce,\n\t\tfee,\n\t);\n\n\t// Set sponsor spending condition on the tx\n\tconst auth = transaction.auth as SponsoredAuthorization;\n\tconst sponsored: StacksTransaction = {\n\t\t...transaction,\n\t\tauth: {\n\t\t\t...auth,\n\t\t\tsponsorSpendingCondition: sponsorCondition,\n\t\t},\n\t};\n\n\t// Sign as sponsor\n\treturn signSponsorWithAccount(sponsored, account);\n}\n"
6
- ],
7
- "mappings": ";;;;;;;;;;;;;;;AAoBA,eAAsB,kBAAkB,CACvC,QACA,QAC6B;AAAA,EAC7B,QAAQ,gBAAgB;AAAA,EAExB,IAAI,YAAY,KAAK,aAAa,SAAS,WAAW;AAAA,IACrD,MAAM,IAAI,MAAM,+CAA+C;AAAA,EAChE;AAAA,EAEA,MAAM,UAAU,OAAO;AAAA,EACvB,IAAI,CAAC;AAAA,IAAS,MAAM,IAAI,MAAM,kBAAkB;AAAA,EAChD,IAAI,kBAAkB,OAAO,GAAG;AAAA,IAC/B,MAAM,IAAI,MAAM,+CAA+C;AAAA,EAChE;AAAA,EAGA,MAAM,QACL,OAAO,SAAS,OACb,YAAY,OAAO,KAAK,IACxB,MAAM,aAAa,QAAQ,QAAQ,OAAO;AAAA,EAI9C,MAAM,MAAM,MAAM,WAAW,QAAQ,aAAa,OAAO,GAAG;AAAA,EAG5D,MAAM,mBAAmB,iCACxB,QAAQ,WACR,OACA,GACD;AAAA,EAGA,MAAM,OAAO,YAAY;AAAA,EACzB,MAAM,YAA+B;AAAA,OACjC;AAAA,IACH,MAAM;AAAA,SACF;AAAA,MACH,0BAA0B;AAAA,IAC3B;AAAA,EACD;AAAA,EAGA,OAAO,uBAAuB,WAAW,OAAO;AAAA;",
8
- "debugId": "AD4711CB97F1F3EB64756E2164756E21",
9
- "names": []
10
- }
@@ -1,3 +0,0 @@
1
-
2
- //# debugId=AAC6E250E380EF1864756E2164756E21
3
- //# sourceMappingURL=stacks-z53fwfcm.js.map
@@ -1,9 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [
5
- ],
6
- "mappings": "",
7
- "debugId": "AAC6E250E380EF1864756E2164756E21",
8
- "names": []
9
- }
@@ -1,65 +0,0 @@
1
- // src/x402/index.ts
2
- var exports_x402 = {};
3
- __export(exports_x402, {
4
- sponsorAndBroadcast: () => sponsorAndBroadcast,
5
- buildExactTransfer: () => buildExactTransfer
6
- });
7
- module.exports = __toCommonJS(exports_x402);
8
-
9
- // src/x402/build.ts
10
- function buildExactTransfer(options) {
11
- const { asset, amount, payTo, payer, payerPublicKey, accountNonce, chain } = options;
12
- if (utf8ToBytes(options.nonce).byteLength > MEMO_MAX_LENGTH_BYTES) {
13
- throw new Error(`x402 nonce exceeds the ${MEMO_MAX_LENGTH_BYTES}-byte memo budget`);
14
- }
15
- if (asset.kind === "stx") {
16
- return buildTokenTransfer({
17
- recipient: payTo,
18
- amount,
19
- memo: options.nonce,
20
- fee: 0,
21
- nonce: accountNonce,
22
- publicKey: payerPublicKey,
23
- chain,
24
- sponsored: true
25
- });
26
- }
27
- const [contractAddress, contractName] = parseContractId(asset.contractId);
28
- const postConditions = [
29
- Pc.principal(payer).willSendEq(amount).ft(asset.contractId, asset.assetName)
30
- ];
31
- return buildContractCall({
32
- contractAddress,
33
- contractName,
34
- functionName: "transfer",
35
- functionArgs: [
36
- Cl.uint(amount),
37
- Cl.principal(payer),
38
- Cl.principal(payTo),
39
- Cl.some(Cl.bufferFromUtf8(options.nonce))
40
- ],
41
- fee: 0,
42
- nonce: accountNonce,
43
- publicKey: payerPublicKey,
44
- chain,
45
- postConditionMode: "deny",
46
- postConditions,
47
- sponsored: true
48
- });
49
- }
50
- // src/x402/settle.ts
51
- async function sponsorAndBroadcast(client, signedTxHex, options = {}) {
52
- const transaction = deserializeTransaction(signedTxHex);
53
- const sponsored = await sponsorTransaction(client, {
54
- transaction,
55
- fee: options.fee,
56
- nonce: options.nonce
57
- });
58
- return sendTransaction(client, {
59
- transaction: sponsored,
60
- wait: options.wait
61
- });
62
- }
63
-
64
- //# debugId=26F0FC52B71944B464756E2164756E21
65
- //# sourceMappingURL=index.cjs.map
@@ -1,11 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/x402/build.ts", "../src/x402/settle.ts"],
4
- "sourcesContent": [
5
- "import type { StacksChain } from \"../chains/types.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport { Pc } from \"../postconditions/builder.ts\";\nimport type { PostCondition } from \"../postconditions/types.ts\";\nimport {\n\tbuildContractCall,\n\tbuildTokenTransfer,\n} from \"../transactions/build.ts\";\nimport {\n\tMEMO_MAX_LENGTH_BYTES,\n\ttype StacksTransaction,\n} from \"../transactions/types.ts\";\nimport { parseContractId } from \"../utils/address.ts\";\nimport { type IntegerType, utf8ToBytes } from \"../utils/encoding.ts\";\n\n/**\n * The asset an x402 payment moves. Either native STX or a SIP-010 token,\n * in which case the fully-qualified contract id and the fungible-token asset\n * name (the `::<asset-name>` suffix, e.g. `sbtc-token`) are both required —\n * the asset name is not always equal to the contract name.\n */\nexport type X402Asset =\n\t| { kind: \"stx\" }\n\t| { kind: \"sip010\"; contractId: string; assetName: string };\n\nexport type BuildExactTransferOptions = {\n\t/** The asset and amount to move. */\n\tasset: X402Asset;\n\tamount: IntegerType;\n\t/** Recipient principal (the resource server's `payTo`). */\n\tpayTo: string;\n\t/** Origin/payer principal — pinned by the post-condition. */\n\tpayer: string;\n\t/** Origin compressed public key (the payer signs origin-only). */\n\tpayerPublicKey: string;\n\t/** The payer account's next nonce. */\n\taccountNonce: IntegerType;\n\t/**\n\t * The x402 challenge nonce, carried in the on-chain memo so the facilitator\n\t * can correlate the settled tx with the challenge. Bound to ≤ 34 bytes\n\t * (UTF-8) — both the STX memo and the SIP-010 `(buff 34)` memo arg cap there.\n\t */\n\tnonce: string;\n\tchain?: StacksChain;\n};\n\n/**\n * Build an exact-amount, Deny-mode, post-conditioned, **sponsored** transfer\n * (origin-only, un-broadcast). The origin sets fee `0`; the facilitator's\n * sponsor fills in + pays the fee at settle time. The Deny-mode post-condition\n * asserts EXACTLY `amount` leaves `payer` to `payTo`, so settlement aborts\n * on-chain if anything differs — the \"exact amount\" x402 guarantee is enforced\n * by Clarity, not just by facilitator simulation.\n */\nexport function buildExactTransfer(\n\toptions: BuildExactTransferOptions,\n): StacksTransaction {\n\tconst { asset, amount, payTo, payer, payerPublicKey, accountNonce, chain } =\n\t\toptions;\n\n\tif (utf8ToBytes(options.nonce).byteLength > MEMO_MAX_LENGTH_BYTES) {\n\t\tthrow new Error(\n\t\t\t`x402 nonce exceeds the ${MEMO_MAX_LENGTH_BYTES}-byte memo budget`,\n\t\t);\n\t}\n\n\tif (asset.kind === \"stx\") {\n\t\t// A TokenTransfer payload CANNOT carry post-conditions (Stacks consensus\n\t\t// rejects it: \"TokenTransfer transactions do not support post-conditions\").\n\t\t// STX exactness is inherent — the amount + recipient are in the signed\n\t\t// payload, so there is nothing a post-condition would add.\n\t\treturn buildTokenTransfer({\n\t\t\trecipient: payTo,\n\t\t\tamount,\n\t\t\tmemo: options.nonce,\n\t\t\tfee: 0,\n\t\t\tnonce: accountNonce,\n\t\t\tpublicKey: payerPublicKey,\n\t\t\tchain,\n\t\t\tsponsored: true,\n\t\t});\n\t}\n\n\tconst [contractAddress, contractName] = parseContractId(asset.contractId);\n\tconst postConditions: PostCondition[] = [\n\t\tPc.principal(payer)\n\t\t\t.willSendEq(amount)\n\t\t\t.ft(asset.contractId, asset.assetName),\n\t];\n\t// SIP-010: (transfer (amount uint) (sender principal) (recipient principal) (memo (optional (buff 34))))\n\treturn buildContractCall({\n\t\tcontractAddress,\n\t\tcontractName,\n\t\tfunctionName: \"transfer\",\n\t\tfunctionArgs: [\n\t\t\tCl.uint(amount),\n\t\t\tCl.principal(payer),\n\t\t\tCl.principal(payTo),\n\t\t\tCl.some(Cl.bufferFromUtf8(options.nonce)),\n\t\t],\n\t\tfee: 0,\n\t\tnonce: accountNonce,\n\t\tpublicKey: payerPublicKey,\n\t\tchain,\n\t\tpostConditionMode: \"deny\",\n\t\tpostConditions,\n\t\tsponsored: true,\n\t});\n}\n",
6
- "import type { TransactionReceipt } from \"../actions/public/txSources.ts\";\nimport { sendTransaction } from \"../actions/wallet/sendTransaction.ts\";\nimport { sponsorTransaction } from \"../actions/wallet/sponsorTransaction.ts\";\nimport type { Client } from \"../clients/types.ts\";\nimport { deserializeTransaction } from \"../transactions/wire/deserialize.ts\";\nimport type { IntegerType } from \"../utils/encoding.ts\";\n\nexport type SponsorAndBroadcastOptions = {\n\t/** Override the sponsor fee (µSTX). Defaults to a fee estimate. */\n\tfee?: IntegerType;\n\t/** Override the sponsor account nonce. Defaults to the on-chain nonce. */\n\tnonce?: IntegerType;\n\t/**\n\t * Wait for the payment to be mined before returning (`true` = 1\n\t * confirmation, a number = that many). Settlement rejects if the payment\n\t * aborts or drops, instead of reporting a txid that never lands.\n\t */\n\twait?: boolean | number;\n};\n\nexport type SponsorAndBroadcastResult = {\n\ttxid: string;\n\t/** Present when `wait` was requested. */\n\treceipt?: TransactionReceipt;\n};\n\n/**\n * Take an origin-signed, sponsored transfer (hex) from the payer, sponsor-sign\n * it with `client`'s account (paying the STX fee), and broadcast it.\n *\n * The payer never holds STX: they sign origin-only with fee `0`; this fills in\n * the sponsor spending condition + fee and POSTs to `/v2/transactions`. The\n * sponsor cannot grief the payer — amount/recipient/asset are pinned by the\n * origin signature + Deny-mode post-conditions baked into the tx.\n *\n * @param client a wallet client whose `account` is the funded sponsor signer.\n * @param signedTxHex the payer's origin-signed sponsored tx, hex-serialized.\n */\nexport async function sponsorAndBroadcast(\n\tclient: Client,\n\tsignedTxHex: string,\n\toptions: SponsorAndBroadcastOptions = {},\n): Promise<SponsorAndBroadcastResult> {\n\tconst transaction = deserializeTransaction(signedTxHex);\n\tconst sponsored = await sponsorTransaction(client, {\n\t\ttransaction,\n\t\tfee: options.fee,\n\t\tnonce: options.nonce,\n\t});\n\treturn sendTransaction(client, {\n\t\ttransaction: sponsored,\n\t\twait: options.wait,\n\t});\n}\n"
7
- ],
8
- "mappings": ";;;;;;;;;AAsDO,SAAS,kBAAkB,CACjC,SACoB;AAAA,EACpB,QAAQ,OAAO,QAAQ,OAAO,OAAO,gBAAgB,cAAc,UAClE;AAAA,EAED,IAAI,YAAY,QAAQ,KAAK,EAAE,aAAa,uBAAuB;AAAA,IAClE,MAAM,IAAI,MACT,0BAA0B,wCAC3B;AAAA,EACD;AAAA,EAEA,IAAI,MAAM,SAAS,OAAO;AAAA,IAKzB,OAAO,mBAAmB;AAAA,MACzB,WAAW;AAAA,MACX;AAAA,MACA,MAAM,QAAQ;AAAA,MACd,KAAK;AAAA,MACL,OAAO;AAAA,MACP,WAAW;AAAA,MACX;AAAA,MACA,WAAW;AAAA,IACZ,CAAC;AAAA,EACF;AAAA,EAEA,OAAO,iBAAiB,gBAAgB,gBAAgB,MAAM,UAAU;AAAA,EACxE,MAAM,iBAAkC;AAAA,IACvC,GAAG,UAAU,KAAK,EAChB,WAAW,MAAM,EACjB,GAAG,MAAM,YAAY,MAAM,SAAS;AAAA,EACvC;AAAA,EAEA,OAAO,kBAAkB;AAAA,IACxB;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,cAAc;AAAA,MACb,GAAG,KAAK,MAAM;AAAA,MACd,GAAG,UAAU,KAAK;AAAA,MAClB,GAAG,UAAU,KAAK;AAAA,MAClB,GAAG,KAAK,GAAG,eAAe,QAAQ,KAAK,CAAC;AAAA,IACzC;AAAA,IACA,KAAK;AAAA,IACL,OAAO;AAAA,I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