@secondlayer/stacks 0.2.2 → 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 (159) hide show
  1. package/dist/shared/stacks-02actsrx.cjs.map +2 -2
  2. package/dist/shared/{stacks-xp9n3r0t.js → stacks-09wa7ewe.js} +108 -108
  3. package/dist/shared/stacks-09wa7ewe.js.map +15 -0
  4. package/dist/shared/{stacks-ky14tdf6.cjs → stacks-0nfexv24.cjs} +20 -8
  5. package/dist/shared/stacks-0nfexv24.cjs.map +14 -0
  6. package/dist/shared/{stacks-an5k8n4t.cjs → stacks-14pgpkrr.cjs} +82 -73
  7. package/dist/shared/stacks-14pgpkrr.cjs.map +23 -0
  8. package/dist/shared/{stacks-v6ja2eh7.cjs → stacks-17sdtaxg.cjs} +106 -102
  9. package/dist/shared/stacks-17sdtaxg.cjs.map +15 -0
  10. package/dist/shared/{stacks-96gaxfcf.js → stacks-1s5w4ncf.js} +44 -32
  11. package/dist/shared/stacks-1s5w4ncf.js.map +17 -0
  12. package/dist/shared/stacks-24h5k94q.cjs.map +3 -3
  13. package/dist/shared/{stacks-evnzth1q.cjs → stacks-4vzmhw3q.cjs} +3 -3
  14. package/dist/shared/stacks-4vzmhw3q.cjs.map +10 -0
  15. package/dist/shared/{stacks-k9p8m3wf.js → stacks-4x2bcc2k.js} +87 -78
  16. package/dist/shared/stacks-4x2bcc2k.js.map +23 -0
  17. package/dist/shared/stacks-5tprhns9.cjs.map +3 -3
  18. package/dist/shared/stacks-709tra19.js.map +2 -2
  19. package/dist/shared/{stacks-q79dx28x.js → stacks-70p84bgg.js} +3 -3
  20. package/dist/shared/stacks-70p84bgg.js.map +10 -0
  21. package/dist/shared/{stacks-k2p5tv6x.js → stacks-913a2rx7.js} +3 -3
  22. package/dist/shared/stacks-913a2rx7.js.map +10 -0
  23. package/dist/shared/{stacks-jrnmh4kc.js → stacks-96d6m1zy.js} +15 -6
  24. package/dist/shared/stacks-96d6m1zy.js.map +11 -0
  25. package/dist/shared/stacks-9g0jhab3.cjs.map +2 -2
  26. package/dist/shared/stacks-dr5en54r.cjs.map +2 -2
  27. package/dist/shared/stacks-fcaefc5b.cjs.map +2 -2
  28. package/dist/shared/stacks-gck1sq7h.cjs.map +2 -2
  29. package/dist/shared/stacks-je937aas.js.map +2 -2
  30. package/dist/shared/{stacks-k58k970n.js → stacks-kg1npstf.js} +5 -3
  31. package/dist/shared/stacks-kg1npstf.js.map +10 -0
  32. package/dist/shared/{stacks-qvg7c24g.cjs → stacks-n98w7g57.cjs} +5 -3
  33. package/dist/shared/stacks-n98w7g57.cjs.map +10 -0
  34. package/dist/shared/{stacks-6m1z4j07.js → stacks-nqae5amn.cjs} +74 -160
  35. package/dist/shared/stacks-nqae5amn.cjs.map +10 -0
  36. package/dist/shared/stacks-qcae5852.js.map +2 -2
  37. package/dist/shared/stacks-qt8ehebn.js.map +3 -3
  38. package/dist/shared/stacks-ra02bpny.cjs.map +3 -3
  39. package/dist/shared/stacks-rwfgts3s.js.map +2 -2
  40. package/dist/shared/stacks-s10yb9gz.js.map +2 -2
  41. package/dist/shared/{stacks-etf219gs.cjs → stacks-s30kkvm8.js} +101 -118
  42. package/dist/shared/stacks-s30kkvm8.js.map +10 -0
  43. package/dist/shared/stacks-s7z5q8be.js.map +3 -3
  44. package/dist/shared/stacks-v9jqcpd4.js.map +2 -2
  45. package/dist/shared/stacks-vdfag81a.cjs.map +2 -2
  46. package/dist/shared/{stacks-rg1g0fja.js → stacks-wjem3xw9.js} +21 -9
  47. package/dist/shared/stacks-wjem3xw9.js.map +14 -0
  48. package/dist/shared/{stacks-k08tgzyp.cjs → stacks-wyxj879g.cjs} +3 -3
  49. package/dist/shared/stacks-wyxj879g.cjs.map +13 -0
  50. package/dist/shared/stacks-y3dh7hv1.js.map +3 -3
  51. package/dist/shared/{stacks-2ar4prfz.cjs → stacks-y5262j0z.cjs} +14 -5
  52. package/dist/shared/stacks-y5262j0z.cjs.map +11 -0
  53. package/dist/shared/stacks-ya3x01yd.cjs.map +2 -2
  54. package/dist/shared/{stacks-p93g814f.js → stacks-zf7rbpzp.js} +4 -4
  55. package/dist/shared/stacks-zf7rbpzp.js.map +13 -0
  56. package/dist/shared/{stacks-61rvzkz1.cjs → stacks-znrb59ce.cjs} +41 -29
  57. package/dist/shared/stacks-znrb59ce.cjs.map +17 -0
  58. package/dist/src/accounts/index.cjs +2 -2
  59. package/dist/src/accounts/index.cjs.map +5 -5
  60. package/dist/src/accounts/index.js +2 -6
  61. package/dist/src/accounts/index.js.map +5 -5
  62. package/dist/src/actions/index.d.cts +29 -29
  63. package/dist/src/actions/index.d.ts +29 -29
  64. package/dist/src/actions/index.js +7 -7
  65. package/dist/src/bns/index.cjs +55 -43
  66. package/dist/src/bns/index.cjs.map +9 -9
  67. package/dist/src/bns/index.d.cts +29 -29
  68. package/dist/src/bns/index.d.ts +29 -29
  69. package/dist/src/bns/index.js +62 -50
  70. package/dist/src/bns/index.js.map +9 -9
  71. package/dist/src/clarity/index.js +4 -4
  72. package/dist/src/connect/index.cjs +114 -112
  73. package/dist/src/connect/index.cjs.map +13 -13
  74. package/dist/src/connect/index.js +114 -112
  75. package/dist/src/connect/index.js.map +13 -13
  76. package/dist/src/connect/walletconnect/index.cjs +3 -3
  77. package/dist/src/connect/walletconnect/index.cjs.map +10 -10
  78. package/dist/src/connect/walletconnect/index.js +3 -3
  79. package/dist/src/connect/walletconnect/index.js.map +10 -10
  80. package/dist/src/index.cjs +108 -2
  81. package/dist/src/index.cjs.map +19 -15
  82. package/dist/src/index.d.cts +291 -112
  83. package/dist/src/index.d.ts +291 -112
  84. package/dist/src/index.js +122 -9
  85. package/dist/src/index.js.map +19 -15
  86. package/dist/src/pox/index.cjs.map +6 -6
  87. package/dist/src/pox/index.d.cts +29 -29
  88. package/dist/src/pox/index.d.ts +29 -29
  89. package/dist/src/pox/index.js +5 -5
  90. package/dist/src/pox/index.js.map +6 -6
  91. package/dist/src/stackingdao/index.cjs +31 -6
  92. package/dist/src/stackingdao/index.cjs.map +6 -6
  93. package/dist/src/stackingdao/index.d.cts +29 -29
  94. package/dist/src/stackingdao/index.d.ts +29 -29
  95. package/dist/src/stackingdao/index.js +37 -12
  96. package/dist/src/stackingdao/index.js.map +6 -6
  97. package/dist/src/subscriptions/index.d.cts +29 -29
  98. package/dist/src/subscriptions/index.d.ts +29 -29
  99. package/dist/src/tools/btc/index.cjs +130 -0
  100. package/dist/src/tools/btc/index.cjs.map +10 -0
  101. package/dist/src/tools/btc/index.d.cts +8 -0
  102. package/dist/src/tools/btc/index.d.ts +8 -0
  103. package/dist/src/tools/btc/index.js +89 -0
  104. package/dist/src/tools/btc/index.js.map +10 -0
  105. package/dist/src/tools/index.cjs +2470 -0
  106. package/dist/src/tools/index.cjs.map +61 -0
  107. package/dist/src/tools/index.d.cts +144 -0
  108. package/dist/src/tools/index.d.ts +144 -0
  109. package/dist/src/tools/index.js +2435 -0
  110. package/dist/src/tools/index.js.map +61 -0
  111. package/dist/src/transactions/index.js +3 -3
  112. package/dist/src/triggers/index.cjs +66 -0
  113. package/dist/src/triggers/index.cjs.map +10 -0
  114. package/dist/src/triggers/index.d.cts +116 -0
  115. package/dist/src/triggers/index.d.ts +116 -0
  116. package/dist/src/triggers/index.js +25 -0
  117. package/dist/src/triggers/index.js.map +10 -0
  118. package/dist/src/tx/index.cjs +65 -0
  119. package/dist/src/tx/index.cjs.map +10 -0
  120. package/dist/src/tx/index.d.cts +42 -0
  121. package/dist/src/tx/index.d.ts +42 -0
  122. package/dist/src/tx/index.js +22 -0
  123. package/dist/src/tx/index.js.map +10 -0
  124. package/dist/src/ui/index.cjs +431 -0
  125. package/dist/src/ui/index.cjs.map +27 -0
  126. package/dist/src/ui/index.d.cts +107 -0
  127. package/dist/src/ui/index.d.ts +107 -0
  128. package/dist/src/ui/index.js +391 -0
  129. package/dist/src/ui/index.js.map +27 -0
  130. package/dist/src/ui/schemas.cjs +134 -0
  131. package/dist/src/ui/schemas.cjs.map +18 -0
  132. package/dist/src/ui/schemas.d.cts +83 -0
  133. package/dist/src/ui/schemas.d.ts +83 -0
  134. package/dist/src/ui/schemas.js +91 -0
  135. package/dist/src/ui/schemas.js.map +18 -0
  136. package/dist/src/utils/index.cjs +3 -3
  137. package/dist/src/utils/index.cjs.map +4 -4
  138. package/dist/src/utils/index.js +4 -4
  139. package/dist/src/utils/index.js.map +4 -4
  140. package/package.json +157 -105
  141. package/dist/shared/stacks-2ar4prfz.cjs.map +0 -11
  142. package/dist/shared/stacks-61rvzkz1.cjs.map +0 -17
  143. package/dist/shared/stacks-6m1z4j07.js.map +0 -10
  144. package/dist/shared/stacks-96gaxfcf.js.map +0 -17
  145. package/dist/shared/stacks-an5k8n4t.cjs.map +0 -23
  146. package/dist/shared/stacks-etf219gs.cjs.map +0 -10
  147. package/dist/shared/stacks-evnzth1q.cjs.map +0 -10
  148. package/dist/shared/stacks-jrnmh4kc.js.map +0 -11
  149. package/dist/shared/stacks-k08tgzyp.cjs.map +0 -13
  150. package/dist/shared/stacks-k2p5tv6x.js.map +0 -10
  151. package/dist/shared/stacks-k58k970n.js.map +0 -10
  152. package/dist/shared/stacks-k9p8m3wf.js.map +0 -23
  153. package/dist/shared/stacks-ky14tdf6.cjs.map +0 -13
  154. package/dist/shared/stacks-p93g814f.js.map +0 -13
  155. package/dist/shared/stacks-q79dx28x.js.map +0 -10
  156. package/dist/shared/stacks-qvg7c24g.cjs.map +0 -10
  157. package/dist/shared/stacks-rg1g0fja.js.map +0 -13
  158. package/dist/shared/stacks-v6ja2eh7.cjs.map +0 -15
  159. package/dist/shared/stacks-xp9n3r0t.js.map +0 -15
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/accounts/providerToAccount.ts"],
4
4
  "sourcesContent": [
5
- "import type { StacksProvider, ProviderAccount } from \"./types.ts\";\n\n/** Create a ProviderAccount by querying the wallet for addresses */\nexport async function providerToAccount(\n provider: StacksProvider\n): Promise<ProviderAccount> {\n const result = await provider.request(\"stx_getAddresses\");\n\n const entry = result?.addresses?.[0];\n if (!entry?.address || !entry?.publicKey) {\n throw new Error(\"Provider did not return a valid address\");\n }\n\n return {\n type: \"provider\",\n address: entry.address,\n publicKey: entry.publicKey,\n provider,\n };\n}\n"
5
+ "import type { ProviderAccount, StacksProvider } from \"./types.ts\";\n\n/** Create a ProviderAccount by querying the wallet for addresses */\nexport async function providerToAccount(\n\tprovider: StacksProvider,\n): Promise<ProviderAccount> {\n\tconst result = await provider.request(\"stx_getAddresses\");\n\n\tconst entry = result?.addresses?.[0];\n\tif (!entry?.address || !entry?.publicKey) {\n\t\tthrow new Error(\"Provider did not return a valid address\");\n\t}\n\n\treturn {\n\t\ttype: \"provider\",\n\t\taddress: entry.address,\n\t\tpublicKey: entry.publicKey,\n\t\tprovider,\n\t};\n}\n"
6
6
  ],
7
- "mappings": ";AAGA,eAAsB,iBAAiB,CACrC,UAC0B;AAAA,EAC1B,MAAM,SAAS,MAAM,SAAS,QAAQ,kBAAkB;AAAA,EAExD,MAAM,QAAQ,QAAQ,YAAY;AAAA,EAClC,IAAI,CAAC,OAAO,WAAW,CAAC,OAAO,WAAW;AAAA,IACxC,MAAM,IAAI,MAAM,yCAAyC;AAAA,EAC3D;AAAA,EAEA,OAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS,MAAM;AAAA,IACf,WAAW,MAAM;AAAA,IACjB;AAAA,EACF;AAAA;",
7
+ "mappings": ";AAGA,eAAsB,iBAAiB,CACtC,UAC2B;AAAA,EAC3B,MAAM,SAAS,MAAM,SAAS,QAAQ,kBAAkB;AAAA,EAExD,MAAM,QAAQ,QAAQ,YAAY;AAAA,EAClC,IAAI,CAAC,OAAO,WAAW,CAAC,OAAO,WAAW;AAAA,IACzC,MAAM,IAAI,MAAM,yCAAyC;AAAA,EAC1D;AAAA,EAEA,OAAO;AAAA,IACN,MAAM;AAAA,IACN,SAAS,MAAM;AAAA,IACf,WAAW,MAAM;AAAA,IACjB;AAAA,EACD;AAAA;",
8
8
  "debugId": "92C250F1EE7F3F3064756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Cl,
3
3
  serializeCVBytes
4
- } from "./stacks-rg1g0fja.js";
4
+ } from "./stacks-wjem3xw9.js";
5
5
  import {
6
6
  hash160,
7
7
  hashP2PKH,
@@ -290,13 +290,9 @@ function serializeTransactionHex(tx) {
290
290
  }
291
291
 
292
292
  // src/transactions/authorization.ts
293
- import {
294
- getPublicKey as nobleGetPublicKey,
295
- sign,
296
- etc
297
- } from "@noble/secp256k1";
298
293
  import { hmac } from "@noble/hashes/hmac.js";
299
294
  import { sha256 } from "@noble/hashes/sha2.js";
295
+ import { etc, getPublicKey as nobleGetPublicKey, sign } from "@noble/secp256k1";
300
296
  etc.hmacSha256Sync = (key, ...msgs) => {
301
297
  const h = hmac.create(sha256, key);
302
298
  msgs.forEach((msg) => h.update(msg));
@@ -451,7 +447,9 @@ function signMultiSig(tx, privateKey, publicKeys) {
451
447
  if (signerIndex === -1) {
452
448
  throw new Error("Private key does not correspond to any signer in the multi-sig");
453
449
  }
454
- const condition = { ...tx.auth.spendingCondition };
450
+ const condition = {
451
+ ...tx.auth.spendingCondition
452
+ };
455
453
  if (isNonSequential(condition.hashMode)) {
456
454
  return signNonSequential(tx, condition, privateKey);
457
455
  }
@@ -526,7 +524,9 @@ async function signMultiSigWithAccount(tx, account, publicKeys) {
526
524
  if (signerIndex === -1) {
527
525
  throw new Error("Account does not correspond to any signer in the multi-sig");
528
526
  }
529
- const condition = { ...tx.auth.spendingCondition };
527
+ const condition = {
528
+ ...tx.auth.spendingCondition
529
+ };
530
530
  if (isNonSequential(condition.hashMode)) {
531
531
  return signNonSequentialWithAccount(tx, condition, account);
532
532
  }
@@ -648,103 +648,6 @@ function combineMultiSigSignatures(baseTx, signedTxs) {
648
648
  };
649
649
  }
650
650
 
651
- // src/transactions/signer.ts
652
- function txid(tx) {
653
- return txidFromBytes(serializeTransaction(tx));
654
- }
655
- function signBegin(tx) {
656
- const cleared = {
657
- ...tx,
658
- auth: intoInitialSighashAuth(tx.auth)
659
- };
660
- return txid(cleared);
661
- }
662
- function signTransaction(tx, privateKey) {
663
- const sigHash = signBegin(tx);
664
- const condition = tx.auth.spendingCondition;
665
- const { nextSig } = nextSignature(sigHash, AuthType.Standard, condition.fee, condition.nonce, privateKey);
666
- return {
667
- ...tx,
668
- auth: {
669
- ...tx.auth,
670
- spendingCondition: {
671
- ...condition,
672
- signature: nextSig
673
- }
674
- }
675
- };
676
- }
677
- async function signTransactionWithAccount(tx, account) {
678
- const sigHash = signBegin(tx);
679
- const condition = tx.auth.spendingCondition;
680
- const sigHashPre = sigHashPreSign(sigHash, AuthType.Standard, condition.fee, condition.nonce);
681
- const sigBytes = await account.sign(hexToBytes(sigHashPre));
682
- const nextSig = bytesToHex(sigBytes);
683
- return {
684
- ...tx,
685
- auth: {
686
- ...tx.auth,
687
- spendingCondition: {
688
- ...condition,
689
- signature: nextSig
690
- }
691
- }
692
- };
693
- }
694
- function getTransactionId(tx) {
695
- return txid(tx);
696
- }
697
- function getOriginSigHash(tx) {
698
- const condition = tx.auth.spendingCondition;
699
- if ("fields" in condition) {
700
- return replayMultiSigSigHash(tx);
701
- }
702
- const initialSigHash2 = signBegin(tx);
703
- const sc = condition;
704
- const preSign = sigHashPreSign(initialSigHash2, AuthType.Standard, sc.fee, sc.nonce);
705
- return sigHashPostSign(preSign, sc.keyEncoding, sc.signature);
706
- }
707
- function signSponsor(tx, privateKey) {
708
- if (tx.auth.authType !== AuthType.Sponsored) {
709
- throw new Error("Transaction must be sponsored");
710
- }
711
- const auth = tx.auth;
712
- const sponsorCondition = auth.sponsorSpendingCondition;
713
- const originSigHash = getOriginSigHash(tx);
714
- const { nextSig } = nextSignature(originSigHash, AuthType.Sponsored, sponsorCondition.fee, sponsorCondition.nonce, privateKey);
715
- return {
716
- ...tx,
717
- auth: {
718
- ...auth,
719
- sponsorSpendingCondition: {
720
- ...sponsorCondition,
721
- signature: nextSig
722
- }
723
- }
724
- };
725
- }
726
- async function signSponsorWithAccount(tx, account) {
727
- if (tx.auth.authType !== AuthType.Sponsored) {
728
- throw new Error("Transaction must be sponsored");
729
- }
730
- const auth = tx.auth;
731
- const sponsorCondition = auth.sponsorSpendingCondition;
732
- const originSigHash = getOriginSigHash(tx);
733
- const sigHashPre = sigHashPreSign(originSigHash, AuthType.Sponsored, sponsorCondition.fee, sponsorCondition.nonce);
734
- const sigBytes = await account.sign(hexToBytes(sigHashPre));
735
- const nextSig = bytesToHex(sigBytes);
736
- return {
737
- ...tx,
738
- auth: {
739
- ...auth,
740
- sponsorSpendingCondition: {
741
- ...sponsorCondition,
742
- signature: nextSig
743
- }
744
- }
745
- };
746
- }
747
-
748
651
  // src/transactions/build.ts
749
652
  function resolvePcMode(mode) {
750
653
  return mode === "allow" ? PostConditionModeWire.Allow : PostConditionModeWire.Deny;
@@ -893,7 +796,104 @@ function buildContractDeploy(options) {
893
796
  return tx;
894
797
  }
895
798
 
896
- export { AuthType, PayloadType, ClarityVersion, AnchorMode, PostConditionModeWire, AddressHashMode, PubKeyEncoding, FungibleConditionCode, NonFungibleConditionCode, PostConditionPrincipalId, AssetType, AuthFieldType, RECOVERABLE_ECDSA_SIG_LENGTH_BYTES, MEMO_MAX_LENGTH_BYTES, MAX_STRING_LENGTH_BYTES, COINBASE_BYTES_LENGTH, VRF_PROOF_BYTES_LENGTH, MICROBLOCK_HEADER_BYTES_LENGTH, TenureChangeCause, serializePayload, serializeTransaction, serializeTransactionHex, createSingleSigSpendingCondition, createStandardAuth, createSponsoredAuth, sigHashPreSign, sigHashPostSign, nextSignature, isNonSequential, makeMultiSigAddress, createMultiSigSpendingCondition, replayMultiSigSigHash, signMultiSig, signMultiSigWithAccount, finalizeMultiSig, combineMultiSigSignatures, signBegin, signTransaction, signTransactionWithAccount, getTransactionId, getOriginSigHash, signSponsor, signSponsorWithAccount, buildTokenTransfer, buildContractCall, buildContractDeploy };
799
+ // src/transactions/signer.ts
800
+ function txid(tx) {
801
+ return txidFromBytes(serializeTransaction(tx));
802
+ }
803
+ function signBegin(tx) {
804
+ const cleared = {
805
+ ...tx,
806
+ auth: intoInitialSighashAuth(tx.auth)
807
+ };
808
+ return txid(cleared);
809
+ }
810
+ function signTransaction(tx, privateKey) {
811
+ const sigHash = signBegin(tx);
812
+ const condition = tx.auth.spendingCondition;
813
+ const { nextSig } = nextSignature(sigHash, AuthType.Standard, condition.fee, condition.nonce, privateKey);
814
+ return {
815
+ ...tx,
816
+ auth: {
817
+ ...tx.auth,
818
+ spendingCondition: {
819
+ ...condition,
820
+ signature: nextSig
821
+ }
822
+ }
823
+ };
824
+ }
825
+ async function signTransactionWithAccount(tx, account) {
826
+ const sigHash = signBegin(tx);
827
+ const condition = tx.auth.spendingCondition;
828
+ const sigHashPre = sigHashPreSign(sigHash, AuthType.Standard, condition.fee, condition.nonce);
829
+ const sigBytes = await account.sign(hexToBytes(sigHashPre));
830
+ const nextSig = bytesToHex(sigBytes);
831
+ return {
832
+ ...tx,
833
+ auth: {
834
+ ...tx.auth,
835
+ spendingCondition: {
836
+ ...condition,
837
+ signature: nextSig
838
+ }
839
+ }
840
+ };
841
+ }
842
+ function getTransactionId(tx) {
843
+ return txid(tx);
844
+ }
845
+ function getOriginSigHash(tx) {
846
+ const condition = tx.auth.spendingCondition;
847
+ if ("fields" in condition) {
848
+ return replayMultiSigSigHash(tx);
849
+ }
850
+ const initialSigHash2 = signBegin(tx);
851
+ const sc = condition;
852
+ const preSign = sigHashPreSign(initialSigHash2, AuthType.Standard, sc.fee, sc.nonce);
853
+ return sigHashPostSign(preSign, sc.keyEncoding, sc.signature);
854
+ }
855
+ function signSponsor(tx, privateKey) {
856
+ if (tx.auth.authType !== AuthType.Sponsored) {
857
+ throw new Error("Transaction must be sponsored");
858
+ }
859
+ const auth = tx.auth;
860
+ const sponsorCondition = auth.sponsorSpendingCondition;
861
+ const originSigHash = getOriginSigHash(tx);
862
+ const { nextSig } = nextSignature(originSigHash, AuthType.Sponsored, sponsorCondition.fee, sponsorCondition.nonce, privateKey);
863
+ return {
864
+ ...tx,
865
+ auth: {
866
+ ...auth,
867
+ sponsorSpendingCondition: {
868
+ ...sponsorCondition,
869
+ signature: nextSig
870
+ }
871
+ }
872
+ };
873
+ }
874
+ async function signSponsorWithAccount(tx, account) {
875
+ if (tx.auth.authType !== AuthType.Sponsored) {
876
+ throw new Error("Transaction must be sponsored");
877
+ }
878
+ const auth = tx.auth;
879
+ const sponsorCondition = auth.sponsorSpendingCondition;
880
+ const originSigHash = getOriginSigHash(tx);
881
+ const sigHashPre = sigHashPreSign(originSigHash, AuthType.Sponsored, sponsorCondition.fee, sponsorCondition.nonce);
882
+ const sigBytes = await account.sign(hexToBytes(sigHashPre));
883
+ const nextSig = bytesToHex(sigBytes);
884
+ return {
885
+ ...tx,
886
+ auth: {
887
+ ...auth,
888
+ sponsorSpendingCondition: {
889
+ ...sponsorCondition,
890
+ signature: nextSig
891
+ }
892
+ }
893
+ };
894
+ }
895
+
896
+ export { AuthType, PayloadType, ClarityVersion, AnchorMode, PostConditionModeWire, AddressHashMode, PubKeyEncoding, FungibleConditionCode, NonFungibleConditionCode, PostConditionPrincipalId, AssetType, AuthFieldType, RECOVERABLE_ECDSA_SIG_LENGTH_BYTES, MEMO_MAX_LENGTH_BYTES, MAX_STRING_LENGTH_BYTES, COINBASE_BYTES_LENGTH, VRF_PROOF_BYTES_LENGTH, MICROBLOCK_HEADER_BYTES_LENGTH, TenureChangeCause, serializePayload, serializeTransaction, serializeTransactionHex, createSingleSigSpendingCondition, createStandardAuth, createSponsoredAuth, sigHashPreSign, sigHashPostSign, nextSignature, isNonSequential, makeMultiSigAddress, createMultiSigSpendingCondition, replayMultiSigSigHash, signMultiSig, signMultiSigWithAccount, finalizeMultiSig, combineMultiSigSignatures, buildTokenTransfer, buildContractCall, buildContractDeploy, signBegin, signTransaction, signTransactionWithAccount, getTransactionId, getOriginSigHash, signSponsor, signSponsorWithAccount };
897
897
 
898
- //# debugId=9CEDB9079783463964756E2164756E21
899
- //# sourceMappingURL=stacks-xp9n3r0t.js.map
898
+ //# debugId=E3994C33C4FEEE6E64756E2164756E21
899
+ //# sourceMappingURL=stacks-09wa7ewe.js.map
@@ -0,0 +1,15 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/transactions/types.ts", "../src/transactions/wire/serialize.ts", "../src/transactions/authorization.ts", "../src/transactions/multisig.ts", "../src/transactions/build.ts", "../src/transactions/signer.ts"],
4
+ "sourcesContent": [
5
+ "import type { ClarityValue } from \"../clarity/types.ts\";\n\n// Auth types\nexport const AuthType = {\n\tStandard: 0x04,\n\tSponsored: 0x05,\n} as const;\nexport type AuthType = (typeof AuthType)[keyof typeof AuthType];\n\n// Payload types\nexport const PayloadType = {\n\tTokenTransfer: 0x00,\n\tSmartContract: 0x01,\n\tContractCall: 0x02,\n\tPoisonMicroblock: 0x03,\n\tCoinbase: 0x04,\n\tCoinbaseToAltRecipient: 0x05,\n\tVersionedSmartContract: 0x06,\n\tTenureChange: 0x07,\n\tNakamotoCoinbase: 0x08,\n} as const;\nexport type PayloadType = (typeof PayloadType)[keyof typeof PayloadType];\n\n// Clarity version\nexport const ClarityVersion = {\n\tClarity1: 1,\n\tClarity2: 2,\n\tClarity3: 3,\n\tClarity4: 4,\n\tClarity5: 5,\n} as const;\nexport type ClarityVersion =\n\t(typeof ClarityVersion)[keyof typeof ClarityVersion];\n\n// Anchor mode (deprecated post-Nakamoto, but needed for wire format)\nexport const AnchorMode = {\n\tOnChainOnly: 0x01,\n\tOffChainOnly: 0x02,\n\tAny: 0x03,\n} as const;\nexport type AnchorMode = (typeof AnchorMode)[keyof typeof AnchorMode];\n\n// Post condition mode\nexport const PostConditionModeWire = {\n\tAllow: 0x01,\n\tDeny: 0x02,\n} as const;\nexport type PostConditionModeWire =\n\t(typeof PostConditionModeWire)[keyof typeof PostConditionModeWire];\n\n// Address hash modes\nexport const AddressHashMode = {\n\tP2PKH: 0x00,\n\tP2SH: 0x01,\n\tP2WPKH: 0x02,\n\tP2WSH: 0x03,\n\tP2SH_NonSequential: 0x05, // SIP-027\n\tP2WSH_P2SH_NonSequential: 0x07, // SIP-027\n} as const;\nexport type AddressHashMode =\n\t(typeof AddressHashMode)[keyof typeof AddressHashMode];\n\n// Pub key encoding\nexport const PubKeyEncoding = {\n\tCompressed: 0x00,\n\tUncompressed: 0x01,\n} as const;\nexport type PubKeyEncoding =\n\t(typeof PubKeyEncoding)[keyof typeof PubKeyEncoding];\n\n// Fungible condition codes (wire format)\nexport const FungibleConditionCode = {\n\tEqual: 0x01,\n\tGreater: 0x02,\n\tGreaterEqual: 0x03,\n\tLess: 0x04,\n\tLessEqual: 0x05,\n} as const;\n\n// Non-fungible condition codes (wire format)\nexport const NonFungibleConditionCode = {\n\tSends: 0x10,\n\tDoesNotSend: 0x11,\n} as const;\n\n// Post condition principal types\nexport const PostConditionPrincipalId = {\n\tOrigin: 0x01,\n\tStandard: 0x02,\n\tContract: 0x03,\n} as const;\n\n// Post condition asset types\nexport const AssetType = {\n\tSTX: 0x00,\n\tFungible: 0x01,\n\tNonFungible: 0x02,\n} as const;\n\n// Auth field types\nexport const AuthFieldType = {\n\tPublicKeyCompressed: 0x00,\n\tPublicKeyUncompressed: 0x01,\n\tSignatureCompressed: 0x02,\n\tSignatureUncompressed: 0x03,\n} as const;\n\nexport const RECOVERABLE_ECDSA_SIG_LENGTH_BYTES = 65;\nexport const MEMO_MAX_LENGTH_BYTES = 34;\nexport const MAX_STRING_LENGTH_BYTES = 128;\nexport const COINBASE_BYTES_LENGTH = 32;\nexport const VRF_PROOF_BYTES_LENGTH = 80;\nexport const MICROBLOCK_HEADER_BYTES_LENGTH = 132; // 1 + 2 + 32 + 32 + 65\n\n// Tenure change cause\nexport const TenureChangeCause = {\n\tBlockFound: 0x00,\n\tExtended: 0x01,\n\tExtendedRuntime: 0x02,\n\tExtendedReadCount: 0x03,\n\tExtendedReadLength: 0x04,\n\tExtendedWriteCount: 0x05,\n\tExtendedWriteLength: 0x06,\n} as const;\nexport type TenureChangeCause =\n\t(typeof TenureChangeCause)[keyof typeof TenureChangeCause];\n\n// Token transfer payload\nexport type TokenTransferPayload = {\n\tpayloadType: typeof PayloadType.TokenTransfer;\n\trecipient: ClarityValue; // PrincipalCV\n\tamount: bigint;\n\tmemo: string;\n};\n\n// Contract call payload\nexport type ContractCallPayload = {\n\tpayloadType: typeof PayloadType.ContractCall;\n\tcontractAddress: string;\n\tcontractName: string;\n\tfunctionName: string;\n\tfunctionArgs: ClarityValue[];\n};\n\n// Smart contract deploy payload\nexport type SmartContractPayload = {\n\tpayloadType:\n\t\t| typeof PayloadType.SmartContract\n\t\t| typeof PayloadType.VersionedSmartContract;\n\tclarityVersion?: ClarityVersion;\n\tcontractName: string;\n\tcodeBody: string;\n};\n\n// Coinbase payload (appears in every pre-Nakamoto block)\nexport type CoinbasePayload = {\n\tpayloadType: typeof PayloadType.Coinbase;\n\tcoinbaseBuffer: string; // 32 bytes hex\n};\n\n// Coinbase to alt recipient payload\nexport type CoinbaseToAltRecipientPayload = {\n\tpayloadType: typeof PayloadType.CoinbaseToAltRecipient;\n\tcoinbaseBuffer: string; // 32 bytes hex\n\trecipient: ClarityValue; // PrincipalCV\n};\n\n// Poison microblock payload\nexport type PoisonMicroblockPayload = {\n\tpayloadType: typeof PayloadType.PoisonMicroblock;\n\theader1: string; // 132 bytes hex (raw microblock header)\n\theader2: string; // 132 bytes hex (raw microblock header)\n};\n\n// Tenure change payload (Nakamoto)\nexport type TenureChangePayload = {\n\tpayloadType: typeof PayloadType.TenureChange;\n\ttenureConsensusHash: string; // 20 bytes hex\n\tprevTenureConsensusHash: string; // 20 bytes hex\n\tburnViewConsensusHash: string; // 20 bytes hex\n\tpreviousTenureEnd: string; // 32 bytes hex\n\tpreviousTenureBlocks: number; // u32\n\tcause: TenureChangeCause;\n\tpubkeyHash: string; // 20 bytes hex\n};\n\n// Nakamoto coinbase payload\nexport type NakamotoCoinbasePayload = {\n\tpayloadType: typeof PayloadType.NakamotoCoinbase;\n\tcoinbaseBuffer: string; // 32 bytes hex\n\trecipient: ClarityValue | null; // Optional PrincipalCV\n\tvrfProof: string; // 80 bytes hex\n};\n\nexport type TransactionPayload =\n\t| TokenTransferPayload\n\t| ContractCallPayload\n\t| SmartContractPayload\n\t| CoinbasePayload\n\t| CoinbaseToAltRecipientPayload\n\t| PoisonMicroblockPayload\n\t| TenureChangePayload\n\t| NakamotoCoinbasePayload;\n\n// Spending condition\nexport type SingleSigSpendingCondition = {\n\thashMode: typeof AddressHashMode.P2PKH | typeof AddressHashMode.P2WPKH;\n\tsigner: string; // hash160 hex\n\tnonce: bigint;\n\tfee: bigint;\n\tkeyEncoding: PubKeyEncoding;\n\tsignature: string; // 65-byte recoverable sig hex\n};\n\nexport type TransactionAuthField = {\n\tpubKeyEncoding: PubKeyEncoding;\n\ttype: \"publicKey\" | \"signature\";\n\tdata: string; // hex\n};\n\nexport type MultiSigHashMode =\n\t| typeof AddressHashMode.P2SH\n\t| typeof AddressHashMode.P2WSH\n\t| typeof AddressHashMode.P2SH_NonSequential\n\t| typeof AddressHashMode.P2WSH_P2SH_NonSequential;\n\nexport type MultiSigSpendingCondition = {\n\thashMode: MultiSigHashMode;\n\tsigner: string;\n\tnonce: bigint;\n\tfee: bigint;\n\tfields: TransactionAuthField[];\n\tsignaturesRequired: number;\n};\n\nexport type SpendingCondition =\n\t| SingleSigSpendingCondition\n\t| MultiSigSpendingCondition;\n\nexport type StandardAuthorization = {\n\tauthType: typeof AuthType.Standard;\n\tspendingCondition: SpendingCondition;\n};\n\nexport type SponsoredAuthorization = {\n\tauthType: typeof AuthType.Sponsored;\n\tspendingCondition: SpendingCondition;\n\tsponsorSpendingCondition: SpendingCondition;\n};\n\nexport type Authorization = StandardAuthorization | SponsoredAuthorization;\n\n// Full transaction\nexport type StacksTransaction = {\n\tversion: number;\n\tchainId: number;\n\tauth: Authorization;\n\tanchorMode: AnchorMode;\n\tpostConditionMode: PostConditionModeWire;\n\tpostConditions: PostConditionWire[];\n\tpayload: TransactionPayload;\n};\n\n// Wire post condition types\nexport type PostConditionWire =\n\t| StxPostConditionWire\n\t| FtPostConditionWire\n\t| NftPostConditionWire;\n\nexport type StxPostConditionWire = {\n\ttype: \"stx\";\n\tprincipal: PostConditionPrincipalWire;\n\tconditionCode: number;\n\tamount: bigint;\n};\n\nexport type FtPostConditionWire = {\n\ttype: \"ft\";\n\tprincipal: PostConditionPrincipalWire;\n\tasset: AssetInfoWire;\n\tconditionCode: number;\n\tamount: bigint;\n};\n\nexport type NftPostConditionWire = {\n\ttype: \"nft\";\n\tprincipal: PostConditionPrincipalWire;\n\tasset: AssetInfoWire;\n\tconditionCode: number;\n\tassetId: ClarityValue;\n};\n\nexport type PostConditionPrincipalWire =\n\t| { type: \"origin\" }\n\t| { type: \"standard\"; address: string }\n\t| { type: \"contract\"; address: string; contractName: string };\n\nexport type AssetInfoWire = {\n\taddress: string;\n\tcontractName: string;\n\tassetName: string;\n};\n",
6
+ "import { serializeCVBytes } from \"../../clarity/serialize.ts\";\nimport { c32addressDecode } from \"../../utils/c32.ts\";\nimport {\n\tasciiToBytes,\n\tbytesToHex,\n\tconcatBytes,\n\thexToBytes,\n\tintToBytes,\n\tintToHex,\n\tutf8ToBytes,\n\twriteUInt8,\n\twriteUInt16BE,\n\twriteUInt32BE,\n} from \"../../utils/encoding.ts\";\nimport {\n\ttype AssetInfoWire,\n\tAssetType,\n\tAuthType,\n\ttype Authorization,\n\ttype CoinbasePayload,\n\ttype CoinbaseToAltRecipientPayload,\n\tMEMO_MAX_LENGTH_BYTES,\n\ttype MultiSigSpendingCondition,\n\ttype NakamotoCoinbasePayload,\n\tPayloadType,\n\ttype PoisonMicroblockPayload,\n\tPostConditionPrincipalId,\n\ttype PostConditionPrincipalWire,\n\ttype PostConditionWire,\n\ttype SingleSigSpendingCondition,\n\ttype SpendingCondition,\n\ttype StacksTransaction,\n\ttype TenureChangePayload as TenureChangePayloadType,\n\ttype TransactionAuthField,\n\ttype TransactionPayload,\n} from \"../types.ts\";\n\n// Address serialization: version (1 byte) + hash160 (20 bytes)\nfunction serializeAddress(c32Address: string): Uint8Array {\n\tconst [version, hash160] = c32addressDecode(c32Address);\n\treturn concatBytes(new Uint8Array([version]), hexToBytes(hash160));\n}\n\n// LP string: length prefix (n bytes) + content bytes\nfunction serializeLPString(str: string, prefixBytes = 1): Uint8Array {\n\tconst content = utf8ToBytes(str);\n\tconst prefix = hexToBytes(intToHex(content.byteLength, prefixBytes));\n\treturn concatBytes(prefix, content);\n}\n\n// LP string for code body (4-byte prefix)\nfunction serializeLPStringLong(str: string): Uint8Array {\n\treturn serializeLPString(str, 4);\n}\n\n// Memo: flat 34-byte field (no length prefix) per SIP-005\nfunction serializeMemo(memo: string): Uint8Array {\n\tconst content = asciiToBytes(memo);\n\tconst padded = new Uint8Array(MEMO_MAX_LENGTH_BYTES);\n\tpadded.set(content.slice(0, MEMO_MAX_LENGTH_BYTES));\n\treturn padded;\n}\n\nfunction serializeSpendingCondition(condition: SpendingCondition): Uint8Array {\n\tconst parts: Uint8Array[] = [\n\t\twriteUInt8(condition.hashMode),\n\t\thexToBytes(condition.signer), // 20 bytes\n\t\tintToBytes(condition.nonce, 8),\n\t\tintToBytes(condition.fee, 8),\n\t];\n\n\tif (\"signature\" in condition) {\n\t\t// Single sig\n\t\tconst sc = condition as SingleSigSpendingCondition;\n\t\tparts.push(writeUInt8(sc.keyEncoding));\n\t\tparts.push(hexToBytes(sc.signature)); // 65 bytes\n\t} else {\n\t\t// Multi sig\n\t\tconst mc = condition as MultiSigSpendingCondition;\n\t\t// Fields as LP list\n\t\tparts.push(writeUInt32BE(mc.fields.length));\n\t\tfor (const field of mc.fields) {\n\t\t\tparts.push(serializeAuthField(field));\n\t\t}\n\t\tparts.push(writeUInt16BE(mc.signaturesRequired));\n\t}\n\n\treturn concatBytes(...parts);\n}\n\nfunction serializeAuthField(field: TransactionAuthField): Uint8Array {\n\tif (field.type === \"publicKey\") {\n\t\tconst typeId = field.pubKeyEncoding === 0x00 ? 0x00 : 0x01;\n\t\treturn concatBytes(writeUInt8(typeId), hexToBytes(field.data));\n\t} else {\n\t\tconst typeId = field.pubKeyEncoding === 0x00 ? 0x02 : 0x03;\n\t\treturn concatBytes(writeUInt8(typeId), hexToBytes(field.data));\n\t}\n}\n\nfunction serializeAuthorization(auth: Authorization): Uint8Array {\n\tconst parts: Uint8Array[] = [writeUInt8(auth.authType)];\n\tparts.push(serializeSpendingCondition(auth.spendingCondition));\n\tif (auth.authType === AuthType.Sponsored) {\n\t\tparts.push(serializeSpendingCondition(auth.sponsorSpendingCondition));\n\t}\n\treturn concatBytes(...parts);\n}\n\nfunction serializePrincipal(principal: PostConditionPrincipalWire): Uint8Array {\n\tswitch (principal.type) {\n\t\tcase \"origin\":\n\t\t\treturn writeUInt8(PostConditionPrincipalId.Origin);\n\t\tcase \"standard\":\n\t\t\treturn concatBytes(\n\t\t\t\twriteUInt8(PostConditionPrincipalId.Standard),\n\t\t\t\tserializeAddress(principal.address),\n\t\t\t);\n\t\tcase \"contract\":\n\t\t\treturn concatBytes(\n\t\t\t\twriteUInt8(PostConditionPrincipalId.Contract),\n\t\t\t\tserializeAddress(principal.address),\n\t\t\t\tserializeLPString(principal.contractName),\n\t\t\t);\n\t}\n}\n\nfunction serializeAssetInfo(asset: AssetInfoWire): Uint8Array {\n\treturn concatBytes(\n\t\tserializeAddress(asset.address),\n\t\tserializeLPString(asset.contractName),\n\t\tserializeLPString(asset.assetName),\n\t);\n}\n\nfunction serializePostCondition(pc: PostConditionWire): Uint8Array {\n\t// Wire order: asset_type first, then principal (per SIP-005)\n\tconst parts: Uint8Array[] = [];\n\n\tswitch (pc.type) {\n\t\tcase \"stx\":\n\t\t\tparts.push(writeUInt8(AssetType.STX));\n\t\t\tparts.push(serializePrincipal(pc.principal));\n\t\t\tparts.push(writeUInt8(pc.conditionCode));\n\t\t\tparts.push(intToBytes(pc.amount, 8));\n\t\t\tbreak;\n\t\tcase \"ft\":\n\t\t\tparts.push(writeUInt8(AssetType.Fungible));\n\t\t\tparts.push(serializePrincipal(pc.principal));\n\t\t\tparts.push(serializeAssetInfo(pc.asset));\n\t\t\tparts.push(writeUInt8(pc.conditionCode));\n\t\t\tparts.push(intToBytes(pc.amount, 8));\n\t\t\tbreak;\n\t\tcase \"nft\":\n\t\t\tparts.push(writeUInt8(AssetType.NonFungible));\n\t\t\tparts.push(serializePrincipal(pc.principal));\n\t\t\tparts.push(serializeAssetInfo(pc.asset));\n\t\t\tparts.push(serializeCVBytes(pc.assetId));\n\t\t\tparts.push(writeUInt8(pc.conditionCode));\n\t\t\tbreak;\n\t}\n\n\treturn concatBytes(...parts);\n}\n\nfunction serializePostConditions(pcs: PostConditionWire[]): Uint8Array {\n\tconst parts: Uint8Array[] = [writeUInt32BE(pcs.length)];\n\tfor (const pc of pcs) {\n\t\tparts.push(serializePostCondition(pc));\n\t}\n\treturn concatBytes(...parts);\n}\n\nexport function serializePayload(payload: TransactionPayload): Uint8Array {\n\tconst parts: Uint8Array[] = [writeUInt8(payload.payloadType)];\n\n\tswitch (payload.payloadType) {\n\t\tcase PayloadType.TokenTransfer:\n\t\t\tparts.push(serializeCVBytes(payload.recipient));\n\t\t\tparts.push(intToBytes(payload.amount, 8));\n\t\t\tparts.push(serializeMemo(payload.memo));\n\t\t\tbreak;\n\n\t\tcase PayloadType.ContractCall:\n\t\t\tparts.push(serializeAddress(payload.contractAddress));\n\t\t\tparts.push(serializeLPString(payload.contractName));\n\t\t\tparts.push(serializeLPString(payload.functionName));\n\t\t\tparts.push(writeUInt32BE(payload.functionArgs.length));\n\t\t\tfor (const arg of payload.functionArgs) {\n\t\t\t\tparts.push(serializeCVBytes(arg));\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase PayloadType.SmartContract:\n\t\t\tparts.push(serializeLPString(payload.contractName));\n\t\t\tparts.push(serializeLPStringLong(payload.codeBody));\n\t\t\tbreak;\n\n\t\tcase PayloadType.VersionedSmartContract:\n\t\t\tparts.push(writeUInt8(payload.clarityVersion ?? 2));\n\t\t\tparts.push(serializeLPString(payload.contractName));\n\t\t\tparts.push(serializeLPStringLong(payload.codeBody));\n\t\t\tbreak;\n\n\t\tcase PayloadType.Coinbase:\n\t\t\tparts.push(hexToBytes((payload as CoinbasePayload).coinbaseBuffer));\n\t\t\tbreak;\n\n\t\tcase PayloadType.CoinbaseToAltRecipient: {\n\t\t\tconst cbAlt = payload as CoinbaseToAltRecipientPayload;\n\t\t\tparts.push(hexToBytes(cbAlt.coinbaseBuffer));\n\t\t\tparts.push(serializeCVBytes(cbAlt.recipient));\n\t\t\tbreak;\n\t\t}\n\n\t\tcase PayloadType.PoisonMicroblock: {\n\t\t\tconst pm = payload as PoisonMicroblockPayload;\n\t\t\tparts.push(hexToBytes(pm.header1));\n\t\t\tparts.push(hexToBytes(pm.header2));\n\t\t\tbreak;\n\t\t}\n\n\t\tcase PayloadType.TenureChange: {\n\t\t\tconst tc = payload as TenureChangePayloadType;\n\t\t\tparts.push(hexToBytes(tc.tenureConsensusHash));\n\t\t\tparts.push(hexToBytes(tc.prevTenureConsensusHash));\n\t\t\tparts.push(hexToBytes(tc.burnViewConsensusHash));\n\t\t\tparts.push(hexToBytes(tc.previousTenureEnd));\n\t\t\tparts.push(writeUInt32BE(tc.previousTenureBlocks));\n\t\t\tparts.push(writeUInt8(tc.cause));\n\t\t\tparts.push(hexToBytes(tc.pubkeyHash));\n\t\t\tbreak;\n\t\t}\n\n\t\tcase PayloadType.NakamotoCoinbase: {\n\t\t\tconst nc = payload as NakamotoCoinbasePayload;\n\t\t\tparts.push(hexToBytes(nc.coinbaseBuffer));\n\t\t\tif (nc.recipient) {\n\t\t\t\tparts.push(serializeCVBytes({ type: \"some\", value: nc.recipient }));\n\t\t\t} else {\n\t\t\t\tparts.push(serializeCVBytes({ type: \"none\" }));\n\t\t\t}\n\t\t\tparts.push(hexToBytes(nc.vrfProof));\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn concatBytes(...parts);\n}\n\nexport function serializeTransaction(tx: StacksTransaction): Uint8Array {\n\treturn concatBytes(\n\t\twriteUInt8(tx.version),\n\t\twriteUInt32BE(tx.chainId),\n\t\tserializeAuthorization(tx.auth),\n\t\twriteUInt8(tx.anchorMode),\n\t\twriteUInt8(tx.postConditionMode),\n\t\tserializePostConditions(tx.postConditions),\n\t\tserializePayload(tx.payload),\n\t);\n}\n\nexport function serializeTransactionHex(tx: StacksTransaction): string {\n\treturn bytesToHex(serializeTransaction(tx));\n}\n",
7
+ "import { hmac } from \"@noble/hashes/hmac.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport { etc, getPublicKey as nobleGetPublicKey, sign } from \"@noble/secp256k1\";\nimport {\n\tbytesToHex,\n\tconcatBytes,\n\thexToBytes,\n\tintToBytes,\n\tintToHex,\n} from \"../utils/encoding.ts\";\nimport { hashP2PKH, txidFromBytes } from \"../utils/hash.ts\";\nimport {\n\tAddressHashMode,\n\tAuthType,\n\ttype Authorization,\n\tPubKeyEncoding,\n\tRECOVERABLE_ECDSA_SIG_LENGTH_BYTES,\n\ttype SingleSigSpendingCondition,\n\ttype SpendingCondition,\n\ttype SponsoredAuthorization,\n\ttype StandardAuthorization,\n} from \"./types.ts\";\n\n// Ensure sync signing is available\netc.hmacSha256Sync = (key: Uint8Array, ...msgs: Uint8Array[]) => {\n\tconst h = hmac.create(sha256, key);\n\tmsgs.forEach((msg) => h.update(msg));\n\treturn h.digest();\n};\n\nconst EMPTY_SIG = bytesToHex(\n\tnew Uint8Array(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES),\n);\n\nexport function createSingleSigSpendingCondition(\n\tpublicKey: string,\n\tnonce: bigint,\n\tfee: bigint,\n): SingleSigSpendingCondition {\n\tconst pubKeyBytes = hexToBytes(publicKey);\n\tconst signer = hashP2PKH(pubKeyBytes);\n\tconst isCompressed = pubKeyBytes.length === 33;\n\n\treturn {\n\t\thashMode: AddressHashMode.P2PKH,\n\t\tsigner,\n\t\tnonce,\n\t\tfee,\n\t\tkeyEncoding: isCompressed\n\t\t\t? PubKeyEncoding.Compressed\n\t\t\t: PubKeyEncoding.Uncompressed,\n\t\tsignature: EMPTY_SIG,\n\t};\n}\n\nexport function createStandardAuth(\n\tspendingCondition: SpendingCondition,\n): StandardAuthorization {\n\treturn { authType: AuthType.Standard, spendingCondition };\n}\n\nexport function createSponsoredAuth(\n\tspendingCondition: SpendingCondition,\n\tsponsorSpendingCondition?: SpendingCondition,\n): SponsoredAuthorization {\n\treturn {\n\t\tauthType: AuthType.Sponsored,\n\t\tspendingCondition,\n\t\tsponsorSpendingCondition:\n\t\t\tsponsorSpendingCondition ??\n\t\t\tcreateSingleSigSpendingCondition(\"0\".repeat(66), 0n, 0n),\n\t};\n}\n\nfunction clearCondition(condition: SpendingCondition): SpendingCondition {\n\tif (\"signature\" in condition) {\n\t\treturn {\n\t\t\t...condition,\n\t\t\tnonce: 0n,\n\t\t\tfee: 0n,\n\t\t\tsignature: EMPTY_SIG,\n\t\t};\n\t}\n\treturn {\n\t\t...condition,\n\t\tnonce: 0n,\n\t\tfee: 0n,\n\t\tfields: [],\n\t};\n}\n\nexport function intoInitialSighashAuth(auth: Authorization): Authorization {\n\tif (auth.authType === AuthType.Standard) {\n\t\treturn createStandardAuth(clearCondition(auth.spendingCondition));\n\t}\n\treturn createSponsoredAuth(\n\t\tclearCondition(auth.spendingCondition),\n\t\tclearCondition(createSingleSigSpendingCondition(\"0\".repeat(66), 0n, 0n)),\n\t);\n}\n\n/** Compute pre-sign sighash = sha512/256(prevSigHash + authType + fee + nonce) */\nexport function sigHashPreSign(\n\tcurSigHash: string,\n\tauthType: number,\n\tfee: bigint,\n\tnonce: bigint,\n): string {\n\tconst data = concatBytes(\n\t\thexToBytes(curSigHash),\n\t\tnew Uint8Array([authType]),\n\t\tintToBytes(fee, 8),\n\t\tintToBytes(nonce, 8),\n\t);\n\treturn txidFromBytes(data);\n}\n\n/** Compute post-sign sighash = sha512/256(preSigHash + pubKeyEncoding + signature) */\nexport function sigHashPostSign(\n\tcurSigHash: string,\n\tpubKeyEncoding: number,\n\tsignature: string,\n): string {\n\tconst data = concatBytes(\n\t\thexToBytes(curSigHash),\n\t\tnew Uint8Array([pubKeyEncoding]),\n\t\thexToBytes(signature),\n\t);\n\treturn txidFromBytes(data);\n}\n\n/** Sign with private key and return VRS signature (recoveryId + r + s) */\nfunction signWithKey(privateKey: string, messageHash: string): string {\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst sig = sign(messageHash, keyBytes, { lowS: true });\n\tconst recoveryIdHex = intToHex(sig.recovery, 1);\n\treturn recoveryIdHex + sig.toCompactHex();\n}\n\nexport function nextSignature(\n\tcurSigHash: string,\n\tauthType: number,\n\tfee: bigint,\n\tnonce: bigint,\n\tprivateKey: string,\n): { nextSig: string; nextSigHash: string } {\n\tconst sigHashPre = sigHashPreSign(curSigHash, authType, fee, nonce);\n\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst pubKey = nobleGetPublicKey(keyBytes, true);\n\tconst isCompressed = pubKey.length === 33;\n\tconst pubKeyEncoding = isCompressed\n\t\t? PubKeyEncoding.Compressed\n\t\t: PubKeyEncoding.Uncompressed;\n\n\tconst nextSig = signWithKey(privateKey, sigHashPre);\n\tconst nextSigHash = sigHashPostSign(sigHashPre, pubKeyEncoding, nextSig);\n\n\treturn { nextSig, nextSigHash };\n}\n",
8
+ "import {\n\tgetPublicKey as nobleGetPublicKey,\n\tsign as nobleSign,\n} from \"@noble/secp256k1\";\nimport type { CustomAccount, LocalAccount } from \"../accounts/types.ts\";\nimport type { StacksChain } from \"../chains/types.ts\";\nimport { c32address } from \"../utils/c32.ts\";\nimport {\n\tbytesToHex,\n\tconcatBytes,\n\thexToBytes,\n\tintToHex,\n} from \"../utils/encoding.ts\";\nimport { hash160 } from \"../utils/hash.ts\";\nimport { txidFromBytes } from \"../utils/hash.ts\";\nimport {\n\tintoInitialSighashAuth,\n\tnextSignature,\n\tsigHashPostSign,\n\tsigHashPreSign,\n} from \"./authorization.ts\";\nimport {\n\tAddressHashMode,\n\tAuthType,\n\ttype MultiSigHashMode,\n\ttype MultiSigSpendingCondition,\n\tPubKeyEncoding,\n\ttype StacksTransaction,\n\ttype TransactionAuthField,\n} from \"./types.ts\";\nimport { serializeTransaction } from \"./wire/serialize.ts\";\n\n// OP codes for redeem script\nconst OP_CHECKMULTISIG = 0xae;\n\n/** Check if hash mode is non-sequential (SIP-027) */\nexport function isNonSequential(hashMode: number): boolean {\n\treturn (hashMode & 0x04) !== 0;\n}\n\n/** Build a Bitcoin-style redeem script for m-of-n multi-sig */\nfunction makeRedeemScript(\n\tpublicKeys: string[],\n\tsignaturesRequired: number,\n): Uint8Array {\n\tconst parts: Uint8Array[] = [];\n\tparts.push(new Uint8Array([0x50 + signaturesRequired])); // OP_n\n\tfor (const pk of publicKeys) {\n\t\tconst pkBytes = hexToBytes(pk);\n\t\tparts.push(new Uint8Array([pkBytes.length])); // length prefix (0x21 for compressed)\n\t\tparts.push(pkBytes);\n\t}\n\tparts.push(new Uint8Array([0x50 + publicKeys.length])); // OP_m\n\tparts.push(new Uint8Array([OP_CHECKMULTISIG]));\n\treturn concatBytes(...parts);\n}\n\n/** Derive a multi-sig address from public keys */\nexport function makeMultiSigAddress(\n\tpublicKeys: string[],\n\tsignaturesRequired: number,\n\tchain?: StacksChain,\n): string {\n\tif (signaturesRequired < 1 || signaturesRequired > publicKeys.length) {\n\t\tthrow new Error(\n\t\t\t`signaturesRequired must be between 1 and ${publicKeys.length}`,\n\t\t);\n\t}\n\tconst redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n\tconst signer = hash160(redeemScript);\n\tconst version = chain?.addressVersion?.multiSig ?? 20; // mainnet default\n\treturn c32address(version, bytesToHex(signer));\n}\n\n/** Create an empty multi-sig spending condition */\nexport function createMultiSigSpendingCondition(\n\tpublicKeys: string[],\n\tsignaturesRequired: number,\n\tnonce: bigint,\n\tfee: bigint,\n\thashMode: MultiSigHashMode = AddressHashMode.P2SH,\n): MultiSigSpendingCondition {\n\tconst redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n\tconst signer = bytesToHex(hash160(redeemScript));\n\n\treturn {\n\t\thashMode,\n\t\tsigner,\n\t\tnonce,\n\t\tfee,\n\t\tfields: [],\n\t\tsignaturesRequired,\n\t};\n}\n\n/** Compute the initial sighash for a transaction (same as signBegin) */\nfunction initialSigHash(tx: StacksTransaction): string {\n\tconst cleared: StacksTransaction = {\n\t\t...tx,\n\t\tauth: intoInitialSighashAuth(tx.auth),\n\t};\n\treturn txidFromBytes(serializeTransaction(cleared));\n}\n\n/** Compute the presign-sighash used by all non-sequential signers */\nfunction nonSequentialPreSignHash(tx: StacksTransaction): string {\n\tconst condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\tconst initHash = initialSigHash(tx);\n\treturn sigHashPreSign(\n\t\tinitHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t);\n}\n\n/** Replay sighash through existing auth fields of a multi-sig tx */\nexport function replayMultiSigSigHash(tx: StacksTransaction): string {\n\tconst condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n\t// Non-sequential: all signers sign the same presign-sighash, no field chaining\n\tif (isNonSequential(condition.hashMode)) {\n\t\tconst preSign = nonSequentialPreSignHash(tx);\n\t\t// Chain through all fields to get the final sighash\n\t\tlet curSigHash = preSign;\n\t\tfor (const field of condition.fields) {\n\t\t\tcurSigHash = sigHashPostSign(\n\t\t\t\tcurSigHash,\n\t\t\t\tfield.pubKeyEncoding,\n\t\t\t\tfield.data,\n\t\t\t);\n\t\t}\n\t\treturn curSigHash;\n\t}\n\n\t// Sequential: chain through all fields\n\tlet curSigHash = initialSigHash(tx);\n\tfor (const field of condition.fields) {\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n\t}\n\treturn curSigHash;\n}\n\n/** Sign one position of a multi-sig transaction with a private key */\nexport function signMultiSig(\n\ttx: StacksTransaction,\n\tprivateKey: string,\n\tpublicKeys: string[],\n): StacksTransaction {\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst signerPubKey = bytesToHex(nobleGetPublicKey(keyBytes, true));\n\n\tconst signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n\tif (signerIndex === -1) {\n\t\tthrow new Error(\n\t\t\t\"Private key does not correspond to any signer in the multi-sig\",\n\t\t);\n\t}\n\n\tconst condition = {\n\t\t...(tx.auth.spendingCondition as MultiSigSpendingCondition),\n\t};\n\n\t// Non-sequential: all signers sign the same presign-sighash independently\n\tif (isNonSequential(condition.hashMode)) {\n\t\treturn signNonSequential(tx, condition, privateKey);\n\t}\n\n\t// Sequential: existing P2SH behavior\n\treturn signSequential(tx, condition, privateKey, publicKeys, signerIndex);\n}\n\n/** Non-sequential signing: compute presign-sighash from initial tx, sign, append */\nfunction signNonSequential(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\tprivateKey: string,\n): StacksTransaction {\n\tconst fields = [...condition.fields];\n\tconst preSignHash = nonSequentialPreSignHash(tx);\n\n\t// Sign the presign-sighash directly\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst sig = nobleSign(preSignHash, keyBytes, { lowS: true });\n\tconst recoveryIdHex = intToHex(sig.recovery, 1);\n\tconst nextSig = recoveryIdHex + sig.toCompactHex();\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\tconst sigCount = fields.filter((f) => f.type === \"signature\").length;\n\n\t// Auto-finalize: non-sequential needs no pubkey gap-filling\n\tif (sigCount >= condition.signaturesRequired) {\n\t\treturn {\n\t\t\t...tx,\n\t\t\tauth: { ...tx.auth, spendingCondition: newCondition },\n\t\t};\n\t}\n\n\treturn {\n\t\t...tx,\n\t\tauth: { ...tx.auth, spendingCondition: newCondition },\n\t};\n}\n\n/** Sequential signing: existing P2SH behavior */\nfunction signSequential(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\tprivateKey: string,\n\tpublicKeys: string[],\n\tsignerIndex: number,\n): StacksTransaction {\n\tconst fields = [...condition.fields];\n\n\t// Replay sighash through existing fields\n\tlet curSigHash = initialSigHash(tx);\n\tfor (const field of fields) {\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n\t}\n\n\t// Fill intervening positions with pubkey fields\n\tfor (let i = fields.length; i < signerIndex; i++) {\n\t\tconst pubKeyField: TransactionAuthField = {\n\t\t\ttype: \"publicKey\",\n\t\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\t\tdata: publicKeys[i]!,\n\t\t};\n\t\tfields.push(pubKeyField);\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(\n\t\t\tpreSign,\n\t\t\tpubKeyField.pubKeyEncoding,\n\t\t\tpubKeyField.data,\n\t\t);\n\t}\n\n\t// Sign at signerIndex\n\tconst { nextSig, nextSigHash } = nextSignature(\n\t\tcurSigHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t\tprivateKey,\n\t);\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\tcurSigHash = nextSigHash;\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n\t// Count signatures so far\n\tconst sigCount = fields.filter((f) => f.type === \"signature\").length;\n\tlet finalCondition = newCondition;\n\n\t// Auto-finalize if enough signatures collected\n\tif (sigCount >= condition.signaturesRequired) {\n\t\tfinalCondition = finalizeMultiSigCondition(\n\t\t\tnewCondition,\n\t\t\tpublicKeys,\n\t\t\tcurSigHash,\n\t\t);\n\t}\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: finalCondition,\n\t\t},\n\t};\n}\n\n/** Sign one position of a multi-sig transaction with an account */\nexport async function signMultiSigWithAccount(\n\ttx: StacksTransaction,\n\taccount: LocalAccount | CustomAccount,\n\tpublicKeys: string[],\n): Promise<StacksTransaction> {\n\tconst signerPubKey = account.publicKey;\n\n\tconst signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n\tif (signerIndex === -1) {\n\t\tthrow new Error(\n\t\t\t\"Account does not correspond to any signer in the multi-sig\",\n\t\t);\n\t}\n\n\tconst condition = {\n\t\t...(tx.auth.spendingCondition as MultiSigSpendingCondition),\n\t};\n\n\t// Non-sequential: all signers sign the same presign-sighash independently\n\tif (isNonSequential(condition.hashMode)) {\n\t\treturn signNonSequentialWithAccount(tx, condition, account);\n\t}\n\n\t// Sequential: existing behavior\n\treturn signSequentialWithAccount(\n\t\ttx,\n\t\tcondition,\n\t\taccount,\n\t\tpublicKeys,\n\t\tsignerIndex,\n\t);\n}\n\n/** Non-sequential signing with account */\nasync function signNonSequentialWithAccount(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\taccount: LocalAccount | CustomAccount,\n): Promise<StacksTransaction> {\n\tconst fields = [...condition.fields];\n\tconst preSignHash = nonSequentialPreSignHash(tx);\n\n\tconst sigBytes = await account.sign(hexToBytes(preSignHash));\n\tconst nextSig = bytesToHex(sigBytes);\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n\treturn {\n\t\t...tx,\n\t\tauth: { ...tx.auth, spendingCondition: newCondition },\n\t};\n}\n\n/** Sequential signing with account */\nasync function signSequentialWithAccount(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\taccount: LocalAccount | CustomAccount,\n\tpublicKeys: string[],\n\tsignerIndex: number,\n): Promise<StacksTransaction> {\n\tconst fields = [...condition.fields];\n\n\t// Replay sighash through existing fields\n\tlet curSigHash = initialSigHash(tx);\n\tfor (const field of fields) {\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n\t}\n\n\t// Fill intervening positions with pubkey fields\n\tfor (let i = fields.length; i < signerIndex; i++) {\n\t\tconst pubKeyField: TransactionAuthField = {\n\t\t\ttype: \"publicKey\",\n\t\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\t\tdata: publicKeys[i]!,\n\t\t};\n\t\tfields.push(pubKeyField);\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(\n\t\t\tpreSign,\n\t\t\tpubKeyField.pubKeyEncoding,\n\t\t\tpubKeyField.data,\n\t\t);\n\t}\n\n\t// Sign at signerIndex\n\tconst preSign = sigHashPreSign(\n\t\tcurSigHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t);\n\tconst sigBytes = await account.sign(hexToBytes(preSign));\n\tconst nextSig = bytesToHex(sigBytes);\n\tconst nextSigHash = sigHashPostSign(\n\t\tpreSign,\n\t\tPubKeyEncoding.Compressed,\n\t\tnextSig,\n\t);\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\tcurSigHash = nextSigHash;\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n\t// Count signatures so far\n\tconst sigCount = fields.filter((f) => f.type === \"signature\").length;\n\tlet finalCondition = newCondition;\n\n\t// Auto-finalize if enough signatures collected\n\tif (sigCount >= condition.signaturesRequired) {\n\t\tfinalCondition = finalizeMultiSigCondition(\n\t\t\tnewCondition,\n\t\t\tpublicKeys,\n\t\t\tcurSigHash,\n\t\t);\n\t}\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: finalCondition,\n\t\t},\n\t};\n}\n\n/** Fill remaining slots with pubkey fields after all signatures are collected */\nexport function finalizeMultiSig(\n\ttx: StacksTransaction,\n\tpublicKeys: string[],\n): StacksTransaction {\n\tconst condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n\t// Non-sequential: no pubkey gap-filling needed\n\tif (isNonSequential(condition.hashMode)) {\n\t\treturn tx;\n\t}\n\n\tconst curSigHash = replayMultiSigSigHash(tx);\n\tconst finalCondition = finalizeMultiSigCondition(\n\t\tcondition,\n\t\tpublicKeys,\n\t\tcurSigHash,\n\t);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: finalCondition,\n\t\t},\n\t};\n}\n\n/** Internal: finalize remaining pubkey slots (sequential only) */\nfunction finalizeMultiSigCondition(\n\tcondition: MultiSigSpendingCondition,\n\tpublicKeys: string[],\n\tcurSigHash: string,\n): MultiSigSpendingCondition {\n\tconst fields = [...condition.fields];\n\tlet sigHash = curSigHash;\n\n\t// Fill remaining positions\n\tfor (let i = fields.length; i < publicKeys.length; i++) {\n\t\tconst pubKeyField: TransactionAuthField = {\n\t\t\ttype: \"publicKey\",\n\t\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\t\tdata: publicKeys[i]!,\n\t\t};\n\t\tfields.push(pubKeyField);\n\t\tconst preSign = sigHashPreSign(\n\t\t\tsigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tsigHash = sigHashPostSign(\n\t\t\tpreSign,\n\t\t\tpubKeyField.pubKeyEncoding,\n\t\t\tpubKeyField.data,\n\t\t);\n\t}\n\n\treturn { ...condition, fields };\n}\n\n/** Combine independently-signed non-sequential multi-sig transactions */\nexport function combineMultiSigSignatures(\n\tbaseTx: StacksTransaction,\n\tsignedTxs: StacksTransaction[],\n): StacksTransaction {\n\tconst condition = baseTx.auth.spendingCondition as MultiSigSpendingCondition;\n\n\tif (!isNonSequential(condition.hashMode)) {\n\t\tthrow new Error(\n\t\t\t\"combineMultiSigSignatures only works with non-sequential hash modes (SIP-027)\",\n\t\t);\n\t}\n\n\t// Collect all signature fields from each signed tx\n\tconst seenSigs = new Set<string>();\n\tconst signatures: TransactionAuthField[] = [];\n\n\tfor (const stx of signedTxs) {\n\t\tconst stxCondition = stx.auth\n\t\t\t.spendingCondition as MultiSigSpendingCondition;\n\t\tfor (const field of stxCondition.fields) {\n\t\t\tif (field.type === \"signature\" && !seenSigs.has(field.data)) {\n\t\t\t\tseenSigs.add(field.data);\n\t\t\t\tsignatures.push(field);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (signatures.length === 0) {\n\t\tthrow new Error(\"No signatures found in the provided transactions\");\n\t}\n\n\tconst newCondition: MultiSigSpendingCondition = {\n\t\t...condition,\n\t\tfields: signatures,\n\t};\n\n\treturn {\n\t\t...baseTx,\n\t\tauth: { ...baseTx.auth, spendingCondition: newCondition },\n\t};\n}\n",
9
+ "import type { StacksChain } from \"../chains/types.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport type { PostCondition } from \"../postconditions/types.ts\";\nimport { parseContractId } from \"../utils/address.ts\";\nimport { type IntegerType, intToBigInt } from \"../utils/encoding.ts\";\nimport {\n\tcreateSingleSigSpendingCondition,\n\tcreateSponsoredAuth,\n\tcreateStandardAuth,\n} from \"./authorization.ts\";\nimport { createMultiSigSpendingCondition } from \"./multisig.ts\";\nimport type { MultiSigHashMode, SpendingCondition } from \"./types.ts\";\nimport {\n\tAnchorMode,\n\ttype ClarityVersion,\n\tFungibleConditionCode,\n\tNonFungibleConditionCode,\n\tPayloadType,\n\tPostConditionModeWire,\n\ttype PostConditionPrincipalWire,\n\ttype PostConditionWire,\n\ttype StacksTransaction,\n} from \"./types.ts\";\n\ntype MultiSigOptions = {\n\tpublicKeys?: string[];\n\tsignaturesRequired?: number;\n\thashMode?: MultiSigHashMode;\n};\n\nexport type BuildTokenTransferOptions = MultiSigOptions & {\n\trecipient: string;\n\tamount: IntegerType;\n\tmemo?: string;\n\tfee: IntegerType;\n\tnonce: IntegerType;\n\tpublicKey?: string;\n\tchain?: StacksChain;\n\tpostConditionMode?: \"allow\" | \"deny\";\n\tpostConditions?: PostCondition[];\n\tsponsored?: boolean;\n};\n\nexport type BuildContractCallOptions = MultiSigOptions & {\n\tcontractAddress: string;\n\tcontractName: string;\n\tfunctionName: string;\n\tfunctionArgs: ClarityValue[];\n\tfee: IntegerType;\n\tnonce: IntegerType;\n\tpublicKey?: string;\n\tchain?: StacksChain;\n\tpostConditionMode?: \"allow\" | \"deny\";\n\tpostConditions?: PostCondition[];\n\tsponsored?: boolean;\n};\n\nexport type BuildContractDeployOptions = MultiSigOptions & {\n\tcontractName: string;\n\tcodeBody: string;\n\tclarityVersion?: ClarityVersion;\n\tfee: IntegerType;\n\tnonce: IntegerType;\n\tpublicKey?: string;\n\tchain?: StacksChain;\n\tpostConditionMode?: \"allow\" | \"deny\";\n\tpostConditions?: PostCondition[];\n\tsponsored?: boolean;\n};\n\nfunction resolvePcMode(mode?: \"allow\" | \"deny\"): PostConditionModeWire {\n\treturn mode === \"allow\"\n\t\t? PostConditionModeWire.Allow\n\t\t: PostConditionModeWire.Deny;\n}\n\nfunction convertPostConditions(pcs?: PostCondition[]): PostConditionWire[] {\n\tif (!pcs || pcs.length === 0) return [];\n\treturn pcs.map(convertPostCondition);\n}\n\nfunction resolvePrincipal(address: string): PostConditionPrincipalWire {\n\tif (address === \"origin\") return { type: \"origin\" };\n\tconst [addr, name] = address.split(\".\");\n\tif (name) {\n\t\treturn { type: \"contract\", address: addr!, contractName: name };\n\t}\n\treturn { type: \"standard\", address: addr! };\n}\n\nconst FUNGIBLE_CODE_MAP: Record<string, number> = {\n\teq: FungibleConditionCode.Equal,\n\tgt: FungibleConditionCode.Greater,\n\tgte: FungibleConditionCode.GreaterEqual,\n\tlt: FungibleConditionCode.Less,\n\tlte: FungibleConditionCode.LessEqual,\n};\n\nfunction convertPostCondition(pc: PostCondition): PostConditionWire {\n\tswitch (pc.type) {\n\t\tcase \"stx-postcondition\":\n\t\t\treturn {\n\t\t\t\ttype: \"stx\",\n\t\t\t\tprincipal: resolvePrincipal(pc.address),\n\t\t\t\tconditionCode: FUNGIBLE_CODE_MAP[pc.condition]!,\n\t\t\t\tamount: intToBigInt(pc.amount),\n\t\t\t};\n\t\tcase \"ft-postcondition\": {\n\t\t\tconst [contractId, tokenName] = pc.asset.split(\"::\");\n\t\t\tconst [addr, name] = parseContractId(contractId!);\n\t\t\treturn {\n\t\t\t\ttype: \"ft\",\n\t\t\t\tprincipal: resolvePrincipal(pc.address),\n\t\t\t\tasset: { address: addr, contractName: name, assetName: tokenName! },\n\t\t\t\tconditionCode: FUNGIBLE_CODE_MAP[pc.condition]!,\n\t\t\t\tamount: intToBigInt(pc.amount),\n\t\t\t};\n\t\t}\n\t\tcase \"nft-postcondition\": {\n\t\t\tconst [contractId, tokenName] = pc.asset.split(\"::\");\n\t\t\tconst [addr, name] = parseContractId(contractId!);\n\t\t\treturn {\n\t\t\t\ttype: \"nft\",\n\t\t\t\tprincipal: resolvePrincipal(pc.address),\n\t\t\t\tasset: { address: addr, contractName: name, assetName: tokenName! },\n\t\t\t\tconditionCode:\n\t\t\t\t\tpc.condition === \"sent\"\n\t\t\t\t\t\t? NonFungibleConditionCode.Sends\n\t\t\t\t\t\t: NonFungibleConditionCode.DoesNotSend,\n\t\t\t\tassetId: pc.assetId,\n\t\t\t};\n\t\t}\n\t}\n}\n\nimport type { Authorization } from \"./types.ts\";\n\nfunction resolveSpendingCondition(\n\topts: MultiSigOptions & { publicKey?: string },\n\tnonce: bigint,\n\tfee: bigint,\n): SpendingCondition {\n\tif (opts.publicKeys) {\n\t\treturn createMultiSigSpendingCondition(\n\t\t\topts.publicKeys,\n\t\t\topts.signaturesRequired!,\n\t\t\tnonce,\n\t\t\tfee,\n\t\t\topts.hashMode,\n\t\t);\n\t}\n\treturn createSingleSigSpendingCondition(opts.publicKey!, nonce, fee);\n}\n\nfunction resolveAuth(\n\tspendingCondition: any,\n\tsponsored?: boolean,\n): Authorization {\n\treturn sponsored\n\t\t? createSponsoredAuth(spendingCondition)\n\t\t: createStandardAuth(spendingCondition);\n}\n\nfunction resolveVersionAndChainId(chain?: StacksChain): {\n\tversion: number;\n\tchainId: number;\n} {\n\tif (!chain) return { version: 0x00, chainId: 0x00000001 }; // mainnet defaults\n\treturn { version: chain.transactionVersion, chainId: chain.id };\n}\n\nexport function buildTokenTransfer(\n\toptions: BuildTokenTransferOptions,\n): StacksTransaction {\n\tconst { version, chainId } = resolveVersionAndChainId(options.chain);\n\tconst fee = intToBigInt(options.fee);\n\tconst nonce = intToBigInt(options.nonce);\n\n\tconst spendingCondition = resolveSpendingCondition(options, nonce, fee);\n\tconst recipient = Cl.principal(options.recipient);\n\n\tconst tx: StacksTransaction = {\n\t\tversion,\n\t\tchainId,\n\t\tauth: resolveAuth(spendingCondition, options.sponsored),\n\t\tanchorMode: AnchorMode.Any,\n\t\tpostConditionMode: resolvePcMode(options.postConditionMode),\n\t\tpostConditions: convertPostConditions(options.postConditions),\n\t\tpayload: {\n\t\t\tpayloadType: PayloadType.TokenTransfer,\n\t\t\trecipient,\n\t\t\tamount: intToBigInt(options.amount),\n\t\t\tmemo: options.memo ?? \"\",\n\t\t},\n\t};\n\n\tif (options.publicKeys) {\n\t\t(tx as any)._multisig = { publicKeys: options.publicKeys };\n\t}\n\treturn tx;\n}\n\nexport function buildContractCall(\n\toptions: BuildContractCallOptions,\n): StacksTransaction {\n\tconst { version, chainId } = resolveVersionAndChainId(options.chain);\n\tconst fee = intToBigInt(options.fee);\n\tconst nonce = intToBigInt(options.nonce);\n\n\tconst spendingCondition = resolveSpendingCondition(options, nonce, fee);\n\n\tconst tx: StacksTransaction = {\n\t\tversion,\n\t\tchainId,\n\t\tauth: resolveAuth(spendingCondition, options.sponsored),\n\t\tanchorMode: AnchorMode.Any,\n\t\tpostConditionMode: resolvePcMode(options.postConditionMode),\n\t\tpostConditions: convertPostConditions(options.postConditions),\n\t\tpayload: {\n\t\t\tpayloadType: PayloadType.ContractCall,\n\t\t\tcontractAddress: options.contractAddress,\n\t\t\tcontractName: options.contractName,\n\t\t\tfunctionName: options.functionName,\n\t\t\tfunctionArgs: options.functionArgs,\n\t\t},\n\t};\n\n\tif (options.publicKeys) {\n\t\t(tx as any)._multisig = { publicKeys: options.publicKeys };\n\t}\n\treturn tx;\n}\n\nexport function buildContractDeploy(\n\toptions: BuildContractDeployOptions,\n): StacksTransaction {\n\tconst { version, chainId } = resolveVersionAndChainId(options.chain);\n\tconst fee = intToBigInt(options.fee);\n\tconst nonce = intToBigInt(options.nonce);\n\n\tconst spendingCondition = resolveSpendingCondition(options, nonce, fee);\n\tconst useVersioned = options.clarityVersion !== undefined;\n\n\tconst tx: StacksTransaction = {\n\t\tversion,\n\t\tchainId,\n\t\tauth: resolveAuth(spendingCondition, options.sponsored),\n\t\tanchorMode: AnchorMode.Any,\n\t\tpostConditionMode: resolvePcMode(options.postConditionMode),\n\t\tpostConditions: convertPostConditions(options.postConditions),\n\t\tpayload: {\n\t\t\tpayloadType: useVersioned\n\t\t\t\t? PayloadType.VersionedSmartContract\n\t\t\t\t: PayloadType.SmartContract,\n\t\t\tclarityVersion: options.clarityVersion,\n\t\t\tcontractName: options.contractName,\n\t\t\tcodeBody: options.codeBody,\n\t\t},\n\t};\n\n\tif (options.publicKeys) {\n\t\t(tx as any)._multisig = { publicKeys: options.publicKeys };\n\t}\n\treturn tx;\n}\n",
10
+ "import type { CustomAccount, LocalAccount } from \"../accounts/types.ts\";\nimport { bytesToHex, hexToBytes } from \"../utils/encoding.ts\";\nimport { txidFromBytes } from \"../utils/hash.ts\";\nimport {\n\tintoInitialSighashAuth,\n\tnextSignature,\n\tsigHashPostSign,\n\tsigHashPreSign,\n} from \"./authorization.ts\";\nimport { replayMultiSigSigHash } from \"./multisig.ts\";\nimport {\n\tAuthType,\n\ttype SingleSigSpendingCondition,\n\ttype SponsoredAuthorization,\n\ttype StacksTransaction,\n} from \"./types.ts\";\nimport { serializeTransaction } from \"./wire/serialize.ts\";\n\nfunction txid(tx: StacksTransaction): string {\n\treturn txidFromBytes(serializeTransaction(tx));\n}\n\n/** Compute the initial sighash for a transaction */\nexport function signBegin(tx: StacksTransaction): string {\n\tconst cleared: StacksTransaction = {\n\t\t...tx,\n\t\tauth: intoInitialSighashAuth(tx.auth),\n\t};\n\treturn txid(cleared);\n}\n\n/** Sign a single-sig transaction with a private key, returning the signed transaction */\nexport function signTransaction(\n\ttx: StacksTransaction,\n\tprivateKey: string,\n): StacksTransaction {\n\tconst sigHash = signBegin(tx);\n\tconst condition = tx.auth.spendingCondition as SingleSigSpendingCondition;\n\n\t// Origin always signs with AuthType.Standard (even for sponsored txs)\n\tconst { nextSig } = nextSignature(\n\t\tsigHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t\tprivateKey,\n\t);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: {\n\t\t\t\t...condition,\n\t\t\t\tsignature: nextSig,\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** Sign a single-sig transaction using an account (LocalAccount or CustomAccount) */\nexport async function signTransactionWithAccount(\n\ttx: StacksTransaction,\n\taccount: LocalAccount | CustomAccount,\n): Promise<StacksTransaction> {\n\tconst sigHash = signBegin(tx);\n\tconst condition = tx.auth.spendingCondition as SingleSigSpendingCondition;\n\n\t// Origin always signs with AuthType.Standard (even for sponsored txs)\n\tconst sigHashPre = sigHashPreSign(\n\t\tsigHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t);\n\n\t// account.sign returns 65-byte VRS (recovery + r + s)\n\tconst sigBytes = await account.sign(hexToBytes(sigHashPre));\n\tconst nextSig = bytesToHex(sigBytes);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: {\n\t\t\t\t...condition,\n\t\t\t\tsignature: nextSig,\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** Get the txid of a transaction */\nexport function getTransactionId(tx: StacksTransaction): string {\n\treturn txid(tx);\n}\n\n/** Reconstruct the sighash after origin signing (needed for sponsor signing) */\nexport function getOriginSigHash(tx: StacksTransaction): string {\n\tconst condition = tx.auth.spendingCondition;\n\n\t// Multi-sig: replay through all fields\n\tif (\"fields\" in condition) {\n\t\treturn replayMultiSigSigHash(tx);\n\t}\n\n\t// Single-sig\n\tconst initialSigHash = signBegin(tx);\n\tconst sc = condition as SingleSigSpendingCondition;\n\tconst preSign = sigHashPreSign(\n\t\tinitialSigHash,\n\t\tAuthType.Standard,\n\t\tsc.fee,\n\t\tsc.nonce,\n\t);\n\treturn sigHashPostSign(preSign, sc.keyEncoding, sc.signature);\n}\n\n/** Sign a sponsored transaction as the sponsor with a private key */\nexport function signSponsor(\n\ttx: StacksTransaction,\n\tprivateKey: string,\n): StacksTransaction {\n\tif (tx.auth.authType !== AuthType.Sponsored) {\n\t\tthrow new Error(\"Transaction must be sponsored\");\n\t}\n\tconst auth = tx.auth as SponsoredAuthorization;\n\tconst sponsorCondition =\n\t\tauth.sponsorSpendingCondition as SingleSigSpendingCondition;\n\tconst originSigHash = getOriginSigHash(tx);\n\n\tconst { nextSig } = nextSignature(\n\t\toriginSigHash,\n\t\tAuthType.Sponsored,\n\t\tsponsorCondition.fee,\n\t\tsponsorCondition.nonce,\n\t\tprivateKey,\n\t);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...auth,\n\t\t\tsponsorSpendingCondition: {\n\t\t\t\t...sponsorCondition,\n\t\t\t\tsignature: nextSig,\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** Sign a sponsored transaction as the sponsor using an account */\nexport async function signSponsorWithAccount(\n\ttx: StacksTransaction,\n\taccount: LocalAccount | CustomAccount,\n): Promise<StacksTransaction> {\n\tif (tx.auth.authType !== AuthType.Sponsored) {\n\t\tthrow new Error(\"Transaction must be sponsored\");\n\t}\n\tconst auth = tx.auth as SponsoredAuthorization;\n\tconst sponsorCondition =\n\t\tauth.sponsorSpendingCondition as SingleSigSpendingCondition;\n\tconst originSigHash = getOriginSigHash(tx);\n\n\tconst sigHashPre = sigHashPreSign(\n\t\toriginSigHash,\n\t\tAuthType.Sponsored,\n\t\tsponsorCondition.fee,\n\t\tsponsorCondition.nonce,\n\t);\n\n\tconst sigBytes = await account.sign(hexToBytes(sigHashPre));\n\tconst nextSig = bytesToHex(sigBytes);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...auth,\n\t\t\tsponsorSpendingCondition: {\n\t\t\t\t...sponsorCondition,\n\t\t\t\tsignature: nextSig,\n\t\t\t},\n\t\t},\n\t};\n}\n"
11
+ ],
12
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,IAAM,WAAW;AAAA,EACvB,UAAU;AAAA,EACV,WAAW;AACZ;AAIO,IAAM,cAAc;AAAA,EAC1B,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB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B,EAAE;AAAA,EAEzC,MAAM,aAAa,eAClB,eACA,SAAS,WACT,iBAAiB,KACjB,iBAAiB,KAClB;AAAA,EAEA,MAAM,WAAW,MAAM,QAAQ,KAAK,WAAW,UAAU,CAAC;AAAA,EAC1D,MAAM,UAAU,WAAW,QAAQ;AAAA,EAEnC,OAAO;AAAA,OACH;AAAA,IACH,MAAM;AAAA,SACF;AAAA,MACH,0BAA0B;AAAA,WACtB;AAAA,QACH,WAAW;AAAA,MACZ;AAAA,IACD;AAAA,EACD;AAAA;",
13
+ "debugId": "E3994C33C4FEEE6E64756E2164756E21",
14
+ "names": []
15
+ }
@@ -106,7 +106,7 @@ function serializeCV(value) {
106
106
  return bytesToHex(serializeCVBytes(value));
107
107
  }
108
108
 
109
- // src/clarity/deserialize.ts
109
+ // src/utils/bytes-reader.ts
110
110
  class BytesReader {
111
111
  data;
112
112
  offset = 0;
@@ -114,21 +114,33 @@ class BytesReader {
114
114
  this.data = data;
115
115
  }
116
116
  readUInt8() {
117
- const value = this.data[this.offset];
118
- this.offset += 1;
119
- return value;
117
+ return this.data[this.offset++];
118
+ }
119
+ readUInt16BE() {
120
+ const val = (this.data[this.offset] << 8 | this.data[this.offset + 1]) >>> 0;
121
+ this.offset += 2;
122
+ return val;
120
123
  }
121
124
  readUInt32BE() {
122
- const value = (this.data[this.offset] << 24 | this.data[this.offset + 1] << 16 | this.data[this.offset + 2] << 8 | this.data[this.offset + 3]) >>> 0;
125
+ const val = (this.data[this.offset] << 24 | this.data[this.offset + 1] << 16 | this.data[this.offset + 2] << 8 | this.data[this.offset + 3]) >>> 0;
123
126
  this.offset += 4;
124
- return value;
127
+ return val;
125
128
  }
126
129
  readBytes(length) {
130
+ if (this.offset + length > this.data.length) {
131
+ throw new Error(`Buffer underflow: need ${length} bytes at offset ${this.offset}, have ${this.data.length}`);
132
+ }
127
133
  const slice = this.data.slice(this.offset, this.offset + length);
128
134
  this.offset += length;
129
135
  return slice;
130
136
  }
137
+ readBigUInt64BE() {
138
+ const hex = bytesToHex(this.readBytes(8));
139
+ return hex.length > 0 ? BigInt(`0x${hex}`) : 0n;
140
+ }
131
141
  }
142
+
143
+ // src/clarity/deserialize.ts
132
144
  function readAddress(reader) {
133
145
  const version = reader.readUInt8();
134
146
  const hash160 = bytesToHex(reader.readBytes(20));
@@ -318,5 +330,5 @@ var Cl = {
318
330
  deserialize: deserializeCVBytes
319
331
  };
320
332
 
321
- //# debugId=204FAEA7057C254064756E2164756E21
322
- //# sourceMappingURL=stacks-ky14tdf6.cjs.map
333
+ //# debugId=9F0937751BC5C71A64756E2164756E21
334
+ //# sourceMappingURL=stacks-0nfexv24.cjs.map
@@ -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;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