@secondlayer/stacks 5.1.3 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +1 -8
  2. package/dist/shared/{stacks-qt8ehebn.js → stacks-esm-0rdxcta7.js} +2 -2
  3. package/dist/shared/{stacks-qt8ehebn.js.map → stacks-esm-0rdxcta7.js.map} +1 -1
  4. package/dist/shared/{stacks-4hs8r4q2.js → stacks-esm-1jae0a3r.js} +2 -2
  5. package/dist/shared/{stacks-xjkn3en1.cjs.map → stacks-esm-1jae0a3r.js.map} +1 -1
  6. package/dist/shared/{stacks-4d7c3x27.js → stacks-esm-2mc7ebrm.js} +3 -3
  7. package/dist/shared/{stacks-4d7c3x27.js.map → stacks-esm-2mc7ebrm.js.map} +1 -1
  8. package/dist/shared/{stacks-8brgfvqx.js → stacks-esm-3g33bqsm.js} +4 -4
  9. package/dist/shared/{stacks-8brgfvqx.js.map → stacks-esm-3g33bqsm.js.map} +1 -1
  10. package/dist/shared/{stacks-gjz26k6b.js → stacks-esm-3pv5avgr.js} +59 -15
  11. package/dist/shared/stacks-esm-3pv5avgr.js.map +12 -0
  12. package/dist/shared/{stacks-qex691bh.js → stacks-esm-743jfh10.js} +6 -6
  13. package/dist/shared/{stacks-qex691bh.js.map → stacks-esm-743jfh10.js.map} +1 -1
  14. package/dist/shared/{stacks-wxfd6r4b.js → stacks-esm-7fpqgtyx.js} +3 -3
  15. package/dist/shared/{stacks-wxfd6r4b.js.map → stacks-esm-7fpqgtyx.js.map} +1 -1
  16. package/dist/shared/{stacks-71k0vmct.js → stacks-esm-9rnx0zxr.js} +5 -5
  17. package/dist/shared/{stacks-71k0vmct.js.map → stacks-esm-9rnx0zxr.js.map} +1 -1
  18. package/dist/shared/{stacks-fd4rx56e.js → stacks-esm-aw2mj3sj.js} +7 -7
  19. package/dist/shared/{stacks-fd4rx56e.js.map → stacks-esm-aw2mj3sj.js.map} +1 -1
  20. package/dist/shared/{stacks-qs5fzts5.js → stacks-esm-cvhazvhd.js} +2 -2
  21. package/dist/shared/{stacks-qs5fzts5.js.map → stacks-esm-cvhazvhd.js.map} +1 -1
  22. package/dist/shared/{stacks-69nq48jp.js → stacks-esm-fcfdn2zx.js} +5 -5
  23. package/dist/shared/{stacks-69nq48jp.js.map → stacks-esm-fcfdn2zx.js.map} +1 -1
  24. package/dist/shared/{stacks-x0qqwrev.js → stacks-esm-hr7fpxtj.js} +4 -4
  25. package/dist/shared/{stacks-x0qqwrev.js.map → stacks-esm-hr7fpxtj.js.map} +1 -1
  26. package/dist/shared/{stacks-mbt36bzt.js → stacks-esm-kds4n82p.js} +11 -11
  27. package/dist/shared/{stacks-mbt36bzt.js.map → stacks-esm-kds4n82p.js.map} +1 -1
  28. package/dist/shared/{stacks-kg1npstf.js → stacks-esm-n53kvwmt.js} +2 -2
  29. package/dist/shared/{stacks-kg1npstf.js.map → stacks-esm-n53kvwmt.js.map} +1 -1
  30. package/dist/shared/{stacks-v2rfr46a.js → stacks-esm-pxhfqfff.js} +4 -4
  31. package/dist/shared/{stacks-v2rfr46a.js.map → stacks-esm-pxhfqfff.js.map} +1 -1
  32. package/dist/shared/{stacks-yajyej2y.js → stacks-esm-q19a17fd.js} +3 -3
  33. package/dist/shared/{stacks-yajyej2y.js.map → stacks-esm-q19a17fd.js.map} +1 -1
  34. package/dist/shared/{stacks-v03zef3g.js → stacks-esm-qk0p9fr6.js} +9 -9
  35. package/dist/shared/{stacks-v03zef3g.js.map → stacks-esm-qk0p9fr6.js.map} +1 -1
  36. package/dist/shared/{stacks-qcae5852.js → stacks-esm-qkj67g80.js} +2 -2
  37. package/dist/shared/{stacks-qcae5852.js.map → stacks-esm-qkj67g80.js.map} +1 -1
  38. package/dist/shared/{stacks-mftyrc60.js → stacks-esm-r6dejrgr.js} +4 -4
  39. package/dist/shared/{stacks-mftyrc60.js.map → stacks-esm-r6dejrgr.js.map} +1 -1
  40. package/dist/shared/{stacks-9c1yam8b.js → stacks-esm-r9q4wnyw.js} +5 -5
  41. package/dist/shared/{stacks-9c1yam8b.js.map → stacks-esm-r9q4wnyw.js.map} +1 -1
  42. package/dist/shared/{stacks-51ybf135.js → stacks-esm-skmcf5n2.js} +5 -5
  43. package/dist/shared/{stacks-51ybf135.js.map → stacks-esm-skmcf5n2.js.map} +1 -1
  44. package/dist/shared/{stacks-yvb7rvwk.js → stacks-esm-v45990hx.js} +2 -2
  45. package/dist/shared/{stacks-8vzxax5e.cjs.map → stacks-esm-v45990hx.js.map} +1 -1
  46. package/dist/shared/{stacks-z90xdr1x.js → stacks-esm-wv67m4g6.js} +3 -3
  47. package/dist/shared/{stacks-z90xdr1x.js.map → stacks-esm-wv67m4g6.js.map} +1 -1
  48. package/dist/shared/{stacks-1m3m1agc.js → stacks-esm-x1r01353.js} +5 -5
  49. package/dist/shared/{stacks-1m3m1agc.js.map → stacks-esm-x1r01353.js.map} +1 -1
  50. package/dist/src/accounts/index.cjs +558 -4
  51. package/dist/src/accounts/index.cjs.map +10 -4
  52. package/dist/src/accounts/index.js +3 -3
  53. package/dist/src/actions/index.cjs +3815 -1
  54. package/dist/src/actions/index.cjs.map +65 -3
  55. package/dist/src/actions/index.js +14 -14
  56. package/dist/src/bitcoin/index.cjs +2477 -1
  57. package/dist/src/bitcoin/index.cjs.map +31 -3
  58. package/dist/src/bitcoin/index.js +11 -11
  59. package/dist/src/bns/index.cjs +4439 -17
  60. package/dist/src/bns/index.cjs.map +50 -3
  61. package/dist/src/bns/index.js +14 -14
  62. package/dist/src/chains/index.cjs +135 -1
  63. package/dist/src/chains/index.cjs.map +5 -3
  64. package/dist/src/chains/index.js +1 -1
  65. package/dist/src/clarity/index.cjs +2019 -1
  66. package/dist/src/clarity/index.cjs.map +24 -3
  67. package/dist/src/clarity/index.js +8 -8
  68. package/dist/src/filters/index.cjs +725 -1
  69. package/dist/src/filters/index.cjs.map +11 -3
  70. package/dist/src/filters/index.d.cts +76 -13
  71. package/dist/src/filters/index.d.ts +76 -13
  72. package/dist/src/filters/index.js +8 -4
  73. package/dist/src/filters/index.js.map +1 -1
  74. package/dist/src/index.cjs +3935 -62
  75. package/dist/src/index.cjs.map +69 -4
  76. package/dist/src/index.d.cts +62 -11
  77. package/dist/src/index.d.ts +62 -11
  78. package/dist/src/index.js +16 -16
  79. package/dist/src/postconditions/index.cjs +1726 -1
  80. package/dist/src/postconditions/index.cjs.map +20 -3
  81. package/dist/src/postconditions/index.js +6 -6
  82. package/dist/src/pox/index.cjs +3855 -1
  83. package/dist/src/pox/index.cjs.map +48 -3
  84. package/dist/src/pox/index.js +13 -13
  85. package/dist/src/pox5/index.cjs +4054 -29
  86. package/dist/src/pox5/index.cjs.map +54 -3
  87. package/dist/src/pox5/index.js +15 -15
  88. package/dist/src/sbtc/index.cjs +3705 -4
  89. package/dist/src/sbtc/index.cjs.map +47 -3
  90. package/dist/src/sbtc/index.js +12 -12
  91. package/dist/src/stackingdao/index.cjs +3751 -8
  92. package/dist/src/stackingdao/index.cjs.map +45 -3
  93. package/dist/src/stackingdao/index.js +12 -12
  94. package/dist/src/subscriptions/index.cjs +153 -1
  95. package/dist/src/subscriptions/index.cjs.map +6 -3
  96. package/dist/src/subscriptions/index.js +2 -2
  97. package/dist/src/transactions/index.cjs +2139 -1
  98. package/dist/src/transactions/index.cjs.map +23 -3
  99. package/dist/src/transactions/index.js +6 -6
  100. package/dist/src/utils/index.cjs +435 -3
  101. package/dist/src/utils/index.cjs.map +9 -3
  102. package/dist/src/utils/index.js +3 -3
  103. package/package.json +3 -23
  104. package/dist/shared/stacks-02actsrx.cjs +0 -17
  105. package/dist/shared/stacks-02actsrx.cjs.map +0 -10
  106. package/dist/shared/stacks-03vfm21t.cjs +0 -222
  107. package/dist/shared/stacks-03vfm21t.cjs.map +0 -12
  108. package/dist/shared/stacks-24h5k94q.cjs +0 -74
  109. package/dist/shared/stacks-24h5k94q.cjs.map +0 -11
  110. package/dist/shared/stacks-37kz5t9f.cjs +0 -764
  111. package/dist/shared/stacks-37kz5t9f.cjs.map +0 -23
  112. package/dist/shared/stacks-3mt2q2na.cjs +0 -65
  113. package/dist/shared/stacks-3mt2q2na.cjs.map +0 -9
  114. package/dist/shared/stacks-4hs8r4q2.js.map +0 -10
  115. package/dist/shared/stacks-8vzxax5e.cjs +0 -45
  116. package/dist/shared/stacks-agk106zs.cjs +0 -267
  117. package/dist/shared/stacks-agk106zs.cjs.map +0 -12
  118. package/dist/shared/stacks-bdgh9n83.cjs +0 -212
  119. package/dist/shared/stacks-bdgh9n83.cjs.map +0 -11
  120. package/dist/shared/stacks-dpxnxhqb.cjs +0 -51
  121. package/dist/shared/stacks-dpxnxhqb.cjs.map +0 -11
  122. package/dist/shared/stacks-ee53k9j2.cjs +0 -651
  123. package/dist/shared/stacks-ee53k9j2.cjs.map +0 -13
  124. package/dist/shared/stacks-enpj9krt.cjs +0 -38
  125. package/dist/shared/stacks-enpj9krt.cjs.map +0 -10
  126. package/dist/shared/stacks-f35mnrmg.cjs +0 -164
  127. package/dist/shared/stacks-f35mnrmg.cjs.map +0 -10
  128. package/dist/shared/stacks-fhzwsn5d.cjs +0 -261
  129. package/dist/shared/stacks-fhzwsn5d.cjs.map +0 -12
  130. package/dist/shared/stacks-gjz26k6b.js.map +0 -12
  131. package/dist/shared/stacks-gza2n1zs.cjs +0 -73
  132. package/dist/shared/stacks-gza2n1zs.cjs.map +0 -11
  133. package/dist/shared/stacks-kem68d80.cjs +0 -156
  134. package/dist/shared/stacks-kem68d80.cjs.map +0 -10
  135. package/dist/shared/stacks-n98w7g57.cjs +0 -234
  136. package/dist/shared/stacks-n98w7g57.cjs.map +0 -10
  137. package/dist/shared/stacks-p337hp6m.cjs +0 -336
  138. package/dist/shared/stacks-p337hp6m.cjs.map +0 -25
  139. package/dist/shared/stacks-q34k4vnc.cjs +0 -286
  140. package/dist/shared/stacks-q34k4vnc.cjs.map +0 -12
  141. package/dist/shared/stacks-rryme9bv.cjs +0 -569
  142. package/dist/shared/stacks-rryme9bv.cjs.map +0 -13
  143. package/dist/shared/stacks-s5vej5z6.cjs +0 -410
  144. package/dist/shared/stacks-s5vej5z6.cjs.map +0 -15
  145. package/dist/shared/stacks-sdqkapct.cjs +0 -67
  146. package/dist/shared/stacks-sdqkapct.cjs.map +0 -12
  147. package/dist/shared/stacks-vea7nde7.cjs +0 -731
  148. package/dist/shared/stacks-vea7nde7.cjs.map +0 -13
  149. package/dist/shared/stacks-wk8yp13j.cjs +0 -33
  150. package/dist/shared/stacks-wk8yp13j.cjs.map +0 -11
  151. package/dist/shared/stacks-xjkn3en1.cjs +0 -42
  152. package/dist/shared/stacks-xnrywjf1.cjs +0 -131
  153. package/dist/shared/stacks-xnrywjf1.cjs.map +0 -11
  154. package/dist/shared/stacks-yvb7rvwk.js.map +0 -10
  155. package/dist/src/tools/btc/index.cjs +0 -131
  156. package/dist/src/tools/btc/index.cjs.map +0 -10
  157. package/dist/src/tools/btc/index.d.cts +0 -10
  158. package/dist/src/tools/btc/index.d.ts +0 -10
  159. package/dist/src/tools/btc/index.js +0 -90
  160. package/dist/src/tools/btc/index.js.map +0 -10
  161. package/dist/src/tools/index.cjs +0 -3865
  162. package/dist/src/tools/index.cjs.map +0 -80
  163. package/dist/src/tools/index.d.cts +0 -206
  164. package/dist/src/tools/index.d.ts +0 -206
  165. package/dist/src/tools/index.js +0 -3827
  166. package/dist/src/tools/index.js.map +0 -80
@@ -1,13 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/transactions/authorization.ts", "../src/transactions/multisig.ts", "../src/transactions/build.ts", "../src/transactions/signer.ts"],
4
- "sourcesContent": [
5
- "import { hmac } from \"@noble/hashes/hmac.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport { etc, getPublicKey as nobleGetPublicKey, sign } from \"@noble/secp256k1\";\nimport {\n\tbytesToHex,\n\tconcatBytes,\n\thexToBytes,\n\tintToBytes,\n\tintToHex,\n} from \"../utils/encoding.ts\";\nimport { hashP2PKH, txidFromBytes } from \"../utils/hash.ts\";\nimport {\n\tAddressHashMode,\n\tAuthType,\n\ttype Authorization,\n\tPubKeyEncoding,\n\tRECOVERABLE_ECDSA_SIG_LENGTH_BYTES,\n\ttype SingleSigSpendingCondition,\n\ttype SpendingCondition,\n\ttype SponsoredAuthorization,\n\ttype StandardAuthorization,\n} from \"./types.ts\";\n\n// Ensure sync signing is available\netc.hmacSha256Sync = (key: Uint8Array, ...msgs: Uint8Array[]) => {\n\tconst h = hmac.create(sha256, key);\n\tfor (const msg of msgs) h.update(msg);\n\treturn h.digest();\n};\n\nconst EMPTY_SIG = bytesToHex(\n\tnew Uint8Array(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES),\n);\n\nexport function createSingleSigSpendingCondition(\n\tpublicKey: string,\n\tnonce: bigint,\n\tfee: bigint,\n): SingleSigSpendingCondition {\n\tconst pubKeyBytes = hexToBytes(publicKey);\n\tconst signer = hashP2PKH(pubKeyBytes);\n\tconst isCompressed = pubKeyBytes.length === 33;\n\n\treturn {\n\t\thashMode: AddressHashMode.P2PKH,\n\t\tsigner,\n\t\tnonce,\n\t\tfee,\n\t\tkeyEncoding: isCompressed\n\t\t\t? PubKeyEncoding.Compressed\n\t\t\t: PubKeyEncoding.Uncompressed,\n\t\tsignature: EMPTY_SIG,\n\t};\n}\n\nexport function createStandardAuth(\n\tspendingCondition: SpendingCondition,\n): StandardAuthorization {\n\treturn { authType: AuthType.Standard, spendingCondition };\n}\n\nexport function createSponsoredAuth(\n\tspendingCondition: SpendingCondition,\n\tsponsorSpendingCondition?: SpendingCondition,\n): SponsoredAuthorization {\n\treturn {\n\t\tauthType: AuthType.Sponsored,\n\t\tspendingCondition,\n\t\tsponsorSpendingCondition:\n\t\t\tsponsorSpendingCondition ??\n\t\t\tcreateSingleSigSpendingCondition(\"0\".repeat(66), 0n, 0n),\n\t};\n}\n\nfunction clearCondition(condition: SpendingCondition): SpendingCondition {\n\tif (\"signature\" in condition) {\n\t\treturn {\n\t\t\t...condition,\n\t\t\tnonce: 0n,\n\t\t\tfee: 0n,\n\t\t\tsignature: EMPTY_SIG,\n\t\t};\n\t}\n\treturn {\n\t\t...condition,\n\t\tnonce: 0n,\n\t\tfee: 0n,\n\t\tfields: [],\n\t};\n}\n\n/**\n * The sponsor \"signing sentinel\" used in the initial sighash of a sponsored tx.\n * Its `signer` MUST be 20 zero bytes (an empty address hash160) — NOT the\n * hash160 of a zero public key. Matching the reference (`newInitialSigHash` in\n * @stacks/transactions) is load-bearing: this exact byte layout is folded into\n * the origin's sighash, so any deviation makes the origin signature invalid and\n * the node rejects the tx with `SignatureValidation`.\n */\nfunction sponsorSigningSentinel(): SingleSigSpendingCondition {\n\treturn {\n\t\thashMode: AddressHashMode.P2PKH,\n\t\tsigner: \"00\".repeat(20),\n\t\tnonce: 0n,\n\t\tfee: 0n,\n\t\tkeyEncoding: PubKeyEncoding.Compressed,\n\t\tsignature: EMPTY_SIG,\n\t};\n}\n\nexport function intoInitialSighashAuth(auth: Authorization): Authorization {\n\tif (auth.authType === AuthType.Standard) {\n\t\treturn createStandardAuth(clearCondition(auth.spendingCondition));\n\t}\n\treturn createSponsoredAuth(\n\t\tclearCondition(auth.spendingCondition),\n\t\tsponsorSigningSentinel(),\n\t);\n}\n\n/** Compute pre-sign sighash = sha512/256(prevSigHash + authType + fee + nonce) */\nexport function sigHashPreSign(\n\tcurSigHash: string,\n\tauthType: number,\n\tfee: bigint,\n\tnonce: bigint,\n): string {\n\tconst data = concatBytes(\n\t\thexToBytes(curSigHash),\n\t\tnew Uint8Array([authType]),\n\t\tintToBytes(fee, 8),\n\t\tintToBytes(nonce, 8),\n\t);\n\treturn txidFromBytes(data);\n}\n\n/** Compute post-sign sighash = sha512/256(preSigHash + pubKeyEncoding + signature) */\nexport function sigHashPostSign(\n\tcurSigHash: string,\n\tpubKeyEncoding: number,\n\tsignature: string,\n): string {\n\tconst data = concatBytes(\n\t\thexToBytes(curSigHash),\n\t\tnew Uint8Array([pubKeyEncoding]),\n\t\thexToBytes(signature),\n\t);\n\treturn txidFromBytes(data);\n}\n\n/** Sign with private key and return VRS signature (recoveryId + r + s) */\nfunction signWithKey(privateKey: string, messageHash: string): string {\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst sig = sign(messageHash, keyBytes, { lowS: true });\n\tconst recoveryIdHex = intToHex(sig.recovery, 1);\n\treturn recoveryIdHex + sig.toCompactHex();\n}\n\nexport function nextSignature(\n\tcurSigHash: string,\n\tauthType: number,\n\tfee: bigint,\n\tnonce: bigint,\n\tprivateKey: string,\n): { nextSig: string; nextSigHash: string } {\n\tconst sigHashPre = sigHashPreSign(curSigHash, authType, fee, nonce);\n\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst pubKey = nobleGetPublicKey(keyBytes, true);\n\tconst isCompressed = pubKey.length === 33;\n\tconst pubKeyEncoding = isCompressed\n\t\t? PubKeyEncoding.Compressed\n\t\t: PubKeyEncoding.Uncompressed;\n\n\tconst nextSig = signWithKey(privateKey, sigHashPre);\n\tconst nextSigHash = sigHashPostSign(sigHashPre, pubKeyEncoding, nextSig);\n\n\treturn { nextSig, nextSigHash };\n}\n",
6
- "import {\n\tgetPublicKey as nobleGetPublicKey,\n\tsign as nobleSign,\n} from \"@noble/secp256k1\";\nimport type { CustomAccount, LocalAccount } from \"../accounts/types.ts\";\nimport type { StacksChain } from \"../chains/types.ts\";\nimport { c32address } from \"../utils/c32.ts\";\nimport {\n\tbytesToHex,\n\tconcatBytes,\n\thexToBytes,\n\tintToHex,\n} from \"../utils/encoding.ts\";\nimport { hash160 } from \"../utils/hash.ts\";\nimport { txidFromBytes } from \"../utils/hash.ts\";\nimport {\n\tintoInitialSighashAuth,\n\tnextSignature,\n\tsigHashPostSign,\n\tsigHashPreSign,\n} from \"./authorization.ts\";\nimport {\n\tAddressHashMode,\n\tAuthType,\n\ttype MultiSigHashMode,\n\ttype MultiSigSpendingCondition,\n\tPubKeyEncoding,\n\ttype StacksTransaction,\n\ttype TransactionAuthField,\n} from \"./types.ts\";\nimport { serializeTransaction } from \"./wire/serialize.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\treturn (hashMode & 0x04) !== 0;\n}\n\n/** Build a Bitcoin-style redeem script for m-of-n multi-sig */\nfunction makeRedeemScript(\n\tpublicKeys: string[],\n\tsignaturesRequired: number,\n): Uint8Array {\n\tconst parts: Uint8Array[] = [];\n\tparts.push(new Uint8Array([0x50 + signaturesRequired])); // OP_n\n\tfor (const pk of publicKeys) {\n\t\tconst pkBytes = hexToBytes(pk);\n\t\tparts.push(new Uint8Array([pkBytes.length])); // length prefix (0x21 for compressed)\n\t\tparts.push(pkBytes);\n\t}\n\tparts.push(new Uint8Array([0x50 + publicKeys.length])); // OP_m\n\tparts.push(new Uint8Array([OP_CHECKMULTISIG]));\n\treturn concatBytes(...parts);\n}\n\n/** Derive a multi-sig address from public keys */\nexport function makeMultiSigAddress(\n\tpublicKeys: string[],\n\tsignaturesRequired: number,\n\tchain?: StacksChain,\n): string {\n\tif (signaturesRequired < 1 || signaturesRequired > publicKeys.length) {\n\t\tthrow new Error(\n\t\t\t`signaturesRequired must be between 1 and ${publicKeys.length}`,\n\t\t);\n\t}\n\tconst redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n\tconst signer = hash160(redeemScript);\n\tconst version = chain?.addressVersion?.multiSig ?? 20; // mainnet default\n\treturn c32address(version, bytesToHex(signer));\n}\n\n/** Create an empty multi-sig spending condition */\nexport function createMultiSigSpendingCondition(\n\tpublicKeys: string[],\n\tsignaturesRequired: number,\n\tnonce: bigint,\n\tfee: bigint,\n\thashMode: MultiSigHashMode = AddressHashMode.P2SH,\n): MultiSigSpendingCondition {\n\tconst redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n\tconst signer = bytesToHex(hash160(redeemScript));\n\n\treturn {\n\t\thashMode,\n\t\tsigner,\n\t\tnonce,\n\t\tfee,\n\t\tfields: [],\n\t\tsignaturesRequired,\n\t};\n}\n\n/** Compute the initial sighash for a transaction (same as signBegin) */\nfunction initialSigHash(tx: StacksTransaction): string {\n\tconst cleared: StacksTransaction = {\n\t\t...tx,\n\t\tauth: intoInitialSighashAuth(tx.auth),\n\t};\n\treturn txidFromBytes(serializeTransaction(cleared));\n}\n\n/** Compute the presign-sighash used by all non-sequential signers */\nfunction nonSequentialPreSignHash(tx: StacksTransaction): string {\n\tconst condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\tconst initHash = initialSigHash(tx);\n\treturn sigHashPreSign(\n\t\tinitHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t);\n}\n\n/** Replay sighash through existing auth fields of a multi-sig tx */\nexport function replayMultiSigSigHash(tx: StacksTransaction): string {\n\tconst condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n\t// Non-sequential: all signers sign the same presign-sighash, no field chaining\n\tif (isNonSequential(condition.hashMode)) {\n\t\tconst preSign = nonSequentialPreSignHash(tx);\n\t\t// Chain through all fields to get the final sighash\n\t\tlet curSigHash = preSign;\n\t\tfor (const field of condition.fields) {\n\t\t\tcurSigHash = sigHashPostSign(\n\t\t\t\tcurSigHash,\n\t\t\t\tfield.pubKeyEncoding,\n\t\t\t\tfield.data,\n\t\t\t);\n\t\t}\n\t\treturn curSigHash;\n\t}\n\n\t// Sequential: chain through all fields\n\tlet curSigHash = initialSigHash(tx);\n\tfor (const field of condition.fields) {\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n\t}\n\treturn curSigHash;\n}\n\n/** Sign one position of a multi-sig transaction with a private key */\nexport function signMultiSig(\n\ttx: StacksTransaction,\n\tprivateKey: string,\n\tpublicKeys: string[],\n): StacksTransaction {\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst signerPubKey = bytesToHex(nobleGetPublicKey(keyBytes, true));\n\n\tconst signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n\tif (signerIndex === -1) {\n\t\tthrow new Error(\n\t\t\t\"Private key does not correspond to any signer in the multi-sig\",\n\t\t);\n\t}\n\n\tconst condition = {\n\t\t...(tx.auth.spendingCondition as MultiSigSpendingCondition),\n\t};\n\n\t// Non-sequential: all signers sign the same presign-sighash independently\n\tif (isNonSequential(condition.hashMode)) {\n\t\treturn signNonSequential(tx, condition, privateKey);\n\t}\n\n\t// Sequential: existing P2SH behavior\n\treturn signSequential(tx, condition, privateKey, publicKeys, signerIndex);\n}\n\n/** Non-sequential signing: compute presign-sighash from initial tx, sign, append */\nfunction signNonSequential(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\tprivateKey: string,\n): StacksTransaction {\n\tconst fields = [...condition.fields];\n\tconst preSignHash = nonSequentialPreSignHash(tx);\n\n\t// Sign the presign-sighash directly\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst sig = nobleSign(preSignHash, keyBytes, { lowS: true });\n\tconst recoveryIdHex = intToHex(sig.recovery, 1);\n\tconst nextSig = recoveryIdHex + sig.toCompactHex();\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\tconst sigCount = fields.filter((f) => f.type === \"signature\").length;\n\n\t// Auto-finalize: non-sequential needs no pubkey gap-filling\n\tif (sigCount >= condition.signaturesRequired) {\n\t\treturn {\n\t\t\t...tx,\n\t\t\tauth: { ...tx.auth, spendingCondition: newCondition },\n\t\t};\n\t}\n\n\treturn {\n\t\t...tx,\n\t\tauth: { ...tx.auth, spendingCondition: newCondition },\n\t};\n}\n\n/** Sequential signing: existing P2SH behavior */\nfunction signSequential(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\tprivateKey: string,\n\tpublicKeys: string[],\n\tsignerIndex: number,\n): StacksTransaction {\n\tconst fields = [...condition.fields];\n\n\t// Replay sighash through existing fields\n\tlet curSigHash = initialSigHash(tx);\n\tfor (const field of fields) {\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n\t}\n\n\t// Fill intervening positions with pubkey fields\n\tfor (let i = fields.length; i < signerIndex; i++) {\n\t\tconst pubKeyField: TransactionAuthField = {\n\t\t\ttype: \"publicKey\",\n\t\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\tdata: publicKeys[i]!,\n\t\t};\n\t\tfields.push(pubKeyField);\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(\n\t\t\tpreSign,\n\t\t\tpubKeyField.pubKeyEncoding,\n\t\t\tpubKeyField.data,\n\t\t);\n\t}\n\n\t// Sign at signerIndex\n\tconst { nextSig, nextSigHash } = nextSignature(\n\t\tcurSigHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t\tprivateKey,\n\t);\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\tcurSigHash = nextSigHash;\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n\t// Count signatures so far\n\tconst sigCount = fields.filter((f) => f.type === \"signature\").length;\n\tlet finalCondition = newCondition;\n\n\t// Auto-finalize if enough signatures collected\n\tif (sigCount >= condition.signaturesRequired) {\n\t\tfinalCondition = finalizeMultiSigCondition(\n\t\t\tnewCondition,\n\t\t\tpublicKeys,\n\t\t\tcurSigHash,\n\t\t);\n\t}\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: finalCondition,\n\t\t},\n\t};\n}\n\n/** Sign one position of a multi-sig transaction with an account */\nexport async function signMultiSigWithAccount(\n\ttx: StacksTransaction,\n\taccount: LocalAccount | CustomAccount,\n\tpublicKeys: string[],\n): Promise<StacksTransaction> {\n\tconst signerPubKey = account.publicKey;\n\n\tconst signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n\tif (signerIndex === -1) {\n\t\tthrow new Error(\n\t\t\t\"Account does not correspond to any signer in the multi-sig\",\n\t\t);\n\t}\n\n\tconst condition = {\n\t\t...(tx.auth.spendingCondition as MultiSigSpendingCondition),\n\t};\n\n\t// Non-sequential: all signers sign the same presign-sighash independently\n\tif (isNonSequential(condition.hashMode)) {\n\t\treturn signNonSequentialWithAccount(tx, condition, account);\n\t}\n\n\t// Sequential: existing behavior\n\treturn signSequentialWithAccount(\n\t\ttx,\n\t\tcondition,\n\t\taccount,\n\t\tpublicKeys,\n\t\tsignerIndex,\n\t);\n}\n\n/** Non-sequential signing with account */\nasync function signNonSequentialWithAccount(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\taccount: LocalAccount | CustomAccount,\n): Promise<StacksTransaction> {\n\tconst fields = [...condition.fields];\n\tconst preSignHash = nonSequentialPreSignHash(tx);\n\n\tconst sigBytes = await account.sign(hexToBytes(preSignHash));\n\tconst nextSig = bytesToHex(sigBytes);\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n\treturn {\n\t\t...tx,\n\t\tauth: { ...tx.auth, spendingCondition: newCondition },\n\t};\n}\n\n/** Sequential signing with account */\nasync function signSequentialWithAccount(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\taccount: LocalAccount | CustomAccount,\n\tpublicKeys: string[],\n\tsignerIndex: number,\n): Promise<StacksTransaction> {\n\tconst fields = [...condition.fields];\n\n\t// Replay sighash through existing fields\n\tlet curSigHash = initialSigHash(tx);\n\tfor (const field of fields) {\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n\t}\n\n\t// Fill intervening positions with pubkey fields\n\tfor (let i = fields.length; i < signerIndex; i++) {\n\t\tconst pubKeyField: TransactionAuthField = {\n\t\t\ttype: \"publicKey\",\n\t\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\tdata: publicKeys[i]!,\n\t\t};\n\t\tfields.push(pubKeyField);\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(\n\t\t\tpreSign,\n\t\t\tpubKeyField.pubKeyEncoding,\n\t\t\tpubKeyField.data,\n\t\t);\n\t}\n\n\t// Sign at signerIndex\n\tconst preSign = sigHashPreSign(\n\t\tcurSigHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t);\n\tconst sigBytes = await account.sign(hexToBytes(preSign));\n\tconst nextSig = bytesToHex(sigBytes);\n\tconst nextSigHash = sigHashPostSign(\n\t\tpreSign,\n\t\tPubKeyEncoding.Compressed,\n\t\tnextSig,\n\t);\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\tcurSigHash = nextSigHash;\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n\t// Count signatures so far\n\tconst sigCount = fields.filter((f) => f.type === \"signature\").length;\n\tlet finalCondition = newCondition;\n\n\t// Auto-finalize if enough signatures collected\n\tif (sigCount >= condition.signaturesRequired) {\n\t\tfinalCondition = finalizeMultiSigCondition(\n\t\t\tnewCondition,\n\t\t\tpublicKeys,\n\t\t\tcurSigHash,\n\t\t);\n\t}\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: finalCondition,\n\t\t},\n\t};\n}\n\n/** Fill remaining slots with pubkey fields after all signatures are collected */\nexport function finalizeMultiSig(\n\ttx: StacksTransaction,\n\tpublicKeys: string[],\n): StacksTransaction {\n\tconst condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n\t// Non-sequential: no pubkey gap-filling needed\n\tif (isNonSequential(condition.hashMode)) {\n\t\treturn tx;\n\t}\n\n\tconst curSigHash = replayMultiSigSigHash(tx);\n\tconst finalCondition = finalizeMultiSigCondition(\n\t\tcondition,\n\t\tpublicKeys,\n\t\tcurSigHash,\n\t);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: finalCondition,\n\t\t},\n\t};\n}\n\n/** Internal: finalize remaining pubkey slots (sequential only) */\nfunction finalizeMultiSigCondition(\n\tcondition: MultiSigSpendingCondition,\n\tpublicKeys: string[],\n\tcurSigHash: string,\n): MultiSigSpendingCondition {\n\tconst fields = [...condition.fields];\n\tlet sigHash = curSigHash;\n\n\t// Fill remaining positions\n\tfor (let i = fields.length; i < publicKeys.length; i++) {\n\t\tconst pubKeyField: TransactionAuthField = {\n\t\t\ttype: \"publicKey\",\n\t\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\tdata: publicKeys[i]!,\n\t\t};\n\t\tfields.push(pubKeyField);\n\t\tconst preSign = sigHashPreSign(\n\t\t\tsigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tsigHash = sigHashPostSign(\n\t\t\tpreSign,\n\t\t\tpubKeyField.pubKeyEncoding,\n\t\t\tpubKeyField.data,\n\t\t);\n\t}\n\n\treturn { ...condition, fields };\n}\n\n/** Combine independently-signed non-sequential multi-sig transactions */\nexport function combineMultiSigSignatures(\n\tbaseTx: StacksTransaction,\n\tsignedTxs: StacksTransaction[],\n): StacksTransaction {\n\tconst condition = baseTx.auth.spendingCondition as MultiSigSpendingCondition;\n\n\tif (!isNonSequential(condition.hashMode)) {\n\t\tthrow new Error(\n\t\t\t\"combineMultiSigSignatures only works with non-sequential hash modes (SIP-027)\",\n\t\t);\n\t}\n\n\t// Collect all signature fields from each signed tx\n\tconst seenSigs = new Set<string>();\n\tconst signatures: TransactionAuthField[] = [];\n\n\tfor (const stx of signedTxs) {\n\t\tconst stxCondition = stx.auth\n\t\t\t.spendingCondition as MultiSigSpendingCondition;\n\t\tfor (const field of stxCondition.fields) {\n\t\t\tif (field.type === \"signature\" && !seenSigs.has(field.data)) {\n\t\t\t\tseenSigs.add(field.data);\n\t\t\t\tsignatures.push(field);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (signatures.length === 0) {\n\t\tthrow new Error(\"No signatures found in the provided transactions\");\n\t}\n\n\tconst newCondition: MultiSigSpendingCondition = {\n\t\t...condition,\n\t\tfields: signatures,\n\t};\n\n\treturn {\n\t\t...baseTx,\n\t\tauth: { ...baseTx.auth, spendingCondition: newCondition },\n\t};\n}\n",
7
- "import type { StacksChain } from \"../chains/types.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport { convertPostCondition, fromHex } from \"../postconditions/convert.ts\";\nimport type {\n\tPostConditionInput,\n\tPostConditionMode,\n} from \"../postconditions/types.ts\";\nimport { type IntegerType, intToBigInt } from \"../utils/encoding.ts\";\nimport {\n\tcreateSingleSigSpendingCondition,\n\tcreateSponsoredAuth,\n\tcreateStandardAuth,\n} from \"./authorization.ts\";\nimport { createMultiSigSpendingCondition } from \"./multisig.ts\";\nimport type { MultiSigHashMode, SpendingCondition } from \"./types.ts\";\nimport {\n\tAnchorMode,\n\tClarityVersion,\n\tPayloadType,\n\tPostConditionModeWire,\n\ttype StacksTransaction,\n} from \"./types.ts\";\n\ntype MultiSigOptions = {\n\tpublicKeys?: string[];\n\tsignaturesRequired?: number;\n\thashMode?: MultiSigHashMode;\n};\n\nexport type BuildTokenTransferOptions = MultiSigOptions & {\n\trecipient: string;\n\tamount: IntegerType;\n\tmemo?: string;\n\tfee: IntegerType;\n\tnonce: IntegerType;\n\tpublicKey?: string;\n\tchain?: StacksChain;\n\tpostConditionMode?: PostConditionMode;\n\tpostConditions?: PostConditionInput[];\n\tsponsored?: boolean;\n};\n\nexport type BuildContractCallOptions = MultiSigOptions & {\n\tcontractAddress: string;\n\tcontractName: string;\n\tfunctionName: string;\n\tfunctionArgs: ClarityValue[];\n\tfee: IntegerType;\n\tnonce: IntegerType;\n\tpublicKey?: string;\n\tchain?: StacksChain;\n\tpostConditionMode?: PostConditionMode;\n\tpostConditions?: PostConditionInput[];\n\tsponsored?: boolean;\n};\n\nexport type BuildContractDeployOptions = MultiSigOptions & {\n\tcontractName: string;\n\tcodeBody: string;\n\tclarityVersion?: ClarityVersion;\n\tfee: IntegerType;\n\tnonce: IntegerType;\n\tpublicKey?: string;\n\tchain?: StacksChain;\n\tpostConditionMode?: PostConditionMode;\n\tpostConditions?: PostConditionInput[];\n\tsponsored?: boolean;\n};\n\nfunction resolvePcMode(mode?: PostConditionMode): PostConditionModeWire {\n\tif (mode === \"allow\") return PostConditionModeWire.Allow;\n\tif (mode === \"originator\") return PostConditionModeWire.Originator;\n\treturn PostConditionModeWire.Deny;\n}\n\nfunction convertPostConditions(\n\tpcs?: PostConditionInput[],\n): ReturnType<typeof convertPostCondition>[] {\n\tif (!pcs || pcs.length === 0) return [];\n\treturn pcs.map((pc) =>\n\t\tconvertPostCondition(typeof pc === \"string\" ? fromHex(pc) : pc),\n\t);\n}\n\nimport type { Authorization } from \"./types.ts\";\n\nfunction resolveSpendingCondition(\n\topts: MultiSigOptions & { publicKey?: string },\n\tnonce: bigint,\n\tfee: bigint,\n): SpendingCondition {\n\tif (opts.publicKeys) {\n\t\treturn createMultiSigSpendingCondition(\n\t\t\topts.publicKeys,\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\topts.signaturesRequired!,\n\t\t\tnonce,\n\t\t\tfee,\n\t\t\topts.hashMode,\n\t\t);\n\t}\n\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\treturn createSingleSigSpendingCondition(opts.publicKey!, nonce, fee);\n}\n\nfunction resolveAuth(\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tspendingCondition: any,\n\tsponsored?: boolean,\n): Authorization {\n\treturn sponsored\n\t\t? createSponsoredAuth(spendingCondition)\n\t\t: createStandardAuth(spendingCondition);\n}\n\nfunction resolveVersionAndChainId(chain?: StacksChain): {\n\tversion: number;\n\tchainId: number;\n} {\n\tif (!chain) return { version: 0x00, chainId: 0x00000001 }; // mainnet defaults\n\treturn { version: chain.transactionVersion, chainId: chain.id };\n}\n\nexport function buildTokenTransfer(\n\toptions: BuildTokenTransferOptions,\n): StacksTransaction {\n\tconst { version, chainId } = resolveVersionAndChainId(options.chain);\n\tconst fee = intToBigInt(options.fee);\n\tconst nonce = intToBigInt(options.nonce);\n\n\tconst spendingCondition = resolveSpendingCondition(options, nonce, fee);\n\tconst recipient = Cl.principal(options.recipient);\n\n\tconst tx: StacksTransaction = {\n\t\tversion,\n\t\tchainId,\n\t\tauth: resolveAuth(spendingCondition, options.sponsored),\n\t\tanchorMode: AnchorMode.Any,\n\t\tpostConditionMode: resolvePcMode(options.postConditionMode),\n\t\tpostConditions: convertPostConditions(options.postConditions),\n\t\tpayload: {\n\t\t\tpayloadType: PayloadType.TokenTransfer,\n\t\t\trecipient,\n\t\t\tamount: intToBigInt(options.amount),\n\t\t\tmemo: options.memo ?? \"\",\n\t\t},\n\t};\n\n\tif (options.publicKeys) {\n\t\ttx._multisig = { publicKeys: options.publicKeys };\n\t}\n\treturn tx;\n}\n\nexport function buildContractCall(\n\toptions: BuildContractCallOptions,\n): StacksTransaction {\n\tconst { version, chainId } = resolveVersionAndChainId(options.chain);\n\tconst fee = intToBigInt(options.fee);\n\tconst nonce = intToBigInt(options.nonce);\n\n\tconst spendingCondition = resolveSpendingCondition(options, nonce, fee);\n\n\tconst tx: StacksTransaction = {\n\t\tversion,\n\t\tchainId,\n\t\tauth: resolveAuth(spendingCondition, options.sponsored),\n\t\tanchorMode: AnchorMode.Any,\n\t\tpostConditionMode: resolvePcMode(options.postConditionMode),\n\t\tpostConditions: convertPostConditions(options.postConditions),\n\t\tpayload: {\n\t\t\tpayloadType: PayloadType.ContractCall,\n\t\t\tcontractAddress: options.contractAddress,\n\t\t\tcontractName: options.contractName,\n\t\t\tfunctionName: options.functionName,\n\t\t\tfunctionArgs: options.functionArgs,\n\t\t},\n\t};\n\n\tif (options.publicKeys) {\n\t\ttx._multisig = { publicKeys: options.publicKeys };\n\t}\n\treturn tx;\n}\n\nexport function buildContractDeploy(\n\toptions: BuildContractDeployOptions,\n): StacksTransaction {\n\tconst { version, chainId } = resolveVersionAndChainId(options.chain);\n\tconst fee = intToBigInt(options.fee);\n\tconst nonce = intToBigInt(options.nonce);\n\n\tconst spendingCondition = resolveSpendingCondition(options, nonce, fee);\n\tconst clarityVersion = options.clarityVersion ?? ClarityVersion.Clarity4;\n\n\tconst tx: StacksTransaction = {\n\t\tversion,\n\t\tchainId,\n\t\tauth: resolveAuth(spendingCondition, options.sponsored),\n\t\tanchorMode: AnchorMode.Any,\n\t\tpostConditionMode: resolvePcMode(options.postConditionMode),\n\t\tpostConditions: convertPostConditions(options.postConditions),\n\t\tpayload: {\n\t\t\tpayloadType: PayloadType.VersionedSmartContract,\n\t\t\tclarityVersion,\n\t\t\tcontractName: options.contractName,\n\t\t\tcodeBody: options.codeBody,\n\t\t},\n\t};\n\n\tif (options.publicKeys) {\n\t\ttx._multisig = { publicKeys: options.publicKeys };\n\t}\n\treturn tx;\n}\n",
8
- "import type { CustomAccount, LocalAccount } from \"../accounts/types.ts\";\nimport { bytesToHex, hexToBytes } from \"../utils/encoding.ts\";\nimport { txidFromBytes } from \"../utils/hash.ts\";\nimport {\n\tintoInitialSighashAuth,\n\tnextSignature,\n\tsigHashPostSign,\n\tsigHashPreSign,\n} from \"./authorization.ts\";\nimport { replayMultiSigSigHash } from \"./multisig.ts\";\nimport {\n\tAuthType,\n\ttype SingleSigSpendingCondition,\n\ttype SponsoredAuthorization,\n\ttype StacksTransaction,\n} from \"./types.ts\";\nimport { serializeTransaction } from \"./wire/serialize.ts\";\n\nfunction txid(tx: StacksTransaction): string {\n\treturn txidFromBytes(serializeTransaction(tx));\n}\n\n/** Compute the initial sighash for a transaction */\nexport function signBegin(tx: StacksTransaction): string {\n\tconst cleared: StacksTransaction = {\n\t\t...tx,\n\t\tauth: intoInitialSighashAuth(tx.auth),\n\t};\n\treturn txid(cleared);\n}\n\n/** Sign a single-sig transaction with a private key, returning the signed transaction */\nexport function signTransaction(\n\ttx: StacksTransaction,\n\tprivateKey: string,\n): StacksTransaction {\n\tconst sigHash = signBegin(tx);\n\tconst condition = tx.auth.spendingCondition as SingleSigSpendingCondition;\n\n\t// Origin always signs with AuthType.Standard (even for sponsored txs)\n\tconst { nextSig } = nextSignature(\n\t\tsigHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t\tprivateKey,\n\t);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: {\n\t\t\t\t...condition,\n\t\t\t\tsignature: nextSig,\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** Sign a single-sig transaction using an account (LocalAccount or CustomAccount) */\nexport async function signTransactionWithAccount(\n\ttx: StacksTransaction,\n\taccount: LocalAccount | CustomAccount,\n): Promise<StacksTransaction> {\n\tconst sigHash = signBegin(tx);\n\tconst condition = tx.auth.spendingCondition as SingleSigSpendingCondition;\n\n\t// Origin always signs with AuthType.Standard (even for sponsored txs)\n\tconst sigHashPre = sigHashPreSign(\n\t\tsigHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t);\n\n\t// account.sign returns 65-byte VRS (recovery + r + s)\n\tconst sigBytes = await account.sign(hexToBytes(sigHashPre));\n\tconst nextSig = bytesToHex(sigBytes);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: {\n\t\t\t\t...condition,\n\t\t\t\tsignature: nextSig,\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** Get the txid of a transaction */\nexport function getTransactionId(tx: StacksTransaction): string {\n\treturn txid(tx);\n}\n\n/** Reconstruct the sighash after origin signing (needed for sponsor signing) */\nexport function getOriginSigHash(tx: StacksTransaction): string {\n\tconst condition = tx.auth.spendingCondition;\n\n\t// Multi-sig: replay through all fields\n\tif (\"fields\" in condition) {\n\t\treturn replayMultiSigSigHash(tx);\n\t}\n\n\t// Single-sig\n\tconst initialSigHash = signBegin(tx);\n\tconst sc = condition as SingleSigSpendingCondition;\n\tconst preSign = sigHashPreSign(\n\t\tinitialSigHash,\n\t\tAuthType.Standard,\n\t\tsc.fee,\n\t\tsc.nonce,\n\t);\n\treturn sigHashPostSign(preSign, sc.keyEncoding, sc.signature);\n}\n\n/** Sign a sponsored transaction as the sponsor with a private key */\nexport function signSponsor(\n\ttx: StacksTransaction,\n\tprivateKey: string,\n): StacksTransaction {\n\tif (tx.auth.authType !== AuthType.Sponsored) {\n\t\tthrow new Error(\"Transaction must be sponsored\");\n\t}\n\tconst auth = tx.auth as SponsoredAuthorization;\n\tconst sponsorCondition =\n\t\tauth.sponsorSpendingCondition as SingleSigSpendingCondition;\n\tconst originSigHash = getOriginSigHash(tx);\n\n\tconst { nextSig } = nextSignature(\n\t\toriginSigHash,\n\t\tAuthType.Sponsored,\n\t\tsponsorCondition.fee,\n\t\tsponsorCondition.nonce,\n\t\tprivateKey,\n\t);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...auth,\n\t\t\tsponsorSpendingCondition: {\n\t\t\t\t...sponsorCondition,\n\t\t\t\tsignature: nextSig,\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** Sign a sponsored transaction as the sponsor using an account */\nexport async function signSponsorWithAccount(\n\ttx: StacksTransaction,\n\taccount: LocalAccount | CustomAccount,\n): Promise<StacksTransaction> {\n\tif (tx.auth.authType !== AuthType.Sponsored) {\n\t\tthrow new Error(\"Transaction must be sponsored\");\n\t}\n\tconst auth = tx.auth as SponsoredAuthorization;\n\tconst sponsorCondition =\n\t\tauth.sponsorSpendingCondition as SingleSigSpendingCondition;\n\tconst originSigHash = getOriginSigHash(tx);\n\n\tconst sigHashPre = sigHashPreSign(\n\t\toriginSigHash,\n\t\tAuthType.Sponsored,\n\t\tsponsorCondition.fee,\n\t\tsponsorCondition.nonce,\n\t);\n\n\tconst sigBytes = await account.sign(hexToBytes(sigHashPre));\n\tconst nextSig = bytesToHex(sigBytes);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...auth,\n\t\t\tsponsorSpendingCondition: {\n\t\t\t\t...sponsorCondition,\n\t\t\t\tsignature: nextSig,\n\t\t\t},\n\t\t},\n\t};\n}\n"
9
- ],
10
- "mappings": ";AAAqB,IAArB;AACuB,IAAvB;AAC6D,IAA7D;AAsBA,qBAAI,iBAAiB,CAAC,QAAoB,SAAuB;AAAA,EAChE,MAAM,IAAI,iBAAK,OAA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AM,OAAO,GAAG;AAAA,EAChB,MAAM,mBACL,KAAK;AAAA,EACN,MAAM,gBAAgB,iBAAiB,EAAE;AAAA,EAEzC,MAAM,aAAa,eAClB,eACA,SAAS,WACT,iBAAiB,KACjB,iBAAiB,KAClB;AAAA,EAEA,MAAM,WAAW,MAAM,QAAQ,KAAK,WAAW,UAAU,CAAC;AAAA,EAC1D,MAAM,UAAU,WAAW,QAAQ;AAAA,EAEnC,OAAO;AAAA,OACH;AAAA,IACH,MAAM;AAAA,SACF;AAAA,MACH,0BAA0B;AAAA,WACtB;AAAA,QACH,WAAW;AAAA,MACZ;AAAA,IACD;AAAA,EACD;AAAA;",
11
- "debugId": "4803818E842AF84364756E2164756E21",
12
- "names": []
13
- }
@@ -1,410 +0,0 @@
1
- // src/clarity/types.ts
2
- var ClarityWireType = {
3
- int: 0,
4
- uint: 1,
5
- buffer: 2,
6
- true: 3,
7
- false: 4,
8
- address: 5,
9
- contract: 6,
10
- ok: 7,
11
- err: 8,
12
- none: 9,
13
- some: 10,
14
- list: 11,
15
- tuple: 12,
16
- ascii: 13,
17
- utf8: 14
18
- };
19
- var wireTypeToClarity = Object.fromEntries(Object.entries(ClarityWireType).map(([k, v]) => [v, k]));
20
- function clarityTypeFromByte(byte) {
21
- const type = wireTypeToClarity[byte];
22
- if (!type)
23
- throw new Error(`Unknown clarity wire type: ${byte}`);
24
- return type;
25
- }
26
-
27
- // src/clarity/serialize.ts
28
- var CLARITY_INT_SIZE = 128n;
29
- var CLARITY_INT_BYTE_SIZE = 16;
30
- function typeIdByte(type) {
31
- return ClarityWireType[type];
32
- }
33
- function withTypeId(type, bytes) {
34
- return concatBytes(new Uint8Array([typeIdByte(type)]), bytes);
35
- }
36
- function serializeAddress(c32Address) {
37
- const [version, hash160] = c32addressDecode(c32Address);
38
- return concatBytes(new Uint8Array([version]), hexToBytes(hash160));
39
- }
40
- function serializeLPString(str, prefixBytes = 1) {
41
- const content = utf8ToBytes(str);
42
- const lengthPrefix = hexToBytes(intToHex(content.byteLength, prefixBytes));
43
- return concatBytes(lengthPrefix, content);
44
- }
45
- function serializeCVBytes(value) {
46
- switch (value.type) {
47
- case "true":
48
- case "false":
49
- return new Uint8Array([typeIdByte(value.type)]);
50
- case "int": {
51
- const bytes = bigIntToBytes(toTwos(BigInt(value.value), CLARITY_INT_SIZE), CLARITY_INT_BYTE_SIZE);
52
- return withTypeId(value.type, bytes);
53
- }
54
- case "uint": {
55
- const bytes = bigIntToBytes(BigInt(value.value), CLARITY_INT_BYTE_SIZE);
56
- return withTypeId(value.type, bytes);
57
- }
58
- case "buffer": {
59
- const bufBytes = hexToBytes(value.value);
60
- return withTypeId(value.type, concatBytes(writeUInt32BE(bufBytes.length), bufBytes));
61
- }
62
- case "none":
63
- return new Uint8Array([typeIdByte(value.type)]);
64
- case "some":
65
- return withTypeId(value.type, serializeCVBytes(value.value));
66
- case "ok":
67
- case "err":
68
- return withTypeId(value.type, serializeCVBytes(value.value));
69
- case "address":
70
- return withTypeId(value.type, serializeAddress(value.value));
71
- case "contract": {
72
- const [addr, name] = value.value.split(".");
73
- if (!addr || !name)
74
- throw new Error(`Invalid contract principal: ${value.value}`);
75
- return withTypeId(value.type, concatBytes(serializeAddress(addr), serializeLPString(name)));
76
- }
77
- case "list": {
78
- const parts = [writeUInt32BE(value.value.length)];
79
- for (const item of value.value) {
80
- parts.push(serializeCVBytes(item));
81
- }
82
- return withTypeId(value.type, concatBytes(...parts));
83
- }
84
- case "tuple": {
85
- const keys = Object.keys(value.value).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
86
- const parts = [writeUInt32BE(keys.length)];
87
- for (const key of keys) {
88
- parts.push(serializeLPString(key));
89
- parts.push(serializeCVBytes(value.value[key]));
90
- }
91
- return withTypeId(value.type, concatBytes(...parts));
92
- }
93
- case "ascii": {
94
- const strBytes = asciiToBytes(value.value);
95
- return withTypeId(value.type, concatBytes(writeUInt32BE(strBytes.length), strBytes));
96
- }
97
- case "utf8": {
98
- const strBytes = utf8ToBytes(value.value);
99
- return withTypeId(value.type, concatBytes(writeUInt32BE(strBytes.length), strBytes));
100
- }
101
- default:
102
- throw new Error("Cannot serialize unknown clarity type");
103
- }
104
- }
105
- function serializeCV(value) {
106
- return bytesToHex(serializeCVBytes(value));
107
- }
108
-
109
- // src/errors/transaction.ts
110
- class TransactionError extends BaseError {
111
- name = "TransactionError";
112
- }
113
-
114
- class BroadcastError extends BaseError {
115
- name = "BroadcastError";
116
- txid;
117
- reason;
118
- reasonData;
119
- constructor(message, options) {
120
- super(message, options);
121
- this.txid = options?.txid;
122
- this.reason = options?.reason;
123
- this.reasonData = options?.reasonData;
124
- }
125
- }
126
-
127
- class TransactionAbortedError extends BaseError {
128
- name = "TransactionAbortedError";
129
- receipt;
130
- constructor(message, options) {
131
- super(message, options);
132
- this.receipt = options.receipt;
133
- }
134
- }
135
-
136
- class TransactionDroppedError extends BaseError {
137
- name = "TransactionDroppedError";
138
- txid;
139
- constructor(message, options) {
140
- super(message, options);
141
- this.txid = options.txid;
142
- }
143
- }
144
-
145
- class WaitForTransactionTimeoutError extends BaseError {
146
- name = "WaitForTransactionTimeoutError";
147
- txid;
148
- constructor(message, options) {
149
- super(message, options);
150
- this.txid = options.txid;
151
- }
152
- }
153
-
154
- class SerializationError extends BaseError {
155
- name = "SerializationError";
156
- }
157
-
158
- class SigningError extends BaseError {
159
- name = "SigningError";
160
- }
161
-
162
- // src/utils/bytes-reader.ts
163
- class BytesReader {
164
- data;
165
- offset = 0;
166
- constructor(data) {
167
- this.data = data;
168
- }
169
- remaining() {
170
- return this.data.length - this.offset;
171
- }
172
- ensure(length) {
173
- if (this.offset + length > this.data.length) {
174
- throw new SerializationError(`Buffer underflow: need ${length} bytes at offset ${this.offset}, have ${this.data.length}`);
175
- }
176
- }
177
- readUInt8() {
178
- this.ensure(1);
179
- return this.data[this.offset++];
180
- }
181
- readUInt16BE() {
182
- this.ensure(2);
183
- const val = (this.data[this.offset] << 8 | this.data[this.offset + 1]) >>> 0;
184
- this.offset += 2;
185
- return val;
186
- }
187
- readUInt32BE() {
188
- this.ensure(4);
189
- const val = (this.data[this.offset] << 24 | this.data[this.offset + 1] << 16 | this.data[this.offset + 2] << 8 | this.data[this.offset + 3]) >>> 0;
190
- this.offset += 4;
191
- return val;
192
- }
193
- readBytes(length) {
194
- this.ensure(length);
195
- const slice = this.data.slice(this.offset, this.offset + length);
196
- this.offset += length;
197
- return slice;
198
- }
199
- readBigUInt64BE() {
200
- const hex = bytesToHex(this.readBytes(8));
201
- return hex.length > 0 ? BigInt(`0x${hex}`) : 0n;
202
- }
203
- }
204
-
205
- // src/clarity/deserialize.ts
206
- function readAddress(reader) {
207
- const version = reader.readUInt8();
208
- const hash160 = bytesToHex(reader.readBytes(20));
209
- return c32address(version, hash160);
210
- }
211
- function readLPString(reader, prefixBytes = 1) {
212
- let length = 0;
213
- for (let i = 0;i < prefixBytes; i++) {
214
- length = length << 8 | reader.readUInt8();
215
- }
216
- return bytesToUtf8(reader.readBytes(length));
217
- }
218
- var MAX_CV_DEPTH = 64;
219
- var MIN_LIST_ITEM_BYTES = 1;
220
- var MIN_TUPLE_ENTRY_BYTES = 2;
221
- function checkCount(reader, count, minBytes) {
222
- if (count * minBytes > reader.remaining()) {
223
- throw new SerializationError(`Clarity value declares ${count} elements but only ${reader.remaining()} bytes remain`);
224
- }
225
- }
226
- function readCV(reader, depth = 0) {
227
- if (depth > MAX_CV_DEPTH) {
228
- throw new SerializationError(`Clarity value nests deeper than ${MAX_CV_DEPTH} levels`);
229
- }
230
- const typeByte = reader.readUInt8();
231
- const type = clarityTypeFromByte(typeByte);
232
- switch (type) {
233
- case "int":
234
- return intCV(bytesToTwosBigInt(reader.readBytes(16)));
235
- case "uint":
236
- return uintCV(reader.readBytes(16));
237
- case "true":
238
- return trueCV();
239
- case "false":
240
- return falseCV();
241
- case "buffer": {
242
- const len = reader.readUInt32BE();
243
- return bufferCV(reader.readBytes(len));
244
- }
245
- case "none":
246
- return noneCV();
247
- case "some":
248
- return someCV(readCV(reader, depth + 1));
249
- case "ok":
250
- return responseOkCV(readCV(reader, depth + 1));
251
- case "err":
252
- return responseErrorCV(readCV(reader, depth + 1));
253
- case "address":
254
- return standardPrincipalCV(readAddress(reader));
255
- case "contract": {
256
- const addr = readAddress(reader);
257
- const name = readLPString(reader);
258
- return contractPrincipalCV(addr, name);
259
- }
260
- case "list": {
261
- const len = reader.readUInt32BE();
262
- checkCount(reader, len, MIN_LIST_ITEM_BYTES);
263
- const items = [];
264
- for (let i = 0;i < len; i++) {
265
- items.push(readCV(reader, depth + 1));
266
- }
267
- return listCV(items);
268
- }
269
- case "tuple": {
270
- const len = reader.readUInt32BE();
271
- checkCount(reader, len, MIN_TUPLE_ENTRY_BYTES);
272
- const data = {};
273
- for (let i = 0;i < len; i++) {
274
- const key = readLPString(reader);
275
- data[key] = readCV(reader, depth + 1);
276
- }
277
- return tupleCV(data);
278
- }
279
- case "ascii": {
280
- const len = reader.readUInt32BE();
281
- return stringAsciiCV(bytesToAscii(reader.readBytes(len)));
282
- }
283
- case "utf8": {
284
- const len = reader.readUInt32BE();
285
- return stringUtf8CV(bytesToUtf8(reader.readBytes(len)));
286
- }
287
- default:
288
- throw new SerializationError(`Cannot deserialize unknown clarity type: ${type}`);
289
- }
290
- }
291
- function deserializeCVBytes(input) {
292
- const bytes = typeof input === "string" ? hexToBytes(without0x(input)) : input;
293
- return readCV(new BytesReader(bytes));
294
- }
295
- function deserializeCV(input) {
296
- return deserializeCVBytes(input);
297
- }
298
-
299
- // src/clarity/values.ts
300
- var MAX_U128 = BigInt("0xffffffffffffffffffffffffffffffff");
301
- var MIN_I128 = BigInt("-170141183460469231731687303715884105728");
302
- var MAX_I128 = BigInt("0x7fffffffffffffffffffffffffffffff");
303
- function intCV(value) {
304
- let v = value;
305
- if (typeof v === "string" && v.toLowerCase().startsWith("0x")) {
306
- v = bytesToTwosBigInt(hexToBytes(v));
307
- }
308
- if (v instanceof Uint8Array)
309
- v = bytesToTwosBigInt(v);
310
- const n = intToBigInt(v);
311
- if (n > MAX_I128)
312
- throw new RangeError(`Int exceeds max i128: ${MAX_I128}`);
313
- if (n < MIN_I128)
314
- throw new RangeError(`Int below min i128: ${MIN_I128}`);
315
- return { type: "int", value: n };
316
- }
317
- function uintCV(value) {
318
- const n = intToBigInt(value);
319
- if (n < 0n)
320
- throw new RangeError("Cannot construct unsigned int from negative value");
321
- if (n > MAX_U128)
322
- throw new RangeError(`UInt exceeds max u128: ${MAX_U128}`);
323
- return { type: "uint", value: n };
324
- }
325
- var trueCV = () => ({ type: "true" });
326
- var falseCV = () => ({ type: "false" });
327
- var boolCV = (v) => v ? trueCV() : falseCV();
328
- function bufferCV(buffer) {
329
- if (buffer.byteLength > 1048576) {
330
- throw new Error("Buffer exceeds max size of 1MB");
331
- }
332
- return { type: "buffer", value: bytesToHex(buffer) };
333
- }
334
- function standardPrincipalCV(address) {
335
- const [version, hash160] = c32addressDecode(address);
336
- const normalized = c32address(version, hash160);
337
- return { type: "address", value: normalized };
338
- }
339
- function contractPrincipalCV(address, contractName) {
340
- const [version, hash160] = c32addressDecode(address);
341
- const normalized = c32address(version, hash160);
342
- if (utf8ToBytes(contractName).byteLength >= 128) {
343
- throw new Error("Contract name must be less than 128 bytes");
344
- }
345
- return { type: "contract", value: `${normalized}.${contractName}` };
346
- }
347
- function noneCV() {
348
- return { type: "none" };
349
- }
350
- function someCV(value) {
351
- return { type: "some", value };
352
- }
353
- function responseOkCV(value) {
354
- return { type: "ok", value };
355
- }
356
- function responseErrorCV(value) {
357
- return { type: "err", value };
358
- }
359
- function listCV(values) {
360
- return { type: "list", value: values };
361
- }
362
- function tupleCV(data) {
363
- for (const key in data) {
364
- if (!isClarityName(key)) {
365
- throw new Error(`"${key}" is not a valid Clarity name`);
366
- }
367
- }
368
- return { type: "tuple", value: data };
369
- }
370
- function stringAsciiCV(value) {
371
- return { type: "ascii", value };
372
- }
373
- function stringUtf8CV(value) {
374
- return { type: "utf8", value };
375
- }
376
- var Cl = {
377
- int: intCV,
378
- uint: uintCV,
379
- bool: boolCV,
380
- principal(address) {
381
- const parsed = parsePrincipal(address);
382
- if (!parsed)
383
- throw new Error(`Invalid principal: ${address}`);
384
- return parsed.contractName ? contractPrincipalCV(parsed.address, parsed.contractName) : standardPrincipalCV(parsed.address);
385
- },
386
- address(address) {
387
- return Cl.principal(address);
388
- },
389
- contractPrincipal: contractPrincipalCV,
390
- standardPrincipal: standardPrincipalCV,
391
- buffer: bufferCV,
392
- bufferFromHex: (hex) => bufferCV(hexToBytes(hex)),
393
- bufferFromAscii: (ascii) => bufferCV(asciiToBytes(ascii)),
394
- bufferFromUtf8: (utf8) => bufferCV(utf8ToBytes(utf8)),
395
- none: noneCV,
396
- some: someCV,
397
- ok: responseOkCV,
398
- error: responseErrorCV,
399
- list: listCV,
400
- tuple: tupleCV,
401
- stringAscii: stringAsciiCV,
402
- stringUtf8: stringUtf8CV,
403
- serialize(value) {
404
- return bytesToHex(serializeCVBytes(value));
405
- },
406
- deserialize: deserializeCVBytes
407
- };
408
-
409
- //# debugId=6A1B0540CCEA27D364756E2164756E21
410
- //# sourceMappingURL=stacks-s5vej5z6.cjs.map
@@ -1,15 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/clarity/types.ts", "../src/clarity/serialize.ts", "../src/errors/transaction.ts", "../src/utils/bytes-reader.ts", "../src/clarity/deserialize.ts", "../src/clarity/values.ts"],
4
- "sourcesContent": [
5
- "export type ClarityType =\n\t| \"int\"\n\t| \"uint\"\n\t| \"buffer\"\n\t| \"true\"\n\t| \"false\"\n\t| \"address\"\n\t| \"contract\"\n\t| \"ok\"\n\t| \"err\"\n\t| \"none\"\n\t| \"some\"\n\t| \"list\"\n\t| \"tuple\"\n\t| \"ascii\"\n\t| \"utf8\";\n\n/** Wire type IDs matching the Stacks binary format (SIP-005) */\nexport const ClarityWireType = {\n\tint: 0x00,\n\tuint: 0x01,\n\tbuffer: 0x02,\n\ttrue: 0x03,\n\tfalse: 0x04,\n\taddress: 0x05,\n\tcontract: 0x06,\n\tok: 0x07,\n\terr: 0x08,\n\tnone: 0x09,\n\tsome: 0x0a,\n\tlist: 0x0b,\n\ttuple: 0x0c,\n\tascii: 0x0d,\n\tutf8: 0x0e,\n} as const satisfies Record<ClarityType, number>;\n\n/** Reverse lookup: wire byte → ClarityType string */\nconst wireTypeToClarity = Object.fromEntries(\n\tObject.entries(ClarityWireType).map(([k, v]) => [v, k]),\n) as Record<number, ClarityType>;\n\nexport function clarityTypeFromByte(byte: number): ClarityType {\n\tconst type = wireTypeToClarity[byte];\n\tif (!type) throw new Error(`Unknown clarity wire type: ${byte}`);\n\treturn 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\treadonly type: \"some\";\n\treadonly value: ClarityValue;\n};\nexport type OptionalCV = NoneCV | SomeCV;\nexport type ResponseOkCV = {\n\treadonly type: \"ok\";\n\treadonly value: ClarityValue;\n};\nexport type ResponseErrorCV = {\n\treadonly type: \"err\";\n\treadonly value: ClarityValue;\n};\nexport type ResponseCV = ResponseOkCV | ResponseErrorCV;\nexport type StandardPrincipalCV = {\n\treadonly type: \"address\";\n\treadonly value: string;\n};\nexport type ContractPrincipalCV = {\n\treadonly type: \"contract\";\n\treadonly value: string; // \"address.name\"\n};\nexport type PrincipalCV = StandardPrincipalCV | ContractPrincipalCV;\nexport type ListCV = {\n\ttype: \"list\";\n\tvalue: ClarityValue[];\n};\nexport type TupleData = {\n\t[key: string]: ClarityValue;\n};\nexport type TupleCV = {\n\ttype: \"tuple\";\n\tvalue: TupleData;\n};\nexport type StringAsciiCV = {\n\treadonly type: \"ascii\";\n\treadonly value: string;\n};\nexport type StringUtf8CV = {\n\treadonly type: \"utf8\";\n\treadonly value: string;\n};\n\nexport type ClarityValue =\n\t| IntCV\n\t| UIntCV\n\t| BooleanCV\n\t| BufferCV\n\t| NoneCV\n\t| SomeCV\n\t| ResponseOkCV\n\t| ResponseErrorCV\n\t| StandardPrincipalCV\n\t| ContractPrincipalCV\n\t| ListCV\n\t| TupleCV\n\t| StringAsciiCV\n\t| StringUtf8CV;\n",
6
- "import { c32addressDecode } from \"../utils/c32.ts\";\nimport {\n\tasciiToBytes,\n\tbigIntToBytes,\n\tbytesToHex,\n\tconcatBytes,\n\thexToBytes,\n\tintToHex,\n\ttoTwos,\n\tutf8ToBytes,\n\twriteUInt32BE,\n} from \"../utils/encoding.ts\";\nimport {\n\ttype ClarityType,\n\ttype ClarityValue,\n\tClarityWireType,\n} from \"./types.ts\";\n\nconst CLARITY_INT_SIZE = 128n;\nconst CLARITY_INT_BYTE_SIZE = 16;\n\nfunction typeIdByte(type: ClarityType): number {\n\treturn ClarityWireType[type];\n}\n\nfunction withTypeId(type: ClarityType, bytes: Uint8Array): Uint8Array {\n\treturn concatBytes(new Uint8Array([typeIdByte(type)]), bytes);\n}\n\nfunction serializeAddress(c32Address: string): Uint8Array {\n\tconst [version, hash160] = c32addressDecode(c32Address);\n\treturn concatBytes(new Uint8Array([version]), hexToBytes(hash160));\n}\n\nfunction serializeLPString(str: string, prefixBytes = 1): Uint8Array {\n\tconst content = utf8ToBytes(str);\n\tconst lengthPrefix = hexToBytes(intToHex(content.byteLength, prefixBytes));\n\treturn concatBytes(lengthPrefix, content);\n}\n\nexport function serializeCVBytes(value: ClarityValue): Uint8Array {\n\tswitch (value.type) {\n\t\tcase \"true\":\n\t\tcase \"false\":\n\t\t\treturn new Uint8Array([typeIdByte(value.type)]);\n\n\t\tcase \"int\": {\n\t\t\tconst bytes = bigIntToBytes(\n\t\t\t\ttoTwos(BigInt(value.value), CLARITY_INT_SIZE),\n\t\t\t\tCLARITY_INT_BYTE_SIZE,\n\t\t\t);\n\t\t\treturn withTypeId(value.type, bytes);\n\t\t}\n\n\t\tcase \"uint\": {\n\t\t\tconst bytes = bigIntToBytes(BigInt(value.value), CLARITY_INT_BYTE_SIZE);\n\t\t\treturn withTypeId(value.type, bytes);\n\t\t}\n\n\t\tcase \"buffer\": {\n\t\t\tconst bufBytes = hexToBytes(value.value);\n\t\t\treturn withTypeId(\n\t\t\t\tvalue.type,\n\t\t\t\tconcatBytes(writeUInt32BE(bufBytes.length), bufBytes),\n\t\t\t);\n\t\t}\n\n\t\tcase \"none\":\n\t\t\treturn new Uint8Array([typeIdByte(value.type)]);\n\n\t\tcase \"some\":\n\t\t\treturn withTypeId(value.type, serializeCVBytes(value.value));\n\n\t\tcase \"ok\":\n\t\tcase \"err\":\n\t\t\treturn withTypeId(value.type, serializeCVBytes(value.value));\n\n\t\tcase \"address\":\n\t\t\treturn withTypeId(value.type, serializeAddress(value.value));\n\n\t\tcase \"contract\": {\n\t\t\tconst [addr, name] = value.value.split(\".\");\n\t\t\tif (!addr || !name)\n\t\t\t\tthrow new Error(`Invalid contract principal: ${value.value}`);\n\t\t\treturn withTypeId(\n\t\t\t\tvalue.type,\n\t\t\t\tconcatBytes(serializeAddress(addr), serializeLPString(name)),\n\t\t\t);\n\t\t}\n\n\t\tcase \"list\": {\n\t\t\tconst parts: Uint8Array[] = [writeUInt32BE(value.value.length)];\n\t\t\tfor (const item of value.value) {\n\t\t\t\tparts.push(serializeCVBytes(item));\n\t\t\t}\n\t\t\treturn withTypeId(value.type, concatBytes(...parts));\n\t\t}\n\n\t\tcase \"tuple\": {\n\t\t\t// Clarity orders tuple fields as a BTreeMap over the raw name bytes.\n\t\t\t// Code-unit comparison equals byte order for the ASCII name grammar;\n\t\t\t// localeCompare does not, and would change the SIP-018 hash.\n\t\t\tconst keys = Object.keys(value.value).sort((a, b) =>\n\t\t\t\ta < b ? -1 : a > b ? 1 : 0,\n\t\t\t);\n\t\t\tconst parts: Uint8Array[] = [writeUInt32BE(keys.length)];\n\t\t\tfor (const key of keys) {\n\t\t\t\tparts.push(serializeLPString(key));\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\t\tparts.push(serializeCVBytes(value.value[key]!));\n\t\t\t}\n\t\t\treturn withTypeId(value.type, concatBytes(...parts));\n\t\t}\n\n\t\tcase \"ascii\": {\n\t\t\tconst strBytes = asciiToBytes(value.value);\n\t\t\treturn withTypeId(\n\t\t\t\tvalue.type,\n\t\t\t\tconcatBytes(writeUInt32BE(strBytes.length), strBytes),\n\t\t\t);\n\t\t}\n\n\t\tcase \"utf8\": {\n\t\t\tconst strBytes = utf8ToBytes(value.value);\n\t\t\treturn withTypeId(\n\t\t\t\tvalue.type,\n\t\t\t\tconcatBytes(writeUInt32BE(strBytes.length), strBytes),\n\t\t\t);\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new Error(\"Cannot serialize unknown clarity type\");\n\t}\n}\n\nexport function serializeCV(value: ClarityValue): string {\n\treturn bytesToHex(serializeCVBytes(value));\n}\n",
7
- "import { BaseError } from \"./base.ts\";\n\nexport class TransactionError extends BaseError {\n\toverride name = \"TransactionError\";\n}\n\n/**\n * Rejection reasons a stacks-node returns from `POST /v2/transactions`.\n * Wire strings from stacks-core `MemPoolRejection::into_json`\n * (`stackslib/src/chainstate/stacks/db/blocks.rs`).\n */\nexport type TxRejectionReason =\n\t| \"Serialization\"\n\t| \"Deserialization\"\n\t| \"SignatureValidation\"\n\t| \"BadNonce\"\n\t| \"ConflictingNonceInMempool\"\n\t| \"TooMuchChaining\"\n\t| \"FeeTooLow\"\n\t| \"NotEnoughFunds\"\n\t| \"NoSuchContract\"\n\t| \"NoSuchPublicFunction\"\n\t| \"BadFunctionArgument\"\n\t| \"ContractAlreadyExists\"\n\t| \"BadTransactionVersion\"\n\t| \"TransferRecipientCannotEqualSender\"\n\t| \"TransferAmountMustBePositive\"\n\t| \"PoisonMicroblocksDoNotConflict\"\n\t| \"PoisonMicroblockHasUnknownPubKeyHash\"\n\t| \"PoisonMicroblockIsInvalid\"\n\t| \"BadAddressVersionByte\"\n\t| \"NoCoinbaseViaMempool\"\n\t| \"NoTenureChangeViaMempool\"\n\t| \"EstimatorError\"\n\t| \"TemporarilyBlacklisted\"\n\t| \"ServerFailureNoSuchChainTip\"\n\t| \"ServerFailureDatabase\"\n\t| \"ServerFailureOther\";\n\nexport class BroadcastError extends BaseError {\n\toverride name = \"BroadcastError\";\n\ttxid?: string;\n\t// `(string & {})` keeps forward-compat with reasons newer nodes may add\n\t// while preserving literal-union completions.\n\treason?: TxRejectionReason | (string & {});\n\t/** Node-provided detail; shape varies per reason (see stacks-core RPC docs). */\n\treasonData?: unknown;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions?: {\n\t\t\tcause?: Error;\n\t\t\ttxid?: string;\n\t\t\treason?: string;\n\t\t\treasonData?: unknown;\n\t\t},\n\t) {\n\t\tsuper(message, options);\n\t\tthis.txid = options?.txid;\n\t\tthis.reason = options?.reason;\n\t\tthis.reasonData = options?.reasonData;\n\t}\n}\n\n/** The transaction was mined but its execution aborted (runtime error or failed post-condition). */\nexport class TransactionAbortedError extends BaseError {\n\toverride name = \"TransactionAbortedError\";\n\t/** The abort receipt (status, block info, raw source response). */\n\treceipt: unknown;\n\n\tconstructor(message: string, options: { receipt: unknown; cause?: Error }) {\n\t\tsuper(message, options);\n\t\tthis.receipt = options.receipt;\n\t}\n}\n\n/** The transaction left the mempool without being mined (dropped/replaced). */\nexport class TransactionDroppedError extends BaseError {\n\toverride name = \"TransactionDroppedError\";\n\ttxid: string;\n\n\tconstructor(message: string, options: { txid: string; cause?: Error }) {\n\t\tsuper(message, options);\n\t\tthis.txid = options.txid;\n\t}\n}\n\n/** waitForTransactionReceipt gave up before the tx reached the requested state. */\nexport class WaitForTransactionTimeoutError extends BaseError {\n\toverride name = \"WaitForTransactionTimeoutError\";\n\ttxid: string;\n\n\tconstructor(message: string, options: { txid: string; cause?: Error }) {\n\t\tsuper(message, options);\n\t\tthis.txid = options.txid;\n\t}\n}\n\nexport class SerializationError extends BaseError {\n\toverride name = \"SerializationError\";\n}\n\nexport class SigningError extends BaseError {\n\toverride name = \"SigningError\";\n}\n",
8
- "import { SerializationError } from \"../errors/transaction.ts\";\nimport { bytesToHex } from \"./encoding.ts\";\n\nexport class BytesReader {\n\tprivate data: Uint8Array;\n\tpublic offset = 0;\n\n\tconstructor(data: Uint8Array) {\n\t\tthis.data = data;\n\t}\n\n\t/** Bytes left after the cursor. */\n\tremaining(): number {\n\t\treturn this.data.length - this.offset;\n\t}\n\n\tprivate ensure(length: number): void {\n\t\tif (this.offset + length > this.data.length) {\n\t\t\tthrow new SerializationError(\n\t\t\t\t`Buffer underflow: need ${length} bytes at offset ${this.offset}, have ${this.data.length}`,\n\t\t\t);\n\t\t}\n\t}\n\n\treadUInt8(): number {\n\t\tthis.ensure(1);\n\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\treturn this.data[this.offset++]!;\n\t}\n\n\treadUInt16BE(): number {\n\t\tthis.ensure(2);\n\t\tconst val =\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\t\t((this.data[this.offset]! << 8) | this.data[this.offset + 1]!) >>> 0;\n\t\tthis.offset += 2;\n\t\treturn val;\n\t}\n\n\treadUInt32BE(): number {\n\t\tthis.ensure(4);\n\t\tconst val =\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\t\t((this.data[this.offset]! << 24) |\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\t\t\t(this.data[this.offset + 1]! << 16) |\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\t\t\t(this.data[this.offset + 2]! << 8) |\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\t\t\tthis.data[this.offset + 3]!) >>>\n\t\t\t0;\n\t\tthis.offset += 4;\n\t\treturn val;\n\t}\n\n\treadBytes(length: number): Uint8Array {\n\t\tthis.ensure(length);\n\t\tconst slice = this.data.slice(this.offset, this.offset + length);\n\t\tthis.offset += length;\n\t\treturn slice;\n\t}\n\n\treadBigUInt64BE(): bigint {\n\t\tconst hex = bytesToHex(this.readBytes(8));\n\t\treturn hex.length > 0 ? BigInt(`0x${hex}`) : 0n;\n\t}\n}\n",
9
- "import { SerializationError } from \"../errors/transaction.ts\";\nimport { BytesReader } from \"../utils/bytes-reader.ts\";\nimport { c32address } from \"../utils/c32.ts\";\nimport {\n\tbytesToAscii,\n\tbytesToHex,\n\tbytesToTwosBigInt,\n\tbytesToUtf8,\n\thexToBytes,\n\twithout0x,\n} from \"../utils/encoding.ts\";\nimport { type ClarityValue, clarityTypeFromByte } from \"./types.ts\";\nimport {\n\tbufferCV,\n\tcontractPrincipalCV,\n\tfalseCV,\n\tintCV,\n\tlistCV,\n\tnoneCV,\n\tresponseErrorCV,\n\tresponseOkCV,\n\tsomeCV,\n\tstandardPrincipalCV,\n\tstringAsciiCV,\n\tstringUtf8CV,\n\ttrueCV,\n\ttupleCV,\n\tuintCV,\n} from \"./values.ts\";\n\nexport function readAddress(reader: BytesReader): string {\n\tconst version = reader.readUInt8();\n\tconst hash160 = bytesToHex(reader.readBytes(20));\n\treturn c32address(version, hash160);\n}\n\nexport function readLPString(reader: BytesReader, prefixBytes = 1): string {\n\tlet length = 0;\n\tfor (let i = 0; i < prefixBytes; i++) {\n\t\tlength = (length << 8) | reader.readUInt8();\n\t}\n\treturn bytesToUtf8(reader.readBytes(length));\n}\n\n/** Deepest nesting the deserializer follows before refusing the input. Clarity\n * itself caps value nesting far below this, so honest data never hits it;\n * hostile bytes that repeat `some`/`ok`/`list` would otherwise blow the stack. */\nexport const MAX_CV_DEPTH = 64;\n\n/** Every list item and tuple entry costs at least this many bytes on the wire\n * (a type byte, plus a name-length byte for tuple entries), so a declared\n * count that outruns the remaining bytes is corrupt before any allocation. */\nconst MIN_LIST_ITEM_BYTES = 1;\nconst MIN_TUPLE_ENTRY_BYTES = 2;\n\nfunction checkCount(reader: BytesReader, count: number, minBytes: number) {\n\tif (count * minBytes > reader.remaining()) {\n\t\tthrow new SerializationError(\n\t\t\t`Clarity value declares ${count} elements but only ${reader.remaining()} bytes remain`,\n\t\t);\n\t}\n}\n\nexport function readCV(reader: BytesReader, depth = 0): ClarityValue {\n\tif (depth > MAX_CV_DEPTH) {\n\t\tthrow new SerializationError(\n\t\t\t`Clarity value nests deeper than ${MAX_CV_DEPTH} levels`,\n\t\t);\n\t}\n\tconst typeByte = reader.readUInt8();\n\tconst type = clarityTypeFromByte(typeByte);\n\n\tswitch (type) {\n\t\tcase \"int\":\n\t\t\treturn intCV(bytesToTwosBigInt(reader.readBytes(16)));\n\n\t\tcase \"uint\":\n\t\t\treturn uintCV(reader.readBytes(16));\n\n\t\tcase \"true\":\n\t\t\treturn trueCV();\n\n\t\tcase \"false\":\n\t\t\treturn falseCV();\n\n\t\tcase \"buffer\": {\n\t\t\tconst len = reader.readUInt32BE();\n\t\t\treturn bufferCV(reader.readBytes(len));\n\t\t}\n\n\t\tcase \"none\":\n\t\t\treturn noneCV();\n\n\t\tcase \"some\":\n\t\t\treturn someCV(readCV(reader, depth + 1));\n\n\t\tcase \"ok\":\n\t\t\treturn responseOkCV(readCV(reader, depth + 1));\n\n\t\tcase \"err\":\n\t\t\treturn responseErrorCV(readCV(reader, depth + 1));\n\n\t\tcase \"address\":\n\t\t\treturn standardPrincipalCV(readAddress(reader));\n\n\t\tcase \"contract\": {\n\t\t\tconst addr = readAddress(reader);\n\t\t\tconst name = readLPString(reader);\n\t\t\treturn contractPrincipalCV(addr, name);\n\t\t}\n\n\t\tcase \"list\": {\n\t\t\tconst len = reader.readUInt32BE();\n\t\t\tcheckCount(reader, len, MIN_LIST_ITEM_BYTES);\n\t\t\tconst items: ClarityValue[] = [];\n\t\t\tfor (let i = 0; i < len; i++) {\n\t\t\t\titems.push(readCV(reader, depth + 1));\n\t\t\t}\n\t\t\treturn listCV(items);\n\t\t}\n\n\t\tcase \"tuple\": {\n\t\t\tconst len = reader.readUInt32BE();\n\t\t\tcheckCount(reader, len, MIN_TUPLE_ENTRY_BYTES);\n\t\t\tconst data: Record<string, ClarityValue> = {};\n\t\t\tfor (let i = 0; i < len; i++) {\n\t\t\t\tconst key = readLPString(reader);\n\t\t\t\tdata[key] = readCV(reader, depth + 1);\n\t\t\t}\n\t\t\treturn tupleCV(data);\n\t\t}\n\n\t\tcase \"ascii\": {\n\t\t\tconst len = reader.readUInt32BE();\n\t\t\treturn stringAsciiCV(bytesToAscii(reader.readBytes(len)));\n\t\t}\n\n\t\tcase \"utf8\": {\n\t\t\tconst len = reader.readUInt32BE();\n\t\t\treturn stringUtf8CV(bytesToUtf8(reader.readBytes(len)));\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new SerializationError(\n\t\t\t\t`Cannot deserialize unknown clarity type: ${type}`,\n\t\t\t);\n\t}\n}\n\nexport function deserializeCVBytes<T extends ClarityValue = ClarityValue>(\n\tinput: Uint8Array | string,\n): T {\n\tconst bytes =\n\t\ttypeof input === \"string\" ? hexToBytes(without0x(input)) : input;\n\treturn readCV(new BytesReader(bytes)) as T;\n}\n\nexport function deserializeCV<T extends ClarityValue = ClarityValue>(\n\tinput: Uint8Array | string,\n): T {\n\treturn deserializeCVBytes(input);\n}\n",
10
- "import { isClarityName, parsePrincipal } from \"../utils/address.ts\";\nimport { c32address, c32addressDecode } from \"../utils/c32.ts\";\nimport {\n\ttype IntegerType,\n\tasciiToBytes,\n\tbytesToHex,\n\tbytesToTwosBigInt,\n\thexToBytes,\n\tintToBigInt,\n\tutf8ToBytes,\n} from \"../utils/encoding.ts\";\nimport { deserializeCVBytes } from \"./deserialize.ts\";\nimport { serializeCVBytes } from \"./serialize.ts\";\nimport type {\n\tBooleanCV,\n\tBufferCV,\n\tClarityValue,\n\tContractPrincipalCV,\n\tFalseCV,\n\tIntCV,\n\tListCV,\n\tNoneCV,\n\tResponseErrorCV,\n\tResponseOkCV,\n\tSomeCV,\n\tStandardPrincipalCV,\n\tStringAsciiCV,\n\tStringUtf8CV,\n\tTrueCV,\n\tTupleCV,\n\tTupleData,\n\tUIntCV,\n} from \"./types.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\tlet v: IntegerType = value;\n\tif (typeof v === \"string\" && v.toLowerCase().startsWith(\"0x\")) {\n\t\tv = bytesToTwosBigInt(hexToBytes(v));\n\t}\n\tif (v instanceof Uint8Array) v = bytesToTwosBigInt(v);\n\tconst n = intToBigInt(v);\n\tif (n > MAX_I128) throw new RangeError(`Int exceeds max i128: ${MAX_I128}`);\n\tif (n < MIN_I128) throw new RangeError(`Int below min i128: ${MIN_I128}`);\n\treturn { type: \"int\", value: n };\n}\n\nexport function uintCV(value: IntegerType): UIntCV {\n\tconst n = intToBigInt(value);\n\tif (n < 0n)\n\t\tthrow new RangeError(\"Cannot construct unsigned int from negative value\");\n\tif (n > MAX_U128) throw new RangeError(`UInt exceeds max u128: ${MAX_U128}`);\n\treturn { 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\tif (buffer.byteLength > 1_048_576) {\n\t\tthrow new Error(\"Buffer exceeds max size of 1MB\");\n\t}\n\treturn { type: \"buffer\", value: bytesToHex(buffer) };\n}\n\nexport function standardPrincipalCV(address: string): StandardPrincipalCV {\n\t// Validate by decoding\n\tconst [version, hash160] = c32addressDecode(address);\n\tconst normalized = c32address(version, hash160);\n\treturn { type: \"address\", value: normalized };\n}\n\nexport function contractPrincipalCV(\n\taddress: string,\n\tcontractName: string,\n): ContractPrincipalCV {\n\tconst [version, hash160] = c32addressDecode(address);\n\tconst normalized = c32address(version, hash160);\n\tif (utf8ToBytes(contractName).byteLength >= 128) {\n\t\tthrow new Error(\"Contract name must be less than 128 bytes\");\n\t}\n\treturn { type: \"contract\", value: `${normalized}.${contractName}` };\n}\n\nexport function noneCV(): NoneCV {\n\treturn { type: \"none\" };\n}\n\nexport function someCV(value: ClarityValue): SomeCV {\n\treturn { type: \"some\", value };\n}\n\nexport function responseOkCV(value: ClarityValue): ResponseOkCV {\n\treturn { type: \"ok\", value };\n}\n\nexport function responseErrorCV(value: ClarityValue): ResponseErrorCV {\n\treturn { type: \"err\", value };\n}\n\nexport function listCV(values: ClarityValue[]): ListCV {\n\treturn { type: \"list\", value: values };\n}\n\nexport function tupleCV(data: TupleData): TupleCV {\n\tfor (const key in data) {\n\t\tif (!isClarityName(key)) {\n\t\t\tthrow new Error(`\"${key}\" is not a valid Clarity name`);\n\t\t}\n\t}\n\treturn { type: \"tuple\", value: data };\n}\n\nexport function stringAsciiCV(value: string): StringAsciiCV {\n\treturn { type: \"ascii\", value };\n}\n\nexport function stringUtf8CV(value: string): StringUtf8CV {\n\treturn { type: \"utf8\", value };\n}\n\n// Cl namespace — clean API\n\nexport const Cl: {\n\treadonly int: (value: IntegerType) => IntCV;\n\treadonly uint: (value: IntegerType) => UIntCV;\n\treadonly bool: (v: boolean) => BooleanCV;\n\tprincipal(address: string): StandardPrincipalCV | ContractPrincipalCV;\n\taddress(address: string): StandardPrincipalCV | ContractPrincipalCV;\n\treadonly contractPrincipal: (\n\t\taddress: string,\n\t\tcontractName: string,\n\t) => ContractPrincipalCV;\n\treadonly standardPrincipal: (address: string) => StandardPrincipalCV;\n\treadonly buffer: (buffer: Uint8Array) => BufferCV;\n\treadonly bufferFromHex: (hex: string) => BufferCV;\n\treadonly bufferFromAscii: (ascii: string) => BufferCV;\n\treadonly bufferFromUtf8: (utf8: string) => BufferCV;\n\treadonly none: () => NoneCV;\n\treadonly some: (value: ClarityValue) => SomeCV;\n\treadonly ok: (value: ClarityValue) => ResponseOkCV;\n\treadonly error: (value: ClarityValue) => ResponseErrorCV;\n\treadonly list: (values: ClarityValue[]) => ListCV;\n\treadonly tuple: (data: TupleData) => TupleCV;\n\treadonly stringAscii: (value: string) => StringAsciiCV;\n\treadonly stringUtf8: (value: string) => StringUtf8CV;\n\tserialize(value: ClarityValue): string;\n\treadonly deserialize: (bytes: Uint8Array) => ClarityValue;\n} = {\n\tint: intCV,\n\tuint: uintCV,\n\tbool: boolCV,\n\tprincipal(address: string): StandardPrincipalCV | ContractPrincipalCV {\n\t\tconst parsed = parsePrincipal(address);\n\t\tif (!parsed) throw new Error(`Invalid principal: ${address}`);\n\t\treturn parsed.contractName\n\t\t\t? contractPrincipalCV(parsed.address, parsed.contractName)\n\t\t\t: standardPrincipalCV(parsed.address);\n\t},\n\taddress(address: string): StandardPrincipalCV | ContractPrincipalCV {\n\t\treturn Cl.principal(address);\n\t},\n\tcontractPrincipal: contractPrincipalCV,\n\tstandardPrincipal: standardPrincipalCV,\n\tbuffer: bufferCV,\n\tbufferFromHex: (hex: string): BufferCV => bufferCV(hexToBytes(hex)),\n\tbufferFromAscii: (ascii: string): BufferCV => bufferCV(asciiToBytes(ascii)),\n\tbufferFromUtf8: (utf8: string): BufferCV => bufferCV(utf8ToBytes(utf8)),\n\tnone: noneCV,\n\tsome: someCV,\n\tok: responseOkCV,\n\terror: responseErrorCV,\n\tlist: listCV,\n\ttuple: tupleCV,\n\tstringAscii: stringAsciiCV,\n\tstringUtf8: stringUtf8CV,\n\tserialize(value: ClarityValue): string {\n\t\treturn bytesToHex(serializeCVBytes(value));\n\t},\n\tdeserialize: deserializeCVBytes,\n} as const;\n"
11
- ],
12
- "mappings": ";AAkBO,IAAM,kBAAkB;AAAA,EAC9B,KAAK;AAAA,EACL,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OA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