@secondlayer/stacks 0.0.1

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 (178) hide show
  1. package/README.md +92 -0
  2. package/dist/shared/stacks-02actsrx.cjs +17 -0
  3. package/dist/shared/stacks-02actsrx.cjs.map +10 -0
  4. package/dist/shared/stacks-1aqm7c2h.cjs +110 -0
  5. package/dist/shared/stacks-1aqm7c2h.cjs.map +11 -0
  6. package/dist/shared/stacks-24h5k94q.cjs +74 -0
  7. package/dist/shared/stacks-24h5k94q.cjs.map +11 -0
  8. package/dist/shared/stacks-2ar4prfz.cjs +328 -0
  9. package/dist/shared/stacks-2ar4prfz.cjs.map +11 -0
  10. package/dist/shared/stacks-4py5pm0r.cjs +237 -0
  11. package/dist/shared/stacks-4py5pm0r.cjs.map +10 -0
  12. package/dist/shared/stacks-5tprhns9.cjs +54 -0
  13. package/dist/shared/stacks-5tprhns9.cjs.map +11 -0
  14. package/dist/shared/stacks-61rvzkz1.cjs +132 -0
  15. package/dist/shared/stacks-61rvzkz1.cjs.map +17 -0
  16. package/dist/shared/stacks-709tra19.js +30 -0
  17. package/dist/shared/stacks-709tra19.js.map +10 -0
  18. package/dist/shared/stacks-74k8cxgb.cjs +567 -0
  19. package/dist/shared/stacks-74k8cxgb.cjs.map +13 -0
  20. package/dist/shared/stacks-8m9byk2j.js +7 -0
  21. package/dist/shared/stacks-8m9byk2j.js.map +9 -0
  22. package/dist/shared/stacks-8yykgdww.js +125 -0
  23. package/dist/shared/stacks-8yykgdww.js.map +11 -0
  24. package/dist/shared/stacks-9g0jhab3.cjs +40 -0
  25. package/dist/shared/stacks-9g0jhab3.cjs.map +10 -0
  26. package/dist/shared/stacks-an5k8n4t.cjs +291 -0
  27. package/dist/shared/stacks-an5k8n4t.cjs.map +23 -0
  28. package/dist/shared/stacks-b008c3w8.cjs +214 -0
  29. package/dist/shared/stacks-b008c3w8.cjs.map +11 -0
  30. package/dist/shared/stacks-bnvfmt7y.cjs +31 -0
  31. package/dist/shared/stacks-bnvfmt7y.cjs.map +9 -0
  32. package/dist/shared/stacks-bycy6t9k.js +22 -0
  33. package/dist/shared/stacks-bycy6t9k.js.map +10 -0
  34. package/dist/shared/stacks-d1fmkv3p.js +258 -0
  35. package/dist/shared/stacks-d1fmkv3p.js.map +13 -0
  36. package/dist/shared/stacks-dr5en54r.cjs +119 -0
  37. package/dist/shared/stacks-dr5en54r.cjs.map +10 -0
  38. package/dist/shared/stacks-dxhntr76.js +278 -0
  39. package/dist/shared/stacks-dxhntr76.js.map +10 -0
  40. package/dist/shared/stacks-evnzth1q.cjs +35 -0
  41. package/dist/shared/stacks-evnzth1q.cjs.map +10 -0
  42. package/dist/shared/stacks-f3tk2k5s.js +27 -0
  43. package/dist/shared/stacks-f3tk2k5s.js.map +9 -0
  44. package/dist/shared/stacks-f7wdrzs3.js +285 -0
  45. package/dist/shared/stacks-f7wdrzs3.js.map +11 -0
  46. package/dist/shared/stacks-fcaefc5b.cjs +16 -0
  47. package/dist/shared/stacks-fcaefc5b.cjs.map +10 -0
  48. package/dist/shared/stacks-g9mcjcqg.cjs +3 -0
  49. package/dist/shared/stacks-g9mcjcqg.cjs.map +9 -0
  50. package/dist/shared/stacks-gck1sq7h.cjs +28 -0
  51. package/dist/shared/stacks-gck1sq7h.cjs.map +10 -0
  52. package/dist/shared/stacks-gjvbq6w7.js +46 -0
  53. package/dist/shared/stacks-gjvbq6w7.js.map +10 -0
  54. package/dist/shared/stacks-j2cy7qtt.js +237 -0
  55. package/dist/shared/stacks-j2cy7qtt.js.map +11 -0
  56. package/dist/shared/stacks-k08tgzyp.cjs +232 -0
  57. package/dist/shared/stacks-k08tgzyp.cjs.map +13 -0
  58. package/dist/shared/stacks-k2p5tv6x.js +37 -0
  59. package/dist/shared/stacks-k2p5tv6x.js.map +10 -0
  60. package/dist/shared/stacks-k58k970n.js +234 -0
  61. package/dist/shared/stacks-k58k970n.js.map +10 -0
  62. package/dist/shared/stacks-n2g56wgg.js +338 -0
  63. package/dist/shared/stacks-n2g56wgg.js.map +23 -0
  64. package/dist/shared/stacks-nqytwfcc.js +243 -0
  65. package/dist/shared/stacks-nqytwfcc.js.map +11 -0
  66. package/dist/shared/stacks-qcae5852.js +19 -0
  67. package/dist/shared/stacks-qcae5852.js.map +10 -0
  68. package/dist/shared/stacks-qt8ehebn.js +76 -0
  69. package/dist/shared/stacks-qt8ehebn.js.map +11 -0
  70. package/dist/shared/stacks-qvg7c24g.cjs +232 -0
  71. package/dist/shared/stacks-qvg7c24g.cjs.map +10 -0
  72. package/dist/shared/stacks-r1t6g3c3.cjs +241 -0
  73. package/dist/shared/stacks-r1t6g3c3.cjs.map +11 -0
  74. package/dist/shared/stacks-tjxmrssa.js +282 -0
  75. package/dist/shared/stacks-tjxmrssa.js.map +11 -0
  76. package/dist/shared/stacks-v9jqcpd4.js +18 -0
  77. package/dist/shared/stacks-v9jqcpd4.js.map +10 -0
  78. package/dist/shared/stacks-vdfag81a.cjs +121 -0
  79. package/dist/shared/stacks-vdfag81a.cjs.map +10 -0
  80. package/dist/shared/stacks-vdfs3e5v.js +134 -0
  81. package/dist/shared/stacks-vdfs3e5v.js.map +10 -0
  82. package/dist/shared/stacks-y3dh7hv1.js +60 -0
  83. package/dist/shared/stacks-y3dh7hv1.js.map +11 -0
  84. package/dist/shared/stacks-ya3x01yd.cjs +16 -0
  85. package/dist/shared/stacks-ya3x01yd.cjs.map +10 -0
  86. package/dist/shared/stacks-yfgsm6ap.js +599 -0
  87. package/dist/shared/stacks-yfgsm6ap.js.map +13 -0
  88. package/dist/shared/stacks-yfveb68e.js +121 -0
  89. package/dist/shared/stacks-yfveb68e.js.map +10 -0
  90. package/dist/shared/stacks-zm0b3tgy.js +160 -0
  91. package/dist/shared/stacks-zm0b3tgy.js.map +17 -0
  92. package/dist/shared/stacks-zyv9qqme.cjs +249 -0
  93. package/dist/shared/stacks-zyv9qqme.cjs.map +11 -0
  94. package/dist/src/accounts/index.cjs +90 -0
  95. package/dist/src/accounts/index.cjs.map +12 -0
  96. package/dist/src/accounts/index.d.cts +47 -0
  97. package/dist/src/accounts/index.d.ts +47 -0
  98. package/dist/src/accounts/index.js +104 -0
  99. package/dist/src/accounts/index.js.map +12 -0
  100. package/dist/src/actions/index.cjs +36 -0
  101. package/dist/src/actions/index.cjs.map +9 -0
  102. package/dist/src/actions/index.d.cts +886 -0
  103. package/dist/src/actions/index.d.ts +886 -0
  104. package/dist/src/actions/index.js +81 -0
  105. package/dist/src/actions/index.js.map +9 -0
  106. package/dist/src/bns/index.cjs +590 -0
  107. package/dist/src/bns/index.cjs.map +15 -0
  108. package/dist/src/bns/index.d.cts +241 -0
  109. package/dist/src/bns/index.d.ts +241 -0
  110. package/dist/src/bns/index.js +611 -0
  111. package/dist/src/bns/index.js.map +15 -0
  112. package/dist/src/chains/index.cjs +13 -0
  113. package/dist/src/chains/index.cjs.map +9 -0
  114. package/dist/src/chains/index.d.cts +53 -0
  115. package/dist/src/chains/index.d.ts +53 -0
  116. package/dist/src/chains/index.js +18 -0
  117. package/dist/src/chains/index.js.map +9 -0
  118. package/dist/src/clarity/index.cjs +3 -0
  119. package/dist/src/clarity/index.cjs.map +9 -0
  120. package/dist/src/clarity/index.d.cts +821 -0
  121. package/dist/src/clarity/index.d.ts +821 -0
  122. package/dist/src/clarity/index.js +145 -0
  123. package/dist/src/clarity/index.js.map +9 -0
  124. package/dist/src/connect/index.cjs +480 -0
  125. package/dist/src/connect/index.cjs.map +19 -0
  126. package/dist/src/connect/index.d.cts +110 -0
  127. package/dist/src/connect/index.d.ts +110 -0
  128. package/dist/src/connect/index.js +448 -0
  129. package/dist/src/connect/index.js.map +19 -0
  130. package/dist/src/connect/walletconnect/index.cjs +1322 -0
  131. package/dist/src/connect/walletconnect/index.cjs.map +18 -0
  132. package/dist/src/connect/walletconnect/index.d.cts +132 -0
  133. package/dist/src/connect/walletconnect/index.d.ts +132 -0
  134. package/dist/src/connect/walletconnect/index.js +1290 -0
  135. package/dist/src/connect/walletconnect/index.js.map +18 -0
  136. package/dist/src/index.cjs +557 -0
  137. package/dist/src/index.cjs.map +21 -0
  138. package/dist/src/index.d.cts +847 -0
  139. package/dist/src/index.d.ts +847 -0
  140. package/dist/src/index.js +629 -0
  141. package/dist/src/index.js.map +21 -0
  142. package/dist/src/postconditions/index.cjs +3 -0
  143. package/dist/src/postconditions/index.cjs.map +9 -0
  144. package/dist/src/postconditions/index.d.cts +91 -0
  145. package/dist/src/postconditions/index.d.ts +91 -0
  146. package/dist/src/postconditions/index.js +12 -0
  147. package/dist/src/postconditions/index.js.map +9 -0
  148. package/dist/src/pox/index.cjs +860 -0
  149. package/dist/src/pox/index.cjs.map +15 -0
  150. package/dist/src/pox/index.d.cts +244 -0
  151. package/dist/src/pox/index.d.ts +244 -0
  152. package/dist/src/pox/index.js +877 -0
  153. package/dist/src/pox/index.js.map +15 -0
  154. package/dist/src/stackingdao/index.cjs +300 -0
  155. package/dist/src/stackingdao/index.cjs.map +13 -0
  156. package/dist/src/stackingdao/index.d.cts +179 -0
  157. package/dist/src/stackingdao/index.d.ts +179 -0
  158. package/dist/src/stackingdao/index.js +318 -0
  159. package/dist/src/stackingdao/index.js.map +13 -0
  160. package/dist/src/subscriptions/index.cjs +14 -0
  161. package/dist/src/subscriptions/index.cjs.map +9 -0
  162. package/dist/src/subscriptions/index.d.cts +250 -0
  163. package/dist/src/subscriptions/index.d.ts +250 -0
  164. package/dist/src/subscriptions/index.js +21 -0
  165. package/dist/src/subscriptions/index.js.map +9 -0
  166. package/dist/src/transactions/index.cjs +50 -0
  167. package/dist/src/transactions/index.cjs.map +9 -0
  168. package/dist/src/transactions/index.d.cts +412 -0
  169. package/dist/src/transactions/index.d.ts +412 -0
  170. package/dist/src/transactions/index.js +101 -0
  171. package/dist/src/transactions/index.js.map +9 -0
  172. package/dist/src/utils/index.cjs +168 -0
  173. package/dist/src/utils/index.cjs.map +11 -0
  174. package/dist/src/utils/index.d.cts +140 -0
  175. package/dist/src/utils/index.d.ts +140 -0
  176. package/dist/src/utils/index.js +222 -0
  177. package/dist/src/utils/index.js.map +11 -0
  178. package/package.json +105 -0
@@ -0,0 +1,412 @@
1
+ type IntCV = {
2
+ readonly type: "int"
3
+ readonly value: bigint
4
+ };
5
+ type UIntCV = {
6
+ readonly type: "uint"
7
+ readonly value: bigint
8
+ };
9
+ type BooleanCV = TrueCV | FalseCV;
10
+ type TrueCV = {
11
+ readonly type: "true"
12
+ };
13
+ type FalseCV = {
14
+ readonly type: "false"
15
+ };
16
+ type BufferCV = {
17
+ readonly type: "buffer"
18
+ readonly value: string
19
+ };
20
+ type NoneCV = {
21
+ readonly type: "none"
22
+ };
23
+ type SomeCV = {
24
+ readonly type: "some"
25
+ readonly value: ClarityValue
26
+ };
27
+ type ResponseOkCV = {
28
+ readonly type: "ok"
29
+ readonly value: ClarityValue
30
+ };
31
+ type ResponseErrorCV = {
32
+ readonly type: "err"
33
+ readonly value: ClarityValue
34
+ };
35
+ type StandardPrincipalCV = {
36
+ readonly type: "address"
37
+ readonly value: string
38
+ };
39
+ type ContractPrincipalCV = {
40
+ readonly type: "contract"
41
+ readonly value: string
42
+ };
43
+ type ListCV = {
44
+ type: "list"
45
+ value: ClarityValue[]
46
+ };
47
+ type TupleData = {
48
+ [key: string]: ClarityValue
49
+ };
50
+ type TupleCV = {
51
+ type: "tuple"
52
+ value: TupleData
53
+ };
54
+ type StringAsciiCV = {
55
+ readonly type: "ascii"
56
+ readonly value: string
57
+ };
58
+ type StringUtf8CV = {
59
+ readonly type: "utf8"
60
+ readonly value: string
61
+ };
62
+ type ClarityValue = IntCV | UIntCV | BooleanCV | BufferCV | NoneCV | SomeCV | ResponseOkCV | ResponseErrorCV | StandardPrincipalCV | ContractPrincipalCV | ListCV | TupleCV | StringAsciiCV | StringUtf8CV;
63
+ declare const AuthType: {
64
+ readonly Standard: 0x04
65
+ readonly Sponsored: 0x05
66
+ };
67
+ type AuthType = (typeof AuthType)[keyof typeof AuthType];
68
+ declare const PayloadType: {
69
+ readonly TokenTransfer: 0x00
70
+ readonly SmartContract: 0x01
71
+ readonly ContractCall: 0x02
72
+ readonly PoisonMicroblock: 0x03
73
+ readonly Coinbase: 0x04
74
+ readonly CoinbaseToAltRecipient: 0x05
75
+ readonly VersionedSmartContract: 0x06
76
+ readonly TenureChange: 0x07
77
+ readonly NakamotoCoinbase: 0x08
78
+ };
79
+ type PayloadType = (typeof PayloadType)[keyof typeof PayloadType];
80
+ declare const ClarityVersion: {
81
+ readonly Clarity1: 1
82
+ readonly Clarity2: 2
83
+ readonly Clarity3: 3
84
+ };
85
+ type ClarityVersion = (typeof ClarityVersion)[keyof typeof ClarityVersion];
86
+ declare const AnchorMode: {
87
+ readonly OnChainOnly: 0x01
88
+ readonly OffChainOnly: 0x02
89
+ readonly Any: 0x03
90
+ };
91
+ type AnchorMode = (typeof AnchorMode)[keyof typeof AnchorMode];
92
+ declare const PostConditionModeWire: {
93
+ readonly Allow: 0x01
94
+ readonly Deny: 0x02
95
+ };
96
+ type PostConditionModeWire = (typeof PostConditionModeWire)[keyof typeof PostConditionModeWire];
97
+ declare const AddressHashMode: {
98
+ readonly P2PKH: 0x00
99
+ readonly P2SH: 0x01
100
+ readonly P2WPKH: 0x02
101
+ readonly P2WSH: 0x03
102
+ readonly P2SH_NonSequential: 0x05
103
+ readonly P2WSH_P2SH_NonSequential: 0x07
104
+ };
105
+ type AddressHashMode = (typeof AddressHashMode)[keyof typeof AddressHashMode];
106
+ declare const PubKeyEncoding: {
107
+ readonly Compressed: 0x00
108
+ readonly Uncompressed: 0x01
109
+ };
110
+ type PubKeyEncoding = (typeof PubKeyEncoding)[keyof typeof PubKeyEncoding];
111
+ declare const FungibleConditionCode: {
112
+ readonly Equal: 0x01
113
+ readonly Greater: 0x02
114
+ readonly GreaterEqual: 0x03
115
+ readonly Less: 0x04
116
+ readonly LessEqual: 0x05
117
+ };
118
+ declare const NonFungibleConditionCode: {
119
+ readonly Sends: 0x10
120
+ readonly DoesNotSend: 0x11
121
+ };
122
+ declare const PostConditionPrincipalId: {
123
+ readonly Origin: 0x01
124
+ readonly Standard: 0x02
125
+ readonly Contract: 0x03
126
+ };
127
+ declare const AssetType: {
128
+ readonly STX: 0x00
129
+ readonly Fungible: 0x01
130
+ readonly NonFungible: 0x02
131
+ };
132
+ declare const AuthFieldType: {
133
+ readonly PublicKeyCompressed: 0x00
134
+ readonly PublicKeyUncompressed: 0x01
135
+ readonly SignatureCompressed: 0x02
136
+ readonly SignatureUncompressed: 0x03
137
+ };
138
+ declare const RECOVERABLE_ECDSA_SIG_LENGTH_BYTES = 65;
139
+ declare const MEMO_MAX_LENGTH_BYTES = 34;
140
+ declare const MAX_STRING_LENGTH_BYTES = 128;
141
+ type TokenTransferPayload = {
142
+ payloadType: typeof PayloadType.TokenTransfer
143
+ recipient: ClarityValue
144
+ amount: bigint
145
+ memo: string
146
+ };
147
+ type ContractCallPayload = {
148
+ payloadType: typeof PayloadType.ContractCall
149
+ contractAddress: string
150
+ contractName: string
151
+ functionName: string
152
+ functionArgs: ClarityValue[]
153
+ };
154
+ type SmartContractPayload = {
155
+ payloadType: typeof PayloadType.SmartContract | typeof PayloadType.VersionedSmartContract
156
+ clarityVersion?: ClarityVersion
157
+ contractName: string
158
+ codeBody: string
159
+ };
160
+ type TransactionPayload = TokenTransferPayload | ContractCallPayload | SmartContractPayload;
161
+ type SingleSigSpendingCondition = {
162
+ hashMode: typeof AddressHashMode.P2PKH | typeof AddressHashMode.P2WPKH
163
+ signer: string
164
+ nonce: bigint
165
+ fee: bigint
166
+ keyEncoding: PubKeyEncoding
167
+ signature: string
168
+ };
169
+ type TransactionAuthField = {
170
+ pubKeyEncoding: PubKeyEncoding
171
+ type: "publicKey" | "signature"
172
+ data: string
173
+ };
174
+ type MultiSigHashMode = typeof AddressHashMode.P2SH | typeof AddressHashMode.P2WSH | typeof AddressHashMode.P2SH_NonSequential | typeof AddressHashMode.P2WSH_P2SH_NonSequential;
175
+ type MultiSigSpendingCondition = {
176
+ hashMode: MultiSigHashMode
177
+ signer: string
178
+ nonce: bigint
179
+ fee: bigint
180
+ fields: TransactionAuthField[]
181
+ signaturesRequired: number
182
+ };
183
+ type SpendingCondition = SingleSigSpendingCondition | MultiSigSpendingCondition;
184
+ type StandardAuthorization = {
185
+ authType: typeof AuthType.Standard
186
+ spendingCondition: SpendingCondition
187
+ };
188
+ type SponsoredAuthorization = {
189
+ authType: typeof AuthType.Sponsored
190
+ spendingCondition: SpendingCondition
191
+ sponsorSpendingCondition: SpendingCondition
192
+ };
193
+ type Authorization = StandardAuthorization | SponsoredAuthorization;
194
+ type StacksTransaction = {
195
+ version: number
196
+ chainId: number
197
+ auth: Authorization
198
+ anchorMode: AnchorMode
199
+ postConditionMode: PostConditionModeWire
200
+ postConditions: PostConditionWire[]
201
+ payload: TransactionPayload
202
+ };
203
+ type PostConditionWire = StxPostConditionWire | FtPostConditionWire | NftPostConditionWire;
204
+ type StxPostConditionWire = {
205
+ type: "stx"
206
+ principal: PostConditionPrincipalWire
207
+ conditionCode: number
208
+ amount: bigint
209
+ };
210
+ type FtPostConditionWire = {
211
+ type: "ft"
212
+ principal: PostConditionPrincipalWire
213
+ asset: AssetInfoWire
214
+ conditionCode: number
215
+ amount: bigint
216
+ };
217
+ type NftPostConditionWire = {
218
+ type: "nft"
219
+ principal: PostConditionPrincipalWire
220
+ asset: AssetInfoWire
221
+ conditionCode: number
222
+ assetId: ClarityValue
223
+ };
224
+ type PostConditionPrincipalWire = {
225
+ type: "origin"
226
+ } | {
227
+ type: "standard"
228
+ address: string
229
+ } | {
230
+ type: "contract"
231
+ address: string
232
+ contractName: string
233
+ };
234
+ type AssetInfoWire = {
235
+ address: string
236
+ contractName: string
237
+ assetName: string
238
+ };
239
+ declare function createSingleSigSpendingCondition(publicKey: string, nonce: bigint, fee: bigint): SingleSigSpendingCondition;
240
+ declare function createStandardAuth(spendingCondition: SpendingCondition): StandardAuthorization;
241
+ declare function createSponsoredAuth(spendingCondition: SpendingCondition, sponsorSpendingCondition?: SpendingCondition): SponsoredAuthorization;
242
+ /** Compute pre-sign sighash = sha512/256(prevSigHash + authType + fee + nonce) */
243
+ declare function sigHashPreSign(curSigHash: string, authType: number, fee: bigint, nonce: bigint): string;
244
+ /** Compute post-sign sighash = sha512/256(preSigHash + pubKeyEncoding + signature) */
245
+ declare function sigHashPostSign(curSigHash: string, pubKeyEncoding: number, signature: string): string;
246
+ declare function nextSignature(curSigHash: string, authType: number, fee: bigint, nonce: bigint, privateKey: string): {
247
+ nextSig: string
248
+ nextSigHash: string
249
+ };
250
+ /** Account derived from a local private key (mnemonic or raw key). */
251
+ type LocalAccount = {
252
+ type: "local"
253
+ address: string
254
+ /** Compressed public key (hex) */
255
+ publicKey: string
256
+ /** Raw ECDSA sign over a hash */
257
+ sign(hash: Uint8Array): Uint8Array
258
+ /** Sign a structured message (SIP-018) */
259
+ signMessage(message: string | Uint8Array): string
260
+ };
261
+ /** Account with a user-provided signing function (sync or async). */
262
+ type CustomAccount = {
263
+ type: "custom"
264
+ address: string
265
+ publicKey: string
266
+ sign(hash: Uint8Array): Promise<Uint8Array> | Uint8Array
267
+ };
268
+ /** Compute the initial sighash for a transaction */
269
+ declare function signBegin(tx: StacksTransaction): string;
270
+ /** Sign a single-sig transaction with a private key, returning the signed transaction */
271
+ declare function signTransaction(tx: StacksTransaction, privateKey: string): StacksTransaction;
272
+ /** Sign a single-sig transaction using an account (LocalAccount or CustomAccount) */
273
+ declare function signTransactionWithAccount(tx: StacksTransaction, account: LocalAccount | CustomAccount): Promise<StacksTransaction>;
274
+ /** Get the txid of a transaction */
275
+ declare function getTransactionId(tx: StacksTransaction): string;
276
+ /** Reconstruct the sighash after origin signing (needed for sponsor signing) */
277
+ declare function getOriginSigHash(tx: StacksTransaction): string;
278
+ /** Sign a sponsored transaction as the sponsor with a private key */
279
+ declare function signSponsor(tx: StacksTransaction, privateKey: string): StacksTransaction;
280
+ /** Sign a sponsored transaction as the sponsor using an account */
281
+ declare function signSponsorWithAccount(tx: StacksTransaction, account: LocalAccount | CustomAccount): Promise<StacksTransaction>;
282
+ /** Full chain descriptor used by clients and transports for network-aware operations. */
283
+ type StacksChain = {
284
+ /** Chain ID (e.g. 0x00000001 for mainnet) */
285
+ id: number
286
+ /** Human-readable name */
287
+ name: string
288
+ /** Network type */
289
+ network: "mainnet" | "testnet"
290
+ /** Transaction version byte for serialization */
291
+ transactionVersion: number
292
+ /** Peer network ID for P2P broadcasting */
293
+ peerNetworkId: number
294
+ /** Address version bytes */
295
+ addressVersion: {
296
+ singleSig: number
297
+ multiSig: number
298
+ }
299
+ /** Magic bytes for network identification */
300
+ magicBytes: string
301
+ /** Boot address (system contracts deployer) */
302
+ bootAddress: string
303
+ /** Native currency info */
304
+ nativeCurrency: {
305
+ name: string
306
+ symbol: string
307
+ decimals: number
308
+ }
309
+ /** Default RPC URLs */
310
+ rpcUrls: {
311
+ default: {
312
+ http: string[]
313
+ ws?: string[]
314
+ }
315
+ }
316
+ /** Block explorer URLs */
317
+ blockExplorers?: {
318
+ default: {
319
+ name: string
320
+ url: string
321
+ }
322
+ }
323
+ };
324
+ type FungibleComparator = "eq" | "gt" | "gte" | "lt" | "lte";
325
+ type NonFungibleComparator = "sent" | "not-sent";
326
+ type StxPostCondition = {
327
+ type: "stx-postcondition"
328
+ address: string
329
+ condition: FungibleComparator
330
+ amount: string | bigint | number
331
+ };
332
+ type FtPostCondition = {
333
+ type: "ft-postcondition"
334
+ address: string
335
+ condition: FungibleComparator
336
+ asset: string
337
+ amount: string | bigint | number
338
+ };
339
+ type NftPostCondition = {
340
+ type: "nft-postcondition"
341
+ address: string
342
+ condition: NonFungibleComparator
343
+ asset: string
344
+ assetId: ClarityValue
345
+ };
346
+ type PostCondition = StxPostCondition | FtPostCondition | NftPostCondition;
347
+ type IntegerType = number | string | bigint | Uint8Array;
348
+ type MultiSigOptions = {
349
+ publicKeys?: string[]
350
+ signaturesRequired?: number
351
+ hashMode?: MultiSigHashMode
352
+ };
353
+ type BuildTokenTransferOptions = MultiSigOptions & {
354
+ recipient: string
355
+ amount: IntegerType
356
+ memo?: string
357
+ fee: IntegerType
358
+ nonce: IntegerType
359
+ publicKey?: string
360
+ chain?: StacksChain
361
+ postConditionMode?: "allow" | "deny"
362
+ postConditions?: PostCondition[]
363
+ sponsored?: boolean
364
+ };
365
+ type BuildContractCallOptions = MultiSigOptions & {
366
+ contractAddress: string
367
+ contractName: string
368
+ functionName: string
369
+ functionArgs: ClarityValue[]
370
+ fee: IntegerType
371
+ nonce: IntegerType
372
+ publicKey?: string
373
+ chain?: StacksChain
374
+ postConditionMode?: "allow" | "deny"
375
+ postConditions?: PostCondition[]
376
+ sponsored?: boolean
377
+ };
378
+ type BuildContractDeployOptions = MultiSigOptions & {
379
+ contractName: string
380
+ codeBody: string
381
+ clarityVersion?: ClarityVersion
382
+ fee: IntegerType
383
+ nonce: IntegerType
384
+ publicKey?: string
385
+ chain?: StacksChain
386
+ postConditionMode?: "allow" | "deny"
387
+ postConditions?: PostCondition[]
388
+ sponsored?: boolean
389
+ };
390
+ declare function buildTokenTransfer(options: BuildTokenTransferOptions): StacksTransaction;
391
+ declare function buildContractCall(options: BuildContractCallOptions): StacksTransaction;
392
+ declare function buildContractDeploy(options: BuildContractDeployOptions): StacksTransaction;
393
+ declare function serializeTransaction(tx: StacksTransaction): Uint8Array;
394
+ declare function serializeTransactionHex(tx: StacksTransaction): string;
395
+ declare function deserializeTransaction(input: string | Uint8Array): StacksTransaction;
396
+ /** Check if hash mode is non-sequential (SIP-027) */
397
+ declare function isNonSequential(hashMode: number): boolean;
398
+ /** Derive a multi-sig address from public keys */
399
+ declare function makeMultiSigAddress(publicKeys: string[], signaturesRequired: number, chain?: StacksChain): string;
400
+ /** Create an empty multi-sig spending condition */
401
+ declare function createMultiSigSpendingCondition(publicKeys: string[], signaturesRequired: number, nonce: bigint, fee: bigint, hashMode?: MultiSigHashMode): MultiSigSpendingCondition;
402
+ /** Replay sighash through existing auth fields of a multi-sig tx */
403
+ declare function replayMultiSigSigHash(tx: StacksTransaction): string;
404
+ /** Sign one position of a multi-sig transaction with a private key */
405
+ declare function signMultiSig(tx: StacksTransaction, privateKey: string, publicKeys: string[]): StacksTransaction;
406
+ /** Sign one position of a multi-sig transaction with an account */
407
+ declare function signMultiSigWithAccount(tx: StacksTransaction, account: LocalAccount | CustomAccount, publicKeys: string[]): Promise<StacksTransaction>;
408
+ /** Fill remaining slots with pubkey fields after all signatures are collected */
409
+ declare function finalizeMultiSig(tx: StacksTransaction, publicKeys: string[]): StacksTransaction;
410
+ /** Combine independently-signed non-sequential multi-sig transactions */
411
+ declare function combineMultiSigSignatures(baseTx: StacksTransaction, signedTxs: StacksTransaction[]): StacksTransaction;
412
+ export { signTransactionWithAccount, signTransaction, signSponsorWithAccount, signSponsor, signMultiSigWithAccount, signMultiSig, signBegin, sigHashPreSign, sigHashPostSign, serializeTransactionHex, serializeTransaction, replayMultiSigSigHash, nextSignature, makeMultiSigAddress, isNonSequential, getTransactionId, getOriginSigHash, finalizeMultiSig, deserializeTransaction, createStandardAuth, createSponsoredAuth, createSingleSigSpendingCondition, createMultiSigSpendingCondition, combineMultiSigSignatures, buildTokenTransfer, buildContractDeploy, buildContractCall, TransactionPayload, TransactionAuthField, TokenTransferPayload, StandardAuthorization, StacksTransaction, SponsoredAuthorization, SpendingCondition, SmartContractPayload, SingleSigSpendingCondition, RECOVERABLE_ECDSA_SIG_LENGTH_BYTES, PubKeyEncoding, PostConditionWire, PostConditionPrincipalId, PostConditionModeWire, PayloadType, NonFungibleConditionCode, MultiSigSpendingCondition, MultiSigHashMode, MEMO_MAX_LENGTH_BYTES, MAX_STRING_LENGTH_BYTES, FungibleConditionCode, ContractCallPayload, ClarityVersion, BuildTokenTransferOptions, BuildContractDeployOptions, BuildContractCallOptions, Authorization, AuthType, AuthFieldType, AssetType, AnchorMode, AddressHashMode };
@@ -0,0 +1,101 @@
1
+ import {
2
+ deserializeTransaction
3
+ } from "../../shared/stacks-dxhntr76.js";
4
+ import {
5
+ buildContractCall,
6
+ buildContractDeploy,
7
+ buildTokenTransfer,
8
+ getOriginSigHash,
9
+ getTransactionId,
10
+ signBegin,
11
+ signSponsor,
12
+ signSponsorWithAccount,
13
+ signTransaction,
14
+ signTransactionWithAccount
15
+ } from "../../shared/stacks-f7wdrzs3.js";
16
+ import {
17
+ AddressHashMode,
18
+ AnchorMode,
19
+ AssetType,
20
+ AuthFieldType,
21
+ AuthType,
22
+ ClarityVersion,
23
+ FungibleConditionCode,
24
+ MAX_STRING_LENGTH_BYTES,
25
+ MEMO_MAX_LENGTH_BYTES,
26
+ NonFungibleConditionCode,
27
+ PayloadType,
28
+ PostConditionModeWire,
29
+ PostConditionPrincipalId,
30
+ PubKeyEncoding,
31
+ RECOVERABLE_ECDSA_SIG_LENGTH_BYTES,
32
+ combineMultiSigSignatures,
33
+ createMultiSigSpendingCondition,
34
+ createSingleSigSpendingCondition,
35
+ createSponsoredAuth,
36
+ createStandardAuth,
37
+ finalizeMultiSig,
38
+ isNonSequential,
39
+ makeMultiSigAddress,
40
+ nextSignature,
41
+ replayMultiSigSigHash,
42
+ serializeTransaction,
43
+ serializeTransactionHex,
44
+ sigHashPostSign,
45
+ sigHashPreSign,
46
+ signMultiSig,
47
+ signMultiSigWithAccount
48
+ } from "../../shared/stacks-yfgsm6ap.js";
49
+ import"../../shared/stacks-j2cy7qtt.js";
50
+ import"../../shared/stacks-8yykgdww.js";
51
+ import"../../shared/stacks-bycy6t9k.js";
52
+ import"../../shared/stacks-gjvbq6w7.js";
53
+ import"../../shared/stacks-nqytwfcc.js";
54
+ import"../../shared/stacks-8m9byk2j.js";
55
+ export {
56
+ signTransactionWithAccount,
57
+ signTransaction,
58
+ signSponsorWithAccount,
59
+ signSponsor,
60
+ signMultiSigWithAccount,
61
+ signMultiSig,
62
+ signBegin,
63
+ sigHashPreSign,
64
+ sigHashPostSign,
65
+ serializeTransactionHex,
66
+ serializeTransaction,
67
+ replayMultiSigSigHash,
68
+ nextSignature,
69
+ makeMultiSigAddress,
70
+ isNonSequential,
71
+ getTransactionId,
72
+ getOriginSigHash,
73
+ finalizeMultiSig,
74
+ deserializeTransaction,
75
+ createStandardAuth,
76
+ createSponsoredAuth,
77
+ createSingleSigSpendingCondition,
78
+ createMultiSigSpendingCondition,
79
+ combineMultiSigSignatures,
80
+ buildTokenTransfer,
81
+ buildContractDeploy,
82
+ buildContractCall,
83
+ RECOVERABLE_ECDSA_SIG_LENGTH_BYTES,
84
+ PubKeyEncoding,
85
+ PostConditionPrincipalId,
86
+ PostConditionModeWire,
87
+ PayloadType,
88
+ NonFungibleConditionCode,
89
+ MEMO_MAX_LENGTH_BYTES,
90
+ MAX_STRING_LENGTH_BYTES,
91
+ FungibleConditionCode,
92
+ ClarityVersion,
93
+ AuthType,
94
+ AuthFieldType,
95
+ AssetType,
96
+ AnchorMode,
97
+ AddressHashMode
98
+ };
99
+
100
+ //# debugId=4E20CE27699281AF64756E2164756E21
101
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,9 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [
5
+ ],
6
+ "mappings": "",
7
+ "debugId": "4E20CE27699281AF64756E2164756E21",
8
+ "names": []
9
+ }
@@ -0,0 +1,168 @@
1
+ // src/utils/index.ts
2
+ var exports_utils = {};
3
+ __export(exports_utils, {
4
+ writeUInt8: () => writeUInt8,
5
+ writeUInt32BE: () => writeUInt32BE,
6
+ writeUInt16BE: () => writeUInt16BE,
7
+ without0x: () => without0x,
8
+ with0x: () => with0x,
9
+ verifySignature: () => verifySignature,
10
+ verifyMessageSignature: () => verifyMessageSignature,
11
+ validateStacksAddress: () => validateStacksAddress,
12
+ utf8ToBytes: () => utf8ToBytes,
13
+ uncompressPublicKey: () => uncompressPublicKey,
14
+ txidFromBytes: () => txidFromBytes,
15
+ toTwos: () => toTwos,
16
+ signatureVrsToRsv: () => signatureVrsToRsv,
17
+ signatureRsvToVrs: () => signatureRsvToVrs,
18
+ sha512_256: () => import_sha22.sha512_256,
19
+ sha256: () => import_sha2.sha256,
20
+ serializeSignature: () => serializeSignature,
21
+ ripemd160: () => import_legacy.ripemd160,
22
+ recoverPublicKey: () => recoverPublicKey,
23
+ recoverAddress: () => recoverAddress,
24
+ readUInt32BE: () => readUInt32BE,
25
+ readUInt16BE: () => readUInt16BE,
26
+ randomBytes: () => randomBytes,
27
+ parseUnits: () => parseUnits,
28
+ parseStx: () => parseStx,
29
+ parseSignature: () => parseSignature,
30
+ parseContractId: () => parseContractId,
31
+ isValidAddress: () => isValidAddress,
32
+ isCompressedPublicKey: () => isCompressedPublicKey,
33
+ isClarityName: () => isClarityName,
34
+ isAddressEqual: () => isAddressEqual,
35
+ intToHex: () => intToHex,
36
+ intToBytes: () => intToBytes,
37
+ intToBigInt: () => intToBigInt,
38
+ hexToBytes: () => hexToBytes,
39
+ hashP2PKH: () => hashP2PKH,
40
+ hash160: () => hash160,
41
+ getContractAddress: () => getContractAddress,
42
+ fromTwos: () => fromTwos,
43
+ formatUnits: () => formatUnits,
44
+ formatStx: () => formatStx,
45
+ concatBytes: () => concatBytes,
46
+ compressPublicKey: () => compressPublicKey,
47
+ c32addressDecode: () => c32addressDecode,
48
+ c32address: () => c32address,
49
+ bytesToUtf8: () => bytesToUtf8,
50
+ bytesToTwosBigInt: () => bytesToTwosBigInt,
51
+ bytesToHex: () => bytesToHex,
52
+ bytesToAscii: () => bytesToAscii,
53
+ bigIntToBytes: () => bigIntToBytes,
54
+ asciiToBytes: () => asciiToBytes,
55
+ addressToVersion: () => addressToVersion,
56
+ ZERO_ADDRESS: () => ZERO_ADDRESS,
57
+ TESTNET_ZERO_ADDRESS: () => TESTNET_ZERO_ADDRESS,
58
+ MIN_I128: () => MIN_I128,
59
+ MICROSTX_PER_STX: () => MICROSTX_PER_STX,
60
+ MAX_U128: () => MAX_U128,
61
+ MAX_I128: () => MAX_I128,
62
+ AddressVersion: () => AddressVersion
63
+ });
64
+ module.exports = __toCommonJS(exports_utils);
65
+
66
+ // src/utils/signature.ts
67
+ var import_secp256k1 = require("@noble/secp256k1");
68
+ var import_sha23 = require("@noble/hashes/sha2.js");
69
+ function parseSignature(hex) {
70
+ const clean = hex.startsWith("0x") ? hex.slice(2) : hex;
71
+ if (clean.length !== 130) {
72
+ throw new Error(`Invalid signature length: expected 130 hex chars, got ${clean.length}`);
73
+ }
74
+ return {
75
+ recovery: parseInt(clean.slice(0, 2), 16),
76
+ r: clean.slice(2, 66),
77
+ s: clean.slice(66, 130)
78
+ };
79
+ }
80
+ function serializeSignature(sig) {
81
+ const v = sig.recovery.toString(16).padStart(2, "0");
82
+ return v + sig.r + sig.s;
83
+ }
84
+ function signatureVrsToRsv(vrs) {
85
+ const clean = vrs.startsWith("0x") ? vrs.slice(2) : vrs;
86
+ return clean.slice(2) + clean.slice(0, 2);
87
+ }
88
+ function signatureRsvToVrs(rsv) {
89
+ const clean = rsv.startsWith("0x") ? rsv.slice(2) : rsv;
90
+ return clean.slice(-2) + clean.slice(0, -2);
91
+ }
92
+ function recoverPublicKey(hash, signature, compressed = true) {
93
+ const parsed = parseSignature(signature);
94
+ const rs = parsed.r + parsed.s;
95
+ const sig = import_secp256k1.Signature.fromCompact(rs).addRecoveryBit(parsed.recovery);
96
+ const msgHash = typeof hash === "string" ? hexToBytes(hash) : hash;
97
+ const point = sig.recoverPublicKey(msgHash);
98
+ return point.toHex(compressed);
99
+ }
100
+ function recoverAddress(hash, signature, addressVersion = AddressVersion.MainnetSingleSig) {
101
+ const pubkey = recoverPublicKey(hash, signature, true);
102
+ const pubkeyHash = hashP2PKH(hexToBytes(pubkey));
103
+ return c32address(addressVersion, pubkeyHash);
104
+ }
105
+ function verifySignature(hash, signature, publicKey) {
106
+ return import_secp256k1.verify(signature, hash, publicKey, { lowS: false });
107
+ }
108
+ function encodeVarint(n) {
109
+ if (n < 253)
110
+ return new Uint8Array([n]);
111
+ if (n <= 65535) {
112
+ const buf2 = new Uint8Array(3);
113
+ buf2[0] = 253;
114
+ buf2[1] = n & 255;
115
+ buf2[2] = n >> 8 & 255;
116
+ return buf2;
117
+ }
118
+ const buf = new Uint8Array(5);
119
+ buf[0] = 254;
120
+ buf[1] = n & 255;
121
+ buf[2] = n >> 8 & 255;
122
+ buf[3] = n >> 16 & 255;
123
+ buf[4] = n >> 24 & 255;
124
+ return buf;
125
+ }
126
+ var STACKS_MESSAGE_PREFIX = `\x17Stacks Signed Message:
127
+ `;
128
+ var LEGACY_MESSAGE_PREFIX = `\x18Stacks Message Signing:
129
+ `;
130
+ function hashMessage(message, prefix) {
131
+ const messageBytes = typeof message === "string" ? utf8ToBytes(message) : message;
132
+ const prefixBytes = utf8ToBytes(prefix);
133
+ const lengthBytes = encodeVarint(messageBytes.length);
134
+ return import_sha23.sha256(concatBytes(prefixBytes, lengthBytes, messageBytes));
135
+ }
136
+ function verifyMessageSignature(message, signature, publicKey) {
137
+ const parsed = parseSignature(signature);
138
+ const compactSig = parsed.r + parsed.s;
139
+ const msgHash = hashMessage(message, STACKS_MESSAGE_PREFIX);
140
+ if (import_secp256k1.verify(compactSig, msgHash, publicKey, { lowS: false }))
141
+ return true;
142
+ if (typeof message === "string") {
143
+ const legacyHash = hashMessage(message, LEGACY_MESSAGE_PREFIX);
144
+ if (import_secp256k1.verify(compactSig, legacyHash, publicKey, { lowS: false }))
145
+ return true;
146
+ }
147
+ return false;
148
+ }
149
+ // src/utils/keys.ts
150
+ var import_secp256k12 = require("@noble/secp256k1");
151
+ function compressPublicKey(publicKey) {
152
+ const hex = typeof publicKey === "string" ? publicKey : bytesToHex(publicKey);
153
+ return import_secp256k12.Point.fromHex(hex).toHex(true);
154
+ }
155
+ function uncompressPublicKey(publicKey) {
156
+ const hex = typeof publicKey === "string" ? publicKey : bytesToHex(publicKey);
157
+ return import_secp256k12.Point.fromHex(hex).toHex(false);
158
+ }
159
+ function isCompressedPublicKey(publicKey) {
160
+ const bytes = typeof publicKey === "string" ? hexToBytes(publicKey) : publicKey;
161
+ return bytes.length === 33 && (bytes[0] === 2 || bytes[0] === 3);
162
+ }
163
+ function randomBytes(length) {
164
+ return import_secp256k12.etc.randomBytes(length ?? 32);
165
+ }
166
+
167
+ //# debugId=F1D67D47267AF34764756E2164756E21
168
+ //# sourceMappingURL=index.cjs.map