@secondlayer/stacks 0.2.1 → 0.3.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 (171) hide show
  1. package/dist/shared/stacks-02actsrx.cjs.map +2 -2
  2. package/dist/shared/{stacks-vyb9rx8q.js → stacks-09wa7ewe.js} +125 -115
  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-vbke9mqw.cjs → stacks-17sdtaxg.cjs} +120 -106
  9. package/dist/shared/stacks-17sdtaxg.cjs.map +15 -0
  10. package/dist/shared/{stacks-wrb1es85.js → stacks-1s5w4ncf.js} +46 -34
  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-vd9jcp0b.js → stacks-4x2bcc2k.js} +89 -80
  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-qcx67vqa.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-qyt8m5v0.js → stacks-96d6m1zy.js} +16 -7
  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-yfveb68e.js → stacks-je937aas.js} +3 -3
  30. package/dist/shared/stacks-je937aas.js.map +10 -0
  31. package/dist/shared/{stacks-k58k970n.js → stacks-kg1npstf.js} +5 -3
  32. package/dist/shared/stacks-kg1npstf.js.map +10 -0
  33. package/dist/shared/{stacks-qvg7c24g.cjs → stacks-n98w7g57.cjs} +5 -3
  34. package/dist/shared/stacks-n98w7g57.cjs.map +10 -0
  35. package/dist/shared/{stacks-9mdk86wp.js → stacks-nqae5amn.cjs} +77 -159
  36. package/dist/shared/stacks-nqae5amn.cjs.map +10 -0
  37. package/dist/shared/stacks-qcae5852.js.map +2 -2
  38. package/dist/shared/stacks-qt8ehebn.js.map +3 -3
  39. package/dist/shared/{stacks-r1t6g3c3.cjs → stacks-ra02bpny.cjs} +8 -3
  40. package/dist/shared/stacks-ra02bpny.cjs.map +11 -0
  41. package/dist/shared/{stacks-bycy6t9k.js → stacks-rwfgts3s.js} +2 -2
  42. package/dist/shared/{stacks-bycy6t9k.js.map → stacks-rwfgts3s.js.map} +2 -2
  43. package/dist/shared/{stacks-gjvbq6w7.js → stacks-s10yb9gz.js} +2 -2
  44. package/dist/shared/stacks-s10yb9gz.js.map +10 -0
  45. package/dist/shared/{stacks-v3zy6zds.cjs → stacks-s30kkvm8.js} +104 -117
  46. package/dist/shared/stacks-s30kkvm8.js.map +10 -0
  47. package/dist/shared/{stacks-nqytwfcc.js → stacks-s7z5q8be.js} +8 -3
  48. package/dist/shared/stacks-s7z5q8be.js.map +11 -0
  49. package/dist/shared/stacks-v9jqcpd4.js.map +2 -2
  50. package/dist/shared/stacks-vdfag81a.cjs.map +2 -2
  51. package/dist/shared/{stacks-fedzr2ka.js → stacks-wjem3xw9.js} +23 -11
  52. package/dist/shared/stacks-wjem3xw9.js.map +14 -0
  53. package/dist/shared/{stacks-k08tgzyp.cjs → stacks-wyxj879g.cjs} +3 -3
  54. package/dist/shared/stacks-wyxj879g.cjs.map +13 -0
  55. package/dist/shared/stacks-y3dh7hv1.js.map +3 -3
  56. package/dist/shared/{stacks-2ar4prfz.cjs → stacks-y5262j0z.cjs} +14 -5
  57. package/dist/shared/stacks-y5262j0z.cjs.map +11 -0
  58. package/dist/shared/stacks-ya3x01yd.cjs.map +2 -2
  59. package/dist/shared/{stacks-9avax1yf.js → stacks-zf7rbpzp.js} +5 -5
  60. package/dist/shared/stacks-zf7rbpzp.js.map +13 -0
  61. package/dist/shared/{stacks-61rvzkz1.cjs → stacks-znrb59ce.cjs} +41 -29
  62. package/dist/shared/stacks-znrb59ce.cjs.map +17 -0
  63. package/dist/src/accounts/index.cjs +2 -2
  64. package/dist/src/accounts/index.cjs.map +5 -5
  65. package/dist/src/accounts/index.js +4 -8
  66. package/dist/src/accounts/index.js.map +5 -5
  67. package/dist/src/actions/index.d.cts +36 -29
  68. package/dist/src/actions/index.d.ts +36 -29
  69. package/dist/src/actions/index.js +10 -10
  70. package/dist/src/bns/index.cjs +55 -43
  71. package/dist/src/bns/index.cjs.map +9 -9
  72. package/dist/src/bns/index.d.cts +29 -29
  73. package/dist/src/bns/index.d.ts +29 -29
  74. package/dist/src/bns/index.js +66 -54
  75. package/dist/src/bns/index.js.map +9 -9
  76. package/dist/src/clarity/index.js +6 -6
  77. package/dist/src/connect/index.cjs +114 -112
  78. package/dist/src/connect/index.cjs.map +13 -13
  79. package/dist/src/connect/index.js +114 -112
  80. package/dist/src/connect/index.js.map +13 -13
  81. package/dist/src/connect/walletconnect/index.cjs +3 -3
  82. package/dist/src/connect/walletconnect/index.cjs.map +10 -10
  83. package/dist/src/connect/walletconnect/index.js +3 -3
  84. package/dist/src/connect/walletconnect/index.js.map +10 -10
  85. package/dist/src/index.cjs +108 -2
  86. package/dist/src/index.cjs.map +19 -15
  87. package/dist/src/index.d.cts +298 -112
  88. package/dist/src/index.d.ts +298 -112
  89. package/dist/src/index.js +125 -12
  90. package/dist/src/index.js.map +19 -15
  91. package/dist/src/postconditions/index.js +3 -3
  92. package/dist/src/pox/index.cjs.map +6 -6
  93. package/dist/src/pox/index.d.cts +29 -29
  94. package/dist/src/pox/index.d.ts +29 -29
  95. package/dist/src/pox/index.js +9 -9
  96. package/dist/src/pox/index.js.map +6 -6
  97. package/dist/src/stackingdao/index.cjs +31 -6
  98. package/dist/src/stackingdao/index.cjs.map +6 -6
  99. package/dist/src/stackingdao/index.d.cts +29 -29
  100. package/dist/src/stackingdao/index.d.ts +29 -29
  101. package/dist/src/stackingdao/index.js +41 -16
  102. package/dist/src/stackingdao/index.js.map +6 -6
  103. package/dist/src/subscriptions/index.d.cts +29 -29
  104. package/dist/src/subscriptions/index.d.ts +29 -29
  105. package/dist/src/tools/btc/index.cjs +130 -0
  106. package/dist/src/tools/btc/index.cjs.map +10 -0
  107. package/dist/src/tools/btc/index.d.cts +8 -0
  108. package/dist/src/tools/btc/index.d.ts +8 -0
  109. package/dist/src/tools/btc/index.js +89 -0
  110. package/dist/src/tools/btc/index.js.map +10 -0
  111. package/dist/src/tools/index.cjs +2470 -0
  112. package/dist/src/tools/index.cjs.map +61 -0
  113. package/dist/src/tools/index.d.cts +144 -0
  114. package/dist/src/tools/index.d.ts +144 -0
  115. package/dist/src/tools/index.js +2435 -0
  116. package/dist/src/tools/index.js.map +61 -0
  117. package/dist/src/transactions/index.d.cts +7 -0
  118. package/dist/src/transactions/index.d.ts +7 -0
  119. package/dist/src/transactions/index.js +6 -6
  120. package/dist/src/triggers/index.cjs +66 -0
  121. package/dist/src/triggers/index.cjs.map +10 -0
  122. package/dist/src/triggers/index.d.cts +116 -0
  123. package/dist/src/triggers/index.d.ts +116 -0
  124. package/dist/src/triggers/index.js +25 -0
  125. package/dist/src/triggers/index.js.map +10 -0
  126. package/dist/src/tx/index.cjs +65 -0
  127. package/dist/src/tx/index.cjs.map +10 -0
  128. package/dist/src/tx/index.d.cts +42 -0
  129. package/dist/src/tx/index.d.ts +42 -0
  130. package/dist/src/tx/index.js +22 -0
  131. package/dist/src/tx/index.js.map +10 -0
  132. package/dist/src/ui/index.cjs +431 -0
  133. package/dist/src/ui/index.cjs.map +27 -0
  134. package/dist/src/ui/index.d.cts +107 -0
  135. package/dist/src/ui/index.d.ts +107 -0
  136. package/dist/src/ui/index.js +391 -0
  137. package/dist/src/ui/index.js.map +27 -0
  138. package/dist/src/ui/schemas.cjs +134 -0
  139. package/dist/src/ui/schemas.cjs.map +18 -0
  140. package/dist/src/ui/schemas.d.cts +83 -0
  141. package/dist/src/ui/schemas.d.ts +83 -0
  142. package/dist/src/ui/schemas.js +91 -0
  143. package/dist/src/ui/schemas.js.map +18 -0
  144. package/dist/src/utils/index.cjs +3 -3
  145. package/dist/src/utils/index.cjs.map +4 -4
  146. package/dist/src/utils/index.js +7 -7
  147. package/dist/src/utils/index.js.map +4 -4
  148. package/package.json +157 -105
  149. package/dist/shared/stacks-2ar4prfz.cjs.map +0 -11
  150. package/dist/shared/stacks-61rvzkz1.cjs.map +0 -17
  151. package/dist/shared/stacks-9avax1yf.js.map +0 -13
  152. package/dist/shared/stacks-9mdk86wp.js.map +0 -10
  153. package/dist/shared/stacks-an5k8n4t.cjs.map +0 -23
  154. package/dist/shared/stacks-evnzth1q.cjs.map +0 -10
  155. package/dist/shared/stacks-fedzr2ka.js.map +0 -13
  156. package/dist/shared/stacks-gjvbq6w7.js.map +0 -10
  157. package/dist/shared/stacks-k08tgzyp.cjs.map +0 -13
  158. package/dist/shared/stacks-k2p5tv6x.js.map +0 -10
  159. package/dist/shared/stacks-k58k970n.js.map +0 -10
  160. package/dist/shared/stacks-ky14tdf6.cjs.map +0 -13
  161. package/dist/shared/stacks-nqytwfcc.js.map +0 -11
  162. package/dist/shared/stacks-qcx67vqa.js.map +0 -10
  163. package/dist/shared/stacks-qvg7c24g.cjs.map +0 -10
  164. package/dist/shared/stacks-qyt8m5v0.js.map +0 -11
  165. package/dist/shared/stacks-r1t6g3c3.cjs.map +0 -11
  166. package/dist/shared/stacks-v3zy6zds.cjs.map +0 -10
  167. package/dist/shared/stacks-vbke9mqw.cjs.map +0 -15
  168. package/dist/shared/stacks-vd9jcp0b.js.map +0 -23
  169. package/dist/shared/stacks-vyb9rx8q.js.map +0 -15
  170. package/dist/shared/stacks-wrb1es85.js.map +0 -17
  171. package/dist/shared/stacks-yfveb68e.js.map +0 -10
@@ -0,0 +1,14 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/clarity/types.ts", "../src/clarity/serialize.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\tconst keys = Object.keys(value.value).sort((a, b) => a.localeCompare(b));\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\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 { 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\treadUInt8(): number {\n\t\treturn this.data[this.offset++]!;\n\t}\n\n\treadUInt16BE(): number {\n\t\tconst val =\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\tconst val =\n\t\t\t((this.data[this.offset]! << 24) |\n\t\t\t\t(this.data[this.offset + 1]! << 16) |\n\t\t\t\t(this.data[this.offset + 2]! << 8) |\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\tif (this.offset + length > this.data.length) {\n\t\t\tthrow new Error(\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\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",
8
+ "import { 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\nexport function readCV(reader: BytesReader): ClarityValue {\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));\n\n\t\tcase \"ok\":\n\t\t\treturn responseOkCV(readCV(reader));\n\n\t\tcase \"err\":\n\t\t\treturn responseErrorCV(readCV(reader));\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\tconst items: ClarityValue[] = [];\n\t\t\tfor (let i = 0; i < len; i++) {\n\t\t\t\titems.push(readCV(reader));\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\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);\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 Error(`Cannot deserialize unknown clarity type: ${type}`);\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",
9
+ "import { isClarityName } 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\tif (typeof value === \"string\" && value.toLowerCase().startsWith(\"0x\")) {\n\t\tvalue = bytesToTwosBigInt(hexToBytes(value));\n\t}\n\tif (value instanceof Uint8Array) value = bytesToTwosBigInt(value);\n\tconst n = intToBigInt(value);\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 [addr, name] = address.split(\".\");\n\t\tif (!addr) throw new Error(\"Invalid principal address\");\n\t\treturn name ? contractPrincipalCV(addr, name) : standardPrincipalCV(addr);\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"
10
+ ],
11
+ "mappings": ";AAkBO,IAAM,kBAAkB;AAAA,EAC9B,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,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM;A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K;AAAA;AAG9B,SAAS,aAAa,CAAC,OAA8B;AAAA,EAC3D,OAAO,EAAE,MAAM,SAAS,MAAM;AAAA;AAGxB,SAAS,YAAY,CAAC,OAA6B;AAAA,EACzD,OAAO,EAAE,MAAM,QAAQ,MAAM;AAAA;AAKvB,IAAM,KAyBT;AAAA,EACH,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS,CAAC,SAA4D;AAAA,IACrE,OAAO,MAAM,QAAQ,QAAQ,MAAM,GAAG;AAAA,IACtC,IAAI,CAAC;AAAA,MAAM,MAAM,IAAI,MAAM,2BAA2B;AAAA,IACtD,OAAO,OAAO,oBAAoB,MAAM,IAAI,IAAI,oBAAoB,IAAI;AAAA;AAAA,EAEzE,OAAO,CAAC,SAA4D;AAAA,IACnE,OAAO,GAAG,UAAU,OAAO;AAAA;AAAA,EAE5B,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,IACtC,OAAO,WAAW,iBAAiB,KAAK,CAAC;AAAA;AAAA,EAE1C,aAAa;AACd;",
12
+ "debugId": "9F0937751BC5C71A64756E2164756E21",
13
+ "names": []
14
+ }
@@ -1,14 +1,8 @@
1
- // src/actions/public/getBalance.ts
2
- async function getBalance(client, params) {
3
- const data = await client.request(`/v2/accounts/${params.address}`, {
4
- method: "GET"
5
- });
6
- return BigInt(data.balance);
7
- }
8
-
9
1
  // src/actions/public/getAccountInfo.ts
10
2
  async function getAccountInfo(client, params) {
11
- const data = await client.request(`/v2/accounts/${params.address}?proof=1`, { method: "GET" });
3
+ const data = await client.request(`/v2/accounts/${params.address}?proof=1`, {
4
+ method: "GET"
5
+ });
12
6
  return {
13
7
  balance: BigInt(data.balance),
14
8
  nonce: BigInt(data.nonce),
@@ -17,13 +11,25 @@ async function getAccountInfo(client, params) {
17
11
  };
18
12
  }
19
13
 
14
+ // src/actions/public/getBalance.ts
15
+ async function getBalance(client, params) {
16
+ const data = await client.request(`/v2/accounts/${params.address}`, {
17
+ method: "GET"
18
+ });
19
+ return BigInt(data.balance);
20
+ }
21
+
20
22
  // src/actions/public/getBlock.ts
21
23
  async function getBlock(client, params) {
22
24
  if (params?.hash) {
23
- return client.request(`/extended/v2/blocks/${params.hash}`, { method: "GET" });
25
+ return client.request(`/extended/v2/blocks/${params.hash}`, {
26
+ method: "GET"
27
+ });
24
28
  }
25
29
  if (params?.height !== undefined) {
26
- return client.request(`/extended/v2/blocks/${params.height}`, { method: "GET" });
30
+ return client.request(`/extended/v2/blocks/${params.height}`, {
31
+ method: "GET"
32
+ });
27
33
  }
28
34
  return client.request("/extended/v2/blocks?limit=1", { method: "GET" });
29
35
  }
@@ -47,7 +53,10 @@ async function multicall(client, params) {
47
53
  const { calls, allowFailure = true } = params;
48
54
  if (allowFailure) {
49
55
  const settled = await Promise.allSettled(calls.map((call) => readContract(client, call)));
50
- return settled.map((r) => r.status === "fulfilled" ? { status: "success", result: r.value } : { status: "failure", error: r.reason instanceof Error ? r.reason : new Error(String(r.reason)) });
56
+ return settled.map((r) => r.status === "fulfilled" ? { status: "success", result: r.value } : {
57
+ status: "failure",
58
+ error: r.reason instanceof Error ? r.reason : new Error(String(r.reason))
59
+ });
51
60
  }
52
61
  const results = await Promise.all(calls.map((call) => readContract(client, call)));
53
62
  return results;
@@ -125,65 +134,6 @@ async function simulateTransaction(client, params) {
125
134
  return { type: "token-transfer", fees };
126
135
  }
127
136
 
128
- // src/actions/wallet/signTransaction.ts
129
- async function signTransactionAction(client, params) {
130
- const account = client.account;
131
- if (!account)
132
- throw new Error("Account required");
133
- if (isProviderAccount(account)) {
134
- const hex = serializeTransactionHex(params.transaction);
135
- const result = await account.provider.request("stx_signTransaction", {
136
- transaction: hex
137
- });
138
- return deserializeTransaction(result.transaction);
139
- }
140
- const condition = params.transaction.auth.spendingCondition;
141
- if ("fields" in condition) {
142
- const publicKeys = params.signers ?? params.transaction._multisig?.publicKeys;
143
- if (!publicKeys)
144
- throw new Error("Multi-sig signing requires signers (publicKeys)");
145
- return signMultiSigWithAccount(params.transaction, account, publicKeys);
146
- }
147
- return signTransactionWithAccount(params.transaction, account);
148
- }
149
-
150
- // src/actions/wallet/transferStx.ts
151
- async function transferStx(client, params) {
152
- const account = client.account;
153
- if (!account)
154
- throw new Error("Account required");
155
- if (isProviderAccount(account)) {
156
- const result2 = await account.provider.request("stx_transferStx", {
157
- recipient: params.to,
158
- amount: String(params.amount),
159
- memo: params.memo
160
- });
161
- return result2.txid;
162
- }
163
- const nonce = params.nonce ?? await getNonce(client, { address: account.address });
164
- const unsigned = buildTokenTransfer({
165
- recipient: params.to,
166
- amount: params.amount,
167
- memo: params.memo,
168
- fee: params.fee ?? 0n,
169
- nonce,
170
- publicKey: account.publicKey,
171
- chain: client.chain,
172
- postConditionMode: params.postConditionMode,
173
- postConditions: params.postConditions
174
- });
175
- if (params.fee === undefined) {
176
- const estimates = await estimateFee(client, { transaction: unsigned });
177
- const mid = estimates[1] ?? estimates[0];
178
- if (mid) {
179
- unsigned.auth.spendingCondition.fee = BigInt(mid.fee);
180
- }
181
- }
182
- const signed = await signTransactionWithAccount(unsigned, account);
183
- const result = await sendTransaction(client, { transaction: signed });
184
- return result.txid;
185
- }
186
-
187
137
  // src/actions/wallet/deployContract.ts
188
138
  async function deployContract(client, params) {
189
139
  const account = client.account;
@@ -254,6 +204,28 @@ async function signMessage(client, params) {
254
204
  return bytesToHex(sigBytes);
255
205
  }
256
206
 
207
+ // src/actions/wallet/signTransaction.ts
208
+ async function signTransactionAction(client, params) {
209
+ const account = client.account;
210
+ if (!account)
211
+ throw new Error("Account required");
212
+ if (isProviderAccount(account)) {
213
+ const hex = serializeTransactionHex(params.transaction);
214
+ const result = await account.provider.request("stx_signTransaction", {
215
+ transaction: hex
216
+ });
217
+ return deserializeTransaction(result.transaction);
218
+ }
219
+ const condition = params.transaction.auth.spendingCondition;
220
+ if ("fields" in condition) {
221
+ const publicKeys = params.signers ?? params.transaction._multisig?.publicKeys;
222
+ if (!publicKeys)
223
+ throw new Error("Multi-sig signing requires signers (publicKeys)");
224
+ return signMultiSigWithAccount(params.transaction, account, publicKeys);
225
+ }
226
+ return signTransactionWithAccount(params.transaction, account);
227
+ }
228
+
257
229
  // src/actions/wallet/sponsorTransaction.ts
258
230
  async function sponsorTransaction(client, params) {
259
231
  const { transaction } = params;
@@ -287,5 +259,42 @@ async function sponsorTransaction(client, params) {
287
259
  return signSponsorWithAccount(sponsored, account);
288
260
  }
289
261
 
290
- //# debugId=611DF286E29AA1A764756E2164756E21
291
- //# sourceMappingURL=stacks-an5k8n4t.cjs.map
262
+ // src/actions/wallet/transferStx.ts
263
+ async function transferStx(client, params) {
264
+ const account = client.account;
265
+ if (!account)
266
+ throw new Error("Account required");
267
+ if (isProviderAccount(account)) {
268
+ const result2 = await account.provider.request("stx_transferStx", {
269
+ recipient: params.to,
270
+ amount: String(params.amount),
271
+ memo: params.memo
272
+ });
273
+ return result2.txid;
274
+ }
275
+ const nonce = params.nonce ?? await getNonce(client, { address: account.address });
276
+ const unsigned = buildTokenTransfer({
277
+ recipient: params.to,
278
+ amount: params.amount,
279
+ memo: params.memo,
280
+ fee: params.fee ?? 0n,
281
+ nonce,
282
+ publicKey: account.publicKey,
283
+ chain: client.chain,
284
+ postConditionMode: params.postConditionMode,
285
+ postConditions: params.postConditions
286
+ });
287
+ if (params.fee === undefined) {
288
+ const estimates = await estimateFee(client, { transaction: unsigned });
289
+ const mid = estimates[1] ?? estimates[0];
290
+ if (mid) {
291
+ unsigned.auth.spendingCondition.fee = BigInt(mid.fee);
292
+ }
293
+ }
294
+ const signed = await signTransactionWithAccount(unsigned, account);
295
+ const result = await sendTransaction(client, { transaction: signed });
296
+ return result.txid;
297
+ }
298
+
299
+ //# debugId=65C97D7D34400C6264756E2164756E21
300
+ //# sourceMappingURL=stacks-14pgpkrr.cjs.map
@@ -0,0 +1,23 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/actions/public/getAccountInfo.ts", "../src/actions/public/getBalance.ts", "../src/actions/public/getBlock.ts", "../src/actions/public/getBlockHeight.ts", "../src/actions/public/getContractAbi.ts", "../src/actions/public/multicall.ts", "../src/errors/simulation.ts", "../src/actions/public/simulateCall.ts", "../src/actions/public/simulateTransaction.ts", "../src/actions/wallet/deployContract.ts", "../src/actions/wallet/signMessage.ts", "../src/actions/wallet/signTransaction.ts", "../src/actions/wallet/sponsorTransaction.ts", "../src/actions/wallet/transferStx.ts"],
4
+ "sourcesContent": [
5
+ "import type { Client } from \"../../clients/types.ts\";\n\nexport type GetAccountInfoParams = {\n\taddress: string;\n};\n\nexport type AccountInfo = {\n\tbalance: bigint;\n\tnonce: bigint;\n\tbalanceProof: string;\n\tnonceProof: string;\n};\n\nexport async function getAccountInfo(\n\tclient: Client,\n\tparams: GetAccountInfoParams,\n): Promise<AccountInfo> {\n\tconst data = await client.request(`/v2/accounts/${params.address}?proof=1`, {\n\t\tmethod: \"GET\",\n\t});\n\treturn {\n\t\tbalance: BigInt(data.balance),\n\t\tnonce: BigInt(data.nonce),\n\t\tbalanceProof: data.balance_proof ?? \"\",\n\t\tnonceProof: data.nonce_proof ?? \"\",\n\t};\n}\n",
6
+ "import type { Client } from \"../../clients/types.ts\";\n\nexport type GetBalanceParams = {\n\taddress: string;\n};\n\nexport async function getBalance(\n\tclient: Client,\n\tparams: GetBalanceParams,\n): Promise<bigint> {\n\tconst data = await client.request(`/v2/accounts/${params.address}`, {\n\t\tmethod: \"GET\",\n\t});\n\treturn BigInt(data.balance);\n}\n",
7
+ "import type { Client } from \"../../clients/types.ts\";\n\nexport type GetBlockParams = {\n\theight?: number;\n\thash?: string;\n};\n\nexport async function getBlock(\n\tclient: Client,\n\tparams?: GetBlockParams,\n): Promise<any> {\n\tif (params?.hash) {\n\t\treturn client.request(`/extended/v2/blocks/${params.hash}`, {\n\t\t\tmethod: \"GET\",\n\t\t});\n\t}\n\tif (params?.height !== undefined) {\n\t\treturn client.request(`/extended/v2/blocks/${params.height}`, {\n\t\t\tmethod: \"GET\",\n\t\t});\n\t}\n\t// Latest block\n\treturn client.request(\"/extended/v2/blocks?limit=1\", { method: \"GET\" });\n}\n",
8
+ "import type { Client } from \"../../clients/types.ts\";\n\nexport async function getBlockHeight(client: Client): Promise<number> {\n\tconst data = await client.request(\"/v2/info\", { method: \"GET\" });\n\treturn data.stacks_tip_height;\n}\n",
9
+ "import type { Client } from \"../../clients/types.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\n\nexport type GetContractAbiParams = {\n\tcontract: string; // \"address.name\"\n};\n\nexport async function getContractAbi(\n\tclient: Client,\n\tparams: GetContractAbiParams,\n): Promise<any> {\n\tconst [address, name] = parseContractId(params.contract);\n\treturn client.request(`/v2/contracts/interface/${address}/${name}`, {\n\t\tmethod: \"GET\",\n\t});\n}\n",
10
+ "import type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { readContract } from \"./readContract.ts\";\n\nexport type MulticallCall = {\n\tcontract: string;\n\tfunctionName: string;\n\targs?: ClarityValue[];\n\tsender?: string;\n};\n\nexport type MulticallParams<TAllowFailure extends boolean = true> = {\n\tcalls: readonly MulticallCall[];\n\tallowFailure?: TAllowFailure;\n};\n\nexport type MulticallSuccessResult = {\n\tstatus: \"success\";\n\tresult: ClarityValue;\n};\nexport type MulticallFailureResult = { status: \"failure\"; error: Error };\n\nexport type MulticallResult<T extends boolean> = T extends true\n\t? (MulticallSuccessResult | MulticallFailureResult)[]\n\t: ClarityValue[];\n\nexport async function multicall<TAllowFailure extends boolean = true>(\n\tclient: Client,\n\tparams: MulticallParams<TAllowFailure>,\n): Promise<MulticallResult<TAllowFailure>> {\n\tconst { calls, allowFailure = true } = params;\n\n\tif (allowFailure) {\n\t\tconst settled = await Promise.allSettled(\n\t\t\tcalls.map((call) => readContract(client, call)),\n\t\t);\n\t\treturn settled.map((r) =>\n\t\t\tr.status === \"fulfilled\"\n\t\t\t\t? { status: \"success\" as const, result: r.value }\n\t\t\t\t: {\n\t\t\t\t\t\tstatus: \"failure\" as const,\n\t\t\t\t\t\terror:\n\t\t\t\t\t\t\tr.reason instanceof Error\n\t\t\t\t\t\t\t\t? r.reason\n\t\t\t\t\t\t\t\t: new Error(String(r.reason)),\n\t\t\t\t\t},\n\t\t) as MulticallResult<TAllowFailure>;\n\t}\n\n\tconst results = await Promise.all(\n\t\tcalls.map((call) => readContract(client, call)),\n\t);\n\treturn results as MulticallResult<TAllowFailure>;\n}\n",
11
+ "import { BaseError } from \"./base.ts\";\n\nexport class SimulationError extends BaseError {\n\toverride name = \"SimulationError\";\n\twritesDetected: boolean;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: { writesDetected: boolean; details?: string },\n\t) {\n\t\tsuper(message, { details: options.details });\n\t\tthis.writesDetected = options.writesDetected;\n\t}\n}\n",
12
+ "import { deserializeCVBytes } from \"../../clarity/deserialize.ts\";\nimport { serializeCVBytes } from \"../../clarity/serialize.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { SimulationError } from \"../../errors/simulation.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\nimport { bytesToHex, with0x } from \"../../utils/encoding.ts\";\n\nexport type SimulateCallParams = {\n\tcontract: string;\n\tfunctionName: string;\n\targs?: ClarityValue[];\n\tsender?: string;\n\ttip?: string;\n};\n\nexport type SimulateCallSuccess = { success: true; result: ClarityValue };\nexport type SimulateCallFailure = { success: false; error: SimulationError };\nexport type SimulateCallResult = SimulateCallSuccess | SimulateCallFailure;\n\nexport async function simulateCall(\n\tclient: Client,\n\tparams: SimulateCallParams,\n): Promise<SimulateCallResult> {\n\tconst [address, name] = parseContractId(params.contract);\n\tconst sender = params.sender ?? address;\n\n\tconst serializedArgs = (params.args ?? []).map((arg) =>\n\t\twith0x(bytesToHex(serializeCVBytes(arg))),\n\t);\n\n\tlet path = `/v2/contracts/call-read/${address}/${name}/${params.functionName}`;\n\tif (params.tip) {\n\t\tpath += `?tip=${params.tip}`;\n\t}\n\n\tconst data = await client.request(path, {\n\t\tmethod: \"POST\",\n\t\tbody: {\n\t\t\tsender,\n\t\t\targuments: serializedArgs,\n\t\t},\n\t});\n\n\tif (data.okay) {\n\t\treturn { success: true, result: deserializeCVBytes(data.result) };\n\t}\n\n\tconst cause: string = data.cause ?? \"Simulation failed\";\n\tconst writesDetected =\n\t\tcause.includes(\"NotReadOnly\") || cause.includes(\"CostBalanceExceeded\");\n\n\treturn {\n\t\tsuccess: false,\n\t\terror: new SimulationError(\n\t\t\twritesDetected\n\t\t\t\t? \"Function mutates state and cannot be simulated\"\n\t\t\t\t: \"Simulation failed\",\n\t\t\t{ writesDetected, details: cause },\n\t\t),\n\t};\n}\n",
13
+ "import type { Client } from \"../../clients/types.ts\";\nimport type { StacksTransaction } from \"../../transactions/types.ts\";\nimport { AddressHashMode, PayloadType } from \"../../transactions/types.ts\";\nimport { c32address } from \"../../utils/address.ts\";\nimport { type FeeEstimation, estimateFee } from \"./estimateFee.ts\";\nimport { type SimulateCallResult, simulateCall } from \"./simulateCall.ts\";\n\nexport type SimulateTransactionParams = {\n\ttransaction: StacksTransaction;\n\tsender?: string;\n\ttip?: string;\n};\n\nexport type SimulateContractCallResult = {\n\ttype: \"contract-call\";\n\texecution: SimulateCallResult;\n\tfees: FeeEstimation[];\n};\n\nexport type SimulateTransferResult = {\n\ttype: \"token-transfer\";\n\tfees: FeeEstimation[];\n};\n\nexport type SimulateDeployResult = {\n\ttype: \"contract-deploy\";\n\tfees: FeeEstimation[];\n};\n\nexport type SimulateTransactionResult =\n\t| SimulateContractCallResult\n\t| SimulateTransferResult\n\t| SimulateDeployResult;\n\nfunction isMultiSig(hashMode: number): boolean {\n\treturn (\n\t\thashMode === AddressHashMode.P2SH ||\n\t\thashMode === AddressHashMode.P2WSH ||\n\t\thashMode === AddressHashMode.P2SH_NonSequential ||\n\t\thashMode === AddressHashMode.P2WSH_P2SH_NonSequential\n\t);\n}\n\nfunction extractSender(tx: StacksTransaction, client: Client): string {\n\tconst { hashMode, signer } = tx.auth.spendingCondition;\n\tconst chain = client.chain;\n\tconst version = isMultiSig(hashMode)\n\t\t? (chain?.addressVersion.multiSig ?? 20)\n\t\t: (chain?.addressVersion.singleSig ?? 22);\n\treturn c32address(version, signer);\n}\n\nexport async function simulateTransaction(\n\tclient: Client,\n\tparams: SimulateTransactionParams,\n): Promise<SimulateTransactionResult> {\n\tconst { transaction, tip } = params;\n\tconst { payload } = transaction;\n\n\tif (payload.payloadType === PayloadType.ContractCall) {\n\t\tconst sender = params.sender ?? extractSender(transaction, client);\n\t\tconst contract = `${payload.contractAddress}.${payload.contractName}`;\n\n\t\tconst [execution, fees] = await Promise.all([\n\t\t\tsimulateCall(client, {\n\t\t\t\tcontract,\n\t\t\t\tfunctionName: payload.functionName,\n\t\t\t\targs: payload.functionArgs,\n\t\t\t\tsender,\n\t\t\t\ttip,\n\t\t\t}),\n\t\t\testimateFee(client, { transaction }),\n\t\t]);\n\n\t\treturn { type: \"contract-call\", execution, fees };\n\t}\n\n\tconst fees = await estimateFee(client, { transaction });\n\n\tif (\n\t\tpayload.payloadType === PayloadType.SmartContract ||\n\t\tpayload.payloadType === PayloadType.VersionedSmartContract\n\t) {\n\t\treturn { type: \"contract-deploy\", fees };\n\t}\n\n\treturn { type: \"token-transfer\", fees };\n}\n",
14
+ "import type { Client } from \"../../clients/types.ts\";\nimport type { PostCondition } from \"../../postconditions/types.ts\";\nimport { buildContractDeploy } from \"../../transactions/build.ts\";\nimport { signTransactionWithAccount } from \"../../transactions/signer.ts\";\nimport type { ClarityVersion } from \"../../transactions/types.ts\";\nimport type { IntegerType } from \"../../utils/encoding.ts\";\nimport { estimateFee } from \"../public/estimateFee.ts\";\nimport { getNonce } from \"../public/getNonce.ts\";\nimport { sendTransaction } from \"./sendTransaction.ts\";\nimport { isProviderAccount } from \"./utils.ts\";\n\nexport type DeployContractParams = {\n\tcontractName: string;\n\tcodeBody: string;\n\tclarityVersion?: ClarityVersion;\n\tfee?: IntegerType;\n\tnonce?: IntegerType;\n\tpostConditionMode?: \"allow\" | \"deny\";\n\tpostConditions?: PostCondition[];\n};\n\n/** Build, sign, and broadcast a contract deploy */\nexport async function deployContract(\n\tclient: Client,\n\tparams: DeployContractParams,\n): Promise<string> {\n\tconst account = client.account;\n\tif (!account) throw new Error(\"Account required\");\n\n\t// Provider: delegate to wallet\n\tif (isProviderAccount(account)) {\n\t\tconst result = await account.provider.request(\"stx_deployContract\", {\n\t\t\tcontractName: params.contractName,\n\t\t\tcodeBody: params.codeBody,\n\t\t\tclarityVersion: params.clarityVersion,\n\t\t});\n\t\treturn result.txid;\n\t}\n\n\t// Local/Custom: build → sign → broadcast\n\tconst nonce =\n\t\tparams.nonce ?? (await getNonce(client, { address: account.address }));\n\n\tconst unsigned = buildContractDeploy({\n\t\tcontractName: params.contractName,\n\t\tcodeBody: params.codeBody,\n\t\tclarityVersion: params.clarityVersion,\n\t\tfee: params.fee ?? 0n,\n\t\tnonce,\n\t\tpublicKey: account.publicKey,\n\t\tchain: client.chain,\n\t\tpostConditionMode: params.postConditionMode,\n\t\tpostConditions: params.postConditions,\n\t});\n\n\tif (params.fee === undefined) {\n\t\tconst estimates = await estimateFee(client, { transaction: unsigned });\n\t\tconst mid = estimates[1] ?? estimates[0];\n\t\tif (mid) {\n\t\t\t(unsigned.auth.spendingCondition as any).fee = BigInt(mid.fee);\n\t\t}\n\t}\n\n\tconst signed = await signTransactionWithAccount(unsigned, account);\n\tconst result = await sendTransaction(client, { transaction: signed });\n\treturn result.txid;\n}\n",
15
+ "import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { serializeCVBytes } from \"../../clarity/serialize.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport { Cl } from \"../../clarity/values.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { bytesToHex, concatBytes } from \"../../utils/encoding.ts\";\nimport { isProviderAccount } from \"./utils.ts\";\n\nexport type SignMessageParams = {\n\tmessage: string | ClarityValue;\n\tdomain?: {\n\t\tname: string;\n\t\tversion: string;\n\t\tchainId: number;\n\t};\n};\n\nconst SIP018_PREFIX = new Uint8Array([0x53, 0x49, 0x50, 0x30, 0x31, 0x38]); // \"SIP018\"\n\n/** Sign a structured message per SIP-018 */\nexport async function signMessage(\n\tclient: Client,\n\tparams: SignMessageParams,\n): Promise<string> {\n\tconst account = client.account;\n\tif (!account) throw new Error(\"Account required\");\n\n\t// Provider: delegate to wallet\n\tif (isProviderAccount(account)) {\n\t\tconst method = params.domain\n\t\t\t? \"stx_signStructuredMessage\"\n\t\t\t: \"stx_signMessage\";\n\t\tconst result = await account.provider.request(method, {\n\t\t\tmessage: params.message,\n\t\t\tdomain: params.domain,\n\t\t});\n\t\treturn result.signature;\n\t}\n\n\t// Local/Custom: sign locally\n\tconst cv =\n\t\ttypeof params.message === \"string\"\n\t\t\t? Cl.stringAscii(params.message)\n\t\t\t: params.message;\n\n\tconst serializedMsg = serializeCVBytes(cv);\n\n\tlet hash: Uint8Array;\n\n\tif (params.domain) {\n\t\tconst domainCV = Cl.tuple({\n\t\t\tname: Cl.stringAscii(params.domain.name),\n\t\t\tversion: Cl.stringAscii(params.domain.version),\n\t\t\t\"chain-id\": Cl.uint(params.domain.chainId),\n\t\t});\n\t\tconst serializedDomain = serializeCVBytes(domainCV);\n\t\thash = sha256(concatBytes(SIP018_PREFIX, serializedDomain, serializedMsg));\n\t} else {\n\t\thash = sha256(serializedMsg);\n\t}\n\n\tconst sigBytes = await account.sign(hash);\n\treturn bytesToHex(sigBytes);\n}\n",
16
+ "import type { Client } from \"../../clients/types.ts\";\nimport { signMultiSigWithAccount } from \"../../transactions/multisig.ts\";\nimport { signTransactionWithAccount } from \"../../transactions/signer.ts\";\nimport type { StacksTransaction } from \"../../transactions/types.ts\";\nimport { deserializeTransaction } from \"../../transactions/wire/deserialize.ts\";\nimport { serializeTransactionHex } from \"../../transactions/wire/serialize.ts\";\nimport { isProviderAccount } from \"./utils.ts\";\n\nexport type SignTransactionParams = {\n\ttransaction: StacksTransaction;\n\t/** Public keys for multi-sig signing (auto-detected from _multisig metadata if omitted) */\n\tsigners?: string[];\n};\n\n/** Sign a transaction using the client's account */\nexport async function signTransactionAction(\n\tclient: Client,\n\tparams: SignTransactionParams,\n): Promise<StacksTransaction> {\n\tconst account = client.account;\n\tif (!account) throw new Error(\"Account required\");\n\n\t// Provider: send hex to wallet, get signed hex back\n\tif (isProviderAccount(account)) {\n\t\tconst hex = serializeTransactionHex(params.transaction);\n\t\tconst result = await account.provider.request(\"stx_signTransaction\", {\n\t\t\ttransaction: hex,\n\t\t});\n\t\treturn deserializeTransaction(result.transaction);\n\t}\n\n\t// Multi-sig: auto-detect from fields or _multisig metadata\n\tconst condition = params.transaction.auth.spendingCondition;\n\tif (\"fields\" in condition) {\n\t\tconst publicKeys =\n\t\t\tparams.signers ?? (params.transaction as any)._multisig?.publicKeys;\n\t\tif (!publicKeys)\n\t\t\tthrow new Error(\"Multi-sig signing requires signers (publicKeys)\");\n\t\treturn signMultiSigWithAccount(params.transaction, account, publicKeys);\n\t}\n\n\t// Local/Custom: sign with account\n\treturn signTransactionWithAccount(params.transaction, account);\n}\n",
17
+ "import type { Client } from \"../../clients/types.ts\";\nimport { createSingleSigSpendingCondition } from \"../../transactions/authorization.ts\";\nimport { signSponsorWithAccount } from \"../../transactions/signer.ts\";\nimport {\n\tAuthType,\n\ttype SponsoredAuthorization,\n\ttype StacksTransaction,\n} from \"../../transactions/types.ts\";\nimport type { IntegerType } from \"../../utils/encoding.ts\";\nimport { intToBigInt } from \"../../utils/encoding.ts\";\nimport { estimateFee } from \"../public/estimateFee.ts\";\nimport { getNonce } from \"../public/getNonce.ts\";\nimport { isProviderAccount } from \"./utils.ts\";\n\nexport type SponsorTransactionParams = {\n\ttransaction: StacksTransaction;\n\tfee?: IntegerType;\n\tnonce?: IntegerType;\n};\n\n/** Sponsor a transaction: set sponsor spending condition, sign as sponsor */\nexport async function sponsorTransaction(\n\tclient: Client,\n\tparams: SponsorTransactionParams,\n): Promise<StacksTransaction> {\n\tconst { transaction } = params;\n\n\tif (transaction.auth.authType !== AuthType.Sponsored) {\n\t\tthrow new Error(\"Transaction must have sponsored authorization\");\n\t}\n\n\tconst account = client.account;\n\tif (!account) throw new Error(\"Account required\");\n\tif (isProviderAccount(account)) {\n\t\tthrow new Error(\"Provider accounts cannot sponsor transactions\");\n\t}\n\n\t// Resolve sponsor nonce\n\tconst nonce =\n\t\tparams.nonce != null\n\t\t\t? intToBigInt(params.nonce)\n\t\t\t: await getNonce(client, { address: account.address });\n\n\t// Resolve sponsor fee\n\tlet fee: bigint;\n\tif (params.fee != null) {\n\t\tfee = intToBigInt(params.fee);\n\t} else {\n\t\tconst estimates = await estimateFee(client, { transaction });\n\t\tconst mid = estimates[1] ?? estimates[0];\n\t\tfee = mid ? BigInt(mid.fee) : 0n;\n\t}\n\n\t// Create sponsor spending condition\n\tconst sponsorCondition = createSingleSigSpendingCondition(\n\t\taccount.publicKey,\n\t\tnonce,\n\t\tfee,\n\t);\n\n\t// Set sponsor spending condition on the tx\n\tconst auth = transaction.auth as SponsoredAuthorization;\n\tconst sponsored: StacksTransaction = {\n\t\t...transaction,\n\t\tauth: {\n\t\t\t...auth,\n\t\t\tsponsorSpendingCondition: sponsorCondition,\n\t\t},\n\t};\n\n\t// Sign as sponsor\n\treturn signSponsorWithAccount(sponsored, account);\n}\n",
18
+ "import type { Client } from \"../../clients/types.ts\";\nimport type { PostCondition } from \"../../postconditions/types.ts\";\nimport { buildTokenTransfer } from \"../../transactions/build.ts\";\nimport { signTransactionWithAccount } from \"../../transactions/signer.ts\";\nimport type { IntegerType } from \"../../utils/encoding.ts\";\nimport { estimateFee } from \"../public/estimateFee.ts\";\nimport { getNonce } from \"../public/getNonce.ts\";\nimport { sendTransaction } from \"./sendTransaction.ts\";\nimport { isProviderAccount } from \"./utils.ts\";\n\nexport type TransferStxParams = {\n\tto: string;\n\tamount: IntegerType;\n\tmemo?: string;\n\tfee?: IntegerType;\n\tnonce?: IntegerType;\n\tpostConditionMode?: \"allow\" | \"deny\";\n\tpostConditions?: PostCondition[];\n};\n\n/** Build, sign, and broadcast an STX transfer */\nexport async function transferStx(\n\tclient: Client,\n\tparams: TransferStxParams,\n): Promise<string> {\n\tconst account = client.account;\n\tif (!account) throw new Error(\"Account required\");\n\n\t// Provider: delegate to wallet\n\tif (isProviderAccount(account)) {\n\t\tconst result = await account.provider.request(\"stx_transferStx\", {\n\t\t\trecipient: params.to,\n\t\t\tamount: String(params.amount),\n\t\t\tmemo: params.memo,\n\t\t});\n\t\treturn result.txid;\n\t}\n\n\t// Local/Custom: build → sign → broadcast\n\tconst nonce =\n\t\tparams.nonce ?? (await getNonce(client, { address: account.address }));\n\n\tconst unsigned = buildTokenTransfer({\n\t\trecipient: params.to,\n\t\tamount: params.amount,\n\t\tmemo: params.memo,\n\t\tfee: params.fee ?? 0n,\n\t\tnonce,\n\t\tpublicKey: account.publicKey,\n\t\tchain: client.chain,\n\t\tpostConditionMode: params.postConditionMode,\n\t\tpostConditions: params.postConditions,\n\t});\n\n\tif (params.fee === undefined) {\n\t\tconst estimates = await estimateFee(client, { transaction: unsigned });\n\t\tconst mid = estimates[1] ?? estimates[0];\n\t\tif (mid) {\n\t\t\t(unsigned.auth.spendingCondition as any).fee = BigInt(mid.fee);\n\t\t}\n\t}\n\n\tconst signed = await signTransactionWithAccount(unsigned, account);\n\tconst result = await sendTransaction(client, { transaction: signed });\n\treturn result.txid;\n}\n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Q,WAAW;AAAA,IAC7B,MAAM,YAAY,MAAM,YAAY,QAAQ,EAAE,aAAa,SAAS,CAAC;AAAA,IACrE,MAAM,MAAM,UAAU,MAAM,UAAU;AAAA,IACtC,IAAI,KAAK;AAAA,MACP,SAAS,KAAK,kBAA0B,MAAM,OAAO,IAAI,GAAG;AAAA,IAC9D;AAAA,EACD;AAAA,EAEA,MAAM,SAAS,MAAM,2BAA2B,UAAU,OAAO;AAAA,EACjE,MAAM,SAAS,MAAM,gBAAgB,QAAQ,EAAE,aAAa,OAAO,CAAC;AAAA,EACpE,OAAO,OAAO;AAAA;",
21
+ "debugId": "65C97D7D34400C6264756E2164756E21",
22
+ "names": []
23
+ }
@@ -17,7 +17,9 @@ var PayloadType = {
17
17
  var ClarityVersion = {
18
18
  Clarity1: 1,
19
19
  Clarity2: 2,
20
- Clarity3: 3
20
+ Clarity3: 3,
21
+ Clarity4: 4,
22
+ Clarity5: 5
21
23
  };
22
24
  var AnchorMode = {
23
25
  OnChainOnly: 1,
@@ -75,7 +77,12 @@ var VRF_PROOF_BYTES_LENGTH = 80;
75
77
  var MICROBLOCK_HEADER_BYTES_LENGTH = 132;
76
78
  var TenureChangeCause = {
77
79
  BlockFound: 0,
78
- Extended: 1
80
+ Extended: 1,
81
+ ExtendedRuntime: 2,
82
+ ExtendedReadCount: 3,
83
+ ExtendedReadLength: 4,
84
+ ExtendedWriteCount: 5,
85
+ ExtendedWriteLength: 6
79
86
  };
80
87
 
81
88
  // src/transactions/wire/serialize.ts
@@ -95,7 +102,7 @@ function serializeMemo(memo) {
95
102
  const content = asciiToBytes(memo);
96
103
  const padded = new Uint8Array(MEMO_MAX_LENGTH_BYTES);
97
104
  padded.set(content.slice(0, MEMO_MAX_LENGTH_BYTES));
98
- return concatBytes(writeUInt8(content.length), padded);
105
+ return padded;
99
106
  }
100
107
  function serializeSpendingCondition(condition) {
101
108
  const parts = [
@@ -149,21 +156,24 @@ function serializeAssetInfo(asset) {
149
156
  return concatBytes(serializeAddress(asset.address), serializeLPString(asset.contractName), serializeLPString(asset.assetName));
150
157
  }
151
158
  function serializePostCondition(pc) {
152
- const parts = [serializePrincipal(pc.principal)];
159
+ const parts = [];
153
160
  switch (pc.type) {
154
161
  case "stx":
155
162
  parts.push(writeUInt8(AssetType.STX));
163
+ parts.push(serializePrincipal(pc.principal));
156
164
  parts.push(writeUInt8(pc.conditionCode));
157
165
  parts.push(intToBytes(pc.amount, 8));
158
166
  break;
159
167
  case "ft":
160
168
  parts.push(writeUInt8(AssetType.Fungible));
169
+ parts.push(serializePrincipal(pc.principal));
161
170
  parts.push(serializeAssetInfo(pc.asset));
162
171
  parts.push(writeUInt8(pc.conditionCode));
163
172
  parts.push(intToBytes(pc.amount, 8));
164
173
  break;
165
174
  case "nft":
166
175
  parts.push(writeUInt8(AssetType.NonFungible));
176
+ parts.push(serializePrincipal(pc.principal));
167
177
  parts.push(serializeAssetInfo(pc.asset));
168
178
  parts.push(serializeCVBytes(pc.assetId));
169
179
  parts.push(writeUInt8(pc.conditionCode));
@@ -252,9 +262,9 @@ function serializeTransactionHex(tx) {
252
262
  }
253
263
 
254
264
  // src/transactions/authorization.ts
255
- var import_secp256k1 = require("@noble/secp256k1");
256
265
  var import_hmac = require("@noble/hashes/hmac.js");
257
266
  var import_sha2 = require("@noble/hashes/sha2.js");
267
+ var import_secp256k1 = require("@noble/secp256k1");
258
268
  import_secp256k1.etc.hmacSha256Sync = (key, ...msgs) => {
259
269
  const h = import_hmac.hmac.create(import_sha2.sha256, key);
260
270
  msgs.forEach((msg) => h.update(msg));
@@ -406,7 +416,9 @@ function signMultiSig(tx, privateKey, publicKeys) {
406
416
  if (signerIndex === -1) {
407
417
  throw new Error("Private key does not correspond to any signer in the multi-sig");
408
418
  }
409
- const condition = { ...tx.auth.spendingCondition };
419
+ const condition = {
420
+ ...tx.auth.spendingCondition
421
+ };
410
422
  if (isNonSequential(condition.hashMode)) {
411
423
  return signNonSequential(tx, condition, privateKey);
412
424
  }
@@ -481,7 +493,9 @@ async function signMultiSigWithAccount(tx, account, publicKeys) {
481
493
  if (signerIndex === -1) {
482
494
  throw new Error("Account does not correspond to any signer in the multi-sig");
483
495
  }
484
- const condition = { ...tx.auth.spendingCondition };
496
+ const condition = {
497
+ ...tx.auth.spendingCondition
498
+ };
485
499
  if (isNonSequential(condition.hashMode)) {
486
500
  return signNonSequentialWithAccount(tx, condition, account);
487
501
  }
@@ -603,103 +617,6 @@ function combineMultiSigSignatures(baseTx, signedTxs) {
603
617
  };
604
618
  }
605
619
 
606
- // src/transactions/signer.ts
607
- function txid(tx) {
608
- return txidFromBytes(serializeTransaction(tx));
609
- }
610
- function signBegin(tx) {
611
- const cleared = {
612
- ...tx,
613
- auth: intoInitialSighashAuth(tx.auth)
614
- };
615
- return txid(cleared);
616
- }
617
- function signTransaction(tx, privateKey) {
618
- const sigHash = signBegin(tx);
619
- const condition = tx.auth.spendingCondition;
620
- const { nextSig } = nextSignature(sigHash, AuthType.Standard, condition.fee, condition.nonce, privateKey);
621
- return {
622
- ...tx,
623
- auth: {
624
- ...tx.auth,
625
- spendingCondition: {
626
- ...condition,
627
- signature: nextSig
628
- }
629
- }
630
- };
631
- }
632
- async function signTransactionWithAccount(tx, account) {
633
- const sigHash = signBegin(tx);
634
- const condition = tx.auth.spendingCondition;
635
- const sigHashPre = sigHashPreSign(sigHash, AuthType.Standard, condition.fee, condition.nonce);
636
- const sigBytes = await account.sign(hexToBytes(sigHashPre));
637
- const nextSig = bytesToHex(sigBytes);
638
- return {
639
- ...tx,
640
- auth: {
641
- ...tx.auth,
642
- spendingCondition: {
643
- ...condition,
644
- signature: nextSig
645
- }
646
- }
647
- };
648
- }
649
- function getTransactionId(tx) {
650
- return txid(tx);
651
- }
652
- function getOriginSigHash(tx) {
653
- const condition = tx.auth.spendingCondition;
654
- if ("fields" in condition) {
655
- return replayMultiSigSigHash(tx);
656
- }
657
- const initialSigHash2 = signBegin(tx);
658
- const sc = condition;
659
- const preSign = sigHashPreSign(initialSigHash2, AuthType.Standard, sc.fee, sc.nonce);
660
- return sigHashPostSign(preSign, sc.keyEncoding, sc.signature);
661
- }
662
- function signSponsor(tx, privateKey) {
663
- if (tx.auth.authType !== AuthType.Sponsored) {
664
- throw new Error("Transaction must be sponsored");
665
- }
666
- const auth = tx.auth;
667
- const sponsorCondition = auth.sponsorSpendingCondition;
668
- const originSigHash = getOriginSigHash(tx);
669
- const { nextSig } = nextSignature(originSigHash, AuthType.Sponsored, sponsorCondition.fee, sponsorCondition.nonce, privateKey);
670
- return {
671
- ...tx,
672
- auth: {
673
- ...auth,
674
- sponsorSpendingCondition: {
675
- ...sponsorCondition,
676
- signature: nextSig
677
- }
678
- }
679
- };
680
- }
681
- async function signSponsorWithAccount(tx, account) {
682
- if (tx.auth.authType !== AuthType.Sponsored) {
683
- throw new Error("Transaction must be sponsored");
684
- }
685
- const auth = tx.auth;
686
- const sponsorCondition = auth.sponsorSpendingCondition;
687
- const originSigHash = getOriginSigHash(tx);
688
- const sigHashPre = sigHashPreSign(originSigHash, AuthType.Sponsored, sponsorCondition.fee, sponsorCondition.nonce);
689
- const sigBytes = await account.sign(hexToBytes(sigHashPre));
690
- const nextSig = bytesToHex(sigBytes);
691
- return {
692
- ...tx,
693
- auth: {
694
- ...auth,
695
- sponsorSpendingCondition: {
696
- ...sponsorCondition,
697
- signature: nextSig
698
- }
699
- }
700
- };
701
- }
702
-
703
620
  // src/transactions/build.ts
704
621
  function resolvePcMode(mode) {
705
622
  return mode === "allow" ? PostConditionModeWire.Allow : PostConditionModeWire.Deny;
@@ -848,5 +765,102 @@ function buildContractDeploy(options) {
848
765
  return tx;
849
766
  }
850
767
 
851
- //# debugId=F9AB0B29B396E33564756E2164756E21
852
- //# sourceMappingURL=stacks-vbke9mqw.cjs.map
768
+ // src/transactions/signer.ts
769
+ function txid(tx) {
770
+ return txidFromBytes(serializeTransaction(tx));
771
+ }
772
+ function signBegin(tx) {
773
+ const cleared = {
774
+ ...tx,
775
+ auth: intoInitialSighashAuth(tx.auth)
776
+ };
777
+ return txid(cleared);
778
+ }
779
+ function signTransaction(tx, privateKey) {
780
+ const sigHash = signBegin(tx);
781
+ const condition = tx.auth.spendingCondition;
782
+ const { nextSig } = nextSignature(sigHash, AuthType.Standard, condition.fee, condition.nonce, privateKey);
783
+ return {
784
+ ...tx,
785
+ auth: {
786
+ ...tx.auth,
787
+ spendingCondition: {
788
+ ...condition,
789
+ signature: nextSig
790
+ }
791
+ }
792
+ };
793
+ }
794
+ async function signTransactionWithAccount(tx, account) {
795
+ const sigHash = signBegin(tx);
796
+ const condition = tx.auth.spendingCondition;
797
+ const sigHashPre = sigHashPreSign(sigHash, AuthType.Standard, condition.fee, condition.nonce);
798
+ const sigBytes = await account.sign(hexToBytes(sigHashPre));
799
+ const nextSig = bytesToHex(sigBytes);
800
+ return {
801
+ ...tx,
802
+ auth: {
803
+ ...tx.auth,
804
+ spendingCondition: {
805
+ ...condition,
806
+ signature: nextSig
807
+ }
808
+ }
809
+ };
810
+ }
811
+ function getTransactionId(tx) {
812
+ return txid(tx);
813
+ }
814
+ function getOriginSigHash(tx) {
815
+ const condition = tx.auth.spendingCondition;
816
+ if ("fields" in condition) {
817
+ return replayMultiSigSigHash(tx);
818
+ }
819
+ const initialSigHash2 = signBegin(tx);
820
+ const sc = condition;
821
+ const preSign = sigHashPreSign(initialSigHash2, AuthType.Standard, sc.fee, sc.nonce);
822
+ return sigHashPostSign(preSign, sc.keyEncoding, sc.signature);
823
+ }
824
+ function signSponsor(tx, privateKey) {
825
+ if (tx.auth.authType !== AuthType.Sponsored) {
826
+ throw new Error("Transaction must be sponsored");
827
+ }
828
+ const auth = tx.auth;
829
+ const sponsorCondition = auth.sponsorSpendingCondition;
830
+ const originSigHash = getOriginSigHash(tx);
831
+ const { nextSig } = nextSignature(originSigHash, AuthType.Sponsored, sponsorCondition.fee, sponsorCondition.nonce, privateKey);
832
+ return {
833
+ ...tx,
834
+ auth: {
835
+ ...auth,
836
+ sponsorSpendingCondition: {
837
+ ...sponsorCondition,
838
+ signature: nextSig
839
+ }
840
+ }
841
+ };
842
+ }
843
+ async function signSponsorWithAccount(tx, account) {
844
+ if (tx.auth.authType !== AuthType.Sponsored) {
845
+ throw new Error("Transaction must be sponsored");
846
+ }
847
+ const auth = tx.auth;
848
+ const sponsorCondition = auth.sponsorSpendingCondition;
849
+ const originSigHash = getOriginSigHash(tx);
850
+ const sigHashPre = sigHashPreSign(originSigHash, AuthType.Sponsored, sponsorCondition.fee, sponsorCondition.nonce);
851
+ const sigBytes = await account.sign(hexToBytes(sigHashPre));
852
+ const nextSig = bytesToHex(sigBytes);
853
+ return {
854
+ ...tx,
855
+ auth: {
856
+ ...auth,
857
+ sponsorSpendingCondition: {
858
+ ...sponsorCondition,
859
+ signature: nextSig
860
+ }
861
+ }
862
+ };
863
+ }
864
+
865
+ //# debugId=2D9CB03503C2B15F64756E2164756E21
866
+ //# sourceMappingURL=stacks-17sdtaxg.cjs.map