@secondlayer/stacks 0.2.2 → 1.0.0-alpha.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 (159) hide show
  1. package/dist/shared/stacks-02actsrx.cjs.map +2 -2
  2. package/dist/shared/{stacks-xp9n3r0t.js → stacks-09wa7ewe.js} +108 -108
  3. package/dist/shared/stacks-09wa7ewe.js.map +15 -0
  4. package/dist/shared/{stacks-ky14tdf6.cjs → stacks-0nfexv24.cjs} +20 -8
  5. package/dist/shared/stacks-0nfexv24.cjs.map +14 -0
  6. package/dist/shared/{stacks-an5k8n4t.cjs → stacks-14pgpkrr.cjs} +82 -73
  7. package/dist/shared/stacks-14pgpkrr.cjs.map +23 -0
  8. package/dist/shared/{stacks-v6ja2eh7.cjs → stacks-17sdtaxg.cjs} +106 -102
  9. package/dist/shared/stacks-17sdtaxg.cjs.map +15 -0
  10. package/dist/shared/{stacks-96gaxfcf.js → stacks-1s5w4ncf.js} +44 -32
  11. package/dist/shared/stacks-1s5w4ncf.js.map +17 -0
  12. package/dist/shared/stacks-24h5k94q.cjs.map +3 -3
  13. package/dist/shared/{stacks-evnzth1q.cjs → stacks-4vzmhw3q.cjs} +3 -3
  14. package/dist/shared/stacks-4vzmhw3q.cjs.map +10 -0
  15. package/dist/shared/{stacks-k9p8m3wf.js → stacks-4x2bcc2k.js} +87 -78
  16. package/dist/shared/stacks-4x2bcc2k.js.map +23 -0
  17. package/dist/shared/stacks-5tprhns9.cjs.map +3 -3
  18. package/dist/shared/stacks-709tra19.js.map +2 -2
  19. package/dist/shared/{stacks-q79dx28x.js → stacks-70p84bgg.js} +3 -3
  20. package/dist/shared/stacks-70p84bgg.js.map +10 -0
  21. package/dist/shared/{stacks-k2p5tv6x.js → stacks-913a2rx7.js} +3 -3
  22. package/dist/shared/stacks-913a2rx7.js.map +10 -0
  23. package/dist/shared/{stacks-jrnmh4kc.js → stacks-96d6m1zy.js} +15 -6
  24. package/dist/shared/stacks-96d6m1zy.js.map +11 -0
  25. package/dist/shared/stacks-9g0jhab3.cjs.map +2 -2
  26. package/dist/shared/stacks-dr5en54r.cjs.map +2 -2
  27. package/dist/shared/stacks-fcaefc5b.cjs.map +2 -2
  28. package/dist/shared/stacks-gck1sq7h.cjs.map +2 -2
  29. package/dist/shared/stacks-je937aas.js.map +2 -2
  30. package/dist/shared/{stacks-k58k970n.js → stacks-kg1npstf.js} +5 -3
  31. package/dist/shared/stacks-kg1npstf.js.map +10 -0
  32. package/dist/shared/{stacks-qvg7c24g.cjs → stacks-n98w7g57.cjs} +5 -3
  33. package/dist/shared/stacks-n98w7g57.cjs.map +10 -0
  34. package/dist/shared/{stacks-6m1z4j07.js → stacks-nqae5amn.cjs} +74 -160
  35. package/dist/shared/stacks-nqae5amn.cjs.map +10 -0
  36. package/dist/shared/stacks-qcae5852.js.map +2 -2
  37. package/dist/shared/stacks-qt8ehebn.js.map +3 -3
  38. package/dist/shared/stacks-ra02bpny.cjs.map +3 -3
  39. package/dist/shared/stacks-rwfgts3s.js.map +2 -2
  40. package/dist/shared/stacks-s10yb9gz.js.map +2 -2
  41. package/dist/shared/{stacks-etf219gs.cjs → stacks-s30kkvm8.js} +101 -118
  42. package/dist/shared/stacks-s30kkvm8.js.map +10 -0
  43. package/dist/shared/stacks-s7z5q8be.js.map +3 -3
  44. package/dist/shared/stacks-v9jqcpd4.js.map +2 -2
  45. package/dist/shared/stacks-vdfag81a.cjs.map +2 -2
  46. package/dist/shared/{stacks-rg1g0fja.js → stacks-wjem3xw9.js} +21 -9
  47. package/dist/shared/stacks-wjem3xw9.js.map +14 -0
  48. package/dist/shared/{stacks-k08tgzyp.cjs → stacks-wyxj879g.cjs} +3 -3
  49. package/dist/shared/stacks-wyxj879g.cjs.map +13 -0
  50. package/dist/shared/stacks-y3dh7hv1.js.map +3 -3
  51. package/dist/shared/{stacks-2ar4prfz.cjs → stacks-y5262j0z.cjs} +14 -5
  52. package/dist/shared/stacks-y5262j0z.cjs.map +11 -0
  53. package/dist/shared/stacks-ya3x01yd.cjs.map +2 -2
  54. package/dist/shared/{stacks-p93g814f.js → stacks-zf7rbpzp.js} +4 -4
  55. package/dist/shared/stacks-zf7rbpzp.js.map +13 -0
  56. package/dist/shared/{stacks-61rvzkz1.cjs → stacks-znrb59ce.cjs} +41 -29
  57. package/dist/shared/stacks-znrb59ce.cjs.map +17 -0
  58. package/dist/src/accounts/index.cjs +2 -2
  59. package/dist/src/accounts/index.cjs.map +5 -5
  60. package/dist/src/accounts/index.js +2 -6
  61. package/dist/src/accounts/index.js.map +5 -5
  62. package/dist/src/actions/index.d.cts +29 -29
  63. package/dist/src/actions/index.d.ts +29 -29
  64. package/dist/src/actions/index.js +7 -7
  65. package/dist/src/bns/index.cjs +55 -43
  66. package/dist/src/bns/index.cjs.map +9 -9
  67. package/dist/src/bns/index.d.cts +29 -29
  68. package/dist/src/bns/index.d.ts +29 -29
  69. package/dist/src/bns/index.js +62 -50
  70. package/dist/src/bns/index.js.map +9 -9
  71. package/dist/src/clarity/index.js +4 -4
  72. package/dist/src/connect/index.cjs +114 -112
  73. package/dist/src/connect/index.cjs.map +13 -13
  74. package/dist/src/connect/index.js +114 -112
  75. package/dist/src/connect/index.js.map +13 -13
  76. package/dist/src/connect/walletconnect/index.cjs +3 -3
  77. package/dist/src/connect/walletconnect/index.cjs.map +10 -10
  78. package/dist/src/connect/walletconnect/index.js +3 -3
  79. package/dist/src/connect/walletconnect/index.js.map +10 -10
  80. package/dist/src/index.cjs +108 -2
  81. package/dist/src/index.cjs.map +19 -15
  82. package/dist/src/index.d.cts +291 -112
  83. package/dist/src/index.d.ts +291 -112
  84. package/dist/src/index.js +122 -9
  85. package/dist/src/index.js.map +19 -15
  86. package/dist/src/pox/index.cjs.map +6 -6
  87. package/dist/src/pox/index.d.cts +29 -29
  88. package/dist/src/pox/index.d.ts +29 -29
  89. package/dist/src/pox/index.js +5 -5
  90. package/dist/src/pox/index.js.map +6 -6
  91. package/dist/src/stackingdao/index.cjs +31 -6
  92. package/dist/src/stackingdao/index.cjs.map +6 -6
  93. package/dist/src/stackingdao/index.d.cts +29 -29
  94. package/dist/src/stackingdao/index.d.ts +29 -29
  95. package/dist/src/stackingdao/index.js +37 -12
  96. package/dist/src/stackingdao/index.js.map +6 -6
  97. package/dist/src/subscriptions/index.d.cts +29 -29
  98. package/dist/src/subscriptions/index.d.ts +29 -29
  99. package/dist/src/tools/btc/index.cjs +130 -0
  100. package/dist/src/tools/btc/index.cjs.map +10 -0
  101. package/dist/src/tools/btc/index.d.cts +8 -0
  102. package/dist/src/tools/btc/index.d.ts +8 -0
  103. package/dist/src/tools/btc/index.js +89 -0
  104. package/dist/src/tools/btc/index.js.map +10 -0
  105. package/dist/src/tools/index.cjs +2470 -0
  106. package/dist/src/tools/index.cjs.map +61 -0
  107. package/dist/src/tools/index.d.cts +144 -0
  108. package/dist/src/tools/index.d.ts +144 -0
  109. package/dist/src/tools/index.js +2435 -0
  110. package/dist/src/tools/index.js.map +61 -0
  111. package/dist/src/transactions/index.js +3 -3
  112. package/dist/src/triggers/index.cjs +66 -0
  113. package/dist/src/triggers/index.cjs.map +10 -0
  114. package/dist/src/triggers/index.d.cts +120 -0
  115. package/dist/src/triggers/index.d.ts +120 -0
  116. package/dist/src/triggers/index.js +25 -0
  117. package/dist/src/triggers/index.js.map +10 -0
  118. package/dist/src/tx/index.cjs +65 -0
  119. package/dist/src/tx/index.cjs.map +10 -0
  120. package/dist/src/tx/index.d.cts +42 -0
  121. package/dist/src/tx/index.d.ts +42 -0
  122. package/dist/src/tx/index.js +22 -0
  123. package/dist/src/tx/index.js.map +10 -0
  124. package/dist/src/ui/index.cjs +431 -0
  125. package/dist/src/ui/index.cjs.map +27 -0
  126. package/dist/src/ui/index.d.cts +107 -0
  127. package/dist/src/ui/index.d.ts +107 -0
  128. package/dist/src/ui/index.js +391 -0
  129. package/dist/src/ui/index.js.map +27 -0
  130. package/dist/src/ui/schemas.cjs +134 -0
  131. package/dist/src/ui/schemas.cjs.map +18 -0
  132. package/dist/src/ui/schemas.d.cts +83 -0
  133. package/dist/src/ui/schemas.d.ts +83 -0
  134. package/dist/src/ui/schemas.js +91 -0
  135. package/dist/src/ui/schemas.js.map +18 -0
  136. package/dist/src/utils/index.cjs +3 -3
  137. package/dist/src/utils/index.cjs.map +4 -4
  138. package/dist/src/utils/index.js +4 -4
  139. package/dist/src/utils/index.js.map +4 -4
  140. package/package.json +156 -105
  141. package/dist/shared/stacks-2ar4prfz.cjs.map +0 -11
  142. package/dist/shared/stacks-61rvzkz1.cjs.map +0 -17
  143. package/dist/shared/stacks-6m1z4j07.js.map +0 -10
  144. package/dist/shared/stacks-96gaxfcf.js.map +0 -17
  145. package/dist/shared/stacks-an5k8n4t.cjs.map +0 -23
  146. package/dist/shared/stacks-etf219gs.cjs.map +0 -10
  147. package/dist/shared/stacks-evnzth1q.cjs.map +0 -10
  148. package/dist/shared/stacks-jrnmh4kc.js.map +0 -11
  149. package/dist/shared/stacks-k08tgzyp.cjs.map +0 -13
  150. package/dist/shared/stacks-k2p5tv6x.js.map +0 -10
  151. package/dist/shared/stacks-k58k970n.js.map +0 -10
  152. package/dist/shared/stacks-k9p8m3wf.js.map +0 -23
  153. package/dist/shared/stacks-ky14tdf6.cjs.map +0 -13
  154. package/dist/shared/stacks-p93g814f.js.map +0 -13
  155. package/dist/shared/stacks-q79dx28x.js.map +0 -10
  156. package/dist/shared/stacks-qvg7c24g.cjs.map +0 -10
  157. package/dist/shared/stacks-rg1g0fja.js.map +0 -13
  158. package/dist/shared/stacks-v6ja2eh7.cjs.map +0 -15
  159. package/dist/shared/stacks-xp9n3r0t.js.map +0 -15
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/actions/getContract.ts"],
4
- "sourcesContent": [
5
- "import type { Client } from \"../clients/types.ts\";\nimport type {\n AbiContract,\n AbiFunction,\n AbiMap,\n AbiType,\n ExtractReadOnlyFunctions,\n ExtractPublicFunctions,\n ExtractFunctionArgs,\n ExtractFunctionOutput,\n ExtractMapNames,\n ExtractMapKey,\n ExtractMapValue,\n} from \"../clarity/abi/index.ts\";\nimport { toCamelCase, type ToCamelCase } from \"../clarity/abi/utils.ts\";\nimport { jsToClarityValue, clarityValueToJSUntyped } from \"../clarity/bridge.ts\";\nimport { readContract } from \"./public/readContract.ts\";\nimport { callContract } from \"./wallet/callContract.ts\";\nimport { getMapEntry } from \"./public/getMapEntry.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport type { PostCondition } from \"../postconditions/types.ts\";\nimport type { IntegerType } from \"../utils/encoding.ts\";\n\n// --- Type helpers for unwrapping response types ---\n\n/** Unwrap `(response ok err)` → just the `ok` branch type */\ntype UnwrapResponse<T> = T extends { ok: infer O } | { err: any } ? O : T;\n\ntype ReadMethodReturn<\n C extends AbiContract,\n N extends ExtractReadOnlyFunctions<C>,\n> = UnwrapResponse<ExtractFunctionOutput<C, N>>;\n\n// --- Public type for the contract instance ---\n\ntype ReadMethods<C extends AbiContract> = {\n [N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>]: (\n args: ExtractFunctionArgs<C, N>,\n ) => Promise<ReadMethodReturn<C, N>>;\n};\n\ntype CallMethods<C extends AbiContract> = {\n [N in ExtractPublicFunctions<C> as ToCamelCase<N>]: (\n args: ExtractFunctionArgs<C, N>,\n options?: ContractCallOptions,\n ) => Promise<string>;\n};\n\ntype MapMethods<C extends AbiContract> = {\n [N in ExtractMapNames<C> as ToCamelCase<N>]: (\n key: ExtractMapKey<C, N>,\n ) => Promise<ExtractMapValue<C, N> | null>;\n};\n\nexport type ContractCallOptions = {\n fee?: IntegerType;\n nonce?: IntegerType;\n postConditionMode?: \"allow\" | \"deny\";\n postConditions?: PostCondition[];\n};\n\nexport type ContractInstance<C extends AbiContract> = {\n read: ReadMethods<C>;\n call: CallMethods<C>;\n maps: MapMethods<C>;\n};\n\nexport type GetContractParams<C extends AbiContract> = {\n client: Client;\n address: string;\n name: string;\n abi: C;\n};\n\nexport function getContract<const TAbi extends AbiContract>(\n params: GetContractParams<TAbi>,\n): ContractInstance<TAbi> {\n const { client, address, name: contractName, abi } = params;\n const contractId = `${address}.${contractName}`;\n\n // Index functions/maps by name for fast lookup\n const fnByName = new Map<string, AbiFunction>();\n for (const fn of abi.functions) {\n fnByName.set(fn.name, fn as AbiFunction);\n }\n\n const mapByName = new Map<string, AbiMap>();\n if (abi.maps) {\n for (const m of abi.maps) {\n mapByName.set(m.name, m as AbiMap);\n }\n }\n\n // Build kebab→camel reverse map for function/map names\n const camelToKebab = new Map<string, string>();\n for (const fn of abi.functions) {\n camelToKebab.set(toCamelCase(fn.name), fn.name);\n }\n if (abi.maps) {\n for (const m of abi.maps) {\n camelToKebab.set(toCamelCase(m.name), m.name);\n }\n }\n\n const read = new Proxy({} as ReadMethods<TAbi>, {\n get(_target, prop: string) {\n const fnName = camelToKebab.get(prop) ?? prop;\n const fn = fnByName.get(fnName);\n if (!fn || fn.access !== \"read-only\") return undefined;\n\n return async (args: Record<string, unknown>) => {\n const clarityArgs = buildFunctionArgs(fn, args);\n const result = await readContract(client, {\n contract: contractId,\n functionName: fn.name,\n args: clarityArgs,\n });\n\n const jsValue = clarityValueToJSUntyped(fn.outputs as AbiType, result);\n\n // Auto-unwrap: if output is response type, unwrap ok / throw on err\n if (isResponseOutput(fn.outputs as AbiType)) {\n const resp = jsValue as { ok?: unknown; err?: unknown };\n if (\"ok\" in resp) return resp.ok;\n throw new ContractResponseError(\n `${contractId}::${fn.name} returned (err ${formatErrValue(resp.err)})`,\n resp.err,\n );\n }\n\n return jsValue;\n };\n },\n });\n\n const call = new Proxy({} as CallMethods<TAbi>, {\n get(_target, prop: string) {\n const fnName = camelToKebab.get(prop) ?? prop;\n const fn = fnByName.get(fnName);\n if (!fn || fn.access !== \"public\") return undefined;\n\n return async (\n args: Record<string, unknown>,\n options?: ContractCallOptions,\n ) => {\n const clarityArgs = buildFunctionArgs(fn, args);\n return callContract(client, {\n contract: contractId,\n functionName: fn.name,\n functionArgs: clarityArgs,\n ...options,\n });\n };\n },\n });\n\n const maps = new Proxy({} as MapMethods<TAbi>, {\n get(_target, prop: string) {\n const mapName = camelToKebab.get(prop) ?? prop;\n const map = mapByName.get(mapName);\n if (!map) return undefined;\n\n return async (key: unknown) => {\n const clarityKey = jsToClarityValue(map.key as AbiType, key);\n const result = await getMapEntry(client, {\n contract: contractId,\n mapName: map.name,\n key: clarityKey,\n });\n\n // Map entries come back as (optional ...). If none, return null.\n if (result.type === \"none\") return null;\n if (result.type === \"some\") {\n return clarityValueToJSUntyped(map.value as AbiType, result.value);\n }\n // Direct value (shouldn't normally happen, but handle gracefully)\n return clarityValueToJSUntyped(map.value as AbiType, result);\n };\n },\n });\n\n return { read, call, maps };\n}\n\n// --- Helpers ---\n\nfunction buildFunctionArgs(\n fn: AbiFunction,\n args: Record<string, unknown>,\n): ClarityValue[] {\n return fn.args.map((arg) => {\n const camelKey = toCamelCase(arg.name);\n const hasOriginal = arg.name in args;\n const hasCamel = camelKey in args;\n const value = hasOriginal ? args[arg.name] : hasCamel ? args[camelKey] : undefined;\n if (value === undefined) throw new Error(`Missing argument: ${arg.name}`);\n return jsToClarityValue(arg.type as AbiType, value);\n });\n}\n\nfunction isResponseOutput(type: AbiType): boolean {\n return typeof type === \"object\" && type !== null && \"response\" in type;\n}\n\nfunction formatErrValue(value: unknown): string {\n if (typeof value === \"bigint\") return value.toString();\n if (typeof value === \"string\") return `\"${value}\"`;\n return String(value);\n}\n\nexport class ContractResponseError extends Error {\n override name = \"ContractResponseError\";\n constructor(\n message: string,\n public readonly errorValue: unknown,\n ) {\n super(message);\n }\n}\n"
6
- ],
7
- "mappings": ";;;;;;;;;;;;AA0EO,SAAS,WAA2C,CACzD,QACwB;AAAA,EACxB,QAAQ,QAAQ,SAAS,MAAM,cAAc,QAAQ;AAAA,EACrD,MAAM,aAAa,GAAG,WAAW;AAAA,EAGjC,MAAM,WAAW,IAAI;AAAA,EACrB,WAAW,MAAM,IAAI,WAAW;AA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GAAG,KAAK,IAAI,CAAC,QAAQ;AAAA,IAC1B,MAAM,WAAW,YAAY,IAAI,IAAI;AAAA,IACrC,MAAM,cAAc,IAAI,QAAQ;AAAA,IAChC,MAAM,WAAW,YAAY;AAAA,IAC7B,MAAM,QAAQ,cAAc,KAAK,IAAI,QAAQ,WAAW,KAAK,YAAY;AAAA,IACzE,IAAI,UAAU;AAAA,MAAW,MAAM,IAAI,MAAM,qBAAqB,IAAI,MAAM;AAAA,IACxE,OAAO,iBAAiB,IAAI,MAAiB,KAAK;AAAA,GACnD;AAAA;AAGH,SAAS,gBAAgB,CAAC,MAAwB;AAAA,EAChD,OAAO,OAAO,SAAS,YAAY,SAAS,QAAQ,cAAc;AAAA;AAGpE,SAAS,cAAc,CAAC,OAAwB;AAAA,EAC9C,IAAI,OAAO,UAAU;AAAA,IAAU,OAAO,MAAM,SAAS;AAAA,EACrD,IAAI,OAAO,UAAU;AAAA,IAAU,OAAO,IAAI;AAAA,EAC1C,OAAO,OAAO,KAAK;AAAA;AAAA;AAGd,MAAM,8BAA8B,MAAM;AAAA,EAI7B;AAAA,EAHT,OAAO;AAAA,EAChB,WAAW,CACT,SACgB,YAChB;AAAA,IACA,MAAM,OAAO;AAAA,IAFG;AAAA;AAIpB;",
8
- "debugId": "C71C39F2B8094B6864756E2164756E21",
9
- "names": []
10
- }
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/clarity/abi/standards.ts"],
4
- "sourcesContent": [
5
- "import type { AbiContract } from \"./contract.ts\";\n\nexport const SIP010_ABI = {\n functions: [\n {\n name: \"transfer\",\n access: \"public\",\n args: [\n { name: \"amount\", type: \"uint128\" },\n { name: \"sender\", type: \"principal\" },\n { name: \"recipient\", type: \"principal\" },\n { name: \"memo\", type: { optional: { buff: { length: 34 } } } },\n ],\n outputs: { response: { ok: \"bool\", error: \"uint128\" } },\n },\n {\n name: \"get-balance\",\n access: \"read-only\",\n args: [{ name: \"account\", type: \"principal\" }],\n outputs: { response: { ok: \"uint128\", error: \"uint128\" } },\n },\n {\n name: \"get-total-supply\",\n access: \"read-only\",\n args: [],\n outputs: { response: { ok: \"uint128\", error: \"uint128\" } },\n },\n {\n name: \"get-name\",\n access: \"read-only\",\n args: [],\n outputs: {\n response: {\n ok: { \"string-ascii\": { length: 32 } },\n error: \"uint128\",\n },\n },\n },\n {\n name: \"get-symbol\",\n access: \"read-only\",\n args: [],\n outputs: {\n response: {\n ok: { \"string-ascii\": { length: 10 } },\n error: \"uint128\",\n },\n },\n },\n {\n name: \"get-decimals\",\n access: \"read-only\",\n args: [],\n outputs: { response: { ok: \"uint128\", error: \"uint128\" } },\n },\n {\n name: \"get-token-uri\",\n access: \"read-only\",\n args: [],\n outputs: {\n response: {\n ok: { optional: { \"string-utf8\": { length: 256 } } },\n error: \"uint128\",\n },\n },\n },\n ],\n fungible_tokens: [{ name: \"token\" }],\n} as const satisfies AbiContract;\n\nexport const SIP009_ABI = {\n functions: [\n {\n name: \"transfer\",\n access: \"public\",\n args: [\n { name: \"id\", type: \"uint128\" },\n { name: \"sender\", type: \"principal\" },\n { name: \"recipient\", type: \"principal\" },\n ],\n outputs: { response: { ok: \"bool\", error: \"uint128\" } },\n },\n {\n name: \"get-owner\",\n access: \"read-only\",\n args: [{ name: \"id\", type: \"uint128\" }],\n outputs: { response: { ok: { optional: \"principal\" }, error: \"uint128\" } },\n },\n {\n name: \"get-last-token-id\",\n access: \"read-only\",\n args: [],\n outputs: { response: { ok: \"uint128\", error: \"uint128\" } },\n },\n {\n name: \"get-token-uri\",\n access: \"read-only\",\n args: [{ name: \"id\", type: \"uint128\" }],\n outputs: {\n response: {\n ok: { optional: { \"string-utf8\": { length: 256 } } },\n error: \"uint128\",\n },\n },\n },\n ],\n non_fungible_tokens: [{ name: \"nft\", type: \"uint128\" }],\n} as const satisfies AbiContract;\n\nexport const SIP013_ABI = {\n functions: [\n {\n name: \"transfer\",\n access: \"public\",\n args: [\n { name: \"token-id\", type: \"uint128\" },\n { name: \"amount\", type: \"uint128\" },\n { name: \"sender\", type: \"principal\" },\n { name: \"recipient\", type: \"principal\" },\n ],\n outputs: { response: { ok: \"bool\", error: \"uint128\" } },\n },\n {\n name: \"transfer-memo\",\n access: \"public\",\n args: [\n { name: \"token-id\", type: \"uint128\" },\n { name: \"amount\", type: \"uint128\" },\n { name: \"sender\", type: \"principal\" },\n { name: \"recipient\", type: \"principal\" },\n { name: \"memo\", type: { buff: { length: 34 } } },\n ],\n outputs: { response: { ok: \"bool\", error: \"uint128\" } },\n },\n {\n name: \"transfer-many\",\n access: \"public\",\n args: [\n {\n name: \"transfers\",\n type: {\n list: {\n type: {\n tuple: [\n { name: \"token-id\", type: \"uint128\" },\n { name: \"amount\", type: \"uint128\" },\n { name: \"sender\", type: \"principal\" },\n { name: \"recipient\", type: \"principal\" },\n ],\n },\n length: 200,\n },\n },\n },\n ],\n outputs: { response: { ok: \"bool\", error: \"uint128\" } },\n },\n {\n name: \"transfer-many-memo\",\n access: \"public\",\n args: [\n {\n name: \"transfers\",\n type: {\n list: {\n type: {\n tuple: [\n { name: \"token-id\", type: \"uint128\" },\n { name: \"amount\", type: \"uint128\" },\n { name: \"sender\", type: \"principal\" },\n { name: \"recipient\", type: \"principal\" },\n { name: \"memo\", type: { buff: { length: 34 } } },\n ],\n },\n length: 200,\n },\n },\n },\n ],\n outputs: { response: { ok: \"bool\", error: \"uint128\" } },\n },\n {\n name: \"get-balance\",\n access: \"read-only\",\n args: [\n { name: \"token-id\", type: \"uint128\" },\n { name: \"account\", type: \"principal\" },\n ],\n outputs: { response: { ok: \"uint128\", error: \"uint128\" } },\n },\n {\n name: \"get-overall-balance\",\n access: \"read-only\",\n args: [{ name: \"account\", type: \"principal\" }],\n outputs: { response: { ok: \"uint128\", error: \"uint128\" } },\n },\n {\n name: \"get-total-supply\",\n access: \"read-only\",\n args: [{ name: \"token-id\", type: \"uint128\" }],\n outputs: { response: { ok: \"uint128\", error: \"uint128\" } },\n },\n {\n name: \"get-overall-supply\",\n access: \"read-only\",\n args: [],\n outputs: { response: { ok: \"uint128\", error: \"uint128\" } },\n },\n {\n name: \"get-decimals\",\n access: \"read-only\",\n args: [{ name: \"token-id\", type: \"uint128\" }],\n outputs: { response: { ok: \"uint128\", error: \"uint128\" } },\n },\n {\n name: \"get-token-uri\",\n access: \"read-only\",\n args: [{ name: \"token-id\", type: \"uint128\" }],\n outputs: {\n response: {\n ok: { optional: { \"string-utf8\": { length: 256 } } },\n error: \"uint128\",\n },\n },\n },\n ],\n fungible_tokens: [],\n non_fungible_tokens: [],\n} as const satisfies AbiContract;\n\n// Camel-case aliases for better DX\nexport const sip010Abi: AbiContract = SIP010_ABI;\nexport const sip009Abi: AbiContract = SIP009_ABI;\nexport const sip013Abi: AbiContract = SIP013_ABI;\n"
6
- ],
7
- "mappings": ";AAEO,IAAM,aAAa;AAAA,EACxB,WAAW;AAAA,IACT;AAAA,MACE,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,MAAM;AAAA,QACJ,EAAE,MAAM,UAAU,MAAM,UAAU;AAAA,QAClC,EAAE,MAAM,UAAU,MAAM,YAAY;AAAA,QACpC,EAAE,MAAM,aAAa,MAAM,YAAY;AAAA,QACvC,EAAE,MAAM,QAAQ,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,GAAG,EAAE,EAAE,EAAE;AAAA,MAC/D;AAAA,MACA,SAAS,EAAE,UAAU,EAAE,IAAI,QAAQ,OAAO,UAAU,EAAE;AAAA,IACxD;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,MAAM,CAAC,EAAE,MAAM,WAAW,MAAM,YAAY,CAAC;AAAA,MAC7C,SAAS,EAAE,UAAU,EAAE,IAAI,WAAW,OAAO,UAAU,EAAE;AAAA,IAC3D;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,MAAM,CAAC;AAAA,MACP,SAAS,EAAE,UAAU,EAAE,IAAI,WAAW,OAAO,UAAU,EA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,EACF;AAAA,EACA,iBAAiB,CAAC;AAAA,EAClB,qBAAqB,CAAC;AACxB;AAGO,IAAM,YAAyB;AAC/B,IAAM,YAAyB;AAC/B,IAAM,YAAyB;",
8
- "debugId": "AB6C51E03AD7EE0164756E2164756E21",
9
- "names": []
10
- }
@@ -1,13 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/clarity/types.ts", "../src/clarity/serialize.ts", "../src/clarity/deserialize.ts", "../src/clarity/values.ts"],
4
- "sourcesContent": [
5
- "export type ClarityType =\n | \"int\"\n | \"uint\"\n | \"buffer\"\n | \"true\"\n | \"false\"\n | \"address\"\n | \"contract\"\n | \"ok\"\n | \"err\"\n | \"none\"\n | \"some\"\n | \"list\"\n | \"tuple\"\n | \"ascii\"\n | \"utf8\";\n\n/** Wire type IDs matching the Stacks binary format (SIP-005) */\nexport const ClarityWireType = {\n int: 0x00,\n uint: 0x01,\n buffer: 0x02,\n true: 0x03,\n false: 0x04,\n address: 0x05,\n contract: 0x06,\n ok: 0x07,\n err: 0x08,\n none: 0x09,\n some: 0x0a,\n list: 0x0b,\n tuple: 0x0c,\n ascii: 0x0d,\n utf8: 0x0e,\n} as const satisfies Record<ClarityType, number>;\n\n/** Reverse lookup: wire byte → ClarityType string */\nconst wireTypeToClarity = Object.fromEntries(\n Object.entries(ClarityWireType).map(([k, v]) => [v, k])\n) as Record<number, ClarityType>;\n\nexport function clarityTypeFromByte(byte: number): ClarityType {\n const type = wireTypeToClarity[byte];\n if (!type) throw new Error(`Unknown clarity wire type: ${byte}`);\n return type;\n}\n\n// CV types\n\nexport type IntCV = { readonly type: \"int\"; readonly value: bigint };\nexport type UIntCV = { readonly type: \"uint\"; readonly value: bigint };\nexport type BooleanCV = TrueCV | FalseCV;\nexport type TrueCV = { readonly type: \"true\" };\nexport type FalseCV = { readonly type: \"false\" };\nexport type BufferCV = { readonly type: \"buffer\"; readonly value: string }; // hex\nexport type NoneCV = { readonly type: \"none\" };\nexport type SomeCV = {\n readonly type: \"some\";\n readonly value: ClarityValue;\n};\nexport type OptionalCV = NoneCV | SomeCV;\nexport type ResponseOkCV = {\n readonly type: \"ok\";\n readonly value: ClarityValue;\n};\nexport type ResponseErrorCV = {\n readonly type: \"err\";\n readonly value: ClarityValue;\n};\nexport type ResponseCV = ResponseOkCV | ResponseErrorCV;\nexport type StandardPrincipalCV = {\n readonly type: \"address\";\n readonly value: string;\n};\nexport type ContractPrincipalCV = {\n readonly type: \"contract\";\n readonly value: string; // \"address.name\"\n};\nexport type PrincipalCV = StandardPrincipalCV | ContractPrincipalCV;\nexport type ListCV = {\n type: \"list\";\n value: ClarityValue[];\n};\nexport type TupleData = {\n [key: string]: ClarityValue;\n};\nexport type TupleCV = {\n type: \"tuple\";\n value: TupleData;\n};\nexport type StringAsciiCV = {\n readonly type: \"ascii\";\n readonly value: string;\n};\nexport type StringUtf8CV = {\n readonly type: \"utf8\";\n readonly value: string;\n};\n\nexport type ClarityValue =\n | IntCV\n | UIntCV\n | BooleanCV\n | BufferCV\n | NoneCV\n | SomeCV\n | ResponseOkCV\n | ResponseErrorCV\n | StandardPrincipalCV\n | ContractPrincipalCV\n | ListCV\n | TupleCV\n | StringAsciiCV\n | StringUtf8CV;\n",
6
- "import {\n bytesToHex,\n hexToBytes,\n concatBytes,\n bigIntToBytes,\n toTwos,\n asciiToBytes,\n utf8ToBytes,\n writeUInt32BE,\n intToHex,\n} from \"../utils/encoding.ts\";\nimport { c32addressDecode } from \"../utils/c32.ts\";\nimport { ClarityWireType, type ClarityValue, type ClarityType } from \"./types.ts\";\n\nconst CLARITY_INT_SIZE = 128n;\nconst CLARITY_INT_BYTE_SIZE = 16;\n\nfunction typeIdByte(type: ClarityType): number {\n return ClarityWireType[type];\n}\n\nfunction withTypeId(type: ClarityType, bytes: Uint8Array): Uint8Array {\n return concatBytes(new Uint8Array([typeIdByte(type)]), bytes);\n}\n\nfunction serializeAddress(c32Address: string): Uint8Array {\n const [version, hash160] = c32addressDecode(c32Address);\n return concatBytes(new Uint8Array([version]), hexToBytes(hash160));\n}\n\nfunction serializeLPString(str: string, prefixBytes = 1): Uint8Array {\n const content = utf8ToBytes(str);\n const lengthPrefix = hexToBytes(intToHex(content.byteLength, prefixBytes));\n return concatBytes(lengthPrefix, content);\n}\n\nexport function serializeCVBytes(value: ClarityValue): Uint8Array {\n switch (value.type) {\n case \"true\":\n case \"false\":\n return new Uint8Array([typeIdByte(value.type)]);\n\n case \"int\": {\n const bytes = bigIntToBytes(\n toTwos(BigInt(value.value), CLARITY_INT_SIZE),\n CLARITY_INT_BYTE_SIZE\n );\n return withTypeId(value.type, bytes);\n }\n\n case \"uint\": {\n const bytes = bigIntToBytes(BigInt(value.value), CLARITY_INT_BYTE_SIZE);\n return withTypeId(value.type, bytes);\n }\n\n case \"buffer\": {\n const bufBytes = hexToBytes(value.value);\n return withTypeId(\n value.type,\n concatBytes(writeUInt32BE(bufBytes.length), bufBytes)\n );\n }\n\n case \"none\":\n return new Uint8Array([typeIdByte(value.type)]);\n\n case \"some\":\n return withTypeId(value.type, serializeCVBytes(value.value));\n\n case \"ok\":\n case \"err\":\n return withTypeId(value.type, serializeCVBytes(value.value));\n\n case \"address\":\n return withTypeId(value.type, serializeAddress(value.value));\n\n case \"contract\": {\n const [addr, name] = value.value.split(\".\");\n if (!addr || !name) throw new Error(`Invalid contract principal: ${value.value}`);\n return withTypeId(\n value.type,\n concatBytes(serializeAddress(addr), serializeLPString(name))\n );\n }\n\n case \"list\": {\n const parts: Uint8Array[] = [writeUInt32BE(value.value.length)];\n for (const item of value.value) {\n parts.push(serializeCVBytes(item));\n }\n return withTypeId(value.type, concatBytes(...parts));\n }\n\n case \"tuple\": {\n const keys = Object.keys(value.value).sort((a, b) => a.localeCompare(b));\n const parts: Uint8Array[] = [writeUInt32BE(keys.length)];\n for (const key of keys) {\n parts.push(serializeLPString(key));\n parts.push(serializeCVBytes(value.value[key]!));\n }\n return withTypeId(value.type, concatBytes(...parts));\n }\n\n case \"ascii\": {\n const strBytes = asciiToBytes(value.value);\n return withTypeId(\n value.type,\n concatBytes(writeUInt32BE(strBytes.length), strBytes)\n );\n }\n\n case \"utf8\": {\n const strBytes = utf8ToBytes(value.value);\n return withTypeId(\n value.type,\n concatBytes(writeUInt32BE(strBytes.length), strBytes)\n );\n }\n\n default:\n throw new Error(`Cannot serialize unknown clarity type`);\n }\n}\n\nexport function serializeCV(value: ClarityValue): string {\n return bytesToHex(serializeCVBytes(value));\n}\n",
7
- "import {\n hexToBytes,\n bytesToHex,\n bytesToAscii,\n bytesToUtf8,\n bytesToTwosBigInt,\n without0x,\n} from \"../utils/encoding.ts\";\nimport { c32address } from \"../utils/c32.ts\";\nimport {\n clarityTypeFromByte,\n type ClarityValue,\n} from \"./types.ts\";\nimport {\n intCV,\n uintCV,\n trueCV,\n falseCV,\n bufferCV,\n noneCV,\n someCV,\n responseOkCV,\n responseErrorCV,\n standardPrincipalCV,\n contractPrincipalCV,\n listCV,\n tupleCV,\n stringAsciiCV,\n stringUtf8CV,\n} from \"./values.ts\";\n\nclass BytesReader {\n private data: Uint8Array;\n private offset = 0;\n\n constructor(data: Uint8Array) {\n this.data = data;\n }\n\n readUInt8(): number {\n const value = this.data[this.offset]!;\n this.offset += 1;\n return value;\n }\n\n readUInt32BE(): number {\n const value =\n ((this.data[this.offset]! << 24) |\n (this.data[this.offset + 1]! << 16) |\n (this.data[this.offset + 2]! << 8) |\n this.data[this.offset + 3]!) >>>\n 0;\n this.offset += 4;\n return value;\n }\n\n readBytes(length: number): Uint8Array {\n const slice = this.data.slice(this.offset, this.offset + length);\n this.offset += length;\n return slice;\n }\n}\n\nfunction readAddress(reader: BytesReader): string {\n const version = reader.readUInt8();\n const hash160 = bytesToHex(reader.readBytes(20));\n return c32address(version, hash160);\n}\n\nfunction readLPString(reader: BytesReader, prefixBytes = 1): string {\n let length = 0;\n for (let i = 0; i < prefixBytes; i++) {\n length = (length << 8) | reader.readUInt8();\n }\n return bytesToUtf8(reader.readBytes(length));\n}\n\nfunction readCV(reader: BytesReader): ClarityValue {\n const typeByte = reader.readUInt8();\n const type = clarityTypeFromByte(typeByte);\n\n switch (type) {\n case \"int\":\n return intCV(bytesToTwosBigInt(reader.readBytes(16)));\n\n case \"uint\":\n return uintCV(reader.readBytes(16));\n\n case \"true\":\n return trueCV();\n\n case \"false\":\n return falseCV();\n\n case \"buffer\": {\n const len = reader.readUInt32BE();\n return bufferCV(reader.readBytes(len));\n }\n\n case \"none\":\n return noneCV();\n\n case \"some\":\n return someCV(readCV(reader));\n\n case \"ok\":\n return responseOkCV(readCV(reader));\n\n case \"err\":\n return responseErrorCV(readCV(reader));\n\n case \"address\":\n return standardPrincipalCV(readAddress(reader));\n\n case \"contract\": {\n const addr = readAddress(reader);\n const name = readLPString(reader);\n return contractPrincipalCV(addr, name);\n }\n\n case \"list\": {\n const len = reader.readUInt32BE();\n const items: ClarityValue[] = [];\n for (let i = 0; i < len; i++) {\n items.push(readCV(reader));\n }\n return listCV(items);\n }\n\n case \"tuple\": {\n const len = reader.readUInt32BE();\n const data: Record<string, ClarityValue> = {};\n for (let i = 0; i < len; i++) {\n const key = readLPString(reader);\n data[key] = readCV(reader);\n }\n return tupleCV(data);\n }\n\n case \"ascii\": {\n const len = reader.readUInt32BE();\n return stringAsciiCV(bytesToAscii(reader.readBytes(len)));\n }\n\n case \"utf8\": {\n const len = reader.readUInt32BE();\n return stringUtf8CV(bytesToUtf8(reader.readBytes(len)));\n }\n\n default:\n throw new Error(`Cannot deserialize unknown clarity type: ${type}`);\n }\n}\n\nexport function deserializeCVBytes<T extends ClarityValue = ClarityValue>(\n input: Uint8Array | string\n): T {\n const bytes =\n typeof input === \"string\" ? hexToBytes(without0x(input)) : input;\n return readCV(new BytesReader(bytes)) as T;\n}\n\nexport function deserializeCV<T extends ClarityValue = ClarityValue>(\n input: Uint8Array | string\n): T {\n return deserializeCVBytes(input);\n}\n",
8
- "import { c32address, c32addressDecode } from \"../utils/c32.ts\";\nimport {\n bytesToHex,\n hexToBytes,\n asciiToBytes,\n utf8ToBytes,\n intToBigInt,\n bytesToTwosBigInt,\n type IntegerType,\n} from \"../utils/encoding.ts\";\nimport { isClarityName } from \"../utils/address.ts\";\nimport type {\n IntCV,\n UIntCV,\n BooleanCV,\n TrueCV,\n FalseCV,\n BufferCV,\n NoneCV,\n SomeCV,\n ResponseOkCV,\n ResponseErrorCV,\n StandardPrincipalCV,\n ContractPrincipalCV,\n ListCV,\n TupleCV,\n TupleData,\n StringAsciiCV,\n StringUtf8CV,\n ClarityValue,\n} from \"./types.ts\";\nimport { serializeCVBytes } from \"./serialize.ts\";\nimport { deserializeCVBytes } from \"./deserialize.ts\";\n\nconst MAX_U128 = BigInt(\"0xffffffffffffffffffffffffffffffff\");\nconst MIN_I128 = BigInt(\"-170141183460469231731687303715884105728\");\nconst MAX_I128 = BigInt(\"0x7fffffffffffffffffffffffffffffff\");\n\n// Primitives\n\nexport function intCV(value: IntegerType): IntCV {\n if (typeof value === \"string\" && value.toLowerCase().startsWith(\"0x\")) {\n value = bytesToTwosBigInt(hexToBytes(value));\n }\n if (value instanceof Uint8Array) value = bytesToTwosBigInt(value);\n const n = intToBigInt(value);\n if (n > MAX_I128) throw new RangeError(`Int exceeds max i128: ${MAX_I128}`);\n if (n < MIN_I128) throw new RangeError(`Int below min i128: ${MIN_I128}`);\n return { type: \"int\", value: n };\n}\n\nexport function uintCV(value: IntegerType): UIntCV {\n const n = intToBigInt(value);\n if (n < 0n) throw new RangeError(\"Cannot construct unsigned int from negative value\");\n if (n > MAX_U128) throw new RangeError(`UInt exceeds max u128: ${MAX_U128}`);\n return { type: \"uint\", value: n };\n}\n\nexport const trueCV = (): TrueCV => ({ type: \"true\" });\nexport const falseCV = (): FalseCV => ({ type: \"false\" });\nexport const boolCV = (v: boolean): BooleanCV => (v ? trueCV() : falseCV());\n\nexport function bufferCV(buffer: Uint8Array): BufferCV {\n if (buffer.byteLength > 1_048_576) {\n throw new Error(\"Buffer exceeds max size of 1MB\");\n }\n return { type: \"buffer\", value: bytesToHex(buffer) };\n}\n\nexport function standardPrincipalCV(address: string): StandardPrincipalCV {\n // Validate by decoding\n const [version, hash160] = c32addressDecode(address);\n const normalized = c32address(version, hash160);\n return { type: \"address\", value: normalized };\n}\n\nexport function contractPrincipalCV(\n address: string,\n contractName: string\n): ContractPrincipalCV {\n const [version, hash160] = c32addressDecode(address);\n const normalized = c32address(version, hash160);\n if (utf8ToBytes(contractName).byteLength >= 128) {\n throw new Error(\"Contract name must be less than 128 bytes\");\n }\n return { type: \"contract\", value: `${normalized}.${contractName}` };\n}\n\nexport function noneCV(): NoneCV {\n return { type: \"none\" };\n}\n\nexport function someCV(value: ClarityValue): SomeCV {\n return { type: \"some\", value };\n}\n\nexport function responseOkCV(value: ClarityValue): ResponseOkCV {\n return { type: \"ok\", value };\n}\n\nexport function responseErrorCV(value: ClarityValue): ResponseErrorCV {\n return { type: \"err\", value };\n}\n\nexport function listCV(values: ClarityValue[]): ListCV {\n return { type: \"list\", value: values };\n}\n\nexport function tupleCV(data: TupleData): TupleCV {\n for (const key in data) {\n if (!isClarityName(key)) {\n throw new Error(`\"${key}\" is not a valid Clarity name`);\n }\n }\n return { type: \"tuple\", value: data };\n}\n\nexport function stringAsciiCV(value: string): StringAsciiCV {\n return { type: \"ascii\", value };\n}\n\nexport function stringUtf8CV(value: string): StringUtf8CV {\n return { type: \"utf8\", value };\n}\n\n// Cl namespace — clean API\n\nexport const Cl: {\n readonly int: (value: IntegerType) => IntCV;\n readonly uint: (value: IntegerType) => UIntCV;\n readonly bool: (v: boolean) => BooleanCV;\n principal(address: string): StandardPrincipalCV | ContractPrincipalCV;\n address(address: string): StandardPrincipalCV | ContractPrincipalCV;\n readonly contractPrincipal: (address: string, contractName: string) => ContractPrincipalCV;\n readonly standardPrincipal: (address: string) => StandardPrincipalCV;\n readonly buffer: (buffer: Uint8Array) => BufferCV;\n readonly bufferFromHex: (hex: string) => BufferCV;\n readonly bufferFromAscii: (ascii: string) => BufferCV;\n readonly bufferFromUtf8: (utf8: string) => BufferCV;\n readonly none: () => NoneCV;\n readonly some: (value: ClarityValue) => SomeCV;\n readonly ok: (value: ClarityValue) => ResponseOkCV;\n readonly error: (value: ClarityValue) => ResponseErrorCV;\n readonly list: (values: ClarityValue[]) => ListCV;\n readonly tuple: (data: TupleData) => TupleCV;\n readonly stringAscii: (value: string) => StringAsciiCV;\n readonly stringUtf8: (value: string) => StringUtf8CV;\n serialize(value: ClarityValue): string;\n readonly deserialize: (bytes: Uint8Array) => ClarityValue;\n} = {\n int: intCV,\n uint: uintCV,\n bool: boolCV,\n principal(address: string): StandardPrincipalCV | ContractPrincipalCV {\n const [addr, name] = address.split(\".\");\n if (!addr) throw new Error(\"Invalid principal address\");\n return name ? contractPrincipalCV(addr, name) : standardPrincipalCV(addr);\n },\n address(address: string): StandardPrincipalCV | ContractPrincipalCV {\n return Cl.principal(address);\n },\n contractPrincipal: contractPrincipalCV,\n standardPrincipal: standardPrincipalCV,\n buffer: bufferCV,\n bufferFromHex: (hex: string): BufferCV => bufferCV(hexToBytes(hex)),\n bufferFromAscii: (ascii: string): BufferCV => bufferCV(asciiToBytes(ascii)),\n bufferFromUtf8: (utf8: string): BufferCV => bufferCV(utf8ToBytes(utf8)),\n none: noneCV,\n some: someCV,\n ok: responseOkCV,\n error: responseErrorCV,\n list: listCV,\n tuple: tupleCV,\n stringAscii: stringAsciiCV,\n stringUtf8: stringUtf8CV,\n serialize(value: ClarityValue): string {\n return bytesToHex(serializeCVBytes(value));\n },\n deserialize: deserializeCVBytes,\n} as const;\n"
9
- ],
10
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAkBO,IAAM,kBAAkB;AAAA,EAC7B,KAAK;AAAA,EACL,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,UAAU;AAAA,EACV,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA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AI,MAAM,2BAA2B;AAAA,IACtD,OAAO,OAAO,oBAAoB,MAAM,IAAI,IAAI,oBAAoB,IAAI;AAAA;AAAA,EAE1E,OAAO,CAAC,SAA4D;AAAA,IAClE,OAAO,GAAG,UAAU,OAAO;AAAA;AAAA,EAE7B,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,QAAQ;AAAA,EACR,eAAe,CAAC,QAA0B,SAAS,WAAW,GAAG,CAAC;AAAA,EAClE,iBAAiB,CAAC,UAA4B,SAAS,aAAa,KAAK,CAAC;AAAA,EAC1E,gBAAgB,CAAC,SAA2B,SAAS,YAAY,IAAI,CAAC;AAAA,EACtE,MAAM;AAAA,EACN,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,SAAS,CAAC,OAA6B;AAAA,IACrC,OAAO,WAAW,iBAAiB,KAAK,CAAC;AAAA;AAAA,EAE3C,aAAa;AACf;",
11
- "debugId": "E7F2F7102FA4D24C64756E2164756E21",
12
- "names": []
13
- }
@@ -1,15 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/transactions/types.ts", "../src/transactions/wire/serialize.ts", "../src/transactions/authorization.ts", "../src/transactions/multisig.ts", "../src/transactions/signer.ts", "../src/transactions/build.ts"],
4
- "sourcesContent": [
5
- "import type { ClarityValue } from \"../clarity/types.ts\";\n\n// Auth types\nexport const AuthType = {\n Standard: 0x04,\n Sponsored: 0x05,\n} as const;\nexport type AuthType = (typeof AuthType)[keyof typeof AuthType];\n\n// Payload types\nexport const PayloadType = {\n TokenTransfer: 0x00,\n SmartContract: 0x01,\n ContractCall: 0x02,\n PoisonMicroblock: 0x03,\n Coinbase: 0x04,\n CoinbaseToAltRecipient: 0x05,\n VersionedSmartContract: 0x06,\n TenureChange: 0x07,\n NakamotoCoinbase: 0x08,\n} as const;\nexport type PayloadType = (typeof PayloadType)[keyof typeof PayloadType];\n\n// Clarity version\nexport const ClarityVersion = {\n Clarity1: 1,\n Clarity2: 2,\n Clarity3: 3,\n Clarity4: 4,\n Clarity5: 5,\n} as const;\nexport type ClarityVersion = (typeof ClarityVersion)[keyof typeof ClarityVersion];\n\n// Anchor mode (deprecated post-Nakamoto, but needed for wire format)\nexport const AnchorMode = {\n OnChainOnly: 0x01,\n OffChainOnly: 0x02,\n Any: 0x03,\n} as const;\nexport type AnchorMode = (typeof AnchorMode)[keyof typeof AnchorMode];\n\n// Post condition mode\nexport const PostConditionModeWire = {\n Allow: 0x01,\n Deny: 0x02,\n} as const;\nexport type PostConditionModeWire =\n (typeof PostConditionModeWire)[keyof typeof PostConditionModeWire];\n\n// Address hash modes\nexport const AddressHashMode = {\n P2PKH: 0x00,\n P2SH: 0x01,\n P2WPKH: 0x02,\n P2WSH: 0x03,\n P2SH_NonSequential: 0x05, // SIP-027\n P2WSH_P2SH_NonSequential: 0x07, // SIP-027\n} as const;\nexport type AddressHashMode = (typeof AddressHashMode)[keyof typeof AddressHashMode];\n\n// Pub key encoding\nexport const PubKeyEncoding = {\n Compressed: 0x00,\n Uncompressed: 0x01,\n} as const;\nexport type PubKeyEncoding = (typeof PubKeyEncoding)[keyof typeof PubKeyEncoding];\n\n// Fungible condition codes (wire format)\nexport const FungibleConditionCode = {\n Equal: 0x01,\n Greater: 0x02,\n GreaterEqual: 0x03,\n Less: 0x04,\n LessEqual: 0x05,\n} as const;\n\n// Non-fungible condition codes (wire format)\nexport const NonFungibleConditionCode = {\n Sends: 0x10,\n DoesNotSend: 0x11,\n} as const;\n\n// Post condition principal types\nexport const PostConditionPrincipalId = {\n Origin: 0x01,\n Standard: 0x02,\n Contract: 0x03,\n} as const;\n\n// Post condition asset types\nexport const AssetType = {\n STX: 0x00,\n Fungible: 0x01,\n NonFungible: 0x02,\n} as const;\n\n// Auth field types\nexport const AuthFieldType = {\n PublicKeyCompressed: 0x00,\n PublicKeyUncompressed: 0x01,\n SignatureCompressed: 0x02,\n SignatureUncompressed: 0x03,\n} as const;\n\nexport const RECOVERABLE_ECDSA_SIG_LENGTH_BYTES = 65;\nexport const MEMO_MAX_LENGTH_BYTES = 34;\nexport const MAX_STRING_LENGTH_BYTES = 128;\nexport const COINBASE_BYTES_LENGTH = 32;\nexport const VRF_PROOF_BYTES_LENGTH = 80;\nexport const MICROBLOCK_HEADER_BYTES_LENGTH = 132; // 1 + 2 + 32 + 32 + 65\n\n// Tenure change cause\nexport const TenureChangeCause = {\n BlockFound: 0x00,\n Extended: 0x01,\n ExtendedRuntime: 0x02,\n ExtendedReadCount: 0x03,\n ExtendedReadLength: 0x04,\n ExtendedWriteCount: 0x05,\n ExtendedWriteLength: 0x06,\n} as const;\nexport type TenureChangeCause = (typeof TenureChangeCause)[keyof typeof TenureChangeCause];\n\n// Token transfer payload\nexport type TokenTransferPayload = {\n payloadType: typeof PayloadType.TokenTransfer;\n recipient: ClarityValue; // PrincipalCV\n amount: bigint;\n memo: string;\n};\n\n// Contract call payload\nexport type ContractCallPayload = {\n payloadType: typeof PayloadType.ContractCall;\n contractAddress: string;\n contractName: string;\n functionName: string;\n functionArgs: ClarityValue[];\n};\n\n// Smart contract deploy payload\nexport type SmartContractPayload = {\n payloadType: typeof PayloadType.SmartContract | typeof PayloadType.VersionedSmartContract;\n clarityVersion?: ClarityVersion;\n contractName: string;\n codeBody: string;\n};\n\n// Coinbase payload (appears in every pre-Nakamoto block)\nexport type CoinbasePayload = {\n payloadType: typeof PayloadType.Coinbase;\n coinbaseBuffer: string; // 32 bytes hex\n};\n\n// Coinbase to alt recipient payload\nexport type CoinbaseToAltRecipientPayload = {\n payloadType: typeof PayloadType.CoinbaseToAltRecipient;\n coinbaseBuffer: string; // 32 bytes hex\n recipient: ClarityValue; // PrincipalCV\n};\n\n// Poison microblock payload\nexport type PoisonMicroblockPayload = {\n payloadType: typeof PayloadType.PoisonMicroblock;\n header1: string; // 132 bytes hex (raw microblock header)\n header2: string; // 132 bytes hex (raw microblock header)\n};\n\n// Tenure change payload (Nakamoto)\nexport type TenureChangePayload = {\n payloadType: typeof PayloadType.TenureChange;\n tenureConsensusHash: string; // 20 bytes hex\n prevTenureConsensusHash: string; // 20 bytes hex\n burnViewConsensusHash: string; // 20 bytes hex\n previousTenureEnd: string; // 32 bytes hex\n previousTenureBlocks: number; // u32\n cause: TenureChangeCause;\n pubkeyHash: string; // 20 bytes hex\n};\n\n// Nakamoto coinbase payload\nexport type NakamotoCoinbasePayload = {\n payloadType: typeof PayloadType.NakamotoCoinbase;\n coinbaseBuffer: string; // 32 bytes hex\n recipient: ClarityValue | null; // Optional PrincipalCV\n vrfProof: string; // 80 bytes hex\n};\n\nexport type TransactionPayload =\n | TokenTransferPayload\n | ContractCallPayload\n | SmartContractPayload\n | CoinbasePayload\n | CoinbaseToAltRecipientPayload\n | PoisonMicroblockPayload\n | TenureChangePayload\n | NakamotoCoinbasePayload;\n\n// Spending condition\nexport type SingleSigSpendingCondition = {\n hashMode: typeof AddressHashMode.P2PKH | typeof AddressHashMode.P2WPKH;\n signer: string; // hash160 hex\n nonce: bigint;\n fee: bigint;\n keyEncoding: PubKeyEncoding;\n signature: string; // 65-byte recoverable sig hex\n};\n\nexport type TransactionAuthField = {\n pubKeyEncoding: PubKeyEncoding;\n type: \"publicKey\" | \"signature\";\n data: string; // hex\n};\n\nexport type MultiSigHashMode =\n | typeof AddressHashMode.P2SH\n | typeof AddressHashMode.P2WSH\n | typeof AddressHashMode.P2SH_NonSequential\n | typeof AddressHashMode.P2WSH_P2SH_NonSequential;\n\nexport type MultiSigSpendingCondition = {\n hashMode: MultiSigHashMode;\n signer: string;\n nonce: bigint;\n fee: bigint;\n fields: TransactionAuthField[];\n signaturesRequired: number;\n};\n\nexport type SpendingCondition = SingleSigSpendingCondition | MultiSigSpendingCondition;\n\nexport type StandardAuthorization = {\n authType: typeof AuthType.Standard;\n spendingCondition: SpendingCondition;\n};\n\nexport type SponsoredAuthorization = {\n authType: typeof AuthType.Sponsored;\n spendingCondition: SpendingCondition;\n sponsorSpendingCondition: SpendingCondition;\n};\n\nexport type Authorization = StandardAuthorization | SponsoredAuthorization;\n\n// Full transaction\nexport type StacksTransaction = {\n version: number;\n chainId: number;\n auth: Authorization;\n anchorMode: AnchorMode;\n postConditionMode: PostConditionModeWire;\n postConditions: PostConditionWire[];\n payload: TransactionPayload;\n};\n\n// Wire post condition types\nexport type PostConditionWire = StxPostConditionWire | FtPostConditionWire | NftPostConditionWire;\n\nexport type StxPostConditionWire = {\n type: \"stx\";\n principal: PostConditionPrincipalWire;\n conditionCode: number;\n amount: bigint;\n};\n\nexport type FtPostConditionWire = {\n type: \"ft\";\n principal: PostConditionPrincipalWire;\n asset: AssetInfoWire;\n conditionCode: number;\n amount: bigint;\n};\n\nexport type NftPostConditionWire = {\n type: \"nft\";\n principal: PostConditionPrincipalWire;\n asset: AssetInfoWire;\n conditionCode: number;\n assetId: ClarityValue;\n};\n\nexport type PostConditionPrincipalWire =\n | { type: \"origin\" }\n | { type: \"standard\"; address: string }\n | { type: \"contract\"; address: string; contractName: string };\n\nexport type AssetInfoWire = {\n address: string;\n contractName: string;\n assetName: string;\n};\n",
6
- "import {\n bytesToHex,\n hexToBytes,\n concatBytes,\n intToBytes,\n intToHex,\n utf8ToBytes,\n asciiToBytes,\n writeUInt32BE,\n writeUInt16BE,\n writeUInt8,\n} from \"../../utils/encoding.ts\";\nimport { c32addressDecode } from \"../../utils/c32.ts\";\nimport { serializeCVBytes } from \"../../clarity/serialize.ts\";\nimport {\n AuthType,\n PayloadType,\n PostConditionPrincipalId,\n AssetType,\n MEMO_MAX_LENGTH_BYTES,\n type StacksTransaction,\n type Authorization,\n type SpendingCondition,\n type SingleSigSpendingCondition,\n type MultiSigSpendingCondition,\n type TransactionPayload,\n type PostConditionWire,\n type PostConditionPrincipalWire,\n type AssetInfoWire,\n type TransactionAuthField,\n type CoinbasePayload,\n type CoinbaseToAltRecipientPayload,\n type PoisonMicroblockPayload,\n type TenureChangePayload as TenureChangePayloadType,\n type NakamotoCoinbasePayload,\n} from \"../types.ts\";\n\n// Address serialization: version (1 byte) + hash160 (20 bytes)\nfunction serializeAddress(c32Address: string): Uint8Array {\n const [version, hash160] = c32addressDecode(c32Address);\n return concatBytes(new Uint8Array([version]), hexToBytes(hash160));\n}\n\n// LP string: length prefix (n bytes) + content bytes\nfunction serializeLPString(str: string, prefixBytes = 1): Uint8Array {\n const content = utf8ToBytes(str);\n const prefix = hexToBytes(intToHex(content.byteLength, prefixBytes));\n return concatBytes(prefix, content);\n}\n\n// LP string for code body (4-byte prefix)\nfunction serializeLPStringLong(str: string): Uint8Array {\n return serializeLPString(str, 4);\n}\n\n// Memo: flat 34-byte field (no length prefix) per SIP-005\nfunction serializeMemo(memo: string): Uint8Array {\n const content = asciiToBytes(memo);\n const padded = new Uint8Array(MEMO_MAX_LENGTH_BYTES);\n padded.set(content.slice(0, MEMO_MAX_LENGTH_BYTES));\n return padded;\n}\n\nfunction serializeSpendingCondition(condition: SpendingCondition): Uint8Array {\n const parts: Uint8Array[] = [\n writeUInt8(condition.hashMode),\n hexToBytes(condition.signer), // 20 bytes\n intToBytes(condition.nonce, 8),\n intToBytes(condition.fee, 8),\n ];\n\n if (\"signature\" in condition) {\n // Single sig\n const sc = condition as SingleSigSpendingCondition;\n parts.push(writeUInt8(sc.keyEncoding));\n parts.push(hexToBytes(sc.signature)); // 65 bytes\n } else {\n // Multi sig\n const mc = condition as MultiSigSpendingCondition;\n // Fields as LP list\n parts.push(writeUInt32BE(mc.fields.length));\n for (const field of mc.fields) {\n parts.push(serializeAuthField(field));\n }\n parts.push(writeUInt16BE(mc.signaturesRequired));\n }\n\n return concatBytes(...parts);\n}\n\nfunction serializeAuthField(field: TransactionAuthField): Uint8Array {\n if (field.type === \"publicKey\") {\n const typeId = field.pubKeyEncoding === 0x00 ? 0x00 : 0x01;\n return concatBytes(writeUInt8(typeId), hexToBytes(field.data));\n } else {\n const typeId = field.pubKeyEncoding === 0x00 ? 0x02 : 0x03;\n return concatBytes(writeUInt8(typeId), hexToBytes(field.data));\n }\n}\n\nfunction serializeAuthorization(auth: Authorization): Uint8Array {\n const parts: Uint8Array[] = [writeUInt8(auth.authType)];\n parts.push(serializeSpendingCondition(auth.spendingCondition));\n if (auth.authType === AuthType.Sponsored) {\n parts.push(serializeSpendingCondition(auth.sponsorSpendingCondition));\n }\n return concatBytes(...parts);\n}\n\nfunction serializePrincipal(principal: PostConditionPrincipalWire): Uint8Array {\n switch (principal.type) {\n case \"origin\":\n return writeUInt8(PostConditionPrincipalId.Origin);\n case \"standard\":\n return concatBytes(\n writeUInt8(PostConditionPrincipalId.Standard),\n serializeAddress(principal.address)\n );\n case \"contract\":\n return concatBytes(\n writeUInt8(PostConditionPrincipalId.Contract),\n serializeAddress(principal.address),\n serializeLPString(principal.contractName)\n );\n }\n}\n\nfunction serializeAssetInfo(asset: AssetInfoWire): Uint8Array {\n return concatBytes(\n serializeAddress(asset.address),\n serializeLPString(asset.contractName),\n serializeLPString(asset.assetName)\n );\n}\n\nfunction serializePostCondition(pc: PostConditionWire): Uint8Array {\n // Wire order: asset_type first, then principal (per SIP-005)\n const parts: Uint8Array[] = [];\n\n switch (pc.type) {\n case \"stx\":\n parts.push(writeUInt8(AssetType.STX));\n parts.push(serializePrincipal(pc.principal));\n parts.push(writeUInt8(pc.conditionCode));\n parts.push(intToBytes(pc.amount, 8));\n break;\n case \"ft\":\n parts.push(writeUInt8(AssetType.Fungible));\n parts.push(serializePrincipal(pc.principal));\n parts.push(serializeAssetInfo(pc.asset));\n parts.push(writeUInt8(pc.conditionCode));\n parts.push(intToBytes(pc.amount, 8));\n break;\n case \"nft\":\n parts.push(writeUInt8(AssetType.NonFungible));\n parts.push(serializePrincipal(pc.principal));\n parts.push(serializeAssetInfo(pc.asset));\n parts.push(serializeCVBytes(pc.assetId));\n parts.push(writeUInt8(pc.conditionCode));\n break;\n }\n\n return concatBytes(...parts);\n}\n\nfunction serializePostConditions(pcs: PostConditionWire[]): Uint8Array {\n const parts: Uint8Array[] = [writeUInt32BE(pcs.length)];\n for (const pc of pcs) {\n parts.push(serializePostCondition(pc));\n }\n return concatBytes(...parts);\n}\n\nexport function serializePayload(payload: TransactionPayload): Uint8Array {\n const parts: Uint8Array[] = [writeUInt8(payload.payloadType)];\n\n switch (payload.payloadType) {\n case PayloadType.TokenTransfer:\n parts.push(serializeCVBytes(payload.recipient));\n parts.push(intToBytes(payload.amount, 8));\n parts.push(serializeMemo(payload.memo));\n break;\n\n case PayloadType.ContractCall:\n parts.push(serializeAddress(payload.contractAddress));\n parts.push(serializeLPString(payload.contractName));\n parts.push(serializeLPString(payload.functionName));\n parts.push(writeUInt32BE(payload.functionArgs.length));\n for (const arg of payload.functionArgs) {\n parts.push(serializeCVBytes(arg));\n }\n break;\n\n case PayloadType.SmartContract:\n parts.push(serializeLPString(payload.contractName));\n parts.push(serializeLPStringLong(payload.codeBody));\n break;\n\n case PayloadType.VersionedSmartContract:\n parts.push(writeUInt8(payload.clarityVersion ?? 2));\n parts.push(serializeLPString(payload.contractName));\n parts.push(serializeLPStringLong(payload.codeBody));\n break;\n\n case PayloadType.Coinbase:\n parts.push(hexToBytes((payload as CoinbasePayload).coinbaseBuffer));\n break;\n\n case PayloadType.CoinbaseToAltRecipient: {\n const cbAlt = payload as CoinbaseToAltRecipientPayload;\n parts.push(hexToBytes(cbAlt.coinbaseBuffer));\n parts.push(serializeCVBytes(cbAlt.recipient));\n break;\n }\n\n case PayloadType.PoisonMicroblock: {\n const pm = payload as PoisonMicroblockPayload;\n parts.push(hexToBytes(pm.header1));\n parts.push(hexToBytes(pm.header2));\n break;\n }\n\n case PayloadType.TenureChange: {\n const tc = payload as TenureChangePayloadType;\n parts.push(hexToBytes(tc.tenureConsensusHash));\n parts.push(hexToBytes(tc.prevTenureConsensusHash));\n parts.push(hexToBytes(tc.burnViewConsensusHash));\n parts.push(hexToBytes(tc.previousTenureEnd));\n parts.push(writeUInt32BE(tc.previousTenureBlocks));\n parts.push(writeUInt8(tc.cause));\n parts.push(hexToBytes(tc.pubkeyHash));\n break;\n }\n\n case PayloadType.NakamotoCoinbase: {\n const nc = payload as NakamotoCoinbasePayload;\n parts.push(hexToBytes(nc.coinbaseBuffer));\n if (nc.recipient) {\n parts.push(serializeCVBytes({ type: \"some\", value: nc.recipient }));\n } else {\n parts.push(serializeCVBytes({ type: \"none\" }));\n }\n parts.push(hexToBytes(nc.vrfProof));\n break;\n }\n }\n\n return concatBytes(...parts);\n}\n\nexport function serializeTransaction(tx: StacksTransaction): Uint8Array {\n return concatBytes(\n writeUInt8(tx.version),\n writeUInt32BE(tx.chainId),\n serializeAuthorization(tx.auth),\n writeUInt8(tx.anchorMode),\n writeUInt8(tx.postConditionMode),\n serializePostConditions(tx.postConditions),\n serializePayload(tx.payload)\n );\n}\n\nexport function serializeTransactionHex(tx: StacksTransaction): string {\n return bytesToHex(serializeTransaction(tx));\n}\n",
7
- "import {\n getPublicKey as nobleGetPublicKey,\n sign,\n etc,\n} from \"@noble/secp256k1\";\nimport { hmac } from \"@noble/hashes/hmac.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport {\n bytesToHex,\n hexToBytes,\n intToBytes,\n intToHex,\n concatBytes,\n} from \"../utils/encoding.ts\";\nimport { hashP2PKH, txidFromBytes } from \"../utils/hash.ts\";\nimport {\n AuthType,\n AddressHashMode,\n PubKeyEncoding,\n RECOVERABLE_ECDSA_SIG_LENGTH_BYTES,\n type SingleSigSpendingCondition,\n type SpendingCondition,\n type Authorization,\n type StandardAuthorization,\n type SponsoredAuthorization,\n} from \"./types.ts\";\n\n// Ensure sync signing is available\netc.hmacSha256Sync = (key: Uint8Array, ...msgs: Uint8Array[]) => {\n const h = hmac.create(sha256, key);\n msgs.forEach((msg) => h.update(msg));\n return h.digest();\n};\n\nconst EMPTY_SIG = bytesToHex(new Uint8Array(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES));\n\nexport function createSingleSigSpendingCondition(\n publicKey: string,\n nonce: bigint,\n fee: bigint\n): SingleSigSpendingCondition {\n const pubKeyBytes = hexToBytes(publicKey);\n const signer = hashP2PKH(pubKeyBytes);\n const isCompressed = pubKeyBytes.length === 33;\n\n return {\n hashMode: AddressHashMode.P2PKH,\n signer,\n nonce,\n fee,\n keyEncoding: isCompressed ? PubKeyEncoding.Compressed : PubKeyEncoding.Uncompressed,\n signature: EMPTY_SIG,\n };\n}\n\nexport function createStandardAuth(\n spendingCondition: SpendingCondition\n): StandardAuthorization {\n return { authType: AuthType.Standard, spendingCondition };\n}\n\nexport function createSponsoredAuth(\n spendingCondition: SpendingCondition,\n sponsorSpendingCondition?: SpendingCondition\n): SponsoredAuthorization {\n return {\n authType: AuthType.Sponsored,\n spendingCondition,\n sponsorSpendingCondition: sponsorSpendingCondition ?? createSingleSigSpendingCondition(\n \"0\".repeat(66),\n 0n,\n 0n\n ),\n };\n}\n\nfunction clearCondition(condition: SpendingCondition): SpendingCondition {\n if (\"signature\" in condition) {\n return {\n ...condition,\n nonce: 0n,\n fee: 0n,\n signature: EMPTY_SIG,\n };\n }\n return {\n ...condition,\n nonce: 0n,\n fee: 0n,\n fields: [],\n };\n}\n\nexport function intoInitialSighashAuth(auth: Authorization): Authorization {\n if (auth.authType === AuthType.Standard) {\n return createStandardAuth(clearCondition(auth.spendingCondition));\n }\n return createSponsoredAuth(\n clearCondition(auth.spendingCondition),\n clearCondition(createSingleSigSpendingCondition(\"0\".repeat(66), 0n, 0n))\n );\n}\n\n/** Compute pre-sign sighash = sha512/256(prevSigHash + authType + fee + nonce) */\nexport function sigHashPreSign(\n curSigHash: string,\n authType: number,\n fee: bigint,\n nonce: bigint\n): string {\n const data = concatBytes(\n hexToBytes(curSigHash),\n new Uint8Array([authType]),\n intToBytes(fee, 8),\n intToBytes(nonce, 8)\n );\n return txidFromBytes(data);\n}\n\n/** Compute post-sign sighash = sha512/256(preSigHash + pubKeyEncoding + signature) */\nexport function sigHashPostSign(\n curSigHash: string,\n pubKeyEncoding: number,\n signature: string\n): string {\n const data = concatBytes(\n hexToBytes(curSigHash),\n new Uint8Array([pubKeyEncoding]),\n hexToBytes(signature)\n );\n return txidFromBytes(data);\n}\n\n/** Sign with private key and return VRS signature (recoveryId + r + s) */\nfunction signWithKey(privateKey: string, messageHash: string): string {\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const sig = sign(messageHash, keyBytes, { lowS: true });\n const recoveryIdHex = intToHex(sig.recovery, 1);\n return recoveryIdHex + sig.toCompactHex();\n}\n\nexport function nextSignature(\n curSigHash: string,\n authType: number,\n fee: bigint,\n nonce: bigint,\n privateKey: string\n): { nextSig: string; nextSigHash: string } {\n const sigHashPre = sigHashPreSign(curSigHash, authType, fee, nonce);\n\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const pubKey = nobleGetPublicKey(keyBytes, true);\n const isCompressed = pubKey.length === 33;\n const pubKeyEncoding = isCompressed\n ? PubKeyEncoding.Compressed\n : PubKeyEncoding.Uncompressed;\n\n const nextSig = signWithKey(privateKey, sigHashPre);\n const nextSigHash = sigHashPostSign(sigHashPre, pubKeyEncoding, nextSig);\n\n return { nextSig, nextSigHash };\n}\n",
8
- "import {\n getPublicKey as nobleGetPublicKey,\n sign as nobleSign,\n} from \"@noble/secp256k1\";\nimport { c32address } from \"../utils/c32.ts\";\nimport { bytesToHex, hexToBytes, intToHex, concatBytes } from \"../utils/encoding.ts\";\nimport { hash160 } from \"../utils/hash.ts\";\nimport {\n sigHashPreSign,\n sigHashPostSign,\n intoInitialSighashAuth,\n nextSignature,\n} from \"./authorization.ts\";\nimport { txidFromBytes } from \"../utils/hash.ts\";\nimport { serializeTransaction } from \"./wire/serialize.ts\";\nimport {\n AuthType,\n AddressHashMode,\n PubKeyEncoding,\n type MultiSigSpendingCondition,\n type MultiSigHashMode,\n type TransactionAuthField,\n type StacksTransaction,\n} from \"./types.ts\";\nimport type { StacksChain } from \"../chains/types.ts\";\nimport type { LocalAccount, CustomAccount } from \"../accounts/types.ts\";\n\n// OP codes for redeem script\nconst OP_CHECKMULTISIG = 0xae;\n\n/** Check if hash mode is non-sequential (SIP-027) */\nexport function isNonSequential(hashMode: number): boolean {\n return (hashMode & 0x04) !== 0;\n}\n\n/** Build a Bitcoin-style redeem script for m-of-n multi-sig */\nfunction makeRedeemScript(publicKeys: string[], signaturesRequired: number): Uint8Array {\n const parts: Uint8Array[] = [];\n parts.push(new Uint8Array([0x50 + signaturesRequired])); // OP_n\n for (const pk of publicKeys) {\n const pkBytes = hexToBytes(pk);\n parts.push(new Uint8Array([pkBytes.length])); // length prefix (0x21 for compressed)\n parts.push(pkBytes);\n }\n parts.push(new Uint8Array([0x50 + publicKeys.length])); // OP_m\n parts.push(new Uint8Array([OP_CHECKMULTISIG]));\n return concatBytes(...parts);\n}\n\n/** Derive a multi-sig address from public keys */\nexport function makeMultiSigAddress(\n publicKeys: string[],\n signaturesRequired: number,\n chain?: StacksChain\n): string {\n if (signaturesRequired < 1 || signaturesRequired > publicKeys.length) {\n throw new Error(`signaturesRequired must be between 1 and ${publicKeys.length}`);\n }\n const redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n const signer = hash160(redeemScript);\n const version = chain?.addressVersion?.multiSig ?? 20; // mainnet default\n return c32address(version, bytesToHex(signer));\n}\n\n/** Create an empty multi-sig spending condition */\nexport function createMultiSigSpendingCondition(\n publicKeys: string[],\n signaturesRequired: number,\n nonce: bigint,\n fee: bigint,\n hashMode: MultiSigHashMode = AddressHashMode.P2SH\n): MultiSigSpendingCondition {\n const redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n const signer = bytesToHex(hash160(redeemScript));\n\n return {\n hashMode,\n signer,\n nonce,\n fee,\n fields: [],\n signaturesRequired,\n };\n}\n\n/** Compute the initial sighash for a transaction (same as signBegin) */\nfunction initialSigHash(tx: StacksTransaction): string {\n const cleared: StacksTransaction = {\n ...tx,\n auth: intoInitialSighashAuth(tx.auth),\n };\n return txidFromBytes(serializeTransaction(cleared));\n}\n\n/** Compute the presign-sighash used by all non-sequential signers */\nfunction nonSequentialPreSignHash(tx: StacksTransaction): string {\n const condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n const initHash = initialSigHash(tx);\n return sigHashPreSign(initHash, AuthType.Standard, condition.fee, condition.nonce);\n}\n\n/** Replay sighash through existing auth fields of a multi-sig tx */\nexport function replayMultiSigSigHash(tx: StacksTransaction): string {\n const condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n // Non-sequential: all signers sign the same presign-sighash, no field chaining\n if (isNonSequential(condition.hashMode)) {\n const preSign = nonSequentialPreSignHash(tx);\n // Chain through all fields to get the final sighash\n let curSigHash = preSign;\n for (const field of condition.fields) {\n curSigHash = sigHashPostSign(curSigHash, field.pubKeyEncoding, field.data);\n }\n return curSigHash;\n }\n\n // Sequential: chain through all fields\n let curSigHash = initialSigHash(tx);\n for (const field of condition.fields) {\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n }\n return curSigHash;\n}\n\n/** Sign one position of a multi-sig transaction with a private key */\nexport function signMultiSig(\n tx: StacksTransaction,\n privateKey: string,\n publicKeys: string[]\n): StacksTransaction {\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const signerPubKey = bytesToHex(nobleGetPublicKey(keyBytes, true));\n\n const signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n if (signerIndex === -1) {\n throw new Error(\"Private key does not correspond to any signer in the multi-sig\");\n }\n\n const condition = { ...(tx.auth.spendingCondition as MultiSigSpendingCondition) };\n\n // Non-sequential: all signers sign the same presign-sighash independently\n if (isNonSequential(condition.hashMode)) {\n return signNonSequential(tx, condition, privateKey);\n }\n\n // Sequential: existing P2SH behavior\n return signSequential(tx, condition, privateKey, publicKeys, signerIndex);\n}\n\n/** Non-sequential signing: compute presign-sighash from initial tx, sign, append */\nfunction signNonSequential(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n privateKey: string\n): StacksTransaction {\n const fields = [...condition.fields];\n const preSignHash = nonSequentialPreSignHash(tx);\n\n // Sign the presign-sighash directly\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const sig = nobleSign(preSignHash, keyBytes, { lowS: true });\n const recoveryIdHex = intToHex(sig.recovery, 1);\n const nextSig = recoveryIdHex + sig.toCompactHex();\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n const sigCount = fields.filter((f) => f.type === \"signature\").length;\n\n // Auto-finalize: non-sequential needs no pubkey gap-filling\n if (sigCount >= condition.signaturesRequired) {\n return {\n ...tx,\n auth: { ...tx.auth, spendingCondition: newCondition },\n };\n }\n\n return {\n ...tx,\n auth: { ...tx.auth, spendingCondition: newCondition },\n };\n}\n\n/** Sequential signing: existing P2SH behavior */\nfunction signSequential(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n privateKey: string,\n publicKeys: string[],\n signerIndex: number\n): StacksTransaction {\n const fields = [...condition.fields];\n\n // Replay sighash through existing fields\n let curSigHash = initialSigHash(tx);\n for (const field of fields) {\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n }\n\n // Fill intervening positions with pubkey fields\n for (let i = fields.length; i < signerIndex; i++) {\n const pubKeyField: TransactionAuthField = {\n type: \"publicKey\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: publicKeys[i]!,\n };\n fields.push(pubKeyField);\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, pubKeyField.pubKeyEncoding, pubKeyField.data);\n }\n\n // Sign at signerIndex\n const { nextSig, nextSigHash } = nextSignature(\n curSigHash,\n AuthType.Standard,\n condition.fee,\n condition.nonce,\n privateKey\n );\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n curSigHash = nextSigHash;\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n // Count signatures so far\n const sigCount = fields.filter((f) => f.type === \"signature\").length;\n let finalCondition = newCondition;\n\n // Auto-finalize if enough signatures collected\n if (sigCount >= condition.signaturesRequired) {\n finalCondition = finalizeMultiSigCondition(newCondition, publicKeys, curSigHash);\n }\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: finalCondition,\n },\n };\n}\n\n/** Sign one position of a multi-sig transaction with an account */\nexport async function signMultiSigWithAccount(\n tx: StacksTransaction,\n account: LocalAccount | CustomAccount,\n publicKeys: string[]\n): Promise<StacksTransaction> {\n const signerPubKey = account.publicKey;\n\n const signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n if (signerIndex === -1) {\n throw new Error(\"Account does not correspond to any signer in the multi-sig\");\n }\n\n const condition = { ...(tx.auth.spendingCondition as MultiSigSpendingCondition) };\n\n // Non-sequential: all signers sign the same presign-sighash independently\n if (isNonSequential(condition.hashMode)) {\n return signNonSequentialWithAccount(tx, condition, account);\n }\n\n // Sequential: existing behavior\n return signSequentialWithAccount(tx, condition, account, publicKeys, signerIndex);\n}\n\n/** Non-sequential signing with account */\nasync function signNonSequentialWithAccount(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n account: LocalAccount | CustomAccount\n): Promise<StacksTransaction> {\n const fields = [...condition.fields];\n const preSignHash = nonSequentialPreSignHash(tx);\n\n const sigBytes = await account.sign(hexToBytes(preSignHash));\n const nextSig = bytesToHex(sigBytes);\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n return {\n ...tx,\n auth: { ...tx.auth, spendingCondition: newCondition },\n };\n}\n\n/** Sequential signing with account */\nasync function signSequentialWithAccount(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n account: LocalAccount | CustomAccount,\n publicKeys: string[],\n signerIndex: number\n): Promise<StacksTransaction> {\n const fields = [...condition.fields];\n\n // Replay sighash through existing fields\n let curSigHash = initialSigHash(tx);\n for (const field of fields) {\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n }\n\n // Fill intervening positions with pubkey fields\n for (let i = fields.length; i < signerIndex; i++) {\n const pubKeyField: TransactionAuthField = {\n type: \"publicKey\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: publicKeys[i]!,\n };\n fields.push(pubKeyField);\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, pubKeyField.pubKeyEncoding, pubKeyField.data);\n }\n\n // Sign at signerIndex\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n const sigBytes = await account.sign(hexToBytes(preSign));\n const nextSig = bytesToHex(sigBytes);\n const nextSigHash = sigHashPostSign(preSign, PubKeyEncoding.Compressed, nextSig);\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n curSigHash = nextSigHash;\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n // Count signatures so far\n const sigCount = fields.filter((f) => f.type === \"signature\").length;\n let finalCondition = newCondition;\n\n // Auto-finalize if enough signatures collected\n if (sigCount >= condition.signaturesRequired) {\n finalCondition = finalizeMultiSigCondition(newCondition, publicKeys, curSigHash);\n }\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: finalCondition,\n },\n };\n}\n\n/** Fill remaining slots with pubkey fields after all signatures are collected */\nexport function finalizeMultiSig(\n tx: StacksTransaction,\n publicKeys: string[]\n): StacksTransaction {\n const condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n // Non-sequential: no pubkey gap-filling needed\n if (isNonSequential(condition.hashMode)) {\n return tx;\n }\n\n const curSigHash = replayMultiSigSigHash(tx);\n const finalCondition = finalizeMultiSigCondition(condition, publicKeys, curSigHash);\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: finalCondition,\n },\n };\n}\n\n/** Internal: finalize remaining pubkey slots (sequential only) */\nfunction finalizeMultiSigCondition(\n condition: MultiSigSpendingCondition,\n publicKeys: string[],\n curSigHash: string\n): MultiSigSpendingCondition {\n const fields = [...condition.fields];\n let sigHash = curSigHash;\n\n // Fill remaining positions\n for (let i = fields.length; i < publicKeys.length; i++) {\n const pubKeyField: TransactionAuthField = {\n type: \"publicKey\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: publicKeys[i]!,\n };\n fields.push(pubKeyField);\n const preSign = sigHashPreSign(sigHash, AuthType.Standard, condition.fee, condition.nonce);\n sigHash = sigHashPostSign(preSign, pubKeyField.pubKeyEncoding, pubKeyField.data);\n }\n\n return { ...condition, fields };\n}\n\n/** Combine independently-signed non-sequential multi-sig transactions */\nexport function combineMultiSigSignatures(\n baseTx: StacksTransaction,\n signedTxs: StacksTransaction[]\n): StacksTransaction {\n const condition = baseTx.auth.spendingCondition as MultiSigSpendingCondition;\n\n if (!isNonSequential(condition.hashMode)) {\n throw new Error(\"combineMultiSigSignatures only works with non-sequential hash modes (SIP-027)\");\n }\n\n // Collect all signature fields from each signed tx\n const seenSigs = new Set<string>();\n const signatures: TransactionAuthField[] = [];\n\n for (const stx of signedTxs) {\n const stxCondition = stx.auth.spendingCondition as MultiSigSpendingCondition;\n for (const field of stxCondition.fields) {\n if (field.type === \"signature\" && !seenSigs.has(field.data)) {\n seenSigs.add(field.data);\n signatures.push(field);\n }\n }\n }\n\n if (signatures.length === 0) {\n throw new Error(\"No signatures found in the provided transactions\");\n }\n\n const newCondition: MultiSigSpendingCondition = {\n ...condition,\n fields: signatures,\n };\n\n return {\n ...baseTx,\n auth: { ...baseTx.auth, spendingCondition: newCondition },\n };\n}\n",
9
- "import { bytesToHex, hexToBytes } from \"../utils/encoding.ts\";\nimport { txidFromBytes } from \"../utils/hash.ts\";\nimport {\n intoInitialSighashAuth,\n nextSignature,\n sigHashPreSign,\n sigHashPostSign,\n} from \"./authorization.ts\";\nimport { replayMultiSigSigHash } from \"./multisig.ts\";\nimport { serializeTransaction } from \"./wire/serialize.ts\";\nimport {\n AuthType,\n type StacksTransaction,\n type SingleSigSpendingCondition,\n type SponsoredAuthorization,\n} from \"./types.ts\";\nimport type { LocalAccount, CustomAccount } from \"../accounts/types.ts\";\n\nfunction txid(tx: StacksTransaction): string {\n return txidFromBytes(serializeTransaction(tx));\n}\n\n/** Compute the initial sighash for a transaction */\nexport function signBegin(tx: StacksTransaction): string {\n const cleared: StacksTransaction = {\n ...tx,\n auth: intoInitialSighashAuth(tx.auth),\n };\n return txid(cleared);\n}\n\n/** Sign a single-sig transaction with a private key, returning the signed transaction */\nexport function signTransaction(\n tx: StacksTransaction,\n privateKey: string\n): StacksTransaction {\n const sigHash = signBegin(tx);\n const condition = tx.auth.spendingCondition as SingleSigSpendingCondition;\n\n // Origin always signs with AuthType.Standard (even for sponsored txs)\n const { nextSig } = nextSignature(\n sigHash,\n AuthType.Standard,\n condition.fee,\n condition.nonce,\n privateKey\n );\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: {\n ...condition,\n signature: nextSig,\n },\n },\n };\n}\n\n/** Sign a single-sig transaction using an account (LocalAccount or CustomAccount) */\nexport async function signTransactionWithAccount(\n tx: StacksTransaction,\n account: LocalAccount | CustomAccount\n): Promise<StacksTransaction> {\n const sigHash = signBegin(tx);\n const condition = tx.auth.spendingCondition as SingleSigSpendingCondition;\n\n // Origin always signs with AuthType.Standard (even for sponsored txs)\n const sigHashPre = sigHashPreSign(\n sigHash,\n AuthType.Standard,\n condition.fee,\n condition.nonce\n );\n\n // account.sign returns 65-byte VRS (recovery + r + s)\n const sigBytes = await account.sign(hexToBytes(sigHashPre));\n const nextSig = bytesToHex(sigBytes);\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: {\n ...condition,\n signature: nextSig,\n },\n },\n };\n}\n\n/** Get the txid of a transaction */\nexport function getTransactionId(tx: StacksTransaction): string {\n return txid(tx);\n}\n\n/** Reconstruct the sighash after origin signing (needed for sponsor signing) */\nexport function getOriginSigHash(tx: StacksTransaction): string {\n const condition = tx.auth.spendingCondition;\n\n // Multi-sig: replay through all fields\n if (\"fields\" in condition) {\n return replayMultiSigSigHash(tx);\n }\n\n // Single-sig\n const initialSigHash = signBegin(tx);\n const sc = condition as SingleSigSpendingCondition;\n const preSign = sigHashPreSign(initialSigHash, AuthType.Standard, sc.fee, sc.nonce);\n return sigHashPostSign(preSign, sc.keyEncoding, sc.signature);\n}\n\n/** Sign a sponsored transaction as the sponsor with a private key */\nexport function signSponsor(tx: StacksTransaction, privateKey: string): StacksTransaction {\n if (tx.auth.authType !== AuthType.Sponsored) {\n throw new Error(\"Transaction must be sponsored\");\n }\n const auth = tx.auth as SponsoredAuthorization;\n const sponsorCondition = auth.sponsorSpendingCondition as SingleSigSpendingCondition;\n const originSigHash = getOriginSigHash(tx);\n\n const { nextSig } = nextSignature(\n originSigHash,\n AuthType.Sponsored,\n sponsorCondition.fee,\n sponsorCondition.nonce,\n privateKey\n );\n\n return {\n ...tx,\n auth: {\n ...auth,\n sponsorSpendingCondition: {\n ...sponsorCondition,\n signature: nextSig,\n },\n },\n };\n}\n\n/** Sign a sponsored transaction as the sponsor using an account */\nexport async function signSponsorWithAccount(\n tx: StacksTransaction,\n account: LocalAccount | CustomAccount\n): Promise<StacksTransaction> {\n if (tx.auth.authType !== AuthType.Sponsored) {\n throw new Error(\"Transaction must be sponsored\");\n }\n const auth = tx.auth as SponsoredAuthorization;\n const sponsorCondition = auth.sponsorSpendingCondition as SingleSigSpendingCondition;\n const originSigHash = getOriginSigHash(tx);\n\n const sigHashPre = sigHashPreSign(\n originSigHash,\n AuthType.Sponsored,\n sponsorCondition.fee,\n sponsorCondition.nonce\n );\n\n const sigBytes = await account.sign(hexToBytes(sigHashPre));\n const nextSig = bytesToHex(sigBytes);\n\n return {\n ...tx,\n auth: {\n ...auth,\n sponsorSpendingCondition: {\n ...sponsorCondition,\n signature: nextSig,\n },\n },\n };\n}\n",
10
- "import type { StacksChain } from \"../chains/types.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport type { PostCondition } from \"../postconditions/types.ts\";\nimport type { MultiSigHashMode, SpendingCondition } from \"./types.ts\";\nimport {\n createSingleSigSpendingCondition,\n createStandardAuth,\n createSponsoredAuth,\n} from \"./authorization.ts\";\nimport { createMultiSigSpendingCondition } from \"./multisig.ts\";\nimport {\n PayloadType,\n AnchorMode,\n PostConditionModeWire,\n FungibleConditionCode,\n NonFungibleConditionCode,\n type StacksTransaction,\n type PostConditionWire,\n type PostConditionPrincipalWire,\n type ClarityVersion,\n} from \"./types.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport { intToBigInt, type IntegerType } from \"../utils/encoding.ts\";\nimport { parseContractId } from \"../utils/address.ts\";\n\ntype MultiSigOptions = {\n publicKeys?: string[];\n signaturesRequired?: number;\n hashMode?: MultiSigHashMode;\n};\n\nexport type BuildTokenTransferOptions = MultiSigOptions & {\n recipient: string;\n amount: IntegerType;\n memo?: string;\n fee: IntegerType;\n nonce: IntegerType;\n publicKey?: string;\n chain?: StacksChain;\n postConditionMode?: \"allow\" | \"deny\";\n postConditions?: PostCondition[];\n sponsored?: boolean;\n};\n\nexport type BuildContractCallOptions = MultiSigOptions & {\n contractAddress: string;\n contractName: string;\n functionName: string;\n functionArgs: ClarityValue[];\n fee: IntegerType;\n nonce: IntegerType;\n publicKey?: string;\n chain?: StacksChain;\n postConditionMode?: \"allow\" | \"deny\";\n postConditions?: PostCondition[];\n sponsored?: boolean;\n};\n\nexport type BuildContractDeployOptions = MultiSigOptions & {\n contractName: string;\n codeBody: string;\n clarityVersion?: ClarityVersion;\n fee: IntegerType;\n nonce: IntegerType;\n publicKey?: string;\n chain?: StacksChain;\n postConditionMode?: \"allow\" | \"deny\";\n postConditions?: PostCondition[];\n sponsored?: boolean;\n};\n\nfunction resolvePcMode(mode?: \"allow\" | \"deny\"): PostConditionModeWire {\n return mode === \"allow\" ? PostConditionModeWire.Allow : PostConditionModeWire.Deny;\n}\n\nfunction convertPostConditions(pcs?: PostCondition[]): PostConditionWire[] {\n if (!pcs || pcs.length === 0) return [];\n return pcs.map(convertPostCondition);\n}\n\nfunction resolvePrincipal(address: string): PostConditionPrincipalWire {\n if (address === \"origin\") return { type: \"origin\" };\n const [addr, name] = address.split(\".\");\n if (name) {\n return { type: \"contract\", address: addr!, contractName: name };\n }\n return { type: \"standard\", address: addr! };\n}\n\nconst FUNGIBLE_CODE_MAP: Record<string, number> = {\n eq: FungibleConditionCode.Equal,\n gt: FungibleConditionCode.Greater,\n gte: FungibleConditionCode.GreaterEqual,\n lt: FungibleConditionCode.Less,\n lte: FungibleConditionCode.LessEqual,\n};\n\nfunction convertPostCondition(pc: PostCondition): PostConditionWire {\n switch (pc.type) {\n case \"stx-postcondition\":\n return {\n type: \"stx\",\n principal: resolvePrincipal(pc.address),\n conditionCode: FUNGIBLE_CODE_MAP[pc.condition]!,\n amount: intToBigInt(pc.amount),\n };\n case \"ft-postcondition\": {\n const [contractId, tokenName] = pc.asset.split(\"::\");\n const [addr, name] = parseContractId(contractId!);\n return {\n type: \"ft\",\n principal: resolvePrincipal(pc.address),\n asset: { address: addr, contractName: name, assetName: tokenName! },\n conditionCode: FUNGIBLE_CODE_MAP[pc.condition]!,\n amount: intToBigInt(pc.amount),\n };\n }\n case \"nft-postcondition\": {\n const [contractId, tokenName] = pc.asset.split(\"::\");\n const [addr, name] = parseContractId(contractId!);\n return {\n type: \"nft\",\n principal: resolvePrincipal(pc.address),\n asset: { address: addr, contractName: name, assetName: tokenName! },\n conditionCode: pc.condition === \"sent\" ? NonFungibleConditionCode.Sends : NonFungibleConditionCode.DoesNotSend,\n assetId: pc.assetId,\n };\n }\n }\n}\n\nimport type { Authorization } from \"./types.ts\";\n\nfunction resolveSpendingCondition(\n opts: MultiSigOptions & { publicKey?: string },\n nonce: bigint,\n fee: bigint\n): SpendingCondition {\n if (opts.publicKeys) {\n return createMultiSigSpendingCondition(\n opts.publicKeys,\n opts.signaturesRequired!,\n nonce,\n fee,\n opts.hashMode\n );\n }\n return createSingleSigSpendingCondition(opts.publicKey!, nonce, fee);\n}\n\nfunction resolveAuth(spendingCondition: any, sponsored?: boolean): Authorization {\n return sponsored\n ? createSponsoredAuth(spendingCondition)\n : createStandardAuth(spendingCondition);\n}\n\nfunction resolveVersionAndChainId(chain?: StacksChain): { version: number; chainId: number } {\n if (!chain) return { version: 0x00, chainId: 0x00000001 }; // mainnet defaults\n return { version: chain.transactionVersion, chainId: chain.id };\n}\n\nexport function buildTokenTransfer(options: BuildTokenTransferOptions): StacksTransaction {\n const { version, chainId } = resolveVersionAndChainId(options.chain);\n const fee = intToBigInt(options.fee);\n const nonce = intToBigInt(options.nonce);\n\n const spendingCondition = resolveSpendingCondition(options, nonce, fee);\n const recipient = Cl.principal(options.recipient);\n\n const tx: StacksTransaction = {\n version,\n chainId,\n auth: resolveAuth(spendingCondition, options.sponsored),\n anchorMode: AnchorMode.Any,\n postConditionMode: resolvePcMode(options.postConditionMode),\n postConditions: convertPostConditions(options.postConditions),\n payload: {\n payloadType: PayloadType.TokenTransfer,\n recipient,\n amount: intToBigInt(options.amount),\n memo: options.memo ?? \"\",\n },\n };\n\n if (options.publicKeys) {\n (tx as any)._multisig = { publicKeys: options.publicKeys };\n }\n return tx;\n}\n\nexport function buildContractCall(options: BuildContractCallOptions): StacksTransaction {\n const { version, chainId } = resolveVersionAndChainId(options.chain);\n const fee = intToBigInt(options.fee);\n const nonce = intToBigInt(options.nonce);\n\n const spendingCondition = resolveSpendingCondition(options, nonce, fee);\n\n const tx: StacksTransaction = {\n version,\n chainId,\n auth: resolveAuth(spendingCondition, options.sponsored),\n anchorMode: AnchorMode.Any,\n postConditionMode: resolvePcMode(options.postConditionMode),\n postConditions: convertPostConditions(options.postConditions),\n payload: {\n payloadType: PayloadType.ContractCall,\n contractAddress: options.contractAddress,\n contractName: options.contractName,\n functionName: options.functionName,\n functionArgs: options.functionArgs,\n },\n };\n\n if (options.publicKeys) {\n (tx as any)._multisig = { publicKeys: options.publicKeys };\n }\n return tx;\n}\n\nexport function buildContractDeploy(options: BuildContractDeployOptions): StacksTransaction {\n const { version, chainId } = resolveVersionAndChainId(options.chain);\n const fee = intToBigInt(options.fee);\n const nonce = intToBigInt(options.nonce);\n\n const spendingCondition = resolveSpendingCondition(options, nonce, fee);\n const useVersioned = options.clarityVersion !== undefined;\n\n const tx: StacksTransaction = {\n version,\n chainId,\n auth: resolveAuth(spendingCondition, options.sponsored),\n anchorMode: AnchorMode.Any,\n postConditionMode: resolvePcMode(options.postConditionMode),\n postConditions: convertPostConditions(options.postConditions),\n payload: {\n payloadType: useVersioned ? PayloadType.VersionedSmartContract : PayloadType.SmartContract,\n clarityVersion: options.clarityVersion,\n contractName: options.contractName,\n codeBody: options.codeBody,\n },\n };\n\n if (options.publicKeys) {\n (tx as any)._multisig = { publicKeys: options.publicKeys };\n }\n return tx;\n}\n"
11
- ],
12
- "mappings": ";AAGO,IAAM,WAAW;AAAA,EACtB,UAAU;AAAA,EACV,WAAW;AACb;AAIO,IAAM,cAAc;AAAA,EACzB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,cAAc;AAAA,EACd,kBAAkB;AACpB;AAIO,IAAM,iBAAiB;AAAA,EAC5B,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACZ;AAIO,IAAM,aAAa;AAAA,EACxB,aAAa;AAAA,EACb,cAAc;AAAA,EACd,KAAK;AACP;AAIO,IAAM,wBAAwB;AAAA,EACnC,OAAO;AAAA,EACP,MAAM;AACR;AAKO,IAAM,k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AAA,MAC7E,gBAAgB,QAAQ;AAAA,MACxB,cAAc,QAAQ;AAAA,MACtB,UAAU,QAAQ;AAAA,IACpB;AAAA,EACF;AAAA,EAEA,IAAI,QAAQ,YAAY;AAAA,IACrB,GAAW,YAAY,EAAE,YAAY,QAAQ,WAAW;AAAA,EAC3D;AAAA,EACA,OAAO;AAAA;",
13
- "debugId": "1CF070DAB537370664756E2164756E21",
14
- "names": []
15
- }
@@ -1,15 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/transactions/types.ts", "../src/transactions/wire/serialize.ts", "../src/transactions/authorization.ts", "../src/transactions/multisig.ts", "../src/transactions/signer.ts", "../src/transactions/build.ts"],
4
- "sourcesContent": [
5
- "import type { ClarityValue } from \"../clarity/types.ts\";\n\n// Auth types\nexport const AuthType = {\n Standard: 0x04,\n Sponsored: 0x05,\n} as const;\nexport type AuthType = (typeof AuthType)[keyof typeof AuthType];\n\n// Payload types\nexport const PayloadType = {\n TokenTransfer: 0x00,\n SmartContract: 0x01,\n ContractCall: 0x02,\n PoisonMicroblock: 0x03,\n Coinbase: 0x04,\n CoinbaseToAltRecipient: 0x05,\n VersionedSmartContract: 0x06,\n TenureChange: 0x07,\n NakamotoCoinbase: 0x08,\n} as const;\nexport type PayloadType = (typeof PayloadType)[keyof typeof PayloadType];\n\n// Clarity version\nexport const ClarityVersion = {\n Clarity1: 1,\n Clarity2: 2,\n Clarity3: 3,\n Clarity4: 4,\n Clarity5: 5,\n} as const;\nexport type ClarityVersion = (typeof ClarityVersion)[keyof typeof ClarityVersion];\n\n// Anchor mode (deprecated post-Nakamoto, but needed for wire format)\nexport const AnchorMode = {\n OnChainOnly: 0x01,\n OffChainOnly: 0x02,\n Any: 0x03,\n} as const;\nexport type AnchorMode = (typeof AnchorMode)[keyof typeof AnchorMode];\n\n// Post condition mode\nexport const PostConditionModeWire = {\n Allow: 0x01,\n Deny: 0x02,\n} as const;\nexport type PostConditionModeWire =\n (typeof PostConditionModeWire)[keyof typeof PostConditionModeWire];\n\n// Address hash modes\nexport const AddressHashMode = {\n P2PKH: 0x00,\n P2SH: 0x01,\n P2WPKH: 0x02,\n P2WSH: 0x03,\n P2SH_NonSequential: 0x05, // SIP-027\n P2WSH_P2SH_NonSequential: 0x07, // SIP-027\n} as const;\nexport type AddressHashMode = (typeof AddressHashMode)[keyof typeof AddressHashMode];\n\n// Pub key encoding\nexport const PubKeyEncoding = {\n Compressed: 0x00,\n Uncompressed: 0x01,\n} as const;\nexport type PubKeyEncoding = (typeof PubKeyEncoding)[keyof typeof PubKeyEncoding];\n\n// Fungible condition codes (wire format)\nexport const FungibleConditionCode = {\n Equal: 0x01,\n Greater: 0x02,\n GreaterEqual: 0x03,\n Less: 0x04,\n LessEqual: 0x05,\n} as const;\n\n// Non-fungible condition codes (wire format)\nexport const NonFungibleConditionCode = {\n Sends: 0x10,\n DoesNotSend: 0x11,\n} as const;\n\n// Post condition principal types\nexport const PostConditionPrincipalId = {\n Origin: 0x01,\n Standard: 0x02,\n Contract: 0x03,\n} as const;\n\n// Post condition asset types\nexport const AssetType = {\n STX: 0x00,\n Fungible: 0x01,\n NonFungible: 0x02,\n} as const;\n\n// Auth field types\nexport const AuthFieldType = {\n PublicKeyCompressed: 0x00,\n PublicKeyUncompressed: 0x01,\n SignatureCompressed: 0x02,\n SignatureUncompressed: 0x03,\n} as const;\n\nexport const RECOVERABLE_ECDSA_SIG_LENGTH_BYTES = 65;\nexport const MEMO_MAX_LENGTH_BYTES = 34;\nexport const MAX_STRING_LENGTH_BYTES = 128;\nexport const COINBASE_BYTES_LENGTH = 32;\nexport const VRF_PROOF_BYTES_LENGTH = 80;\nexport const MICROBLOCK_HEADER_BYTES_LENGTH = 132; // 1 + 2 + 32 + 32 + 65\n\n// Tenure change cause\nexport const TenureChangeCause = {\n BlockFound: 0x00,\n Extended: 0x01,\n ExtendedRuntime: 0x02,\n ExtendedReadCount: 0x03,\n ExtendedReadLength: 0x04,\n ExtendedWriteCount: 0x05,\n ExtendedWriteLength: 0x06,\n} as const;\nexport type TenureChangeCause = (typeof TenureChangeCause)[keyof typeof TenureChangeCause];\n\n// Token transfer payload\nexport type TokenTransferPayload = {\n payloadType: typeof PayloadType.TokenTransfer;\n recipient: ClarityValue; // PrincipalCV\n amount: bigint;\n memo: string;\n};\n\n// Contract call payload\nexport type ContractCallPayload = {\n payloadType: typeof PayloadType.ContractCall;\n contractAddress: string;\n contractName: string;\n functionName: string;\n functionArgs: ClarityValue[];\n};\n\n// Smart contract deploy payload\nexport type SmartContractPayload = {\n payloadType: typeof PayloadType.SmartContract | typeof PayloadType.VersionedSmartContract;\n clarityVersion?: ClarityVersion;\n contractName: string;\n codeBody: string;\n};\n\n// Coinbase payload (appears in every pre-Nakamoto block)\nexport type CoinbasePayload = {\n payloadType: typeof PayloadType.Coinbase;\n coinbaseBuffer: string; // 32 bytes hex\n};\n\n// Coinbase to alt recipient payload\nexport type CoinbaseToAltRecipientPayload = {\n payloadType: typeof PayloadType.CoinbaseToAltRecipient;\n coinbaseBuffer: string; // 32 bytes hex\n recipient: ClarityValue; // PrincipalCV\n};\n\n// Poison microblock payload\nexport type PoisonMicroblockPayload = {\n payloadType: typeof PayloadType.PoisonMicroblock;\n header1: string; // 132 bytes hex (raw microblock header)\n header2: string; // 132 bytes hex (raw microblock header)\n};\n\n// Tenure change payload (Nakamoto)\nexport type TenureChangePayload = {\n payloadType: typeof PayloadType.TenureChange;\n tenureConsensusHash: string; // 20 bytes hex\n prevTenureConsensusHash: string; // 20 bytes hex\n burnViewConsensusHash: string; // 20 bytes hex\n previousTenureEnd: string; // 32 bytes hex\n previousTenureBlocks: number; // u32\n cause: TenureChangeCause;\n pubkeyHash: string; // 20 bytes hex\n};\n\n// Nakamoto coinbase payload\nexport type NakamotoCoinbasePayload = {\n payloadType: typeof PayloadType.NakamotoCoinbase;\n coinbaseBuffer: string; // 32 bytes hex\n recipient: ClarityValue | null; // Optional PrincipalCV\n vrfProof: string; // 80 bytes hex\n};\n\nexport type TransactionPayload =\n | TokenTransferPayload\n | ContractCallPayload\n | SmartContractPayload\n | CoinbasePayload\n | CoinbaseToAltRecipientPayload\n | PoisonMicroblockPayload\n | TenureChangePayload\n | NakamotoCoinbasePayload;\n\n// Spending condition\nexport type SingleSigSpendingCondition = {\n hashMode: typeof AddressHashMode.P2PKH | typeof AddressHashMode.P2WPKH;\n signer: string; // hash160 hex\n nonce: bigint;\n fee: bigint;\n keyEncoding: PubKeyEncoding;\n signature: string; // 65-byte recoverable sig hex\n};\n\nexport type TransactionAuthField = {\n pubKeyEncoding: PubKeyEncoding;\n type: \"publicKey\" | \"signature\";\n data: string; // hex\n};\n\nexport type MultiSigHashMode =\n | typeof AddressHashMode.P2SH\n | typeof AddressHashMode.P2WSH\n | typeof AddressHashMode.P2SH_NonSequential\n | typeof AddressHashMode.P2WSH_P2SH_NonSequential;\n\nexport type MultiSigSpendingCondition = {\n hashMode: MultiSigHashMode;\n signer: string;\n nonce: bigint;\n fee: bigint;\n fields: TransactionAuthField[];\n signaturesRequired: number;\n};\n\nexport type SpendingCondition = SingleSigSpendingCondition | MultiSigSpendingCondition;\n\nexport type StandardAuthorization = {\n authType: typeof AuthType.Standard;\n spendingCondition: SpendingCondition;\n};\n\nexport type SponsoredAuthorization = {\n authType: typeof AuthType.Sponsored;\n spendingCondition: SpendingCondition;\n sponsorSpendingCondition: SpendingCondition;\n};\n\nexport type Authorization = StandardAuthorization | SponsoredAuthorization;\n\n// Full transaction\nexport type StacksTransaction = {\n version: number;\n chainId: number;\n auth: Authorization;\n anchorMode: AnchorMode;\n postConditionMode: PostConditionModeWire;\n postConditions: PostConditionWire[];\n payload: TransactionPayload;\n};\n\n// Wire post condition types\nexport type PostConditionWire = StxPostConditionWire | FtPostConditionWire | NftPostConditionWire;\n\nexport type StxPostConditionWire = {\n type: \"stx\";\n principal: PostConditionPrincipalWire;\n conditionCode: number;\n amount: bigint;\n};\n\nexport type FtPostConditionWire = {\n type: \"ft\";\n principal: PostConditionPrincipalWire;\n asset: AssetInfoWire;\n conditionCode: number;\n amount: bigint;\n};\n\nexport type NftPostConditionWire = {\n type: \"nft\";\n principal: PostConditionPrincipalWire;\n asset: AssetInfoWire;\n conditionCode: number;\n assetId: ClarityValue;\n};\n\nexport type PostConditionPrincipalWire =\n | { type: \"origin\" }\n | { type: \"standard\"; address: string }\n | { type: \"contract\"; address: string; contractName: string };\n\nexport type AssetInfoWire = {\n address: string;\n contractName: string;\n assetName: string;\n};\n",
6
- "import {\n bytesToHex,\n hexToBytes,\n concatBytes,\n intToBytes,\n intToHex,\n utf8ToBytes,\n asciiToBytes,\n writeUInt32BE,\n writeUInt16BE,\n writeUInt8,\n} from \"../../utils/encoding.ts\";\nimport { c32addressDecode } from \"../../utils/c32.ts\";\nimport { serializeCVBytes } from \"../../clarity/serialize.ts\";\nimport {\n AuthType,\n PayloadType,\n PostConditionPrincipalId,\n AssetType,\n MEMO_MAX_LENGTH_BYTES,\n type StacksTransaction,\n type Authorization,\n type SpendingCondition,\n type SingleSigSpendingCondition,\n type MultiSigSpendingCondition,\n type TransactionPayload,\n type PostConditionWire,\n type PostConditionPrincipalWire,\n type AssetInfoWire,\n type TransactionAuthField,\n type CoinbasePayload,\n type CoinbaseToAltRecipientPayload,\n type PoisonMicroblockPayload,\n type TenureChangePayload as TenureChangePayloadType,\n type NakamotoCoinbasePayload,\n} from \"../types.ts\";\n\n// Address serialization: version (1 byte) + hash160 (20 bytes)\nfunction serializeAddress(c32Address: string): Uint8Array {\n const [version, hash160] = c32addressDecode(c32Address);\n return concatBytes(new Uint8Array([version]), hexToBytes(hash160));\n}\n\n// LP string: length prefix (n bytes) + content bytes\nfunction serializeLPString(str: string, prefixBytes = 1): Uint8Array {\n const content = utf8ToBytes(str);\n const prefix = hexToBytes(intToHex(content.byteLength, prefixBytes));\n return concatBytes(prefix, content);\n}\n\n// LP string for code body (4-byte prefix)\nfunction serializeLPStringLong(str: string): Uint8Array {\n return serializeLPString(str, 4);\n}\n\n// Memo: flat 34-byte field (no length prefix) per SIP-005\nfunction serializeMemo(memo: string): Uint8Array {\n const content = asciiToBytes(memo);\n const padded = new Uint8Array(MEMO_MAX_LENGTH_BYTES);\n padded.set(content.slice(0, MEMO_MAX_LENGTH_BYTES));\n return padded;\n}\n\nfunction serializeSpendingCondition(condition: SpendingCondition): Uint8Array {\n const parts: Uint8Array[] = [\n writeUInt8(condition.hashMode),\n hexToBytes(condition.signer), // 20 bytes\n intToBytes(condition.nonce, 8),\n intToBytes(condition.fee, 8),\n ];\n\n if (\"signature\" in condition) {\n // Single sig\n const sc = condition as SingleSigSpendingCondition;\n parts.push(writeUInt8(sc.keyEncoding));\n parts.push(hexToBytes(sc.signature)); // 65 bytes\n } else {\n // Multi sig\n const mc = condition as MultiSigSpendingCondition;\n // Fields as LP list\n parts.push(writeUInt32BE(mc.fields.length));\n for (const field of mc.fields) {\n parts.push(serializeAuthField(field));\n }\n parts.push(writeUInt16BE(mc.signaturesRequired));\n }\n\n return concatBytes(...parts);\n}\n\nfunction serializeAuthField(field: TransactionAuthField): Uint8Array {\n if (field.type === \"publicKey\") {\n const typeId = field.pubKeyEncoding === 0x00 ? 0x00 : 0x01;\n return concatBytes(writeUInt8(typeId), hexToBytes(field.data));\n } else {\n const typeId = field.pubKeyEncoding === 0x00 ? 0x02 : 0x03;\n return concatBytes(writeUInt8(typeId), hexToBytes(field.data));\n }\n}\n\nfunction serializeAuthorization(auth: Authorization): Uint8Array {\n const parts: Uint8Array[] = [writeUInt8(auth.authType)];\n parts.push(serializeSpendingCondition(auth.spendingCondition));\n if (auth.authType === AuthType.Sponsored) {\n parts.push(serializeSpendingCondition(auth.sponsorSpendingCondition));\n }\n return concatBytes(...parts);\n}\n\nfunction serializePrincipal(principal: PostConditionPrincipalWire): Uint8Array {\n switch (principal.type) {\n case \"origin\":\n return writeUInt8(PostConditionPrincipalId.Origin);\n case \"standard\":\n return concatBytes(\n writeUInt8(PostConditionPrincipalId.Standard),\n serializeAddress(principal.address)\n );\n case \"contract\":\n return concatBytes(\n writeUInt8(PostConditionPrincipalId.Contract),\n serializeAddress(principal.address),\n serializeLPString(principal.contractName)\n );\n }\n}\n\nfunction serializeAssetInfo(asset: AssetInfoWire): Uint8Array {\n return concatBytes(\n serializeAddress(asset.address),\n serializeLPString(asset.contractName),\n serializeLPString(asset.assetName)\n );\n}\n\nfunction serializePostCondition(pc: PostConditionWire): Uint8Array {\n // Wire order: asset_type first, then principal (per SIP-005)\n const parts: Uint8Array[] = [];\n\n switch (pc.type) {\n case \"stx\":\n parts.push(writeUInt8(AssetType.STX));\n parts.push(serializePrincipal(pc.principal));\n parts.push(writeUInt8(pc.conditionCode));\n parts.push(intToBytes(pc.amount, 8));\n break;\n case \"ft\":\n parts.push(writeUInt8(AssetType.Fungible));\n parts.push(serializePrincipal(pc.principal));\n parts.push(serializeAssetInfo(pc.asset));\n parts.push(writeUInt8(pc.conditionCode));\n parts.push(intToBytes(pc.amount, 8));\n break;\n case \"nft\":\n parts.push(writeUInt8(AssetType.NonFungible));\n parts.push(serializePrincipal(pc.principal));\n parts.push(serializeAssetInfo(pc.asset));\n parts.push(serializeCVBytes(pc.assetId));\n parts.push(writeUInt8(pc.conditionCode));\n break;\n }\n\n return concatBytes(...parts);\n}\n\nfunction serializePostConditions(pcs: PostConditionWire[]): Uint8Array {\n const parts: Uint8Array[] = [writeUInt32BE(pcs.length)];\n for (const pc of pcs) {\n parts.push(serializePostCondition(pc));\n }\n return concatBytes(...parts);\n}\n\nexport function serializePayload(payload: TransactionPayload): Uint8Array {\n const parts: Uint8Array[] = [writeUInt8(payload.payloadType)];\n\n switch (payload.payloadType) {\n case PayloadType.TokenTransfer:\n parts.push(serializeCVBytes(payload.recipient));\n parts.push(intToBytes(payload.amount, 8));\n parts.push(serializeMemo(payload.memo));\n break;\n\n case PayloadType.ContractCall:\n parts.push(serializeAddress(payload.contractAddress));\n parts.push(serializeLPString(payload.contractName));\n parts.push(serializeLPString(payload.functionName));\n parts.push(writeUInt32BE(payload.functionArgs.length));\n for (const arg of payload.functionArgs) {\n parts.push(serializeCVBytes(arg));\n }\n break;\n\n case PayloadType.SmartContract:\n parts.push(serializeLPString(payload.contractName));\n parts.push(serializeLPStringLong(payload.codeBody));\n break;\n\n case PayloadType.VersionedSmartContract:\n parts.push(writeUInt8(payload.clarityVersion ?? 2));\n parts.push(serializeLPString(payload.contractName));\n parts.push(serializeLPStringLong(payload.codeBody));\n break;\n\n case PayloadType.Coinbase:\n parts.push(hexToBytes((payload as CoinbasePayload).coinbaseBuffer));\n break;\n\n case PayloadType.CoinbaseToAltRecipient: {\n const cbAlt = payload as CoinbaseToAltRecipientPayload;\n parts.push(hexToBytes(cbAlt.coinbaseBuffer));\n parts.push(serializeCVBytes(cbAlt.recipient));\n break;\n }\n\n case PayloadType.PoisonMicroblock: {\n const pm = payload as PoisonMicroblockPayload;\n parts.push(hexToBytes(pm.header1));\n parts.push(hexToBytes(pm.header2));\n break;\n }\n\n case PayloadType.TenureChange: {\n const tc = payload as TenureChangePayloadType;\n parts.push(hexToBytes(tc.tenureConsensusHash));\n parts.push(hexToBytes(tc.prevTenureConsensusHash));\n parts.push(hexToBytes(tc.burnViewConsensusHash));\n parts.push(hexToBytes(tc.previousTenureEnd));\n parts.push(writeUInt32BE(tc.previousTenureBlocks));\n parts.push(writeUInt8(tc.cause));\n parts.push(hexToBytes(tc.pubkeyHash));\n break;\n }\n\n case PayloadType.NakamotoCoinbase: {\n const nc = payload as NakamotoCoinbasePayload;\n parts.push(hexToBytes(nc.coinbaseBuffer));\n if (nc.recipient) {\n parts.push(serializeCVBytes({ type: \"some\", value: nc.recipient }));\n } else {\n parts.push(serializeCVBytes({ type: \"none\" }));\n }\n parts.push(hexToBytes(nc.vrfProof));\n break;\n }\n }\n\n return concatBytes(...parts);\n}\n\nexport function serializeTransaction(tx: StacksTransaction): Uint8Array {\n return concatBytes(\n writeUInt8(tx.version),\n writeUInt32BE(tx.chainId),\n serializeAuthorization(tx.auth),\n writeUInt8(tx.anchorMode),\n writeUInt8(tx.postConditionMode),\n serializePostConditions(tx.postConditions),\n serializePayload(tx.payload)\n );\n}\n\nexport function serializeTransactionHex(tx: StacksTransaction): string {\n return bytesToHex(serializeTransaction(tx));\n}\n",
7
- "import {\n getPublicKey as nobleGetPublicKey,\n sign,\n etc,\n} from \"@noble/secp256k1\";\nimport { hmac } from \"@noble/hashes/hmac.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport {\n bytesToHex,\n hexToBytes,\n intToBytes,\n intToHex,\n concatBytes,\n} from \"../utils/encoding.ts\";\nimport { hashP2PKH, txidFromBytes } from \"../utils/hash.ts\";\nimport {\n AuthType,\n AddressHashMode,\n PubKeyEncoding,\n RECOVERABLE_ECDSA_SIG_LENGTH_BYTES,\n type SingleSigSpendingCondition,\n type SpendingCondition,\n type Authorization,\n type StandardAuthorization,\n type SponsoredAuthorization,\n} from \"./types.ts\";\n\n// Ensure sync signing is available\netc.hmacSha256Sync = (key: Uint8Array, ...msgs: Uint8Array[]) => {\n const h = hmac.create(sha256, key);\n msgs.forEach((msg) => h.update(msg));\n return h.digest();\n};\n\nconst EMPTY_SIG = bytesToHex(new Uint8Array(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES));\n\nexport function createSingleSigSpendingCondition(\n publicKey: string,\n nonce: bigint,\n fee: bigint\n): SingleSigSpendingCondition {\n const pubKeyBytes = hexToBytes(publicKey);\n const signer = hashP2PKH(pubKeyBytes);\n const isCompressed = pubKeyBytes.length === 33;\n\n return {\n hashMode: AddressHashMode.P2PKH,\n signer,\n nonce,\n fee,\n keyEncoding: isCompressed ? PubKeyEncoding.Compressed : PubKeyEncoding.Uncompressed,\n signature: EMPTY_SIG,\n };\n}\n\nexport function createStandardAuth(\n spendingCondition: SpendingCondition\n): StandardAuthorization {\n return { authType: AuthType.Standard, spendingCondition };\n}\n\nexport function createSponsoredAuth(\n spendingCondition: SpendingCondition,\n sponsorSpendingCondition?: SpendingCondition\n): SponsoredAuthorization {\n return {\n authType: AuthType.Sponsored,\n spendingCondition,\n sponsorSpendingCondition: sponsorSpendingCondition ?? createSingleSigSpendingCondition(\n \"0\".repeat(66),\n 0n,\n 0n\n ),\n };\n}\n\nfunction clearCondition(condition: SpendingCondition): SpendingCondition {\n if (\"signature\" in condition) {\n return {\n ...condition,\n nonce: 0n,\n fee: 0n,\n signature: EMPTY_SIG,\n };\n }\n return {\n ...condition,\n nonce: 0n,\n fee: 0n,\n fields: [],\n };\n}\n\nexport function intoInitialSighashAuth(auth: Authorization): Authorization {\n if (auth.authType === AuthType.Standard) {\n return createStandardAuth(clearCondition(auth.spendingCondition));\n }\n return createSponsoredAuth(\n clearCondition(auth.spendingCondition),\n clearCondition(createSingleSigSpendingCondition(\"0\".repeat(66), 0n, 0n))\n );\n}\n\n/** Compute pre-sign sighash = sha512/256(prevSigHash + authType + fee + nonce) */\nexport function sigHashPreSign(\n curSigHash: string,\n authType: number,\n fee: bigint,\n nonce: bigint\n): string {\n const data = concatBytes(\n hexToBytes(curSigHash),\n new Uint8Array([authType]),\n intToBytes(fee, 8),\n intToBytes(nonce, 8)\n );\n return txidFromBytes(data);\n}\n\n/** Compute post-sign sighash = sha512/256(preSigHash + pubKeyEncoding + signature) */\nexport function sigHashPostSign(\n curSigHash: string,\n pubKeyEncoding: number,\n signature: string\n): string {\n const data = concatBytes(\n hexToBytes(curSigHash),\n new Uint8Array([pubKeyEncoding]),\n hexToBytes(signature)\n );\n return txidFromBytes(data);\n}\n\n/** Sign with private key and return VRS signature (recoveryId + r + s) */\nfunction signWithKey(privateKey: string, messageHash: string): string {\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const sig = sign(messageHash, keyBytes, { lowS: true });\n const recoveryIdHex = intToHex(sig.recovery, 1);\n return recoveryIdHex + sig.toCompactHex();\n}\n\nexport function nextSignature(\n curSigHash: string,\n authType: number,\n fee: bigint,\n nonce: bigint,\n privateKey: string\n): { nextSig: string; nextSigHash: string } {\n const sigHashPre = sigHashPreSign(curSigHash, authType, fee, nonce);\n\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const pubKey = nobleGetPublicKey(keyBytes, true);\n const isCompressed = pubKey.length === 33;\n const pubKeyEncoding = isCompressed\n ? PubKeyEncoding.Compressed\n : PubKeyEncoding.Uncompressed;\n\n const nextSig = signWithKey(privateKey, sigHashPre);\n const nextSigHash = sigHashPostSign(sigHashPre, pubKeyEncoding, nextSig);\n\n return { nextSig, nextSigHash };\n}\n",
8
- "import {\n getPublicKey as nobleGetPublicKey,\n sign as nobleSign,\n} from \"@noble/secp256k1\";\nimport { c32address } from \"../utils/c32.ts\";\nimport { bytesToHex, hexToBytes, intToHex, concatBytes } from \"../utils/encoding.ts\";\nimport { hash160 } from \"../utils/hash.ts\";\nimport {\n sigHashPreSign,\n sigHashPostSign,\n intoInitialSighashAuth,\n nextSignature,\n} from \"./authorization.ts\";\nimport { txidFromBytes } from \"../utils/hash.ts\";\nimport { serializeTransaction } from \"./wire/serialize.ts\";\nimport {\n AuthType,\n AddressHashMode,\n PubKeyEncoding,\n type MultiSigSpendingCondition,\n type MultiSigHashMode,\n type TransactionAuthField,\n type StacksTransaction,\n} from \"./types.ts\";\nimport type { StacksChain } from \"../chains/types.ts\";\nimport type { LocalAccount, CustomAccount } from \"../accounts/types.ts\";\n\n// OP codes for redeem script\nconst OP_CHECKMULTISIG = 0xae;\n\n/** Check if hash mode is non-sequential (SIP-027) */\nexport function isNonSequential(hashMode: number): boolean {\n return (hashMode & 0x04) !== 0;\n}\n\n/** Build a Bitcoin-style redeem script for m-of-n multi-sig */\nfunction makeRedeemScript(publicKeys: string[], signaturesRequired: number): Uint8Array {\n const parts: Uint8Array[] = [];\n parts.push(new Uint8Array([0x50 + signaturesRequired])); // OP_n\n for (const pk of publicKeys) {\n const pkBytes = hexToBytes(pk);\n parts.push(new Uint8Array([pkBytes.length])); // length prefix (0x21 for compressed)\n parts.push(pkBytes);\n }\n parts.push(new Uint8Array([0x50 + publicKeys.length])); // OP_m\n parts.push(new Uint8Array([OP_CHECKMULTISIG]));\n return concatBytes(...parts);\n}\n\n/** Derive a multi-sig address from public keys */\nexport function makeMultiSigAddress(\n publicKeys: string[],\n signaturesRequired: number,\n chain?: StacksChain\n): string {\n if (signaturesRequired < 1 || signaturesRequired > publicKeys.length) {\n throw new Error(`signaturesRequired must be between 1 and ${publicKeys.length}`);\n }\n const redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n const signer = hash160(redeemScript);\n const version = chain?.addressVersion?.multiSig ?? 20; // mainnet default\n return c32address(version, bytesToHex(signer));\n}\n\n/** Create an empty multi-sig spending condition */\nexport function createMultiSigSpendingCondition(\n publicKeys: string[],\n signaturesRequired: number,\n nonce: bigint,\n fee: bigint,\n hashMode: MultiSigHashMode = AddressHashMode.P2SH\n): MultiSigSpendingCondition {\n const redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n const signer = bytesToHex(hash160(redeemScript));\n\n return {\n hashMode,\n signer,\n nonce,\n fee,\n fields: [],\n signaturesRequired,\n };\n}\n\n/** Compute the initial sighash for a transaction (same as signBegin) */\nfunction initialSigHash(tx: StacksTransaction): string {\n const cleared: StacksTransaction = {\n ...tx,\n auth: intoInitialSighashAuth(tx.auth),\n };\n return txidFromBytes(serializeTransaction(cleared));\n}\n\n/** Compute the presign-sighash used by all non-sequential signers */\nfunction nonSequentialPreSignHash(tx: StacksTransaction): string {\n const condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n const initHash = initialSigHash(tx);\n return sigHashPreSign(initHash, AuthType.Standard, condition.fee, condition.nonce);\n}\n\n/** Replay sighash through existing auth fields of a multi-sig tx */\nexport function replayMultiSigSigHash(tx: StacksTransaction): string {\n const condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n // Non-sequential: all signers sign the same presign-sighash, no field chaining\n if (isNonSequential(condition.hashMode)) {\n const preSign = nonSequentialPreSignHash(tx);\n // Chain through all fields to get the final sighash\n let curSigHash = preSign;\n for (const field of condition.fields) {\n curSigHash = sigHashPostSign(curSigHash, field.pubKeyEncoding, field.data);\n }\n return curSigHash;\n }\n\n // Sequential: chain through all fields\n let curSigHash = initialSigHash(tx);\n for (const field of condition.fields) {\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n }\n return curSigHash;\n}\n\n/** Sign one position of a multi-sig transaction with a private key */\nexport function signMultiSig(\n tx: StacksTransaction,\n privateKey: string,\n publicKeys: string[]\n): StacksTransaction {\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const signerPubKey = bytesToHex(nobleGetPublicKey(keyBytes, true));\n\n const signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n if (signerIndex === -1) {\n throw new Error(\"Private key does not correspond to any signer in the multi-sig\");\n }\n\n const condition = { ...(tx.auth.spendingCondition as MultiSigSpendingCondition) };\n\n // Non-sequential: all signers sign the same presign-sighash independently\n if (isNonSequential(condition.hashMode)) {\n return signNonSequential(tx, condition, privateKey);\n }\n\n // Sequential: existing P2SH behavior\n return signSequential(tx, condition, privateKey, publicKeys, signerIndex);\n}\n\n/** Non-sequential signing: compute presign-sighash from initial tx, sign, append */\nfunction signNonSequential(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n privateKey: string\n): StacksTransaction {\n const fields = [...condition.fields];\n const preSignHash = nonSequentialPreSignHash(tx);\n\n // Sign the presign-sighash directly\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const sig = nobleSign(preSignHash, keyBytes, { lowS: true });\n const recoveryIdHex = intToHex(sig.recovery, 1);\n const nextSig = recoveryIdHex + sig.toCompactHex();\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n const sigCount = fields.filter((f) => f.type === \"signature\").length;\n\n // Auto-finalize: non-sequential needs no pubkey gap-filling\n if (sigCount >= condition.signaturesRequired) {\n return {\n ...tx,\n auth: { ...tx.auth, spendingCondition: newCondition },\n };\n }\n\n return {\n ...tx,\n auth: { ...tx.auth, spendingCondition: newCondition },\n };\n}\n\n/** Sequential signing: existing P2SH behavior */\nfunction signSequential(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n privateKey: string,\n publicKeys: string[],\n signerIndex: number\n): StacksTransaction {\n const fields = [...condition.fields];\n\n // Replay sighash through existing fields\n let curSigHash = initialSigHash(tx);\n for (const field of fields) {\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n }\n\n // Fill intervening positions with pubkey fields\n for (let i = fields.length; i < signerIndex; i++) {\n const pubKeyField: TransactionAuthField = {\n type: \"publicKey\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: publicKeys[i]!,\n };\n fields.push(pubKeyField);\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, pubKeyField.pubKeyEncoding, pubKeyField.data);\n }\n\n // Sign at signerIndex\n const { nextSig, nextSigHash } = nextSignature(\n curSigHash,\n AuthType.Standard,\n condition.fee,\n condition.nonce,\n privateKey\n );\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n curSigHash = nextSigHash;\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n // Count signatures so far\n const sigCount = fields.filter((f) => f.type === \"signature\").length;\n let finalCondition = newCondition;\n\n // Auto-finalize if enough signatures collected\n if (sigCount >= condition.signaturesRequired) {\n finalCondition = finalizeMultiSigCondition(newCondition, publicKeys, curSigHash);\n }\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: finalCondition,\n },\n };\n}\n\n/** Sign one position of a multi-sig transaction with an account */\nexport async function signMultiSigWithAccount(\n tx: StacksTransaction,\n account: LocalAccount | CustomAccount,\n publicKeys: string[]\n): Promise<StacksTransaction> {\n const signerPubKey = account.publicKey;\n\n const signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n if (signerIndex === -1) {\n throw new Error(\"Account does not correspond to any signer in the multi-sig\");\n }\n\n const condition = { ...(tx.auth.spendingCondition as MultiSigSpendingCondition) };\n\n // Non-sequential: all signers sign the same presign-sighash independently\n if (isNonSequential(condition.hashMode)) {\n return signNonSequentialWithAccount(tx, condition, account);\n }\n\n // Sequential: existing behavior\n return signSequentialWithAccount(tx, condition, account, publicKeys, signerIndex);\n}\n\n/** Non-sequential signing with account */\nasync function signNonSequentialWithAccount(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n account: LocalAccount | CustomAccount\n): Promise<StacksTransaction> {\n const fields = [...condition.fields];\n const preSignHash = nonSequentialPreSignHash(tx);\n\n const sigBytes = await account.sign(hexToBytes(preSignHash));\n const nextSig = bytesToHex(sigBytes);\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n return {\n ...tx,\n auth: { ...tx.auth, spendingCondition: newCondition },\n };\n}\n\n/** Sequential signing with account */\nasync function signSequentialWithAccount(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n account: LocalAccount | CustomAccount,\n publicKeys: string[],\n signerIndex: number\n): Promise<StacksTransaction> {\n const fields = [...condition.fields];\n\n // Replay sighash through existing fields\n let curSigHash = initialSigHash(tx);\n for (const field of fields) {\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n }\n\n // Fill intervening positions with pubkey fields\n for (let i = fields.length; i < signerIndex; i++) {\n const pubKeyField: TransactionAuthField = {\n type: \"publicKey\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: publicKeys[i]!,\n };\n fields.push(pubKeyField);\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, pubKeyField.pubKeyEncoding, pubKeyField.data);\n }\n\n // Sign at signerIndex\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n const sigBytes = await account.sign(hexToBytes(preSign));\n const nextSig = bytesToHex(sigBytes);\n const nextSigHash = sigHashPostSign(preSign, PubKeyEncoding.Compressed, nextSig);\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n curSigHash = nextSigHash;\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n // Count signatures so far\n const sigCount = fields.filter((f) => f.type === \"signature\").length;\n let finalCondition = newCondition;\n\n // Auto-finalize if enough signatures collected\n if (sigCount >= condition.signaturesRequired) {\n finalCondition = finalizeMultiSigCondition(newCondition, publicKeys, curSigHash);\n }\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: finalCondition,\n },\n };\n}\n\n/** Fill remaining slots with pubkey fields after all signatures are collected */\nexport function finalizeMultiSig(\n tx: StacksTransaction,\n publicKeys: string[]\n): StacksTransaction {\n const condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n // Non-sequential: no pubkey gap-filling needed\n if (isNonSequential(condition.hashMode)) {\n return tx;\n }\n\n const curSigHash = replayMultiSigSigHash(tx);\n const finalCondition = finalizeMultiSigCondition(condition, publicKeys, curSigHash);\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: finalCondition,\n },\n };\n}\n\n/** Internal: finalize remaining pubkey slots (sequential only) */\nfunction finalizeMultiSigCondition(\n condition: MultiSigSpendingCondition,\n publicKeys: string[],\n curSigHash: string\n): MultiSigSpendingCondition {\n const fields = [...condition.fields];\n let sigHash = curSigHash;\n\n // Fill remaining positions\n for (let i = fields.length; i < publicKeys.length; i++) {\n const pubKeyField: TransactionAuthField = {\n type: \"publicKey\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: publicKeys[i]!,\n };\n fields.push(pubKeyField);\n const preSign = sigHashPreSign(sigHash, AuthType.Standard, condition.fee, condition.nonce);\n sigHash = sigHashPostSign(preSign, pubKeyField.pubKeyEncoding, pubKeyField.data);\n }\n\n return { ...condition, fields };\n}\n\n/** Combine independently-signed non-sequential multi-sig transactions */\nexport function combineMultiSigSignatures(\n baseTx: StacksTransaction,\n signedTxs: StacksTransaction[]\n): StacksTransaction {\n const condition = baseTx.auth.spendingCondition as MultiSigSpendingCondition;\n\n if (!isNonSequential(condition.hashMode)) {\n throw new Error(\"combineMultiSigSignatures only works with non-sequential hash modes (SIP-027)\");\n }\n\n // Collect all signature fields from each signed tx\n const seenSigs = new Set<string>();\n const signatures: TransactionAuthField[] = [];\n\n for (const stx of signedTxs) {\n const stxCondition = stx.auth.spendingCondition as MultiSigSpendingCondition;\n for (const field of stxCondition.fields) {\n if (field.type === \"signature\" && !seenSigs.has(field.data)) {\n seenSigs.add(field.data);\n signatures.push(field);\n }\n }\n }\n\n if (signatures.length === 0) {\n throw new Error(\"No signatures found in the provided transactions\");\n }\n\n const newCondition: MultiSigSpendingCondition = {\n ...condition,\n fields: signatures,\n };\n\n return {\n ...baseTx,\n auth: { ...baseTx.auth, spendingCondition: newCondition },\n };\n}\n",
9
- "import { bytesToHex, hexToBytes } from \"../utils/encoding.ts\";\nimport { txidFromBytes } from \"../utils/hash.ts\";\nimport {\n intoInitialSighashAuth,\n nextSignature,\n sigHashPreSign,\n sigHashPostSign,\n} from \"./authorization.ts\";\nimport { replayMultiSigSigHash } from \"./multisig.ts\";\nimport { serializeTransaction } from \"./wire/serialize.ts\";\nimport {\n AuthType,\n type StacksTransaction,\n type SingleSigSpendingCondition,\n type SponsoredAuthorization,\n} from \"./types.ts\";\nimport type { LocalAccount, CustomAccount } from \"../accounts/types.ts\";\n\nfunction txid(tx: StacksTransaction): string {\n return txidFromBytes(serializeTransaction(tx));\n}\n\n/** Compute the initial sighash for a transaction */\nexport function signBegin(tx: StacksTransaction): string {\n const cleared: StacksTransaction = {\n ...tx,\n auth: intoInitialSighashAuth(tx.auth),\n };\n return txid(cleared);\n}\n\n/** Sign a single-sig transaction with a private key, returning the signed transaction */\nexport function signTransaction(\n tx: StacksTransaction,\n privateKey: string\n): StacksTransaction {\n const sigHash = signBegin(tx);\n const condition = tx.auth.spendingCondition as SingleSigSpendingCondition;\n\n // Origin always signs with AuthType.Standard (even for sponsored txs)\n const { nextSig } = nextSignature(\n sigHash,\n AuthType.Standard,\n condition.fee,\n condition.nonce,\n privateKey\n );\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: {\n ...condition,\n signature: nextSig,\n },\n },\n };\n}\n\n/** Sign a single-sig transaction using an account (LocalAccount or CustomAccount) */\nexport async function signTransactionWithAccount(\n tx: StacksTransaction,\n account: LocalAccount | CustomAccount\n): Promise<StacksTransaction> {\n const sigHash = signBegin(tx);\n const condition = tx.auth.spendingCondition as SingleSigSpendingCondition;\n\n // Origin always signs with AuthType.Standard (even for sponsored txs)\n const sigHashPre = sigHashPreSign(\n sigHash,\n AuthType.Standard,\n condition.fee,\n condition.nonce\n );\n\n // account.sign returns 65-byte VRS (recovery + r + s)\n const sigBytes = await account.sign(hexToBytes(sigHashPre));\n const nextSig = bytesToHex(sigBytes);\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: {\n ...condition,\n signature: nextSig,\n },\n },\n };\n}\n\n/** Get the txid of a transaction */\nexport function getTransactionId(tx: StacksTransaction): string {\n return txid(tx);\n}\n\n/** Reconstruct the sighash after origin signing (needed for sponsor signing) */\nexport function getOriginSigHash(tx: StacksTransaction): string {\n const condition = tx.auth.spendingCondition;\n\n // Multi-sig: replay through all fields\n if (\"fields\" in condition) {\n return replayMultiSigSigHash(tx);\n }\n\n // Single-sig\n const initialSigHash = signBegin(tx);\n const sc = condition as SingleSigSpendingCondition;\n const preSign = sigHashPreSign(initialSigHash, AuthType.Standard, sc.fee, sc.nonce);\n return sigHashPostSign(preSign, sc.keyEncoding, sc.signature);\n}\n\n/** Sign a sponsored transaction as the sponsor with a private key */\nexport function signSponsor(tx: StacksTransaction, privateKey: string): StacksTransaction {\n if (tx.auth.authType !== AuthType.Sponsored) {\n throw new Error(\"Transaction must be sponsored\");\n }\n const auth = tx.auth as SponsoredAuthorization;\n const sponsorCondition = auth.sponsorSpendingCondition as SingleSigSpendingCondition;\n const originSigHash = getOriginSigHash(tx);\n\n const { nextSig } = nextSignature(\n originSigHash,\n AuthType.Sponsored,\n sponsorCondition.fee,\n sponsorCondition.nonce,\n privateKey\n );\n\n return {\n ...tx,\n auth: {\n ...auth,\n sponsorSpendingCondition: {\n ...sponsorCondition,\n signature: nextSig,\n },\n },\n };\n}\n\n/** Sign a sponsored transaction as the sponsor using an account */\nexport async function signSponsorWithAccount(\n tx: StacksTransaction,\n account: LocalAccount | CustomAccount\n): Promise<StacksTransaction> {\n if (tx.auth.authType !== AuthType.Sponsored) {\n throw new Error(\"Transaction must be sponsored\");\n }\n const auth = tx.auth as SponsoredAuthorization;\n const sponsorCondition = auth.sponsorSpendingCondition as SingleSigSpendingCondition;\n const originSigHash = getOriginSigHash(tx);\n\n const sigHashPre = sigHashPreSign(\n originSigHash,\n AuthType.Sponsored,\n sponsorCondition.fee,\n sponsorCondition.nonce\n );\n\n const sigBytes = await account.sign(hexToBytes(sigHashPre));\n const nextSig = bytesToHex(sigBytes);\n\n return {\n ...tx,\n auth: {\n ...auth,\n sponsorSpendingCondition: {\n ...sponsorCondition,\n signature: nextSig,\n },\n },\n };\n}\n",
10
- "import type { StacksChain } from \"../chains/types.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport type { PostCondition } from \"../postconditions/types.ts\";\nimport type { MultiSigHashMode, SpendingCondition } from \"./types.ts\";\nimport {\n createSingleSigSpendingCondition,\n createStandardAuth,\n createSponsoredAuth,\n} from \"./authorization.ts\";\nimport { createMultiSigSpendingCondition } from \"./multisig.ts\";\nimport {\n PayloadType,\n AnchorMode,\n PostConditionModeWire,\n FungibleConditionCode,\n NonFungibleConditionCode,\n type StacksTransaction,\n type PostConditionWire,\n type PostConditionPrincipalWire,\n type ClarityVersion,\n} from \"./types.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport { intToBigInt, type IntegerType } from \"../utils/encoding.ts\";\nimport { parseContractId } from \"../utils/address.ts\";\n\ntype MultiSigOptions = {\n publicKeys?: string[];\n signaturesRequired?: number;\n hashMode?: MultiSigHashMode;\n};\n\nexport type BuildTokenTransferOptions = MultiSigOptions & {\n recipient: string;\n amount: IntegerType;\n memo?: string;\n fee: IntegerType;\n nonce: IntegerType;\n publicKey?: string;\n chain?: StacksChain;\n postConditionMode?: \"allow\" | \"deny\";\n postConditions?: PostCondition[];\n sponsored?: boolean;\n};\n\nexport type BuildContractCallOptions = MultiSigOptions & {\n contractAddress: string;\n contractName: string;\n functionName: string;\n functionArgs: ClarityValue[];\n fee: IntegerType;\n nonce: IntegerType;\n publicKey?: string;\n chain?: StacksChain;\n postConditionMode?: \"allow\" | \"deny\";\n postConditions?: PostCondition[];\n sponsored?: boolean;\n};\n\nexport type BuildContractDeployOptions = MultiSigOptions & {\n contractName: string;\n codeBody: string;\n clarityVersion?: ClarityVersion;\n fee: IntegerType;\n nonce: IntegerType;\n publicKey?: string;\n chain?: StacksChain;\n postConditionMode?: \"allow\" | \"deny\";\n postConditions?: PostCondition[];\n sponsored?: boolean;\n};\n\nfunction resolvePcMode(mode?: \"allow\" | \"deny\"): PostConditionModeWire {\n return mode === \"allow\" ? PostConditionModeWire.Allow : PostConditionModeWire.Deny;\n}\n\nfunction convertPostConditions(pcs?: PostCondition[]): PostConditionWire[] {\n if (!pcs || pcs.length === 0) return [];\n return pcs.map(convertPostCondition);\n}\n\nfunction resolvePrincipal(address: string): PostConditionPrincipalWire {\n if (address === \"origin\") return { type: \"origin\" };\n const [addr, name] = address.split(\".\");\n if (name) {\n return { type: \"contract\", address: addr!, contractName: name };\n }\n return { type: \"standard\", address: addr! };\n}\n\nconst FUNGIBLE_CODE_MAP: Record<string, number> = {\n eq: FungibleConditionCode.Equal,\n gt: FungibleConditionCode.Greater,\n gte: FungibleConditionCode.GreaterEqual,\n lt: FungibleConditionCode.Less,\n lte: FungibleConditionCode.LessEqual,\n};\n\nfunction convertPostCondition(pc: PostCondition): PostConditionWire {\n switch (pc.type) {\n case \"stx-postcondition\":\n return {\n type: \"stx\",\n principal: resolvePrincipal(pc.address),\n conditionCode: FUNGIBLE_CODE_MAP[pc.condition]!,\n amount: intToBigInt(pc.amount),\n };\n case \"ft-postcondition\": {\n const [contractId, tokenName] = pc.asset.split(\"::\");\n const [addr, name] = parseContractId(contractId!);\n return {\n type: \"ft\",\n principal: resolvePrincipal(pc.address),\n asset: { address: addr, contractName: name, assetName: tokenName! },\n conditionCode: FUNGIBLE_CODE_MAP[pc.condition]!,\n amount: intToBigInt(pc.amount),\n };\n }\n case \"nft-postcondition\": {\n const [contractId, tokenName] = pc.asset.split(\"::\");\n const [addr, name] = parseContractId(contractId!);\n return {\n type: \"nft\",\n principal: resolvePrincipal(pc.address),\n asset: { address: addr, contractName: name, assetName: tokenName! },\n conditionCode: pc.condition === \"sent\" ? NonFungibleConditionCode.Sends : NonFungibleConditionCode.DoesNotSend,\n assetId: pc.assetId,\n };\n }\n }\n}\n\nimport type { Authorization } from \"./types.ts\";\n\nfunction resolveSpendingCondition(\n opts: MultiSigOptions & { publicKey?: string },\n nonce: bigint,\n fee: bigint\n): SpendingCondition {\n if (opts.publicKeys) {\n return createMultiSigSpendingCondition(\n opts.publicKeys,\n opts.signaturesRequired!,\n nonce,\n fee,\n opts.hashMode\n );\n }\n return createSingleSigSpendingCondition(opts.publicKey!, nonce, fee);\n}\n\nfunction resolveAuth(spendingCondition: any, sponsored?: boolean): Authorization {\n return sponsored\n ? createSponsoredAuth(spendingCondition)\n : createStandardAuth(spendingCondition);\n}\n\nfunction resolveVersionAndChainId(chain?: StacksChain): { version: number; chainId: number } {\n if (!chain) return { version: 0x00, chainId: 0x00000001 }; // mainnet defaults\n return { version: chain.transactionVersion, chainId: chain.id };\n}\n\nexport function buildTokenTransfer(options: BuildTokenTransferOptions): StacksTransaction {\n const { version, chainId } = resolveVersionAndChainId(options.chain);\n const fee = intToBigInt(options.fee);\n const nonce = intToBigInt(options.nonce);\n\n const spendingCondition = resolveSpendingCondition(options, nonce, fee);\n const recipient = Cl.principal(options.recipient);\n\n const tx: StacksTransaction = {\n version,\n chainId,\n auth: resolveAuth(spendingCondition, options.sponsored),\n anchorMode: AnchorMode.Any,\n postConditionMode: resolvePcMode(options.postConditionMode),\n postConditions: convertPostConditions(options.postConditions),\n payload: {\n payloadType: PayloadType.TokenTransfer,\n recipient,\n amount: intToBigInt(options.amount),\n memo: options.memo ?? \"\",\n },\n };\n\n if (options.publicKeys) {\n (tx as any)._multisig = { publicKeys: options.publicKeys };\n }\n return tx;\n}\n\nexport function buildContractCall(options: BuildContractCallOptions): StacksTransaction {\n const { version, chainId } = resolveVersionAndChainId(options.chain);\n const fee = intToBigInt(options.fee);\n const nonce = intToBigInt(options.nonce);\n\n const spendingCondition = resolveSpendingCondition(options, nonce, fee);\n\n const tx: StacksTransaction = {\n version,\n chainId,\n auth: resolveAuth(spendingCondition, options.sponsored),\n anchorMode: AnchorMode.Any,\n postConditionMode: resolvePcMode(options.postConditionMode),\n postConditions: convertPostConditions(options.postConditions),\n payload: {\n payloadType: PayloadType.ContractCall,\n contractAddress: options.contractAddress,\n contractName: options.contractName,\n functionName: options.functionName,\n functionArgs: options.functionArgs,\n },\n };\n\n if (options.publicKeys) {\n (tx as any)._multisig = { publicKeys: options.publicKeys };\n }\n return tx;\n}\n\nexport function buildContractDeploy(options: BuildContractDeployOptions): StacksTransaction {\n const { version, chainId } = resolveVersionAndChainId(options.chain);\n const fee = intToBigInt(options.fee);\n const nonce = intToBigInt(options.nonce);\n\n const spendingCondition = resolveSpendingCondition(options, nonce, fee);\n const useVersioned = options.clarityVersion !== undefined;\n\n const tx: StacksTransaction = {\n version,\n chainId,\n auth: resolveAuth(spendingCondition, options.sponsored),\n anchorMode: AnchorMode.Any,\n postConditionMode: resolvePcMode(options.postConditionMode),\n postConditions: convertPostConditions(options.postConditions),\n payload: {\n payloadType: useVersioned ? PayloadType.VersionedSmartContract : PayloadType.SmartContract,\n clarityVersion: options.clarityVersion,\n contractName: options.contractName,\n codeBody: options.codeBody,\n },\n };\n\n if (options.publicKeys) {\n (tx as any)._multisig = { publicKeys: options.publicKeys };\n }\n return tx;\n}\n"
11
- ],
12
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAM,WAAW;AAAA,EACtB,UAAU;AAAA,EACV,WAAW;AACb;AAIO,IAAM,cAAc;AAAA,EACzB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,cAAc;AAAA,EACd,kBAAkB;AACpB;AAIO,IAAM,iBAAiB;AAAA,EAC5B,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACZ;AAIO,IAAM,aAAa;AAAA,EACxB,aAAa;AAAA,EACb,cAAc;AAAA,EACd,KAAK;AACP;AAIO,IAAM,wBAAwB;AAAA,EACnC,OAAO;AAAA,EACP,MAAM;AACR;AAKO,IAAM,kBAAkB;AAAA,EAC7B,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,oBAAoB;AAAA,EACpB,0BAA0B;AAC5B;AAIO,IAAM,iBAAiB;AAAA,EAC5B,YAAY;AAAA,EACZ,cAAc;AAChB;AAIO,IAAM,wBAAwB;AAAA,EACnC,OAAO;AAAA,EACP,SAAS;AAAA,EACT,cAAc;AAAA,EACd,MAAM;AAAA,EACN,WAAW;AACb;AAGO,IAAM,2BAA2B;AAAA,EACtC,OAAO;AAAA,EACP,aAAa;AACf;AAGO,IAAM,2BAA2B;AAAA,EACtC,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