@secondlayer/stacks 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/shared/{stacks-vdfs3e5v.js → stacks-1ddg6mbv.js} +2 -2
  2. package/dist/shared/{stacks-bnvfmt7y.cjs → stacks-2gdt3aqj.cjs} +15 -2
  3. package/dist/shared/{stacks-8m9byk2j.js.map → stacks-2gdt3aqj.cjs.map} +1 -1
  4. package/dist/shared/stacks-709tra19.js.map +2 -2
  5. package/dist/shared/stacks-9g0jhab3.cjs.map +2 -2
  6. package/dist/shared/stacks-b008c3w8.cjs.map +2 -2
  7. package/dist/shared/stacks-gck1sq7h.cjs.map +2 -2
  8. package/dist/shared/stacks-gjvbq6w7.js.map +2 -2
  9. package/dist/shared/{stacks-74k8cxgb.cjs → stacks-hfem9dck.cjs} +46 -2
  10. package/dist/shared/stacks-hfem9dck.cjs.map +13 -0
  11. package/dist/shared/stacks-j2cy7qtt.js.map +2 -2
  12. package/dist/shared/stacks-k58k970n.js.map +2 -2
  13. package/dist/shared/{stacks-zm0b3tgy.js → stacks-m2dc5xwg.js} +7 -7
  14. package/dist/shared/{stacks-zm0b3tgy.js.map → stacks-m2dc5xwg.js.map} +1 -1
  15. package/dist/shared/{stacks-n2g56wgg.js → stacks-md6e5ta0.js} +13 -13
  16. package/dist/shared/{stacks-n2g56wgg.js.map → stacks-md6e5ta0.js.map} +1 -1
  17. package/dist/shared/stacks-njvyj3ab.js +23 -0
  18. package/dist/shared/{stacks-bnvfmt7y.cjs.map → stacks-njvyj3ab.js.map} +1 -1
  19. package/dist/shared/{stacks-dxhntr76.js → stacks-ph4a6322.js} +54 -11
  20. package/dist/shared/stacks-ph4a6322.js.map +10 -0
  21. package/dist/shared/{stacks-f7wdrzs3.js → stacks-pz73cn97.js} +17 -17
  22. package/dist/shared/{stacks-f7wdrzs3.js.map → stacks-pz73cn97.js.map} +1 -1
  23. package/dist/shared/stacks-qvg7c24g.cjs.map +2 -2
  24. package/dist/shared/{stacks-4py5pm0r.cjs → stacks-v3zy6zds.cjs} +42 -2
  25. package/dist/shared/stacks-v3zy6zds.cjs.map +10 -0
  26. package/dist/shared/stacks-v9jqcpd4.js.map +2 -2
  27. package/dist/shared/{stacks-yfgsm6ap.js → stacks-xtz0n62y.js} +58 -3
  28. package/dist/shared/stacks-xtz0n62y.js.map +13 -0
  29. package/dist/shared/stacks-ya3x01yd.cjs.map +2 -2
  30. package/dist/src/accounts/index.js +1 -1
  31. package/dist/src/actions/index.d.cts +43 -2
  32. package/dist/src/actions/index.d.ts +43 -2
  33. package/dist/src/actions/index.js +7 -7
  34. package/dist/src/bns/index.js +10 -10
  35. package/dist/src/bns/index.js.map +1 -1
  36. package/dist/src/chains/index.js +1 -1
  37. package/dist/src/clarity/index.cjs +326 -1
  38. package/dist/src/clarity/index.cjs.map +5 -3
  39. package/dist/src/clarity/index.d.cts +24 -5
  40. package/dist/src/clarity/index.d.ts +24 -5
  41. package/dist/src/clarity/index.js +264 -13
  42. package/dist/src/clarity/index.js.map +5 -3
  43. package/dist/src/connect/index.cjs.map +2 -2
  44. package/dist/src/connect/index.d.cts +7 -1
  45. package/dist/src/connect/index.d.ts +7 -1
  46. package/dist/src/connect/index.js.map +2 -2
  47. package/dist/src/connect/walletconnect/index.cjs +4 -4
  48. package/dist/src/connect/walletconnect/index.cjs.map +7 -7
  49. package/dist/src/connect/walletconnect/index.d.cts +5 -5
  50. package/dist/src/connect/walletconnect/index.d.ts +5 -5
  51. package/dist/src/connect/walletconnect/index.js +4 -4
  52. package/dist/src/connect/walletconnect/index.js.map +7 -7
  53. package/dist/src/index.cjs +1 -1
  54. package/dist/src/index.cjs.map +2 -2
  55. package/dist/src/index.d.cts +44 -3
  56. package/dist/src/index.d.ts +44 -3
  57. package/dist/src/index.js +12 -11
  58. package/dist/src/index.js.map +3 -3
  59. package/dist/src/postconditions/index.cjs +117 -1
  60. package/dist/src/postconditions/index.cjs.map +4 -3
  61. package/dist/src/postconditions/index.js +119 -6
  62. package/dist/src/postconditions/index.js.map +4 -3
  63. package/dist/src/pox/index.js +9 -9
  64. package/dist/src/pox/index.js.map +1 -1
  65. package/dist/src/stackingdao/index.cjs.map +2 -2
  66. package/dist/src/stackingdao/index.d.cts +18 -7
  67. package/dist/src/stackingdao/index.d.ts +18 -7
  68. package/dist/src/stackingdao/index.js +9 -9
  69. package/dist/src/stackingdao/index.js.map +3 -3
  70. package/dist/src/subscriptions/index.js +1 -1
  71. package/dist/src/transactions/index.cjs +5 -1
  72. package/dist/src/transactions/index.cjs.map +1 -1
  73. package/dist/src/transactions/index.d.cts +40 -2
  74. package/dist/src/transactions/index.d.ts +40 -2
  75. package/dist/src/transactions/index.js +18 -10
  76. package/dist/src/transactions/index.js.map +1 -1
  77. package/dist/src/utils/index.d.cts +4 -4
  78. package/dist/src/utils/index.d.ts +4 -4
  79. package/dist/src/utils/index.js +1 -1
  80. package/package.json +1 -1
  81. package/dist/shared/stacks-2ar4prfz.cjs +0 -328
  82. package/dist/shared/stacks-2ar4prfz.cjs.map +0 -11
  83. package/dist/shared/stacks-4py5pm0r.cjs.map +0 -10
  84. package/dist/shared/stacks-74k8cxgb.cjs.map +0 -13
  85. package/dist/shared/stacks-8m9byk2j.js +0 -7
  86. package/dist/shared/stacks-dr5en54r.cjs +0 -119
  87. package/dist/shared/stacks-dr5en54r.cjs.map +0 -10
  88. package/dist/shared/stacks-dxhntr76.js.map +0 -10
  89. package/dist/shared/stacks-f3tk2k5s.js +0 -27
  90. package/dist/shared/stacks-f3tk2k5s.js.map +0 -9
  91. package/dist/shared/stacks-g9mcjcqg.cjs +0 -3
  92. package/dist/shared/stacks-g9mcjcqg.cjs.map +0 -9
  93. package/dist/shared/stacks-tjxmrssa.js +0 -282
  94. package/dist/shared/stacks-tjxmrssa.js.map +0 -11
  95. package/dist/shared/stacks-yfgsm6ap.js.map +0 -13
  96. package/dist/shared/stacks-yfveb68e.js +0 -121
  97. package/dist/shared/stacks-yfveb68e.js.map +0 -10
  98. /package/dist/shared/{stacks-vdfs3e5v.js.map → stacks-1ddg6mbv.js.map} +0 -0
@@ -1,13 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/transactions/multisig.ts", "../src/transactions/authorization.ts", "../src/transactions/types.ts", "../src/transactions/wire/serialize.ts"],
4
- "sourcesContent": [
5
- "import {\n getPublicKey as nobleGetPublicKey,\n sign as nobleSign,\n} from \"@noble/secp256k1\";\nimport { c32address } from \"../utils/c32.ts\";\nimport { bytesToHex, hexToBytes, intToHex, concatBytes } from \"../utils/encoding.ts\";\nimport { hash160 } from \"../utils/hash.ts\";\nimport {\n sigHashPreSign,\n sigHashPostSign,\n intoInitialSighashAuth,\n nextSignature,\n} from \"./authorization.ts\";\nimport { txidFromBytes } from \"../utils/hash.ts\";\nimport { serializeTransaction } from \"./wire/serialize.ts\";\nimport {\n AuthType,\n AddressHashMode,\n PubKeyEncoding,\n type MultiSigSpendingCondition,\n type MultiSigHashMode,\n type TransactionAuthField,\n type StacksTransaction,\n} from \"./types.ts\";\nimport type { StacksChain } from \"../chains/types.ts\";\nimport type { LocalAccount, CustomAccount } from \"../accounts/types.ts\";\n\n// OP codes for redeem script\nconst OP_CHECKMULTISIG = 0xae;\n\n/** Check if hash mode is non-sequential (SIP-027) */\nexport function isNonSequential(hashMode: number): boolean {\n return (hashMode & 0x04) !== 0;\n}\n\n/** Build a Bitcoin-style redeem script for m-of-n multi-sig */\nfunction makeRedeemScript(publicKeys: string[], signaturesRequired: number): Uint8Array {\n const parts: Uint8Array[] = [];\n parts.push(new Uint8Array([0x50 + signaturesRequired])); // OP_n\n for (const pk of publicKeys) {\n const pkBytes = hexToBytes(pk);\n parts.push(new Uint8Array([pkBytes.length])); // length prefix (0x21 for compressed)\n parts.push(pkBytes);\n }\n parts.push(new Uint8Array([0x50 + publicKeys.length])); // OP_m\n parts.push(new Uint8Array([OP_CHECKMULTISIG]));\n return concatBytes(...parts);\n}\n\n/** Derive a multi-sig address from public keys */\nexport function makeMultiSigAddress(\n publicKeys: string[],\n signaturesRequired: number,\n chain?: StacksChain\n): string {\n if (signaturesRequired < 1 || signaturesRequired > publicKeys.length) {\n throw new Error(`signaturesRequired must be between 1 and ${publicKeys.length}`);\n }\n const redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n const signer = hash160(redeemScript);\n const version = chain?.addressVersion?.multiSig ?? 20; // mainnet default\n return c32address(version, bytesToHex(signer));\n}\n\n/** Create an empty multi-sig spending condition */\nexport function createMultiSigSpendingCondition(\n publicKeys: string[],\n signaturesRequired: number,\n nonce: bigint,\n fee: bigint,\n hashMode: MultiSigHashMode = AddressHashMode.P2SH\n): MultiSigSpendingCondition {\n const redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n const signer = bytesToHex(hash160(redeemScript));\n\n return {\n hashMode,\n signer,\n nonce,\n fee,\n fields: [],\n signaturesRequired,\n };\n}\n\n/** Compute the initial sighash for a transaction (same as signBegin) */\nfunction initialSigHash(tx: StacksTransaction): string {\n const cleared: StacksTransaction = {\n ...tx,\n auth: intoInitialSighashAuth(tx.auth),\n };\n return txidFromBytes(serializeTransaction(cleared));\n}\n\n/** Compute the presign-sighash used by all non-sequential signers */\nfunction nonSequentialPreSignHash(tx: StacksTransaction): string {\n const condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n const initHash = initialSigHash(tx);\n return sigHashPreSign(initHash, AuthType.Standard, condition.fee, condition.nonce);\n}\n\n/** Replay sighash through existing auth fields of a multi-sig tx */\nexport function replayMultiSigSigHash(tx: StacksTransaction): string {\n const condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n // Non-sequential: all signers sign the same presign-sighash, no field chaining\n if (isNonSequential(condition.hashMode)) {\n const preSign = nonSequentialPreSignHash(tx);\n // Chain through all fields to get the final sighash\n let curSigHash = preSign;\n for (const field of condition.fields) {\n curSigHash = sigHashPostSign(curSigHash, field.pubKeyEncoding, field.data);\n }\n return curSigHash;\n }\n\n // Sequential: chain through all fields\n let curSigHash = initialSigHash(tx);\n for (const field of condition.fields) {\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n }\n return curSigHash;\n}\n\n/** Sign one position of a multi-sig transaction with a private key */\nexport function signMultiSig(\n tx: StacksTransaction,\n privateKey: string,\n publicKeys: string[]\n): StacksTransaction {\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const signerPubKey = bytesToHex(nobleGetPublicKey(keyBytes, true));\n\n const signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n if (signerIndex === -1) {\n throw new Error(\"Private key does not correspond to any signer in the multi-sig\");\n }\n\n const condition = { ...(tx.auth.spendingCondition as MultiSigSpendingCondition) };\n\n // Non-sequential: all signers sign the same presign-sighash independently\n if (isNonSequential(condition.hashMode)) {\n return signNonSequential(tx, condition, privateKey);\n }\n\n // Sequential: existing P2SH behavior\n return signSequential(tx, condition, privateKey, publicKeys, signerIndex);\n}\n\n/** Non-sequential signing: compute presign-sighash from initial tx, sign, append */\nfunction signNonSequential(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n privateKey: string\n): StacksTransaction {\n const fields = [...condition.fields];\n const preSignHash = nonSequentialPreSignHash(tx);\n\n // Sign the presign-sighash directly\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const sig = nobleSign(preSignHash, keyBytes, { lowS: true });\n const recoveryIdHex = intToHex(sig.recovery, 1);\n const nextSig = recoveryIdHex + sig.toCompactHex();\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n const sigCount = fields.filter((f) => f.type === \"signature\").length;\n\n // Auto-finalize: non-sequential needs no pubkey gap-filling\n if (sigCount >= condition.signaturesRequired) {\n return {\n ...tx,\n auth: { ...tx.auth, spendingCondition: newCondition },\n };\n }\n\n return {\n ...tx,\n auth: { ...tx.auth, spendingCondition: newCondition },\n };\n}\n\n/** Sequential signing: existing P2SH behavior */\nfunction signSequential(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n privateKey: string,\n publicKeys: string[],\n signerIndex: number\n): StacksTransaction {\n const fields = [...condition.fields];\n\n // Replay sighash through existing fields\n let curSigHash = initialSigHash(tx);\n for (const field of fields) {\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n }\n\n // Fill intervening positions with pubkey fields\n for (let i = fields.length; i < signerIndex; i++) {\n const pubKeyField: TransactionAuthField = {\n type: \"publicKey\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: publicKeys[i]!,\n };\n fields.push(pubKeyField);\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, pubKeyField.pubKeyEncoding, pubKeyField.data);\n }\n\n // Sign at signerIndex\n const { nextSig, nextSigHash } = nextSignature(\n curSigHash,\n AuthType.Standard,\n condition.fee,\n condition.nonce,\n privateKey\n );\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n curSigHash = nextSigHash;\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n // Count signatures so far\n const sigCount = fields.filter((f) => f.type === \"signature\").length;\n let finalCondition = newCondition;\n\n // Auto-finalize if enough signatures collected\n if (sigCount >= condition.signaturesRequired) {\n finalCondition = finalizeMultiSigCondition(newCondition, publicKeys, curSigHash);\n }\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: finalCondition,\n },\n };\n}\n\n/** Sign one position of a multi-sig transaction with an account */\nexport async function signMultiSigWithAccount(\n tx: StacksTransaction,\n account: LocalAccount | CustomAccount,\n publicKeys: string[]\n): Promise<StacksTransaction> {\n const signerPubKey = account.publicKey;\n\n const signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n if (signerIndex === -1) {\n throw new Error(\"Account does not correspond to any signer in the multi-sig\");\n }\n\n const condition = { ...(tx.auth.spendingCondition as MultiSigSpendingCondition) };\n\n // Non-sequential: all signers sign the same presign-sighash independently\n if (isNonSequential(condition.hashMode)) {\n return signNonSequentialWithAccount(tx, condition, account);\n }\n\n // Sequential: existing behavior\n return signSequentialWithAccount(tx, condition, account, publicKeys, signerIndex);\n}\n\n/** Non-sequential signing with account */\nasync function signNonSequentialWithAccount(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n account: LocalAccount | CustomAccount\n): Promise<StacksTransaction> {\n const fields = [...condition.fields];\n const preSignHash = nonSequentialPreSignHash(tx);\n\n const sigBytes = await account.sign(hexToBytes(preSignHash));\n const nextSig = bytesToHex(sigBytes);\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n return {\n ...tx,\n auth: { ...tx.auth, spendingCondition: newCondition },\n };\n}\n\n/** Sequential signing with account */\nasync function signSequentialWithAccount(\n tx: StacksTransaction,\n condition: MultiSigSpendingCondition,\n account: LocalAccount | CustomAccount,\n publicKeys: string[],\n signerIndex: number\n): Promise<StacksTransaction> {\n const fields = [...condition.fields];\n\n // Replay sighash through existing fields\n let curSigHash = initialSigHash(tx);\n for (const field of fields) {\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n }\n\n // Fill intervening positions with pubkey fields\n for (let i = fields.length; i < signerIndex; i++) {\n const pubKeyField: TransactionAuthField = {\n type: \"publicKey\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: publicKeys[i]!,\n };\n fields.push(pubKeyField);\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n curSigHash = sigHashPostSign(preSign, pubKeyField.pubKeyEncoding, pubKeyField.data);\n }\n\n // Sign at signerIndex\n const preSign = sigHashPreSign(curSigHash, AuthType.Standard, condition.fee, condition.nonce);\n const sigBytes = await account.sign(hexToBytes(preSign));\n const nextSig = bytesToHex(sigBytes);\n const nextSigHash = sigHashPostSign(preSign, PubKeyEncoding.Compressed, nextSig);\n\n fields.push({\n type: \"signature\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: nextSig,\n });\n curSigHash = nextSigHash;\n\n const newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n // Count signatures so far\n const sigCount = fields.filter((f) => f.type === \"signature\").length;\n let finalCondition = newCondition;\n\n // Auto-finalize if enough signatures collected\n if (sigCount >= condition.signaturesRequired) {\n finalCondition = finalizeMultiSigCondition(newCondition, publicKeys, curSigHash);\n }\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: finalCondition,\n },\n };\n}\n\n/** Fill remaining slots with pubkey fields after all signatures are collected */\nexport function finalizeMultiSig(\n tx: StacksTransaction,\n publicKeys: string[]\n): StacksTransaction {\n const condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n // Non-sequential: no pubkey gap-filling needed\n if (isNonSequential(condition.hashMode)) {\n return tx;\n }\n\n const curSigHash = replayMultiSigSigHash(tx);\n const finalCondition = finalizeMultiSigCondition(condition, publicKeys, curSigHash);\n\n return {\n ...tx,\n auth: {\n ...tx.auth,\n spendingCondition: finalCondition,\n },\n };\n}\n\n/** Internal: finalize remaining pubkey slots (sequential only) */\nfunction finalizeMultiSigCondition(\n condition: MultiSigSpendingCondition,\n publicKeys: string[],\n curSigHash: string\n): MultiSigSpendingCondition {\n const fields = [...condition.fields];\n let sigHash = curSigHash;\n\n // Fill remaining positions\n for (let i = fields.length; i < publicKeys.length; i++) {\n const pubKeyField: TransactionAuthField = {\n type: \"publicKey\",\n pubKeyEncoding: PubKeyEncoding.Compressed,\n data: publicKeys[i]!,\n };\n fields.push(pubKeyField);\n const preSign = sigHashPreSign(sigHash, AuthType.Standard, condition.fee, condition.nonce);\n sigHash = sigHashPostSign(preSign, pubKeyField.pubKeyEncoding, pubKeyField.data);\n }\n\n return { ...condition, fields };\n}\n\n/** Combine independently-signed non-sequential multi-sig transactions */\nexport function combineMultiSigSignatures(\n baseTx: StacksTransaction,\n signedTxs: StacksTransaction[]\n): StacksTransaction {\n const condition = baseTx.auth.spendingCondition as MultiSigSpendingCondition;\n\n if (!isNonSequential(condition.hashMode)) {\n throw new Error(\"combineMultiSigSignatures only works with non-sequential hash modes (SIP-027)\");\n }\n\n // Collect all signature fields from each signed tx\n const seenSigs = new Set<string>();\n const signatures: TransactionAuthField[] = [];\n\n for (const stx of signedTxs) {\n const stxCondition = stx.auth.spendingCondition as MultiSigSpendingCondition;\n for (const field of stxCondition.fields) {\n if (field.type === \"signature\" && !seenSigs.has(field.data)) {\n seenSigs.add(field.data);\n signatures.push(field);\n }\n }\n }\n\n if (signatures.length === 0) {\n throw new Error(\"No signatures found in the provided transactions\");\n }\n\n const newCondition: MultiSigSpendingCondition = {\n ...condition,\n fields: signatures,\n };\n\n return {\n ...baseTx,\n auth: { ...baseTx.auth, spendingCondition: newCondition },\n };\n}\n",
6
- "import {\n getPublicKey as nobleGetPublicKey,\n sign,\n etc,\n} from \"@noble/secp256k1\";\nimport { hmac } from \"@noble/hashes/hmac.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport {\n bytesToHex,\n hexToBytes,\n intToBytes,\n intToHex,\n concatBytes,\n} from \"../utils/encoding.ts\";\nimport { hashP2PKH, txidFromBytes } from \"../utils/hash.ts\";\nimport {\n AuthType,\n AddressHashMode,\n PubKeyEncoding,\n RECOVERABLE_ECDSA_SIG_LENGTH_BYTES,\n type SingleSigSpendingCondition,\n type SpendingCondition,\n type Authorization,\n type StandardAuthorization,\n type SponsoredAuthorization,\n} from \"./types.ts\";\n\n// Ensure sync signing is available\netc.hmacSha256Sync = (key: Uint8Array, ...msgs: Uint8Array[]) => {\n const h = hmac.create(sha256, key);\n msgs.forEach((msg) => h.update(msg));\n return h.digest();\n};\n\nconst EMPTY_SIG = bytesToHex(new Uint8Array(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES));\n\nexport function createSingleSigSpendingCondition(\n publicKey: string,\n nonce: bigint,\n fee: bigint\n): SingleSigSpendingCondition {\n const pubKeyBytes = hexToBytes(publicKey);\n const signer = hashP2PKH(pubKeyBytes);\n const isCompressed = pubKeyBytes.length === 33;\n\n return {\n hashMode: AddressHashMode.P2PKH,\n signer,\n nonce,\n fee,\n keyEncoding: isCompressed ? PubKeyEncoding.Compressed : PubKeyEncoding.Uncompressed,\n signature: EMPTY_SIG,\n };\n}\n\nexport function createStandardAuth(\n spendingCondition: SpendingCondition\n): StandardAuthorization {\n return { authType: AuthType.Standard, spendingCondition };\n}\n\nexport function createSponsoredAuth(\n spendingCondition: SpendingCondition,\n sponsorSpendingCondition?: SpendingCondition\n): SponsoredAuthorization {\n return {\n authType: AuthType.Sponsored,\n spendingCondition,\n sponsorSpendingCondition: sponsorSpendingCondition ?? createSingleSigSpendingCondition(\n \"0\".repeat(66),\n 0n,\n 0n\n ),\n };\n}\n\nfunction clearCondition(condition: SpendingCondition): SpendingCondition {\n if (\"signature\" in condition) {\n return {\n ...condition,\n nonce: 0n,\n fee: 0n,\n signature: EMPTY_SIG,\n };\n }\n return {\n ...condition,\n nonce: 0n,\n fee: 0n,\n fields: [],\n };\n}\n\nexport function intoInitialSighashAuth(auth: Authorization): Authorization {\n if (auth.authType === AuthType.Standard) {\n return createStandardAuth(clearCondition(auth.spendingCondition));\n }\n return createSponsoredAuth(\n clearCondition(auth.spendingCondition),\n clearCondition(createSingleSigSpendingCondition(\"0\".repeat(66), 0n, 0n))\n );\n}\n\n/** Compute pre-sign sighash = sha512/256(prevSigHash + authType + fee + nonce) */\nexport function sigHashPreSign(\n curSigHash: string,\n authType: number,\n fee: bigint,\n nonce: bigint\n): string {\n const data = concatBytes(\n hexToBytes(curSigHash),\n new Uint8Array([authType]),\n intToBytes(fee, 8),\n intToBytes(nonce, 8)\n );\n return txidFromBytes(data);\n}\n\n/** Compute post-sign sighash = sha512/256(preSigHash + pubKeyEncoding + signature) */\nexport function sigHashPostSign(\n curSigHash: string,\n pubKeyEncoding: number,\n signature: string\n): string {\n const data = concatBytes(\n hexToBytes(curSigHash),\n new Uint8Array([pubKeyEncoding]),\n hexToBytes(signature)\n );\n return txidFromBytes(data);\n}\n\n/** Sign with private key and return VRS signature (recoveryId + r + s) */\nfunction signWithKey(privateKey: string, messageHash: string): string {\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const sig = sign(messageHash, keyBytes, { lowS: true });\n const recoveryIdHex = intToHex(sig.recovery, 1);\n return recoveryIdHex + sig.toCompactHex();\n}\n\nexport function nextSignature(\n curSigHash: string,\n authType: number,\n fee: bigint,\n nonce: bigint,\n privateKey: string\n): { nextSig: string; nextSigHash: string } {\n const sigHashPre = sigHashPreSign(curSigHash, authType, fee, nonce);\n\n const keyBytes = hexToBytes(privateKey).slice(0, 32);\n const pubKey = nobleGetPublicKey(keyBytes, true);\n const isCompressed = pubKey.length === 33;\n const pubKeyEncoding = isCompressed\n ? PubKeyEncoding.Compressed\n : PubKeyEncoding.Uncompressed;\n\n const nextSig = signWithKey(privateKey, sigHashPre);\n const nextSigHash = sigHashPostSign(sigHashPre, pubKeyEncoding, nextSig);\n\n return { nextSig, nextSigHash };\n}\n",
7
- "import type { ClarityValue } from \"../clarity/types.ts\";\n\n// Auth types\nexport const AuthType = {\n Standard: 0x04,\n Sponsored: 0x05,\n} as const;\nexport type AuthType = (typeof AuthType)[keyof typeof AuthType];\n\n// Payload types\nexport const PayloadType = {\n TokenTransfer: 0x00,\n SmartContract: 0x01,\n ContractCall: 0x02,\n PoisonMicroblock: 0x03,\n Coinbase: 0x04,\n CoinbaseToAltRecipient: 0x05,\n VersionedSmartContract: 0x06,\n TenureChange: 0x07,\n NakamotoCoinbase: 0x08,\n} as const;\nexport type PayloadType = (typeof PayloadType)[keyof typeof PayloadType];\n\n// Clarity version\nexport const ClarityVersion = {\n Clarity1: 1,\n Clarity2: 2,\n Clarity3: 3,\n} as const;\nexport type ClarityVersion = (typeof ClarityVersion)[keyof typeof ClarityVersion];\n\n// Anchor mode (deprecated post-Nakamoto, but needed for wire format)\nexport const AnchorMode = {\n OnChainOnly: 0x01,\n OffChainOnly: 0x02,\n Any: 0x03,\n} as const;\nexport type AnchorMode = (typeof AnchorMode)[keyof typeof AnchorMode];\n\n// Post condition mode\nexport const PostConditionModeWire = {\n Allow: 0x01,\n Deny: 0x02,\n} as const;\nexport type PostConditionModeWire =\n (typeof PostConditionModeWire)[keyof typeof PostConditionModeWire];\n\n// Address hash modes\nexport const AddressHashMode = {\n P2PKH: 0x00,\n P2SH: 0x01,\n P2WPKH: 0x02,\n P2WSH: 0x03,\n P2SH_NonSequential: 0x05, // SIP-027\n P2WSH_P2SH_NonSequential: 0x07, // SIP-027\n} as const;\nexport type AddressHashMode = (typeof AddressHashMode)[keyof typeof AddressHashMode];\n\n// Pub key encoding\nexport const PubKeyEncoding = {\n Compressed: 0x00,\n Uncompressed: 0x01,\n} as const;\nexport type PubKeyEncoding = (typeof PubKeyEncoding)[keyof typeof PubKeyEncoding];\n\n// Fungible condition codes (wire format)\nexport const FungibleConditionCode = {\n Equal: 0x01,\n Greater: 0x02,\n GreaterEqual: 0x03,\n Less: 0x04,\n LessEqual: 0x05,\n} as const;\n\n// Non-fungible condition codes (wire format)\nexport const NonFungibleConditionCode = {\n Sends: 0x10,\n DoesNotSend: 0x11,\n} as const;\n\n// Post condition principal types\nexport const PostConditionPrincipalId = {\n Origin: 0x01,\n Standard: 0x02,\n Contract: 0x03,\n} as const;\n\n// Post condition asset types\nexport const AssetType = {\n STX: 0x00,\n Fungible: 0x01,\n NonFungible: 0x02,\n} as const;\n\n// Auth field types\nexport const AuthFieldType = {\n PublicKeyCompressed: 0x00,\n PublicKeyUncompressed: 0x01,\n SignatureCompressed: 0x02,\n SignatureUncompressed: 0x03,\n} as const;\n\nexport const RECOVERABLE_ECDSA_SIG_LENGTH_BYTES = 65;\nexport const MEMO_MAX_LENGTH_BYTES = 34;\nexport const MAX_STRING_LENGTH_BYTES = 128;\n\n// Token transfer payload\nexport type TokenTransferPayload = {\n payloadType: typeof PayloadType.TokenTransfer;\n recipient: ClarityValue; // PrincipalCV\n amount: bigint;\n memo: string;\n};\n\n// Contract call payload\nexport type ContractCallPayload = {\n payloadType: typeof PayloadType.ContractCall;\n contractAddress: string;\n contractName: string;\n functionName: string;\n functionArgs: ClarityValue[];\n};\n\n// Smart contract deploy payload\nexport type SmartContractPayload = {\n payloadType: typeof PayloadType.SmartContract | typeof PayloadType.VersionedSmartContract;\n clarityVersion?: ClarityVersion;\n contractName: string;\n codeBody: string;\n};\n\nexport type TransactionPayload =\n | TokenTransferPayload\n | ContractCallPayload\n | SmartContractPayload;\n\n// Spending condition\nexport type SingleSigSpendingCondition = {\n hashMode: typeof AddressHashMode.P2PKH | typeof AddressHashMode.P2WPKH;\n signer: string; // hash160 hex\n nonce: bigint;\n fee: bigint;\n keyEncoding: PubKeyEncoding;\n signature: string; // 65-byte recoverable sig hex\n};\n\nexport type TransactionAuthField = {\n pubKeyEncoding: PubKeyEncoding;\n type: \"publicKey\" | \"signature\";\n data: string; // hex\n};\n\nexport type MultiSigHashMode =\n | typeof AddressHashMode.P2SH\n | typeof AddressHashMode.P2WSH\n | typeof AddressHashMode.P2SH_NonSequential\n | typeof AddressHashMode.P2WSH_P2SH_NonSequential;\n\nexport type MultiSigSpendingCondition = {\n hashMode: MultiSigHashMode;\n signer: string;\n nonce: bigint;\n fee: bigint;\n fields: TransactionAuthField[];\n signaturesRequired: number;\n};\n\nexport type SpendingCondition = SingleSigSpendingCondition | MultiSigSpendingCondition;\n\nexport type StandardAuthorization = {\n authType: typeof AuthType.Standard;\n spendingCondition: SpendingCondition;\n};\n\nexport type SponsoredAuthorization = {\n authType: typeof AuthType.Sponsored;\n spendingCondition: SpendingCondition;\n sponsorSpendingCondition: SpendingCondition;\n};\n\nexport type Authorization = StandardAuthorization | SponsoredAuthorization;\n\n// Full transaction\nexport type StacksTransaction = {\n version: number;\n chainId: number;\n auth: Authorization;\n anchorMode: AnchorMode;\n postConditionMode: PostConditionModeWire;\n postConditions: PostConditionWire[];\n payload: TransactionPayload;\n};\n\n// Wire post condition types\nexport type PostConditionWire = StxPostConditionWire | FtPostConditionWire | NftPostConditionWire;\n\nexport type StxPostConditionWire = {\n type: \"stx\";\n principal: PostConditionPrincipalWire;\n conditionCode: number;\n amount: bigint;\n};\n\nexport type FtPostConditionWire = {\n type: \"ft\";\n principal: PostConditionPrincipalWire;\n asset: AssetInfoWire;\n conditionCode: number;\n amount: bigint;\n};\n\nexport type NftPostConditionWire = {\n type: \"nft\";\n principal: PostConditionPrincipalWire;\n asset: AssetInfoWire;\n conditionCode: number;\n assetId: ClarityValue;\n};\n\nexport type PostConditionPrincipalWire =\n | { type: \"origin\" }\n | { type: \"standard\"; address: string }\n | { type: \"contract\"; address: string; contractName: string };\n\nexport type AssetInfoWire = {\n address: string;\n contractName: string;\n assetName: string;\n};\n",
8
- "import {\n bytesToHex,\n hexToBytes,\n concatBytes,\n intToBytes,\n intToHex,\n utf8ToBytes,\n asciiToBytes,\n writeUInt32BE,\n writeUInt16BE,\n writeUInt8,\n} from \"../../utils/encoding.ts\";\nimport { c32addressDecode } from \"../../utils/c32.ts\";\nimport { serializeCVBytes } from \"../../clarity/serialize.ts\";\nimport {\n AuthType,\n PayloadType,\n PostConditionPrincipalId,\n AssetType,\n RECOVERABLE_ECDSA_SIG_LENGTH_BYTES,\n MEMO_MAX_LENGTH_BYTES,\n type StacksTransaction,\n type Authorization,\n type SpendingCondition,\n type SingleSigSpendingCondition,\n type MultiSigSpendingCondition,\n type TransactionPayload,\n type PostConditionWire,\n type PostConditionPrincipalWire,\n type AssetInfoWire,\n type TransactionAuthField,\n type AuthFieldType,\n} from \"../types.ts\";\n\n// Address serialization: version (1 byte) + hash160 (20 bytes)\nfunction serializeAddress(c32Address: string): Uint8Array {\n const [version, hash160] = c32addressDecode(c32Address);\n return concatBytes(new Uint8Array([version]), hexToBytes(hash160));\n}\n\n// LP string: length prefix (n bytes) + content bytes\nfunction serializeLPString(str: string, prefixBytes = 1): Uint8Array {\n const content = utf8ToBytes(str);\n const prefix = hexToBytes(intToHex(content.byteLength, prefixBytes));\n return concatBytes(prefix, content);\n}\n\n// LP string for code body (4-byte prefix)\nfunction serializeLPStringLong(str: string): Uint8Array {\n return serializeLPString(str, 4);\n}\n\n// Memo: padded to MEMO_MAX_LENGTH_BYTES\nfunction serializeMemo(memo: string): Uint8Array {\n const content = asciiToBytes(memo);\n const padded = new Uint8Array(MEMO_MAX_LENGTH_BYTES);\n padded.set(content.slice(0, MEMO_MAX_LENGTH_BYTES));\n return concatBytes(writeUInt8(content.length), padded);\n}\n\nfunction serializeSpendingCondition(condition: SpendingCondition): Uint8Array {\n const parts: Uint8Array[] = [\n writeUInt8(condition.hashMode),\n hexToBytes(condition.signer), // 20 bytes\n intToBytes(condition.nonce, 8),\n intToBytes(condition.fee, 8),\n ];\n\n if (\"signature\" in condition) {\n // Single sig\n const sc = condition as SingleSigSpendingCondition;\n parts.push(writeUInt8(sc.keyEncoding));\n parts.push(hexToBytes(sc.signature)); // 65 bytes\n } else {\n // Multi sig\n const mc = condition as MultiSigSpendingCondition;\n // Fields as LP list\n parts.push(writeUInt32BE(mc.fields.length));\n for (const field of mc.fields) {\n parts.push(serializeAuthField(field));\n }\n parts.push(writeUInt16BE(mc.signaturesRequired));\n }\n\n return concatBytes(...parts);\n}\n\nfunction serializeAuthField(field: TransactionAuthField): Uint8Array {\n if (field.type === \"publicKey\") {\n const typeId = field.pubKeyEncoding === 0x00 ? 0x00 : 0x01;\n return concatBytes(writeUInt8(typeId), hexToBytes(field.data));\n } else {\n const typeId = field.pubKeyEncoding === 0x00 ? 0x02 : 0x03;\n return concatBytes(writeUInt8(typeId), hexToBytes(field.data));\n }\n}\n\nfunction serializeAuthorization(auth: Authorization): Uint8Array {\n const parts: Uint8Array[] = [writeUInt8(auth.authType)];\n parts.push(serializeSpendingCondition(auth.spendingCondition));\n if (auth.authType === AuthType.Sponsored) {\n parts.push(serializeSpendingCondition(auth.sponsorSpendingCondition));\n }\n return concatBytes(...parts);\n}\n\nfunction serializePrincipal(principal: PostConditionPrincipalWire): Uint8Array {\n switch (principal.type) {\n case \"origin\":\n return writeUInt8(PostConditionPrincipalId.Origin);\n case \"standard\":\n return concatBytes(\n writeUInt8(PostConditionPrincipalId.Standard),\n serializeAddress(principal.address)\n );\n case \"contract\":\n return concatBytes(\n writeUInt8(PostConditionPrincipalId.Contract),\n serializeAddress(principal.address),\n serializeLPString(principal.contractName)\n );\n }\n}\n\nfunction serializeAssetInfo(asset: AssetInfoWire): Uint8Array {\n return concatBytes(\n serializeAddress(asset.address),\n serializeLPString(asset.contractName),\n serializeLPString(asset.assetName)\n );\n}\n\nfunction serializePostCondition(pc: PostConditionWire): Uint8Array {\n const parts: Uint8Array[] = [serializePrincipal(pc.principal)];\n\n switch (pc.type) {\n case \"stx\":\n parts.push(writeUInt8(AssetType.STX));\n parts.push(writeUInt8(pc.conditionCode));\n parts.push(intToBytes(pc.amount, 8));\n break;\n case \"ft\":\n parts.push(writeUInt8(AssetType.Fungible));\n parts.push(serializeAssetInfo(pc.asset));\n parts.push(writeUInt8(pc.conditionCode));\n parts.push(intToBytes(pc.amount, 8));\n break;\n case \"nft\":\n parts.push(writeUInt8(AssetType.NonFungible));\n parts.push(serializeAssetInfo(pc.asset));\n parts.push(serializeCVBytes(pc.assetId));\n parts.push(writeUInt8(pc.conditionCode));\n break;\n }\n\n return concatBytes(...parts);\n}\n\nfunction serializePostConditions(pcs: PostConditionWire[]): Uint8Array {\n const parts: Uint8Array[] = [writeUInt32BE(pcs.length)];\n for (const pc of pcs) {\n parts.push(serializePostCondition(pc));\n }\n return concatBytes(...parts);\n}\n\nexport function serializePayload(payload: TransactionPayload): Uint8Array {\n const parts: Uint8Array[] = [writeUInt8(payload.payloadType)];\n\n switch (payload.payloadType) {\n case PayloadType.TokenTransfer:\n parts.push(serializeCVBytes(payload.recipient));\n parts.push(intToBytes(payload.amount, 8));\n parts.push(serializeMemo(payload.memo));\n break;\n\n case PayloadType.ContractCall:\n parts.push(serializeAddress(payload.contractAddress));\n parts.push(serializeLPString(payload.contractName));\n parts.push(serializeLPString(payload.functionName));\n parts.push(writeUInt32BE(payload.functionArgs.length));\n for (const arg of payload.functionArgs) {\n parts.push(serializeCVBytes(arg));\n }\n break;\n\n case PayloadType.SmartContract:\n parts.push(serializeLPString(payload.contractName));\n parts.push(serializeLPStringLong(payload.codeBody));\n break;\n\n case PayloadType.VersionedSmartContract:\n parts.push(writeUInt8(payload.clarityVersion ?? 2));\n parts.push(serializeLPString(payload.contractName));\n parts.push(serializeLPStringLong(payload.codeBody));\n break;\n }\n\n return concatBytes(...parts);\n}\n\nexport function serializeTransaction(tx: StacksTransaction): Uint8Array {\n return concatBytes(\n writeUInt8(tx.version),\n writeUInt32BE(tx.chainId),\n serializeAuthorization(tx.auth),\n writeUInt8(tx.anchorMode),\n writeUInt8(tx.postConditionMode),\n serializePostConditions(tx.postConditions),\n serializePayload(tx.payload)\n );\n}\n\nexport function serializeTransactionHex(tx: StacksTransaction): string {\n return bytesToHex(serializeTransaction(tx));\n}\n"
9
- ],
10
- "mappings": ";AAGO,IAHP;;;ACIO,IAJP;AAKqB,IAArB;AACuB,IAAvB;;;ACHO,IAAM,WAAW;AAAA,EACtB,UAAU;AAAA,EACV,WAAW;AACb;AAIO,IAAM,cAAc;AAAA,EACzB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,UAAU;AAAA,EACV,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,cAAc;AAAA,EACd,kBAAkB;AACpB;AAIO,IAAM,iBAAiB;AAAA,EAC5B,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACZ;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AAA,EAGA,MAAM,WAAW,IAAI;AAAA,EACrB,MAAM,aAAqC,CAAC;AAAA,EAE5C,WAAW,OAAO,WAAW;AAAA,IAC3B,MAAM,eAAe,IAAI,KAAK;AAAA,IAC9B,WAAW,SAAS,aAAa,QAAQ;AAAA,MACvC,IAAI,MAAM,SAAS,eAAe,CAAC,SAAS,IAAI,MAAM,IAAI,GAAG;AAAA,QAC3D,SAAS,IAAI,MAAM,IAAI;AAAA,QACvB,WAAW,KAAK,KAAK;AAAA,MACvB;AAAA,IACF;AAAA,EACF;AAAA,EAEA,IAAI,WAAW,WAAW,GAAG;AAAA,IAC3B,MAAM,IAAI,MAAM,kDAAkD;AAAA,EACpE;AAAA,EAEA,MAAM,eAA0C;AAAA,OAC3C;AAAA,IACH,QAAQ;AAAA,EACV;AAAA,EAEA,OAAO;AAAA,OACF;AAAA,IACH,MAAM,KAAK,OAAO,MAAM,mBAAmB,aAAa;AAAA,EAC1D;AAAA;",
11
- "debugId": "281F100A87B1568364756E2164756E21",
12
- "names": []
13
- }
@@ -1,7 +0,0 @@
1
- import { createRequire } from "node:module";
2
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
-
4
- export { __require };
5
-
6
- //# debugId=FEB3BB96297A3C6464756E2164756E21
7
- //# sourceMappingURL=stacks-8m9byk2j.js.map
@@ -1,119 +0,0 @@
1
- // src/postconditions/index.ts
2
- var exports_postconditions = {};
3
- __export(exports_postconditions, {
4
- Pc: () => Pc
5
- });
6
- module.exports = __toCommonJS(exports_postconditions);
7
-
8
- // src/postconditions/builder.ts
9
- class PartialPcWithPrincipal {
10
- address;
11
- constructor(address) {
12
- this.address = address;
13
- }
14
- willSendEq(amount) {
15
- return new PartialPcFtWithCode(this.address, amount, "eq");
16
- }
17
- willSendGte(amount) {
18
- return new PartialPcFtWithCode(this.address, amount, "gte");
19
- }
20
- willSendGt(amount) {
21
- return new PartialPcFtWithCode(this.address, amount, "gt");
22
- }
23
- willSendLte(amount) {
24
- return new PartialPcFtWithCode(this.address, amount, "lte");
25
- }
26
- willSendLt(amount) {
27
- return new PartialPcFtWithCode(this.address, amount, "lt");
28
- }
29
- willSendAsset() {
30
- return new PartialPcNftWithCode(this.address, "sent");
31
- }
32
- willNotSendAsset() {
33
- return new PartialPcNftWithCode(this.address, "not-sent");
34
- }
35
- }
36
-
37
- class PartialPcFtWithCode {
38
- address;
39
- amount;
40
- code;
41
- constructor(address, amount, code) {
42
- this.address = address;
43
- this.amount = amount;
44
- this.code = code;
45
- }
46
- ustx() {
47
- return {
48
- type: "stx-postcondition",
49
- address: this.address,
50
- condition: this.code,
51
- amount: intToBigInt(this.amount).toString()
52
- };
53
- }
54
- ft(contractId, tokenName) {
55
- const [address, name] = contractId.split(".");
56
- if (!address || !validateStacksAddress(address) || !name) {
57
- throw new Error(`Invalid contract id: ${contractId}`);
58
- }
59
- return {
60
- type: "ft-postcondition",
61
- address: this.address,
62
- condition: this.code,
63
- amount: intToBigInt(this.amount).toString(),
64
- asset: `${contractId}::${tokenName}`
65
- };
66
- }
67
- }
68
-
69
- class PartialPcNftWithCode {
70
- address;
71
- code;
72
- constructor(address, code) {
73
- this.address = address;
74
- this.code = code;
75
- }
76
- nft(assetOrContractId, tokenNameOrAssetId, assetId) {
77
- let contractAddress;
78
- let contractName;
79
- let tokenName;
80
- let id;
81
- if (assetId !== undefined) {
82
- [contractAddress, contractName] = parseContractId(assetOrContractId);
83
- tokenName = tokenNameOrAssetId;
84
- id = assetId;
85
- } else {
86
- const [principal, tName] = assetOrContractId.split("::");
87
- if (!principal || !tName)
88
- throw new Error(`Invalid asset name: ${assetOrContractId}`);
89
- [contractAddress, contractName] = parseContractId(principal);
90
- tokenName = tName;
91
- id = tokenNameOrAssetId;
92
- }
93
- if (!validateStacksAddress(contractAddress)) {
94
- throw new Error(`Invalid contract address: ${contractAddress}`);
95
- }
96
- return {
97
- type: "nft-postcondition",
98
- address: this.address,
99
- condition: this.code,
100
- asset: `${contractAddress}.${contractName}::${tokenName}`,
101
- assetId: id
102
- };
103
- }
104
- }
105
- var Pc = {
106
- principal(address) {
107
- const [addr, name] = address.split(".");
108
- if (!addr || !validateStacksAddress(addr) || typeof name === "string" && !name) {
109
- throw new Error(`Invalid principal: ${address}`);
110
- }
111
- return new PartialPcWithPrincipal(address);
112
- },
113
- origin() {
114
- return new PartialPcWithPrincipal("origin");
115
- }
116
- };
117
-
118
- //# debugId=60B2774FE4E4DD2564756E2164756E21
119
- //# sourceMappingURL=stacks-dr5en54r.cjs.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/postconditions/builder.ts"],
4
- "sourcesContent": [
5
- "import { intToBigInt, type IntegerType } from \"../utils/encoding.ts\";\nimport { validateStacksAddress, parseContractId } from \"../utils/address.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport type {\n StxPostCondition,\n FtPostCondition,\n NftPostCondition,\n FungibleComparator,\n NonFungibleComparator,\n} from \"./types.ts\";\n\nclass PartialPcWithPrincipal {\n constructor(private address: string) {}\n\n willSendEq(amount: IntegerType) {\n return new PartialPcFtWithCode(this.address, amount, \"eq\");\n }\n willSendGte(amount: IntegerType) {\n return new PartialPcFtWithCode(this.address, amount, \"gte\");\n }\n willSendGt(amount: IntegerType) {\n return new PartialPcFtWithCode(this.address, amount, \"gt\");\n }\n willSendLte(amount: IntegerType) {\n return new PartialPcFtWithCode(this.address, amount, \"lte\");\n }\n willSendLt(amount: IntegerType) {\n return new PartialPcFtWithCode(this.address, amount, \"lt\");\n }\n willSendAsset() {\n return new PartialPcNftWithCode(this.address, \"sent\");\n }\n willNotSendAsset() {\n return new PartialPcNftWithCode(this.address, \"not-sent\");\n }\n}\n\nclass PartialPcFtWithCode {\n constructor(\n private address: string,\n private amount: IntegerType,\n private code: FungibleComparator\n ) {}\n\n ustx(): StxPostCondition {\n return {\n type: \"stx-postcondition\",\n address: this.address,\n condition: this.code,\n amount: intToBigInt(this.amount).toString(),\n };\n }\n\n ft(contractId: string, tokenName: string): FtPostCondition {\n const [address, name] = contractId.split(\".\");\n if (!address || !validateStacksAddress(address) || !name) {\n throw new Error(`Invalid contract id: ${contractId}`);\n }\n return {\n type: \"ft-postcondition\",\n address: this.address,\n condition: this.code,\n amount: intToBigInt(this.amount).toString(),\n asset: `${contractId}::${tokenName}`,\n };\n }\n}\n\nclass PartialPcNftWithCode {\n constructor(\n private address: string,\n private code: NonFungibleComparator\n ) {}\n\n nft(assetOrContractId: string, tokenNameOrAssetId: string | ClarityValue, assetId?: ClarityValue): NftPostCondition {\n let contractAddress: string;\n let contractName: string;\n let tokenName: string;\n let id: ClarityValue;\n\n if (assetId !== undefined) {\n // 3 args: contractId, tokenName, assetId\n [contractAddress, contractName] = parseContractId(assetOrContractId);\n tokenName = tokenNameOrAssetId as string;\n id = assetId;\n } else {\n // 2 args: assetString (addr.contract::token), assetId\n const [principal, tName] = assetOrContractId.split(\"::\");\n if (!principal || !tName) throw new Error(`Invalid asset name: ${assetOrContractId}`);\n [contractAddress, contractName] = parseContractId(principal);\n tokenName = tName;\n id = tokenNameOrAssetId as ClarityValue;\n }\n\n if (!validateStacksAddress(contractAddress)) {\n throw new Error(`Invalid contract address: ${contractAddress}`);\n }\n\n return {\n type: \"nft-postcondition\",\n address: this.address,\n condition: this.code,\n asset: `${contractAddress}.${contractName}::${tokenName}`,\n assetId: id,\n };\n }\n}\n\nexport const Pc = {\n principal(address: string) {\n const [addr, name] = address.split(\".\");\n if (!addr || !validateStacksAddress(addr) || (typeof name === \"string\" && !name)) {\n throw new Error(`Invalid principal: ${address}`);\n }\n return new PartialPcWithPrincipal(address);\n },\n origin() {\n return new PartialPcWithPrincipal(\"origin\");\n },\n};\n"
6
- ],
7
- "mappings": ";;;;;;;;AAWA,MAAM,uBAAuB;AAAA,EACP;AAAA,EAApB,WAAW,CAAS,SAAiB;AAAA,IAAjB;AAAA;AAAA,EAEpB,UAAU,CAAC,QAAqB;AAAA,IAC9B,OAAO,IAAI,oBAAoB,KAAK,SAAS,QAAQ,IAAI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AG;AAAA,IACP,OAAO,IAAI,uBAAuB,QAAQ;AAAA;AAE9C;",
8
- "debugId": "60B2774FE4E4DD2564756E2164756E21",
9
- "names": []
10
- }
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/transactions/wire/deserialize.ts"],
4
- "sourcesContent": [
5
- "import {\n bytesToHex,\n hexToBytes,\n bytesToAscii,\n bytesToUtf8,\n without0x,\n} from \"../../utils/encoding.ts\";\nimport { c32address } from \"../../utils/c32.ts\";\nimport {\n AuthType,\n PayloadType,\n AddressHashMode,\n PostConditionPrincipalId,\n AssetType,\n RECOVERABLE_ECDSA_SIG_LENGTH_BYTES,\n MEMO_MAX_LENGTH_BYTES,\n type StacksTransaction,\n type Authorization,\n type SpendingCondition,\n type TransactionPayload,\n type PostConditionWire,\n type PostConditionPrincipalWire,\n type AssetInfoWire,\n type TransactionAuthField,\n type AnchorMode,\n type PostConditionModeWire,\n type ClarityVersion,\n} from \"../types.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport { clarityTypeFromByte } from \"../../clarity/types.ts\";\nimport {\n intCV,\n uintCV,\n trueCV,\n falseCV,\n bufferCV,\n noneCV,\n someCV,\n responseOkCV,\n responseErrorCV,\n standardPrincipalCV,\n contractPrincipalCV,\n listCV,\n tupleCV,\n stringAsciiCV,\n stringUtf8CV,\n} from \"../../clarity/values.ts\";\nimport { bytesToTwosBigInt } from \"../../utils/encoding.ts\";\n\nclass Reader {\n private data: Uint8Array;\n public offset = 0;\n\n constructor(data: Uint8Array) {\n this.data = data;\n }\n\n readUInt8(): number {\n return this.data[this.offset++]!;\n }\n\n readUInt16BE(): number {\n const val = ((this.data[this.offset]! << 8) | this.data[this.offset + 1]!) >>> 0;\n this.offset += 2;\n return val;\n }\n\n readUInt32BE(): number {\n const val =\n ((this.data[this.offset]! << 24) |\n (this.data[this.offset + 1]! << 16) |\n (this.data[this.offset + 2]! << 8) |\n this.data[this.offset + 3]!) >>>\n 0;\n this.offset += 4;\n return val;\n }\n\n readBytes(length: number): Uint8Array {\n const slice = this.data.slice(this.offset, this.offset + length);\n this.offset += length;\n return slice;\n }\n\n readBigUInt64BE(): bigint {\n return BigInt(`0x${bytesToHex(this.readBytes(8))}`);\n }\n}\n\nfunction readAddress(r: Reader): string {\n const version = r.readUInt8();\n const hash160 = bytesToHex(r.readBytes(20));\n return c32address(version, hash160);\n}\n\nfunction readLPString(r: Reader, prefixBytes = 1): string {\n let length = 0;\n for (let i = 0; i < prefixBytes; i++) {\n length = (length << 8) | r.readUInt8();\n }\n return bytesToUtf8(r.readBytes(length));\n}\n\nfunction readCV(r: Reader): ClarityValue {\n const typeByte = r.readUInt8();\n const type = clarityTypeFromByte(typeByte);\n\n switch (type) {\n case \"int\":\n return intCV(bytesToTwosBigInt(r.readBytes(16)));\n case \"uint\":\n return uintCV(r.readBytes(16));\n case \"true\":\n return trueCV();\n case \"false\":\n return falseCV();\n case \"buffer\": {\n const len = r.readUInt32BE();\n return bufferCV(r.readBytes(len));\n }\n case \"none\":\n return noneCV();\n case \"some\":\n return someCV(readCV(r));\n case \"ok\":\n return responseOkCV(readCV(r));\n case \"err\":\n return responseErrorCV(readCV(r));\n case \"address\":\n return standardPrincipalCV(readAddress(r));\n case \"contract\": {\n const addr = readAddress(r);\n const name = readLPString(r);\n return contractPrincipalCV(addr, name);\n }\n case \"list\": {\n const len = r.readUInt32BE();\n const items: ClarityValue[] = [];\n for (let i = 0; i < len; i++) items.push(readCV(r));\n return listCV(items);\n }\n case \"tuple\": {\n const len = r.readUInt32BE();\n const data: Record<string, ClarityValue> = {};\n for (let i = 0; i < len; i++) {\n const key = readLPString(r);\n data[key] = readCV(r);\n }\n return tupleCV(data);\n }\n case \"ascii\": {\n const len = r.readUInt32BE();\n return stringAsciiCV(bytesToAscii(r.readBytes(len)));\n }\n case \"utf8\": {\n const len = r.readUInt32BE();\n return stringUtf8CV(bytesToUtf8(r.readBytes(len)));\n }\n default:\n throw new Error(`Unknown clarity type: ${type}`);\n }\n}\n\nfunction readSpendingCondition(r: Reader): SpendingCondition {\n const hashMode = r.readUInt8();\n const signer = bytesToHex(r.readBytes(20));\n const nonce = r.readBigUInt64BE();\n const fee = r.readBigUInt64BE();\n\n if (hashMode === AddressHashMode.P2PKH || hashMode === AddressHashMode.P2WPKH) {\n const keyEncoding = r.readUInt8();\n const signature = bytesToHex(r.readBytes(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES));\n return { hashMode, signer, nonce, fee, keyEncoding, signature } as SpendingCondition;\n }\n\n const fieldCount = r.readUInt32BE();\n const fields: TransactionAuthField[] = [];\n for (let i = 0; i < fieldCount; i++) {\n const fieldType = r.readUInt8();\n if (fieldType <= 0x01) {\n const keyLen = fieldType === 0x00 ? 33 : 65;\n fields.push({\n type: \"publicKey\",\n pubKeyEncoding: fieldType as 0x00 | 0x01,\n data: bytesToHex(r.readBytes(keyLen)),\n });\n } else {\n fields.push({\n type: \"signature\",\n pubKeyEncoding: (fieldType === 0x02 ? 0x00 : 0x01) as 0x00 | 0x01,\n data: bytesToHex(r.readBytes(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES)),\n });\n }\n }\n const signaturesRequired = r.readUInt16BE();\n\n return { hashMode, signer, nonce, fee, fields, signaturesRequired } as SpendingCondition;\n}\n\nfunction readAuthorization(r: Reader): Authorization {\n const authType = r.readUInt8();\n const spendingCondition = readSpendingCondition(r);\n\n if (authType === AuthType.Standard) {\n return { authType: AuthType.Standard, spendingCondition };\n }\n\n const sponsorSpendingCondition = readSpendingCondition(r);\n return {\n authType: AuthType.Sponsored,\n spendingCondition,\n sponsorSpendingCondition,\n };\n}\n\nfunction readAssetInfo(r: Reader): AssetInfoWire {\n return {\n address: readAddress(r),\n contractName: readLPString(r),\n assetName: readLPString(r),\n };\n}\n\nfunction readPostConditionPrincipal(r: Reader): PostConditionPrincipalWire {\n const type = r.readUInt8();\n switch (type) {\n case PostConditionPrincipalId.Origin:\n return { type: \"origin\" };\n case PostConditionPrincipalId.Standard:\n return { type: \"standard\", address: readAddress(r) };\n case PostConditionPrincipalId.Contract:\n return { type: \"contract\", address: readAddress(r), contractName: readLPString(r) };\n default:\n throw new Error(`Unknown post condition principal type: ${type}`);\n }\n}\n\nfunction readPostConditions(r: Reader): PostConditionWire[] {\n const count = r.readUInt32BE();\n const pcs: PostConditionWire[] = [];\n for (let i = 0; i < count; i++) {\n const principal = readPostConditionPrincipal(r);\n const assetType = r.readUInt8();\n switch (assetType) {\n case AssetType.STX:\n pcs.push({ type: \"stx\", principal, conditionCode: r.readUInt8(), amount: r.readBigUInt64BE() });\n break;\n case AssetType.Fungible:\n pcs.push({ type: \"ft\", principal, asset: readAssetInfo(r), conditionCode: r.readUInt8(), amount: r.readBigUInt64BE() });\n break;\n case AssetType.NonFungible:\n pcs.push({ type: \"nft\", principal, asset: readAssetInfo(r), assetId: readCV(r), conditionCode: r.readUInt8() });\n break;\n }\n }\n return pcs;\n}\n\nfunction readPayload(r: Reader): TransactionPayload {\n const payloadType = r.readUInt8();\n\n switch (payloadType) {\n case PayloadType.TokenTransfer: {\n const recipient = readCV(r);\n const amount = r.readBigUInt64BE();\n const memoContentLen = r.readUInt8();\n const memoBytes = r.readBytes(MEMO_MAX_LENGTH_BYTES);\n const memo = bytesToAscii(memoBytes.slice(0, memoContentLen)).replace(/\\0+$/, \"\");\n return { payloadType: PayloadType.TokenTransfer, recipient, amount, memo };\n }\n case PayloadType.ContractCall: {\n const contractAddress = readAddress(r);\n const contractName = readLPString(r);\n const functionName = readLPString(r);\n const numArgs = r.readUInt32BE();\n const functionArgs: ClarityValue[] = [];\n for (let i = 0; i < numArgs; i++) functionArgs.push(readCV(r));\n return { payloadType: PayloadType.ContractCall, contractAddress, contractName, functionName, functionArgs };\n }\n case PayloadType.SmartContract: {\n const contractName = readLPString(r);\n const codeBody = readLPString(r, 4);\n return { payloadType: PayloadType.SmartContract, contractName, codeBody };\n }\n case PayloadType.VersionedSmartContract: {\n const clarityVersion = r.readUInt8() as ClarityVersion;\n const contractName = readLPString(r);\n const codeBody = readLPString(r, 4);\n return { payloadType: PayloadType.VersionedSmartContract, clarityVersion, contractName, codeBody };\n }\n default:\n throw new Error(`Unknown payload type: ${payloadType}`);\n }\n}\n\nexport function deserializeTransaction(input: string | Uint8Array): StacksTransaction {\n const bytes = typeof input === \"string\" ? hexToBytes(without0x(input)) : input;\n const r = new Reader(bytes);\n\n return {\n version: r.readUInt8(),\n chainId: r.readUInt32BE(),\n auth: readAuthorization(r),\n anchorMode: r.readUInt8() as AnchorMode,\n postConditionMode: r.readUInt8() as PostConditionModeWire,\n postConditions: readPostConditions(r),\n payload: readPayload(r),\n };\n}\n"
6
- ],
7
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,MAAM,OAAO;AAAA,EACH;AAAA,EACD,SAAS;AAAA,EAEhB,WAAW,CAAC,MAAkB;AAAA,IAC5B,KAAK,OAAO;AAAA;AAAA,EAGd,SAAS,GAAW;AAAA,IAClB,OAAO,KAAK,KAAK,KAAK;AAAA;AAAA,EAGxB,YAAY,GAAW;AAAA,IACrB,MAAM,OAAQ,KAAK,KAAK,KAAK,WAAY,IAAK,KAAK,KAAK,KAAK,SAAS,QAAS;AAAA,IAC/E,KAAK,UAAU;AAAA,IACf,OAAO;AAAA;AAAA,EAGT,YAAY,GAAW;AAAA,IACrB,MAAM,OACF,KAAK,KAAK,KAAK,WAAY,KAC1B,KAAK,KAAK,KAAK,SAAS,MAAO,KAC/B,KAAK,KAAK,KAAK,SAAS,MAAO,IAChC,KAAK,KAAK,KAAK,SAAS,QAC1B;AAAA,IACF,KAAK,UAAU;AAAA,IACf,OAAO;AAAA;AAAA,EAGT,SAAS,CAAC,QAA4B;AAAA,IACpC,MAAM,QAAQ,KAAK,KAAK,MAAM,KAAK,QAAQ,KAAK,SAAS,MAAM;AAAA,IAC/D,KAAK,UAAU;AAAA,IACf,OAAO;AAAA;AAAA,EAGT,eAAe,GAAW;AAAA,IACxB,OAAO,OA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,MAAM,IAAI,IAAI,OAAO,KAAK;AAAA,EAE1B,OAAO;AAAA,IACL,SAAS,EAAE,UAAU;AAAA,IACrB,SAAS,EAAE,aAAa;AAAA,IACxB,MAAM,kBAAkB,CAAC;AAAA,IACzB,YAAY,EAAE,UAAU;AAAA,IACxB,mBAAmB,EAAE,UAAU;AAAA,IAC/B,gBAAgB,mBAAmB,CAAC;AAAA,IACpC,SAAS,YAAY,CAAC;AAAA,EACxB;AAAA;",
8
- "debugId": "10C8FB91F221D94764756E2164756E21",
9
- "names": []
10
- }
@@ -1,27 +0,0 @@
1
- import {
2
- combineMultiSigSignatures,
3
- createMultiSigSpendingCondition,
4
- finalizeMultiSig,
5
- isNonSequential,
6
- makeMultiSigAddress,
7
- replayMultiSigSigHash,
8
- signMultiSig,
9
- signMultiSigWithAccount
10
- } from "./stacks-yfgsm6ap.js";
11
- import"./stacks-8yykgdww.js";
12
- import"./stacks-bycy6t9k.js";
13
- import"./stacks-nqytwfcc.js";
14
- import"./stacks-8m9byk2j.js";
15
- export {
16
- signMultiSigWithAccount,
17
- signMultiSig,
18
- replayMultiSigSigHash,
19
- makeMultiSigAddress,
20
- isNonSequential,
21
- finalizeMultiSig,
22
- createMultiSigSpendingCondition,
23
- combineMultiSigSignatures
24
- };
25
-
26
- //# debugId=D608AC6A85F865CA64756E2164756E21
27
- //# sourceMappingURL=stacks-f3tk2k5s.js.map
@@ -1,9 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [
5
- ],
6
- "mappings": "",
7
- "debugId": "D608AC6A85F865CA64756E2164756E21",
8
- "names": []
9
- }
@@ -1,3 +0,0 @@
1
-
2
- //# debugId=EF27B0F17AED2D2A64756E2164756E21
3
- //# sourceMappingURL=stacks-g9mcjcqg.cjs.map
@@ -1,9 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [
5
- ],
6
- "mappings": "",
7
- "debugId": "EF27B0F17AED2D2A64756E2164756E21",
8
- "names": []
9
- }
@@ -1,282 +0,0 @@
1
- import {
2
- isAbiBuffer,
3
- isAbiList,
4
- isAbiOptional,
5
- isAbiResponse,
6
- isAbiStringAscii,
7
- isAbiStringUtf8,
8
- isAbiTuple,
9
- isBool,
10
- isInt128,
11
- isPrincipal,
12
- isString,
13
- isUint128,
14
- isUint8Array,
15
- toCamelCase
16
- } from "./stacks-d1fmkv3p.js";
17
- import {
18
- asciiToBytes,
19
- bytesToAscii,
20
- hexToBytes,
21
- utf8ToBytes
22
- } from "./stacks-nqytwfcc.js";
23
- // src/clarity/prettyPrint.ts
24
- function prettyPrint(val, encoding = "hex") {
25
- switch (val.type) {
26
- case "true":
27
- return "true";
28
- case "false":
29
- return "false";
30
- case "int":
31
- return val.value.toString();
32
- case "uint":
33
- return `u${val.value.toString()}`;
34
- case "buffer":
35
- if (encoding === "tryAscii") {
36
- const str = bytesToAscii(hexToBytes(val.value));
37
- if (/^[ -~]*$/.test(str))
38
- return JSON.stringify(str);
39
- }
40
- return `0x${val.value}`;
41
- case "none":
42
- return "none";
43
- case "some":
44
- return `(some ${prettyPrint(val.value, encoding)})`;
45
- case "ok":
46
- return `(ok ${prettyPrint(val.value, encoding)})`;
47
- case "err":
48
- return `(err ${prettyPrint(val.value, encoding)})`;
49
- case "address":
50
- case "contract":
51
- return val.value;
52
- case "list":
53
- return `(list ${val.value.map((v) => prettyPrint(v, encoding)).join(" ")})`;
54
- case "tuple":
55
- return `(tuple ${Object.keys(val.value).map((key) => `(${key} ${prettyPrint(val.value[key], encoding)})`).join(" ")})`;
56
- case "ascii":
57
- return `"${val.value}"`;
58
- case "utf8":
59
- return `u"${val.value}"`;
60
- }
61
- }
62
- function cvToJSON(val) {
63
- switch (val.type) {
64
- case "true":
65
- return { type: "bool", value: true };
66
- case "false":
67
- return { type: "bool", value: false };
68
- case "int":
69
- return { type: "int", value: val.value.toString() };
70
- case "uint":
71
- return { type: "uint", value: val.value.toString() };
72
- case "buffer":
73
- return { type: `(buff ${Math.ceil(val.value.length / 2)})`, value: `0x${val.value}` };
74
- case "none":
75
- return { type: "(optional none)", value: null };
76
- case "some":
77
- return { type: `(optional)`, value: cvToJSON(val.value) };
78
- case "ok":
79
- return { type: "(response)", value: cvToJSON(val.value), success: true };
80
- case "err":
81
- return { type: "(response)", value: cvToJSON(val.value), success: false };
82
- case "address":
83
- case "contract":
84
- return { type: "principal", value: val.value };
85
- case "list":
86
- return { type: "(list)", value: val.value.map(cvToJSON) };
87
- case "tuple": {
88
- const result = {};
89
- for (const key of Object.keys(val.value)) {
90
- result[key] = cvToJSON(val.value[key]);
91
- }
92
- return { type: "(tuple)", value: result };
93
- }
94
- case "ascii":
95
- return { type: `(string-ascii ${asciiToBytes(val.value).length})`, value: val.value };
96
- case "utf8":
97
- return { type: `(string-utf8 ${utf8ToBytes(val.value).length})`, value: val.value };
98
- }
99
- }
100
- function cvToValue(val) {
101
- switch (val.type) {
102
- case "true":
103
- return true;
104
- case "false":
105
- return false;
106
- case "int":
107
- case "uint":
108
- return val.value;
109
- case "buffer":
110
- return `0x${val.value}`;
111
- case "none":
112
- return null;
113
- case "some":
114
- return cvToValue(val.value);
115
- case "ok":
116
- case "err":
117
- return cvToValue(val.value);
118
- case "address":
119
- case "contract":
120
- return val.value;
121
- case "list":
122
- return val.value.map(cvToValue);
123
- case "tuple": {
124
- const result = {};
125
- for (const key of Object.keys(val.value)) {
126
- result[key] = cvToValue(val.value[key]);
127
- }
128
- return result;
129
- }
130
- case "ascii":
131
- case "utf8":
132
- return val.value;
133
- }
134
- }
135
- // src/clarity/abi/converters.ts
136
- class ClarityConversionError extends Error {
137
- type;
138
- value;
139
- constructor(message, type, value) {
140
- super(message);
141
- this.type = type;
142
- this.value = value;
143
- this.name = "ClarityConversionError";
144
- }
145
- }
146
- function jsToClarity(type, value) {
147
- if (type === "none")
148
- return null;
149
- if (type === "uint128") {
150
- if (!isUint128(value))
151
- throw new ClarityConversionError("Invalid uint128 value", type, value);
152
- return value;
153
- }
154
- if (type === "int128") {
155
- if (!isInt128(value))
156
- throw new ClarityConversionError("Invalid int128 value", type, value);
157
- return value;
158
- }
159
- if (type === "bool") {
160
- if (!isBool(value))
161
- throw new ClarityConversionError("Invalid bool value", type, value);
162
- return value;
163
- }
164
- if (type === "principal") {
165
- if (!isPrincipal(value))
166
- throw new ClarityConversionError("Invalid principal value", type, value);
167
- return value;
168
- }
169
- if (type === "trait_reference") {
170
- if (!isPrincipal(value))
171
- throw new ClarityConversionError("Invalid trait_reference value", type, value);
172
- return value;
173
- }
174
- if (isAbiStringAscii(type)) {
175
- if (!isString(value))
176
- throw new ClarityConversionError("Invalid string-ascii value", type, value);
177
- const str = value;
178
- for (let i = 0;i < str.length; i++) {
179
- if (str.charCodeAt(i) > 127) {
180
- throw new ClarityConversionError(`Non-ASCII character at position ${i}: '${str[i]}' (code ${str.charCodeAt(i)})`, type, value);
181
- }
182
- }
183
- if (str.length > type["string-ascii"].length) {
184
- throw new ClarityConversionError(`String length ${str.length} exceeds max ${type["string-ascii"].length}`, type, value);
185
- }
186
- return value;
187
- }
188
- if (isAbiStringUtf8(type)) {
189
- if (!isString(value))
190
- throw new ClarityConversionError("Invalid string-utf8 value", type, value);
191
- const str = value;
192
- const byteLength = new TextEncoder().encode(str).length;
193
- if (byteLength > type["string-utf8"].length) {
194
- throw new ClarityConversionError(`String byte length ${byteLength} exceeds max ${type["string-utf8"].length}`, type, value);
195
- }
196
- return value;
197
- }
198
- if (isAbiBuffer(type)) {
199
- if (!isUint8Array(value))
200
- throw new ClarityConversionError("Invalid buffer value", type, value);
201
- const buff = value;
202
- if (buff.length > type.buff.length) {
203
- throw new ClarityConversionError(`Buffer length ${buff.length} exceeds max ${type.buff.length}`, type, value);
204
- }
205
- return value;
206
- }
207
- if (isAbiList(type)) {
208
- if (!Array.isArray(value))
209
- throw new ClarityConversionError("Expected array for list type", type, value);
210
- if (value.length > type.list.length) {
211
- throw new ClarityConversionError(`List length ${value.length} exceeds max ${type.list.length}`, type, value);
212
- }
213
- return value.map((item) => jsToClarity(type.list.type, item));
214
- }
215
- if (isAbiTuple(type)) {
216
- if (typeof value !== "object" || value === null)
217
- throw new ClarityConversionError("Expected object for tuple type", type, value);
218
- const result = {};
219
- for (const field of type.tuple) {
220
- const camelKey = toCamelCase(field.name);
221
- const hasOriginal = field.name in value;
222
- const hasCamel = camelKey in value;
223
- if (!hasOriginal && !hasCamel) {
224
- throw new ClarityConversionError(`Missing tuple field: ${field.name}`, type, value);
225
- }
226
- const fieldValue = hasOriginal ? value[field.name] : value[camelKey];
227
- result[field.name] = jsToClarity(field.type, fieldValue);
228
- }
229
- return result;
230
- }
231
- if (isAbiOptional(type)) {
232
- if (value === null || value === undefined)
233
- return null;
234
- return jsToClarity(type.optional, value);
235
- }
236
- if (isAbiResponse(type)) {
237
- if (typeof value !== "object" || value === null)
238
- throw new ClarityConversionError("Expected object for response type", type, value);
239
- const hasOk = "ok" in value;
240
- const hasErr = "err" in value;
241
- if (hasOk && !hasErr) {
242
- return {
243
- ok: jsToClarity(type.response.ok, value.ok)
244
- };
245
- }
246
- if (hasErr && !hasOk) {
247
- return {
248
- err: jsToClarity(type.response.error, value.err)
249
- };
250
- }
251
- throw new ClarityConversionError("Response must have exactly 'ok' or 'err' property", type, value);
252
- }
253
- throw new ClarityConversionError(`Unknown Clarity type`, type, value);
254
- }
255
- function prepareArgs(func, args) {
256
- return func.args.map((arg) => {
257
- if (!(arg.name in args)) {
258
- throw new ClarityConversionError(`Missing argument: ${arg.name}`, arg.type, undefined);
259
- }
260
- return jsToClarity(arg.type, args[arg.name]);
261
- });
262
- }
263
- function validateArgs(func, args) {
264
- for (const arg of func.args) {
265
- if (!(arg.name in args)) {
266
- throw new ClarityConversionError(`Missing argument: ${arg.name}`, arg.type, undefined);
267
- }
268
- jsToClarity(arg.type, args[arg.name]);
269
- }
270
- }
271
- function validateArgsArray(func, args) {
272
- if (args.length !== func.args.length) {
273
- throw new ClarityConversionError(`Expected ${func.args.length} arguments, got ${args.length}`, func.args[0]?.type ?? "bool", args);
274
- }
275
- func.args.forEach((arg, i) => {
276
- jsToClarity(arg.type, args[i]);
277
- });
278
- }
279
- export { prettyPrint, cvToJSON, cvToValue, ClarityConversionError, jsToClarity, prepareArgs, validateArgs, validateArgsArray };
280
-
281
- //# debugId=DAD8B8065D272C2164756E2164756E21
282
- //# sourceMappingURL=stacks-tjxmrssa.js.map