{
  "version": 3,
  "sources": ["../src/epochs.ts", "../src/pox5/constants.ts", "../src/pox5/activation.ts", "../src/pox5/errors.ts", "../src/errors/base.ts", "../src/errors/response.ts", "../src/actions/public/getBalance.ts", "../src/errors/transaction.ts", "../src/utils/encoding.ts", "../src/utils/bytes-reader.ts", "../src/utils/c32.ts", "../src/clarity/types.ts", "../src/utils/constants.ts", "../src/utils/hash.ts", "../src/utils/address.ts", "../src/clarity/serialize.ts", "../src/clarity/values.ts", "../src/clarity/deserialize.ts", "../src/actions/public/getDataVar.ts", "../src/actions/public/getMapEntry.ts", "../src/clarity/abi/utils.ts", "../src/clarity/abi/guards.ts", "../src/clarity/bridge.ts", "../src/transactions/types.ts", "../src/transactions/wire/deserialize.ts", "../src/transactions/wire/serialize.ts", "../src/postconditions/convert.ts", "../src/transactions/authorization.ts", "../src/transactions/multisig.ts", "../src/transactions/build.ts", "../src/actions/public/getNonce.ts", "../src/actions/public/readContract.ts", "../src/transactions/signer.ts", "../src/errors/http.ts", "../src/errors/transport.ts", "../src/transports/createTransport.ts", "../src/actions/public/txSources.ts", "../src/actions/public/getTransaction.ts", "../src/actions/public/getBlockHeight.ts", "../src/actions/public/waitForTransactionReceipt.ts", "../src/actions/wallet/sendTransaction.ts", "../src/actions/wallet/nonceManager.ts", "../src/actions/public/estimateFee.ts", "../src/actions/wallet/utils.ts", "../src/actions/wallet/callContract.ts", "../src/actions/getContract.ts", "../src/pox5/abi.ts", "../src/pox5/actions.ts", "../src/pox5/cycles.ts", "../src/pox5/eligibility.ts", "../src/pox5/script.ts", "../src/bitcoin/address.ts", "../src/bitcoin/serialize.ts", "../src/pox5/grants.ts", "../src/clarity/structuredData.ts", "../src/pox5/lockProof.ts", "../src/bitcoin/merkle.ts", "../src/bitcoin/proof.ts", "../src/pox5/reclaim.ts", "../src/actions/public/multicall.ts", "../src/pox5/extension.ts", "../src/pox5/btcAddress.ts", "../src/pox/constants.ts", "../src/pox5/signerCalldata.ts"],
  "sourcesContent": [
    "/**\n * Stacks hard-fork epoch activation heights, as Bitcoin burn block heights.\n *\n * Epoch 4.0 carries both SIP-044 (the native Bitcoin SPV built-ins / Clarity 6)\n * and SIP-045 (`pox-5` Bitcoin Staking) — one fork, one height. Keep it here so\n * the two modules can never disagree.\n */\n\n/**\n * Epoch 4.0 activation height on mainnet — Bitcoin block 960,230 (~2026-07-30\n * AM UTC, per the stacks-core 4.0.1 release notes).\n *\n * Only mainnet has a fixed height. On other networks, read it from the node\n * (`getPox5Activation` for pox-5) or pass it explicitly.\n */\nexport const EPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET = 960_230;\n",
    "/**\n * PoX-5 (SIP-045 Bitcoin Staking) constants, pinned against the final\n * contract shipped in stacks-core 4.0.1 (`stackslib/.../boot/pox-5.clar`);\n * `scripts/ci/check-pox5-pin.ts` holds the pinned tag + content hash.\n */\n\nimport { EPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET } from \"../epochs.ts\";\n\n/** Boot contract name; deployer is the chain's boot address. */\nexport const POX5_CONTRACT_NAME = \"pox-5\";\n\n/** Fully-qualified mainnet contract id (boot address + `pox-5`). */\nexport const POX5_CONTRACT_ID_MAINNET: string = `SP000000000000000000002Q6VF78.${POX5_CONTRACT_NAME}`;\n\n/**\n * All print-event topic strings emitted by `pox-5.clar`. Unlike pox-2/3/4,\n * pox-5 has NO node-synthesized events — every event is a real `(print ...)`\n * with these `topic` values and the remaining tuple fields flattened at the\n * top level via `merge` (not nested under a `data` key).\n *\n * `add-to-allowlist` and `bond-distribution` are emitted per-item inside\n * folds (`setup-bond` / `calculate-rewards`), so one transaction can carry\n * many prints.\n */\nexport const POX5_EVENT_TOPICS = [\n\t\"set-bond-admin\",\n\t\"set-pause-admin\",\n\t\"pause-rewards\",\n\t\"setup-bond\",\n\t\"add-to-allowlist\",\n\t\"register-for-bond\",\n\t\"update-bond-registration\",\n\t\"register-signer\",\n\t\"stake\",\n\t\"stake-update\",\n\t\"announce-l1-early-exit\",\n\t\"unstake-sbtc\",\n\t\"unstake\",\n\t\"calculate-rewards\",\n\t\"bond-distribution\",\n\t\"claim-rewards\",\n\t\"claim-staker-rewards-for-signer\",\n\t\"grant-signer-key\",\n\t\"revoke-signer-grant\",\n] as const;\n\nexport type Pox5EventTopic = (typeof POX5_EVENT_TOPICS)[number];\n\n/**\n * Epoch 4.0 hard-fork activation height on mainnet — see\n * {@link EPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET}. Prefer the runtime gate in\n * `activation.ts` (`getPox5Activation`), which reads the node's `/v2/pox` and\n * works on every network.\n */\nexport const POX5_ACTIVATION_BURN_HEIGHT_MAINNET: typeof EPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET =\n\tEPOCH_4_ACTIVATION_BURN_HEIGHT_MAINNET;\n\n/**\n * Reward-cycle prepare-phase length, in burn blocks. A genesis chain\n * parameter (`/v2/pox` `prepare_cycle_length`) fixed since pox-2 and\n * unchanged by pox-5; prefer reading it from `/v2/pox` where a client is\n * available (see `eligibility.ts`), and fall back to this pinned mainnet\n * value where one isn't (an offline rollup, a CLI without a node).\n */\nexport const MAINNET_PREPARE_CYCLE_LENGTH = 100;\n\n/** Length of a paired-BTC bond, in reward cycles (`BOND_LENGTH_CYCLES`). */\nexport const BOND_LENGTH_CYCLES = 12;\n\n/** Gap between consecutive bond starts, in reward cycles (`BOND_GAP_CYCLES`). */\nexport const BOND_GAP_CYCLES = 2;\n\n/** Hard cap for STX-only stake duration, in cycles (`MAX_NUM_CYCLES`). */\nexport const MAX_NUM_CYCLES = 96;\n\n/** SIP-018 domain for signer-key grants (`POX_5_SIGNER_DOMAIN`). */\nexport const POX5_SIGNER_DOMAIN = {\n\tname: \"pox-5-signer\",\n\tversion: \"1.0.0\",\n} as const;\n\n/**\n * `serialize-c-script-num` rejects values at or above 2^39 — the ceiling of a\n * 5-byte minimally-encoded ScriptNum (`ERR_INVALID_UNLOCK_HEIGHT`).\n */\nexport const C_SCRIPT_NUM_MAX = 549_755_813_888n; // 2^39\n\n/**\n * Bitcoin treats CLTV values >= 500,000,000 as Unix timestamps (BIP-65); the\n * contract rejects unlock heights at or above this so a lockup can never\n * commit a height Bitcoin would reinterpret.\n */\nexport const BITCOIN_LOCKTIME_THRESHOLD = 500_000_000n;\n",
    "import type { Client } from \"../clients/types.ts\";\nimport { POX5_CONTRACT_NAME } from \"./constants.ts\";\n\n/**\n * Chain-reported PoX-5 activation facts, read from the node's `/v2/pox`\n * `contract_versions[]`. Present the moment nodes run stacks-core >= 4.0.0 —\n * no hardcoded heights, works on any network.\n */\nexport type Pox5Activation = {\n\t/** Fully-qualified `pox-5` contract id (boot address differs per network). */\n\tcontractId: string;\n\t/** Bitcoin block height at which Epoch 4.0 (and pox-5) activates. */\n\tactivationBurnchainBlockHeight: number;\n\t/** First reward cycle in which pox-5 governs PoX. */\n\tfirstRewardCycleId: number;\n};\n\ntype PoxInfoResponse = {\n\tcontract_id?: string;\n\tcurrent_burnchain_block_height?: number;\n\tfirst_burnchain_block_height?: number;\n\tpox_5_sbtc_contract?: string;\n\tpox_5_sbtc_registry_contract?: string;\n\tcontract_versions?: Array<{\n\t\tcontract_id: string;\n\t\tactivation_burnchain_block_height: number;\n\t\tfirst_reward_cycle_id: number;\n\t}>;\n};\n\n/**\n * `/v2/pox` fields a pox-5 integration actually needs. `sbtcContract` is\n * compiled into the boot contract per network — never hardcode it.\n */\nexport type Pox5Info = {\n\tcontractId?: string;\n\tcurrentBurnchainBlockHeight?: number;\n\tfirstBurnchainBlockHeight?: number;\n\t/** Token principal pox-5 custodies. Read this for sBTC post-conditions. */\n\tsbtcContract?: string;\n\tsbtcRegistryContract?: string;\n\tcontractVersions: Array<{\n\t\tcontractId: string;\n\t\tactivationBurnchainBlockHeight: number;\n\t\tfirstRewardCycleId: number;\n\t}>;\n};\n\nexport async function getPoxInfo(client: Client): Promise<Pox5Info> {\n\tconst info = (await client.request(\"/v2/pox\", {\n\t\tmethod: \"GET\",\n\t})) as PoxInfoResponse;\n\treturn {\n\t\tcontractId: info.contract_id,\n\t\tcurrentBurnchainBlockHeight: info.current_burnchain_block_height,\n\t\tfirstBurnchainBlockHeight: info.first_burnchain_block_height,\n\t\tsbtcContract: info.pox_5_sbtc_contract,\n\t\tsbtcRegistryContract: info.pox_5_sbtc_registry_contract,\n\t\tcontractVersions: (info.contract_versions ?? []).map((v) => ({\n\t\t\tcontractId: v.contract_id,\n\t\t\tactivationBurnchainBlockHeight: v.activation_burnchain_block_height,\n\t\t\tfirstRewardCycleId: v.first_reward_cycle_id,\n\t\t})),\n\t};\n}\n\n/**\n * Read pox-5's activation entry from the node. Returns `undefined` when the\n * node doesn't know about pox-5 yet (pre-4.0.0 node software).\n */\nexport async function getPox5Activation(\n\tclient: Client,\n): Promise<Pox5Activation | undefined> {\n\tconst info = (await client.request(\"/v2/pox\", {\n\t\tmethod: \"GET\",\n\t})) as PoxInfoResponse;\n\tconst entry = info.contract_versions?.find((v) =>\n\t\tv.contract_id.endsWith(`.${POX5_CONTRACT_NAME}`),\n\t);\n\tif (!entry) return undefined;\n\treturn {\n\t\tcontractId: entry.contract_id,\n\t\tactivationBurnchainBlockHeight: entry.activation_burnchain_block_height,\n\t\tfirstRewardCycleId: entry.first_reward_cycle_id,\n\t};\n}\n\n/**\n * Whether pox-5 is live on the node's chain: the node software knows the\n * contract AND the burnchain has reached its activation height. One request.\n */\nexport async function isPox5Active(client: Client): Promise<boolean> {\n\tconst info = (await client.request(\"/v2/pox\", {\n\t\tmethod: \"GET\",\n\t})) as PoxInfoResponse;\n\tconst entry = info.contract_versions?.find((v) =>\n\t\tv.contract_id.endsWith(`.${POX5_CONTRACT_NAME}`),\n\t);\n\tif (!entry || typeof info.current_burnchain_block_height !== \"number\")\n\t\treturn false;\n\treturn (\n\t\tinfo.current_burnchain_block_height >=\n\t\tentry.activation_burnchain_block_height\n\t);\n}\n\n/** Throw a descriptive error unless pox-5 is active on the client's chain. */\nexport async function assertPox5Active(client: Client): Promise<void> {\n\tif (!(await isPox5Active(client))) {\n\t\tthrow new Error(\n\t\t\t\"pox-5 is not active on this chain yet (Epoch 4.0 activates at Bitcoin block 960,230 on mainnet, ~2026-07-29). \" +\n\t\t\t\t\"Check getPox5Activation(client) for this network's activation height.\",\n\t\t);\n\t}\n}\n",
    "import type { ClarityValue } from \"../clarity/types.ts\";\n\n/**\n * Numeric `(err uN)` codes from pox-5. Missing numbers were never assigned\n * on-chain. Pair with {@link parsePox5Error} / {@link describePox5Error}.\n */\nexport const Pox5ErrorCode = {\n\tUnauthorized: 1,\n\tCannotSetupBondTooSoon: 2,\n\tCannotSetupBondTooLate: 3,\n\tBondAlreadySetup: 4,\n\tStakerAlreadyAdded: 5,\n\tBondNotFound: 7,\n\tInsufficientStx: 8,\n\tAlreadyRegistered: 9,\n\tTooMuchSats: 10,\n\tNotAllowlisted: 11,\n\tSignerKeyGrantUsed: 12,\n\tInvalidSignatureRecover: 13,\n\tInvalidSignaturePubkey: 14,\n\tSignerKeyGrantNotFound: 17,\n\tAlreadyStaked: 19,\n\tInvalidNumCycles: 20,\n\tSignerNotFound: 23,\n\tInvalidStartBurnHeight: 24,\n\tUnauthorizedSignerRegistration: 26,\n\tNotStaking: 27,\n\tUnstakeInPreparePhase: 28,\n\tInvalidBondPeriodOrdering: 29,\n\tDistributionAlreadyComputed: 30,\n\tBondNotActive: 31,\n\tNoClaimableRewards: 32,\n\tActiveBondNotIncluded: 33,\n\tNotBondParticipant: 34,\n\tCannotAnnounceL1EarlyUnlock: 35,\n\tInvalidOldSignerManager: 36,\n\tInvalidUnstakeSbtcAmount: 37,\n\tCannotUnstakeSbtc: 38,\n\tReadTxOutOfBounds: 39,\n\tInvalidBtcHeader: 40,\n\tInvalidMerkleProof: 41,\n\tInvalidLockupScript: 42,\n\tBondAlreadyStarted: 43,\n\tUpdateBondSameSigner: 44,\n\tInvalidLockupAmount: 45,\n\tDuplicateLockupOutpoint: 46,\n\tStakeInPreparePhase: 47,\n\tRolloverTooEarly: 48,\n\tReentrantCall: 49,\n\tL1EarlyExitAlreadyAnnounced: 50,\n\tInsufficientReserveBalance: 51,\n\tInvalidUnlockHeight: 52,\n\tRewardsPaused: 53,\n} as const;\n\nexport type Pox5ErrorCode = (typeof Pox5ErrorCode)[keyof typeof Pox5ErrorCode];\n\nexport const POX5_ERROR_NAMES: Record<Pox5ErrorCode, string> = {\n\t[Pox5ErrorCode.Unauthorized]: \"ERR_UNAUTHORIZED\",\n\t[Pox5ErrorCode.CannotSetupBondTooSoon]: \"ERR_CANNOT_SETUP_BOND_TOO_SOON\",\n\t[Pox5ErrorCode.CannotSetupBondTooLate]: \"ERR_CANNOT_SETUP_BOND_TOO_LATE\",\n\t[Pox5ErrorCode.BondAlreadySetup]: \"ERR_BOND_ALREADY_SETUP\",\n\t[Pox5ErrorCode.StakerAlreadyAdded]: \"ERR_STAKER_ALREADY_ADDED\",\n\t[Pox5ErrorCode.BondNotFound]: \"ERR_BOND_NOT_FOUND\",\n\t[Pox5ErrorCode.InsufficientStx]: \"ERR_INSUFFICIENT_STX\",\n\t[Pox5ErrorCode.AlreadyRegistered]: \"ERR_ALREADY_REGISTERED\",\n\t[Pox5ErrorCode.TooMuchSats]: \"ERR_TOO_MUCH_SATS\",\n\t[Pox5ErrorCode.NotAllowlisted]: \"ERR_NOT_ALLOWLISTED\",\n\t[Pox5ErrorCode.SignerKeyGrantUsed]: \"ERR_SIGNER_KEY_GRANT_USED\",\n\t[Pox5ErrorCode.InvalidSignatureRecover]: \"ERR_INVALID_SIGNATURE_RECOVER\",\n\t[Pox5ErrorCode.InvalidSignaturePubkey]: \"ERR_INVALID_SIGNATURE_PUBKEY\",\n\t[Pox5ErrorCode.SignerKeyGrantNotFound]: \"ERR_SIGNER_KEY_GRANT_NOT_FOUND\",\n\t[Pox5ErrorCode.AlreadyStaked]: \"ERR_ALREADY_STAKED\",\n\t[Pox5ErrorCode.InvalidNumCycles]: \"ERR_INVALID_NUM_CYCLES\",\n\t[Pox5ErrorCode.SignerNotFound]: \"ERR_SIGNER_NOT_FOUND\",\n\t[Pox5ErrorCode.InvalidStartBurnHeight]: \"ERR_INVALID_START_BURN_HEIGHT\",\n\t[Pox5ErrorCode.UnauthorizedSignerRegistration]:\n\t\t\"ERR_UNAUTHORIZED_SIGNER_REGISTRATION\",\n\t[Pox5ErrorCode.NotStaking]: \"ERR_NOT_STAKING\",\n\t[Pox5ErrorCode.UnstakeInPreparePhase]: \"ERR_UNSTAKE_IN_PREPARE_PHASE\",\n\t[Pox5ErrorCode.InvalidBondPeriodOrdering]: \"ERR_INVALID_BOND_PERIOD_ORDERING\",\n\t[Pox5ErrorCode.DistributionAlreadyComputed]:\n\t\t\"ERR_DISTRIBUTION_ALREADY_COMPUTED\",\n\t[Pox5ErrorCode.BondNotActive]: \"ERR_BOND_NOT_ACTIVE\",\n\t[Pox5ErrorCode.NoClaimableRewards]: \"ERR_NO_CLAIMABLE_REWARDS\",\n\t[Pox5ErrorCode.ActiveBondNotIncluded]: \"ERR_ACTIVE_BOND_NOT_INCLUDED\",\n\t[Pox5ErrorCode.NotBondParticipant]: \"ERR_NOT_BOND_PARTICIPANT\",\n\t[Pox5ErrorCode.CannotAnnounceL1EarlyUnlock]:\n\t\t\"ERR_CANNOT_ANNOUNCE_L1_EARLY_UNLOCK\",\n\t[Pox5ErrorCode.InvalidOldSignerManager]: \"ERR_INVALID_OLD_SIGNER_MANAGER\",\n\t[Pox5ErrorCode.InvalidUnstakeSbtcAmount]: \"ERR_INVALID_UNSTAKE_SBTC_AMOUNT\",\n\t[Pox5ErrorCode.CannotUnstakeSbtc]: \"ERR_CANNOT_UNSTAKE_SBTC\",\n\t[Pox5ErrorCode.ReadTxOutOfBounds]: \"ERR_READ_TX_OUT_OF_BOUNDS\",\n\t[Pox5ErrorCode.InvalidBtcHeader]: \"ERR_INVALID_BTC_HEADER\",\n\t[Pox5ErrorCode.InvalidMerkleProof]: \"ERR_INVALID_MERKLE_PROOF\",\n\t[Pox5ErrorCode.InvalidLockupScript]: \"ERR_INVALID_LOCKUP_SCRIPT\",\n\t[Pox5ErrorCode.BondAlreadyStarted]: \"ERR_BOND_ALREADY_STARTED\",\n\t[Pox5ErrorCode.UpdateBondSameSigner]: \"ERR_UPDATE_BOND_SAME_SIGNER\",\n\t[Pox5ErrorCode.InvalidLockupAmount]: \"ERR_INVALID_LOCKUP_AMOUNT\",\n\t[Pox5ErrorCode.DuplicateLockupOutpoint]: \"ERR_DUPLICATE_LOCKUP_OUTPOINT\",\n\t[Pox5ErrorCode.StakeInPreparePhase]: \"ERR_STAKE_IN_PREPARE_PHASE\",\n\t[Pox5ErrorCode.RolloverTooEarly]: \"ERR_ROLLOVER_TOO_EARLY\",\n\t[Pox5ErrorCode.ReentrantCall]: \"ERR_REENTRANT_CALL\",\n\t[Pox5ErrorCode.L1EarlyExitAlreadyAnnounced]:\n\t\t\"ERR_L1_EARLY_EXIT_ALREADY_ANNOUNCED\",\n\t[Pox5ErrorCode.InsufficientReserveBalance]:\n\t\t\"ERR_INSUFFICIENT_RESERVE_BALANCE\",\n\t[Pox5ErrorCode.InvalidUnlockHeight]: \"ERR_INVALID_UNLOCK_HEIGHT\",\n\t[Pox5ErrorCode.RewardsPaused]: \"ERR_REWARDS_PAUSED\",\n};\n\nconst POX5_ERROR_DESCRIPTIONS: Record<Pox5ErrorCode, string> = {\n\t[Pox5ErrorCode.Unauthorized]: \"Caller is not authorized.\",\n\t[Pox5ErrorCode.CannotSetupBondTooSoon]: \"Bond setup window has not opened.\",\n\t[Pox5ErrorCode.CannotSetupBondTooLate]: \"Bond setup window has closed.\",\n\t[Pox5ErrorCode.BondAlreadySetup]: \"This bond period is already set up.\",\n\t[Pox5ErrorCode.StakerAlreadyAdded]: \"Staker is already on this bond.\",\n\t[Pox5ErrorCode.BondNotFound]: \"No bond at this index.\",\n\t[Pox5ErrorCode.InsufficientStx]: \"Not enough STX for this operation.\",\n\t[Pox5ErrorCode.AlreadyRegistered]:\n\t\t\"Staker already has an overlapping position.\",\n\t[Pox5ErrorCode.TooMuchSats]: \"Sats amount exceeds the allowlist maximum.\",\n\t[Pox5ErrorCode.NotAllowlisted]: \"Principal is not on the bond allowlist.\",\n\t[Pox5ErrorCode.SignerKeyGrantUsed]:\n\t\t\"This signer-key grant was already consumed.\",\n\t[Pox5ErrorCode.InvalidSignatureRecover]:\n\t\t\"Could not recover a public key from the signature.\",\n\t[Pox5ErrorCode.InvalidSignaturePubkey]:\n\t\t\"Recovered public key does not match the signer key.\",\n\t[Pox5ErrorCode.SignerKeyGrantNotFound]: \"No grant found for this signer key.\",\n\t[Pox5ErrorCode.AlreadyStaked]: \"Principal already has an overlapping stake.\",\n\t[Pox5ErrorCode.InvalidNumCycles]: \"Cycle count is outside the allowed range.\",\n\t[Pox5ErrorCode.SignerNotFound]: \"No signer found for this principal.\",\n\t[Pox5ErrorCode.InvalidStartBurnHeight]:\n\t\t\"Start burn height must fall in the current reward cycle.\",\n\t[Pox5ErrorCode.UnauthorizedSignerRegistration]:\n\t\t\"Caller is not authorized to register this signer.\",\n\t[Pox5ErrorCode.NotStaking]: \"Principal is not currently staking.\",\n\t[Pox5ErrorCode.UnstakeInPreparePhase]:\n\t\t\"Unstaking is not allowed in the prepare phase.\",\n\t[Pox5ErrorCode.InvalidBondPeriodOrdering]:\n\t\t\"Bond periods were supplied out of order.\",\n\t[Pox5ErrorCode.DistributionAlreadyComputed]:\n\t\t\"Reward distribution already computed for this period.\",\n\t[Pox5ErrorCode.BondNotActive]: \"Bond is not currently active.\",\n\t[Pox5ErrorCode.NoClaimableRewards]: \"No claimable rewards for this caller.\",\n\t[Pox5ErrorCode.ActiveBondNotIncluded]:\n\t\t\"The currently active bond was not included in the list.\",\n\t[Pox5ErrorCode.NotBondParticipant]: \"Caller is not in a bond.\",\n\t[Pox5ErrorCode.CannotAnnounceL1EarlyUnlock]:\n\t\t\"Early-exit announce is not valid for this membership.\",\n\t[Pox5ErrorCode.InvalidOldSignerManager]:\n\t\t\"old-signer-manager does not match the staker's current signer.\",\n\t[Pox5ErrorCode.InvalidUnstakeSbtcAmount]: \"sBTC unstake amount is invalid.\",\n\t[Pox5ErrorCode.CannotUnstakeSbtc]: \"Bond participant did not stake sBTC.\",\n\t[Pox5ErrorCode.ReadTxOutOfBounds]: \"Lockup proof buffer was truncated.\",\n\t[Pox5ErrorCode.InvalidBtcHeader]:\n\t\t\"Bitcoin header in the lockup proof is invalid.\",\n\t[Pox5ErrorCode.InvalidMerkleProof]:\n\t\t\"Merkle proof in the lockup proof is invalid.\",\n\t[Pox5ErrorCode.InvalidLockupScript]: \"Lockup output script does not match.\",\n\t[Pox5ErrorCode.BondAlreadyStarted]:\n\t\t\"Cannot register after the bond has started.\",\n\t[Pox5ErrorCode.UpdateBondSameSigner]:\n\t\t\"update-bond-registration cannot keep the same signer.\",\n\t[Pox5ErrorCode.InvalidLockupAmount]:\n\t\t\"Lockup output amount does not match sats.\",\n\t[Pox5ErrorCode.DuplicateLockupOutpoint]:\n\t\t\"The same Bitcoin outpoint appeared twice in the lockup list.\",\n\t[Pox5ErrorCode.StakeInPreparePhase]:\n\t\t\"Cannot modify next-cycle stake during the prepare phase.\",\n\t[Pox5ErrorCode.RolloverTooEarly]: \"Bond rollover is too early.\",\n\t[Pox5ErrorCode.ReentrantCall]:\n\t\t\"Reentrant call into pox-5 while a trait call is in flight.\",\n\t[Pox5ErrorCode.L1EarlyExitAlreadyAnnounced]:\n\t\t\"L1 early exit already announced for this bond period.\",\n\t[Pox5ErrorCode.InsufficientReserveBalance]:\n\t\t\"Reserve withdrawal exceeds the balance.\",\n\t[Pox5ErrorCode.InvalidUnlockHeight]:\n\t\t\"Unlock height is below the bond minimum or at/above 500,000,000.\",\n\t[Pox5ErrorCode.RewardsPaused]: \"Signer reward claims are paused.\",\n};\n\n/** Extract `(err uN)` from a Clarity value or Hiro `repr` string. */\nexport function parsePox5Error(\n\tresult: ClarityValue | string | undefined,\n): number | undefined {\n\tif (result == null) return undefined;\n\tif (typeof result === \"string\") {\n\t\tconst match = result.trim().match(/^\\(err u(\\d+)\\)$/);\n\t\treturn match ? Number(match[1]) : undefined;\n\t}\n\tif (result.type !== \"err\") return undefined;\n\treturn result.value.type === \"uint\" ? Number(result.value.value) : undefined;\n}\n\nexport function describePox5Error(\n\tcode: number | bigint,\n): { code: number; name: string; description: string } | undefined {\n\tconst n = Number(code) as Pox5ErrorCode;\n\tconst name = POX5_ERROR_NAMES[n];\n\tif (!name) return undefined;\n\treturn { code: n, name, description: POX5_ERROR_DESCRIPTIONS[n] };\n}\n",
    "/**\n * Derive a stable machine-readable code from an error's `name` field:\n * `HttpRequestError` becomes `HTTP_REQUEST_ERROR`. `name` is a string\n * literal each class sets, so the code survives a bundler that mangles\n * class names. Branch on `code` instead of parsing `message`, which is\n * free to change.\n */\nfunction codeFromName(name: string): string {\n\treturn name\n\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1_$2\")\n\t\t.replace(/([A-Z]+)([A-Z][a-z])/g, \"$1_$2\")\n\t\t.toUpperCase();\n}\n\nexport class BaseError extends Error {\n\toverride name = \"StacksError\";\n\t#code?: string;\n\tshortMessage: string;\n\tdetails?: string;\n\n\tconstructor(\n\t\tshortMessage: string,\n\t\toptions?: { cause?: Error; details?: string; code?: string },\n\t) {\n\t\tconst message = [\n\t\t\tshortMessage,\n\t\t\toptions?.details ? `\\n${options.details}` : \"\",\n\t\t].join(\"\");\n\n\t\tsuper(message, { cause: options?.cause });\n\t\tif (options?.code !== undefined) this.#code = options.code;\n\t\tthis.shortMessage = shortMessage;\n\t\tthis.details = options?.details;\n\t}\n\n\t/**\n\t * Stable identifier for programmatic handling; survives message\n\t * rewording and minification. An explicit `code` option wins, else it\n\t * is derived from `name` (`TimeoutError` gives `TIMEOUT_ERROR`).\n\t */\n\tget code(): string {\n\t\treturn this.#code ?? codeFromName(this.name);\n\t}\n\n\tset code(value: string) {\n\t\tthis.#code = value;\n\t}\n\n\ttoJSON(): {\n\t\tname: string;\n\t\tcode: string;\n\t\tmessage: string;\n\t\tshortMessage: string;\n\t\tdetails: string | undefined;\n\t\tcause: string | undefined;\n\t} {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tcode: this.code,\n\t\t\tmessage: this.message,\n\t\t\tshortMessage: this.shortMessage,\n\t\t\tdetails: this.details,\n\t\t\tcause: this.cause instanceof Error ? this.cause.message : undefined,\n\t\t};\n\t}\n}\n",
    "import { BaseError } from \"./base.ts\";\n\n/** Thrown when a node/API response is missing an expected field. */\nexport class MalformedResponseError extends BaseError {\n\toverride name = \"MalformedResponseError\";\n}\n\n/** Thrown when `/v2/contracts/call-read` answers `okay: false`. */\nexport class ReadContractError extends BaseError {\n\toverride name = \"ReadContractError\";\n}\n",
    "import type { Client } from \"../../clients/types.ts\";\nimport { MalformedResponseError } from \"../../errors/response.ts\";\n\nexport type GetBalanceParams = {\n\taddress: string;\n};\n\nexport async function getBalance(\n\tclient: Client,\n\tparams: GetBalanceParams,\n): Promise<bigint> {\n\tconst data = await client.request(\n\t\t`/v2/accounts/${encodeURIComponent(params.address)}`,\n\t\t{\n\t\t\tmethod: \"GET\",\n\t\t},\n\t);\n\tconst balance = (data as { balance?: unknown })?.balance;\n\tif (typeof balance !== \"string\" && typeof balance !== \"number\") {\n\t\tthrow new MalformedResponseError(\n\t\t\t`getBalance: /v2/accounts/${params.address} response is missing \"balance\"`,\n\t\t);\n\t}\n\treturn BigInt(balance);\n}\n",
    "import { BaseError } from \"./base.ts\";\n\nexport class TransactionError extends BaseError {\n\toverride name = \"TransactionError\";\n}\n\n/**\n * Rejection reasons a stacks-node returns from `POST /v2/transactions`.\n * Wire strings from stacks-core `MemPoolRejection::into_json`\n * (`stackslib/src/chainstate/stacks/db/blocks.rs`).\n */\nexport type TxRejectionReason =\n\t| \"Serialization\"\n\t| \"Deserialization\"\n\t| \"SignatureValidation\"\n\t| \"BadNonce\"\n\t| \"ConflictingNonceInMempool\"\n\t| \"TooMuchChaining\"\n\t| \"FeeTooLow\"\n\t| \"NotEnoughFunds\"\n\t| \"NoSuchContract\"\n\t| \"NoSuchPublicFunction\"\n\t| \"BadFunctionArgument\"\n\t| \"ContractAlreadyExists\"\n\t| \"BadTransactionVersion\"\n\t| \"TransferRecipientCannotEqualSender\"\n\t| \"TransferAmountMustBePositive\"\n\t| \"PoisonMicroblocksDoNotConflict\"\n\t| \"PoisonMicroblockHasUnknownPubKeyHash\"\n\t| \"PoisonMicroblockIsInvalid\"\n\t| \"BadAddressVersionByte\"\n\t| \"NoCoinbaseViaMempool\"\n\t| \"NoTenureChangeViaMempool\"\n\t| \"EstimatorError\"\n\t| \"TemporarilyBlacklisted\"\n\t| \"ServerFailureNoSuchChainTip\"\n\t| \"ServerFailureDatabase\"\n\t| \"ServerFailureOther\";\n\nexport class BroadcastError extends BaseError {\n\toverride name = \"BroadcastError\";\n\ttxid?: string;\n\t// `(string & {})` keeps forward-compat with reasons newer nodes may add\n\t// while preserving literal-union completions.\n\treason?: TxRejectionReason | (string & {});\n\t/** Node-provided detail; shape varies per reason (see stacks-core RPC docs). */\n\treasonData?: unknown;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions?: {\n\t\t\tcause?: Error;\n\t\t\ttxid?: string;\n\t\t\treason?: string;\n\t\t\treasonData?: unknown;\n\t\t},\n\t) {\n\t\tsuper(message, options);\n\t\tthis.txid = options?.txid;\n\t\tthis.reason = options?.reason;\n\t\tthis.reasonData = options?.reasonData;\n\t}\n}\n\n/** The transaction was mined but its execution aborted (runtime error or failed post-condition). */\nexport class TransactionAbortedError extends BaseError {\n\toverride name = \"TransactionAbortedError\";\n\t/** The abort receipt (status, block info, raw source response). */\n\treceipt: unknown;\n\n\tconstructor(message: string, options: { receipt: unknown; cause?: Error }) {\n\t\tsuper(message, options);\n\t\tthis.receipt = options.receipt;\n\t}\n}\n\n/** The transaction left the mempool without being mined (dropped/replaced). */\nexport class TransactionDroppedError extends BaseError {\n\toverride name = \"TransactionDroppedError\";\n\ttxid: string;\n\n\tconstructor(message: string, options: { txid: string; cause?: Error }) {\n\t\tsuper(message, options);\n\t\tthis.txid = options.txid;\n\t}\n}\n\n/** waitForTransactionReceipt gave up before the tx reached the requested state. */\nexport class WaitForTransactionTimeoutError extends BaseError {\n\toverride name = \"WaitForTransactionTimeoutError\";\n\ttxid: string;\n\n\tconstructor(message: string, options: { txid: string; cause?: Error }) {\n\t\tsuper(message, options);\n\t\tthis.txid = options.txid;\n\t}\n}\n\nexport class SerializationError extends BaseError {\n\toverride name = \"SerializationError\";\n}\n\nexport class SigningError extends BaseError {\n\toverride name = \"SigningError\";\n}\n",
    "const hexes = Array.from({ length: 256 }, (_, i) =>\n\ti.toString(16).padStart(2, \"0\"),\n);\n\nexport function bytesToHex(bytes: Uint8Array): string {\n\tlet hex = \"\";\n\tfor (const b of bytes) {\n\t\thex += hexes[b];\n\t}\n\treturn hex;\n}\n\nexport function hexToBytes(hex: string): Uint8Array {\n\tlet h = without0x(hex);\n\tif (h.length % 2) h = `0${h}`;\n\n\tconst array = new Uint8Array(h.length / 2);\n\tfor (let i = 0; i < array.length; i++) {\n\t\tconst j = i * 2;\n\t\tconst byte = Number.parseInt(h.slice(j, j + 2), 16);\n\t\tif (Number.isNaN(byte) || byte < 0)\n\t\t\tthrow new Error(\"Invalid byte sequence\");\n\t\tarray[i] = byte;\n\t}\n\treturn array;\n}\n\nexport function with0x(value: string): string {\n\treturn /^0x/i.test(value) ? value : `0x${value}`;\n}\n\nexport function without0x(value: string): string {\n\treturn /^0x/i.test(value) ? value.slice(2) : value;\n}\n\nexport function utf8ToBytes(str: string): Uint8Array {\n\treturn new TextEncoder().encode(str);\n}\n\nexport function bytesToUtf8(bytes: Uint8Array): string {\n\treturn new TextDecoder().decode(bytes);\n}\n\nexport function asciiToBytes(str: string): Uint8Array {\n\tconst bytes = new Uint8Array(str.length);\n\tfor (let i = 0; i < str.length; i++) {\n\t\tbytes[i] = str.charCodeAt(i) & 0xff;\n\t}\n\treturn bytes;\n}\n\nexport function bytesToAscii(bytes: Uint8Array): string {\n\treturn String.fromCharCode(...bytes);\n}\n\nexport function concatBytes(...arrays: Uint8Array[]): Uint8Array {\n\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\tif (arrays.length === 1) return arrays[0]!;\n\tconst length = arrays.reduce((a, arr) => a + arr.length, 0);\n\tconst result = new Uint8Array(length);\n\tlet pad = 0;\n\tfor (const arr of arrays) {\n\t\tresult.set(arr, pad);\n\t\tpad += arr.length;\n\t}\n\treturn result;\n}\n\nexport type IntegerType = number | string | bigint | Uint8Array;\n\nexport function intToBigInt(value: IntegerType): bigint {\n\tif (typeof value === \"bigint\") return value;\n\tif (typeof value === \"string\") return BigInt(value);\n\tif (typeof value === \"number\") {\n\t\tif (!Number.isInteger(value))\n\t\t\tthrow new RangeError(\"Values of type 'number' must be an integer.\");\n\t\tif (value > Number.MAX_SAFE_INTEGER)\n\t\t\tthrow new RangeError(\n\t\t\t\t`Values of type 'number' must be <= ${Number.MAX_SAFE_INTEGER}. Use BigInt instead.`,\n\t\t\t);\n\t\treturn BigInt(value);\n\t}\n\tif (value instanceof Uint8Array) return BigInt(`0x${bytesToHex(value)}`);\n\tthrow new TypeError(\"Must be a number, bigint, string, or Uint8Array.\");\n}\n\nexport function intToBytes(value: IntegerType, byteLength: number): Uint8Array {\n\treturn bigIntToBytes(intToBigInt(value), byteLength);\n}\n\nexport function bigIntToBytes(value: bigint, length = 16): Uint8Array {\n\tconst hex = value.toString(16).padStart(length * 2, \"0\");\n\treturn hexToBytes(hex);\n}\n\nexport function intToHex(integer: IntegerType, byteLength = 8): string {\n\tconst value = typeof integer === \"bigint\" ? integer : intToBigInt(integer);\n\treturn value.toString(16).padStart(byteLength * 2, \"0\");\n}\n\nexport function toTwos(value: bigint, width: bigint): bigint {\n\tconst limit = BigInt(1) << (width - BigInt(1));\n\tif (value < -limit || value > limit - BigInt(1)) {\n\t\tthrow new Error(`Unable to represent integer in width: ${width}`);\n\t}\n\tif (value >= BigInt(0)) return value;\n\treturn value + (BigInt(1) << width);\n}\n\nexport function fromTwos(value: bigint, width: bigint): bigint {\n\tif (value & (BigInt(1) << (width - BigInt(1)))) {\n\t\treturn value - (BigInt(1) << width);\n\t}\n\treturn value;\n}\n\nexport function bytesToTwosBigInt(bytes: Uint8Array): bigint {\n\tif (bytes.length === 0) return 0n;\n\tconst hex = bytesToHex(bytes);\n\tif (hex.length === 0) return 0n;\n\treturn fromTwos(BigInt(`0x${hex}`), BigInt(bytes.byteLength * 8));\n}\n\nexport function writeUInt32BE(value: number): Uint8Array {\n\tconst buf = new Uint8Array(4);\n\tbuf[0] = (value >>> 24) & 0xff;\n\tbuf[1] = (value >>> 16) & 0xff;\n\tbuf[2] = (value >>> 8) & 0xff;\n\tbuf[3] = value & 0xff;\n\treturn buf;\n}\n\nexport function readUInt32BE(bytes: Uint8Array, offset = 0): number {\n\treturn (\n\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t((bytes[offset]! << 24) |\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t\t(bytes[offset + 1]! << 16) |\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t\t(bytes[offset + 2]! << 8) |\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t\tbytes[offset + 3]!) >>>\n\t\t0\n\t);\n}\n\nexport function writeUInt16BE(value: number): Uint8Array {\n\tconst buf = new Uint8Array(2);\n\tbuf[0] = (value >>> 8) & 0xff;\n\tbuf[1] = value & 0xff;\n\treturn buf;\n}\n\nexport function readUInt16BE(bytes: Uint8Array, offset = 0): number {\n\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\treturn ((bytes[offset]! << 8) | bytes[offset + 1]!) >>> 0;\n}\n\nexport function writeUInt8(value: number): Uint8Array {\n\treturn new Uint8Array([value & 0xff]);\n}\n",
    "import { SerializationError } from \"../errors/transaction.ts\";\nimport { bytesToHex } from \"./encoding.ts\";\n\nexport class BytesReader {\n\tprivate data: Uint8Array;\n\tpublic offset = 0;\n\n\tconstructor(data: Uint8Array) {\n\t\tthis.data = data;\n\t}\n\n\t/** Bytes left after the cursor. */\n\tremaining(): number {\n\t\treturn this.data.length - this.offset;\n\t}\n\n\tprivate ensure(length: number): void {\n\t\tif (this.offset + length > this.data.length) {\n\t\t\tthrow new SerializationError(\n\t\t\t\t`Buffer underflow: need ${length} bytes at offset ${this.offset}, have ${this.data.length}`,\n\t\t\t);\n\t\t}\n\t}\n\n\treadUInt8(): number {\n\t\tthis.ensure(1);\n\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\treturn this.data[this.offset++]!;\n\t}\n\n\treadUInt16BE(): number {\n\t\tthis.ensure(2);\n\t\tconst val =\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\t\t((this.data[this.offset]! << 8) | this.data[this.offset + 1]!) >>> 0;\n\t\tthis.offset += 2;\n\t\treturn val;\n\t}\n\n\treadUInt32BE(): number {\n\t\tthis.ensure(4);\n\t\tconst val =\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\t\t((this.data[this.offset]! << 24) |\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\t\t\t(this.data[this.offset + 1]! << 16) |\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\t\t\t(this.data[this.offset + 2]! << 8) |\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: bounds checked by ensure()\n\t\t\t\tthis.data[this.offset + 3]!) >>>\n\t\t\t0;\n\t\tthis.offset += 4;\n\t\treturn val;\n\t}\n\n\treadBytes(length: number): Uint8Array {\n\t\tthis.ensure(length);\n\t\tconst slice = this.data.slice(this.offset, this.offset + length);\n\t\tthis.offset += length;\n\t\treturn slice;\n\t}\n\n\treadBigUInt64BE(): bigint {\n\t\tconst hex = bytesToHex(this.readBytes(8));\n\t\treturn hex.length > 0 ? BigInt(`0x${hex}`) : 0n;\n\t}\n}\n",
    "import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { bytesToHex, hexToBytes } from \"./encoding.ts\";\n\nconst C32 = \"0123456789ABCDEFGHJKMNPQRSTVWXYZ\";\nconst HEX = \"0123456789abcdef\";\n\nfunction c32normalize(input: string): string {\n\treturn input.toUpperCase().replace(/O/g, \"0\").replace(/L|I/g, \"1\");\n}\n\nfunction c32encode(inputHex: string): string {\n\tlet hex = inputHex;\n\tif (hex.length % 2 !== 0) hex = `0${hex}`;\n\thex = hex.toLowerCase();\n\n\tconst res: string[] = [];\n\tlet carry = 0;\n\tfor (let i = hex.length - 1; i >= 0; i--) {\n\t\tif (carry < 4) {\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t\tconst currentCode = HEX.indexOf(hex[i]!) >> carry;\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t\tconst nextCode = i !== 0 ? HEX.indexOf(hex[i - 1]!) : 0;\n\t\t\tconst nextBits = 1 + carry;\n\t\t\tconst nextLowBits = (nextCode % (1 << nextBits)) << (5 - nextBits);\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t\tres.unshift(C32[currentCode + nextLowBits]!);\n\t\t\tcarry = nextBits;\n\t\t} else {\n\t\t\tcarry = 0;\n\t\t}\n\t}\n\n\t// Strip leading c32 zeros\n\tlet leadingZeros = 0;\n\twhile (leadingZeros < res.length && res[leadingZeros] === \"0\") leadingZeros++;\n\tconst stripped = res.slice(leadingZeros);\n\n\t// Preserve leading zero bytes from hex\n\tconst bytes = hexToBytes(hex);\n\tlet zeroBytesCount = 0;\n\twhile (zeroBytesCount < bytes.length && bytes[zeroBytesCount] === 0)\n\t\tzeroBytesCount++;\n\tconst prefix = Array(zeroBytesCount).fill(C32[0]) as string[];\n\n\treturn [...prefix, ...stripped].join(\"\");\n}\n\nfunction c32decode(c32input: string): string {\n\tconst input = c32normalize(c32input);\n\tif (!input.match(`^[${C32}]*$`)) throw new Error(\"Not a c32-encoded string\");\n\n\tconst zeroPrefix = input.match(`^${C32[0]}*`);\n\tconst numLeadingZeroBytes = zeroPrefix ? zeroPrefix[0]?.length : 0;\n\n\tconst res: string[] = [];\n\tlet carry = 0;\n\tlet carryBits = 0;\n\tfor (let i = input.length - 1; i >= 0; i--) {\n\t\tif (carryBits === 4) {\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\t\tres.unshift(HEX[carry]!);\n\t\t\tcarryBits = 0;\n\t\t\tcarry = 0;\n\t\t}\n\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\tconst currentValue = (C32.indexOf(input[i]!) << carryBits) + carry;\n\t\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\t\tres.unshift(HEX[currentValue % 16]!);\n\t\tcarryBits += 1;\n\t\tcarry = currentValue >> 4;\n\t\tif (carry > 1 << carryBits) throw new Error(\"Panic error in c32 decoding\");\n\t}\n\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\tres.unshift(HEX[carry]!);\n\n\tif (res.length % 2 === 1) res.unshift(\"0\");\n\n\t// Strip leading hex zeros\n\tlet hexLeadingZeros = 0;\n\twhile (hexLeadingZeros < res.length && res[hexLeadingZeros] === \"0\")\n\t\thexLeadingZeros++;\n\tlet hexStr = res.slice(hexLeadingZeros - (hexLeadingZeros % 2)).join(\"\");\n\n\tfor (let i = 0; i < numLeadingZeroBytes; i++) hexStr = `00${hexStr}`;\n\n\treturn hexStr;\n}\n\nfunction c32checksum(dataHex: string): string {\n\treturn bytesToHex(sha256(sha256(hexToBytes(dataHex))).slice(0, 4));\n}\n\nfunction c32checkEncode(version: number, data: string): string {\n\tif (version < 0 || version >= 32)\n\t\tthrow new Error(\"Invalid version (must be between 0 and 31)\");\n\tif (!data.match(/^[0-9a-fA-F]*$/))\n\t\tthrow new Error(\"Invalid data (not a hex string)\");\n\n\tlet d = data.toLowerCase();\n\tif (d.length % 2 !== 0) d = `0${d}`;\n\n\tlet versionHex = version.toString(16);\n\tif (versionHex.length === 1) versionHex = `0${versionHex}`;\n\n\tconst checksumHex = c32checksum(`${versionHex}${d}`);\n\treturn `${C32[version]}${c32encode(`${d}${checksumHex}`)}`;\n}\n\nfunction c32checkDecode(c32data: string): [number, string] {\n\tconst normalized = c32normalize(c32data);\n\tconst dataHex = c32decode(normalized.slice(1));\n\t// biome-ignore lint/style/noNonNullAssertion: bit-encoding routine where index is provably bounded by surrounding loop/length checks\n\tconst version = C32.indexOf(normalized[0]!);\n\tconst checksum = dataHex.slice(-8);\n\n\tlet versionHex = version.toString(16);\n\tif (versionHex.length === 1) versionHex = `0${versionHex}`;\n\n\tif (\n\t\tc32checksum(`${versionHex}${dataHex.substring(0, dataHex.length - 8)}`) !==\n\t\tchecksum\n\t) {\n\t\tthrow new Error(\"Invalid c32check string: checksum mismatch\");\n\t}\n\n\treturn [version, dataHex.substring(0, dataHex.length - 8)];\n}\n\nexport function c32address(version: number, hash160hex: string): string {\n\tif (!hash160hex.match(/^[0-9a-fA-F]{40}$/)) {\n\t\tthrow new Error(\"Invalid argument: not a hash160 hex string\");\n\t}\n\treturn `S${c32checkEncode(version, hash160hex)}`;\n}\n\nexport function c32addressDecode(c32addr: string): [number, string] {\n\tif (c32addr.length <= 5)\n\t\tthrow new Error(\"Invalid c32 address: invalid length\");\n\tif (c32addr[0] !== \"S\")\n\t\tthrow new Error('Invalid c32 address: must start with \"S\"');\n\treturn c32checkDecode(c32addr.slice(1));\n}\n",
    "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",
    "// Clarity integer bounds\nexport const MAX_U128: bigint = (1n << 128n) - 1n;\nexport const MAX_I128: bigint = (1n << 127n) - 1n;\nexport const MIN_I128: bigint = -(1n << 127n);\n\n/** C32-encoded address version bytes for single-sig and multi-sig on each network. */\nexport const AddressVersion = {\n\tMainnetSingleSig: 22,\n\tMainnetMultiSig: 20,\n\tTestnetSingleSig: 26,\n\tTestnetMultiSig: 21,\n} as const;\nexport type AddressVersion =\n\t(typeof AddressVersion)[keyof typeof AddressVersion];\n\n/** Mainnet burn address (all-zero hash160). */\nexport const ZERO_ADDRESS = \"SP000000000000000000002Q6VF78\";\n/** Testnet burn address (all-zero hash160). */\nexport const TESTNET_ZERO_ADDRESS = \"ST000000000000000000002AMW42H\";\n\n/** Number of microSTX per 1 STX (10^6). */\nexport const MICROSTX_PER_STX = 1_000_000n;\n",
    "import { ripemd160 } from \"@noble/hashes/legacy.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport { sha512_256 } from \"@noble/hashes/sha2.js\";\nimport { bytesToHex } from \"./encoding.ts\";\n\nexport { sha256, sha512_256, ripemd160 };\n\n/** RIPEMD160(SHA256(input)) — standard Bitcoin/Stacks address hash */\nexport function hash160(input: Uint8Array): Uint8Array {\n\treturn ripemd160(sha256(input));\n}\n\n/** Hash used for transaction IDs */\nexport function txidFromBytes(data: Uint8Array): string {\n\treturn bytesToHex(sha512_256(data));\n}\n\n/** hash160 as hex — used for P2PKH address derivation */\nexport function hashP2PKH(input: Uint8Array): string {\n\treturn bytesToHex(hash160(input));\n}\n",
    "import { c32address, c32addressDecode } from \"./c32.ts\";\nimport { AddressVersion } from \"./constants.ts\";\nimport { bytesToHex, hexToBytes, without0x } from \"./encoding.ts\";\nimport { hash160 } from \"./hash.ts\";\n\nexport { c32address, c32addressDecode };\n\n/**\n * Derive the single-sig Stacks address for a compressed public key.\n */\nexport function publicKeyToAddress(\n\tpublicKey: string | Uint8Array,\n\tnetwork: \"mainnet\" | \"testnet\" = \"mainnet\",\n): string {\n\tconst bytes =\n\t\ttypeof publicKey === \"string\"\n\t\t\t? hexToBytes(without0x(publicKey))\n\t\t\t: publicKey;\n\tconst version =\n\t\tnetwork === \"mainnet\"\n\t\t\t? AddressVersion.MainnetSingleSig\n\t\t\t: AddressVersion.TestnetSingleSig;\n\treturn c32address(version, bytesToHex(hash160(bytes)));\n}\n\n/** Clarity contract-name grammar: leading letter, then letters/digits/`-`/`_`.\n *  Underscore is legal (SIP-002) and deployed contracts use it — matches the\n *  pattern the Index API already accepts for contract ids. */\nexport const CONTRACT_NAME_REGEX: RegExp = /^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/;\n\nexport function validateStacksAddress(address: string): boolean {\n\ttry {\n\t\tc32addressDecode(address);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** Alias for validateStacksAddress — matches future.md naming. */\nexport const isValidAddress: (address: string) => boolean =\n\tvalidateStacksAddress;\n\n/** Parse a principal into its parts, or null when malformed. The single\n *  definition of \"valid principal\" for this package: exactly one optional\n *  `.name` segment (never two), a c32-decodable address, and a contract name\n *  matching the Clarity grammar. */\nexport function parsePrincipal(\n\tvalue: string,\n): { address: string; contractName?: string } | null {\n\tconst parts = value.split(\".\");\n\tif (parts.length > 2) return null;\n\tconst [address, contractName] = parts as [string, string | undefined];\n\tif (!validateStacksAddress(address)) return null;\n\tif (contractName === undefined) return { address };\n\tif (!CONTRACT_NAME_REGEX.test(contractName)) return null;\n\treturn { address, contractName };\n}\n\n/** Split `address.name` into its parts. Throws on anything `parsePrincipal`\n *  rejects, and on a bare address with no contract name. */\nexport function parseContractId(contractId: string): [string, string] {\n\tconst parsed = parsePrincipal(contractId);\n\tif (!parsed?.contractName)\n\t\tthrow new Error(`Invalid contract identifier: ${contractId}`);\n\treturn [parsed.address, parsed.contractName];\n}\n\nexport function isClarityName(name: string): boolean {\n\tconst regex = /^[a-zA-Z]([a-zA-Z0-9]|[-_!?+<>=/*])*$|^[-+=/*]$|^[<>]=?$/;\n\treturn regex.test(name) && name.length < 128;\n}\n\n/**\n * Compare two Stacks addresses for equality (case-insensitive, version-aware).\n * Throws if either address is invalid.\n */\nexport function isAddressEqual(a: string, b: string): boolean {\n\tconst [versionA, hashA] = c32addressDecode(a);\n\tconst [versionB, hashB] = c32addressDecode(b);\n\treturn versionA === versionB && hashA.toLowerCase() === hashB.toLowerCase();\n}\n\n/** Extract the version byte from a Stacks address (22, 20, 26, or 21). */\nexport function addressToVersion(address: string): number {\n\treturn c32addressDecode(address)[0];\n}\n\n/**\n * Build a contract address from deployer + contract name.\n * Validates both parts; returns `deployer.contractName`.\n */\nexport function getContractAddress(\n\tdeployer: string,\n\tcontractName: string,\n): string {\n\tif (!validateStacksAddress(deployer)) {\n\t\tthrow new Error(`Invalid deployer address: ${deployer}`);\n\t}\n\tif (!isClarityName(contractName)) {\n\t\tthrow new Error(`Invalid contract name: ${contractName}`);\n\t}\n\treturn `${deployer}.${contractName}`;\n}\n",
    "import { c32addressDecode } from \"../utils/c32.ts\";\nimport {\n\tasciiToBytes,\n\tbigIntToBytes,\n\tbytesToHex,\n\tconcatBytes,\n\thexToBytes,\n\tintToHex,\n\ttoTwos,\n\tutf8ToBytes,\n\twriteUInt32BE,\n} from \"../utils/encoding.ts\";\nimport {\n\ttype ClarityType,\n\ttype ClarityValue,\n\tClarityWireType,\n} from \"./types.ts\";\n\nconst CLARITY_INT_SIZE = 128n;\nconst CLARITY_INT_BYTE_SIZE = 16;\n\nfunction typeIdByte(type: ClarityType): number {\n\treturn ClarityWireType[type];\n}\n\nfunction withTypeId(type: ClarityType, bytes: Uint8Array): Uint8Array {\n\treturn concatBytes(new Uint8Array([typeIdByte(type)]), bytes);\n}\n\nfunction serializeAddress(c32Address: string): Uint8Array {\n\tconst [version, hash160] = c32addressDecode(c32Address);\n\treturn concatBytes(new Uint8Array([version]), hexToBytes(hash160));\n}\n\nfunction serializeLPString(str: string, prefixBytes = 1): Uint8Array {\n\tconst content = utf8ToBytes(str);\n\tconst lengthPrefix = hexToBytes(intToHex(content.byteLength, prefixBytes));\n\treturn concatBytes(lengthPrefix, content);\n}\n\nexport function serializeCVBytes(value: ClarityValue): Uint8Array {\n\tswitch (value.type) {\n\t\tcase \"true\":\n\t\tcase \"false\":\n\t\t\treturn new Uint8Array([typeIdByte(value.type)]);\n\n\t\tcase \"int\": {\n\t\t\tconst bytes = bigIntToBytes(\n\t\t\t\ttoTwos(BigInt(value.value), CLARITY_INT_SIZE),\n\t\t\t\tCLARITY_INT_BYTE_SIZE,\n\t\t\t);\n\t\t\treturn withTypeId(value.type, bytes);\n\t\t}\n\n\t\tcase \"uint\": {\n\t\t\tconst bytes = bigIntToBytes(BigInt(value.value), CLARITY_INT_BYTE_SIZE);\n\t\t\treturn withTypeId(value.type, bytes);\n\t\t}\n\n\t\tcase \"buffer\": {\n\t\t\tconst bufBytes = hexToBytes(value.value);\n\t\t\treturn withTypeId(\n\t\t\t\tvalue.type,\n\t\t\t\tconcatBytes(writeUInt32BE(bufBytes.length), bufBytes),\n\t\t\t);\n\t\t}\n\n\t\tcase \"none\":\n\t\t\treturn new Uint8Array([typeIdByte(value.type)]);\n\n\t\tcase \"some\":\n\t\t\treturn withTypeId(value.type, serializeCVBytes(value.value));\n\n\t\tcase \"ok\":\n\t\tcase \"err\":\n\t\t\treturn withTypeId(value.type, serializeCVBytes(value.value));\n\n\t\tcase \"address\":\n\t\t\treturn withTypeId(value.type, serializeAddress(value.value));\n\n\t\tcase \"contract\": {\n\t\t\tconst [addr, name] = value.value.split(\".\");\n\t\t\tif (!addr || !name)\n\t\t\t\tthrow new Error(`Invalid contract principal: ${value.value}`);\n\t\t\treturn withTypeId(\n\t\t\t\tvalue.type,\n\t\t\t\tconcatBytes(serializeAddress(addr), serializeLPString(name)),\n\t\t\t);\n\t\t}\n\n\t\tcase \"list\": {\n\t\t\tconst parts: Uint8Array[] = [writeUInt32BE(value.value.length)];\n\t\t\tfor (const item of value.value) {\n\t\t\t\tparts.push(serializeCVBytes(item));\n\t\t\t}\n\t\t\treturn withTypeId(value.type, concatBytes(...parts));\n\t\t}\n\n\t\tcase \"tuple\": {\n\t\t\t// Clarity orders tuple fields as a BTreeMap over the raw name bytes.\n\t\t\t// Code-unit comparison equals byte order for the ASCII name grammar;\n\t\t\t// localeCompare does not, and would change the SIP-018 hash.\n\t\t\tconst keys = Object.keys(value.value).sort((a, b) =>\n\t\t\t\ta < b ? -1 : a > b ? 1 : 0,\n\t\t\t);\n\t\t\tconst parts: Uint8Array[] = [writeUInt32BE(keys.length)];\n\t\t\tfor (const key of keys) {\n\t\t\t\tparts.push(serializeLPString(key));\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\t\tparts.push(serializeCVBytes(value.value[key]!));\n\t\t\t}\n\t\t\treturn withTypeId(value.type, concatBytes(...parts));\n\t\t}\n\n\t\tcase \"ascii\": {\n\t\t\tconst strBytes = asciiToBytes(value.value);\n\t\t\treturn withTypeId(\n\t\t\t\tvalue.type,\n\t\t\t\tconcatBytes(writeUInt32BE(strBytes.length), strBytes),\n\t\t\t);\n\t\t}\n\n\t\tcase \"utf8\": {\n\t\t\tconst strBytes = utf8ToBytes(value.value);\n\t\t\treturn withTypeId(\n\t\t\t\tvalue.type,\n\t\t\t\tconcatBytes(writeUInt32BE(strBytes.length), strBytes),\n\t\t\t);\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new Error(\"Cannot serialize unknown clarity type\");\n\t}\n}\n\nexport function serializeCV(value: ClarityValue): string {\n\treturn bytesToHex(serializeCVBytes(value));\n}\n",
    "import { isClarityName, parsePrincipal } from \"../utils/address.ts\";\nimport { c32address, c32addressDecode } from \"../utils/c32.ts\";\nimport {\n\ttype IntegerType,\n\tasciiToBytes,\n\tbytesToHex,\n\tbytesToTwosBigInt,\n\thexToBytes,\n\tintToBigInt,\n\tutf8ToBytes,\n} from \"../utils/encoding.ts\";\nimport { deserializeCVBytes } from \"./deserialize.ts\";\nimport { serializeCVBytes } from \"./serialize.ts\";\nimport type {\n\tBooleanCV,\n\tBufferCV,\n\tClarityValue,\n\tContractPrincipalCV,\n\tFalseCV,\n\tIntCV,\n\tListCV,\n\tNoneCV,\n\tResponseErrorCV,\n\tResponseOkCV,\n\tSomeCV,\n\tStandardPrincipalCV,\n\tStringAsciiCV,\n\tStringUtf8CV,\n\tTrueCV,\n\tTupleCV,\n\tTupleData,\n\tUIntCV,\n} from \"./types.ts\";\n\nconst MAX_U128 = BigInt(\"0xffffffffffffffffffffffffffffffff\");\nconst MIN_I128 = BigInt(\"-170141183460469231731687303715884105728\");\nconst MAX_I128 = BigInt(\"0x7fffffffffffffffffffffffffffffff\");\n\n// Primitives\n\nexport function intCV(value: IntegerType): IntCV {\n\tlet v: IntegerType = value;\n\tif (typeof v === \"string\" && v.toLowerCase().startsWith(\"0x\")) {\n\t\tv = bytesToTwosBigInt(hexToBytes(v));\n\t}\n\tif (v instanceof Uint8Array) v = bytesToTwosBigInt(v);\n\tconst n = intToBigInt(v);\n\tif (n > MAX_I128) throw new RangeError(`Int exceeds max i128: ${MAX_I128}`);\n\tif (n < MIN_I128) throw new RangeError(`Int below min i128: ${MIN_I128}`);\n\treturn { type: \"int\", value: n };\n}\n\nexport function uintCV(value: IntegerType): UIntCV {\n\tconst n = intToBigInt(value);\n\tif (n < 0n)\n\t\tthrow new RangeError(\"Cannot construct unsigned int from negative value\");\n\tif (n > MAX_U128) throw new RangeError(`UInt exceeds max u128: ${MAX_U128}`);\n\treturn { type: \"uint\", value: n };\n}\n\nexport const trueCV = (): TrueCV => ({ type: \"true\" });\nexport const falseCV = (): FalseCV => ({ type: \"false\" });\nexport const boolCV = (v: boolean): BooleanCV => (v ? trueCV() : falseCV());\n\nexport function bufferCV(buffer: Uint8Array): BufferCV {\n\tif (buffer.byteLength > 1_048_576) {\n\t\tthrow new Error(\"Buffer exceeds max size of 1MB\");\n\t}\n\treturn { type: \"buffer\", value: bytesToHex(buffer) };\n}\n\nexport function standardPrincipalCV(address: string): StandardPrincipalCV {\n\t// Validate by decoding\n\tconst [version, hash160] = c32addressDecode(address);\n\tconst normalized = c32address(version, hash160);\n\treturn { type: \"address\", value: normalized };\n}\n\nexport function contractPrincipalCV(\n\taddress: string,\n\tcontractName: string,\n): ContractPrincipalCV {\n\tconst [version, hash160] = c32addressDecode(address);\n\tconst normalized = c32address(version, hash160);\n\tif (utf8ToBytes(contractName).byteLength >= 128) {\n\t\tthrow new Error(\"Contract name must be less than 128 bytes\");\n\t}\n\treturn { type: \"contract\", value: `${normalized}.${contractName}` };\n}\n\nexport function noneCV(): NoneCV {\n\treturn { type: \"none\" };\n}\n\nexport function someCV(value: ClarityValue): SomeCV {\n\treturn { type: \"some\", value };\n}\n\nexport function responseOkCV(value: ClarityValue): ResponseOkCV {\n\treturn { type: \"ok\", value };\n}\n\nexport function responseErrorCV(value: ClarityValue): ResponseErrorCV {\n\treturn { type: \"err\", value };\n}\n\nexport function listCV(values: ClarityValue[]): ListCV {\n\treturn { type: \"list\", value: values };\n}\n\nexport function tupleCV(data: TupleData): TupleCV {\n\tfor (const key in data) {\n\t\tif (!isClarityName(key)) {\n\t\t\tthrow new Error(`\"${key}\" is not a valid Clarity name`);\n\t\t}\n\t}\n\treturn { type: \"tuple\", value: data };\n}\n\nexport function stringAsciiCV(value: string): StringAsciiCV {\n\treturn { type: \"ascii\", value };\n}\n\nexport function stringUtf8CV(value: string): StringUtf8CV {\n\treturn { type: \"utf8\", value };\n}\n\n// Cl namespace — clean API\n\nexport const Cl: {\n\treadonly int: (value: IntegerType) => IntCV;\n\treadonly uint: (value: IntegerType) => UIntCV;\n\treadonly bool: (v: boolean) => BooleanCV;\n\tprincipal(address: string): StandardPrincipalCV | ContractPrincipalCV;\n\taddress(address: string): StandardPrincipalCV | ContractPrincipalCV;\n\treadonly contractPrincipal: (\n\t\taddress: string,\n\t\tcontractName: string,\n\t) => ContractPrincipalCV;\n\treadonly standardPrincipal: (address: string) => StandardPrincipalCV;\n\treadonly buffer: (buffer: Uint8Array) => BufferCV;\n\treadonly bufferFromHex: (hex: string) => BufferCV;\n\treadonly bufferFromAscii: (ascii: string) => BufferCV;\n\treadonly bufferFromUtf8: (utf8: string) => BufferCV;\n\treadonly none: () => NoneCV;\n\treadonly some: (value: ClarityValue) => SomeCV;\n\treadonly ok: (value: ClarityValue) => ResponseOkCV;\n\treadonly error: (value: ClarityValue) => ResponseErrorCV;\n\treadonly list: (values: ClarityValue[]) => ListCV;\n\treadonly tuple: (data: TupleData) => TupleCV;\n\treadonly stringAscii: (value: string) => StringAsciiCV;\n\treadonly stringUtf8: (value: string) => StringUtf8CV;\n\tserialize(value: ClarityValue): string;\n\treadonly deserialize: (bytes: Uint8Array) => ClarityValue;\n} = {\n\tint: intCV,\n\tuint: uintCV,\n\tbool: boolCV,\n\tprincipal(address: string): StandardPrincipalCV | ContractPrincipalCV {\n\t\tconst parsed = parsePrincipal(address);\n\t\tif (!parsed) throw new Error(`Invalid principal: ${address}`);\n\t\treturn parsed.contractName\n\t\t\t? contractPrincipalCV(parsed.address, parsed.contractName)\n\t\t\t: standardPrincipalCV(parsed.address);\n\t},\n\taddress(address: string): StandardPrincipalCV | ContractPrincipalCV {\n\t\treturn Cl.principal(address);\n\t},\n\tcontractPrincipal: contractPrincipalCV,\n\tstandardPrincipal: standardPrincipalCV,\n\tbuffer: bufferCV,\n\tbufferFromHex: (hex: string): BufferCV => bufferCV(hexToBytes(hex)),\n\tbufferFromAscii: (ascii: string): BufferCV => bufferCV(asciiToBytes(ascii)),\n\tbufferFromUtf8: (utf8: string): BufferCV => bufferCV(utf8ToBytes(utf8)),\n\tnone: noneCV,\n\tsome: someCV,\n\tok: responseOkCV,\n\terror: responseErrorCV,\n\tlist: listCV,\n\ttuple: tupleCV,\n\tstringAscii: stringAsciiCV,\n\tstringUtf8: stringUtf8CV,\n\tserialize(value: ClarityValue): string {\n\t\treturn bytesToHex(serializeCVBytes(value));\n\t},\n\tdeserialize: deserializeCVBytes,\n} as const;\n",
    "import { SerializationError } from \"../errors/transaction.ts\";\nimport { BytesReader } from \"../utils/bytes-reader.ts\";\nimport { c32address } from \"../utils/c32.ts\";\nimport {\n\tbytesToAscii,\n\tbytesToHex,\n\tbytesToTwosBigInt,\n\tbytesToUtf8,\n\thexToBytes,\n\twithout0x,\n} from \"../utils/encoding.ts\";\nimport { type ClarityValue, clarityTypeFromByte } from \"./types.ts\";\nimport {\n\tbufferCV,\n\tcontractPrincipalCV,\n\tfalseCV,\n\tintCV,\n\tlistCV,\n\tnoneCV,\n\tresponseErrorCV,\n\tresponseOkCV,\n\tsomeCV,\n\tstandardPrincipalCV,\n\tstringAsciiCV,\n\tstringUtf8CV,\n\ttrueCV,\n\ttupleCV,\n\tuintCV,\n} from \"./values.ts\";\n\nexport function readAddress(reader: BytesReader): string {\n\tconst version = reader.readUInt8();\n\tconst hash160 = bytesToHex(reader.readBytes(20));\n\treturn c32address(version, hash160);\n}\n\nexport function readLPString(reader: BytesReader, prefixBytes = 1): string {\n\tlet length = 0;\n\tfor (let i = 0; i < prefixBytes; i++) {\n\t\tlength = (length << 8) | reader.readUInt8();\n\t}\n\treturn bytesToUtf8(reader.readBytes(length));\n}\n\n/** Deepest nesting the deserializer follows before refusing the input. Clarity\n *  itself caps value nesting far below this, so honest data never hits it;\n *  hostile bytes that repeat `some`/`ok`/`list` would otherwise blow the stack. */\nexport const MAX_CV_DEPTH = 64;\n\n/** Every list item and tuple entry costs at least this many bytes on the wire\n *  (a type byte, plus a name-length byte for tuple entries), so a declared\n *  count that outruns the remaining bytes is corrupt before any allocation. */\nconst MIN_LIST_ITEM_BYTES = 1;\nconst MIN_TUPLE_ENTRY_BYTES = 2;\n\nfunction checkCount(reader: BytesReader, count: number, minBytes: number) {\n\tif (count * minBytes > reader.remaining()) {\n\t\tthrow new SerializationError(\n\t\t\t`Clarity value declares ${count} elements but only ${reader.remaining()} bytes remain`,\n\t\t);\n\t}\n}\n\nexport function readCV(reader: BytesReader, depth = 0): ClarityValue {\n\tif (depth > MAX_CV_DEPTH) {\n\t\tthrow new SerializationError(\n\t\t\t`Clarity value nests deeper than ${MAX_CV_DEPTH} levels`,\n\t\t);\n\t}\n\tconst typeByte = reader.readUInt8();\n\tconst type = clarityTypeFromByte(typeByte);\n\n\tswitch (type) {\n\t\tcase \"int\":\n\t\t\treturn intCV(bytesToTwosBigInt(reader.readBytes(16)));\n\n\t\tcase \"uint\":\n\t\t\treturn uintCV(reader.readBytes(16));\n\n\t\tcase \"true\":\n\t\t\treturn trueCV();\n\n\t\tcase \"false\":\n\t\t\treturn falseCV();\n\n\t\tcase \"buffer\": {\n\t\t\tconst len = reader.readUInt32BE();\n\t\t\treturn bufferCV(reader.readBytes(len));\n\t\t}\n\n\t\tcase \"none\":\n\t\t\treturn noneCV();\n\n\t\tcase \"some\":\n\t\t\treturn someCV(readCV(reader, depth + 1));\n\n\t\tcase \"ok\":\n\t\t\treturn responseOkCV(readCV(reader, depth + 1));\n\n\t\tcase \"err\":\n\t\t\treturn responseErrorCV(readCV(reader, depth + 1));\n\n\t\tcase \"address\":\n\t\t\treturn standardPrincipalCV(readAddress(reader));\n\n\t\tcase \"contract\": {\n\t\t\tconst addr = readAddress(reader);\n\t\t\tconst name = readLPString(reader);\n\t\t\treturn contractPrincipalCV(addr, name);\n\t\t}\n\n\t\tcase \"list\": {\n\t\t\tconst len = reader.readUInt32BE();\n\t\t\tcheckCount(reader, len, MIN_LIST_ITEM_BYTES);\n\t\t\tconst items: ClarityValue[] = [];\n\t\t\tfor (let i = 0; i < len; i++) {\n\t\t\t\titems.push(readCV(reader, depth + 1));\n\t\t\t}\n\t\t\treturn listCV(items);\n\t\t}\n\n\t\tcase \"tuple\": {\n\t\t\tconst len = reader.readUInt32BE();\n\t\t\tcheckCount(reader, len, MIN_TUPLE_ENTRY_BYTES);\n\t\t\tconst data: Record<string, ClarityValue> = {};\n\t\t\tfor (let i = 0; i < len; i++) {\n\t\t\t\tconst key = readLPString(reader);\n\t\t\t\tdata[key] = readCV(reader, depth + 1);\n\t\t\t}\n\t\t\treturn tupleCV(data);\n\t\t}\n\n\t\tcase \"ascii\": {\n\t\t\tconst len = reader.readUInt32BE();\n\t\t\treturn stringAsciiCV(bytesToAscii(reader.readBytes(len)));\n\t\t}\n\n\t\tcase \"utf8\": {\n\t\t\tconst len = reader.readUInt32BE();\n\t\t\treturn stringUtf8CV(bytesToUtf8(reader.readBytes(len)));\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new SerializationError(\n\t\t\t\t`Cannot deserialize unknown clarity type: ${type}`,\n\t\t\t);\n\t}\n}\n\nexport function deserializeCVBytes<T extends ClarityValue = ClarityValue>(\n\tinput: Uint8Array | string,\n): T {\n\tconst bytes =\n\t\ttypeof input === \"string\" ? hexToBytes(without0x(input)) : input;\n\treturn readCV(new BytesReader(bytes)) as T;\n}\n\nexport function deserializeCV<T extends ClarityValue = ClarityValue>(\n\tinput: Uint8Array | string,\n): T {\n\treturn deserializeCVBytes(input);\n}\n",
    "import { deserializeCVBytes } from \"../../clarity/deserialize.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { MalformedResponseError } from \"../../errors/response.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\n\nexport type GetDataVarParams = {\n\tcontract: string; // \"address.name\"\n\tvarName: string;\n};\n\nexport async function getDataVar<T extends ClarityValue = ClarityValue>(\n\tclient: Client,\n\tparams: GetDataVarParams,\n): Promise<T> {\n\tconst [address, name] = parseContractId(params.contract);\n\tconst path = `/v2/data_var/${address}/${name}/${params.varName}?proof=0`;\n\n\tconst data = await client.request(path, { method: \"GET\" });\n\n\tif (typeof data?.data !== \"string\") {\n\t\tthrow new MalformedResponseError(\n\t\t\t`getDataVar: /v2/data_var/${address}/${name}/${params.varName} response is missing \"data\"`,\n\t\t);\n\t}\n\treturn deserializeCVBytes<T>(data.data);\n}\n",
    "import { deserializeCVBytes } from \"../../clarity/deserialize.ts\";\nimport { serializeCVBytes } from \"../../clarity/serialize.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { MalformedResponseError } from \"../../errors/response.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\nimport { bytesToHex, with0x } from \"../../utils/encoding.ts\";\n\nexport type GetMapEntryParams = {\n\tcontract: string; // \"address.name\"\n\tmapName: string;\n\tkey: ClarityValue;\n};\n\nexport async function getMapEntry<T extends ClarityValue = ClarityValue>(\n\tclient: Client,\n\tparams: GetMapEntryParams,\n): Promise<T> {\n\tconst [address, name] = parseContractId(params.contract);\n\tconst serializedKey = with0x(bytesToHex(serializeCVBytes(params.key)));\n\n\tconst data = await client.request(\n\t\t`/v2/map_entry/${address}/${name}/${params.mapName}`,\n\t\t{\n\t\t\tmethod: \"POST\",\n\t\t\tbody: serializedKey,\n\t\t},\n\t);\n\n\tif (typeof data?.data !== \"string\") {\n\t\tthrow new MalformedResponseError(\n\t\t\t`getMapEntry: /v2/map_entry/${address}/${name}/${params.mapName} response is missing \"data\"`,\n\t\t);\n\t}\n\treturn deserializeCVBytes<T>(data.data);\n}\n",
    "type CamelCaseInner<S extends string> =\n\tS extends `${infer P1}-${infer P2}${infer P3}`\n\t\t? `${P1}${Capitalize<CamelCaseInner<`${P2}${P3}`>>}`\n\t\t: S;\n\nexport type ToCamelCase<S extends string> =\n\tCamelCaseInner<S> extends `${number}${string}`\n\t\t? `_${CamelCaseInner<S>}`\n\t\t: CamelCaseInner<S>;\n\nexport function toCamelCase(str: string): string {\n\treturn str\n\t\t.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())\n\t\t.replace(/-([A-Z])/g, (_, letter) => letter)\n\t\t.replace(/-(\\d)/g, (_, digit) => digit)\n\t\t.replace(/-/g, \"\")\n\t\t.replace(/^\\d/, \"_$&\");\n}\n",
    "import { parsePrincipal } from \"../../utils/address.ts\";\nimport type { ResponseErr, ResponseOk } from \"./mappings.ts\";\nimport { MAX_I128, MAX_U128, MIN_I128 } from \"./types.ts\";\nimport type {\n\tAbiBuffer,\n\tAbiListType,\n\tAbiOptionalType,\n\tAbiResponseType,\n\tAbiStringAscii,\n\tAbiStringUtf8,\n\tAbiTraitReference,\n\tAbiTupleType,\n\tAbiType,\n} from \"./types.ts\";\n\n// Value guards\n\nexport function isUint128(value: unknown): value is bigint {\n\treturn typeof value === \"bigint\" && value >= 0n && value <= MAX_U128;\n}\n\nexport function isInt128(value: unknown): value is bigint {\n\treturn typeof value === \"bigint\" && value >= MIN_I128 && value <= MAX_I128;\n}\n\nexport function isBool(value: unknown): value is boolean {\n\treturn typeof value === \"boolean\";\n}\n\nexport function isPrincipal(value: unknown): value is string {\n\treturn typeof value === \"string\" && parsePrincipal(value) !== null;\n}\n\nexport function isStandardPrincipal(value: unknown): value is string {\n\tif (typeof value !== \"string\") return false;\n\tconst parsed = parsePrincipal(value);\n\t// Explicit null check: `null?.contractName === undefined` is also true.\n\treturn parsed !== null && parsed.contractName === undefined;\n}\n\nexport function isContractPrincipal(value: unknown): value is string {\n\tif (typeof value !== \"string\") return false;\n\tconst parsed = parsePrincipal(value);\n\treturn parsed !== null && parsed.contractName !== undefined;\n}\n\nexport function isTraitReference(value: unknown): value is string {\n\treturn isContractPrincipal(value);\n}\n\nexport function isString(value: unknown): value is string {\n\treturn typeof value === \"string\";\n}\n\nexport function isUint8Array(value: unknown): value is Uint8Array {\n\treturn value instanceof Uint8Array;\n}\n\nexport function isArray<T>(\n\tvalue: unknown,\n\titemGuard: (item: unknown) => item is T,\n): value is T[] {\n\treturn Array.isArray(value) && value.every(itemGuard);\n}\n\nexport function isOptional<T>(\n\tvalue: unknown,\n\tguard: (val: unknown) => val is T,\n): value is T | null {\n\treturn value === null || guard(value);\n}\n\nexport function isOkResponse<T>(\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tresponse: { ok: T } | { err: any },\n): response is ResponseOk<T> {\n\treturn \"ok\" in response && !(\"err\" in response);\n}\n\nexport function isErrResponse<E>(\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tresponse: { ok: any } | { err: E },\n): response is ResponseErr<E> {\n\treturn \"err\" in response && !(\"ok\" in response);\n}\n\nexport function isResponse<T, E>(\n\tvalue: unknown,\n\tokGuard: (val: unknown) => val is T,\n\terrGuard: (val: unknown) => val is E,\n): value is ResponseOk<T> | ResponseErr<E> {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst obj = value as Record<string, unknown>;\n\tif (\"ok\" in value && !(\"err\" in value)) return okGuard(obj.ok);\n\tif (\"err\" in value && !(\"ok\" in value)) return errGuard(obj.err);\n\treturn false;\n}\n\n// ABI type definition guards\n\nexport function isAbiList(type: AbiType): type is AbiListType {\n\treturn typeof type === \"object\" && type !== null && \"list\" in type;\n}\n\nexport function isAbiTuple(type: AbiType): type is AbiTupleType {\n\treturn typeof type === \"object\" && type !== null && \"tuple\" in type;\n}\n\nexport function isAbiOptional(type: AbiType): type is AbiOptionalType {\n\treturn typeof type === \"object\" && type !== null && \"optional\" in type;\n}\n\nexport function isAbiResponse(type: AbiType): type is AbiResponseType {\n\treturn typeof type === \"object\" && type !== null && \"response\" in type;\n}\n\nexport function isAbiBuffer(type: AbiType): type is AbiBuffer {\n\treturn typeof type === \"object\" && type !== null && \"buff\" in type;\n}\n\nexport function isAbiStringAscii(type: AbiType): type is AbiStringAscii {\n\treturn typeof type === \"object\" && type !== null && \"string-ascii\" in type;\n}\n\nexport function isAbiStringUtf8(type: AbiType): type is AbiStringUtf8 {\n\treturn typeof type === \"object\" && type !== null && \"string-utf8\" in type;\n}\n\nexport function isAbiTraitReference(type: AbiType): type is AbiTraitReference {\n\treturn type === \"trait_reference\";\n}\n",
    "import {\n\tisAbiBuffer,\n\tisAbiList,\n\tisAbiOptional,\n\tisAbiResponse,\n\tisAbiStringAscii,\n\tisAbiStringUtf8,\n\tisAbiTuple,\n} from \"./abi/guards.ts\";\nimport type { AbiToTS } from \"./abi/mappings.ts\";\nimport type { AbiType } from \"./abi/types.ts\";\nimport { toCamelCase } from \"./abi/utils.ts\";\nimport type { ClarityValue } from \"./types.ts\";\nimport {\n\tboolCV,\n\tbufferCV,\n\tintCV,\n\tlistCV,\n\tnoneCV,\n\tresponseErrorCV,\n\tresponseOkCV,\n\tsomeCV,\n\tstringAsciiCV,\n\tstringUtf8CV,\n\ttupleCV,\n\tuintCV,\n} from \"./values.ts\";\nimport { Cl } from \"./values.ts\";\n\n/** CV type tags — mirrors the discriminants of `ClarityValue`. */\nconst CV_TYPE_TAGS = new Set([\n\t\"int\",\n\t\"uint\",\n\t\"true\",\n\t\"false\",\n\t\"address\",\n\t\"contract\",\n\t\"ascii\",\n\t\"utf8\",\n\t\"buffer\",\n\t\"list\",\n\t\"tuple\",\n\t\"none\",\n\t\"some\",\n\t\"ok\",\n\t\"err\",\n]);\n\n/**\n * Duck-type check: is `value` already a built ClarityValue? Tag-only CVs\n * (`true`/`false`/`none`) have no payload; every other tag carries `value`.\n */\nexport function isClarityValue(value: unknown): value is ClarityValue {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst type = (value as { type?: unknown }).type;\n\tif (typeof type !== \"string\" || !CV_TYPE_TAGS.has(type)) return false;\n\tif (type === \"true\" || type === \"false\" || type === \"none\") return true;\n\treturn \"value\" in value;\n}\n\nconst HEX_PAIRS_REGEX = /^(?:[0-9a-fA-F]{2})+$/;\n\n/**\n * Coerce a flexible buffer input to a BufferCV. Accepts `Uint8Array`, a\n * pre-built `BufferCV`, a tagged `{ type: 'ascii' | 'utf8' | 'hex', value }`\n * object, or a bare string (even-length hex — optionally 0x-prefixed — is\n * decoded as hex; anything else is UTF-8 encoded).\n */\nfunction coerceBuffer(value: unknown): ClarityValue {\n\tif (value instanceof Uint8Array) return bufferCV(value);\n\tif (typeof value === \"object\" && value !== null && \"type\" in value) {\n\t\tconst tagged = value as { type: string; value?: unknown };\n\t\tif (tagged.type === \"buffer\" && isClarityValue(value)) return value;\n\t\tif (typeof tagged.value === \"string\") {\n\t\t\tif (tagged.type === \"ascii\") return Cl.bufferFromAscii(tagged.value);\n\t\t\tif (tagged.type === \"utf8\") return Cl.bufferFromUtf8(tagged.value);\n\t\t\tif (tagged.type === \"hex\") return Cl.bufferFromHex(tagged.value);\n\t\t}\n\t\tthrow new Error(`Unsupported buffer input: ${JSON.stringify(value)}`);\n\t}\n\tif (typeof value === \"string\") {\n\t\tconst hex = value.startsWith(\"0x\") ? value.slice(2) : value;\n\t\tif (HEX_PAIRS_REGEX.test(hex)) return Cl.bufferFromHex(hex);\n\t\treturn Cl.bufferFromUtf8(value);\n\t}\n\tthrow new Error(\n\t\t\"buffer arg expects Uint8Array, hex string, { type, value }, or BufferCV\",\n\t);\n}\n\n/**\n * Convert a JS value to a ClarityValue using ABI type information.\n *\n * Pre-built ClarityValues pass through unchanged (escape hatch for callers\n * that already hold a CV). Buffer args additionally accept hex strings and\n * tagged `{ type, value }` objects — matching the generated-client input\n * contract.\n */\nexport function jsToClarityValue(\n\tabiType: AbiType,\n\tvalue: unknown,\n): ClarityValue {\n\t// Buffers first: the tagged `{ type: 'ascii', value }` input form is\n\t// shape-identical to StringAsciiCV, so buffer coercion wins for buff args.\n\tif (isAbiBuffer(abiType)) return coerceBuffer(value);\n\n\tif (isClarityValue(value)) return value;\n\n\tif (abiType === \"uint128\") return uintCV(value as bigint | number);\n\tif (abiType === \"int128\") return intCV(value as bigint | number);\n\tif (abiType === \"bool\") return boolCV(value as boolean);\n\tif (abiType === \"principal\" || abiType === \"trait_reference\")\n\t\treturn Cl.principal(value as string);\n\n\tif (isAbiStringAscii(abiType)) return stringAsciiCV(value as string);\n\tif (isAbiStringUtf8(abiType)) return stringUtf8CV(value as string);\n\n\tif (isAbiList(abiType)) {\n\t\tconst arr = value as unknown[];\n\t\treturn listCV(arr.map((item) => jsToClarityValue(abiType.list.type, item)));\n\t}\n\n\tif (isAbiTuple(abiType)) {\n\t\tconst obj = value as Record<string, unknown>;\n\t\tconst data: Record<string, ClarityValue> = {};\n\t\tfor (const field of abiType.tuple) {\n\t\t\tconst camelKey = toCamelCase(field.name);\n\t\t\tconst hasOriginal = field.name in obj;\n\t\t\tconst hasCamel = camelKey in obj;\n\t\t\tconst fieldValue = hasOriginal\n\t\t\t\t? obj[field.name]\n\t\t\t\t: hasCamel\n\t\t\t\t\t? obj[camelKey]\n\t\t\t\t\t: undefined;\n\t\t\tif (fieldValue === undefined && !isAbiOptional(field.type)) {\n\t\t\t\tthrow new Error(`Missing tuple field: ${field.name}`);\n\t\t\t}\n\t\t\tdata[field.name] = jsToClarityValue(field.type, fieldValue);\n\t\t}\n\t\treturn tupleCV(data);\n\t}\n\n\tif (isAbiOptional(abiType)) {\n\t\tif (value === null || value === undefined) return noneCV();\n\t\treturn someCV(jsToClarityValue(abiType.optional, value));\n\t}\n\n\tif (isAbiResponse(abiType)) {\n\t\tconst obj = value as Record<string, unknown>;\n\t\tif (\"ok\" in obj && !(\"err\" in obj))\n\t\t\treturn responseOkCV(jsToClarityValue(abiType.response.ok, obj.ok));\n\t\tif (\"err\" in obj && !(\"ok\" in obj))\n\t\t\treturn responseErrorCV(jsToClarityValue(abiType.response.error, obj.err));\n\t\tthrow new Error(\"Response must have exactly 'ok' or 'err' property\");\n\t}\n\n\tthrow new Error(`Unknown ABI type: ${JSON.stringify(abiType)}`);\n}\n\n/**\n * Convert a ClarityValue back to a typed JS value using ABI type information.\n */\nexport function clarityValueToJS<T extends AbiType>(\n\tabiType: T,\n\tcv: ClarityValue,\n): AbiToTS<T> {\n\treturn clarityValueToJSInner(abiType, cv) as AbiToTS<T>;\n}\n\n/** Non-generic version for internal use — avoids deep type instantiation. */\nexport function clarityValueToJSUntyped(\n\tabiType: AbiType,\n\tcv: ClarityValue,\n): unknown {\n\treturn clarityValueToJSInner(abiType, cv);\n}\n\nfunction clarityValueToJSInner(abiType: AbiType, cv: ClarityValue): unknown {\n\tif (abiType === \"uint128\" || abiType === \"int128\") {\n\t\tif (cv.type !== \"int\" && cv.type !== \"uint\")\n\t\t\tthrow new Error(`Expected int/uint CV, got ${cv.type}`);\n\t\treturn cv.value;\n\t}\n\n\tif (abiType === \"bool\") {\n\t\tif (cv.type === \"true\") return true;\n\t\tif (cv.type === \"false\") return false;\n\t\tthrow new Error(`Expected bool CV, got ${cv.type}`);\n\t}\n\n\tif (abiType === \"principal\" || abiType === \"trait_reference\") {\n\t\tif (cv.type !== \"address\" && cv.type !== \"contract\")\n\t\t\tthrow new Error(`Expected principal CV, got ${cv.type}`);\n\t\treturn cv.value;\n\t}\n\n\tif (isAbiStringAscii(abiType) || isAbiStringUtf8(abiType)) {\n\t\tif (cv.type !== \"ascii\" && cv.type !== \"utf8\")\n\t\t\tthrow new Error(`Expected string CV, got ${cv.type}`);\n\t\treturn cv.value;\n\t}\n\n\tif (isAbiBuffer(abiType)) {\n\t\tif (cv.type !== \"buffer\")\n\t\t\tthrow new Error(`Expected buffer CV, got ${cv.type}`);\n\t\t// BufferCV stores hex string; convert back to Uint8Array\n\t\tconst hex = cv.value;\n\t\tconst bytes = new Uint8Array(hex.length / 2);\n\t\tfor (let i = 0; i < bytes.length; i++) {\n\t\t\tbytes[i] = Number.parseInt(hex.substring(i * 2, i * 2 + 2), 16);\n\t\t}\n\t\treturn bytes;\n\t}\n\n\tif (isAbiList(abiType)) {\n\t\tif (cv.type !== \"list\") throw new Error(`Expected list CV, got ${cv.type}`);\n\t\treturn cv.value.map((item) =>\n\t\t\tclarityValueToJSInner(abiType.list.type, item),\n\t\t);\n\t}\n\n\tif (isAbiTuple(abiType)) {\n\t\tif (cv.type !== \"tuple\")\n\t\t\tthrow new Error(`Expected tuple CV, got ${cv.type}`);\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const field of abiType.tuple) {\n\t\t\tconst fieldCV = cv.value[field.name];\n\t\t\tif (!fieldCV) throw new Error(`Missing tuple field in CV: ${field.name}`);\n\t\t\tconst camelKey = toCamelCase(field.name);\n\t\t\tresult[camelKey] = clarityValueToJSInner(field.type, fieldCV);\n\t\t}\n\t\treturn result;\n\t}\n\n\tif (isAbiOptional(abiType)) {\n\t\tif (cv.type === \"none\") return null;\n\t\tif (cv.type === \"some\")\n\t\t\treturn clarityValueToJSInner(abiType.optional, cv.value);\n\t\tthrow new Error(`Expected optional CV, got ${cv.type}`);\n\t}\n\n\tif (isAbiResponse(abiType)) {\n\t\tif (cv.type === \"ok\")\n\t\t\treturn { ok: clarityValueToJSInner(abiType.response.ok, cv.value) };\n\t\tif (cv.type === \"err\")\n\t\t\treturn { err: clarityValueToJSInner(abiType.response.error, cv.value) };\n\t\tthrow new Error(`Expected response CV, got ${cv.type}`);\n\t}\n\n\tthrow new Error(`Unknown ABI type: ${JSON.stringify(abiType)}`);\n}\n",
    "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\tClarity6: 6, // SIP-044, Epoch 4.0\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\tOriginator: 0x03, // SIP-040, Epoch 3.4\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\tMaybeSent: 0x12, // SIP-040, Epoch 3.4\n} as const;\n\n// PoX condition codes (wire format, SIP-045)\nexport const PoxConditionCode = {\n\tWillNotPerform: 0x30,\n\tMayPerform: 0x31,\n\tWillPerform: 0x32,\n} as const;\nexport type PoxConditionCode =\n\t(typeof PoxConditionCode)[keyof typeof PoxConditionCode];\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\tStaking: 0x03, // SIP-045\n\tPox: 0x04, // SIP-045\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\t/** Multi-sig signer metadata — not part of the wire format, preserved\n\t *  through serialize/deserialize round-trip for auto-detection. */\n\t_multisig?: { publicKeys: string[] };\n};\n\n// Wire post condition types\nexport type PostConditionWire =\n\t| StxPostConditionWire\n\t| FtPostConditionWire\n\t| NftPostConditionWire\n\t| StakingPostConditionWire\n\t| PoxPostConditionWire;\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\n// SIP-045: gates stake/register-for-bond/stake-update; same shape as STX\nexport type StakingPostConditionWire = {\n\ttype: \"staking\";\n\tprincipal: PostConditionPrincipalWire;\n\tconditionCode: number;\n\tamount: bigint;\n};\n\n// SIP-045: gates non-locking PoX state changes (unstake, announce-l1-early-exit, …); no amount\nexport type PoxPostConditionWire = {\n\ttype: \"pox\";\n\tprincipal: PostConditionPrincipalWire;\n\tconditionCode: PoxConditionCode;\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",
    "import {\n\treadAddress,\n\treadCV,\n\treadLPString,\n} from \"../../clarity/deserialize.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport { BytesReader } from \"../../utils/bytes-reader.ts\";\nimport {\n\tbytesToAscii,\n\tbytesToHex,\n\thexToBytes,\n\twithout0x,\n} from \"../../utils/encoding.ts\";\nimport {\n\tAddressHashMode,\n\ttype AnchorMode,\n\ttype AssetInfoWire,\n\tAssetType,\n\tAuthType,\n\ttype Authorization,\n\tCOINBASE_BYTES_LENGTH,\n\ttype ClarityVersion,\n\tMEMO_MAX_LENGTH_BYTES,\n\tMICROBLOCK_HEADER_BYTES_LENGTH,\n\tPayloadType,\n\ttype PostConditionModeWire,\n\tPostConditionPrincipalId,\n\ttype PostConditionPrincipalWire,\n\ttype PostConditionWire,\n\ttype PoxConditionCode,\n\tRECOVERABLE_ECDSA_SIG_LENGTH_BYTES,\n\ttype SpendingCondition,\n\ttype StacksTransaction,\n\ttype TenureChangeCause,\n\ttype TransactionAuthField,\n\ttype TransactionPayload,\n\tVRF_PROOF_BYTES_LENGTH,\n} from \"../types.ts\";\n\nfunction readSpendingCondition(r: BytesReader): SpendingCondition {\n\tconst hashMode = r.readUInt8();\n\tconst signer = bytesToHex(r.readBytes(20));\n\tconst nonce = r.readBigUInt64BE();\n\tconst fee = r.readBigUInt64BE();\n\n\tif (\n\t\thashMode === AddressHashMode.P2PKH ||\n\t\thashMode === AddressHashMode.P2WPKH\n\t) {\n\t\tconst keyEncoding = r.readUInt8();\n\t\tconst signature = bytesToHex(\n\t\t\tr.readBytes(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES),\n\t\t);\n\t\treturn {\n\t\t\thashMode,\n\t\t\tsigner,\n\t\t\tnonce,\n\t\t\tfee,\n\t\t\tkeyEncoding,\n\t\t\tsignature,\n\t\t} as SpendingCondition;\n\t}\n\n\tconst fieldCount = r.readUInt32BE();\n\tconst fields: TransactionAuthField[] = [];\n\tfor (let i = 0; i < fieldCount; i++) {\n\t\tconst fieldType = r.readUInt8();\n\t\tif (fieldType <= 0x01) {\n\t\t\tconst keyLen = fieldType === 0x00 ? 33 : 65;\n\t\t\tfields.push({\n\t\t\t\ttype: \"publicKey\",\n\t\t\t\tpubKeyEncoding: fieldType as 0x00 | 0x01,\n\t\t\t\tdata: bytesToHex(r.readBytes(keyLen)),\n\t\t\t});\n\t\t} else {\n\t\t\tfields.push({\n\t\t\t\ttype: \"signature\",\n\t\t\t\tpubKeyEncoding: (fieldType === 0x02 ? 0x00 : 0x01) as 0x00 | 0x01,\n\t\t\t\tdata: bytesToHex(r.readBytes(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES)),\n\t\t\t});\n\t\t}\n\t}\n\tconst signaturesRequired = r.readUInt16BE();\n\n\treturn {\n\t\thashMode,\n\t\tsigner,\n\t\tnonce,\n\t\tfee,\n\t\tfields,\n\t\tsignaturesRequired,\n\t} as SpendingCondition;\n}\n\nfunction readAuthorization(r: BytesReader): Authorization {\n\tconst authType = r.readUInt8();\n\tconst spendingCondition = readSpendingCondition(r);\n\n\tif (authType === AuthType.Standard) {\n\t\treturn { authType: AuthType.Standard, spendingCondition };\n\t}\n\n\tconst sponsorSpendingCondition = readSpendingCondition(r);\n\treturn {\n\t\tauthType: AuthType.Sponsored,\n\t\tspendingCondition,\n\t\tsponsorSpendingCondition,\n\t};\n}\n\nfunction readAssetInfo(r: BytesReader): AssetInfoWire {\n\treturn {\n\t\taddress: readAddress(r),\n\t\tcontractName: readLPString(r),\n\t\tassetName: readLPString(r),\n\t};\n}\n\nfunction readPostConditionPrincipal(\n\tr: BytesReader,\n): PostConditionPrincipalWire {\n\tconst type = r.readUInt8();\n\tswitch (type) {\n\t\tcase PostConditionPrincipalId.Origin:\n\t\t\treturn { type: \"origin\" };\n\t\tcase PostConditionPrincipalId.Standard:\n\t\t\treturn { type: \"standard\", address: readAddress(r) };\n\t\tcase PostConditionPrincipalId.Contract:\n\t\t\treturn {\n\t\t\t\ttype: \"contract\",\n\t\t\t\taddress: readAddress(r),\n\t\t\t\tcontractName: readLPString(r),\n\t\t\t};\n\t\tdefault:\n\t\t\t// Some legacy transactions may have unexpected principal types.\n\t\t\t// Treat as origin to allow deserialization to continue.\n\t\t\treturn { type: \"origin\" };\n\t}\n}\n\nfunction readPostCondition(r: BytesReader): PostConditionWire {\n\t// Wire order: asset_type, then principal (per SIP-005 and stacks.js)\n\tconst assetType = r.readUInt8();\n\tconst principal = readPostConditionPrincipal(r);\n\tswitch (assetType) {\n\t\tcase AssetType.STX:\n\t\t\treturn {\n\t\t\t\ttype: \"stx\",\n\t\t\t\tprincipal,\n\t\t\t\tconditionCode: r.readUInt8(),\n\t\t\t\tamount: r.readBigUInt64BE(),\n\t\t\t};\n\t\tcase AssetType.Fungible:\n\t\t\treturn {\n\t\t\t\ttype: \"ft\",\n\t\t\t\tprincipal,\n\t\t\t\tasset: readAssetInfo(r),\n\t\t\t\tconditionCode: r.readUInt8(),\n\t\t\t\tamount: r.readBigUInt64BE(),\n\t\t\t};\n\t\tcase AssetType.NonFungible:\n\t\t\treturn {\n\t\t\t\ttype: \"nft\",\n\t\t\t\tprincipal,\n\t\t\t\tasset: readAssetInfo(r),\n\t\t\t\tassetId: readCV(r),\n\t\t\t\tconditionCode: r.readUInt8(),\n\t\t\t};\n\t\tcase AssetType.Staking:\n\t\t\treturn {\n\t\t\t\ttype: \"staking\",\n\t\t\t\tprincipal,\n\t\t\t\tconditionCode: r.readUInt8(),\n\t\t\t\tamount: r.readBigUInt64BE(),\n\t\t\t};\n\t\tcase AssetType.Pox:\n\t\t\treturn {\n\t\t\t\ttype: \"pox\",\n\t\t\t\tprincipal,\n\t\t\t\tconditionCode: r.readUInt8() as PoxConditionCode,\n\t\t\t};\n\t\tdefault:\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown post-condition asset type: 0x${assetType.toString(16).padStart(2, \"0\")}`,\n\t\t\t);\n\t}\n}\n\nfunction readPostConditions(r: BytesReader): PostConditionWire[] {\n\tconst count = r.readUInt32BE();\n\tconst pcs: PostConditionWire[] = [];\n\tfor (let i = 0; i < count; i++) {\n\t\ttry {\n\t\t\tpcs.push(readPostCondition(r));\n\t\t} catch (e) {\n\t\t\tif (\n\t\t\t\te instanceof Error &&\n\t\t\t\te.message.startsWith(\"Unknown post-condition asset type:\")\n\t\t\t) {\n\t\t\t\tthrow new Error(`${e.message} (post-condition ${i + 1}/${count})`);\n\t\t\t}\n\t\t\tthrow e;\n\t\t}\n\t}\n\treturn pcs;\n}\n\nfunction readPayload(r: BytesReader): TransactionPayload {\n\tconst payloadType = r.readUInt8();\n\n\tswitch (payloadType) {\n\t\tcase PayloadType.TokenTransfer: {\n\t\t\tconst recipient = readCV(r);\n\t\t\tconst amount = r.readBigUInt64BE();\n\t\t\t// Memo is a flat 34-byte field (no length prefix) per SIP-005\n\t\t\tconst memoBytes = r.readBytes(MEMO_MAX_LENGTH_BYTES);\n\t\t\tconst memo = bytesToAscii(memoBytes).replace(/\\0+$/, \"\");\n\t\t\treturn {\n\t\t\t\tpayloadType: PayloadType.TokenTransfer,\n\t\t\t\trecipient,\n\t\t\t\tamount,\n\t\t\t\tmemo,\n\t\t\t};\n\t\t}\n\t\tcase PayloadType.ContractCall: {\n\t\t\tconst contractAddress = readAddress(r);\n\t\t\tconst contractName = readLPString(r);\n\t\t\tconst functionName = readLPString(r);\n\t\t\tconst numArgs = r.readUInt32BE();\n\t\t\tconst functionArgs: ClarityValue[] = [];\n\t\t\tfor (let i = 0; i < numArgs; i++) functionArgs.push(readCV(r));\n\t\t\treturn {\n\t\t\t\tpayloadType: PayloadType.ContractCall,\n\t\t\t\tcontractAddress,\n\t\t\t\tcontractName,\n\t\t\t\tfunctionName,\n\t\t\t\tfunctionArgs,\n\t\t\t};\n\t\t}\n\t\tcase PayloadType.SmartContract: {\n\t\t\tconst contractName = readLPString(r);\n\t\t\tconst codeBody = readLPString(r, 4);\n\t\t\treturn { payloadType: PayloadType.SmartContract, contractName, codeBody };\n\t\t}\n\t\tcase PayloadType.VersionedSmartContract: {\n\t\t\tconst clarityVersion = r.readUInt8() as ClarityVersion;\n\t\t\tconst contractName = readLPString(r);\n\t\t\tconst codeBody = readLPString(r, 4);\n\t\t\treturn {\n\t\t\t\tpayloadType: PayloadType.VersionedSmartContract,\n\t\t\t\tclarityVersion,\n\t\t\t\tcontractName,\n\t\t\t\tcodeBody,\n\t\t\t};\n\t\t}\n\t\tcase PayloadType.Coinbase: {\n\t\t\tconst coinbaseBuffer = bytesToHex(r.readBytes(COINBASE_BYTES_LENGTH));\n\t\t\treturn { payloadType: PayloadType.Coinbase, coinbaseBuffer };\n\t\t}\n\t\tcase PayloadType.CoinbaseToAltRecipient: {\n\t\t\tconst coinbaseBuffer = bytesToHex(r.readBytes(COINBASE_BYTES_LENGTH));\n\t\t\tconst recipient = readCV(r);\n\t\t\treturn {\n\t\t\t\tpayloadType: PayloadType.CoinbaseToAltRecipient,\n\t\t\t\tcoinbaseBuffer,\n\t\t\t\trecipient,\n\t\t\t};\n\t\t}\n\t\tcase PayloadType.PoisonMicroblock: {\n\t\t\tconst header1 = bytesToHex(r.readBytes(MICROBLOCK_HEADER_BYTES_LENGTH));\n\t\t\tconst header2 = bytesToHex(r.readBytes(MICROBLOCK_HEADER_BYTES_LENGTH));\n\t\t\treturn { payloadType: PayloadType.PoisonMicroblock, header1, header2 };\n\t\t}\n\t\tcase PayloadType.TenureChange: {\n\t\t\tconst tenureConsensusHash = bytesToHex(r.readBytes(20));\n\t\t\tconst prevTenureConsensusHash = bytesToHex(r.readBytes(20));\n\t\t\tconst burnViewConsensusHash = bytesToHex(r.readBytes(20));\n\t\t\tconst previousTenureEnd = bytesToHex(r.readBytes(32));\n\t\t\tconst previousTenureBlocks = r.readUInt32BE();\n\t\t\tconst cause = r.readUInt8() as TenureChangeCause;\n\t\t\tconst pubkeyHash = bytesToHex(r.readBytes(20));\n\t\t\treturn {\n\t\t\t\tpayloadType: PayloadType.TenureChange,\n\t\t\t\ttenureConsensusHash,\n\t\t\t\tprevTenureConsensusHash,\n\t\t\t\tburnViewConsensusHash,\n\t\t\t\tpreviousTenureEnd,\n\t\t\t\tpreviousTenureBlocks,\n\t\t\t\tcause,\n\t\t\t\tpubkeyHash,\n\t\t\t};\n\t\t}\n\t\tcase PayloadType.NakamotoCoinbase: {\n\t\t\tconst coinbaseBuffer = bytesToHex(r.readBytes(COINBASE_BYTES_LENGTH));\n\t\t\tconst optionalCV = readCV(r);\n\t\t\tconst recipient =\n\t\t\t\toptionalCV.type === \"none\"\n\t\t\t\t\t? null\n\t\t\t\t\t: optionalCV.type === \"some\"\n\t\t\t\t\t\t? optionalCV.value\n\t\t\t\t\t\t: optionalCV;\n\t\t\tconst vrfProof = bytesToHex(r.readBytes(VRF_PROOF_BYTES_LENGTH));\n\t\t\treturn {\n\t\t\t\tpayloadType: PayloadType.NakamotoCoinbase,\n\t\t\t\tcoinbaseBuffer,\n\t\t\t\trecipient,\n\t\t\t\tvrfProof,\n\t\t\t};\n\t\t}\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown payload type: ${payloadType}`);\n\t}\n}\n\nexport function deserializePostConditionWire(\n\tinput: string | Uint8Array,\n): PostConditionWire {\n\tconst bytes =\n\t\ttypeof input === \"string\" ? hexToBytes(without0x(input)) : input;\n\treturn readPostCondition(new BytesReader(bytes));\n}\n\nexport function deserializeTransaction(\n\tinput: string | Uint8Array,\n\tmeta?: { _multisig?: { publicKeys: string[] } },\n): StacksTransaction {\n\tconst bytes =\n\t\ttypeof input === \"string\" ? hexToBytes(without0x(input)) : input;\n\treturn readTransaction(new BytesReader(bytes), meta);\n}\n\n/**\n * Split `count` back-to-back consensus-serialized transactions (a block body\n * after its u32 count) into each one's exact bytes, which hash to its txid.\n * Transactions carry no length prefix, so each is parsed to find its end.\n * Throws on a truncated or malformed transaction; bytes past the last one are\n * left for the caller to judge.\n */\nexport function splitTransactions(\n\tbytes: Uint8Array,\n\tcount: number,\n): Uint8Array[] {\n\tconst r = new BytesReader(bytes);\n\tconst out: Uint8Array[] = [];\n\tfor (let i = 0; i < count; i++) {\n\t\tconst start = r.offset;\n\t\treadTransaction(r);\n\t\tout.push(bytes.subarray(start, r.offset));\n\t}\n\treturn out;\n}\n\nfunction readTransaction(\n\tr: BytesReader,\n\tmeta?: { _multisig?: { publicKeys: string[] } },\n): StacksTransaction {\n\tconst tx: StacksTransaction = {\n\t\tversion: r.readUInt8(),\n\t\tchainId: r.readUInt32BE(),\n\t\tauth: readAuthorization(r),\n\t\tanchorMode: r.readUInt8() as AnchorMode,\n\t\tpostConditionMode: r.readUInt8() as PostConditionModeWire,\n\t\tpostConditions: readPostConditions(r),\n\t\tpayload: readPayload(r),\n\t};\n\tif (meta?._multisig) {\n\t\ttx._multisig = meta._multisig;\n\t}\n\treturn tx;\n}\n",
    "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}\n\tconst typeId = field.pubKeyEncoding === 0x00 ? 0x02 : 0x03;\n\treturn concatBytes(writeUInt8(typeId), hexToBytes(field.data));\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\nexport function serializePostConditionWire(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\tcase \"staking\":\n\t\t\t// SIP-045: same body as STX (fungible condition code + amount)\n\t\t\tparts.push(writeUInt8(AssetType.Staking));\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 \"pox\":\n\t\t\t// SIP-045: PoX condition code only, no amount\n\t\t\tparts.push(writeUInt8(AssetType.Pox));\n\t\t\tparts.push(serializePrincipal(pc.principal));\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) parts.push(serializePostConditionWire(pc));\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\n// Memoization cache: transactions are immutable in practice (fields are set\n// once during build/signing), so the serialized bytes for a given transaction\n// object never change. The signing flow serializes the same object several\n// times (txid, sighash, sponsor sighash); caching avoids that redundant work.\n// Any in-place mutation MUST call clearTxCache — see setUnsignedFee.\nconst _txCache = new WeakMap<StacksTransaction, Uint8Array>();\n\n/** Invalidate the memoized serialization of a mutated transaction */\nexport function clearTxCache(tx: StacksTransaction): void {\n\t_txCache.delete(tx);\n}\n\nexport function serializeTransaction(tx: StacksTransaction): Uint8Array {\n\tconst cached = _txCache.get(tx);\n\tif (cached) return cached;\n\tconst bytes = 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\t_txCache.set(tx, bytes);\n\treturn bytes;\n}\n\nexport function serializeTransactionHex(tx: StacksTransaction): string {\n\treturn bytesToHex(serializeTransaction(tx));\n}\n\n/** Serialize a transaction, returning the wire bytes plus the out-of-band\n *  `_multisig` metadata so callers can preserve it across a round-trip\n *  (the wire format itself does not carry it). */\nexport function serializeTransactionWithMeta(tx: StacksTransaction): {\n\tbytes: Uint8Array;\n\t_multisig?: { publicKeys: string[] };\n} {\n\treturn { bytes: serializeTransaction(tx), _multisig: tx._multisig };\n}\n",
    "import {\n\tFungibleConditionCode,\n\tNonFungibleConditionCode,\n\ttype PostConditionPrincipalWire,\n\ttype PostConditionWire,\n\tPoxConditionCode,\n} from \"../transactions/types.ts\";\nimport { deserializePostConditionWire } from \"../transactions/wire/deserialize.ts\";\nimport { serializePostConditionWire } from \"../transactions/wire/serialize.ts\";\nimport { parseContractId } from \"../utils/address.ts\";\nimport {\n\ttype IntegerType,\n\tbytesToHex,\n\tintToBigInt,\n} from \"../utils/encoding.ts\";\nimport type {\n\tFungibleComparator,\n\tNonFungibleComparator,\n\tPostCondition,\n\tPoxComparator,\n} from \"./types.ts\";\n\nconst MAX_U64 = 18446744073709551615n; // 2^64 - 1\n\n/** Parse a PC amount; throw if outside the u64 the wire can carry. */\nexport function parsePostConditionAmount(amount: IntegerType): bigint {\n\tconst value = intToBigInt(amount);\n\tif (value < 0n || value > MAX_U64) {\n\t\tthrow new RangeError(\n\t\t\t`Post-condition amount must be between 0 and ${MAX_U64} (u64 max), received: ${value}`,\n\t\t);\n\t}\n\treturn value;\n}\n\nexport const FUNGIBLE_CODE_MAP: Record<FungibleComparator, number> = {\n\teq: FungibleConditionCode.Equal,\n\tgt: FungibleConditionCode.Greater,\n\tgte: FungibleConditionCode.GreaterEqual,\n\tlt: FungibleConditionCode.Less,\n\tlte: FungibleConditionCode.LessEqual,\n};\n\nconst FUNGIBLE_CODE_REVERSE: Record<number, FungibleComparator> = {\n\t[FungibleConditionCode.Equal]: \"eq\",\n\t[FungibleConditionCode.Greater]: \"gt\",\n\t[FungibleConditionCode.GreaterEqual]: \"gte\",\n\t[FungibleConditionCode.Less]: \"lt\",\n\t[FungibleConditionCode.LessEqual]: \"lte\",\n};\n\nexport const NFT_CODE_MAP: Record<NonFungibleComparator, number> = {\n\tsent: NonFungibleConditionCode.Sends,\n\t\"not-sent\": NonFungibleConditionCode.DoesNotSend,\n\t\"maybe-sent\": NonFungibleConditionCode.MaybeSent,\n};\n\nconst NFT_CODE_REVERSE: Record<number, NonFungibleComparator> = {\n\t[NonFungibleConditionCode.Sends]: \"sent\",\n\t[NonFungibleConditionCode.DoesNotSend]: \"not-sent\",\n\t[NonFungibleConditionCode.MaybeSent]: \"maybe-sent\",\n};\n\nexport const POX_CODE_MAP: Record<PoxComparator, PoxConditionCode> = {\n\t\"will-not-perform\": PoxConditionCode.WillNotPerform,\n\t\"may-perform\": PoxConditionCode.MayPerform,\n\t\"will-perform\": PoxConditionCode.WillPerform,\n};\n\nconst POX_CODE_REVERSE: Record<number, PoxComparator> = {\n\t[PoxConditionCode.WillNotPerform]: \"will-not-perform\",\n\t[PoxConditionCode.MayPerform]: \"may-perform\",\n\t[PoxConditionCode.WillPerform]: \"will-perform\",\n};\n\nexport function resolvePrincipal(address: string): PostConditionPrincipalWire {\n\tif (address === \"origin\") return { type: \"origin\" };\n\tconst [addr, name] = address.split(\".\");\n\tif (name) {\n\t\t// biome-ignore lint/style/noNonNullAssertion: split yields address when name is present\n\t\treturn { type: \"contract\", address: addr!, contractName: name };\n\t}\n\t// biome-ignore lint/style/noNonNullAssertion: address is the whole string\n\treturn { type: \"standard\", address: addr! };\n}\n\nfunction principalToString(principal: PostConditionPrincipalWire): string {\n\tif (principal.type === \"origin\") return \"origin\";\n\tif (principal.type === \"contract\") {\n\t\treturn `${principal.address}.${principal.contractName}`;\n\t}\n\treturn principal.address;\n}\n\nfunction assetToString(asset: {\n\taddress: string;\n\tcontractName: string;\n\tassetName: string;\n}): string {\n\treturn `${asset.address}.${asset.contractName}::${asset.assetName}`;\n}\n\nfunction parseAsset(asset: string): {\n\taddress: string;\n\tcontractName: string;\n\tassetName: string;\n} {\n\tconst [contractId, tokenName] = asset.split(\"::\");\n\t// biome-ignore lint/style/noNonNullAssertion: callers validate `::` form\n\tconst [addr, name] = parseContractId(contractId!);\n\t// biome-ignore lint/style/noNonNullAssertion: split of `addr.contract::token`\n\treturn { address: addr, contractName: name, assetName: tokenName! };\n}\n\nexport function 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: parsePostConditionAmount(pc.amount),\n\t\t\t};\n\t\tcase \"ft-postcondition\":\n\t\t\treturn {\n\t\t\t\ttype: \"ft\",\n\t\t\t\tprincipal: resolvePrincipal(pc.address),\n\t\t\t\tasset: parseAsset(pc.asset),\n\t\t\t\tconditionCode: FUNGIBLE_CODE_MAP[pc.condition],\n\t\t\t\tamount: parsePostConditionAmount(pc.amount),\n\t\t\t};\n\t\tcase \"nft-postcondition\":\n\t\t\treturn {\n\t\t\t\ttype: \"nft\",\n\t\t\t\tprincipal: resolvePrincipal(pc.address),\n\t\t\t\tasset: parseAsset(pc.asset),\n\t\t\t\tconditionCode: NFT_CODE_MAP[pc.condition],\n\t\t\t\tassetId: pc.assetId,\n\t\t\t};\n\t\tcase \"staking-postcondition\":\n\t\t\treturn {\n\t\t\t\ttype: \"staking\",\n\t\t\t\tprincipal: resolvePrincipal(pc.address),\n\t\t\t\tconditionCode: FUNGIBLE_CODE_MAP[pc.condition],\n\t\t\t\tamount: parsePostConditionAmount(pc.amount),\n\t\t\t};\n\t\tcase \"pox-postcondition\":\n\t\t\treturn {\n\t\t\t\ttype: \"pox\",\n\t\t\t\tprincipal: resolvePrincipal(pc.address),\n\t\t\t\tconditionCode: POX_CODE_MAP[pc.condition],\n\t\t\t};\n\t}\n}\n\nexport function wireToPostCondition(wire: PostConditionWire): PostCondition {\n\tswitch (wire.type) {\n\t\tcase \"stx\":\n\t\t\treturn {\n\t\t\t\ttype: \"stx-postcondition\",\n\t\t\t\taddress: principalToString(wire.principal),\n\t\t\t\tcondition: fungibleName(wire.conditionCode),\n\t\t\t\tamount: wire.amount.toString(),\n\t\t\t};\n\t\tcase \"ft\":\n\t\t\treturn {\n\t\t\t\ttype: \"ft-postcondition\",\n\t\t\t\taddress: principalToString(wire.principal),\n\t\t\t\tcondition: fungibleName(wire.conditionCode),\n\t\t\t\tamount: wire.amount.toString(),\n\t\t\t\tasset: assetToString(wire.asset),\n\t\t\t};\n\t\tcase \"nft\":\n\t\t\treturn {\n\t\t\t\ttype: \"nft-postcondition\",\n\t\t\t\taddress: principalToString(wire.principal),\n\t\t\t\tcondition: nftName(wire.conditionCode),\n\t\t\t\tasset: assetToString(wire.asset),\n\t\t\t\tassetId: wire.assetId,\n\t\t\t};\n\t\tcase \"staking\":\n\t\t\treturn {\n\t\t\t\ttype: \"staking-postcondition\",\n\t\t\t\taddress: principalToString(wire.principal),\n\t\t\t\tcondition: fungibleName(wire.conditionCode),\n\t\t\t\tamount: wire.amount.toString(),\n\t\t\t};\n\t\tcase \"pox\":\n\t\t\treturn {\n\t\t\t\ttype: \"pox-postcondition\",\n\t\t\t\taddress: principalToString(wire.principal),\n\t\t\t\tcondition: poxName(wire.conditionCode),\n\t\t\t};\n\t}\n}\n\nfunction fungibleName(code: number): FungibleComparator {\n\tconst name = FUNGIBLE_CODE_REVERSE[code];\n\tif (!name) throw new Error(`Unknown fungible post-condition code: ${code}`);\n\treturn name;\n}\n\nfunction nftName(code: number): NonFungibleComparator {\n\tconst name = NFT_CODE_REVERSE[code];\n\tif (!name) throw new Error(`Unknown nft post-condition code: ${code}`);\n\treturn name;\n}\n\nfunction poxName(code: number): PoxComparator {\n\tconst name = POX_CODE_REVERSE[code];\n\tif (!name) throw new Error(`Unknown pox post-condition code: ${code}`);\n\treturn name;\n}\n\n/** Decode a serialized post-condition (stacks.js `Pc.fromHex`). */\nexport function fromHex(hex: string): PostCondition {\n\treturn wireToPostCondition(deserializePostConditionWire(hex));\n}\n\n/** Encode a post-condition to hex (stacks.js `postConditionToHex`). */\nexport function postConditionToHex(pc: PostCondition): string {\n\treturn bytesToHex(serializePostConditionWire(convertPostCondition(pc)));\n}\n",
    "import { hmac } from \"@noble/hashes/hmac.js\";\nimport { sha256 } from \"@noble/hashes/sha2.js\";\nimport { etc, getPublicKey as nobleGetPublicKey, sign } from \"@noble/secp256k1\";\nimport {\n\tbytesToHex,\n\tconcatBytes,\n\thexToBytes,\n\tintToBytes,\n\tintToHex,\n} from \"../utils/encoding.ts\";\nimport { hashP2PKH, txidFromBytes } from \"../utils/hash.ts\";\nimport {\n\tAddressHashMode,\n\tAuthType,\n\ttype Authorization,\n\tPubKeyEncoding,\n\tRECOVERABLE_ECDSA_SIG_LENGTH_BYTES,\n\ttype SingleSigSpendingCondition,\n\ttype SpendingCondition,\n\ttype SponsoredAuthorization,\n\ttype StandardAuthorization,\n} from \"./types.ts\";\n\n// Ensure sync signing is available\netc.hmacSha256Sync = (key: Uint8Array, ...msgs: Uint8Array[]) => {\n\tconst h = hmac.create(sha256, key);\n\tfor (const msg of msgs) h.update(msg);\n\treturn h.digest();\n};\n\nconst EMPTY_SIG = bytesToHex(\n\tnew Uint8Array(RECOVERABLE_ECDSA_SIG_LENGTH_BYTES),\n);\n\nexport function createSingleSigSpendingCondition(\n\tpublicKey: string,\n\tnonce: bigint,\n\tfee: bigint,\n): SingleSigSpendingCondition {\n\tconst pubKeyBytes = hexToBytes(publicKey);\n\tconst signer = hashP2PKH(pubKeyBytes);\n\tconst isCompressed = pubKeyBytes.length === 33;\n\n\treturn {\n\t\thashMode: AddressHashMode.P2PKH,\n\t\tsigner,\n\t\tnonce,\n\t\tfee,\n\t\tkeyEncoding: isCompressed\n\t\t\t? PubKeyEncoding.Compressed\n\t\t\t: PubKeyEncoding.Uncompressed,\n\t\tsignature: EMPTY_SIG,\n\t};\n}\n\nexport function createStandardAuth(\n\tspendingCondition: SpendingCondition,\n): StandardAuthorization {\n\treturn { authType: AuthType.Standard, spendingCondition };\n}\n\nexport function createSponsoredAuth(\n\tspendingCondition: SpendingCondition,\n\tsponsorSpendingCondition?: SpendingCondition,\n): SponsoredAuthorization {\n\treturn {\n\t\tauthType: AuthType.Sponsored,\n\t\tspendingCondition,\n\t\tsponsorSpendingCondition:\n\t\t\tsponsorSpendingCondition ??\n\t\t\tcreateSingleSigSpendingCondition(\"0\".repeat(66), 0n, 0n),\n\t};\n}\n\nfunction clearCondition(condition: SpendingCondition): SpendingCondition {\n\tif (\"signature\" in condition) {\n\t\treturn {\n\t\t\t...condition,\n\t\t\tnonce: 0n,\n\t\t\tfee: 0n,\n\t\t\tsignature: EMPTY_SIG,\n\t\t};\n\t}\n\treturn {\n\t\t...condition,\n\t\tnonce: 0n,\n\t\tfee: 0n,\n\t\tfields: [],\n\t};\n}\n\n/**\n * The sponsor \"signing sentinel\" used in the initial sighash of a sponsored tx.\n * Its `signer` MUST be 20 zero bytes (an empty address hash160) — NOT the\n * hash160 of a zero public key. Matching the reference (`newInitialSigHash` in\n * @stacks/transactions) is load-bearing: this exact byte layout is folded into\n * the origin's sighash, so any deviation makes the origin signature invalid and\n * the node rejects the tx with `SignatureValidation`.\n */\nfunction sponsorSigningSentinel(): SingleSigSpendingCondition {\n\treturn {\n\t\thashMode: AddressHashMode.P2PKH,\n\t\tsigner: \"00\".repeat(20),\n\t\tnonce: 0n,\n\t\tfee: 0n,\n\t\tkeyEncoding: PubKeyEncoding.Compressed,\n\t\tsignature: EMPTY_SIG,\n\t};\n}\n\nexport function intoInitialSighashAuth(auth: Authorization): Authorization {\n\tif (auth.authType === AuthType.Standard) {\n\t\treturn createStandardAuth(clearCondition(auth.spendingCondition));\n\t}\n\treturn createSponsoredAuth(\n\t\tclearCondition(auth.spendingCondition),\n\t\tsponsorSigningSentinel(),\n\t);\n}\n\n/** Compute pre-sign sighash = sha512/256(prevSigHash + authType + fee + nonce) */\nexport function sigHashPreSign(\n\tcurSigHash: string,\n\tauthType: number,\n\tfee: bigint,\n\tnonce: bigint,\n): string {\n\tconst data = concatBytes(\n\t\thexToBytes(curSigHash),\n\t\tnew Uint8Array([authType]),\n\t\tintToBytes(fee, 8),\n\t\tintToBytes(nonce, 8),\n\t);\n\treturn txidFromBytes(data);\n}\n\n/** Compute post-sign sighash = sha512/256(preSigHash + pubKeyEncoding + signature) */\nexport function sigHashPostSign(\n\tcurSigHash: string,\n\tpubKeyEncoding: number,\n\tsignature: string,\n): string {\n\tconst data = concatBytes(\n\t\thexToBytes(curSigHash),\n\t\tnew Uint8Array([pubKeyEncoding]),\n\t\thexToBytes(signature),\n\t);\n\treturn txidFromBytes(data);\n}\n\n/** Sign with private key and return VRS signature (recoveryId + r + s) */\nfunction signWithKey(privateKey: string, messageHash: string): string {\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst sig = sign(messageHash, keyBytes, { lowS: true });\n\tconst recoveryIdHex = intToHex(sig.recovery, 1);\n\treturn recoveryIdHex + sig.toCompactHex();\n}\n\nexport function nextSignature(\n\tcurSigHash: string,\n\tauthType: number,\n\tfee: bigint,\n\tnonce: bigint,\n\tprivateKey: string,\n): { nextSig: string; nextSigHash: string } {\n\tconst sigHashPre = sigHashPreSign(curSigHash, authType, fee, nonce);\n\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst pubKey = nobleGetPublicKey(keyBytes, true);\n\tconst isCompressed = pubKey.length === 33;\n\tconst pubKeyEncoding = isCompressed\n\t\t? PubKeyEncoding.Compressed\n\t\t: PubKeyEncoding.Uncompressed;\n\n\tconst nextSig = signWithKey(privateKey, sigHashPre);\n\tconst nextSigHash = sigHashPostSign(sigHashPre, pubKeyEncoding, nextSig);\n\n\treturn { nextSig, nextSigHash };\n}\n",
    "import {\n\tgetPublicKey as nobleGetPublicKey,\n\tsign as nobleSign,\n} from \"@noble/secp256k1\";\nimport type { CustomAccount, LocalAccount } from \"../accounts/types.ts\";\nimport type { StacksChain } from \"../chains/types.ts\";\nimport { c32address } from \"../utils/c32.ts\";\nimport {\n\tbytesToHex,\n\tconcatBytes,\n\thexToBytes,\n\tintToHex,\n} from \"../utils/encoding.ts\";\nimport { hash160 } from \"../utils/hash.ts\";\nimport { txidFromBytes } from \"../utils/hash.ts\";\nimport {\n\tintoInitialSighashAuth,\n\tnextSignature,\n\tsigHashPostSign,\n\tsigHashPreSign,\n} from \"./authorization.ts\";\nimport {\n\tAddressHashMode,\n\tAuthType,\n\ttype MultiSigHashMode,\n\ttype MultiSigSpendingCondition,\n\tPubKeyEncoding,\n\ttype StacksTransaction,\n\ttype TransactionAuthField,\n} from \"./types.ts\";\nimport { serializeTransaction } from \"./wire/serialize.ts\";\n\n// OP codes for redeem script\nconst OP_CHECKMULTISIG = 0xae;\n\n/** Check if hash mode is non-sequential (SIP-027) */\nexport function isNonSequential(hashMode: number): boolean {\n\treturn (hashMode & 0x04) !== 0;\n}\n\n/** Build a Bitcoin-style redeem script for m-of-n multi-sig */\nfunction makeRedeemScript(\n\tpublicKeys: string[],\n\tsignaturesRequired: number,\n): Uint8Array {\n\tconst parts: Uint8Array[] = [];\n\tparts.push(new Uint8Array([0x50 + signaturesRequired])); // OP_n\n\tfor (const pk of publicKeys) {\n\t\tconst pkBytes = hexToBytes(pk);\n\t\tparts.push(new Uint8Array([pkBytes.length])); // length prefix (0x21 for compressed)\n\t\tparts.push(pkBytes);\n\t}\n\tparts.push(new Uint8Array([0x50 + publicKeys.length])); // OP_m\n\tparts.push(new Uint8Array([OP_CHECKMULTISIG]));\n\treturn concatBytes(...parts);\n}\n\n/** Derive a multi-sig address from public keys */\nexport function makeMultiSigAddress(\n\tpublicKeys: string[],\n\tsignaturesRequired: number,\n\tchain?: StacksChain,\n): string {\n\tif (signaturesRequired < 1 || signaturesRequired > publicKeys.length) {\n\t\tthrow new Error(\n\t\t\t`signaturesRequired must be between 1 and ${publicKeys.length}`,\n\t\t);\n\t}\n\tconst redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n\tconst signer = hash160(redeemScript);\n\tconst version = chain?.addressVersion?.multiSig ?? 20; // mainnet default\n\treturn c32address(version, bytesToHex(signer));\n}\n\n/** Create an empty multi-sig spending condition */\nexport function createMultiSigSpendingCondition(\n\tpublicKeys: string[],\n\tsignaturesRequired: number,\n\tnonce: bigint,\n\tfee: bigint,\n\thashMode: MultiSigHashMode = AddressHashMode.P2SH,\n): MultiSigSpendingCondition {\n\tconst redeemScript = makeRedeemScript(publicKeys, signaturesRequired);\n\tconst signer = bytesToHex(hash160(redeemScript));\n\n\treturn {\n\t\thashMode,\n\t\tsigner,\n\t\tnonce,\n\t\tfee,\n\t\tfields: [],\n\t\tsignaturesRequired,\n\t};\n}\n\n/** Compute the initial sighash for a transaction (same as signBegin) */\nfunction initialSigHash(tx: StacksTransaction): string {\n\tconst cleared: StacksTransaction = {\n\t\t...tx,\n\t\tauth: intoInitialSighashAuth(tx.auth),\n\t};\n\treturn txidFromBytes(serializeTransaction(cleared));\n}\n\n/** Compute the presign-sighash used by all non-sequential signers */\nfunction nonSequentialPreSignHash(tx: StacksTransaction): string {\n\tconst condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\tconst initHash = initialSigHash(tx);\n\treturn sigHashPreSign(\n\t\tinitHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t);\n}\n\n/** Replay sighash through existing auth fields of a multi-sig tx */\nexport function replayMultiSigSigHash(tx: StacksTransaction): string {\n\tconst condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n\t// Non-sequential: all signers sign the same presign-sighash, no field chaining\n\tif (isNonSequential(condition.hashMode)) {\n\t\tconst preSign = nonSequentialPreSignHash(tx);\n\t\t// Chain through all fields to get the final sighash\n\t\tlet curSigHash = preSign;\n\t\tfor (const field of condition.fields) {\n\t\t\tcurSigHash = sigHashPostSign(\n\t\t\t\tcurSigHash,\n\t\t\t\tfield.pubKeyEncoding,\n\t\t\t\tfield.data,\n\t\t\t);\n\t\t}\n\t\treturn curSigHash;\n\t}\n\n\t// Sequential: chain through all fields\n\tlet curSigHash = initialSigHash(tx);\n\tfor (const field of condition.fields) {\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n\t}\n\treturn curSigHash;\n}\n\n/** Sign one position of a multi-sig transaction with a private key */\nexport function signMultiSig(\n\ttx: StacksTransaction,\n\tprivateKey: string,\n\tpublicKeys: string[],\n): StacksTransaction {\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst signerPubKey = bytesToHex(nobleGetPublicKey(keyBytes, true));\n\n\tconst signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n\tif (signerIndex === -1) {\n\t\tthrow new Error(\n\t\t\t\"Private key does not correspond to any signer in the multi-sig\",\n\t\t);\n\t}\n\n\tconst condition = {\n\t\t...(tx.auth.spendingCondition as MultiSigSpendingCondition),\n\t};\n\n\t// Non-sequential: all signers sign the same presign-sighash independently\n\tif (isNonSequential(condition.hashMode)) {\n\t\treturn signNonSequential(tx, condition, privateKey);\n\t}\n\n\t// Sequential: existing P2SH behavior\n\treturn signSequential(tx, condition, privateKey, publicKeys, signerIndex);\n}\n\n/** Non-sequential signing: compute presign-sighash from initial tx, sign, append */\nfunction signNonSequential(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\tprivateKey: string,\n): StacksTransaction {\n\tconst fields = [...condition.fields];\n\tconst preSignHash = nonSequentialPreSignHash(tx);\n\n\t// Sign the presign-sighash directly\n\tconst keyBytes = hexToBytes(privateKey).slice(0, 32);\n\tconst sig = nobleSign(preSignHash, keyBytes, { lowS: true });\n\tconst recoveryIdHex = intToHex(sig.recovery, 1);\n\tconst nextSig = recoveryIdHex + sig.toCompactHex();\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\tconst sigCount = fields.filter((f) => f.type === \"signature\").length;\n\n\t// Auto-finalize: non-sequential needs no pubkey gap-filling\n\tif (sigCount >= condition.signaturesRequired) {\n\t\treturn {\n\t\t\t...tx,\n\t\t\tauth: { ...tx.auth, spendingCondition: newCondition },\n\t\t};\n\t}\n\n\treturn {\n\t\t...tx,\n\t\tauth: { ...tx.auth, spendingCondition: newCondition },\n\t};\n}\n\n/** Sequential signing: existing P2SH behavior */\nfunction signSequential(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\tprivateKey: string,\n\tpublicKeys: string[],\n\tsignerIndex: number,\n): StacksTransaction {\n\tconst fields = [...condition.fields];\n\n\t// Replay sighash through existing fields\n\tlet curSigHash = initialSigHash(tx);\n\tfor (const field of fields) {\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n\t}\n\n\t// Fill intervening positions with pubkey fields\n\tfor (let i = fields.length; i < signerIndex; i++) {\n\t\tconst pubKeyField: TransactionAuthField = {\n\t\t\ttype: \"publicKey\",\n\t\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\tdata: publicKeys[i]!,\n\t\t};\n\t\tfields.push(pubKeyField);\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(\n\t\t\tpreSign,\n\t\t\tpubKeyField.pubKeyEncoding,\n\t\t\tpubKeyField.data,\n\t\t);\n\t}\n\n\t// Sign at signerIndex\n\tconst { nextSig, nextSigHash } = nextSignature(\n\t\tcurSigHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t\tprivateKey,\n\t);\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\tcurSigHash = nextSigHash;\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n\t// Count signatures so far\n\tconst sigCount = fields.filter((f) => f.type === \"signature\").length;\n\tlet finalCondition = newCondition;\n\n\t// Auto-finalize if enough signatures collected\n\tif (sigCount >= condition.signaturesRequired) {\n\t\tfinalCondition = finalizeMultiSigCondition(\n\t\t\tnewCondition,\n\t\t\tpublicKeys,\n\t\t\tcurSigHash,\n\t\t);\n\t}\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: finalCondition,\n\t\t},\n\t};\n}\n\n/** Sign one position of a multi-sig transaction with an account */\nexport async function signMultiSigWithAccount(\n\ttx: StacksTransaction,\n\taccount: LocalAccount | CustomAccount,\n\tpublicKeys: string[],\n): Promise<StacksTransaction> {\n\tconst signerPubKey = account.publicKey;\n\n\tconst signerIndex = publicKeys.findIndex((pk) => pk === signerPubKey);\n\tif (signerIndex === -1) {\n\t\tthrow new Error(\n\t\t\t\"Account does not correspond to any signer in the multi-sig\",\n\t\t);\n\t}\n\n\tconst condition = {\n\t\t...(tx.auth.spendingCondition as MultiSigSpendingCondition),\n\t};\n\n\t// Non-sequential: all signers sign the same presign-sighash independently\n\tif (isNonSequential(condition.hashMode)) {\n\t\treturn signNonSequentialWithAccount(tx, condition, account);\n\t}\n\n\t// Sequential: existing behavior\n\treturn signSequentialWithAccount(\n\t\ttx,\n\t\tcondition,\n\t\taccount,\n\t\tpublicKeys,\n\t\tsignerIndex,\n\t);\n}\n\n/** Non-sequential signing with account */\nasync function signNonSequentialWithAccount(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\taccount: LocalAccount | CustomAccount,\n): Promise<StacksTransaction> {\n\tconst fields = [...condition.fields];\n\tconst preSignHash = nonSequentialPreSignHash(tx);\n\n\tconst sigBytes = await account.sign(hexToBytes(preSignHash));\n\tconst nextSig = bytesToHex(sigBytes);\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n\treturn {\n\t\t...tx,\n\t\tauth: { ...tx.auth, spendingCondition: newCondition },\n\t};\n}\n\n/** Sequential signing with account */\nasync function signSequentialWithAccount(\n\ttx: StacksTransaction,\n\tcondition: MultiSigSpendingCondition,\n\taccount: LocalAccount | CustomAccount,\n\tpublicKeys: string[],\n\tsignerIndex: number,\n): Promise<StacksTransaction> {\n\tconst fields = [...condition.fields];\n\n\t// Replay sighash through existing fields\n\tlet curSigHash = initialSigHash(tx);\n\tfor (const field of fields) {\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(preSign, field.pubKeyEncoding, field.data);\n\t}\n\n\t// Fill intervening positions with pubkey fields\n\tfor (let i = fields.length; i < signerIndex; i++) {\n\t\tconst pubKeyField: TransactionAuthField = {\n\t\t\ttype: \"publicKey\",\n\t\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\tdata: publicKeys[i]!,\n\t\t};\n\t\tfields.push(pubKeyField);\n\t\tconst preSign = sigHashPreSign(\n\t\t\tcurSigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tcurSigHash = sigHashPostSign(\n\t\t\tpreSign,\n\t\t\tpubKeyField.pubKeyEncoding,\n\t\t\tpubKeyField.data,\n\t\t);\n\t}\n\n\t// Sign at signerIndex\n\tconst preSign = sigHashPreSign(\n\t\tcurSigHash,\n\t\tAuthType.Standard,\n\t\tcondition.fee,\n\t\tcondition.nonce,\n\t);\n\tconst sigBytes = await account.sign(hexToBytes(preSign));\n\tconst nextSig = bytesToHex(sigBytes);\n\tconst nextSigHash = sigHashPostSign(\n\t\tpreSign,\n\t\tPubKeyEncoding.Compressed,\n\t\tnextSig,\n\t);\n\n\tfields.push({\n\t\ttype: \"signature\",\n\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\tdata: nextSig,\n\t});\n\tcurSigHash = nextSigHash;\n\n\tconst newCondition: MultiSigSpendingCondition = { ...condition, fields };\n\n\t// Count signatures so far\n\tconst sigCount = fields.filter((f) => f.type === \"signature\").length;\n\tlet finalCondition = newCondition;\n\n\t// Auto-finalize if enough signatures collected\n\tif (sigCount >= condition.signaturesRequired) {\n\t\tfinalCondition = finalizeMultiSigCondition(\n\t\t\tnewCondition,\n\t\t\tpublicKeys,\n\t\t\tcurSigHash,\n\t\t);\n\t}\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: finalCondition,\n\t\t},\n\t};\n}\n\n/** Fill remaining slots with pubkey fields after all signatures are collected */\nexport function finalizeMultiSig(\n\ttx: StacksTransaction,\n\tpublicKeys: string[],\n): StacksTransaction {\n\tconst condition = tx.auth.spendingCondition as MultiSigSpendingCondition;\n\n\t// Non-sequential: no pubkey gap-filling needed\n\tif (isNonSequential(condition.hashMode)) {\n\t\treturn tx;\n\t}\n\n\tconst curSigHash = replayMultiSigSigHash(tx);\n\tconst finalCondition = finalizeMultiSigCondition(\n\t\tcondition,\n\t\tpublicKeys,\n\t\tcurSigHash,\n\t);\n\n\treturn {\n\t\t...tx,\n\t\tauth: {\n\t\t\t...tx.auth,\n\t\t\tspendingCondition: finalCondition,\n\t\t},\n\t};\n}\n\n/** Internal: finalize remaining pubkey slots (sequential only) */\nfunction finalizeMultiSigCondition(\n\tcondition: MultiSigSpendingCondition,\n\tpublicKeys: string[],\n\tcurSigHash: string,\n): MultiSigSpendingCondition {\n\tconst fields = [...condition.fields];\n\tlet sigHash = curSigHash;\n\n\t// Fill remaining positions\n\tfor (let i = fields.length; i < publicKeys.length; i++) {\n\t\tconst pubKeyField: TransactionAuthField = {\n\t\t\ttype: \"publicKey\",\n\t\t\tpubKeyEncoding: PubKeyEncoding.Compressed,\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\tdata: publicKeys[i]!,\n\t\t};\n\t\tfields.push(pubKeyField);\n\t\tconst preSign = sigHashPreSign(\n\t\t\tsigHash,\n\t\t\tAuthType.Standard,\n\t\t\tcondition.fee,\n\t\t\tcondition.nonce,\n\t\t);\n\t\tsigHash = sigHashPostSign(\n\t\t\tpreSign,\n\t\t\tpubKeyField.pubKeyEncoding,\n\t\t\tpubKeyField.data,\n\t\t);\n\t}\n\n\treturn { ...condition, fields };\n}\n\n/** Combine independently-signed non-sequential multi-sig transactions */\nexport function combineMultiSigSignatures(\n\tbaseTx: StacksTransaction,\n\tsignedTxs: StacksTransaction[],\n): StacksTransaction {\n\tconst condition = baseTx.auth.spendingCondition as MultiSigSpendingCondition;\n\n\tif (!isNonSequential(condition.hashMode)) {\n\t\tthrow new Error(\n\t\t\t\"combineMultiSigSignatures only works with non-sequential hash modes (SIP-027)\",\n\t\t);\n\t}\n\n\t// Collect all signature fields from each signed tx\n\tconst seenSigs = new Set<string>();\n\tconst signatures: TransactionAuthField[] = [];\n\n\tfor (const stx of signedTxs) {\n\t\tconst stxCondition = stx.auth\n\t\t\t.spendingCondition as MultiSigSpendingCondition;\n\t\tfor (const field of stxCondition.fields) {\n\t\t\tif (field.type === \"signature\" && !seenSigs.has(field.data)) {\n\t\t\t\tseenSigs.add(field.data);\n\t\t\t\tsignatures.push(field);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (signatures.length === 0) {\n\t\tthrow new Error(\"No signatures found in the provided transactions\");\n\t}\n\n\tconst newCondition: MultiSigSpendingCondition = {\n\t\t...condition,\n\t\tfields: signatures,\n\t};\n\n\treturn {\n\t\t...baseTx,\n\t\tauth: { ...baseTx.auth, spendingCondition: newCondition },\n\t};\n}\n",
    "import type { StacksChain } from \"../chains/types.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport { convertPostCondition, fromHex } from \"../postconditions/convert.ts\";\nimport type {\n\tPostConditionInput,\n\tPostConditionMode,\n} from \"../postconditions/types.ts\";\nimport { type IntegerType, intToBigInt } from \"../utils/encoding.ts\";\nimport {\n\tcreateSingleSigSpendingCondition,\n\tcreateSponsoredAuth,\n\tcreateStandardAuth,\n} from \"./authorization.ts\";\nimport { createMultiSigSpendingCondition } from \"./multisig.ts\";\nimport type { MultiSigHashMode, SpendingCondition } from \"./types.ts\";\nimport {\n\tAnchorMode,\n\tClarityVersion,\n\tPayloadType,\n\tPostConditionModeWire,\n\ttype StacksTransaction,\n} from \"./types.ts\";\n\ntype MultiSigOptions = {\n\tpublicKeys?: string[];\n\tsignaturesRequired?: number;\n\thashMode?: MultiSigHashMode;\n};\n\nexport type BuildTokenTransferOptions = MultiSigOptions & {\n\trecipient: string;\n\tamount: IntegerType;\n\tmemo?: string;\n\tfee: IntegerType;\n\tnonce: IntegerType;\n\tpublicKey?: string;\n\tchain?: StacksChain;\n\tpostConditionMode?: PostConditionMode;\n\tpostConditions?: PostConditionInput[];\n\tsponsored?: boolean;\n};\n\nexport type BuildContractCallOptions = MultiSigOptions & {\n\tcontractAddress: string;\n\tcontractName: string;\n\tfunctionName: string;\n\tfunctionArgs: ClarityValue[];\n\tfee: IntegerType;\n\tnonce: IntegerType;\n\tpublicKey?: string;\n\tchain?: StacksChain;\n\tpostConditionMode?: PostConditionMode;\n\tpostConditions?: PostConditionInput[];\n\tsponsored?: boolean;\n};\n\nexport type BuildContractDeployOptions = MultiSigOptions & {\n\tcontractName: string;\n\tcodeBody: string;\n\tclarityVersion?: ClarityVersion;\n\tfee: IntegerType;\n\tnonce: IntegerType;\n\tpublicKey?: string;\n\tchain?: StacksChain;\n\tpostConditionMode?: PostConditionMode;\n\tpostConditions?: PostConditionInput[];\n\tsponsored?: boolean;\n};\n\nfunction resolvePcMode(mode?: PostConditionMode): PostConditionModeWire {\n\tif (mode === \"allow\") return PostConditionModeWire.Allow;\n\tif (mode === \"originator\") return PostConditionModeWire.Originator;\n\treturn PostConditionModeWire.Deny;\n}\n\nfunction convertPostConditions(\n\tpcs?: PostConditionInput[],\n): ReturnType<typeof convertPostCondition>[] {\n\tif (!pcs || pcs.length === 0) return [];\n\treturn pcs.map((pc) =>\n\t\tconvertPostCondition(typeof pc === \"string\" ? fromHex(pc) : pc),\n\t);\n}\n\nimport type { Authorization } from \"./types.ts\";\n\nfunction resolveSpendingCondition(\n\topts: MultiSigOptions & { publicKey?: string },\n\tnonce: bigint,\n\tfee: bigint,\n): SpendingCondition {\n\tif (opts.publicKeys) {\n\t\treturn createMultiSigSpendingCondition(\n\t\t\topts.publicKeys,\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\topts.signaturesRequired!,\n\t\t\tnonce,\n\t\t\tfee,\n\t\t\topts.hashMode,\n\t\t);\n\t}\n\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\treturn createSingleSigSpendingCondition(opts.publicKey!, nonce, fee);\n}\n\nfunction resolveAuth(\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tspendingCondition: any,\n\tsponsored?: boolean,\n): Authorization {\n\treturn sponsored\n\t\t? createSponsoredAuth(spendingCondition)\n\t\t: createStandardAuth(spendingCondition);\n}\n\nfunction resolveVersionAndChainId(chain?: StacksChain): {\n\tversion: number;\n\tchainId: number;\n} {\n\tif (!chain) return { version: 0x00, chainId: 0x00000001 }; // mainnet defaults\n\treturn { version: chain.transactionVersion, chainId: chain.id };\n}\n\nexport function buildTokenTransfer(\n\toptions: BuildTokenTransferOptions,\n): StacksTransaction {\n\tconst { version, chainId } = resolveVersionAndChainId(options.chain);\n\tconst fee = intToBigInt(options.fee);\n\tconst nonce = intToBigInt(options.nonce);\n\n\tconst spendingCondition = resolveSpendingCondition(options, nonce, fee);\n\tconst recipient = Cl.principal(options.recipient);\n\n\tconst tx: StacksTransaction = {\n\t\tversion,\n\t\tchainId,\n\t\tauth: resolveAuth(spendingCondition, options.sponsored),\n\t\tanchorMode: AnchorMode.Any,\n\t\tpostConditionMode: resolvePcMode(options.postConditionMode),\n\t\tpostConditions: convertPostConditions(options.postConditions),\n\t\tpayload: {\n\t\t\tpayloadType: PayloadType.TokenTransfer,\n\t\t\trecipient,\n\t\t\tamount: intToBigInt(options.amount),\n\t\t\tmemo: options.memo ?? \"\",\n\t\t},\n\t};\n\n\tif (options.publicKeys) {\n\t\ttx._multisig = { publicKeys: options.publicKeys };\n\t}\n\treturn tx;\n}\n\nexport function buildContractCall(\n\toptions: BuildContractCallOptions,\n): StacksTransaction {\n\tconst { version, chainId } = resolveVersionAndChainId(options.chain);\n\tconst fee = intToBigInt(options.fee);\n\tconst nonce = intToBigInt(options.nonce);\n\n\tconst spendingCondition = resolveSpendingCondition(options, nonce, fee);\n\n\tconst tx: StacksTransaction = {\n\t\tversion,\n\t\tchainId,\n\t\tauth: resolveAuth(spendingCondition, options.sponsored),\n\t\tanchorMode: AnchorMode.Any,\n\t\tpostConditionMode: resolvePcMode(options.postConditionMode),\n\t\tpostConditions: convertPostConditions(options.postConditions),\n\t\tpayload: {\n\t\t\tpayloadType: PayloadType.ContractCall,\n\t\t\tcontractAddress: options.contractAddress,\n\t\t\tcontractName: options.contractName,\n\t\t\tfunctionName: options.functionName,\n\t\t\tfunctionArgs: options.functionArgs,\n\t\t},\n\t};\n\n\tif (options.publicKeys) {\n\t\ttx._multisig = { publicKeys: options.publicKeys };\n\t}\n\treturn tx;\n}\n\nexport function buildContractDeploy(\n\toptions: BuildContractDeployOptions,\n): StacksTransaction {\n\tconst { version, chainId } = resolveVersionAndChainId(options.chain);\n\tconst fee = intToBigInt(options.fee);\n\tconst nonce = intToBigInt(options.nonce);\n\n\tconst spendingCondition = resolveSpendingCondition(options, nonce, fee);\n\tconst clarityVersion = options.clarityVersion ?? ClarityVersion.Clarity4;\n\n\tconst tx: StacksTransaction = {\n\t\tversion,\n\t\tchainId,\n\t\tauth: resolveAuth(spendingCondition, options.sponsored),\n\t\tanchorMode: AnchorMode.Any,\n\t\tpostConditionMode: resolvePcMode(options.postConditionMode),\n\t\tpostConditions: convertPostConditions(options.postConditions),\n\t\tpayload: {\n\t\t\tpayloadType: PayloadType.VersionedSmartContract,\n\t\t\tclarityVersion,\n\t\t\tcontractName: options.contractName,\n\t\t\tcodeBody: options.codeBody,\n\t\t},\n\t};\n\n\tif (options.publicKeys) {\n\t\ttx._multisig = { publicKeys: options.publicKeys };\n\t}\n\treturn tx;\n}\n",
    "import type { Client } from \"../../clients/types.ts\";\nimport { MalformedResponseError } from \"../../errors/response.ts\";\n\nexport type GetNonceParams = {\n\taddress: string;\n};\n\nexport type GetNonceResult = {\n\tnonce: bigint;\n\tpossibleNextNonce: bigint;\n};\n\nexport async function getNonce(\n\tclient: Client,\n\tparams: GetNonceParams,\n): Promise<bigint> {\n\tconst data = await client.request(\n\t\t`/v2/accounts/${encodeURIComponent(params.address)}`,\n\t\t{ method: \"GET\" },\n\t);\n\tconst nonce = (data as { nonce?: unknown })?.nonce;\n\tif (typeof nonce !== \"number\" && typeof nonce !== \"string\") {\n\t\tthrow new MalformedResponseError(\n\t\t\t`getNonce: /v2/accounts/${params.address} response is missing \"nonce\"`,\n\t\t);\n\t}\n\treturn BigInt(nonce);\n}\n",
    "import { deserializeCVBytes } from \"../../clarity/deserialize.ts\";\nimport { serializeCVBytes } from \"../../clarity/serialize.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport {\n\tMalformedResponseError,\n\tReadContractError,\n} from \"../../errors/response.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\nimport { bytesToHex, with0x } from \"../../utils/encoding.ts\";\n\nexport type ReadContractParams = {\n\tcontract: string; // \"address.name\"\n\tfunctionName: string;\n\targs?: ClarityValue[];\n\tsender?: string;\n\t/**\n\t * Nakamoto StacksBlockId to evaluate against. Without it the node answers\n\t * at its own moving tip, which makes a read non-deterministic — the same\n\t * reindex of the same block can return a different value.\n\t */\n\ttip?: string;\n};\n\nexport async function readContract<T extends ClarityValue = ClarityValue>(\n\tclient: Client,\n\tparams: ReadContractParams,\n): Promise<T> {\n\tconst [address, name] = parseContractId(params.contract);\n\tconst sender = params.sender ?? address;\n\n\tconst serializedArgs = (params.args ?? []).map((arg) =>\n\t\twith0x(bytesToHex(serializeCVBytes(arg))),\n\t);\n\n\tconst path = `/v2/contracts/call-read/${encodeURIComponent(address)}/${encodeURIComponent(name)}/${encodeURIComponent(params.functionName)}`;\n\tconst data = await client.request(\n\t\tparams.tip ? `${path}?tip=${encodeURIComponent(params.tip)}` : path,\n\t\t{\n\t\t\tmethod: \"POST\",\n\t\t\tbody: {\n\t\t\t\tsender,\n\t\t\t\targuments: serializedArgs,\n\t\t\t},\n\t\t},\n\t);\n\n\tif (data.okay) {\n\t\tif (typeof data.result !== \"string\") {\n\t\t\tthrow new MalformedResponseError(\n\t\t\t\t`readContract: /v2/contracts/call-read response is missing \"result\"`,\n\t\t\t);\n\t\t}\n\t\treturn deserializeCVBytes<T>(data.result);\n\t}\n\tthrow new ReadContractError(data.cause ?? \"Read-only call failed\");\n}\n",
    "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",
    "import { BaseError } from \"./base.ts\";\n\n/** Thrown by the HTTP transport when a response's status isn't 2xx. */\nexport class HttpRequestError extends BaseError {\n\toverride name = \"HttpRequestError\";\n\tstatus: number;\n\t/** Request URL, when the transport knows it. */\n\turl?: string;\n\t/** Request method, when the transport knows it. */\n\tmethod?: string;\n\n\tconstructor(\n\t\tstatus: number,\n\t\toptions?: {\n\t\t\tcause?: Error;\n\t\t\tdetails?: string;\n\t\t\turl?: string;\n\t\t\tmethod?: string;\n\t\t},\n\t) {\n\t\tconst where =\n\t\t\toptions?.url !== undefined\n\t\t\t\t? ` (${options.method ?? \"GET\"} ${options.url})`\n\t\t\t\t: \"\";\n\t\tsuper(`HTTP request failed with status ${status}${where}`, options);\n\t\tthis.status = status;\n\t\tthis.url = options?.url;\n\t\tthis.method = options?.method;\n\t}\n}\n",
    "import { BaseError } from \"./base.ts\";\n\n/**\n * Thrown by the HTTP transport when a request, headers and body included,\n * does not finish inside `timeout`. Carries enough to tell which endpoint\n * stalled and on which retry attempt. A caller-supplied `signal` abort is\n * NOT a timeout: that rejects with the signal's own reason and never retries.\n */\nexport class TimeoutError extends BaseError {\n\toverride name = \"TimeoutError\";\n\tmethod: string;\n\turl: string;\n\ttimeout: number;\n\t/** Zero-based attempt index at which the timeout fired. */\n\tattempt: number;\n\n\tconstructor(params: {\n\t\tmethod: string;\n\t\turl: string;\n\t\ttimeout: number;\n\t\tattempt: number;\n\t}) {\n\t\tsuper(\n\t\t\t`${params.method} ${params.url} did not complete within ${params.timeout}ms (attempt ${params.attempt + 1})`,\n\t\t);\n\t\tthis.method = params.method;\n\t\tthis.url = params.url;\n\t\tthis.timeout = params.timeout;\n\t\tthis.attempt = params.attempt;\n\t}\n}\n",
    "import { HttpRequestError } from \"../errors/http.ts\";\nimport { TimeoutError } from \"../errors/transport.ts\";\nimport type {\n\tRequestFn,\n\tRequestOptions,\n\tTransport,\n\tTransportConfig,\n} from \"./types.ts\";\n\n/** Bind a request function into a transport. The exposed `config` never\n *  carries `apiKey`: the key lives in the request closure, so logging a\n *  client or inspecting `client.transport.config` does not print it. */\nexport function createTransport(\n\ttype: string,\n\tconfig: TransportConfig & { request: RequestFn },\n): Transport {\n\tconst { request, apiKey: _apiKey, ...exposed } = config;\n\treturn {\n\t\ttype,\n\t\trequest,\n\t\tconfig: exposed,\n\t};\n}\n\n/** Longest response body kept on `HttpRequestError.details`. The body is\n *  untrusted and lands in `error.message`, so a runaway HTML page or a\n *  hostile reply must not become a multi-megabyte log line. */\nexport const MAX_ERROR_DETAILS_BYTES = 4096;\n\nfunction capDetails(body: string | undefined): string | undefined {\n\tif (body === undefined) return undefined;\n\tconst bytes = new TextEncoder().encode(body);\n\tif (bytes.length <= MAX_ERROR_DETAILS_BYTES) return body;\n\tconst head = new TextDecoder().decode(\n\t\tbytes.subarray(0, MAX_ERROR_DETAILS_BYTES),\n\t);\n\treturn `${head}... [truncated ${bytes.length - MAX_ERROR_DETAILS_BYTES} bytes]`;\n}\n\n/** 5xx and 429 are transient and worth a retry. Every other status is not. */\nfunction isRetryableStatus(status: number): boolean {\n\treturn status === 429 || status >= 500;\n}\n\n/** Retry-After above this cap falls back to the normal backoff: a node\n *  asking for minutes should not stall a transport-level retry. */\nconst MAX_RETRY_AFTER_MS = 60_000;\n\n/** Parse a `Retry-After` header (delta-seconds or HTTP-date) into a delay,\n *  or undefined when absent/unparseable/over the cap. */\nfunction retryAfterMs(response: Response): number | undefined {\n\tconst value = response.headers.get(\"Retry-After\");\n\tif (!value) return undefined;\n\tconst seconds = Number(value);\n\tconst ms = Number.isFinite(seconds)\n\t\t? seconds * 1000\n\t\t: Date.parse(value) - Date.now();\n\tif (!Number.isFinite(ms) || ms < 0 || ms > MAX_RETRY_AFTER_MS)\n\t\treturn undefined;\n\treturn ms;\n}\n\nfunction abortReason(signal: AbortSignal): Error {\n\tconst reason = signal.reason;\n\tif (reason instanceof Error) return reason;\n\treturn new DOMException(\n\t\ttypeof reason === \"string\" ? reason : \"The operation was aborted\",\n\t\t\"AbortError\",\n\t);\n}\n\n/** Sleep that wakes early (rejecting with the abort reason) when `signal` fires. */\nfunction sleep(ms: number, signal?: AbortSignal): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal?.aborted) return reject(abortReason(signal));\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(id);\n\t\t\treject(abortReason(signal as AbortSignal));\n\t\t};\n\t\tconst id = setTimeout(() => {\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve();\n\t\t}, ms);\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n}\n\nexport type FetchWithRetryOptions<T> = {\n\t/** Caller-side cancellation. Combined with the timeout; never retried. */\n\tsignal?: AbortSignal;\n\t/**\n\t * Consume the response body inside the timeout window. Defaults to\n\t * returning the `Response` untouched, in which case the caller reads the\n\t * body outside the deadline.\n\t */\n\tread?: (response: Response) => Promise<T>;\n};\n\n/**\n * Fetch with linear backoff on network errors, timeouts, 429 and 5xx.\n *\n * One timeout covers each attempt end to end, headers and body: the timer is\n * armed before `fetch` and cleared once the attempt settles (before any\n * retry sleep, and in `finally`), so a body that never arrives rejects with\n * {@link TimeoutError} rather than hanging the caller, and a rejected fetch\n * never leaves a live timer behind.\n * A caller abort (`signal`) rejects at once with the signal's reason and is\n * not retried.\n */\nexport async function fetchWithRetry<T = Response>(\n\turl: string,\n\toptions: RequestInit,\n\tretryCount: number,\n\tretryDelay: number,\n\ttimeout: number,\n\textra: FetchWithRetryOptions<T> = {},\n): Promise<T> {\n\tconst { signal } = extra;\n\tconst read =\n\t\textra.read ?? (async (response: Response) => response as unknown as T);\n\tconst method = options.method ?? \"GET\";\n\tlet lastError: Error | undefined;\n\n\tfor (let attempt = 0; attempt <= retryCount; attempt++) {\n\t\tif (signal?.aborted) throw abortReason(signal);\n\n\t\tconst controller = new AbortController();\n\t\tlet timedOut = false;\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\ttimedOut = true;\n\t\t\tcontroller.abort(new TimeoutError({ method, url, timeout, attempt }));\n\t\t}, timeout);\n\t\tconst onCallerAbort = () =>\n\t\t\tcontroller.abort(abortReason(signal as AbortSignal));\n\t\tsignal?.addEventListener(\"abort\", onCallerAbort, { once: true });\n\n\t\t// Rejects the moment the attempt is aborted, whether by the timer or by\n\t\t// the caller, so a body read on a stalled stream cannot outlive the\n\t\t// deadline even when the runtime does not tie the body to the signal.\n\t\tconst aborted = new Promise<never>((_, reject) => {\n\t\t\tif (controller.signal.aborted) return reject(controller.signal.reason);\n\t\t\tcontroller.signal.addEventListener(\n\t\t\t\t\"abort\",\n\t\t\t\t() => reject(controller.signal.reason),\n\t\t\t\t{ once: true },\n\t\t\t);\n\t\t});\n\n\t\tlet response: Response;\n\t\ttry {\n\t\t\ttry {\n\t\t\t\tresponse = await Promise.race([\n\t\t\t\t\tfetch(url, { ...options, signal: controller.signal }),\n\t\t\t\t\taborted,\n\t\t\t\t]);\n\t\t\t} catch (error) {\n\t\t\t\tif (signal?.aborted) throw abortReason(signal);\n\t\t\t\tlastError = timedOut\n\t\t\t\t\t? new TimeoutError({ method, url, timeout, attempt })\n\t\t\t\t\t: error instanceof Error\n\t\t\t\t\t\t? error\n\t\t\t\t\t\t: new Error(String(error));\n\t\t\t\tif (attempt < retryCount) {\n\t\t\t\t\tclearTimeout(timeoutId);\n\t\t\t\t\tawait sleep(retryDelay * (attempt + 1), signal);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tthrow lastError;\n\t\t\t}\n\n\t\t\tif (response.ok) {\n\t\t\t\ttry {\n\t\t\t\t\treturn await Promise.race([read(response), aborted]);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tresponse.body?.cancel().catch(() => {});\n\t\t\t\t\tif (signal?.aborted) throw abortReason(signal);\n\t\t\t\t\tif (!timedOut) throw error;\n\t\t\t\t\tlastError = new TimeoutError({ method, url, timeout, attempt });\n\t\t\t\t\tif (attempt < retryCount) {\n\t\t\t\t\t\tclearTimeout(timeoutId);\n\t\t\t\t\t\tawait sleep(retryDelay * (attempt + 1), signal);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tthrow lastError;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst retryable = isRetryableStatus(response.status);\n\t\t\tif (!retryable || attempt === retryCount) {\n\t\t\t\tconst body = await Promise.race([\n\t\t\t\t\tresponse.text().catch(() => undefined),\n\t\t\t\t\taborted.catch(() => undefined),\n\t\t\t\t]);\n\t\t\t\tthrow new HttpRequestError(response.status, {\n\t\t\t\t\tdetails: capDetails(body),\n\t\t\t\t\turl,\n\t\t\t\t\tmethod,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlastError = new HttpRequestError(response.status, { url, method });\n\t\t\t// A server-sent Retry-After (429/503) overrides the linear backoff.\n\t\t\tconst delay = retryAfterMs(response) ?? retryDelay * (attempt + 1);\n\t\t\tresponse.body?.cancel().catch(() => {});\n\t\t\t// The attempt is over: a Retry-After longer than `timeout` must not\n\t\t\t// let the attempt timer fire mid-sleep and flag a timeout that never\n\t\t\t// happened.\n\t\t\tclearTimeout(timeoutId);\n\t\t\tawait sleep(delay, signal);\n\t\t} finally {\n\t\t\tclearTimeout(timeoutId);\n\t\t\tsignal?.removeEventListener(\"abort\", onCallerAbort);\n\t\t}\n\t}\n\n\tthrow lastError ?? new Error(\"Request failed\");\n}\n\n/** Decode a 2xx body: JSON when the content type says so, text otherwise. */\nexport async function readBody(response: Response): Promise<unknown> {\n\tconst contentType = response.headers.get(\"content-type\") ?? \"\";\n\tif (contentType.includes(\"application/json\")) {\n\t\treturn response.json();\n\t}\n\treturn response.text();\n}\n\nexport function buildRequestFn(\n\tbaseUrl: string,\n\tconfig: TransportConfig,\n): RequestFn {\n\tconst {\n\t\ttimeout = 30_000,\n\t\tretryCount = 3,\n\t\tretryDelay = 150,\n\t\tfetchOptions = {},\n\t\tapiKey,\n\t} = config;\n\n\treturn async (path: string, options?: RequestOptions) => {\n\t\tconst url = `${baseUrl.replace(/\\/$/, \"\")}${path}`;\n\t\tconst headers: Record<string, string> = {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t...(fetchOptions.headers as Record<string, string>),\n\t\t\t...options?.headers,\n\t\t};\n\n\t\tif (apiKey) {\n\t\t\theaders[\"x-api-key\"] = apiKey;\n\t\t}\n\n\t\tconst init: RequestInit = {\n\t\t\t...fetchOptions,\n\t\t\tmethod: options?.method ?? \"GET\",\n\t\t\theaders,\n\t\t};\n\n\t\tif (options?.body !== undefined) {\n\t\t\tinit.body = JSON.stringify(options.body);\n\t\t}\n\n\t\treturn fetchWithRetry(\n\t\t\turl,\n\t\t\tinit,\n\t\t\toptions?.retryCount ?? retryCount,\n\t\t\tretryDelay,\n\t\t\ttimeout,\n\t\t\t{ signal: options?.signal, read: readBody },\n\t\t);\n\t};\n}\n",
    "import { deserializeCVBytes } from \"../../clarity/deserialize.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { HttpRequestError } from \"../../errors/http.ts\";\nimport { buildRequestFn } from \"../../transports/createTransport.ts\";\nimport type { RequestFn } from \"../../transports/types.ts\";\n\n/**\n * Pluggable transaction-status sources for {@link getTransaction} /\n * `waitForTransactionReceipt`.\n *\n * A bare stacks-node has no confirmed-transaction endpoint, so status reads\n * need a host that indexes transactions. Where that data comes from is\n * pluggable, mirroring the nonce sources:\n *\n *   - {@link extendedApiSource} — default; `/extended/v1/tx/{txid}` on the\n *     client's transport host (Hiro API or any extended-API-compatible host).\n *   - {@link indexTxSource}: a Secondlayer instance's\n *     `/v1/index/transactions/{txid}`; returns the chain tip in the same\n *     response, so N-confirmation waits need no second request.\n */\n\nexport type TransactionStatus =\n\t| \"pending\"\n\t| \"success\"\n\t| \"abort_by_response\"\n\t| \"abort_by_post_condition\"\n\t| \"dropped\";\n\nexport type TransactionReceipt = {\n\ttxid: string;\n\tstatus: TransactionStatus;\n\t/** Anchor block height; absent while pending. */\n\tblockHeight?: number;\n\tblockHash?: string;\n\t/** Decoded Clarity result; absent while pending or when the source omits it. */\n\tresult?: ClarityValue;\n\tresultHex?: string;\n\tevents: unknown[];\n\t/** The source's unnormalized response, for fields the receipt doesn't model. */\n\traw: unknown;\n};\n\nexport type TransactionSnapshot = {\n\t/** `null` when the source has no record of the tx (mempool + chain). */\n\treceipt: TransactionReceipt | null;\n\t/** Chain tip height, when the source knows it (saves a round-trip). */\n\ttip?: number;\n};\n\nexport type TransactionStatusSource = {\n\tget(args: { client: Client; txid: string }): Promise<TransactionSnapshot>;\n\t/**\n\t * True when the source only knows mined transactions and reports\n\t * `receipt: null` for the whole mempool life of a tx. The wait action\n\t * then stretches its dropped-grace window to the full timeout, since\n\t * \"unknown\" cannot mean \"dropped\" until the deadline.\n\t */\n\tcanonicalOnly?: boolean;\n};\n\n/**\n * Thrown when an index-backed source cannot reach a Secondlayer instance\n * because of how it was configured (no URL, a Hiro host, a bare node).\n * Sources that degrade on transient failures let this one through: a\n * misconfiguration would otherwise degrade silently on every read.\n */\nexport class IndexSourceConfigError extends Error {\n\toverride name = \"IndexSourceConfigError\";\n}\n\n/** Hosts that serve Hiro's API, never a Secondlayer instance. */\nfunction isHiroHost(url: string, client: Client): boolean {\n\tlet hostname: string;\n\ttry {\n\t\thostname = new URL(url).hostname;\n\t} catch {\n\t\treturn false;\n\t}\n\tif (hostname === \"hiro.so\" || hostname.endsWith(\".hiro.so\")) return true;\n\tconst defaults = client.chain?.rpcUrls?.default?.http ?? [];\n\treturn defaults.some((d) => {\n\t\ttry {\n\t\t\treturn new URL(d).hostname === hostname && hostname !== \"localhost\";\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t});\n}\n\n/**\n * Pick the request function for a Secondlayer index route. With no\n * `baseUrl` the client's transport URL is taken to be the instance and\n * `client.request` carries its retries, timeout and auth; a transport\n * pointed at a Hiro host throws instead of polling routes it cannot serve.\n * A different `baseUrl` gets the transport's retry and timeout policy\n * bound to that host. Only policy crosses over: the transport's `apiKey`\n * and `fetchOptions` were issued for the transport host and never travel\n * to another one.\n */\nexport function indexRequestFn(\n\tclient: Client,\n\tbaseUrl: string | undefined,\n\tsourceName: string,\n): RequestFn {\n\tconst transportUrl = client.transport.config.url?.replace(/\\/$/, \"\");\n\tif (baseUrl === undefined) {\n\t\tif (!transportUrl) {\n\t\t\tthrow new IndexSourceConfigError(\n\t\t\t\t`${sourceName} needs the URL of your Secondlayer instance: pass baseUrl, or use an http() transport pointed at the instance`,\n\t\t\t);\n\t\t}\n\t\tif (isHiroHost(transportUrl, client)) {\n\t\t\tthrow new IndexSourceConfigError(\n\t\t\t\t`${sourceName} reads /v1/index on a Secondlayer instance, and ${transportUrl} is a Hiro host: pass baseUrl with the URL of your instance`,\n\t\t\t);\n\t\t}\n\t\treturn client.request;\n\t}\n\tconst target = baseUrl.replace(/\\/$/, \"\");\n\tif (target === transportUrl) return client.request;\n\tconst { timeout, retryCount, retryDelay } = client.transport.config;\n\treturn buildRequestFn(target, { timeout, retryCount, retryDelay });\n}\n\n/**\n * An instance answers an unknown tx with a JSON 404.\n * A 404 with a non-JSON body comes from a host that does not serve\n * `/v1/index` at all (a bare stacks-node, an unmatched route), so it is a\n * configuration error rather than \"not mined yet\".\n */\nexport function indexNotFound(\n\terror: unknown,\n\tsourceName: string,\n): error is HttpRequestError {\n\tif (!(error instanceof HttpRequestError) || error.status !== 404) {\n\t\treturn false;\n\t}\n\tconst body = error.details;\n\tif (body !== undefined) {\n\t\ttry {\n\t\t\tJSON.parse(body);\n\t\t} catch {\n\t\t\tthrow new IndexSourceConfigError(\n\t\t\t\t`${sourceName} got a non-JSON 404 from ${error.url ?? \"the transport host\"}: it does not serve /v1/index, pass baseUrl with the URL of your Secondlayer instance`,\n\t\t\t\t{ cause: error },\n\t\t\t);\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction normalizeTxid(txid: string): string {\n\treturn txid.startsWith(\"0x\") ? txid : `0x${txid}`;\n}\n\nfunction decodeResultHex(hex: string | null | undefined): {\n\tresult?: ClarityValue;\n\tresultHex?: string;\n} {\n\tif (!hex) return {};\n\ttry {\n\t\treturn { result: deserializeCVBytes(hex), resultHex: hex };\n\t} catch {\n\t\treturn { resultHex: hex };\n\t}\n}\n\n/** Map a Hiro `tx_status` string onto the receipt vocabulary. */\nfunction normalizeStatus(txStatus: string): TransactionStatus | undefined {\n\tswitch (txStatus) {\n\t\tcase \"pending\":\n\t\tcase \"success\":\n\t\tcase \"abort_by_response\":\n\t\tcase \"abort_by_post_condition\":\n\t\t\treturn txStatus;\n\t\tdefault:\n\t\t\treturn txStatus.startsWith(\"dropped\") ? \"dropped\" : undefined;\n\t}\n}\n\n/**\n * Default source: `GET /extended/v1/tx/{txid}` via the client's transport.\n * Requires a host that serves Hiro's extended API (a bare stacks-node does\n * not). Does not report the chain tip — the wait action fetches it separately\n * when `confirmations > 1`.\n */\nexport function extendedApiSource(): TransactionStatusSource {\n\treturn {\n\t\tasync get({ client, txid }) {\n\t\t\tlet data: Awaited<ReturnType<Client[\"request\"]>>;\n\t\t\ttry {\n\t\t\t\tdata = await client.request(\n\t\t\t\t\t`/extended/v1/tx/${encodeURIComponent(normalizeTxid(txid))}`,\n\t\t\t\t\t{ method: \"GET\" },\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof HttpRequestError && error.status === 404) {\n\t\t\t\t\treturn { receipt: null };\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tconst txStatus =\n\t\t\t\ttypeof data?.tx_status === \"string\" ? data.tx_status : undefined;\n\t\t\tif (!txStatus) return { receipt: null }; // unexpected shape\n\n\t\t\tconst status = normalizeStatus(txStatus);\n\t\t\tif (!status) return { receipt: null };\n\n\t\t\treturn {\n\t\t\t\treceipt: {\n\t\t\t\t\ttxid: normalizeTxid(txid),\n\t\t\t\t\tstatus,\n\t\t\t\t\tblockHeight:\n\t\t\t\t\t\ttypeof data.block_height === \"number\" && data.block_height > 0\n\t\t\t\t\t\t\t? data.block_height\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tblockHash: data.block_hash ?? undefined,\n\t\t\t\t\t...decodeResultHex(data.tx_result?.hex),\n\t\t\t\t\tevents: Array.isArray(data.events) ? data.events : [],\n\t\t\t\t\traw: data,\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n\nexport type IndexTxSourceParams = {\n\t/**\n\t * URL of your Secondlayer instance. Without it the client's transport\n\t * URL is assumed to be the instance: a transport on a Hiro host throws\n\t * up front, and a host that answers `/v1/index` with a non-JSON 404\n\t * (a bare stacks-node) throws on the first read. Pass it whenever the\n\t * transport is not the instance.\n\t */\n\tbaseUrl?: string;\n\t/** Instance token, sent as `Authorization: Bearer`. */\n\tapiKey?: string;\n};\n\n/**\n * Source backed by a Secondlayer instance's `/v1/index/transactions/{txid}`.\n * The response embeds the chain tip, so N-confirmation math needs no extra\n * request. Requests go through the transport layer: same retries, timeout\n * and typed errors as every other read. The index only returns canonical\n * (mined) transactions; while a tx is in the mempool this source reports\n * `receipt: null`, and the wait action's grace window carries it until\n * inclusion.\n */\nexport function indexTxSource(\n\tparams: IndexTxSourceParams = {},\n): TransactionStatusSource {\n\tconst headers = params.apiKey\n\t\t? { authorization: `Bearer ${params.apiKey}` }\n\t\t: undefined;\n\n\treturn {\n\t\tcanonicalOnly: true,\n\t\tasync get({ client, txid }) {\n\t\t\tconst request = indexRequestFn(client, params.baseUrl, \"indexTxSource\");\n\t\t\tlet data: {\n\t\t\t\ttransaction?: {\n\t\t\t\t\ttx_id: string;\n\t\t\t\t\tblock_height: number;\n\t\t\t\t\tstatus: string;\n\t\t\t\t\tcontract_call?: { result_hex: string | null };\n\t\t\t\t};\n\t\t\t\ttip?: { block_height: number };\n\t\t\t};\n\t\t\ttry {\n\t\t\t\tdata = await request(`/v1/index/transactions/${normalizeTxid(txid)}`, {\n\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\theaders,\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tif (indexNotFound(error, \"indexTxSource\")) return { receipt: null };\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tconst tx = data.transaction;\n\t\t\tconst tip = data.tip?.block_height;\n\t\t\tif (!tx) return { receipt: null, tip };\n\n\t\t\tconst status = normalizeStatus(tx.status) ?? \"success\";\n\t\t\treturn {\n\t\t\t\treceipt: {\n\t\t\t\t\ttxid: normalizeTxid(tx.tx_id),\n\t\t\t\t\tstatus,\n\t\t\t\t\tblockHeight: tx.block_height,\n\t\t\t\t\t...decodeResultHex(tx.contract_call?.result_hex),\n\t\t\t\t\tevents: [],\n\t\t\t\t\traw: data,\n\t\t\t\t},\n\t\t\t\ttip,\n\t\t\t};\n\t\t},\n\t};\n}\n",
    "import type { Client } from \"../../clients/types.ts\";\nimport {\n\ttype TransactionReceipt,\n\ttype TransactionStatusSource,\n\textendedApiSource,\n} from \"./txSources.ts\";\n\nexport type GetTransactionParams = {\n\ttxid: string;\n\t/** Where to read status from. Defaults to {@link extendedApiSource}. */\n\tsource?: TransactionStatusSource;\n};\n\n/**\n * Fetch a transaction's receipt (status, block info, decoded result).\n * Returns `null` when the source has no record of the transaction.\n */\nexport async function getTransaction(\n\tclient: Client,\n\tparams: GetTransactionParams,\n): Promise<TransactionReceipt | null> {\n\tconst source = params.source ?? extendedApiSource();\n\tconst { receipt } = await source.get({ client, txid: params.txid });\n\treturn receipt;\n}\n",
    "import type { Client } from \"../../clients/types.ts\";\nimport { MalformedResponseError } from \"../../errors/response.ts\";\n\nexport async function getBlockHeight(client: Client): Promise<number> {\n\tconst data = await client.request(\"/v2/info\", { method: \"GET\" });\n\tif (typeof data?.stacks_tip_height !== \"number\") {\n\t\tthrow new MalformedResponseError(\n\t\t\t'getBlockHeight: /v2/info response is missing \"stacks_tip_height\"',\n\t\t);\n\t}\n\treturn data.stacks_tip_height;\n}\n",
    "import type { Client } from \"../../clients/types.ts\";\nimport {\n\tTransactionAbortedError,\n\tTransactionDroppedError,\n\tWaitForTransactionTimeoutError,\n} from \"../../errors/transaction.ts\";\nimport { getBlockHeight } from \"./getBlockHeight.ts\";\nimport {\n\ttype TransactionReceipt,\n\ttype TransactionStatusSource,\n\textendedApiSource,\n} from \"./txSources.ts\";\n\nexport type WaitForTransactionReceiptParams = {\n\ttxid: string;\n\t/** Anchor-block confirmations to wait for. Default 1 (mined). */\n\tconfirmations?: number;\n\t/** Give up after this many ms. Default 180_000 (3 min). */\n\ttimeout?: number;\n\t/** Delay between status polls, ms. Default 3_000. */\n\tpollingInterval?: number;\n\t/**\n\t * How long a tx may be unknown to the source before it counts as dropped,\n\t * ms. Covers broadcast propagation lag. Default 30_000, or the full\n\t * `timeout` for a canonical-only source (one that cannot see the\n\t * mempool, so \"unknown\" means \"not mined yet\" until the deadline).\n\t */\n\tdroppedGracePeriod?: number;\n\t/** Where to read status from. Defaults to {@link extendedApiSource}. */\n\tsource?: TransactionStatusSource;\n};\n\nconst sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));\n\n/**\n * Poll until a transaction is mined with N confirmations, then return its\n * receipt.\n *\n * Rejects with {@link TransactionAbortedError} when the tx mines but aborts\n * (`abort_by_response` / `abort_by_post_condition`) — the receipt is attached.\n * Rejects with {@link TransactionDroppedError} when the tx leaves the mempool\n * unmined or stays unknown past `droppedGracePeriod`, and\n * {@link WaitForTransactionTimeoutError} at `timeout`.\n *\n * Reorg-tolerant: every cycle re-reads the receipt (block height may change)\n * and recomputes confirmations from the current tip.\n */\nexport async function waitForTransactionReceipt(\n\tclient: Client,\n\tparams: WaitForTransactionReceiptParams,\n): Promise<TransactionReceipt> {\n\tconst {\n\t\ttxid,\n\t\tconfirmations = 1,\n\t\ttimeout = 180_000,\n\t\tpollingInterval = 3_000,\n\t} = params;\n\tconst source = params.source ?? extendedApiSource();\n\tconst droppedGracePeriod =\n\t\tparams.droppedGracePeriod ?? (source.canonicalOnly ? timeout : 30_000);\n\n\tconst startedAt = Date.now();\n\tlet unknownSince: number | null = null;\n\tlet everPending = false;\n\n\twhile (true) {\n\t\tconst snapshot = await source.get({ client, txid });\n\t\tconst receipt = snapshot.receipt;\n\n\t\tif (receipt === null) {\n\t\t\t// Unknown to the source: propagation lag, a canonical-only source\n\t\t\t// looking at a mempool tx, or a genuine drop. Only the grace clock\n\t\t\t// distinguishes them.\n\t\t\tunknownSince ??= Date.now();\n\t\t\tif (Date.now() - unknownSince >= droppedGracePeriod) {\n\t\t\t\tthrow new TransactionDroppedError(\n\t\t\t\t\teverPending\n\t\t\t\t\t\t? `Transaction ${txid} left the mempool without being mined`\n\t\t\t\t\t\t: `Transaction ${txid} was never observed by the status source`,\n\t\t\t\t\t{ txid },\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tunknownSince = null;\n\n\t\t\tswitch (receipt.status) {\n\t\t\t\tcase \"dropped\":\n\t\t\t\t\tthrow new TransactionDroppedError(\n\t\t\t\t\t\t`Transaction ${txid} was dropped from the mempool`,\n\t\t\t\t\t\t{ txid },\n\t\t\t\t\t);\n\t\t\t\tcase \"abort_by_response\":\n\t\t\t\tcase \"abort_by_post_condition\":\n\t\t\t\t\tthrow new TransactionAbortedError(\n\t\t\t\t\t\t`Transaction ${txid} aborted (${receipt.status})`,\n\t\t\t\t\t\t{ receipt },\n\t\t\t\t\t);\n\t\t\t\tcase \"pending\":\n\t\t\t\t\teverPending = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"success\": {\n\t\t\t\t\tif (confirmations <= 1) return receipt;\n\t\t\t\t\tif (receipt.blockHeight !== undefined) {\n\t\t\t\t\t\tconst tip = snapshot.tip ?? (await getBlockHeight(client));\n\t\t\t\t\t\tif (tip - receipt.blockHeight + 1 >= confirmations) return receipt;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (Date.now() - startedAt >= timeout) {\n\t\t\tthrow new WaitForTransactionTimeoutError(\n\t\t\t\t`Timed out after ${timeout}ms waiting for transaction ${txid}`,\n\t\t\t\t{ txid },\n\t\t\t);\n\t\t}\n\t\tawait sleep(pollingInterval);\n\t}\n}\n",
    "import { getTransaction } from \"../../actions/public/getTransaction.ts\";\nimport type { TransactionReceipt } from \"../../actions/public/txSources.ts\";\nimport { waitForTransactionReceipt } from \"../../actions/public/waitForTransactionReceipt.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { HttpRequestError } from \"../../errors/http.ts\";\nimport { BroadcastError } from \"../../errors/transaction.ts\";\nimport { TimeoutError } from \"../../errors/transport.ts\";\nimport { getTransactionId } from \"../../transactions/signer.ts\";\nimport type { StacksTransaction } from \"../../transactions/types.ts\";\nimport { serializeTransaction } from \"../../transactions/wire/serialize.ts\";\nimport { bytesToHex } from \"../../utils/encoding.ts\";\n\nexport type SendTransactionParams = {\n\ttransaction: StacksTransaction;\n\tattachment?: Uint8Array | string;\n\t/**\n\t * Wait for the transaction to be mined before returning. `true` waits for\n\t * 1 confirmation; a number waits for that many. The receipt lands on the\n\t * result. Rejects if the tx aborts, is dropped, or the wait times out.\n\t */\n\twait?: boolean | number;\n};\n\nexport type SendTransactionResult = {\n\ttxid: string;\n\t/** Present when `wait` was requested. */\n\treceipt?: TransactionReceipt;\n};\n\n/** Broadcast a signed transaction to the network */\nexport async function sendTransaction(\n\tclient: Client,\n\tparams: SendTransactionParams,\n): Promise<SendTransactionResult> {\n\tconst hex = bytesToHex(serializeTransaction(params.transaction));\n\n\tconst body: Record<string, string> = { tx: hex };\n\tif (params.attachment) {\n\t\tbody.attachment =\n\t\t\ttypeof params.attachment === \"string\"\n\t\t\t\t? params.attachment\n\t\t\t\t: bytesToHex(params.attachment);\n\t}\n\n\t// A stacks-node responds to a rejected broadcast with a non-2xx status\n\t// (the transport throws for that) but the rejection JSON, the thing this\n\t// function actually needs, rides along as the error body. The broadcast\n\t// is never retried at the transport level: the node may already hold the\n\t// transaction, and a re-send would surface as a nonce conflict.\n\tlet data: Awaited<ReturnType<Client[\"request\"]>>;\n\ttry {\n\t\tdata = await client.request(\"/v2/transactions\", {\n\t\t\tmethod: \"POST\",\n\t\t\tbody,\n\t\t\tretryCount: 0,\n\t\t});\n\t} catch (error) {\n\t\tif (error instanceof HttpRequestError && error.details) {\n\t\t\ttry {\n\t\t\t\tdata = JSON.parse(error.details);\n\t\t\t} catch {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t} else if (error instanceof TimeoutError) {\n\t\t\t// The deadline passed after the node may have accepted the tx. Ask\n\t\t\t// before surfacing: a known tx means the broadcast succeeded.\n\t\t\tconst txid = getTransactionId(params.transaction);\n\t\t\tconst receipt = await getTransaction(client, { txid }).catch(() => null);\n\t\t\tif (receipt === null) throw error;\n\t\t\tdata = { txid };\n\t\t} else {\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tif (data.error) {\n\t\tthrow new BroadcastError(data.reason ?? data.error, {\n\t\t\treason: data.reason,\n\t\t\treasonData: data.reason_data,\n\t\t\ttxid: data.txid ?? getTransactionId(params.transaction),\n\t\t});\n\t}\n\n\tconst txid =\n\t\ttypeof data === \"string\"\n\t\t\t? data.replace(/\"/g, \"\")\n\t\t\t: (data.txid ?? getTransactionId(params.transaction));\n\n\tif (params.wait) {\n\t\tconst confirmations = params.wait === true ? 1 : params.wait;\n\t\tconst receipt = await waitForTransactionReceipt(client, {\n\t\t\ttxid,\n\t\t\tconfirmations,\n\t\t});\n\t\treturn { txid, receipt };\n\t}\n\n\treturn { txid };\n}\n",
    "import type { Client } from \"../../clients/types.ts\";\nimport { BroadcastError } from \"../../errors/transaction.ts\";\nimport type { StacksTransaction } from \"../../transactions/types.ts\";\nimport { getNonce } from \"../public/getNonce.ts\";\nimport { sendTransaction } from \"./sendTransaction.ts\";\n\n/**\n * Provides the confirmed on-chain nonce floor for an address.\n *\n * The default {@link jsonRpcSource} reads the configured node's `/v2/accounts`\n * endpoint — node-agnostic, no Hiro dependency. Other sources (mempool-aware,\n * first-party Index) can be swapped in without touching the manager.\n */\nexport type NonceManagerSource = {\n\tget(params: { client: Client; address: string }): Promise<bigint>;\n};\n\n/**\n * Holds per-address allocation state and hands out the next nonce.\n *\n * `reserve` MUST be atomic per `key`: two concurrent reservations for the same\n * key must never return the same value. The in-memory {@link memoryStore}\n * serializes with a per-key promise chain; a persisted store (Redis `INCR`,\n * Postgres `SELECT ... FOR UPDATE`) becomes the cross-process lock for the\n * multi-builder / smart-wallet-as-a-service case.\n */\nexport type NonceStore = {\n\t/**\n\t * Reserve the next nonce for `key`. `getFloor` reads the confirmed on-chain\n\t * nonce; it is only invoked when the store has no tracked value (cold start\n\t * or after {@link NonceStore.reset}).\n\t */\n\treserve(key: string, getFloor: () => Promise<bigint>): Promise<bigint>;\n\t/** Forget tracked state for `key` so the next reserve re-syncs from the floor. */\n\treset(key: string): void | Promise<void>;\n\t/**\n\t * Hand back a nonce that {@link NonceStore.reserve} issued but that never\n\t * reached the mempool. Rolls the counter back ONLY when `nonce` is the\n\t * most recently issued value (`next - 1`); a stale release, or one that\n\t * races a newer reservation, is a no-op. Optional: stores that omit it\n\t * leave the gap for {@link reconcileNonce} to heal.\n\t */\n\trelease?(key: string, nonce: bigint): void | Promise<void>;\n\t/**\n\t * Return the next nonce that {@link NonceStore.reserve} would hand out for\n\t * `key` WITHOUT consuming it, or `undefined` if `key` is untracked. Used by\n\t * {@link reconcileNonce} to detect drift. Optional — stores that omit it\n\t * simply opt out of reconciliation.\n\t */\n\tpeek?(key: string): Promise<bigint | undefined> | bigint | undefined;\n};\n\n/** Allocates mempool-safe sequential nonces across rapid broadcasts from one account. */\nexport type NonceManager = {\n\tconsume(params: { client: Client; address: string }): Promise<bigint>;\n\treset(params: { client: Client; address: string }): void | Promise<void>;\n\t/**\n\t * Give back a nonce from {@link NonceManager.consume} whose transaction\n\t * was never accepted by the node. No-op unless it is the latest issued.\n\t */\n\trelease(params: {\n\t\tclient: Client;\n\t\taddress: string;\n\t\tnonce: bigint;\n\t}): void | Promise<void>;\n\t/** Next nonce that {@link NonceManager.consume} would return without consuming it, or `undefined` if untracked. */\n\tpeek(params: {\n\t\tclient: Client;\n\t\taddress: string;\n\t}): Promise<bigint | undefined>;\n};\n\nexport type CreateNonceManagerParams = {\n\tsource?: NonceManagerSource;\n\tstore?: NonceStore;\n};\n\n/** Confirmed-nonce source backed by the configured node's `/v2/accounts` RPC (no Hiro dependency). */\nexport function jsonRpcSource(): NonceManagerSource {\n\treturn {\n\t\tget: ({ client, address }) => getNonce(client, { address }),\n\t};\n}\n\n/**\n * In-memory, single-process store. Tracks the next nonce per key and serializes\n * concurrent reservations with a per-key promise chain.\n *\n * Correct only within one process — swap in a persisted store for multi-process\n * deployments that share a signing key.\n */\nexport function memoryStore(): NonceStore {\n\tconst next = new Map<string, bigint>();\n\tconst locks = new Map<string, Promise<unknown>>();\n\n\tfunction withLock<T>(key: string, fn: () => Promise<T>): Promise<T> {\n\t\tconst prev = locks.get(key) ?? Promise.resolve();\n\t\t// Chain onto the prior reservation regardless of how it settled, so a\n\t\t// rejected reserve never wedges the key.\n\t\tconst run = prev.then(fn, fn);\n\t\tlocks.set(\n\t\t\tkey,\n\t\t\trun.catch(() => {}),\n\t\t);\n\t\treturn run;\n\t}\n\n\treturn {\n\t\treserve(key, getFloor) {\n\t\t\treturn withLock(key, async () => {\n\t\t\t\tlet current = next.get(key);\n\t\t\t\tif (current === undefined) current = await getFloor();\n\t\t\t\tnext.set(key, current + 1n);\n\t\t\t\treturn current;\n\t\t\t});\n\t\t},\n\t\treset(key) {\n\t\t\tnext.delete(key);\n\t\t},\n\t\trelease(key, nonce) {\n\t\t\treturn withLock(key, async () => {\n\t\t\t\tif (next.get(key) === nonce + 1n) next.set(key, nonce);\n\t\t\t});\n\t\t},\n\t\tpeek(key) {\n\t\t\treturn next.get(key);\n\t\t},\n\t};\n}\n\nfunction nonceKey(client: Client, address: string): string {\n\treturn `${client.chain?.id ?? \"stacks\"}:${address}`;\n}\n\n/**\n * Create a nonce manager that floors on a confirmed-nonce {@link NonceManagerSource}\n * and increments a {@link NonceStore} on every {@link NonceManager.consume}.\n *\n * Defaults to {@link jsonRpcSource} + {@link memoryStore} — node-agnostic,\n * single-process, zero external dependencies.\n */\nexport function createNonceManager(\n\tparams: CreateNonceManagerParams = {},\n): NonceManager {\n\tconst source = params.source ?? jsonRpcSource();\n\tconst store = params.store ?? memoryStore();\n\n\treturn {\n\t\tconsume({ client, address }) {\n\t\t\treturn store.reserve(nonceKey(client, address), () =>\n\t\t\t\tsource.get({ client, address }),\n\t\t\t);\n\t\t},\n\t\treset({ client, address }) {\n\t\t\treturn store.reset(nonceKey(client, address));\n\t\t},\n\t\trelease({ client, address, nonce }) {\n\t\t\treturn store.release?.(nonceKey(client, address), nonce);\n\t\t},\n\t\tasync peek({ client, address }) {\n\t\t\treturn store.peek?.(nonceKey(client, address));\n\t\t},\n\t};\n}\n\n/** Resolve the next nonce via the client's nonce manager, falling back to a confirmed read. */\nexport async function resolveNonce(\n\tclient: Client,\n\taddress: string,\n): Promise<bigint> {\n\tif (client.nonceManager)\n\t\treturn client.nonceManager.consume({ client, address });\n\treturn getNonce(client, { address });\n}\n\n/**\n * Return `nonce` to the client's nonce manager after a send that never\n * reached the mempool. No-op without a manager. Never throws: a failed\n * release must not mask the error that caused it.\n */\nexport async function releaseNonce(\n\tclient: Client,\n\taddress: string,\n\tnonce: bigint,\n): Promise<void> {\n\tif (!client.nonceManager) return;\n\ttry {\n\t\tawait client.nonceManager.release({ client, address, nonce });\n\t} catch {\n\t\t// The store is unreachable; the reconciler heals the gap later.\n\t}\n}\n\nexport type ReconcileNonceParams = {\n\tclient: Client;\n\taddress: string;\n\t/** Authoritative (ideally mempool-aware) source to reconcile against. */\n\tsource: NonceManagerSource;\n\t/**\n\t * Allow resetting DOWNWARD when the source's next nonce is below what the\n\t * store tracks — i.e. a previously-allocated tx is no longer pending or\n\t * confirmed (dropped/GC'd), so its nonce should be reused. Default `true`.\n\t *\n\t * Downward resets rely on `source` being current: with a go-forward mempool\n\t * source that lags broadcast, run reconciliation on an interval comfortably\n\t * longer than mempool propagation so a still-missing tx is genuinely dropped.\n\t * Set `false` for upward-only reconciliation (always safe).\n\t */\n\tdownward?: boolean;\n};\n\nexport type ReconcileNonceResult = {\n\t/** Whether the manager was reset (drift detected). */\n\treset: boolean;\n\t/** Authoritative next nonce from `source`. */\n\tauthoritative: bigint;\n\t/** Next nonce the store tracked, or `undefined` if untracked. */\n\ttracked: bigint | undefined;\n};\n\n/**\n * Reconcile a tracked nonce against an authoritative source, healing silent\n * drift that produces no broadcast error (a dropped/GC'd mempool tx leaving the\n * counter overshot, or the chain advancing past the local view).\n *\n * When the source's next nonce differs from the tracked value, the manager is\n * {@link NonceManager.reset}; the next `consume` re-seeds from `source`. A no-op\n * if the store is untracked or does not implement `peek`.\n */\nexport async function reconcileNonce(\n\tmanager: NonceManager,\n\tparams: ReconcileNonceParams,\n): Promise<ReconcileNonceResult> {\n\tconst { client, address, source } = params;\n\tconst downward = params.downward ?? true;\n\n\tconst authoritative = await source.get({ client, address });\n\tconst tracked = await manager.peek({ client, address });\n\n\tif (tracked === undefined || authoritative === tracked) {\n\t\treturn { reset: false, authoritative, tracked };\n\t}\n\tif (authoritative < tracked && !downward) {\n\t\treturn { reset: false, authoritative, tracked };\n\t}\n\n\tawait manager.reset({ client, address });\n\treturn { reset: true, authoritative, tracked };\n}\n\nexport type StartNonceReconcilerParams = {\n\tclient: Client;\n\taddresses: string[];\n\tsource: NonceManagerSource;\n\t/** Reconcile interval in ms. Default 60_000. Keep well above mempool propagation. */\n\tintervalMs?: number;\n\tdownward?: boolean;\n\t/** Per-address callback after each reconcile (observability). */\n\tonReconcile?: (address: string, result: ReconcileNonceResult) => void;\n\t/** Per-address error callback; reconciliation continues on the next tick. */\n\tonError?: (address: string, error: unknown) => void;\n\t/** Optional test clock. If provided, the reconciler advances time via\n\t *  `clock.advance(ms)` instead of real `setInterval`. */\n\tclock?: {\n\t\tadvance: (ms: number) => Promise<void>;\n\t\tnow: () => number;\n\t};\n};\n\n/**\n * Run {@link reconcileNonce} on a timer for a set of addresses.\n *\n * SINGLE-WRITER: run this in exactly ONE process. With a shared persisted store,\n * a reconciler resetting the counter while other workers allocate is racy — keep\n * reconciliation on one designated process and let the others only allocate.\n *\n * Returns a handle; call `stop()` to clear the timer.\n */\nexport function startNonceReconciler(\n\tmanager: NonceManager,\n\tparams: StartNonceReconcilerParams,\n): { stop: () => void } {\n\tconst { client, addresses, source, clock } = params;\n\tconst intervalMs = params.intervalMs ?? 60_000;\n\tlet running = true;\n\n\tconst tick = async () => {\n\t\tif (!running) return;\n\t\tfor (const address of addresses) {\n\t\t\ttry {\n\t\t\t\tconst result = await reconcileNonce(manager, {\n\t\t\t\t\tclient,\n\t\t\t\t\taddress,\n\t\t\t\t\tsource,\n\t\t\t\t\tdownward: params.downward,\n\t\t\t\t});\n\t\t\t\tparams.onReconcile?.(address, result);\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\tparams.onError?.(address, error);\n\t\t\t\t} catch {\n\t\t\t\t\t// A throwing onError callback must not abort the reconcile loop\n\t\t\t\t\t// or surface as an unhandled rejection on the interval timer.\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (running && clock) {\n\t\t\tawait clock.advance(intervalMs);\n\t\t\ttick();\n\t\t}\n\t};\n\n\tif (clock) {\n\t\ttick();\n\t\treturn {\n\t\t\tstop: () => {\n\t\t\t\trunning = false;\n\t\t\t},\n\t\t};\n\t}\n\n\tconst timer = setInterval(tick, intervalMs);\n\t// Don't keep the event loop alive solely for reconciliation (Node/Bun).\n\t(timer as { unref?: () => void }).unref?.();\n\n\treturn {\n\t\tstop: () => clearInterval(timer),\n\t};\n}\n\n/** True when a broadcast was rejected for a nonce conflict (`ConflictingNonceInMempool`, `BadNonce`). */\nexport function isNonceConflictError(error: unknown): boolean {\n\tif (!(error instanceof BroadcastError)) return false;\n\tif (\n\t\terror.reason === \"ConflictingNonceInMempool\" ||\n\t\terror.reason === \"BadNonce\"\n\t) {\n\t\treturn true;\n\t}\n\t// Typed reason present but not nonce-related — trust it over the message\n\t// (e.g. a FeeTooLow message mentioning \"nonce\" must not trigger a reset).\n\tif (error.reason !== undefined) return false;\n\t// No structured reason (older nodes/proxies) — fall back to message match.\n\treturn error.message.toLowerCase().includes(\"nonce\");\n}\n\n/**\n * Broadcast a signed transaction; on a nonce-conflict rejection, reset the\n * manager so the next build re-syncs to the confirmed floor.\n */\nexport async function broadcastWithNonceReset(\n\tclient: Client,\n\tparams: { transaction: StacksTransaction; address: string },\n): Promise<string> {\n\ttry {\n\t\tconst result = await sendTransaction(client, {\n\t\t\ttransaction: params.transaction,\n\t\t});\n\t\treturn result.txid;\n\t} catch (error) {\n\t\tif (client.nonceManager && isNonceConflictError(error)) {\n\t\t\tawait client.nonceManager.reset({ client, address: params.address });\n\t\t}\n\t\tthrow error;\n\t}\n}\n",
    "import type { Client } from \"../../clients/types.ts\";\nimport { MalformedResponseError } from \"../../errors/response.ts\";\nimport type { StacksTransaction } from \"../../transactions/types.ts\";\nimport {\n\tserializePayload,\n\tserializeTransaction,\n} from \"../../transactions/wire/serialize.ts\";\nimport { bytesToHex } from \"../../utils/encoding.ts\";\n\nexport type EstimateFeeParams = {\n\ttransaction: StacksTransaction;\n};\n\nexport type FeeEstimation = {\n\tfeeRate: number;\n\tfee: number;\n};\n\nfunction isValidEstimation(\n\te: unknown,\n): e is { fee_rate: number | string; fee: number | string } {\n\treturn (\n\t\ttypeof e === \"object\" &&\n\t\te !== null &&\n\t\t\"fee_rate\" in e &&\n\t\t\"fee\" in e &&\n\t\t(typeof (e as Record<string, unknown>).fee_rate === \"number\" ||\n\t\t\ttypeof (e as Record<string, unknown>).fee_rate === \"string\") &&\n\t\t(typeof (e as Record<string, unknown>).fee === \"number\" ||\n\t\t\ttypeof (e as Record<string, unknown>).fee === \"string\")\n\t);\n}\n\nexport async function estimateFee(\n\tclient: Client,\n\tparams: EstimateFeeParams,\n): Promise<FeeEstimation[]> {\n\tconst payloadHex = bytesToHex(serializePayload(params.transaction.payload));\n\tconst txHex = bytesToHex(serializeTransaction(params.transaction));\n\n\tconst data = await client.request(\"/v2/fees/transaction\", {\n\t\tmethod: \"POST\",\n\t\tbody: {\n\t\t\testimated_len: Math.ceil(txHex.length / 2),\n\t\t\ttransaction_payload: `0x${payloadHex}`,\n\t\t},\n\t});\n\n\tconst raw = (data as { estimations?: unknown[] })?.estimations ?? [];\n\treturn raw.map((e) => {\n\t\tif (!isValidEstimation(e)) {\n\t\t\tthrow new MalformedResponseError(\n\t\t\t\t\"estimateFee: node response contains invalid fee estimation entry\",\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\tfeeRate: Number(e.fee_rate),\n\t\t\tfee: Number(e.fee),\n\t\t};\n\t});\n}\n",
    "import type { ProviderAccount } from \"../../accounts/types.ts\";\nimport type { Account, Client } from \"../../clients/types.ts\";\nimport { HttpRequestError } from \"../../errors/http.ts\";\nimport type { StacksTransaction } from \"../../transactions/types.ts\";\nimport {\n\tclearTxCache,\n\tserializeTransaction,\n} from \"../../transactions/wire/serialize.ts\";\nimport type { IntegerType } from \"../../utils/encoding.ts\";\nimport { intToBigInt } from \"../../utils/encoding.ts\";\nimport { estimateFee } from \"../public/estimateFee.ts\";\n\nexport function isProviderAccount(\n\taccount: Account,\n): account is ProviderAccount {\n\treturn account.type === \"provider\";\n}\n\n/**\n * Named fee tiers. `'low' | 'mid' | 'high'` map to the node's three fee\n * estimations; `'min'` is the node's minimum relay fee — 1 uSTX per byte of\n * the serialized transaction, computable offline.\n */\nexport type FeeTier = \"min\" | \"low\" | \"mid\" | \"high\";\n\n/** Fee input accepted by wallet actions: an explicit amount or a named tier. */\nexport type FeeParam = IntegerType | FeeTier;\n\nconst FEE_TIERS: readonly FeeTier[] = [\"min\", \"low\", \"mid\", \"high\"];\nconst TIER_INDEX = { low: 0, mid: 1, high: 2 } as const;\n\nexport function isFeeTier(fee: FeeParam | undefined): fee is FeeTier {\n\treturn typeof fee === \"string\" && FEE_TIERS.includes(fee as FeeTier);\n}\n\n/**\n * Minimum relay fee: 1 uSTX per byte of the serialized transaction. The fee\n * field is fixed-width (8 bytes), so the size — and therefore this floor — is\n * stable regardless of the fee value later set on the spending condition.\n */\nexport function minimumFee(transaction: StacksTransaction): bigint {\n\treturn BigInt(serializeTransaction(transaction).length);\n}\n\n/** Outcome of {@link resolveFee}: the amount and which tier produced it. */\nexport type ResolvedFee = {\n\tfee: bigint;\n\t/**\n\t * Tier the amount came from. `'min'` when the estimator had no estimate\n\t * and the relay floor was used instead. Absent when the caller passed an\n\t * exact amount.\n\t */\n\ttier?: FeeTier;\n};\n\n/**\n * True when the node answered `POST /v2/fees/transaction` with 400\n * `NoEstimateAvailable`: it is healthy but has no fee history for this\n * payload (fresh devnet, quiet chain). Every other failure means the\n * estimate was never obtained and must surface to the caller.\n */\nexport function isNoEstimateAvailable(error: unknown): boolean {\n\treturn (\n\t\terror instanceof HttpRequestError &&\n\t\terror.status === 400 &&\n\t\t(error.details?.includes(\"NoEstimateAvailable\") ?? false)\n\t);\n}\n\n/**\n * Resolve a fee param to a concrete amount. Numeric input passes through.\n * Tiers `'low' | 'mid' | 'high'` index the node's estimations (nearest\n * available when fewer than three are returned); `'min'` resolves to\n * {@link minimumFee}, which needs no network round-trip.\n *\n * The relay floor is the fallback ONLY when the node reports\n * `NoEstimateAvailable` or returns no estimations. A transport timeout, 5xx,\n * or auth failure rethrows: silently under-paying because the node was\n * unreachable would strand the transaction in the mempool.\n */\nexport async function resolveFee(\n\tclient: Client,\n\ttransaction: StacksTransaction,\n\tfee: FeeParam | undefined,\n): Promise<ResolvedFee> {\n\tif (fee !== undefined && !isFeeTier(fee)) return { fee: intToBigInt(fee) };\n\n\tconst tier = fee ?? \"mid\";\n\tif (tier === \"min\") return { fee: minimumFee(transaction), tier };\n\n\tlet estimates: Awaited<ReturnType<typeof estimateFee>>;\n\ttry {\n\t\testimates = await estimateFee(client, { transaction });\n\t} catch (error) {\n\t\tif (!isNoEstimateAvailable(error)) throw error;\n\t\treturn { fee: minimumFee(transaction), tier: \"min\" };\n\t}\n\tconst pick = estimates[TIER_INDEX[tier]] ?? estimates[estimates.length - 1];\n\tif (pick) return { fee: BigInt(pick.fee), tier };\n\treturn { fee: minimumFee(transaction), tier: \"min\" };\n}\n\n/** Set the resolved fee on an unsigned transaction's origin spending condition. */\nexport function setUnsignedFee(\n\ttransaction: StacksTransaction,\n\tfee: bigint,\n): void {\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t(transaction.auth.spendingCondition as any).fee = fee;\n\t// In-place mutation: invalidate the memoized serialization (resolveFee may\n\t// have already serialized this object via minimumFee/estimateFee).\n\tclearTxCache(transaction);\n}\n\n/** Throw when a named fee tier is used with a provider (wallet) account. */\nexport function assertNoFeeTierForProvider(fee: FeeParam | undefined): void {\n\tif (isFeeTier(fee)) {\n\t\tthrow new Error(\n\t\t\t`Fee tier '${fee}' requires local signing; provider (wallet) accounts set their own fee`,\n\t\t);\n\t}\n}\n",
    "import type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport type {\n\tPostConditionInput,\n\tPostConditionMode,\n} from \"../../postconditions/types.ts\";\nimport { buildContractCall } from \"../../transactions/build.ts\";\nimport { signTransactionWithAccount } from \"../../transactions/signer.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\nimport type { IntegerType } from \"../../utils/encoding.ts\";\nimport {\n\tbroadcastWithNonceReset,\n\treleaseNonce,\n\tresolveNonce,\n} from \"./nonceManager.ts\";\nimport {\n\ttype FeeParam,\n\tassertNoFeeTierForProvider,\n\tisFeeTier,\n\tisProviderAccount,\n\tresolveFee,\n\tsetUnsignedFee,\n} from \"./utils.ts\";\n\nexport type CallContractParams = {\n\tcontract: string; // \"address.name\"\n\tfunctionName: string;\n\tfunctionArgs?: ClarityValue[];\n\tfee?: FeeParam;\n\tnonce?: IntegerType;\n\tpostConditionMode?: PostConditionMode;\n\tpostConditions?: PostConditionInput[];\n};\n\n/** Build, sign, and broadcast a contract call */\nexport async function callContract(\n\tclient: Client,\n\tparams: CallContractParams,\n): Promise<string> {\n\tconst account = client.account;\n\tif (!account) throw new Error(\"Account required\");\n\n\t// Validate the contract id up front so both the provider and local paths\n\t// reject malformed input instead of forwarding it to the wallet.\n\tconst [contractAddress, contractName] = parseContractId(params.contract);\n\n\t// Provider: delegate to wallet\n\tif (isProviderAccount(account)) {\n\t\tassertNoFeeTierForProvider(params.fee);\n\t\tconst result = await account.provider.request(\"stx_callContract\", {\n\t\t\tcontract: params.contract,\n\t\t\tfunctionName: params.functionName,\n\t\t\tfunctionArgs: params.functionArgs ?? [],\n\t\t});\n\t\treturn result.txid;\n\t}\n\n\t// Local/Custom: build → sign → broadcast\n\tconst managed =\n\t\tparams.nonce === undefined && client.nonceManager !== undefined;\n\tconst nonce = params.nonce ?? (await resolveNonce(client, account.address));\n\n\ttry {\n\t\tconst needsFeeResolution =\n\t\t\tparams.fee === undefined || isFeeTier(params.fee);\n\n\t\tconst unsigned = buildContractCall({\n\t\t\tcontractAddress,\n\t\t\tcontractName,\n\t\t\tfunctionName: params.functionName,\n\t\t\tfunctionArgs: params.functionArgs ?? [],\n\t\t\tfee: needsFeeResolution ? 0n : (params.fee as IntegerType),\n\t\t\tnonce,\n\t\t\tpublicKey: account.publicKey,\n\t\t\tchain: client.chain,\n\t\t\tpostConditionMode: params.postConditionMode,\n\t\t\tpostConditions: params.postConditions,\n\t\t});\n\n\t\tif (needsFeeResolution) {\n\t\t\tconst { fee } = await resolveFee(client, unsigned, params.fee);\n\t\t\tsetUnsignedFee(unsigned, fee);\n\t\t}\n\n\t\tconst signed = await signTransactionWithAccount(unsigned, account);\n\t\treturn await broadcastWithNonceReset(client, {\n\t\t\ttransaction: signed,\n\t\t\taddress: account.address,\n\t\t});\n\t} catch (error) {\n\t\t// Anything that fails between reserving the nonce and a 2xx broadcast\n\t\t// (fee estimate, signing, FeeTooLow, transport) never reached the\n\t\t// mempool: hand the nonce back so the next send does not skip it.\n\t\tif (managed) await releaseNonce(client, account.address, nonce as bigint);\n\t\tthrow error;\n\t}\n}\n",
    "import type {\n\tAbiContract,\n\tAbiFunction,\n\tAbiMap,\n\tAbiType,\n\tAbiTypesOf,\n\tContractTypes,\n\tExtractFunctionArgs,\n\tExtractFunctionOutput,\n\tExtractMapKey,\n\tExtractMapNames,\n\tExtractMapValue,\n\tExtractPublicFunctions,\n\tExtractReadOnlyFunctions,\n} from \"../clarity/abi/index.ts\";\nimport { type ToCamelCase, toCamelCase } from \"../clarity/abi/utils.ts\";\nimport {\n\tclarityValueToJSUntyped,\n\tjsToClarityValue,\n} from \"../clarity/bridge.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport type { Client } from \"../clients/types.ts\";\nimport type {\n\tPostConditionInput,\n\tPostConditionMode,\n} from \"../postconditions/types.ts\";\nimport { buildContractCall } from \"../transactions/build.ts\";\nimport type { StacksTransaction } from \"../transactions/types.ts\";\nimport { publicKeyToAddress } from \"../utils/address.ts\";\nimport type { IntegerType } from \"../utils/encoding.ts\";\nimport { getMapEntry } from \"./public/getMapEntry.ts\";\nimport { getNonce } from \"./public/getNonce.ts\";\nimport { readContract } from \"./public/readContract.ts\";\nimport { callContract } from \"./wallet/callContract.ts\";\nimport { resolveFee, setUnsignedFee } from \"./wallet/utils.ts\";\n\n// --- Type helpers for unwrapping response types ---\n\n/**\n * Unwrap `(response ok err)` → just the `ok` branch type. Distributes over the\n * `{ ok } | { err }` union: the `err` branch maps to `never` (it throws\n * `ContractResponseError` at runtime, so it never reaches the caller).\n */\nexport type UnwrapResponse<T> = T extends { ok: infer O }\n\t? O\n\t: T extends { err: unknown }\n\t\t? never\n\t\t: T;\n\n/**\n * True for a structural empty mapped type (`{}`) and for codegen's\n * `Record<string, never>`. `keyof Record<string, never>` is `string`, so the\n * first check alone is not enough.\n */\ntype IsEmptyArgs<A> = [keyof A & string] extends [never]\n\t? true\n\t: Record<string, never> extends A\n\t\t? true\n\t\t: false;\n\n/** No-arg ABI functions may omit the dummy `{}`. Functions with args stay required. */\ntype ContractMethod<\n\tA,\n\tR,\n\tExtra extends unknown[] = [],\n> = IsEmptyArgs<A> extends true\n\t? (args?: A, ...extra: Extra) => R\n\t: (args: A, ...extra: Extra) => R;\n\ntype ReadMethodReturn<\n\tC extends AbiContract,\n\tN extends ExtractReadOnlyFunctions<C>,\n> = UnwrapResponse<ExtractFunctionOutput<C, N>>;\n\n// --- Public type for the contract instance ---\n\n/**\n * When the ABI carries a codegen brand (`TypedAbi`), method types resolve to\n * the generated named aliases — cleaner hovers and error messages. Un-branded\n * ABIs fall back to structural inference over the as-const literal.\n */\ntype TypedReadMethods<T extends ContractTypes> = {\n\t[K in keyof T[\"functions\"] as T[\"functions\"][K][\"access\"] extends \"read-only\"\n\t\t? K\n\t\t: never]: ContractMethod<\n\t\tT[\"functions\"][K][\"args\"],\n\t\tPromise<UnwrapResponse<T[\"functions\"][K][\"ret\"]>>\n\t>;\n};\n\ntype TypedCallMethods<T extends ContractTypes> = {\n\t[K in keyof T[\"functions\"] as T[\"functions\"][K][\"access\"] extends \"public\"\n\t\t? K\n\t\t: never]: ContractMethod<\n\t\tT[\"functions\"][K][\"args\"],\n\t\tPromise<string>,\n\t\t[options?: ContractCallOptions]\n\t>;\n};\n\ntype TypedMapMethods<T extends ContractTypes> = {\n\t[K in keyof NonNullable<T[\"maps\"]>]: (\n\t\tkey: NonNullable<T[\"maps\"]>[K][\"key\"],\n\t) => Promise<NonNullable<T[\"maps\"]>[K][\"value\"] | null>;\n};\n\ntype ReadMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>]: ContractMethod<\n\t\t\t\tExtractFunctionArgs<C, N>,\n\t\t\t\tPromise<ReadMethodReturn<C, N>>\n\t\t\t>;\n\t\t}\n\t: TypedReadMethods<AbiTypesOf<C>>;\n\ntype CallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractPublicFunctions<C> as ToCamelCase<N>]: ContractMethod<\n\t\t\t\tExtractFunctionArgs<C, N>,\n\t\t\t\tPromise<string>,\n\t\t\t\t[options?: ContractCallOptions]\n\t\t\t>;\n\t\t}\n\t: TypedCallMethods<AbiTypesOf<C>>;\n\ntype MapMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractMapNames<C> as ToCamelCase<N>]: (\n\t\t\t\tkey: ExtractMapKey<C, N>,\n\t\t\t) => Promise<ExtractMapValue<C, N> | null>;\n\t\t}\n\t: TypedMapMethods<AbiTypesOf<C>>;\n\nexport type ContractCallOptions = {\n\tfee?: IntegerType;\n\tnonce?: IntegerType;\n\tpostConditionMode?: PostConditionMode;\n\tpostConditions?: PostConditionInput[];\n};\n\n/**\n * Options for `buildCall.*`, building an unsigned transaction for\n * wallet-signs-later flows. `publicKey` defaults to the client account's\n * public key. When omitted, `nonce` is the confirmed on-chain nonce read\n * straight from the node (the client's nonce manager is never consumed for\n * a transaction that may never be sent) and `fee` is the mid estimate,\n * falling back to the relay floor only on `NoEstimateAvailable`.\n */\nexport type ContractBuildCallOptions = ContractCallOptions & {\n\tpublicKey?: string;\n\tsponsored?: boolean;\n};\n\ntype TypedBuildCallMethods<T extends ContractTypes> = {\n\t[K in keyof T[\"functions\"] as T[\"functions\"][K][\"access\"] extends \"public\"\n\t\t? K\n\t\t: never]: ContractMethod<\n\t\tT[\"functions\"][K][\"args\"],\n\t\tPromise<StacksTransaction>,\n\t\t[options?: ContractBuildCallOptions]\n\t>;\n};\n\ntype BuildCallMethods<C extends AbiContract> = [AbiTypesOf<C>] extends [never]\n\t? {\n\t\t\t[N in ExtractPublicFunctions<C> as ToCamelCase<N>]: ContractMethod<\n\t\t\t\tExtractFunctionArgs<C, N>,\n\t\t\t\tPromise<StacksTransaction>,\n\t\t\t\t[options?: ContractBuildCallOptions]\n\t\t\t>;\n\t\t}\n\t: TypedBuildCallMethods<AbiTypesOf<C>>;\n\nexport type ContractInstance<C extends AbiContract> = {\n\tread: ReadMethods<C>;\n\tcall: CallMethods<C>;\n\t/** Build unsigned transactions (wallet-signs-later) — never broadcasts. */\n\tbuildCall: BuildCallMethods<C>;\n\tmaps: MapMethods<C>;\n};\n\nexport type GetContractParams<C extends AbiContract> = {\n\tclient: Client;\n\taddress: string;\n\tname: string;\n\tabi: C;\n};\n\nexport function getContract<const TAbi extends AbiContract>(\n\tparams: GetContractParams<TAbi>,\n): ContractInstance<TAbi> {\n\tconst { client, address, name: contractName, abi } = params;\n\tconst contractId = `${address}.${contractName}`;\n\n\t// Index functions/maps by name for fast lookup\n\tconst fnByName = new Map<string, AbiFunction>();\n\tfor (const fn of abi.functions) {\n\t\tfnByName.set(fn.name, fn as AbiFunction);\n\t}\n\n\tconst mapByName = new Map<string, AbiMap>();\n\tif (abi.maps) {\n\t\tfor (const m of abi.maps) {\n\t\t\tmapByName.set(m.name, m as AbiMap);\n\t\t}\n\t}\n\n\t// Build kebab→camel reverse map for function/map names\n\tconst camelToKebab = new Map<string, string>();\n\tfor (const fn of abi.functions) {\n\t\tcamelToKebab.set(toCamelCase(fn.name), fn.name);\n\t}\n\tif (abi.maps) {\n\t\tfor (const m of abi.maps) {\n\t\t\tcamelToKebab.set(toCamelCase(m.name), m.name);\n\t\t}\n\t}\n\n\tconst read = new Proxy({} as ReadMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst fnName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst fn = fnByName.get(fnName);\n\t\t\tif (!fn || fn.access !== \"read-only\") return undefined;\n\n\t\t\treturn async (args: Record<string, unknown> = {}) => {\n\t\t\t\tconst clarityArgs = buildFunctionArgs(fn, args);\n\t\t\t\tconst result = await readContract(client, {\n\t\t\t\t\tcontract: contractId,\n\t\t\t\t\tfunctionName: fn.name,\n\t\t\t\t\targs: clarityArgs,\n\t\t\t\t});\n\n\t\t\t\tconst jsValue = clarityValueToJSUntyped(fn.outputs as AbiType, result);\n\n\t\t\t\t// Auto-unwrap: if output is response type, unwrap ok / throw on err\n\t\t\t\tif (isResponseOutput(fn.outputs as AbiType)) {\n\t\t\t\t\tconst resp = jsValue as { ok?: unknown; err?: unknown };\n\t\t\t\t\tif (\"ok\" in resp) return resp.ok;\n\t\t\t\t\tthrow new ContractResponseError(\n\t\t\t\t\t\t`${contractId}::${fn.name} returned (err ${formatErrValue(resp.err)})`,\n\t\t\t\t\t\tresp.err,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn jsValue;\n\t\t\t};\n\t\t},\n\t});\n\n\tconst call = new Proxy({} as CallMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst fnName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst fn = fnByName.get(fnName);\n\t\t\tif (!fn || fn.access !== \"public\") return undefined;\n\n\t\t\treturn async (\n\t\t\t\targs: Record<string, unknown> = {},\n\t\t\t\toptions?: ContractCallOptions,\n\t\t\t) => {\n\t\t\t\tconst clarityArgs = buildFunctionArgs(fn, args);\n\t\t\t\treturn callContract(client, {\n\t\t\t\t\tcontract: contractId,\n\t\t\t\t\tfunctionName: fn.name,\n\t\t\t\t\tfunctionArgs: clarityArgs,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\t\t\t};\n\t\t},\n\t});\n\n\tconst buildCall = new Proxy({} as BuildCallMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst fnName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst fn = fnByName.get(fnName);\n\t\t\tif (!fn || fn.access !== \"public\") return undefined;\n\n\t\t\treturn async (\n\t\t\t\targs: Record<string, unknown> = {},\n\t\t\t\toptions?: ContractBuildCallOptions,\n\t\t\t) => {\n\t\t\t\tconst publicKey = options?.publicKey ?? client.account?.publicKey;\n\t\t\t\tif (!publicKey) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"buildCall requires a publicKey (pass options.publicKey or configure a client account)\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst functionArgs = buildFunctionArgs(fn, args);\n\t\t\t\tconst network = client.chain?.network ?? \"mainnet\";\n\t\t\t\tconst nonce =\n\t\t\t\t\toptions?.nonce ??\n\t\t\t\t\t(await getNonce(client, {\n\t\t\t\t\t\taddress: publicKeyToAddress(publicKey, network),\n\t\t\t\t\t}));\n\n\t\t\t\tconst unsigned = buildContractCall({\n\t\t\t\t\tcontractAddress: address,\n\t\t\t\t\tcontractName,\n\t\t\t\t\tfunctionName: fn.name,\n\t\t\t\t\tfunctionArgs,\n\t\t\t\t\tfee: options?.fee ?? 0n,\n\t\t\t\t\tnonce,\n\t\t\t\t\tpublicKey,\n\t\t\t\t\tchain: client.chain,\n\t\t\t\t\tpostConditionMode: options?.postConditionMode,\n\t\t\t\t\tpostConditions: options?.postConditions,\n\t\t\t\t\tsponsored: options?.sponsored,\n\t\t\t\t});\n\n\t\t\t\tif (options?.fee === undefined) {\n\t\t\t\t\tconst { fee } = await resolveFee(client, unsigned, undefined);\n\t\t\t\t\tsetUnsignedFee(unsigned, fee);\n\t\t\t\t}\n\n\t\t\t\treturn unsigned;\n\t\t\t};\n\t\t},\n\t});\n\n\tconst maps = new Proxy({} as MapMethods<TAbi>, {\n\t\tget(_target, prop: string) {\n\t\t\tconst mapName = camelToKebab.get(prop) ?? prop;\n\t\t\tconst map = mapByName.get(mapName);\n\t\t\tif (!map) return undefined;\n\n\t\t\treturn async (key: unknown) => {\n\t\t\t\tconst clarityKey = jsToClarityValue(map.key as AbiType, key);\n\t\t\t\tconst result = await getMapEntry(client, {\n\t\t\t\t\tcontract: contractId,\n\t\t\t\t\tmapName: map.name,\n\t\t\t\t\tkey: clarityKey,\n\t\t\t\t});\n\n\t\t\t\t// Map entries come back as (optional ...). If none, return null.\n\t\t\t\tif (result.type === \"none\") return null;\n\t\t\t\tif (result.type === \"some\") {\n\t\t\t\t\treturn clarityValueToJSUntyped(map.value as AbiType, result.value);\n\t\t\t\t}\n\t\t\t\t// Direct value (shouldn't normally happen, but handle gracefully)\n\t\t\t\treturn clarityValueToJSUntyped(map.value as AbiType, result);\n\t\t\t};\n\t\t},\n\t});\n\n\treturn { read, call, buildCall, maps };\n}\n\n/**\n * Resolve a network-keyed contract config for the client's chain. The contracts\n * map is keyed by network (\"mainnet\" | \"testnet\"), so selection is a direct\n * index — no per-call ternary. Throws if the client has no chain configured.\n */\nexport function resolveNetworkContract<\n\tT extends Record<\"mainnet\" | \"testnet\", { address: string }>,\n>(client: Client, contracts: T): T[\"mainnet\"] | T[\"testnet\"] {\n\tif (!client.chain) {\n\t\tthrow new Error(\"Client must have a chain configured\");\n\t}\n\treturn contracts[client.chain.network];\n}\n\n// --- Helpers ---\n\n/**\n * Encode an ABI function's named args into positional ClarityValues. Exported\n * so a caller that needs the raw ClarityValue result (to cache or re-serialize\n * it) can reuse the same encoding this module's read methods use, instead of\n * maintaining a second one that drifts.\n */\nexport function buildFunctionArgs(\n\tfn: AbiFunction,\n\targs: Record<string, unknown> = {},\n): ClarityValue[] {\n\treturn fn.args.map((arg) => {\n\t\tconst camelKey = toCamelCase(arg.name);\n\t\tconst hasOriginal = arg.name in args;\n\t\tconst hasCamel = camelKey in args;\n\t\tconst value = hasOriginal\n\t\t\t? args[arg.name]\n\t\t\t: hasCamel\n\t\t\t\t? args[camelKey]\n\t\t\t\t: undefined;\n\t\tif (value === undefined) throw new Error(`Missing argument: ${arg.name}`);\n\t\treturn jsToClarityValue(arg.type as AbiType, value);\n\t});\n}\n\n/** True when an ABI output is a `(response ok err)` and needs unwrapping. */\nexport function isResponseOutput(type: AbiType): boolean {\n\treturn typeof type === \"object\" && type !== null && \"response\" in type;\n}\n\nfunction formatErrValue(value: unknown): string {\n\tif (typeof value === \"bigint\") return value.toString();\n\tif (typeof value === \"string\") return `\"${value}\"`;\n\treturn String(value);\n}\n\nexport class ContractResponseError extends Error {\n\toverride name = \"ContractResponseError\";\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly errorValue: unknown,\n\t) {\n\t\tsuper(message);\n\t}\n}\n",
    "/**\n * Curated pox-5 ABI — the 32 functions this module calls, subset of the full\n * boot-contract interface (88 functions). Regenerate when stacks-core bumps\n * pox-5: `bun spike/pox5-getContract/extract-abi.ts`, then re-curate.\n * Drift-guarded by __tests__/actions.simnet.test.ts.\n */\nimport type { AbiContract } from \"../clarity/abi/contract.ts\";\n\n// NOTE: ABI fragments are written out at each use site rather than shared via a\n// module-local const. bunup's dts emitter cannot express a reference to a\n// non-exported const — it drops the `type` property entirely (and collapses it\n// to `{}` if the const is exported), so the SHIPPED types were malformed while\n// the source type-checked clean. Verbose here beats broken for consumers.\n\nexport const POX5_ABI = {\n\tfunctions: [\n\t\t// Read-only\n\t\t{\n\t\t\tname: \"current-pox-reward-cycle\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-bond-allowance\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [\n\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t],\n\t\t\toutputs: { optional: \"uint128\" },\n\t\t},\n\t\t{\n\t\t\tname: \"get-bond-l1-unlock-height\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"bond-index\", type: \"uint128\" }],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-bond-membership\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"staker\", type: \"principal\" }],\n\t\t\toutputs: {\n\t\t\t\toptional: {\n\t\t\t\t\ttuple: [\n\t\t\t\t\t\t{ name: \"amount-sats\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"is-l1-lock\", type: \"bool\" },\n\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"get-first-pox-5-reward-cycle\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-protocol-bond\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"bond-index\", type: \"uint128\" }],\n\t\t\toutputs: {\n\t\t\t\toptional: {\n\t\t\t\t\ttuple: [\n\t\t\t\t\t\t{ name: \"early-unlock-bytes\", type: { buff: { length: 683 } } },\n\t\t\t\t\t\t{ name: \"min-ustx-ratio\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"stx-value-ratio\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"target-rate\", type: \"uint128\" },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"get-signer-info\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"signer\", type: \"principal\" }],\n\t\t\toutputs: { optional: { buff: { length: 33 } } },\n\t\t},\n\t\t{\n\t\t\tname: \"get-staker-custodied-sbtc\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"staker\", type: \"principal\" }],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-staker-info\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"staker\", type: \"principal\" }],\n\t\t\toutputs: {\n\t\t\t\toptional: {\n\t\t\t\t\ttuple: [\n\t\t\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"first-reward-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"num-cycles\", type: \"uint128\" },\n\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"get-total-sbtc-staked-for-bond\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [{ name: \"bond-index\", type: \"uint128\" }],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"has-announced-l1-early-exit\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [\n\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t],\n\t\t\toutputs: \"bool\",\n\t\t},\n\t\t{\n\t\t\tname: \"verify-signer-key-grant\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer-manager\", type: \"principal\" },\n\t\t\t\t{ name: \"signer-key\", type: { buff: { length: 33 } } },\n\t\t\t],\n\t\t\toutputs: { response: { ok: \"bool\", error: \"uint128\" } },\n\t\t},\n\t\t{\n\t\t\tname: \"get-earned\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t{ name: \"reward-cycle\", type: \"uint128\" },\n\t\t\t\t{ name: \"bond-index\", type: { optional: \"uint128\" } },\n\t\t\t],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-earned-staker-rewards\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t{ name: \"reward-cycle\", type: \"uint128\" },\n\t\t\t\t{ name: \"bond-index\", type: { optional: \"uint128\" } },\n\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-last-reward-compute-height\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\t\t{\n\t\t\tname: \"get-total-shares-staked-for-cycle\",\n\t\t\taccess: \"read-only\",\n\t\t\targs: [\n\t\t\t\t{ name: \"reward-cycle\", type: \"uint128\" },\n\t\t\t\t{ name: \"bond-index\", type: { optional: \"uint128\" } },\n\t\t\t],\n\t\t\toutputs: \"uint128\",\n\t\t},\n\n\t\t// Public\n\t\t{\n\t\t\tname: \"announce-l1-early-exit\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t{ name: \"old-signer-manager\", type: \"trait_reference\" },\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"amount-sats-released\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"calculate-rewards\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{\n\t\t\t\t\tname: \"bond-periods\",\n\t\t\t\t\ttype: { list: { type: \"uint128\", length: 6 } },\n\t\t\t\t},\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"accrued-rewards-per-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"bond-periods\",\n\t\t\t\t\t\t\t\ttype: { list: { type: \"uint128\", length: 6 } },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ name: \"calculation-height\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"cumulative-rewards-per-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"cycle-staked-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"gross-accrued-rewards\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"reserve-balance\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"reserve-deposit\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"stx-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"total-bond-rewards\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"total-stx-staker-rewards\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"claim-rewards\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{\n\t\t\t\t\tname: \"bond-periods\",\n\t\t\t\t\ttype: { list: { type: \"uint128\", length: 6 } },\n\t\t\t\t},\n\t\t\t\t{ name: \"reward-cycle\", type: \"uint128\" },\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"bond-rewards\",\n\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\tlist: {\n\t\t\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"earned\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"rewards-per-token\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tlength: 6,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ name: \"bond-totals\", type: \"uint128\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"stx-rewards\",\n\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t\t\t\t{ name: \"earned\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t{ name: \"rewards-per-token\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ name: \"total-rewards\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"claim-staker-rewards-for-signer\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t{ name: \"reward-cycle\", type: \"uint128\" },\n\t\t\t\t{ name: \"bond-index\", type: { optional: \"uint128\" } },\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"earned\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"rewards-per-token\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"grant-signer-key\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer-key\", type: { buff: { length: 33 } } },\n\t\t\t\t{ name: \"signer-manager\", type: \"principal\" },\n\t\t\t\t{ name: \"auth-id\", type: \"uint128\" },\n\t\t\t\t{ name: \"signer-sig\", type: { buff: { length: 65 } } },\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"auth-id\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"signer-key\", type: { buff: { length: 33 } } },\n\t\t\t\t\t\t\t{ name: \"signer-manager\", type: \"principal\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"register-for-bond\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t{ name: \"signer-manager\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t{\n\t\t\t\t\tname: \"btc-lockup\",\n\t\t\t\t\ttype: {\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tok: {\n\t\t\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: \"outputs\",\n\t\t\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\t\t\tlist: {\n\t\t\t\t\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"amount\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"header\", type: { buff: { length: 80 } } },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"height\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tname: \"leaf-hashes\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlist: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype: { buff: { length: 32 } },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlength: 14,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"output-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"tx\", type: { buff: { length: 100000 } } },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"tx-count\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"tx-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"unlock-burn-height\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\tlength: 10,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tname: \"staker-unlock-bytes\",\n\t\t\t\t\t\t\t\t\t\ttype: { buff: { length: 683 } },\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\terror: \"uint128\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: \"signer-calldata\",\n\t\t\t\t\ttype: {\n\t\t\t\t\t\toptional: { buff: { length: 500 } },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"btc-lockup\",\n\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tname: \"txs\",\n\t\t\t\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\t\t\t\toptional: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tlist: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ name: \"output-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tname: \"txid\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype: { buff: { length: 32 } },\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlength: 10,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tname: \"type\",\n\t\t\t\t\t\t\t\t\t\t\ttype: { \"string-ascii\": { length: 2 } },\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ name: \"first-reward-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"is-l1-lock\", type: \"bool\" },\n\t\t\t\t\t\t\t{ name: \"sats-total\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"unlock-burn-height\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"unlock-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"revoke-signer-grant\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer-manager\", type: \"principal\" },\n\t\t\t\t{ name: \"signer-key\", type: { buff: { length: 33 } } },\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"existed\", type: \"bool\" },\n\t\t\t\t\t\t\t{ name: \"signer-key\", type: { buff: { length: 33 } } },\n\t\t\t\t\t\t\t{ name: \"signer-manager\", type: \"principal\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"setup-bond\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t{ name: \"target-rate\", type: \"uint128\" },\n\t\t\t\t{ name: \"stx-value-ratio\", type: \"uint128\" },\n\t\t\t\t{ name: \"min-ustx-ratio\", type: \"uint128\" },\n\t\t\t\t{ name: \"early-unlock-bytes\", type: { buff: { length: 683 } } },\n\t\t\t\t{\n\t\t\t\t\tname: \"allowlist\",\n\t\t\t\t\ttype: {\n\t\t\t\t\t\tlist: {\n\t\t\t\t\t\t\ttype: {\n\t\t\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t\t\t{ name: \"max-sats\", type: \"uint128\" },\n\t\t\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tlength: 1000,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tname: \"early-unlock-bytes\",\n\t\t\t\t\t\t\t\ttype: { buff: { length: 683 } },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ name: \"max-allocation-sats\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"min-ustx-ratio\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"stx-value-ratio\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"target-rate\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"stake\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer-manager\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t{ name: \"num-cycles\", type: \"uint128\" },\n\t\t\t\t{ name: \"start-burn-ht\", type: \"uint128\" },\n\t\t\t\t{\n\t\t\t\t\tname: \"signer-calldata\",\n\t\t\t\t\ttype: {\n\t\t\t\t\t\toptional: { buff: { length: 500 } },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"first-reward-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"num-cycles\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"unlock-burn-height\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"unlock-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"stake-update\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer-manager\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"old-signer-manager\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"cycles-to-extend\", type: \"uint128\" },\n\t\t\t\t{ name: \"amount-increase\", type: \"uint128\" },\n\t\t\t\t{\n\t\t\t\t\tname: \"signer-calldata\",\n\t\t\t\t\ttype: {\n\t\t\t\t\t\toptional: { buff: { length: 500 } },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"amount-increase\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"cycles-to-extend\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"num-cycles\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"old-signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"prev-unlock-height\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"unlock-burn-height\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"unlock-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"unstake\",\n\t\t\taccess: \"public\",\n\t\t\targs: [{ name: \"old-signer-manager\", type: \"trait_reference\" }],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"first-reward-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"unlock-burn-height\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"unlock-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"unstake-sbtc\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer-manager\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"amount-to-withdrawal-sats\", type: \"uint128\" },\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"amount-withdrawn-sats\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"new-amount-sats\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"update-bond-registration\",\n\t\t\taccess: \"public\",\n\t\t\targs: [\n\t\t\t\t{ name: \"signer-manager\", type: \"trait_reference\" },\n\t\t\t\t{ name: \"old-signer-manager\", type: \"trait_reference\" },\n\t\t\t\t{\n\t\t\t\t\tname: \"signer-calldata\",\n\t\t\t\t\ttype: {\n\t\t\t\t\t\toptional: { buff: { length: 500 } },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"amount-sats\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"amount-ustx\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"bond-index\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"first-reward-cycle\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"is-l1-lock\", type: \"bool\" },\n\t\t\t\t\t\t\t{ name: \"num-cycles\", type: \"uint128\" },\n\t\t\t\t\t\t\t{ name: \"old-signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"signer\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"staker\", type: \"principal\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"set-bond-admin\",\n\t\t\taccess: \"public\",\n\t\t\targs: [{ name: \"new-admin\", type: \"principal\" }],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"new-admin\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"old-admin\", type: \"principal\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"set-pause-admin\",\n\t\t\taccess: \"public\",\n\t\t\targs: [{ name: \"new-admin\", type: \"principal\" }],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: {\n\t\t\t\t\t\ttuple: [\n\t\t\t\t\t\t\t{ name: \"new-admin\", type: \"principal\" },\n\t\t\t\t\t\t\t{ name: \"old-admin\", type: \"principal\" },\n\t\t\t\t\t\t],\n\t\t\t\t\t},\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"pause-rewards\",\n\t\t\taccess: \"public\",\n\t\t\targs: [],\n\t\t\toutputs: {\n\t\t\t\tresponse: {\n\t\t\t\t\tok: \"bool\",\n\t\t\t\t\terror: \"uint128\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t],\n} as const satisfies AbiContract;\n",
    "import { getContract } from \"../actions/getContract.ts\";\nimport type { FeeParam } from \"../actions/wallet/utils.ts\";\nimport type { Client } from \"../clients/types.ts\";\nimport type {\n\tPostConditionInput,\n\tPostConditionMode,\n} from \"../postconditions/types.ts\";\nimport {\n\ttype IntegerType,\n\thexToBytes,\n\tintToBigInt,\n} from \"../utils/encoding.ts\";\nimport { POX5_ABI } from \"./abi.ts\";\nimport { POX5_CONTRACT_NAME } from \"./constants.ts\";\nimport type {\n\tBondAllowance,\n\tBondMembership,\n\tProtocolBond,\n\tSignerInfo,\n\tStakerInfo,\n} from \"./types.ts\";\n\n/**\n * PoX-5 contract calls and reads, pinned against the final contract in\n * stacks-core 4.0.0. Wallet actions route through `callContract`, so they\n * inherit fee tiers, nonce management, and typed broadcast errors; pair the\n * returned txid with `waitForTransactionReceipt` to await inclusion.\n *\n * Note: pox-5 uses `contract-caller`/`tx-sender` directly (there is no\n * `allow-contract-caller` indirection like pox-4). Amount/lock safety is\n * expressed with the new Epoch 4.0 `Staking`/`Pox` post-conditions — pass\n * them via `postConditions` on any of these actions.\n */\n\n/** Resolve the boot `pox-5` contract id for the client's chain. */\nexport function pox5ContractId(client: Client): string {\n\tconst boot = client.chain?.bootAddress;\n\tif (!boot) throw new Error(\"Client must have a chain with a bootAddress\");\n\treturn `${boot}.${POX5_CONTRACT_NAME}`;\n}\n\ntype TxOptions = {\n\tfee?: FeeParam;\n\tnonce?: IntegerType;\n\tpostConditions?: PostConditionInput[];\n\tpostConditionMode?: PostConditionMode;\n};\n\nfunction getPox5Contract(client: Client) {\n\tconst [address, name] = pox5ContractId(client).split(\".\") as [string, string];\n\treturn getContract({ client, address, name, abi: POX5_ABI });\n}\n\n// ---------------------------------------------------------------------------\n// L1 BTC lockup proof shape (register-for-bond's ok-branch outputs)\n// ---------------------------------------------------------------------------\n\n/**\n * One proven L1 timelock output — a Bitcoin SPV inclusion proof of the lockup\n * tx plus which output is the lockup. `@secondlayer/stacks/bitcoin`'s\n * `buildTxProof` produces the proof fields.\n */\nexport type L1LockupOutput = {\n\t/** Burn height of the Bitcoin block containing the lockup tx. */\n\theight: IntegerType;\n\t/** Raw Bitcoin tx (witness-stripped), hex or bytes. */\n\ttx: Uint8Array | string;\n\toutputIndex: IntegerType;\n\t/** 80-byte Bitcoin block header. */\n\theader: Uint8Array | string;\n\t/** Merkle siblings, leaf→root (max 14). */\n\tleafHashes: Array<Uint8Array | string>;\n\ttxCount: IntegerType;\n\ttxIndex: IntegerType;\n\t/** Output value in sats. */\n\tamount: IntegerType;\n\tunlockBurnHeight: IntegerType;\n};\n\n/** BTC side of a bond registration: proven L1 lockups, or an sBTC amount. */\nexport type BtcLockup =\n\t| { l1Outputs: L1LockupOutput[]; stakerUnlockBytes: Uint8Array | string }\n\t| { sbtcSats: IntegerType };\n\n/** ABI buff args take `Uint8Array`; hex strings decode exactly like `Cl.bufferFromHex`. */\nfunction toBytes(input: Uint8Array | string): Uint8Array {\n\treturn typeof input === \"string\" ? hexToBytes(input) : input;\n}\n\n/** ABI `(optional (buff …))` args are required-with-null. */\nfunction optionalBytes(input?: Uint8Array | string): Uint8Array | null {\n\treturn input === undefined ? null : toBytes(input);\n}\n\nconst MAX_LOCKUP_OUTPUTS = 10;\nconst MAX_LEAF_HASHES = 14;\n\n/** Map `BtcLockup` to the ABI's `(response (tuple …) uint)` arg shape. */\nfunction btcLockupArg(lockup: BtcLockup) {\n\tif (\"sbtcSats\" in lockup) return { err: intToBigInt(lockup.sbtcSats) };\n\tif (lockup.l1Outputs.length === 0) {\n\t\tthrow new Error(\n\t\t\t\"registerForBond: l1Outputs is empty — nothing would be locked\",\n\t\t);\n\t}\n\tif (lockup.l1Outputs.length > MAX_LOCKUP_OUTPUTS) {\n\t\tthrow new Error(\n\t\t\t`registerForBond: ${lockup.l1Outputs.length} lockup outputs; pox-5 accepts at most ${MAX_LOCKUP_OUTPUTS}`,\n\t\t);\n\t}\n\tfor (let i = 0; i < lockup.l1Outputs.length; i++) {\n\t\tconst n = lockup.l1Outputs[i]?.leafHashes.length ?? 0;\n\t\tif (n > MAX_LEAF_HASHES) {\n\t\t\tthrow new Error(\n\t\t\t\t`registerForBond: output ${i} has ${n} merkle siblings; pox-5 accepts at most ${MAX_LEAF_HASHES}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn {\n\t\tok: {\n\t\t\toutputs: lockup.l1Outputs.map((o) => ({\n\t\t\t\theight: intToBigInt(o.height),\n\t\t\t\ttx: toBytes(o.tx),\n\t\t\t\toutputIndex: intToBigInt(o.outputIndex),\n\t\t\t\theader: toBytes(o.header),\n\t\t\t\tleafHashes: o.leafHashes.map(toBytes),\n\t\t\t\ttxCount: intToBigInt(o.txCount),\n\t\t\t\ttxIndex: intToBigInt(o.txIndex),\n\t\t\t\tamount: intToBigInt(o.amount),\n\t\t\t\tunlockBurnHeight: intToBigInt(o.unlockBurnHeight),\n\t\t\t})),\n\t\t\tstakerUnlockBytes: toBytes(lockup.stakerUnlockBytes),\n\t\t},\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Wallet actions (broadcast a pox-5 contract call, return the txid)\n// ---------------------------------------------------------------------------\n\nexport type SetupBondParams = TxOptions & {\n\tbondIndex: IntegerType;\n\t/** Target yield rate, basis points. */\n\ttargetRate: IntegerType;\n\t/** µSTX per 100 sats (BTCUSD / STXUSD representation). */\n\tstxValueRatio: IntegerType;\n\t/** Minimum locked STX relative to BTC, basis points. */\n\tminUstxRatio: IntegerType;\n\t/** Early-unlock subscript for this bond's L1 lockup scripts (max 683B). */\n\tearlyUnlockBytes: Uint8Array | string;\n\tallowlist: Array<{ staker: string; maxSats: IntegerType }>;\n};\n\n/** `setup-bond` — bond-admin only. */\nexport function setupBond(\n\tclient: Client,\n\tparams: SetupBondParams,\n): Promise<string> {\n\tconst {\n\t\tbondIndex,\n\t\ttargetRate,\n\t\tstxValueRatio,\n\t\tminUstxRatio,\n\t\tearlyUnlockBytes,\n\t\tallowlist,\n\t\t...tx\n\t} = params;\n\treturn getPox5Contract(client).call.setupBond(\n\t\t{\n\t\t\tbondIndex: intToBigInt(bondIndex),\n\t\t\ttargetRate: intToBigInt(targetRate),\n\t\t\tstxValueRatio: intToBigInt(stxValueRatio),\n\t\t\tminUstxRatio: intToBigInt(minUstxRatio),\n\t\t\tearlyUnlockBytes: toBytes(earlyUnlockBytes),\n\t\t\tallowlist: allowlist.map((a) => ({\n\t\t\t\tstaker: a.staker,\n\t\t\t\tmaxSats: intToBigInt(a.maxSats),\n\t\t\t})),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type RegisterForBondParams = TxOptions & {\n\tbondIndex: IntegerType;\n\t/** Signer-manager contract principal. */\n\tsignerManager: string;\n\tamountUstx: IntegerType;\n\tbtcLockup: BtcLockup;\n\tsignerCalldata?: Uint8Array | string;\n};\n\n/** `register-for-bond` — join a bond with proven L1 lockups or sBTC. */\nexport function registerForBond(\n\tclient: Client,\n\tparams: RegisterForBondParams,\n): Promise<string> {\n\tconst {\n\t\tbondIndex,\n\t\tsignerManager,\n\t\tamountUstx,\n\t\tbtcLockup,\n\t\tsignerCalldata,\n\t\t...tx\n\t} = params;\n\treturn getPox5Contract(client).call.registerForBond(\n\t\t{\n\t\t\tbondIndex: intToBigInt(bondIndex),\n\t\t\tsignerManager,\n\t\t\tamountUstx: intToBigInt(amountUstx),\n\t\t\tbtcLockup: btcLockupArg(btcLockup),\n\t\t\tsignerCalldata: optionalBytes(signerCalldata),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type UpdateBondRegistrationParams = TxOptions & {\n\tsignerManager: string;\n\toldSignerManager: string;\n\tsignerCalldata?: Uint8Array | string;\n};\n\n/** `update-bond-registration` — switch signer-managers mid-bond. */\nexport function updateBondRegistration(\n\tclient: Client,\n\tparams: UpdateBondRegistrationParams,\n): Promise<string> {\n\tconst { signerManager, oldSignerManager, signerCalldata, ...tx } = params;\n\treturn getPox5Contract(client).call.updateBondRegistration(\n\t\t{\n\t\t\tsignerManager,\n\t\t\toldSignerManager,\n\t\t\tsignerCalldata: optionalBytes(signerCalldata),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type StakeParams = TxOptions & {\n\tsignerManager: string;\n\tamountUstx: IntegerType;\n\tnumCycles: IntegerType;\n\tstartBurnHeight: IntegerType;\n\tsignerCalldata?: Uint8Array | string;\n};\n\n/** `stake` — STX-only staking. */\nexport function stake(client: Client, params: StakeParams): Promise<string> {\n\tconst {\n\t\tsignerManager,\n\t\tamountUstx,\n\t\tnumCycles,\n\t\tstartBurnHeight,\n\t\tsignerCalldata,\n\t\t...tx\n\t} = params;\n\treturn getPox5Contract(client).call.stake(\n\t\t{\n\t\t\tsignerManager,\n\t\t\tamountUstx: intToBigInt(amountUstx),\n\t\t\tnumCycles: intToBigInt(numCycles),\n\t\t\tstartBurnHt: intToBigInt(startBurnHeight),\n\t\t\tsignerCalldata: optionalBytes(signerCalldata),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type StakeUpdateParams = TxOptions & {\n\tsignerManager: string;\n\toldSignerManager: string;\n\tcyclesToExtend: IntegerType;\n\tamountIncrease: IntegerType;\n\tsignerCalldata?: Uint8Array | string;\n};\n\n/** `stake-update` — extend and/or increase an STX-only position. */\nexport function stakeUpdate(\n\tclient: Client,\n\tparams: StakeUpdateParams,\n): Promise<string> {\n\tconst {\n\t\tsignerManager,\n\t\toldSignerManager,\n\t\tcyclesToExtend,\n\t\tamountIncrease,\n\t\tsignerCalldata,\n\t\t...tx\n\t} = params;\n\treturn getPox5Contract(client).call.stakeUpdate(\n\t\t{\n\t\t\tsignerManager,\n\t\t\toldSignerManager,\n\t\t\tcyclesToExtend: intToBigInt(cyclesToExtend),\n\t\t\tamountIncrease: intToBigInt(amountIncrease),\n\t\t\tsignerCalldata: optionalBytes(signerCalldata),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type UnstakeParams = TxOptions & { oldSignerManager: string };\n\n/** `unstake` — wind down an STX-only position at the next cycle. */\nexport function unstake(\n\tclient: Client,\n\tparams: UnstakeParams,\n): Promise<string> {\n\tconst { oldSignerManager, ...tx } = params;\n\treturn getPox5Contract(client).call.unstake({ oldSignerManager }, tx);\n}\n\nexport type UnstakeSbtcParams = TxOptions & {\n\tsignerManager: string;\n\tamountSats: IntegerType;\n};\n\n/** `unstake-sbtc` — withdraw custodied sBTC from a bond (rejected in prepare phase). */\nexport function unstakeSbtc(\n\tclient: Client,\n\tparams: UnstakeSbtcParams,\n): Promise<string> {\n\tconst { signerManager, amountSats, ...tx } = params;\n\treturn getPox5Contract(client).call.unstakeSbtc(\n\t\t{ signerManager, amountToWithdrawalSats: intToBigInt(amountSats) },\n\t\ttx,\n\t);\n}\n\nexport type AnnounceL1EarlyExitParams = TxOptions & {\n\tstaker: string;\n\toldSignerManager: string;\n};\n\n/** `announce-l1-early-exit` — staker-callable since 4.0.0 (rejected in prepare phase). */\nexport function announceL1EarlyExit(\n\tclient: Client,\n\tparams: AnnounceL1EarlyExitParams,\n): Promise<string> {\n\tconst { staker, oldSignerManager, ...tx } = params;\n\treturn getPox5Contract(client).call.announceL1EarlyExit(\n\t\t{ staker, oldSignerManager },\n\t\ttx,\n\t);\n}\n\nexport type CalculateRewardsParams = TxOptions & {\n\tbondPeriods: IntegerType[];\n};\n\n/** `calculate-rewards` — settle the reward accounting for up to 6 bond periods. */\nexport function calculateRewards(\n\tclient: Client,\n\tparams: CalculateRewardsParams,\n): Promise<string> {\n\tconst { bondPeriods, ...tx } = params;\n\treturn getPox5Contract(client).call.calculateRewards(\n\t\t{ bondPeriods: bondPeriods.map(intToBigInt) },\n\t\ttx,\n\t);\n}\n\nexport type ClaimRewardsParams = TxOptions & {\n\tbondPeriods: IntegerType[];\n\trewardCycle: IntegerType;\n};\n\n/** `claim-rewards` — signer-manager claims accrued rewards for a cycle. */\nexport function claimRewards(\n\tclient: Client,\n\tparams: ClaimRewardsParams,\n): Promise<string> {\n\tconst { bondPeriods, rewardCycle, ...tx } = params;\n\treturn getPox5Contract(client).call.claimRewards(\n\t\t{\n\t\t\tbondPeriods: bondPeriods.map(intToBigInt),\n\t\t\trewardCycle: intToBigInt(rewardCycle),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type ClaimStakerRewardsForSignerParams = TxOptions & {\n\tstaker: string;\n\trewardCycle: IntegerType;\n\tbondIndex?: IntegerType;\n};\n\n/** `claim-staker-rewards-for-signer`. */\nexport function claimStakerRewardsForSigner(\n\tclient: Client,\n\tparams: ClaimStakerRewardsForSignerParams,\n): Promise<string> {\n\tconst { staker, rewardCycle, bondIndex, ...tx } = params;\n\treturn getPox5Contract(client).call.claimStakerRewardsForSigner(\n\t\t{\n\t\t\tstaker,\n\t\t\trewardCycle: intToBigInt(rewardCycle),\n\t\t\tbondIndex: bondIndex === undefined ? null : intToBigInt(bondIndex),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type GrantSignerKeyParams = TxOptions & {\n\t/** 33-byte compressed signer key. */\n\tsignerKey: Uint8Array | string;\n\tsignerManager: string;\n\tauthId: IntegerType;\n\t/** 65-byte RSV signature from `signSignerGrant`. */\n\tsignerSig: Uint8Array | string;\n};\n\n/** `grant-signer-key` — callable by the signer-manager contract itself. */\nexport function grantSignerKey(\n\tclient: Client,\n\tparams: GrantSignerKeyParams,\n): Promise<string> {\n\tconst { signerKey, signerManager, authId, signerSig, ...tx } = params;\n\treturn getPox5Contract(client).call.grantSignerKey(\n\t\t{\n\t\t\tsignerKey: toBytes(signerKey),\n\t\t\tsignerManager,\n\t\t\tauthId: intToBigInt(authId),\n\t\t\tsignerSig: toBytes(signerSig),\n\t\t},\n\t\ttx,\n\t);\n}\n\nexport type RevokeSignerGrantParams = TxOptions & {\n\tsignerManager: string;\n\tsignerKey: Uint8Array | string;\n};\n\n/** `revoke-signer-grant`. */\nexport function revokeSignerGrant(\n\tclient: Client,\n\tparams: RevokeSignerGrantParams,\n): Promise<string> {\n\tconst { signerManager, signerKey, ...tx } = params;\n\treturn getPox5Contract(client).call.revokeSignerGrant(\n\t\t{ signerManager, signerKey: toBytes(signerKey) },\n\t\ttx,\n\t);\n}\n\nexport type SetBondAdminParams = TxOptions & { newAdmin: string };\n\n/** `set-bond-admin` — current bond-admin only. */\nexport function setBondAdmin(\n\tclient: Client,\n\tparams: SetBondAdminParams,\n): Promise<string> {\n\tconst { newAdmin, ...tx } = params;\n\treturn getPox5Contract(client).call.setBondAdmin({ newAdmin }, tx);\n}\n\nexport type SetPauseAdminParams = TxOptions & { newAdmin: string };\n\n/** `set-pause-admin` — current pause-admin only. */\nexport function setPauseAdmin(\n\tclient: Client,\n\tparams: SetPauseAdminParams,\n): Promise<string> {\n\tconst { newAdmin, ...tx } = params;\n\treturn getPox5Contract(client).call.setPauseAdmin({ newAdmin }, tx);\n}\n\nexport type PauseRewardsParams = TxOptions;\n\n/**\n * `pause-rewards` — one-way. After this call succeeds, rewards stay paused\n * (`ERR_REWARDS_PAUSED`); there is no unpause.\n */\nexport function pauseRewards(\n\tclient: Client,\n\tparams?: PauseRewardsParams,\n): Promise<string> {\n\treturn getPox5Contract(client).call.pauseRewards({}, params ?? {});\n}\n\n// ---------------------------------------------------------------------------\n// Reads (JS-mapped return types — see types.ts)\n// ---------------------------------------------------------------------------\n\n/** `get-staker-info` — lock dimensions + signer, `none` when expired/absent. */\nexport async function getStakerInfo(\n\tclient: Client,\n\tstaker: string,\n): Promise<StakerInfo> {\n\treturn (await getPox5Contract(client).read.getStakerInfo({\n\t\tstaker,\n\t})) as StakerInfo;\n}\n\n/** `get-bond-membership` — the staker's active bond membership, if any. */\nexport async function getBondMembership(\n\tclient: Client,\n\tstaker: string,\n): Promise<BondMembership> {\n\treturn (await getPox5Contract(client).read.getBondMembership({\n\t\tstaker,\n\t})) as BondMembership;\n}\n\n/** `get-protocol-bond` — a bond's core parameters. */\nexport async function getProtocolBond(\n\tclient: Client,\n\tbondIndex: IntegerType,\n): Promise<ProtocolBond> {\n\treturn (await getPox5Contract(client).read.getProtocolBond({\n\t\tbondIndex: intToBigInt(bondIndex),\n\t})) as ProtocolBond;\n}\n\n/** `get-bond-allowance` — a staker's allowlisted max sats for a bond. */\nexport async function getBondAllowance(\n\tclient: Client,\n\tbondIndex: IntegerType,\n\tstaker: string,\n): Promise<BondAllowance> {\n\treturn (await getPox5Contract(client).read.getBondAllowance({\n\t\tbondIndex: intToBigInt(bondIndex),\n\t\tstaker,\n\t})) as BondAllowance;\n}\n\n/** `get-total-sbtc-staked-for-bond`. */\nexport function getTotalSbtcStakedForBond(\n\tclient: Client,\n\tbondIndex: IntegerType,\n): Promise<bigint> {\n\treturn getPox5Contract(client).read.getTotalSbtcStakedForBond({\n\t\tbondIndex: intToBigInt(bondIndex),\n\t});\n}\n\n/** `get-staker-custodied-sbtc`. */\nexport function getStakerCustodiedSbtc(\n\tclient: Client,\n\tstaker: string,\n): Promise<bigint> {\n\treturn getPox5Contract(client).read.getStakerCustodiedSbtc({ staker });\n}\n\n/** `has-announced-l1-early-exit`. */\nexport function hasAnnouncedL1EarlyExit(\n\tclient: Client,\n\tbondIndex: IntegerType,\n\tstaker: string,\n): Promise<boolean> {\n\treturn getPox5Contract(client).read.hasAnnouncedL1EarlyExit({\n\t\tbondIndex: intToBigInt(bondIndex),\n\t\tstaker,\n\t});\n}\n\n/** `get-bond-l1-unlock-height` — half a cycle before the bond period ends. */\nexport function getBondL1UnlockHeight(\n\tclient: Client,\n\tbondIndex: IntegerType,\n): Promise<bigint> {\n\treturn getPox5Contract(client).read.getBondL1UnlockHeight({\n\t\tbondIndex: intToBigInt(bondIndex),\n\t});\n}\n\n/** `get-signer-info`. */\nexport async function getSignerInfo(\n\tclient: Client,\n\tsigner: string,\n): Promise<SignerInfo> {\n\treturn (await getPox5Contract(client).read.getSignerInfo({\n\t\tsigner,\n\t})) as SignerInfo;\n}\n\n/** `verify-signer-key-grant` — whether a grant exists on-chain. */\nexport function verifySignerKeyGrantOnChain(\n\tclient: Client,\n\tsignerManager: string,\n\tsignerKey: Uint8Array | string,\n): Promise<boolean> {\n\treturn getPox5Contract(client).read.verifySignerKeyGrant({\n\t\tsignerManager,\n\t\tsignerKey: toBytes(signerKey),\n\t});\n}\n\n/** `current-pox-reward-cycle`. */\nexport function getCurrentRewardCycle(client: Client): Promise<bigint> {\n\treturn getPox5Contract(client).read.currentPoxRewardCycle({});\n}\n\n/** `get-first-pox-5-reward-cycle`. */\nexport function getFirstPox5RewardCycle(client: Client): Promise<bigint> {\n\treturn getPox5Contract(client).read.getFirstPox5RewardCycle({});\n}\n\n/** `get-earned` — claimable rewards for a signer in a cycle (optional bond). */\nexport function getEarned(\n\tclient: Client,\n\tparams: {\n\t\tsigner: string;\n\t\trewardCycle: IntegerType;\n\t\tbondIndex?: IntegerType;\n\t},\n): Promise<bigint> {\n\treturn getPox5Contract(client).read.getEarned({\n\t\tsigner: params.signer,\n\t\trewardCycle: intToBigInt(params.rewardCycle),\n\t\tbondIndex:\n\t\t\tparams.bondIndex === undefined ? null : intToBigInt(params.bondIndex),\n\t});\n}\n\n/** `get-earned-staker-rewards` — a staker's share of a signer's cycle rewards. */\nexport function getEarnedStakerRewards(\n\tclient: Client,\n\tparams: {\n\t\tsigner: string;\n\t\trewardCycle: IntegerType;\n\t\tbondIndex?: IntegerType;\n\t\tstaker: string;\n\t},\n): Promise<bigint> {\n\treturn getPox5Contract(client).read.getEarnedStakerRewards({\n\t\tsigner: params.signer,\n\t\trewardCycle: intToBigInt(params.rewardCycle),\n\t\tbondIndex:\n\t\t\tparams.bondIndex === undefined ? null : intToBigInt(params.bondIndex),\n\t\tstaker: params.staker,\n\t});\n}\n\n/** `get-last-reward-compute-height`. */\nexport function getLastRewardComputeHeight(client: Client): Promise<bigint> {\n\treturn getPox5Contract(client).read.getLastRewardComputeHeight({});\n}\n\n/** `get-total-shares-staked-for-cycle`. */\nexport function getTotalSharesStakedForCycle(\n\tclient: Client,\n\trewardCycle: IntegerType,\n\tbondIndex?: IntegerType,\n): Promise<bigint> {\n\treturn getPox5Contract(client).read.getTotalSharesStakedForCycle({\n\t\trewardCycle: intToBigInt(rewardCycle),\n\t\tbondIndex: bondIndex === undefined ? null : intToBigInt(bondIndex),\n\t});\n}\n",
    "import { BOND_GAP_CYCLES, BOND_LENGTH_CYCLES } from \"./constants.ts\";\n\n/**\n * Pure cycle/height math, mirroring the pox-5 helper read-onlys byte-for-byte\n * (`burn-height-to-reward-cycle`, `reward-cycle-to-burn-height`,\n * `bond-period-to-reward-cycle`, `burn-height-to-distribution-index`).\n *\n * All functions anchor on chain-reported parameters — pass values from\n * `/v2/pox` (`first_burnchain_block_height`, `reward_cycle_length`,\n * `prepare_cycle_length`) and `getPox5Activation` (`firstRewardCycleId` =\n * the contract's `first-bond-period-cycle`). Nothing is hardcoded, so the\n * math is correct on mainnet, testnet, and devnet alike.\n */\nexport type PoxCycleParams = {\n\t/** `/v2/pox` `first_burnchain_block_height`. */\n\tfirstBurnchainBlockHeight: number;\n\t/** `/v2/pox` `reward_cycle_length` (mainnet 2100). */\n\trewardCycleLength: number;\n};\n\nexport type BondCycleParams = PoxCycleParams & {\n\t/** pox-5's first bond-period cycle (`getPox5Activation().firstRewardCycleId`). */\n\tfirstBondPeriodCycle: number;\n};\n\n/** Reward cycle containing `burnHeight`. Mirrors `burn-height-to-reward-cycle`. */\nexport function burnHeightToRewardCycle(\n\tburnHeight: number,\n\tparams: PoxCycleParams,\n): number {\n\tif (burnHeight < params.firstBurnchainBlockHeight) {\n\t\tthrow new Error(\n\t\t\t`burnHeight ${burnHeight} precedes first burnchain block ${params.firstBurnchainBlockHeight}`,\n\t\t);\n\t}\n\treturn Math.floor(\n\t\t(burnHeight - params.firstBurnchainBlockHeight) / params.rewardCycleLength,\n\t);\n}\n\n/** Burn height at the start of `cycle`. Mirrors `reward-cycle-to-burn-height`. */\nexport function rewardCycleToBurnHeight(\n\tcycle: number,\n\tparams: PoxCycleParams,\n): number {\n\treturn params.firstBurnchainBlockHeight + cycle * params.rewardCycleLength;\n}\n\n/** Reward cycle at which bond period `bondIndex` starts. Mirrors `bond-period-to-reward-cycle`. */\nexport function bondPeriodToRewardCycle(\n\tbondIndex: number,\n\tparams: BondCycleParams,\n): number {\n\treturn params.firstBondPeriodCycle + bondIndex * BOND_GAP_CYCLES;\n}\n\n/** Burn height at which bond period `bondIndex` starts. Mirrors `bond-period-to-burn-height`. */\nexport function bondPeriodToBurnHeight(\n\tbondIndex: number,\n\tparams: BondCycleParams,\n): number {\n\treturn rewardCycleToBurnHeight(\n\t\tbondPeriodToRewardCycle(bondIndex, params),\n\t\tparams,\n\t);\n}\n\n/** First reward cycle in which bond `bondIndex`'s STX unlock (start + 12 cycles). */\nexport function bondUnlockCycle(\n\tbondIndex: number,\n\tparams: BondCycleParams,\n): number {\n\treturn bondPeriodToRewardCycle(bondIndex, params) + BOND_LENGTH_CYCLES;\n}\n\n/**\n * Minimum L1 CLTV height for bond `bondIndex` — half a cycle before the\n * bond period ends. Mirrors `get-bond-l1-unlock-height`. Distinct from\n * {@link bondUnlockCycle} (the STX unlock cycle).\n */\nexport function computeBondUnlockHeight(\n\tbondIndex: number,\n\tparams: BondCycleParams,\n): number {\n\tconst endCycle = bondPeriodToRewardCycle(\n\t\tbondIndex + BOND_LENGTH_CYCLES / BOND_GAP_CYCLES,\n\t\tparams,\n\t);\n\treturn (\n\t\trewardCycleToBurnHeight(endCycle, params) -\n\t\tMath.floor(params.rewardCycleLength / 2)\n\t);\n}\n\n/**\n * Distribution-cycle index at `burnHeight` — distribution cycles are half a\n * reward cycle long. Mirrors `burn-height-to-distribution-index`.\n */\nexport function burnHeightToDistributionIndex(\n\tburnHeight: number,\n\tparams: PoxCycleParams,\n): number {\n\treturn Math.floor(\n\t\t(burnHeight - params.firstBurnchainBlockHeight) /\n\t\t\tMath.floor(params.rewardCycleLength / 2),\n\t);\n}\n\n/** Burn height at the start of `distIndex`. Mirrors `distribution-cycle-to-burn-height`. */\nexport function distributionCycleToBurnHeight(\n\tdistIndex: number,\n\tparams: PoxCycleParams,\n): number {\n\treturn (\n\t\tparams.firstBurnchainBlockHeight +\n\t\tdistIndex * Math.floor(params.rewardCycleLength / 2)\n\t);\n}\n\n/**\n * Distribution cycle containing `burnHeight`. Named after the contract's\n * `current-distribution-cycle` but takes height as an argument — no clock.\n */\nexport function currentDistributionCycle(\n\tburnHeight: number,\n\tparams: PoxCycleParams,\n): number {\n\treturn burnHeightToDistributionIndex(burnHeight, params);\n}\n\n/**\n * Whether `burnHeight` falls in a cycle's prepare phase (the final\n * `prepareCycleLength` blocks). pox-5 rejects `unstake-sbtc` and\n * `announce-l1-early-exit` during a prepare phase.\n */\nexport function isInPreparePhase(\n\tburnHeight: number,\n\tparams: PoxCycleParams & { prepareCycleLength: number },\n): boolean {\n\tconst offset =\n\t\t(burnHeight - params.firstBurnchainBlockHeight) % params.rewardCycleLength;\n\treturn offset >= params.rewardCycleLength - params.prepareCycleLength;\n}\n\nexport type BondPhase = \"too-early\" | \"open\" | \"locked\" | \"unlocked\";\n\n/**\n * Coarse lifecycle phase of bond `bondIndex` at `burnHeight`: `too-early`\n * (before the bond's start is registerable), `open`/`locked` while active,\n * `unlocked` after 12 cycles.\n */\nexport function bondPhaseAtHeight(\n\tbondIndex: number,\n\tburnHeight: number,\n\tparams: BondCycleParams,\n): BondPhase {\n\tconst cycle = burnHeightToRewardCycle(burnHeight, params);\n\tconst start = bondPeriodToRewardCycle(bondIndex, params);\n\tconst unlock = bondUnlockCycle(bondIndex, params);\n\tif (cycle < start - BOND_GAP_CYCLES) return \"too-early\";\n\tif (cycle < start) return \"open\";\n\tif (cycle < unlock) return \"locked\";\n\treturn \"unlocked\";\n}\n\n/**\n * Prepare-aware bond lifecycle. `open` is the registerable window — it\n * ends when the start cycle's prepare phase begins (`register-for-bond`\n * then fails with `ERR_STAKE_IN_PREPARE_PHASE`). Coarse cycle buckets\n * (whole pre-start cycle as `open`) stay on {@link BondPhase}.\n *\n * `eligible`/`missed`/`finished` are omitted: they are not contract\n * states (registration is height-gated, not a per-staker enum).\n */\nexport type BondStatusName = \"too-early\" | \"open\" | \"locked\" | \"unlocked\";\n\nexport function bondStatusAtHeight(\n\tbondIndex: number,\n\tburnHeight: number,\n\tparams: BondCycleParams & { prepareCycleLength: number },\n): BondStatusName {\n\tconst cycle = burnHeightToRewardCycle(burnHeight, params);\n\tconst start = bondPeriodToRewardCycle(bondIndex, params);\n\tconst unlock = bondUnlockCycle(bondIndex, params);\n\tif (cycle < start - BOND_GAP_CYCLES) return \"too-early\";\n\tif (cycle < start) {\n\t\t// Prepare of the start cycle (last prepareCycleLength blocks of\n\t\t// cycle start-1) permanently closes registration. Other prepares\n\t\t// in the window still report `open`; st-022 layers isInPreparePhase.\n\t\tif (cycle === start - 1 && isInPreparePhase(burnHeight, params)) {\n\t\t\treturn \"locked\";\n\t\t}\n\t\treturn \"open\";\n\t}\n\tif (cycle < unlock) return \"locked\";\n\treturn \"unlocked\";\n}\n",
    "/**\n * Client-side pox-5 eligibility preflights. Rebuilds the contract's assert\n * chains from existing reads so callers can avoid burning fees on a known\n * abort.\n *\n * `reasons` is a **set**, not the on-chain abort order.\n *\n * Uncovered gates (Hiro skips these too — a preflight `{ ok: true }` is not\n * a guarantee the tx will land):\n * - `signer-manager-validate-stake!` (trait callback)\n * - L1 merkle proof (`ERR_INVALID_MERKLE_PROOF` u41)\n * - L1 lockup script match (`ERR_INVALID_LOCKUP_SCRIPT` u42)\n * - L1 lockup amount vs parsed tx (`ERR_INVALID_LOCKUP_AMOUNT` u45, except\n *   the empty-outputs case which we do flag)\n * - Bitcoin header / tx parse (`ERR_INVALID_BTC_HEADER` u40,\n *   `ERR_READ_TX_OUT_OF_BOUNDS` u39)\n *\n * These functions are never attached to wallet actions — call them\n * explicitly. Do not infer coverage of a gate from a missing reason.\n */\n\nimport { getBalance } from \"../actions/public/getBalance.ts\";\nimport { getDataVar } from \"../actions/public/getDataVar.ts\";\nimport { getMapEntry } from \"../actions/public/getMapEntry.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport type { Client } from \"../clients/types.ts\";\nimport {\n\ttype IntegerType,\n\tbytesToHex,\n\thexToBytes,\n\tintToBigInt,\n} from \"../utils/encoding.ts\";\nimport {\n\ttype BtcLockup,\n\tgetBondAllowance,\n\tgetBondL1UnlockHeight,\n\tgetBondMembership,\n\tgetEarned,\n\tgetProtocolBond,\n\tgetSignerInfo,\n\tgetStakerInfo,\n\tpox5ContractId,\n\tverifySignerKeyGrantOnChain,\n} from \"./actions.ts\";\nimport { getPoxInfo } from \"./activation.ts\";\nimport {\n\tBITCOIN_LOCKTIME_THRESHOLD,\n\tBOND_LENGTH_CYCLES,\n\tMAX_NUM_CYCLES,\n\tPOX5_CONTRACT_NAME,\n} from \"./constants.ts\";\nimport {\n\ttype PoxCycleParams,\n\tbondPeriodToBurnHeight,\n\tbondPeriodToRewardCycle,\n\tburnHeightToRewardCycle,\n\tisInPreparePhase,\n} from \"./cycles.ts\";\nimport { Pox5ErrorCode } from \"./errors.ts\";\nimport type { BondMembership, SignerInfo } from \"./types.ts\";\n\nexport type EligibilityResult =\n\t| { ok: true }\n\t| { ok: false; reasons: [Pox5ErrorCode, ...Pox5ErrorCode[]] };\n\nexport type EligibleStakeParams = {\n\tstaker: string;\n\tsignerManager: string;\n\tamountUstx: IntegerType;\n\tnumCycles: IntegerType;\n\tstartBurnHeight: IntegerType;\n};\n\nexport type EligibleRegisterForBondParams = {\n\tstaker: string;\n\tbondIndex: IntegerType;\n\tsignerManager: string;\n\tamountUstx: IntegerType;\n\tbtcLockup: BtcLockup;\n};\n\nexport type EligibleUnstakeParams = {\n\tstaker: string;\n\toldSignerManager: string;\n};\n\nexport type EligibleUnstakeSbtcParams = {\n\tstaker: string;\n\tsignerManager: string;\n\tamountSats: IntegerType;\n};\n\nexport type EligibleClaimRewardsParams = {\n\tsigner: string;\n\trewardCycle: IntegerType;\n\tbondIndex?: IntegerType;\n\tbondPeriods?: IntegerType[];\n};\n\nexport type EligibleGrantSignerKeyParams = {\n\tsignerKey: Uint8Array | string;\n\tsignerManager: string;\n\tauthId: IntegerType;\n};\n\nexport type EligibleAdminParams = {\n\tcaller: string;\n};\n\ntype CycleClock = {\n\tburnHeight: number;\n\tparams: PoxCycleParams & { prepareCycleLength: number };\n\tfirstBondPeriodCycle: number;\n};\n\nfunction finish(reasons: Pox5ErrorCode[]): EligibilityResult {\n\tconst unique: Pox5ErrorCode[] = [];\n\tconst seen = new Set<Pox5ErrorCode>();\n\tfor (const code of reasons) {\n\t\tif (!seen.has(code)) {\n\t\t\tseen.add(code);\n\t\t\tunique.push(code);\n\t\t}\n\t}\n\tif (unique.length === 0) return { ok: true };\n\treturn { ok: false, reasons: unique as [Pox5ErrorCode, ...Pox5ErrorCode[]] };\n}\n\nfunction toBytes(input: Uint8Array | string): Uint8Array {\n\treturn typeof input === \"string\" ? hexToBytes(input) : input;\n}\n\nfunction outpointKey(\n\ttx: Uint8Array | string,\n\toutputIndex: IntegerType,\n): string {\n\tconst hex = typeof tx === \"string\" ? tx.toLowerCase() : bytesToHex(tx);\n\treturn `${hex}:${intToBigInt(outputIndex)}`;\n}\n\n/**\n * Burn height from `getPoxInfo` (pox5/activation.ts, not frozen pox-4).\n * Cycle lengths are on `/v2/pox` but not mapped through `Pox5Info` — read\n * the same endpoint rather than guessing mainnet constants. Missing height\n * or lengths → `undefined` so callers fail closed instead of guessing.\n */\nasync function readCycleClock(client: Client): Promise<CycleClock | undefined> {\n\tconst info = await getPoxInfo(client);\n\tconst burnHeight = info.currentBurnchainBlockHeight;\n\tconst first = info.firstBurnchainBlockHeight;\n\tconst raw = (await client.request(\"/v2/pox\", { method: \"GET\" })) as {\n\t\treward_cycle_length?: number;\n\t\tprepare_cycle_length?: number;\n\t};\n\tconst pox5 = info.contractVersions.find((v) =>\n\t\tv.contractId.endsWith(`.${POX5_CONTRACT_NAME}`),\n\t);\n\tif (\n\t\ttypeof burnHeight !== \"number\" ||\n\t\ttypeof first !== \"number\" ||\n\t\ttypeof raw.reward_cycle_length !== \"number\" ||\n\t\ttypeof raw.prepare_cycle_length !== \"number\" ||\n\t\tpox5 == null\n\t) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\tburnHeight,\n\t\tparams: {\n\t\t\tfirstBurnchainBlockHeight: first,\n\t\t\trewardCycleLength: raw.reward_cycle_length,\n\t\t\tprepareCycleLength: raw.prepare_cycle_length,\n\t\t},\n\t\tfirstBondPeriodCycle: pox5.firstRewardCycleId,\n\t};\n}\n\nfunction inPrepare(clock: CycleClock | undefined): boolean {\n\tif (!clock) return true;\n\treturn isInPreparePhase(clock.burnHeight, clock.params);\n}\n\nasync function signerReasons(\n\tclient: Client,\n\tsignerManager: string,\n): Promise<Pox5ErrorCode[]> {\n\tconst info: SignerInfo = await getSignerInfo(client, signerManager);\n\tif (info == null) return [Pox5ErrorCode.SignerNotFound];\n\ttry {\n\t\tconst granted = await verifySignerKeyGrantOnChain(\n\t\t\tclient,\n\t\t\tsignerManager,\n\t\t\tinfo,\n\t\t);\n\t\tif (!granted) return [Pox5ErrorCode.SignerKeyGrantNotFound];\n\t} catch {\n\t\treturn [Pox5ErrorCode.SignerKeyGrantNotFound];\n\t}\n\treturn [];\n}\n\nfunction bondOverlaps(\n\tmembership: BondMembership,\n\tnewFirstCycle: number,\n\tclock: CycleClock,\n): boolean {\n\tif (!membership) return false;\n\tconst start = bondPeriodToRewardCycle(Number(membership.bondIndex), {\n\t\t...clock.params,\n\t\tfirstBondPeriodCycle: clock.firstBondPeriodCycle,\n\t});\n\treturn start + BOND_LENGTH_CYCLES > newFirstCycle;\n}\n\nasync function stxFloor(\n\tclient: Client,\n\tstaker: string,\n\tamountUstx: bigint,\n): Promise<Pox5ErrorCode | undefined> {\n\tconst balance = await getBalance(client, { address: staker });\n\t// `/v2/accounts` `balance` is unlocked STX. Rollover (locked+unlocked)\n\t// can still succeed on-chain when this flags InsufficientStx.\n\tif (balance < amountUstx) return Pox5ErrorCode.InsufficientStx;\n\treturn undefined;\n}\n\nfunction principalValue(cv: ClarityValue): string | undefined {\n\tif (cv.type === \"address\" || cv.type === \"contract\") return cv.value;\n\treturn undefined;\n}\n\nfunction minUstxForSats(\n\tsats: bigint,\n\tstxValueRatio: bigint,\n\tminUstxRatio: bigint,\n): bigint {\n\treturn (((stxValueRatio * sats) / 100n) * minUstxRatio) / 10_000n;\n}\n\nexport async function eligibleStake(\n\tclient: Client,\n\tparams: EligibleStakeParams,\n): Promise<EligibilityResult> {\n\tconst reasons: Pox5ErrorCode[] = [];\n\tconst amountUstx = intToBigInt(params.amountUstx);\n\tconst numCycles = intToBigInt(params.numCycles);\n\tconst startBurnHeight = intToBigInt(params.startBurnHeight);\n\n\tconst [clock, stakerInfo, membership, signerErrs, floor] = await Promise.all([\n\t\treadCycleClock(client),\n\t\tgetStakerInfo(client, params.staker),\n\t\tgetBondMembership(client, params.staker),\n\t\tsignerReasons(client, params.signerManager),\n\t\tstxFloor(client, params.staker, amountUstx),\n\t]);\n\n\tif (inPrepare(clock)) reasons.push(Pox5ErrorCode.StakeInPreparePhase);\n\treasons.push(...signerErrs);\n\tif (floor !== undefined) reasons.push(floor);\n\n\tif (numCycles < 1n || numCycles > BigInt(MAX_NUM_CYCLES)) {\n\t\treasons.push(Pox5ErrorCode.InvalidNumCycles);\n\t}\n\n\tif (clock) {\n\t\tconst currentCycle = burnHeightToRewardCycle(\n\t\t\tclock.burnHeight,\n\t\t\tclock.params,\n\t\t);\n\t\tconst firstRewardCycle = currentCycle + 1;\n\t\tconst specified =\n\t\t\tburnHeightToRewardCycle(Number(startBurnHeight), clock.params) + 1;\n\t\tif (firstRewardCycle !== specified) {\n\t\t\treasons.push(Pox5ErrorCode.InvalidStartBurnHeight);\n\t\t}\n\t\tif (stakerInfo) reasons.push(Pox5ErrorCode.AlreadyStaked);\n\t\tif (bondOverlaps(membership, firstRewardCycle, clock)) {\n\t\t\treasons.push(Pox5ErrorCode.AlreadyStaked);\n\t\t}\n\t\tif (membership) {\n\t\t\tconst unlock = await getBondL1UnlockHeight(client, membership.bondIndex);\n\t\t\tif (BigInt(clock.burnHeight) < unlock) {\n\t\t\t\treasons.push(Pox5ErrorCode.RolloverTooEarly);\n\t\t\t}\n\t\t}\n\t} else if (stakerInfo) {\n\t\treasons.push(Pox5ErrorCode.AlreadyStaked);\n\t}\n\n\treturn finish(reasons);\n}\n\nexport async function eligibleRegisterForBond(\n\tclient: Client,\n\tparams: EligibleRegisterForBondParams,\n): Promise<EligibilityResult> {\n\tconst reasons: Pox5ErrorCode[] = [];\n\tconst amountUstx = intToBigInt(params.amountUstx);\n\tconst lockup = params.btcLockup;\n\n\tlet sats = 0n;\n\tif (\"sbtcSats\" in lockup) {\n\t\tsats = intToBigInt(lockup.sbtcSats);\n\t} else {\n\t\tif (lockup.l1Outputs.length === 0) {\n\t\t\treasons.push(Pox5ErrorCode.InvalidLockupAmount);\n\t\t}\n\t\tconst seen = new Set<string>();\n\t\tfor (const output of lockup.l1Outputs) {\n\t\t\tsats += intToBigInt(output.amount);\n\t\t\tconst key = outpointKey(output.tx, output.outputIndex);\n\t\t\tif (seen.has(key)) reasons.push(Pox5ErrorCode.DuplicateLockupOutpoint);\n\t\t\tseen.add(key);\n\t\t}\n\t}\n\n\tconst [clock, stakerInfo, membership, bond, allowance, signerErrs, floor] =\n\t\tawait Promise.all([\n\t\t\treadCycleClock(client),\n\t\t\tgetStakerInfo(client, params.staker),\n\t\t\tgetBondMembership(client, params.staker),\n\t\t\tgetProtocolBond(client, params.bondIndex),\n\t\t\tgetBondAllowance(client, params.bondIndex, params.staker),\n\t\t\tsignerReasons(client, params.signerManager),\n\t\t\tstxFloor(client, params.staker, amountUstx),\n\t\t]);\n\n\tif (inPrepare(clock)) reasons.push(Pox5ErrorCode.StakeInPreparePhase);\n\treasons.push(...signerErrs);\n\tif (floor !== undefined) reasons.push(floor);\n\n\tif (!bond) reasons.push(Pox5ErrorCode.BondNotFound);\n\tif (allowance == null) reasons.push(Pox5ErrorCode.NotAllowlisted);\n\telse if (sats > allowance) reasons.push(Pox5ErrorCode.TooMuchSats);\n\n\tif (bond) {\n\t\tconst min = minUstxForSats(sats, bond.stxValueRatio, bond.minUstxRatio);\n\t\tif (amountUstx < min) reasons.push(Pox5ErrorCode.InsufficientStx);\n\t}\n\n\tif (clock) {\n\t\tconst bondStart = bondPeriodToBurnHeight(\n\t\t\tNumber(intToBigInt(params.bondIndex)),\n\t\t\t{\n\t\t\t\t...clock.params,\n\t\t\t\tfirstBondPeriodCycle: clock.firstBondPeriodCycle,\n\t\t\t},\n\t\t);\n\t\tif (clock.burnHeight >= bondStart) {\n\t\t\treasons.push(Pox5ErrorCode.BondAlreadyStarted);\n\t\t}\n\t\tconst firstRewardCycle = bondPeriodToRewardCycle(\n\t\t\tNumber(intToBigInt(params.bondIndex)),\n\t\t\t{ ...clock.params, firstBondPeriodCycle: clock.firstBondPeriodCycle },\n\t\t);\n\t\tif (stakerInfo) {\n\t\t\tconst unlockCycle =\n\t\t\t\tNumber(stakerInfo.firstRewardCycle) + Number(stakerInfo.numCycles);\n\t\t\tif (unlockCycle > firstRewardCycle) {\n\t\t\t\treasons.push(Pox5ErrorCode.AlreadyStaked);\n\t\t\t}\n\t\t}\n\t\tif (bondOverlaps(membership, firstRewardCycle, clock)) {\n\t\t\treasons.push(Pox5ErrorCode.AlreadyRegistered);\n\t\t}\n\t\tif (membership) {\n\t\t\tconst unlock = await getBondL1UnlockHeight(client, membership.bondIndex);\n\t\t\tif (BigInt(clock.burnHeight) < unlock) {\n\t\t\t\treasons.push(Pox5ErrorCode.RolloverTooEarly);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (\"l1Outputs\" in lockup && lockup.l1Outputs.length > 0) {\n\t\tconst minUnlock = await getBondL1UnlockHeight(client, params.bondIndex);\n\t\tfor (const output of lockup.l1Outputs) {\n\t\t\tconst height = intToBigInt(output.unlockBurnHeight);\n\t\t\tif (height < minUnlock || height >= BITCOIN_LOCKTIME_THRESHOLD) {\n\t\t\t\treasons.push(Pox5ErrorCode.InvalidUnlockHeight);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn finish(reasons);\n}\n\nexport async function eligibleUnstake(\n\tclient: Client,\n\tparams: EligibleUnstakeParams,\n): Promise<EligibilityResult> {\n\tconst reasons: Pox5ErrorCode[] = [];\n\tconst [clock, stakerInfo] = await Promise.all([\n\t\treadCycleClock(client),\n\t\tgetStakerInfo(client, params.staker),\n\t]);\n\tif (inPrepare(clock)) reasons.push(Pox5ErrorCode.UnstakeInPreparePhase);\n\tif (!stakerInfo) reasons.push(Pox5ErrorCode.NotStaking);\n\telse if (stakerInfo.signer !== params.oldSignerManager) {\n\t\treasons.push(Pox5ErrorCode.InvalidOldSignerManager);\n\t}\n\treturn finish(reasons);\n}\n\nexport async function eligibleUnstakeSbtc(\n\tclient: Client,\n\tparams: EligibleUnstakeSbtcParams,\n): Promise<EligibilityResult> {\n\tconst reasons: Pox5ErrorCode[] = [];\n\tconst amount = intToBigInt(params.amountSats);\n\tconst [clock, membership] = await Promise.all([\n\t\treadCycleClock(client),\n\t\tgetBondMembership(client, params.staker),\n\t]);\n\t// unstake-sbtc uses verify-not-prepare-phase → ERR_STAKE_IN_PREPARE_PHASE\n\tif (inPrepare(clock)) reasons.push(Pox5ErrorCode.StakeInPreparePhase);\n\tif (!membership) reasons.push(Pox5ErrorCode.NotBondParticipant);\n\telse {\n\t\tif (membership.signer !== params.signerManager) {\n\t\t\treasons.push(Pox5ErrorCode.InvalidOldSignerManager);\n\t\t}\n\t\tif (membership.isL1Lock) reasons.push(Pox5ErrorCode.CannotUnstakeSbtc);\n\t\tif (amount > membership.amountSats) {\n\t\t\treasons.push(Pox5ErrorCode.InvalidUnstakeSbtcAmount);\n\t\t}\n\t}\n\treturn finish(reasons);\n}\n\nexport async function eligibleClaimRewards(\n\tclient: Client,\n\tparams: EligibleClaimRewardsParams,\n): Promise<EligibilityResult> {\n\tconst reasons: Pox5ErrorCode[] = [];\n\tconst contract = pox5ContractId(client);\n\tconst paused = await getDataVar(client, {\n\t\tcontract,\n\t\tvarName: \"rewards-paused\",\n\t});\n\tif (paused.type === \"true\") reasons.push(Pox5ErrorCode.RewardsPaused);\n\n\tconst periods = params.bondPeriods ?? [];\n\tconst earnedParts = await Promise.all([\n\t\tgetEarned(client, {\n\t\t\tsigner: params.signer,\n\t\t\trewardCycle: params.rewardCycle,\n\t\t\tbondIndex: params.bondIndex,\n\t\t}),\n\t\t...periods.map((bondIndex) =>\n\t\t\tgetEarned(client, {\n\t\t\t\tsigner: params.signer,\n\t\t\t\trewardCycle: params.rewardCycle,\n\t\t\t\tbondIndex,\n\t\t\t}),\n\t\t),\n\t]);\n\tlet total = 0n;\n\tfor (const part of earnedParts) total += part;\n\tif (total === 0n) reasons.push(Pox5ErrorCode.NoClaimableRewards);\n\n\treturn finish(reasons);\n}\n\nexport async function eligibleGrantSignerKey(\n\tclient: Client,\n\tparams: EligibleGrantSignerKeyParams,\n): Promise<EligibilityResult> {\n\tconst reasons: Pox5ErrorCode[] = [];\n\tconst used = await getMapEntry(client, {\n\t\tcontract: pox5ContractId(client),\n\t\tmapName: \"used-signer-key-grants\",\n\t\tkey: Cl.tuple({\n\t\t\t\"signer-key\": Cl.buffer(toBytes(params.signerKey)),\n\t\t\t\"signer-manager\": Cl.principal(params.signerManager),\n\t\t\t\"auth-id\": Cl.uint(intToBigInt(params.authId)),\n\t\t}),\n\t});\n\tif (used.type === \"some\") reasons.push(Pox5ErrorCode.SignerKeyGrantUsed);\n\treturn finish(reasons);\n}\n\nexport async function eligibleSetBondAdmin(\n\tclient: Client,\n\tparams: EligibleAdminParams,\n): Promise<EligibilityResult> {\n\tconst admin = await getDataVar(client, {\n\t\tcontract: pox5ContractId(client),\n\t\tvarName: \"bond-admin\",\n\t});\n\tif (principalValue(admin) !== params.caller) {\n\t\treturn finish([Pox5ErrorCode.Unauthorized]);\n\t}\n\treturn { ok: true };\n}\n\nexport async function eligiblePauseRewards(\n\tclient: Client,\n\tparams: EligibleAdminParams,\n): Promise<EligibilityResult> {\n\tconst admin = await getDataVar(client, {\n\t\tcontract: pox5ContractId(client),\n\t\tvarName: \"pause-admin\",\n\t});\n\tif (principalValue(admin) !== params.caller) {\n\t\treturn finish([Pox5ErrorCode.Unauthorized]);\n\t}\n\treturn { ok: true };\n}\n",
    "import { sha256 } from \"@noble/hashes/sha2.js\";\nimport { bech32 } from \"@scure/base\";\nimport { BITCOIN_NETWORK_PARAMS } from \"../bitcoin/address.ts\";\nimport type { BitcoinNetwork } from \"../bitcoin/constants.ts\";\nimport { serializeCVBytes } from \"../clarity/serialize.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport { concatBytes, hexToBytes } from \"../utils/encoding.ts\";\nimport { BITCOIN_LOCKTIME_THRESHOLD, C_SCRIPT_NUM_MAX } from \"./constants.ts\";\nimport { type BondCycleParams, computeBondUnlockHeight } from \"./cycles.ts\";\n\n/**\n * Byte-for-byte TypeScript mirrors of pox-5's Bitcoin-script helpers\n * (`serialize-c-script-num`, `push-c-script-num`, `push-script-bytes`,\n * `construct-lockup-script`, `construct-lockup-output-script`), pinned\n * against the final contract in stacks-core 4.0.1. The contract validates a\n * staker's L1 lockup output against exactly these bytes, so any divergence\n * means a rejected registration — the read-onlys on-chain double as a\n * cross-check oracle for these functions.\n */\n\n/**\n * Minimal little-endian ScriptNum encoding of a non-negative integer\n * (`0` → empty; a `0x00` sign byte is appended when the top byte's high bit\n * is set). Mirrors `serialize-c-script-num`, including its 2^39 ceiling.\n */\nexport function serializeCScriptNum(n: number | bigint): Uint8Array {\n\tconst big = typeof n === \"bigint\" ? n : BigInt(n);\n\tif (big < 0n) throw new Error(\"serializeCScriptNum: negative value\");\n\tif (big >= C_SCRIPT_NUM_MAX) {\n\t\tthrow new Error(\n\t\t\t\"serializeCScriptNum: n >= 2^39 (contract rejects with ERR_INVALID_UNLOCK_HEIGHT)\",\n\t\t);\n\t}\n\tif (big === 0n) return new Uint8Array(0);\n\tconst out: number[] = [];\n\tlet v = big;\n\twhile (v > 0n) {\n\t\tout.push(Number(v & 0xffn));\n\t\tv >>= 8n;\n\t}\n\tif ((out[out.length - 1] as number) & 0x80) out.push(0x00);\n\treturn Uint8Array.from(out);\n}\n\n/**\n * Push arbitrary bytes onto a Bitcoin script: direct length byte under 76,\n * `OP_PUSHDATA1` under 256, `OP_PUSHDATA2` otherwise. Mirrors\n * `push-script-bytes`.\n */\nexport function pushScriptBytes(bytes: Uint8Array): Uint8Array {\n\tconst len = bytes.length;\n\tif (len > 0xffff)\n\t\tthrow new Error(`pushScriptBytes: payload too large (${len} > 65535)`);\n\tlet prefix: Uint8Array;\n\tif (len < 76) prefix = Uint8Array.of(len);\n\telse if (len < 256) prefix = Uint8Array.of(0x4c, len);\n\telse prefix = Uint8Array.of(0x4d, len & 0xff, len >> 8);\n\treturn concatBytes(prefix, bytes);\n}\n\n/**\n * Push a numeric script value: `OP_0` for zero, the single-byte ops\n * `OP_1`..`OP_16` for 1–16, else a minimal ScriptNum push. Mirrors\n * `push-c-script-num`.\n */\nexport function pushCScriptNum(n: number | bigint): Uint8Array {\n\tconst big = typeof n === \"bigint\" ? n : BigInt(n);\n\tif (big === 0n) return Uint8Array.of(0x00);\n\tif (big >= 1n && big <= 16n) return Uint8Array.of(0x50 + Number(big));\n\treturn pushScriptBytes(serializeCScriptNum(big));\n}\n\n/** `to-consensus-buff?` of a principal — the staker identity the script commits to. */\nexport function stakerConsensusBuff(stxAddress: string): Uint8Array {\n\treturn serializeCVBytes(Cl.principal(stxAddress));\n}\n\n/**\n * The 32-byte witness item the early-exit branch must reveal:\n * `sha256(to-consensus-buff? staker)`. The script stores `sha256` of THIS,\n * so revealing it proves which staker the exit is for.\n */\nexport function stakerPreimage(stxAddress: string): Uint8Array {\n\treturn sha256(stakerConsensusBuff(stxAddress));\n}\n\nexport type BuildLockupScriptOptions = {\n\t/** Staker principal (standard or contract address). */\n\tstxAddress: string;\n\t/** Burn height at which the CLTV branch becomes spendable. */\n\tunlockBurnHeight: number | bigint;\n\t/** Staker-signature subscript, run last in BOTH branches. */\n\tstakerUnlockBytes: Uint8Array | string;\n\t/** Per-bond early-unlock subscript (from `protocol-bonds.early-unlock-bytes`). */\n\tearlyUnlockBytes: Uint8Array | string;\n};\n\nfunction toBytes(input: Uint8Array | string): Uint8Array {\n\treturn typeof input === \"string\" ? hexToBytes(input) : input;\n}\n\n/**\n * The L1 lockup witness script. Mirrors `construct-lockup-script`:\n *\n * ```\n * OP_IF\n *   <unlockBurnHeight> OP_CHECKLOCKTIMEVERIFY\n * OP_ELSE\n *   OP_SIZE <32> OP_EQUALVERIFY OP_SHA256\n *   <sha256(sha256(consensus-buff(staker)))> OP_EQUALVERIFY\n *   <earlyUnlockBytes>\n * OP_ENDIF\n * OP_VERIFY\n * <stakerUnlockBytes>\n * ```\n */\nexport function buildLockupScript(opts: BuildLockupScriptOptions): Uint8Array {\n\tconst height = BigInt(opts.unlockBurnHeight);\n\tif (height <= 0n) {\n\t\tthrow new Error(\n\t\t\t\"unlockBurnHeight must be > 0 (contract rejects with ERR_INVALID_UNLOCK_HEIGHT)\",\n\t\t);\n\t}\n\tif (height >= BITCOIN_LOCKTIME_THRESHOLD) {\n\t\tthrow new Error(\n\t\t\t\"unlockBurnHeight >= 500,000,000 would be read by Bitcoin as a timestamp (contract rejects it)\",\n\t\t);\n\t}\n\tconst stakerHash = sha256(stakerPreimage(opts.stxAddress));\n\treturn concatBytes(\n\t\tUint8Array.of(0x63), // OP_IF\n\t\tpushCScriptNum(height),\n\t\tUint8Array.of(0xb1, 0x67), // OP_CHECKLOCKTIMEVERIFY, OP_ELSE\n\t\t// OP_SIZE, <0x20>, OP_EQUALVERIFY, OP_SHA256, OP_PUSHBYTES_32\n\t\thexToBytes(\"82012088a820\"),\n\t\tstakerHash,\n\t\tUint8Array.of(0x88), // OP_EQUALVERIFY\n\t\ttoBytes(opts.earlyUnlockBytes),\n\t\tUint8Array.of(0x68, 0x69), // OP_ENDIF, OP_VERIFY\n\t\ttoBytes(opts.stakerUnlockBytes),\n\t);\n}\n\n/**\n * P2WSH `scriptPubKey` for a lockup script: `0x0020 || sha256(script)`.\n * Mirrors `construct-lockup-output-script`.\n */\nexport function buildLockupOutputScript(\n\topts: BuildLockupScriptOptions,\n): Uint8Array {\n\treturn concatBytes(\n\t\tUint8Array.of(0x00, 0x20),\n\t\tsha256(buildLockupScript(opts)),\n\t);\n}\n\n/** The bech32 P2WSH address a staker sends their L1 BTC lockup to. */\nexport function buildLockupAddress(\n\topts: BuildLockupScriptOptions,\n\tnetwork: BitcoinNetwork = \"mainnet\",\n): string {\n\tconst hash = sha256(buildLockupScript(opts));\n\treturn bech32.encode(BITCOIN_NETWORK_PARAMS[network].hrp, [\n\t\t0,\n\t\t...bech32.toWords(hash),\n\t]);\n}\n\n/**\n * The default staker subscript: `<pubkey> OP_CHECKSIG` — spendable by one\n * key. Any script tail is valid as far as the contract is concerned; this is\n * the common case.\n */\nexport function buildDefaultStakerUnlockBytes(\n\tpublicKey: Uint8Array | string,\n): Uint8Array {\n\tconst pubkey = toBytes(publicKey);\n\tif (pubkey.length !== 33)\n\t\tthrow new Error(`Expected 33-byte compressed pubkey, got ${pubkey.length}`);\n\tconst prefix = pubkey[0];\n\tif (prefix !== 0x02 && prefix !== 0x03) {\n\t\tthrow new Error(\n\t\t\t`Expected compressed pubkey prefix 0x02 or 0x03, got ${prefix}`,\n\t\t);\n\t}\n\treturn concatBytes(pushScriptBytes(pubkey), Uint8Array.of(0xac)); // OP_CHECKSIG\n}\n\nexport type RegisterMetadata = {\n\tlockAddress: string;\n\tlockScript: Uint8Array;\n\toutputScript: Uint8Array;\n\tunlockBytes: Uint8Array;\n\tunlockHeight: number;\n};\n\n/**\n * One-call L1 register metadata: unlock height, staker subscript, lock\n * script, P2WSH output, and address. Staker funds `lockAddress` then\n * passes `lockScript` into the proof mapper.\n */\nexport function buildRegisterMetadata(opts: {\n\tbondIndex: number;\n\tstxAddress: string;\n\tbitcoinPublicKey: Uint8Array | string;\n\tearlyUnlockBytes: Uint8Array | string;\n\tnetwork?: BitcoinNetwork;\n\tcycle: BondCycleParams;\n}): RegisterMetadata {\n\tconst unlockHeight = computeBondUnlockHeight(opts.bondIndex, opts.cycle);\n\tconst unlockBytes = buildDefaultStakerUnlockBytes(opts.bitcoinPublicKey);\n\tconst lockOpts: BuildLockupScriptOptions = {\n\t\tstxAddress: opts.stxAddress,\n\t\tunlockBurnHeight: unlockHeight,\n\t\tstakerUnlockBytes: unlockBytes,\n\t\tearlyUnlockBytes: opts.earlyUnlockBytes,\n\t};\n\treturn {\n\t\tlockAddress: buildLockupAddress(lockOpts, opts.network ?? \"mainnet\"),\n\t\tlockScript: buildLockupScript(lockOpts),\n\t\toutputScript: buildLockupOutputScript(lockOpts),\n\t\tunlockBytes,\n\t\tunlockHeight,\n\t};\n}\n",
    "import { schnorr, secp256k1 } from \"@noble/curves/secp256k1.js\";\nimport { base58, bech32, bech32m } from \"@scure/base\";\nimport { concatBytes, hexToBytes } from \"../utils/encoding.ts\";\nimport { hash160 } from \"../utils/hash.ts\";\nimport type { ParsedOutputScript } from \"./codec.ts\";\nimport type { BitcoinNetwork } from \"./constants.ts\";\nimport { doubleSha256 } from \"./serialize.ts\";\n\n/** Address-encoding parameters (base58 version bytes + bech32 hrp) per network. */\nexport const BITCOIN_NETWORK_PARAMS = {\n\tmainnet: { p2pkh: 0x00, p2sh: 0x05, hrp: \"bc\" },\n\ttestnet: { p2pkh: 0x6f, p2sh: 0xc4, hrp: \"tb\" },\n\tregtest: { p2pkh: 0x6f, p2sh: 0xc4, hrp: \"bcrt\" },\n} as const;\n\nconst NETWORK_PARAMS = BITCOIN_NETWORK_PARAMS;\n\n/** Base58Check-encode a versioned 20-byte payload (legacy P2PKH / P2SH).\n *  The one encoder for the package; pox5 and sbtc address code import it. */\nexport function base58CheckEncode(\n\tversion: number,\n\tpayload: Uint8Array,\n): string {\n\tconst data = concatBytes(Uint8Array.of(version), payload);\n\tconst checksum = doubleSha256(data).slice(0, 4);\n\treturn base58.encode(concatBytes(data, checksum));\n}\n\n/**\n * Render a parsed output script as a Bitcoin address for the given network.\n * Returns `undefined` for scripts without a standard address (OP_RETURN, P2PK,\n * unknown). Address encoding is network-dependent, which is why this is separate\n * from the pure `parseOutputScript` decoder.\n */\nexport function formatBitcoinAddress(\n\tparsed: ParsedOutputScript,\n\tnetwork: BitcoinNetwork = \"mainnet\",\n): string | undefined {\n\tconst params = NETWORK_PARAMS[network];\n\tconst hash = parsed.hash;\n\tif (!hash) return undefined;\n\tswitch (parsed.type) {\n\t\tcase \"p2pkh\":\n\t\t\treturn base58CheckEncode(params.p2pkh, hash);\n\t\tcase \"p2sh\":\n\t\t\treturn base58CheckEncode(params.p2sh, hash);\n\t\tcase \"p2wpkh\":\n\t\tcase \"p2wsh\":\n\t\t\treturn bech32.encode(params.hrp, [0, ...bech32.toWords(hash)]);\n\t\tcase \"p2tr\":\n\t\t\treturn bech32m.encode(params.hrp, [1, ...bech32m.toWords(hash)]);\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nfunction toPubkeyBytes(publicKey: Uint8Array | string): Uint8Array {\n\treturn typeof publicKey === \"string\" ? hexToBytes(publicKey) : publicKey;\n}\n\n/**\n * BIP341 key-path tweak: lift the x-only internal key to a point, add\n * `tapTweakHash(P)·G` (no script tree), and return the x-only output key.\n */\nexport function taprootTweakPubkey(xonly: Uint8Array): Uint8Array {\n\tif (xonly.length !== 32)\n\t\tthrow new Error(`Expected 32-byte x-only pubkey, got ${xonly.length}`);\n\tconst tweak = schnorr.utils.taggedHash(\"TapTweak\", xonly);\n\tconst t = BigInt(\n\t\t`0x${Array.from(tweak, (b) => b.toString(16).padStart(2, \"0\")).join(\"\")}`,\n\t);\n\tif (t >= secp256k1.Point.Fn.ORDER)\n\t\tthrow new Error(\"Invalid tap tweak (exceeds curve order)\");\n\tconst internal = secp256k1.Point.fromBytes(\n\t\tconcatBytes(Uint8Array.of(0x02), xonly),\n\t);\n\tconst output = internal.add(secp256k1.Point.BASE.multiply(t));\n\treturn output.toBytes(true).slice(1);\n}\n\n/**\n * Derive the native-segwit (P2WPKH, bech32 v0) address for a compressed\n * public key.\n */\nexport function publicKeyToP2wpkhAddress(\n\tpublicKey: Uint8Array | string,\n\tnetwork: BitcoinNetwork = \"mainnet\",\n): string {\n\tconst pubkey = toPubkeyBytes(publicKey);\n\tif (pubkey.length !== 33)\n\t\tthrow new Error(`Expected 33-byte compressed pubkey, got ${pubkey.length}`);\n\tconst params = NETWORK_PARAMS[network];\n\treturn bech32.encode(params.hrp, [0, ...bech32.toWords(hash160(pubkey))]);\n}\n\n/**\n * Derive the taproot (P2TR, bech32m v1) address for a public key — BIP341\n * key-path spend, no script tree. Accepts a 33-byte compressed key (the\n * parity byte is dropped) or a 32-byte x-only key.\n */\nexport function publicKeyToP2trAddress(\n\tpublicKey: Uint8Array | string,\n\tnetwork: BitcoinNetwork = \"mainnet\",\n): string {\n\tconst pubkey = toPubkeyBytes(publicKey);\n\tconst xonly =\n\t\tpubkey.length === 33\n\t\t\t? pubkey.slice(1)\n\t\t\t: pubkey.length === 32\n\t\t\t\t? pubkey\n\t\t\t\t: undefined;\n\tif (!xonly)\n\t\tthrow new Error(\n\t\t\t`Expected 33-byte compressed or 32-byte x-only pubkey, got ${pubkey.length}`,\n\t\t);\n\tconst params = NETWORK_PARAMS[network];\n\tconst outputKey = taprootTweakPubkey(xonly);\n\treturn bech32m.encode(params.hrp, [1, ...bech32m.toWords(outputKey)]);\n}\n",
    "import { concatBytes } from \"../utils/encoding.ts\";\nimport { sha256 } from \"../utils/hash.ts\";\n\n/**\n * Bitcoin double-SHA256: `sha256(sha256(bytes))`. This is the hash Bitcoin uses\n * for txids, block headers, and merkle nodes — NOT the same as the Stacks\n * `txidFromBytes` (which uses sha512_256), so it lives here, not in `utils/hash`.\n */\nexport function doubleSha256(bytes: Uint8Array): Uint8Array {\n\treturn sha256(sha256(bytes));\n}\n\n/**\n * Reverse a byte array. Bitcoin hashes are computed and stored in *internal*\n * (little-endian) order but *displayed* big-endian, so the two differ by a\n * reversal. The SIP-044 built-ins consume internal order; only reverse for\n * display / when matching an explorer value.\n */\nexport function reverseBytes(bytes: Uint8Array): Uint8Array {\n\tconst out = new Uint8Array(bytes.length);\n\tfor (let i = 0; i < bytes.length; i++) {\n\t\tout[i] = bytes[bytes.length - 1 - i] as number;\n\t}\n\treturn out;\n}\n\n/**\n * A little-endian, varint-aware byte reader for Bitcoin serialization. The\n * shared `utils/BytesReader` is big-endian only; Bitcoin tx fields are\n * little-endian with compact-size (varint) length prefixes.\n */\nexport class BtcReader {\n\tprivate readonly data: Uint8Array;\n\tprivate readonly view: DataView;\n\tpublic offset = 0;\n\n\tconstructor(data: Uint8Array) {\n\t\tthis.data = data;\n\t\tthis.view = new DataView(data.buffer, data.byteOffset, data.byteLength);\n\t}\n\n\tget length(): number {\n\t\treturn this.data.length;\n\t}\n\n\treadUInt8(): number {\n\t\tconst v = this.view.getUint8(this.offset);\n\t\tthis.offset += 1;\n\t\treturn v;\n\t}\n\n\t/** Read the next byte without advancing. */\n\tpeekUInt8(): number {\n\t\treturn this.view.getUint8(this.offset);\n\t}\n\n\treadUInt32LE(): number {\n\t\tconst v = this.view.getUint32(this.offset, true);\n\t\tthis.offset += 4;\n\t\treturn v;\n\t}\n\n\treadUInt64LE(): bigint {\n\t\tconst v = this.view.getBigUint64(this.offset, true);\n\t\tthis.offset += 8;\n\t\treturn v;\n\t}\n\n\treadBytes(n: number): Uint8Array {\n\t\tif (this.offset + n > this.data.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Bitcoin tx underflow: need ${n} 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 + n);\n\t\tthis.offset += n;\n\t\treturn slice;\n\t}\n\n\t/** Read a Bitcoin compact-size unsigned integer (varint). */\n\treadVarInt(): number {\n\t\tconst first = this.readUInt8();\n\t\tif (first < 0xfd) return first;\n\t\tif (first === 0xfd) {\n\t\t\tconst v = this.view.getUint16(this.offset, true);\n\t\t\tthis.offset += 2;\n\t\t\treturn v;\n\t\t}\n\t\tif (first === 0xfe) {\n\t\t\treturn this.readUInt32LE();\n\t\t}\n\t\tconst big = this.readUInt64LE();\n\t\tif (big > BigInt(Number.MAX_SAFE_INTEGER)) {\n\t\t\tthrow new Error(\"Bitcoin varint exceeds safe integer range\");\n\t\t}\n\t\treturn Number(big);\n\t}\n}\n\nexport interface BitcoinTxInput {\n\t/** Previous output txid, in serialized (internal) byte order. */\n\tprevTxid: Uint8Array;\n\tvout: number;\n\tscriptSig: Uint8Array;\n\tsequence: number;\n}\n\nexport interface BitcoinTxOutput {\n\t/** Output value in satoshis. */\n\tvalue: bigint;\n\tscriptPubKey: Uint8Array;\n}\n\nexport interface ParsedBitcoinTx {\n\tversion: number;\n\thasWitness: boolean;\n\tinputs: BitcoinTxInput[];\n\toutputs: BitcoinTxOutput[];\n\tlocktime: number;\n\t/**\n\t * The legacy txid as the raw double-SHA256 in *internal* byte order — ready\n\t * to pass as the leaf to `verify-merkle-proof`. Witness data is excluded\n\t * (the txid is computed over the legacy serialization), so this is stable for\n\t * both legacy and SegWit txs. Use `reverseBytes` for the displayed form.\n\t */\n\ttxidInternal: Uint8Array;\n}\n\ninterface ScanResult {\n\tversion: number;\n\thasWitness: boolean;\n\tinputs: BitcoinTxInput[];\n\toutputs: BitcoinTxOutput[];\n\tlocktime: number;\n\t/** The legacy (witness-stripped) serialization — what the txid is hashed over. */\n\tlegacy: Uint8Array;\n}\n\n/**\n * Single-pass scan of a raw Bitcoin tx. Captures the inputs/outputs slice and\n * reassembles the legacy serialization so both `parseBitcoinTx` and\n * `stripWitness` share one parser (and one set of foot-guns).\n */\nfunction scanTx(rawTx: Uint8Array): ScanResult {\n\tconst r = new BtcReader(rawTx);\n\tconst version = r.readUInt32LE();\n\n\t// SegWit marker (0x00) + flag (0x01) sit immediately after the version. A\n\t// legacy tx can never have a zero input count, so 0x00 here is unambiguous.\n\tlet hasWitness = false;\n\tif (r.peekUInt8() === 0x00) {\n\t\tr.readUInt8(); // marker\n\t\tconst flag = r.readUInt8();\n\t\tif (flag !== 0x01) {\n\t\t\tthrow new Error(`Unexpected SegWit flag 0x${flag.toString(16)}`);\n\t\t}\n\t\thasWitness = true;\n\t}\n\n\tconst bodyStart = r.offset;\n\tconst inputCount = r.readVarInt();\n\tconst inputs: BitcoinTxInput[] = [];\n\tfor (let i = 0; i < inputCount; i++) {\n\t\tconst prevTxid = r.readBytes(32);\n\t\tconst vout = r.readUInt32LE();\n\t\tconst scriptSig = r.readBytes(r.readVarInt());\n\t\tconst sequence = r.readUInt32LE();\n\t\tinputs.push({ prevTxid, vout, scriptSig, sequence });\n\t}\n\n\tconst outputCount = r.readVarInt();\n\tconst outputs: BitcoinTxOutput[] = [];\n\tfor (let i = 0; i < outputCount; i++) {\n\t\tconst value = r.readUInt64LE();\n\t\tconst scriptPubKey = r.readBytes(r.readVarInt());\n\t\toutputs.push({ value, scriptPubKey });\n\t}\n\tconst bodyEnd = r.offset;\n\n\tif (hasWitness) {\n\t\tfor (let i = 0; i < inputCount; i++) {\n\t\t\tconst itemCount = r.readVarInt();\n\t\t\tfor (let j = 0; j < itemCount; j++) {\n\t\t\t\tr.readBytes(r.readVarInt());\n\t\t\t}\n\t\t}\n\t}\n\n\tconst locktime = r.readUInt32LE();\n\n\tconst legacy = concatBytes(\n\t\trawTx.slice(0, 4),\n\t\trawTx.slice(bodyStart, bodyEnd),\n\t\trawTx.slice(r.offset - 4, r.offset),\n\t);\n\n\treturn { version, hasWitness, inputs, outputs, locktime, legacy };\n}\n\n/** Parse a serialized Bitcoin tx (legacy or SegWit) into its fields + txid. */\nexport function parseBitcoinTx(rawTx: Uint8Array): ParsedBitcoinTx {\n\tconst s = scanTx(rawTx);\n\treturn {\n\t\tversion: s.version,\n\t\thasWitness: s.hasWitness,\n\t\tinputs: s.inputs,\n\t\toutputs: s.outputs,\n\t\tlocktime: s.locktime,\n\t\ttxidInternal: doubleSha256(s.legacy),\n\t};\n}\n\n/**\n * Return the legacy (witness-stripped) serialization of a tx. For a legacy tx\n * this is the input unchanged; for a SegWit tx the marker, flag, and witness\n * stack are removed. This is the byte string the txid is hashed over.\n */\nexport function stripWitness(rawTx: Uint8Array): Uint8Array {\n\treturn scanTx(rawTx).legacy;\n}\n\n/**\n * Compute a tx's id from its raw serialization. Internal byte order by default\n * (the merkle leaf / built-in input); pass `{ display: true }` for the\n * explorer-style big-endian form.\n */\nexport function bitcoinTxid(\n\trawTx: Uint8Array,\n\t{ display = false }: { display?: boolean } = {},\n): Uint8Array {\n\tconst txid = doubleSha256(scanTx(rawTx).legacy);\n\treturn display ? reverseBytes(txid) : txid;\n}\n\nexport interface BlockHeader {\n\tversion: number;\n\t/** Previous block hash, internal byte order. */\n\tprevBlock: Uint8Array;\n\t/** Merkle root, internal byte order — pairs with `verify-merkle-proof`. */\n\tmerkleRoot: Uint8Array;\n\ttimestamp: number;\n\tbits: number;\n\tnonce: number;\n}\n\n/** Parse an 80-byte Bitcoin block header into its fields (hashes internal order). */\nexport function parseBlockHeader(header: Uint8Array): BlockHeader {\n\tif (header.length !== 80) {\n\t\tthrow new Error(\n\t\t\t`Bitcoin block header must be 80 bytes, got ${header.length}`,\n\t\t);\n\t}\n\tconst r = new BtcReader(header);\n\tconst version = r.readUInt32LE();\n\tconst prevBlock = r.readBytes(32);\n\tconst merkleRoot = r.readBytes(32);\n\tconst timestamp = r.readUInt32LE();\n\tconst bits = r.readUInt32LE();\n\tconst nonce = r.readUInt32LE();\n\treturn { version, prevBlock, merkleRoot, timestamp, bits, nonce };\n}\n\n/**\n * Hash an 80-byte block header (double-SHA256). Internal byte order by default;\n * `{ display: true }` for the explorer-style block hash.\n */\nexport function blockHash(\n\theader: Uint8Array,\n\t{ display = false }: { display?: boolean } = {},\n): Uint8Array {\n\tconst hash = doubleSha256(header);\n\treturn display ? reverseBytes(hash) : hash;\n}\n",
    "import { secp256k1 } from \"@noble/curves/secp256k1.js\";\nimport type { LocalAccount } from \"../accounts/types.ts\";\nimport { structuredDataHash } from \"../clarity/structuredData.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport { bytesToHex, concatBytes, hexToBytes } from \"../utils/encoding.ts\";\nimport { POX5_SIGNER_DOMAIN } from \"./constants.ts\";\n\n/**\n * PoX-5 signer-key grants: SIP-018 structured-data signatures authorizing a\n * signer-manager contract to use a signer key. Mirrors\n * `pox-5.get-signer-grant-message-hash` — domain `pox-5-signer/1.0.0`,\n * message `{ topic: \"grant-authorization\", signer-manager, auth-id }`.\n */\nexport type SignerGrantOptions = {\n\t/** The signer-manager contract principal being authorized. */\n\tsignerManager: string;\n\t/** Replay-protection id, chosen by the signer. */\n\tauthId: bigint | number;\n\t/** Stacks chain id (`mainnet.id` / `testnet.id`). */\n\tchainId: number;\n};\n\n/**\n * The 32-byte hash a signer signs to grant their key — byte-identical to the\n * contract's `get-signer-grant-message-hash` read-only (which doubles as an\n * on-chain cross-check).\n */\nexport function computeSignerGrantHash(opts: SignerGrantOptions): Uint8Array {\n\treturn structuredDataHash({\n\t\tdomain: Cl.tuple({\n\t\t\tname: Cl.stringAscii(POX5_SIGNER_DOMAIN.name),\n\t\t\tversion: Cl.stringAscii(POX5_SIGNER_DOMAIN.version),\n\t\t\t\"chain-id\": Cl.uint(opts.chainId),\n\t\t}),\n\t\tmessage: Cl.tuple({\n\t\t\ttopic: Cl.stringAscii(\"grant-authorization\"),\n\t\t\t\"signer-manager\": Cl.principal(opts.signerManager),\n\t\t\t\"auth-id\": Cl.uint(opts.authId),\n\t\t}),\n\t});\n}\n\n/**\n * Sign a signer-key grant. Returns the 65-byte recoverable signature in RSV\n * order (recovery byte last), hex — the layout `grant-signer-key`'s\n * `signer-sig (buff 65)` expects.\n */\nexport async function signSignerGrant(\n\taccount: LocalAccount,\n\topts: SignerGrantOptions,\n): Promise<string> {\n\tconst vrs = await account.sign(computeSignerGrantHash(opts));\n\tif (vrs.length !== 65)\n\t\tthrow new Error(\n\t\t\t`Expected 65-byte recoverable signature, got ${vrs.length}`,\n\t\t);\n\t// account.sign returns VRS; the contract wants RSV.\n\treturn bytesToHex(concatBytes(vrs.slice(1), vrs.slice(0, 1)));\n}\n\n/**\n * Verify a signer-key grant signature locally: recover the pubkey from the\n * RSV signature over the grant hash and compare. Returns `false` for\n * malformed input rather than throwing.\n */\nexport function verifySignerGrant(\n\topts: SignerGrantOptions & {\n\t\tpublicKey: Uint8Array | string;\n\t\tsignature: Uint8Array | string;\n\t},\n): boolean {\n\ttry {\n\t\tconst sig =\n\t\t\ttypeof opts.signature === \"string\"\n\t\t\t\t? hexToBytes(opts.signature)\n\t\t\t\t: opts.signature;\n\t\tif (sig.length !== 65) return false;\n\t\tconst pubkey =\n\t\t\ttypeof opts.publicKey === \"string\"\n\t\t\t\t? hexToBytes(opts.publicKey)\n\t\t\t\t: opts.publicKey;\n\t\tconst hash = computeSignerGrantHash(opts);\n\t\tconst recovered = secp256k1.Signature.fromBytes(sig.slice(0, 64))\n\t\t\t.addRecoveryBit(sig[64] as number)\n\t\t\t.recoverPublicKey(hash)\n\t\t\t.toBytes(true);\n\t\treturn bytesToHex(recovered) === bytesToHex(pubkey);\n\t} catch {\n\t\treturn false;\n\t}\n}\n",
    "import { sha256 } from \"@noble/hashes/sha2.js\";\nimport type { LocalAccount } from \"../accounts/types.ts\";\nimport { bytesToHex, concatBytes } from \"../utils/encoding.ts\";\nimport { serializeCVBytes } from \"./serialize.ts\";\nimport type { ClarityValue, TupleCV } from \"./types.ts\";\n\n/** asciiToBytes(\"SIP018\") */\nexport const SIP018_PREFIX: Uint8Array = new Uint8Array([\n\t0x53, 0x49, 0x50, 0x30, 0x31, 0x38,\n]);\n\n/** sha256(serialize(cv)) — inner hash used by SIP-018. */\nexport function hashStructuredData(structuredData: ClarityValue): Uint8Array {\n\treturn sha256(serializeCVBytes(structuredData));\n}\n\nfunction isDomain(value: ClarityValue): value is TupleCV {\n\tif (value.type !== \"tuple\") return false;\n\tconst { name, version, \"chain-id\": chainId } = value.value;\n\treturn (\n\t\tname?.type === \"ascii\" &&\n\t\tversion?.type === \"ascii\" &&\n\t\tchainId?.type === \"uint\"\n\t);\n}\n\n/**\n * SIP-018 encoding: `\"SIP018\" || sha256(serialize(domain)) || sha256(serialize(message))`.\n * The signature is over `sha256` of this buffer.\n */\nexport function encodeStructuredData(opts: {\n\tmessage: ClarityValue;\n\tdomain: ClarityValue;\n}): Uint8Array {\n\tif (!isDomain(opts.domain)) {\n\t\tthrow new Error(\n\t\t\t\"domain must be a tuple { name: ascii, version: ascii, chain-id: uint }\",\n\t\t);\n\t}\n\treturn concatBytes(\n\t\tSIP018_PREFIX,\n\t\thashStructuredData(opts.domain),\n\t\thashStructuredData(opts.message),\n\t);\n}\n\n/** SIP-018 message hash: sha256(encodeStructuredData(...)). */\nexport function structuredDataHash(opts: {\n\tmessage: ClarityValue;\n\tdomain: ClarityValue;\n}): Uint8Array {\n\treturn sha256(encodeStructuredData(opts));\n}\n\n/**\n * Sign a SIP-018 structured message. Returns a 65-byte recoverable signature\n * in RSV order (recovery byte last) — the layout contracts expect.\n */\nexport async function signStructuredData(\n\taccount: LocalAccount,\n\topts: { message: ClarityValue; domain: ClarityValue },\n): Promise<string> {\n\tconst vrs = await account.sign(structuredDataHash(opts));\n\tif (vrs.length !== 65) {\n\t\tthrow new Error(\n\t\t\t`Expected 65-byte recoverable signature, got ${vrs.length}`,\n\t\t);\n\t}\n\treturn bytesToHex(concatBytes(vrs.slice(1), vrs.slice(0, 1)));\n}\n",
    "import { sha256 } from \"@noble/hashes/sha2.js\";\nimport {\n\ttype ProofSource,\n\ttype SpvProof,\n\tbuildTxProof,\n} from \"../bitcoin/proof.ts\";\nimport { parseBitcoinTx, stripWitness } from \"../bitcoin/serialize.ts\";\nimport {\n\ttype IntegerType,\n\tbytesToHex,\n\tconcatBytes,\n} from \"../utils/encoding.ts\";\nimport type { L1LockupOutput } from \"./actions.ts\";\n\n/** pox-5 ABI: `(list 14 (buff 32))`. SIP-044 allows 24; we throw rather than truncate. */\nconst MAX_LEAF_HASHES = 14;\n\n/** P2WSH scriptPubKey: `0x0020 || sha256(witness script)`. */\nfunction lockupScriptPubKey(lockScript: Uint8Array): Uint8Array {\n\treturn concatBytes(Uint8Array.of(0x00, 0x20), sha256(lockScript));\n}\n\nfunction scriptsEqual(a: Uint8Array, b: Uint8Array): boolean {\n\treturn bytesToHex(a) === bytesToHex(b);\n}\n\n/**\n * Map a generic SIP-044 `SpvProof` onto pox-5's `L1LockupOutput`.\n * Witness is stripped, the lockup vout is resolved against the P2WSH\n * of `lockScript`, and more than {@link MAX_LEAF_HASHES} siblings throws.\n */\nexport function spvProofToL1LockupOutput(opts: {\n\tproof: SpvProof;\n\t/** Witness script; hashed to match the P2WSH lockup output. */\n\tlockScript: Uint8Array;\n\tunlockBurnHeight: IntegerType;\n\t/** Default: `proof.vout`, else the unique matching output. */\n\tvout?: number;\n}): L1LockupOutput {\n\tconst { proof, lockScript, unlockBurnHeight } = opts;\n\tconst tx = stripWitness(proof.rawTx);\n\tconst parsed = parseBitcoinTx(proof.rawTx);\n\tconst expected = lockupScriptPubKey(lockScript);\n\n\tlet outputIndex = opts.vout ?? proof.vout;\n\tif (outputIndex === undefined) {\n\t\tconst matches: number[] = [];\n\t\tfor (let i = 0; i < parsed.outputs.length; i++) {\n\t\t\tconst spk = parsed.outputs[i]?.scriptPubKey;\n\t\t\tif (spk && scriptsEqual(spk, expected)) matches.push(i);\n\t\t}\n\t\tif (matches.length !== 1) {\n\t\t\tthrow new Error(\n\t\t\t\t`spvProofToL1LockupOutput: expected exactly one matching lockup output, found ${matches.length}`,\n\t\t\t);\n\t\t}\n\t\toutputIndex = matches[0] as number;\n\t}\n\n\tconst output = parsed.outputs[outputIndex];\n\tif (!output) {\n\t\tthrow new Error(\n\t\t\t`spvProofToL1LockupOutput: output ${outputIndex} is out of range (${parsed.outputs.length} outputs)`,\n\t\t);\n\t}\n\tif (!scriptsEqual(output.scriptPubKey, expected)) {\n\t\tthrow new Error(\"lockup output script does not match\");\n\t}\n\n\tconst leafHashes = proof.merkle.siblings;\n\tif (leafHashes.length > MAX_LEAF_HASHES) {\n\t\tthrow new Error(\n\t\t\t`spvProofToL1LockupOutput: ${leafHashes.length} merkle siblings; pox-5 accepts at most ${MAX_LEAF_HASHES}`,\n\t\t);\n\t}\n\n\treturn {\n\t\theight: proof.height,\n\t\ttx,\n\t\toutputIndex,\n\t\theader: proof.header,\n\t\tleafHashes,\n\t\ttxCount: proof.merkle.txCount,\n\t\ttxIndex: proof.merkle.txIndex,\n\t\tamount: output.value,\n\t\tunlockBurnHeight,\n\t};\n}\n\n/**\n * Fetch a SIP-044 proof from `source` and map it onto pox-5's lockup shape.\n * `source` is required — no hosted Esplora default.\n */\nexport async function buildPox5LockProof(opts: {\n\tsource: ProofSource;\n\ttxid: string;\n\tlockScript: Uint8Array;\n\tunlockBurnHeight: IntegerType;\n\tvout?: number;\n}): Promise<L1LockupOutput> {\n\tconst proof = await buildTxProof(opts.source, {\n\t\ttxid: opts.txid,\n\t\tvout: opts.vout,\n\t});\n\treturn spvProofToL1LockupOutput({\n\t\tproof,\n\t\tlockScript: opts.lockScript,\n\t\tunlockBurnHeight: opts.unlockBurnHeight,\n\t\tvout: opts.vout,\n\t});\n}\n",
    "import { concatBytes } from \"../utils/encoding.ts\";\nimport { doubleSha256 } from \"./serialize.ts\";\n\n/**\n * A Bitcoin merkle inclusion proof, shaped for the SIP-044 `verify-merkle-proof`\n * built-in: `(leaf-hash, root-hash, tx-index, tx-count, sibling-hashes)`.\n *\n * - `siblings` are the sibling node hashes from the leaf up to (excluding) the\n *   root, in *internal* byte order — never reversed.\n * - `txCount` (not tree-depth) pins the canonical tree shape; the built-in\n *   rejects any proof whose length differs from `ceil(log2(tx-count))`.\n */\nexport interface MerkleProof {\n\tsiblings: Uint8Array[];\n\ttxIndex: number;\n\ttxCount: number;\n}\n\n/** Combine an ordered pair of nodes into their parent hash. */\nfunction hashPair(left: Uint8Array, right: Uint8Array): Uint8Array {\n\treturn doubleSha256(concatBytes(left, right));\n}\n\n/** Collapse one merkle level into the next, duplicating the last node if odd. */\nfunction nextLevel(level: Uint8Array[]): Uint8Array[] {\n\tconst next: Uint8Array[] = [];\n\tfor (let i = 0; i < level.length; i += 2) {\n\t\tconst left = level[i];\n\t\tif (left === undefined) throw new Error(\"merkle: missing left node\");\n\t\t// Bitcoin duplicates the final node when a level has an odd count.\n\t\tconst right = level[i + 1] ?? left;\n\t\tnext.push(hashPair(left, right));\n\t}\n\treturn next;\n}\n\n/**\n * Compute the merkle root over txids in *internal* byte order. The result is\n * also internal order — it matches the `merkle-root` field read straight out of\n * an 80-byte block header, so it can be cross-checked against the header before\n * a proof is trusted.\n */\nexport function merkleRoot(txidsInternal: Uint8Array[]): Uint8Array {\n\tif (txidsInternal.length === 0) {\n\t\tthrow new Error(\"merkleRoot: empty tx list\");\n\t}\n\tlet level = txidsInternal.slice();\n\twhile (level.length > 1) {\n\t\tlevel = nextLevel(level);\n\t}\n\tconst root = level[0];\n\tif (root === undefined) throw new Error(\"merkleRoot: no root\");\n\treturn root;\n}\n\n/**\n * Build the merkle inclusion proof for the tx at `txIndex`. Sibling count is\n * exactly `ceil(log2(txCount))`, as the SIP-044 built-in requires.\n */\nexport function buildMerkleProof(\n\ttxidsInternal: Uint8Array[],\n\ttxIndex: number,\n): MerkleProof {\n\tconst txCount = txidsInternal.length;\n\tif (txCount === 0) {\n\t\tthrow new Error(\"buildMerkleProof: empty tx list\");\n\t}\n\tif (txIndex < 0 || txIndex >= txCount) {\n\t\tthrow new Error(\n\t\t\t`buildMerkleProof: txIndex ${txIndex} out of range for ${txCount} txs`,\n\t\t);\n\t}\n\n\tconst siblings: Uint8Array[] = [];\n\tlet index = txIndex;\n\tlet level = txidsInternal.slice();\n\twhile (level.length > 1) {\n\t\tconst isRight = index % 2 === 1;\n\t\tconst siblingIndex = isRight ? index - 1 : index + 1;\n\t\tconst self = level[index];\n\t\tif (self === undefined) throw new Error(\"buildMerkleProof: missing node\");\n\t\t// When the node is the last of an odd level, it is paired with itself.\n\t\tsiblings.push(level[siblingIndex] ?? self);\n\t\tlevel = nextLevel(level);\n\t\tindex = Math.floor(index / 2);\n\t}\n\n\treturn { siblings, txIndex, txCount };\n}\n\n/**\n * Recompute the merkle root from a leaf + its proof — the same fold the on-chain\n * `verify-merkle-proof` performs. Use it off-chain to self-check a constructed\n * proof against the header's merkle root before submitting a contract call.\n */\nexport function rootFromProof(\n\tleafInternal: Uint8Array,\n\tproof: MerkleProof,\n): Uint8Array {\n\tlet hash = leafInternal;\n\tlet index = proof.txIndex;\n\tfor (const sibling of proof.siblings) {\n\t\thash = index % 2 === 1 ? hashPair(sibling, hash) : hashPair(hash, sibling);\n\t\tindex = Math.floor(index / 2);\n\t}\n\treturn hash;\n}\n",
    "import { bytesToHex, hexToBytes, without0x } from \"../utils/encoding.ts\";\nimport { type MerkleProof, buildMerkleProof, rootFromProof } from \"./merkle.ts\";\nimport { parseBitcoinTx, parseBlockHeader, reverseBytes } from \"./serialize.ts\";\n\n/**\n * A self-contained Bitcoin SPV proof: everything the SIP-044 built-ins need to\n * prove a tx (and one of its outputs) is committed in a confirmed block. Hashes\n * are internal byte order throughout.\n */\nexport interface SpvProof {\n\trawTx: Uint8Array;\n\t/** The tx's txid, internal order — the merkle leaf. */\n\ttxidInternal: Uint8Array;\n\t/** Output index of interest, if the proof targets a specific output. */\n\tvout?: number;\n\tmerkle: MerkleProof;\n\t/** The 80-byte block header that commits the tx. */\n\theader: Uint8Array;\n\t/** Bitcoin block height. */\n\theight: number;\n}\n\n/** The block context a `ProofSource` resolves for a confirmed tx. */\nexport interface BlockForTx {\n\t/** 80-byte block header. */\n\theader: Uint8Array;\n\theight: number;\n\t/** All of the block's txids, internal order, in block order. */\n\ttxidsInternal: Uint8Array[];\n\t/** Index of the target tx within the block. */\n\ttxIndex: number;\n}\n\n/**\n * Where proof inputs come from. The default is the integrator's own Bitcoin node\n * (`bitcoinRpcSource`) — trustless; a hosted Esplora-compatible endpoint\n * (`esploraSource`) is the fallback. `buildTxProof` independently re-checks\n * whatever a source returns, so a wrong or hostile source fails loudly rather\n * than producing a bad proof.\n */\nexport interface ProofSource {\n\t/** Raw (serialized) tx bytes for a txid (display-order hex). */\n\tgetRawTx(txid: string): Promise<Uint8Array>;\n\t/** The confirming block's header, height, and txid set for a txid. */\n\tgetBlockForTx(txid: string): Promise<BlockForTx>;\n}\n\nfunction normalizeTxid(txid: string): string {\n\treturn without0x(txid).toLowerCase();\n}\n\n/**\n * Locate `txid` in a block's txid set and assemble its `BlockForTx`. Owns the\n * display→internal byte-order reversal (`reverseBytes`) so the ProofSources\n * can't drift on the one operation a silent merkle-root mismatch would hide.\n * `txidsDisplay` are display-order hex txids as returned by Core / Esplora.\n */\nfunction assembleBlockForTx(args: {\n\ttxid: string;\n\tblockId: string;\n\theaderHex: string;\n\theight: number;\n\ttxidsDisplay: string[];\n}): BlockForTx {\n\tconst txIndex = args.txidsDisplay.indexOf(normalizeTxid(args.txid));\n\tif (txIndex < 0) {\n\t\tthrow new Error(`tx ${args.txid} not found in block ${args.blockId}`);\n\t}\n\treturn {\n\t\theader: hexToBytes(args.headerHex),\n\t\theight: args.height,\n\t\ttxidsInternal: args.txidsDisplay.map((t) => reverseBytes(hexToBytes(t))),\n\t\ttxIndex,\n\t};\n}\n\n/**\n * Assemble an `SpvProof` for a txid from a `ProofSource`, validating every claim\n * the source makes:\n *  - the returned raw tx actually hashes to the requested txid,\n *  - the claimed `txIndex` points at that txid in the block, and\n *  - the resulting merkle proof folds back to the block header's merkle root.\n * Any mismatch throws — the proof is never returned half-trusted.\n */\nexport async function buildTxProof(\n\tsource: ProofSource,\n\tparams: { txid: string; vout?: number },\n): Promise<SpvProof> {\n\tconst { txid, vout } = params;\n\tconst want = normalizeTxid(txid);\n\n\tconst [rawTx, block] = await Promise.all([\n\t\tsource.getRawTx(txid),\n\t\tsource.getBlockForTx(txid),\n\t]);\n\n\tconst parsed = parseBitcoinTx(rawTx);\n\tconst gotDisplay = bytesToHex(reverseBytes(parsed.txidInternal));\n\tif (gotDisplay !== want) {\n\t\tthrow new Error(\n\t\t\t`source returned a tx whose id ${gotDisplay} does not match requested ${want}`,\n\t\t);\n\t}\n\n\tconst atIndex = block.txidsInternal[block.txIndex];\n\tif (!atIndex || bytesToHex(atIndex) !== bytesToHex(parsed.txidInternal)) {\n\t\tthrow new Error(\n\t\t\t`source txIndex ${block.txIndex} does not point at tx ${want}`,\n\t\t);\n\t}\n\n\tconst merkle = buildMerkleProof(block.txidsInternal, block.txIndex);\n\n\tconst headerRoot = parseBlockHeader(block.header).merkleRoot;\n\tconst computed = rootFromProof(parsed.txidInternal, merkle);\n\tif (bytesToHex(computed) !== bytesToHex(headerRoot)) {\n\t\tthrow new Error(\n\t\t\t\"constructed merkle proof does not reconcile with the block header merkle root\",\n\t\t);\n\t}\n\n\treturn {\n\t\trawTx,\n\t\ttxidInternal: parsed.txidInternal,\n\t\tvout,\n\t\tmerkle,\n\t\theader: block.header,\n\t\theight: block.height,\n\t};\n}\n\n/**\n * Compose sources into an ordered fallback chain: each call tries them in turn\n * and returns the first success, throwing the last error if all fail. Put the\n * trustless integrator node first and a hosted endpoint last.\n */\nexport function fallbackProofSource(sources: ProofSource[]): ProofSource {\n\tif (sources.length === 0) {\n\t\tthrow new Error(\"fallbackProofSource: at least one source is required\");\n\t}\n\tasync function firstSuccess<T>(\n\t\tfn: (s: ProofSource) => Promise<T>,\n\t): Promise<T> {\n\t\tlet lastError: unknown;\n\t\tfor (const source of sources) {\n\t\t\ttry {\n\t\t\t\treturn await fn(source);\n\t\t\t} catch (error) {\n\t\t\t\tlastError = error;\n\t\t\t}\n\t\t}\n\t\tthrow lastError;\n\t}\n\treturn {\n\t\tgetRawTx: (txid) => firstSuccess((s) => s.getRawTx(txid)),\n\t\tgetBlockForTx: (txid) => firstSuccess((s) => s.getBlockForTx(txid)),\n\t};\n}\n\nexport interface BitcoinRpcConfig {\n\t/** Bitcoin Core JSON-RPC endpoint URL. */\n\turl: string;\n\t/** Basic auth — `{ username, password }` or a pre-encoded base64 string. */\n\tauth?: { username: string; password: string } | string;\n\t/** Override the fetch implementation (testing / custom agents). */\n\tfetch?: typeof fetch;\n}\n\n/**\n * A `ProofSource` backed by the integrator's own Bitcoin Core node over\n * JSON-RPC. This is the trustless default. The node must run with `-txindex`\n * (or the tx must be in the mempool's block view) so `getrawtransaction` can\n * resolve the confirming block.\n */\nexport function bitcoinRpcSource(config: BitcoinRpcConfig): ProofSource {\n\tconst doFetch = config.fetch ?? fetch;\n\n\tasync function rpc<T>(method: string, rpcParams: unknown[]): Promise<T> {\n\t\tconst headers: Record<string, string> = {\n\t\t\t\"content-type\": \"application/json\",\n\t\t};\n\t\tif (config.auth) {\n\t\t\tconst basic =\n\t\t\t\ttypeof config.auth === \"string\"\n\t\t\t\t\t? config.auth\n\t\t\t\t\t: btoa(`${config.auth.username}:${config.auth.password}`);\n\t\t\theaders.authorization = `Basic ${basic}`;\n\t\t}\n\t\tconst res = await doFetch(config.url, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders,\n\t\t\tbody: JSON.stringify({\n\t\t\t\tjsonrpc: \"1.0\",\n\t\t\t\tid: \"secondlayer\",\n\t\t\t\tmethod,\n\t\t\t\tparams: rpcParams,\n\t\t\t}),\n\t\t});\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(`bitcoin rpc ${method} failed: HTTP ${res.status}`);\n\t\t}\n\t\tconst json = (await res.json()) as {\n\t\t\tresult: T;\n\t\t\terror: { message: string } | null;\n\t\t};\n\t\tif (json.error) {\n\t\t\tthrow new Error(`bitcoin rpc ${method} error: ${json.error.message}`);\n\t\t}\n\t\treturn json.result;\n\t}\n\n\treturn {\n\t\tasync getRawTx(txid) {\n\t\t\treturn hexToBytes(await rpc<string>(\"getrawtransaction\", [txid, false]));\n\t\t},\n\t\tasync getBlockForTx(txid) {\n\t\t\tconst tx = await rpc<{ blockhash?: string }>(\"getrawtransaction\", [\n\t\t\t\ttxid,\n\t\t\t\ttrue,\n\t\t\t]);\n\t\t\tif (!tx.blockhash) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`tx ${txid} is not in a block (node needs -txindex, or the tx is unconfirmed)`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst block = await rpc<{ tx: string[]; height: number }>(\"getblock\", [\n\t\t\t\ttx.blockhash,\n\t\t\t\t1,\n\t\t\t]);\n\t\t\tconst header = await rpc<string>(\"getblockheader\", [tx.blockhash, false]);\n\t\t\treturn assembleBlockForTx({\n\t\t\t\ttxid,\n\t\t\t\tblockId: tx.blockhash,\n\t\t\t\theaderHex: header,\n\t\t\t\theight: block.height,\n\t\t\t\ttxidsDisplay: block.tx,\n\t\t\t});\n\t\t},\n\t};\n}\n\nexport interface EsploraConfig {\n\t/** Esplora REST base URL, e.g. `https://blockstream.info/api` or a self-hosted instance. */\n\turl: string;\n\t/** Override the fetch implementation. */\n\tfetch?: typeof fetch;\n}\n\n/**\n * A `ProofSource` backed by an Esplora REST API (self-hosted, or a hosted\n * provider as a fallback). Provider-agnostic: any Esplora-compatible endpoint\n * works. Use as the hosted fallback behind `bitcoinRpcSource`.\n */\nexport function esploraSource(config: EsploraConfig): ProofSource {\n\tconst doFetch = config.fetch ?? fetch;\n\tconst base = config.url.replace(/\\/+$/, \"\");\n\n\tasync function get(path: string): Promise<Response> {\n\t\tconst res = await doFetch(`${base}${path}`);\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(`esplora GET ${path} failed: HTTP ${res.status}`);\n\t\t}\n\t\treturn res;\n\t}\n\n\treturn {\n\t\tasync getRawTx(txid) {\n\t\t\treturn hexToBytes((await (await get(`/tx/${txid}/hex`)).text()).trim());\n\t\t},\n\t\tasync getBlockForTx(txid) {\n\t\t\tconst status = (await (await get(`/tx/${txid}`)).json()) as {\n\t\t\t\tstatus: {\n\t\t\t\t\tconfirmed: boolean;\n\t\t\t\t\tblock_height: number;\n\t\t\t\t\tblock_hash: string;\n\t\t\t\t};\n\t\t\t};\n\t\t\tif (!status.status.confirmed) {\n\t\t\t\tthrow new Error(`tx ${txid} is unconfirmed`);\n\t\t\t}\n\t\t\tconst blockHashHex = status.status.block_hash;\n\t\t\tconst header = (\n\t\t\t\tawait (await get(`/block/${blockHashHex}/header`)).text()\n\t\t\t).trim();\n\t\t\tconst txids = (await (\n\t\t\t\tawait get(`/block/${blockHashHex}/txids`)\n\t\t\t).json()) as string[];\n\t\t\treturn assembleBlockForTx({\n\t\t\t\ttxid,\n\t\t\t\tblockId: blockHashHex,\n\t\t\t\theaderHex: header,\n\t\t\t\theight: status.status.block_height,\n\t\t\t\ttxidsDisplay: txids,\n\t\t\t});\n\t\t},\n\t};\n}\n",
    "import { sha256 } from \"@noble/hashes/sha2.js\";\nimport * as btc from \"@scure/btc-signer\";\nimport { signECDSA } from \"@scure/btc-signer/utils.js\";\nimport type { BitcoinNetwork } from \"../bitcoin/constants.ts\";\nimport {\n\ttype IntegerType,\n\tbytesToHex,\n\tconcatBytes,\n\thexToBytes,\n\tintToBigInt,\n} from \"../utils/encoding.ts\";\nimport { stakerPreimage } from \"./script.ts\";\n\n/**\n * Spend a pox-5 P2WSH lockup back out.\n *\n * Two paths through the lockup script (mirror of `construct-lockup-script`):\n * - `'locktime'` — CLTV exit (`OP_IF`), single-sig, spendable once the burn\n *   height is past the lock's unlock height.\n * - `'early-exit'` — cosigned exit (`OP_ELSE`), 2-of-2 staker + bond cosigner.\n *   Valid only after `announce-l1-early-exit` on Stacks; this helper spends the\n *   UTXO and does not announce.\n */\nexport type ReclaimPath = \"locktime\" | \"early-exit\";\n\nconst SIGHASH_ALL = 1;\n/** Conservative dust limit (the 546-sat P2PKH bound covers all output types). */\nconst DUST_LIMIT_SATS = 546n;\n/** Empty witness item — selects the `OP_ELSE` (early-exit) branch. */\nconst ELSE_SELECTOR = new Uint8Array(0);\n/** Truthy witness item — selects the `OP_IF` (CLTV) branch. */\nconst IF_SELECTOR = new Uint8Array([0x01]);\n/** Custom-script spend; let btc-signer carry it unvalidated. */\nconst TX_OPTS = {\n\tallowUnknownOutputs: true,\n\tdisableScriptCheck: true,\n\tallowUnknownInputs: true,\n} as const;\n\nconst REGTEST_NETWORK = { ...btc.TEST_NETWORK, bech32: \"bcrt\" };\n\nfunction btcNetworkFrom(network: BitcoinNetwork): typeof btc.NETWORK {\n\tif (network === \"mainnet\") return btc.NETWORK;\n\tif (network === \"testnet\") return btc.TEST_NETWORK;\n\treturn REGTEST_NETWORK;\n}\n\nfunction toBytes(value: Uint8Array | string): Uint8Array {\n\treturn typeof value === \"string\" ? hexToBytes(value) : value;\n}\n\nfunction toPrivBytes(value: Uint8Array | string): Uint8Array {\n\treturn toBytes(value).slice(0, 32);\n}\n\nfunction bytesEqual(a: Uint8Array, b: Uint8Array): boolean {\n\treturn bytesToHex(a) === bytesToHex(b);\n}\n\n/** P2WSH `scriptPubKey`: `0x0020 || sha256(lockScript)`. */\nfunction scriptToWshOutput(lockScript: Uint8Array): Uint8Array {\n\treturn concatBytes(Uint8Array.of(0x00, 0x20), sha256(lockScript));\n}\n\n/** Ops in the fixed lockup scaffold before the early-unlock subscript. */\nconst SCAFFOLD_PREFIX_LEN = 10;\n\n/**\n * Split a lockup witness script on the `construct-lockup-script` scaffold so\n * each subscript's keys stay attributed to the right party. Locate\n * `OP_ENDIF OP_VERIFY` from the end — a subscript may contain conditionals of\n * its own.\n *\n * @throws if the script is not a pox-5 lockup script.\n */\nfunction decodeLockScript(script: Uint8Array): {\n\tstakerPubs: Uint8Array[];\n\tcosignerPubs: Uint8Array[];\n\tunlockHeight?: number;\n} {\n\tconst ops = btc.Script.decode(script);\n\n\tconst endifIdx = ops.reduce<number>(\n\t\t(found, op, i) => (op === \"ENDIF\" && ops[i + 1] === \"VERIFY\" ? i : found),\n\t\t-1,\n\t);\n\n\tconst hashOp = ops[8];\n\tconst shapeOk =\n\t\tendifIdx >= SCAFFOLD_PREFIX_LEN &&\n\t\tops[0] === \"IF\" &&\n\t\tops[2] === \"CHECKLOCKTIMEVERIFY\" &&\n\t\tops[3] === \"ELSE\" &&\n\t\tops[4] === \"SIZE\" &&\n\t\tops[6] === \"EQUALVERIFY\" &&\n\t\tops[7] === \"SHA256\" &&\n\t\thashOp instanceof Uint8Array &&\n\t\thashOp.length === 32 &&\n\t\tops[9] === \"EQUALVERIFY\";\n\tif (!shapeOk) {\n\t\tthrow new Error(\n\t\t\t\"reclaim: lockScript is not a pox-5 lockup script (expected the OP_IF/OP_ELSE … OP_ENDIF OP_VERIFY scaffold)\",\n\t\t);\n\t}\n\n\tconst keysIn = (slice: btc.ScriptType) =>\n\t\tslice.filter(\n\t\t\t(op): op is Uint8Array => op instanceof Uint8Array && op.length === 33,\n\t\t);\n\n\tconst heightOp = ops[1];\n\tconst unlockHeight =\n\t\ttypeof heightOp === \"number\"\n\t\t\t? heightOp\n\t\t\t: heightOp instanceof Uint8Array\n\t\t\t\t? Number(btc.ScriptNum().decode(heightOp))\n\t\t\t\t: undefined;\n\n\treturn {\n\t\tcosignerPubs: keysIn(ops.slice(SCAFFOLD_PREFIX_LEN, endifIdx)),\n\t\tstakerPubs: keysIn(ops.slice(endifIdx + 2)),\n\t\tunlockHeight,\n\t};\n}\n\n/** Confirmed lockup UTXO (esplora / mempool.space shape). */\nexport type ReclaimUtxo = {\n\ttxid: string;\n\tvout: number;\n\tvalue: IntegerType;\n\t/** Cross-check only; re-derived from `lockScript` when omitted. */\n\tscriptPubKey?: Uint8Array;\n};\n\n/** Inputs to {@link buildReclaim}. */\nexport type BuildReclaimOpts = {\n\tpath: ReclaimPath;\n\tutxo: ReclaimUtxo;\n\tnetwork: BitcoinNetwork;\n\t/**\n\t * Sweep output: `value - feeSats` pays `address`. Mutate the returned tx's\n\t * outputs before signing if needed (`SIGHASH_ALL` commits to them).\n\t */\n\toutput: { address: string; feeSats: IntegerType };\n\t/**\n\t * The lockup `witnessScript` — pass the bytes you funded (typically\n\t * `buildLockupScript(...)` / `RegisterMetadata.lockScript`). The CLTV\n\t * unlock height is decoded from it.\n\t */\n\tlockScript: Uint8Array | string;\n};\n\n/**\n * Build the unsigned reclaim transaction (a `@scure/btc-signer` `Transaction`).\n *\n * One P2WSH input with `witnessUtxo` + `witnessScript` so the tx is a complete\n * PSBT (`toPSBT` / `fromPSBT` round-trip). HSM path: `buildReclaim` →\n * `tx.signIdx` or {@link computeReclaimSighash} + detached `partialSig` →\n * {@link finalizeReclaim}.\n *\n * - `path: \"early-exit\"` → `sequence = 0xffffffff`, `lockTime = 0`\n * - `path: \"locktime\"` → `sequence = 0xfffffffe`, `lockTime = unlockHeight`\n */\nexport function buildReclaim(opts: BuildReclaimOpts): btc.Transaction {\n\tconst network = btcNetworkFrom(opts.network);\n\tconst lockScript = toBytes(opts.lockScript);\n\tconst { unlockHeight: scriptHeight } = decodeLockScript(lockScript);\n\n\tconst amount = intToBigInt(opts.utxo.value);\n\tconst { address } = opts.output;\n\tconst feeSats = intToBigInt(opts.output.feeSats);\n\n\tif (feeSats < 0n) {\n\t\tthrow new Error(`buildReclaim: feeSats (${feeSats}) must be non-negative`);\n\t}\n\n\tconst outputScript = scriptToWshOutput(lockScript);\n\tif (\n\t\topts.utxo.scriptPubKey &&\n\t\t!bytesEqual(opts.utxo.scriptPubKey, outputScript)\n\t) {\n\t\tthrow new Error(\n\t\t\t\"buildReclaim: utxo.scriptPubKey does not match the lockScript — the signature would commit to the wrong output and every reclaim attempt would fail at relay\",\n\t\t);\n\t}\n\n\tconst sweepSats = amount - feeSats;\n\tif (sweepSats <= 0n) {\n\t\tthrow new Error(`buildReclaim: fee (${feeSats}) >= utxo value (${amount})`);\n\t}\n\tif (sweepSats < DUST_LIMIT_SATS) {\n\t\tthrow new Error(\n\t\t\t`buildReclaim: sweep of ${sweepSats} sats is below the ${DUST_LIMIT_SATS}-sat dust limit — nodes would not relay the tx`,\n\t\t);\n\t}\n\n\tconst earlyExit = opts.path === \"early-exit\";\n\tif (!earlyExit && scriptHeight == null) {\n\t\tthrow new Error(\n\t\t\t\"buildReclaim: the locktime path needs a lockScript that encodes a CLTV unlock height\",\n\t\t);\n\t}\n\tconst lockTime = earlyExit ? 0 : scriptHeight;\n\n\tconst tx = new btc.Transaction({ ...TX_OPTS, lockTime });\n\ttx.addInput({\n\t\ttxid: opts.utxo.txid,\n\t\tindex: opts.utxo.vout,\n\t\tsequence: earlyExit ? 0xffffffff : 0xfffffffe,\n\t\twitnessUtxo: { script: outputScript, amount },\n\t\twitnessScript: lockScript,\n\t});\n\ttx.addOutputAddress(address, sweepSats, network);\n\treturn tx;\n}\n\n/**\n * Input-0 BIP-143 sighash for a reclaim tx.\n *\n * In-process keys should prefer `tx.signIdx(privateKey, 0)`. This helper is\n * for HSMs / MPC that sign a bare digest, and for passing the early-exit\n * sighash between parties. Recompute after any output/fee change.\n *\n * Reads `witnessScript` + amount off the tx (set by {@link buildReclaim});\n * pass `opts` to re-supply them for a tx parsed from raw hex.\n */\nexport function computeReclaimSighash(\n\ttx: btc.Transaction,\n\topts?: { witnessScript?: Uint8Array | string; amountSats?: IntegerType },\n): Uint8Array {\n\tconst input = tx.getInput(0);\n\tconst witnessScript =\n\t\topts?.witnessScript != null\n\t\t\t? toBytes(opts.witnessScript)\n\t\t\t: input.witnessScript;\n\tconst amount =\n\t\topts?.amountSats != null\n\t\t\t? intToBigInt(opts.amountSats)\n\t\t\t: input.witnessUtxo?.amount;\n\tif (!witnessScript || amount == null) {\n\t\tthrow new Error(\n\t\t\t\"computeReclaimSighash: need witnessScript + amount (pass `opts` for a raw-hex tx)\",\n\t\t);\n\t}\n\treturn tx.preimageWitnessV0(0, witnessScript, SIGHASH_ALL, amount);\n}\n\n/**\n * Sign a reclaim sighash with a software key: DER + trailing `SIGHASH_ALL`.\n * `lowR` defaults to `false` to match btc-signer's `signIdx`. Kept as the\n * software stand-in for a detached signer (HSM tests).\n */\nexport function signReclaim(\n\tsighash: Uint8Array,\n\tprivateKey: Uint8Array | string,\n\topts?: { lowR?: boolean },\n): Uint8Array {\n\tconst priv = toPrivBytes(privateKey);\n\treturn concatBytes(\n\t\tsignECDSA(sighash, priv, opts?.lowR ?? false),\n\t\tUint8Array.of(SIGHASH_ALL),\n\t);\n}\n\n/** Arguments to {@link finalizeReclaim}, discriminated on the spend path. */\nexport type FinalizeReclaimOpts =\n\t| {\n\t\t\tpath: \"early-exit\";\n\t\t\ttx: btc.Transaction;\n\t\t\t/** Staker principal — rebuilds the 32-byte preimage the `OP_ELSE` branch reveals. */\n\t\t\tstxAddress: string;\n\t  }\n\t| { path: \"locktime\"; tx: btc.Transaction };\n\n/**\n * Assemble the custom IF/ELSE witness from signatures already on the tx.\n *\n * btc-signer's own finalizer cannot build this script, so we splice\n * `finalScriptWitness` directly. Does not broadcast.\n *\n * - locktime: `[stakerSig, 0x01, witnessScript]`\n * - early-exit: `[stakerSig, cosignerSig, preimage, <empty>, witnessScript]`\n */\nexport function finalizeReclaim(opts: FinalizeReclaimOpts): {\n\ttxHex: string;\n\ttxid: string;\n} {\n\tconst { tx } = opts;\n\tconst witnessScript = tx.getInput(0).witnessScript;\n\tif (!witnessScript)\n\t\tthrow new Error(\"finalizeReclaim: input 0 has no witnessScript\");\n\n\ttx.updateInput(\n\t\t0,\n\t\t{ finalScriptWitness: reclaimWitness(opts, witnessScript) },\n\t\ttrue,\n\t);\n\tif (!tx.isFinal)\n\t\tthrow new Error(\"finalizeReclaim: witness injection failed (tx not final)\");\n\treturn { txHex: tx.hex, txid: tx.id };\n}\n\nfunction reclaimWitness(\n\topts: FinalizeReclaimOpts,\n\twitnessScript: Uint8Array,\n): Uint8Array[] {\n\tconst sigs = opts.tx.getInput(0).partialSig ?? [];\n\tconst { stakerPubs, cosignerPubs } = decodeLockScript(witnessScript);\n\n\tif (stakerPubs.length !== 1) {\n\t\tthrow new Error(\n\t\t\t`finalizeReclaim: expected exactly one staker public key in the lockup script, found ${stakerPubs.length} — multi-key subscripts are not supported`,\n\t\t);\n\t}\n\tconst stakerPub = stakerPubs[0];\n\tif (!stakerPub) {\n\t\tthrow new Error(\n\t\t\t\"finalizeReclaim: expected exactly one staker public key in the lockup script, found 0 — multi-key subscripts are not supported\",\n\t\t);\n\t}\n\n\tconst sigFor = (pub: Uint8Array) =>\n\t\tsigs.find(([p]) => p !== undefined && bytesEqual(p, pub))?.[1];\n\n\tconst stakerSig = sigFor(stakerPub);\n\tif (!stakerSig)\n\t\tthrow new Error(\"finalizeReclaim: missing staker signature (partialSig)\");\n\n\tif (opts.path === \"locktime\") return [stakerSig, IF_SELECTOR, witnessScript];\n\n\tif (cosignerPubs.length !== 1) {\n\t\tthrow new Error(\n\t\t\t`finalizeReclaim: expected exactly one cosigner public key in the lockup script, found ${cosignerPubs.length} — multi-key subscripts are not supported`,\n\t\t);\n\t}\n\tconst cosignerPub = cosignerPubs[0];\n\tif (!cosignerPub) {\n\t\tthrow new Error(\n\t\t\t\"finalizeReclaim: expected exactly one cosigner public key in the lockup script, found 0 — multi-key subscripts are not supported\",\n\t\t);\n\t}\n\tconst cosignerSig = sigFor(cosignerPub);\n\tif (!cosignerSig)\n\t\tthrow new Error(\"finalizeReclaim: missing cosigner signature (partialSig)\");\n\treturn [\n\t\tstakerSig,\n\t\tcosignerSig,\n\t\tstakerPreimage(opts.stxAddress),\n\t\tELSE_SELECTOR,\n\t\twitnessScript,\n\t];\n}\n\nexport type ReclaimOpts = BuildReclaimOpts & {\n\t/** 32-byte BTC private key (raw bytes or hex). Not a Stacks account key. */\n\tstakerPrivateKey: Uint8Array | string;\n\t/** Required for `path: \"early-exit\"`. */\n\tcosignerPrivateKey?: Uint8Array | string;\n\t/** Required for `path: \"early-exit\"` — feeds {@link stakerPreimage}. */\n\tstxAddress?: string;\n};\n\n/**\n * One-shot reclaim for in-process BTC keys: build + signIdx + finalize.\n * Does not broadcast; the caller relays `txHex`.\n */\nexport function reclaim(opts: ReclaimOpts): { txHex: string; txid: string } {\n\tconst tx = buildReclaim(opts);\n\ttx.signIdx(toPrivBytes(opts.stakerPrivateKey), 0);\n\tif (opts.path === \"early-exit\") {\n\t\tif (opts.cosignerPrivateKey == null) {\n\t\t\tthrow new Error(\n\t\t\t\t'reclaim: cosignerPrivateKey is required for path \"early-exit\"',\n\t\t\t);\n\t\t}\n\t\tif (opts.stxAddress == null) {\n\t\t\tthrow new Error(\n\t\t\t\t'reclaim: stxAddress is required for path \"early-exit\" (preimage)',\n\t\t\t);\n\t\t}\n\t\ttx.signIdx(toPrivBytes(opts.cosignerPrivateKey), 0);\n\t\treturn finalizeReclaim({\n\t\t\tpath: \"early-exit\",\n\t\t\ttx,\n\t\t\tstxAddress: opts.stxAddress,\n\t\t});\n\t}\n\treturn finalizeReclaim({ path: \"locktime\", tx });\n}\n",
    "import type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { readContract } from \"./readContract.ts\";\n\nexport type MulticallCall = {\n\tcontract: string;\n\tfunctionName: string;\n\targs?: ClarityValue[];\n\tsender?: string;\n};\n\nexport type MulticallParams<TAllowFailure extends boolean = true> = {\n\tcalls: readonly MulticallCall[];\n\tallowFailure?: TAllowFailure;\n\t/**\n\t * Reads in flight at once. Default 8. Each call is its own\n\t * `/v2/contracts/call-read` request (Stacks nodes have no batch RPC), so\n\t * an uncapped fan-out turns one multicall into a burst that trips rate\n\t * limits and then retries in lockstep.\n\t */\n\tconcurrency?: number;\n};\n\nexport type MulticallSuccessResult = {\n\tstatus: \"success\";\n\tresult: ClarityValue;\n};\nexport type MulticallFailureResult = { status: \"failure\"; error: Error };\n\nexport type MulticallResult<T extends boolean> = T extends true\n\t? (MulticallSuccessResult | MulticallFailureResult)[]\n\t: ClarityValue[];\n\n/** Run `fn` over `items` with at most `limit` in flight, preserving order. */\nasync function mapWithConcurrency<T, R>(\n\titems: readonly T[],\n\tlimit: number,\n\tfn: (item: T) => Promise<R>,\n): Promise<PromiseSettledResult<R>[]> {\n\tconst results: PromiseSettledResult<R>[] = new Array(items.length);\n\tlet cursor = 0;\n\tconst worker = async () => {\n\t\twhile (cursor < items.length) {\n\t\t\tconst index = cursor++;\n\t\t\ttry {\n\t\t\t\tresults[index] = {\n\t\t\t\t\tstatus: \"fulfilled\",\n\t\t\t\t\tvalue: await fn(items[index] as T),\n\t\t\t\t};\n\t\t\t} catch (reason) {\n\t\t\t\tresults[index] = { status: \"rejected\", reason };\n\t\t\t}\n\t\t}\n\t};\n\tconst workers = Math.max(1, Math.min(limit, items.length));\n\tawait Promise.all(Array.from({ length: workers }, worker));\n\treturn results;\n}\n\nexport async function multicall<TAllowFailure extends boolean = true>(\n\tclient: Client,\n\tparams: MulticallParams<TAllowFailure>,\n): Promise<MulticallResult<TAllowFailure>> {\n\tconst { calls, allowFailure = true, concurrency = 8 } = params;\n\tif (!Number.isInteger(concurrency) || concurrency < 1) {\n\t\tthrow new RangeError(\n\t\t\t`multicall concurrency must be a positive integer, got ${concurrency}`,\n\t\t);\n\t}\n\n\tconst settled = await mapWithConcurrency(calls, concurrency, (call) =>\n\t\treadContract(client, call),\n\t);\n\n\tif (allowFailure) {\n\t\treturn settled.map((r) =>\n\t\t\tr.status === \"fulfilled\"\n\t\t\t\t? { status: \"success\" as const, result: r.value }\n\t\t\t\t: {\n\t\t\t\t\t\tstatus: \"failure\" as const,\n\t\t\t\t\t\terror:\n\t\t\t\t\t\t\tr.reason instanceof Error\n\t\t\t\t\t\t\t\t? r.reason\n\t\t\t\t\t\t\t\t: new Error(String(r.reason)),\n\t\t\t\t\t},\n\t\t) as MulticallResult<TAllowFailure>;\n\t}\n\n\tconst results: ClarityValue[] = [];\n\tfor (const r of settled) {\n\t\tif (r.status === \"rejected\") throw r.reason;\n\t\tresults.push(r.value);\n\t}\n\treturn results as MulticallResult<TAllowFailure>;\n}\n",
    "import { multicall } from \"../actions/public/multicall.ts\";\nimport type { ProofSource } from \"../bitcoin/proof.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport type { Client } from \"../clients/types.ts\";\nimport type { IntegerType } from \"../utils/encoding.ts\";\nimport {\n\ttype AnnounceL1EarlyExitParams,\n\ttype CalculateRewardsParams,\n\ttype ClaimRewardsParams,\n\ttype ClaimStakerRewardsForSignerParams,\n\ttype GrantSignerKeyParams,\n\ttype L1LockupOutput,\n\ttype PauseRewardsParams,\n\ttype RegisterForBondParams,\n\ttype RevokeSignerGrantParams,\n\ttype SetBondAdminParams,\n\ttype SetPauseAdminParams,\n\ttype SetupBondParams,\n\ttype StakeParams,\n\ttype StakeUpdateParams,\n\ttype UnstakeParams,\n\ttype UnstakeSbtcParams,\n\ttype UpdateBondRegistrationParams,\n\tannounceL1EarlyExit,\n\tcalculateRewards,\n\tclaimRewards,\n\tclaimStakerRewardsForSigner,\n\tgetBondAllowance,\n\tgetBondL1UnlockHeight,\n\tgetBondMembership,\n\tgetCurrentRewardCycle,\n\tgetEarned,\n\tgetEarnedStakerRewards,\n\tgetFirstPox5RewardCycle,\n\tgetLastRewardComputeHeight,\n\tgetProtocolBond,\n\tgetSignerInfo,\n\tgetStakerCustodiedSbtc,\n\tgetStakerInfo,\n\tgetTotalSbtcStakedForBond,\n\tgetTotalSharesStakedForCycle,\n\tgrantSignerKey,\n\thasAnnouncedL1EarlyExit,\n\tpauseRewards,\n\tpox5ContractId,\n\tregisterForBond,\n\trevokeSignerGrant,\n\tsetBondAdmin,\n\tsetPauseAdmin,\n\tsetupBond,\n\tstake,\n\tstakeUpdate,\n\tunstake,\n\tunstakeSbtc,\n\tupdateBondRegistration,\n\tverifySignerKeyGrantOnChain,\n} from \"./actions.ts\";\nimport {\n\ttype Pox5Activation,\n\ttype Pox5Info,\n\tgetPox5Activation,\n\tgetPoxInfo,\n\tisPox5Active,\n} from \"./activation.ts\";\nimport {\n\ttype EligibilityResult,\n\ttype EligibleAdminParams,\n\ttype EligibleClaimRewardsParams,\n\ttype EligibleGrantSignerKeyParams,\n\ttype EligibleRegisterForBondParams,\n\ttype EligibleStakeParams,\n\ttype EligibleUnstakeParams,\n\ttype EligibleUnstakeSbtcParams,\n\teligibleClaimRewards,\n\teligibleGrantSignerKey,\n\teligiblePauseRewards,\n\teligibleRegisterForBond,\n\teligibleSetBondAdmin,\n\teligibleStake,\n\teligibleUnstake,\n\teligibleUnstakeSbtc,\n} from \"./eligibility.ts\";\nimport { buildPox5LockProof } from \"./lockProof.ts\";\nimport type {\n\tBondAllowance,\n\tBondMembership,\n\tProtocolBond,\n\tSignerInfo,\n\tStakerInfo,\n} from \"./types.ts\";\n\n/**\n * A staker's whole PoX-5 position in ONE batched request: staker info, bond\n * membership, custodied sBTC, and the current cycle — the state a dashboard\n * or agent polls, without four round-trips.\n */\nexport type StakerState = {\n\tstakerInfo: ClarityValue;\n\tbondMembership: ClarityValue;\n\tcustodiedSbtc: ClarityValue;\n\tcurrentCycle: ClarityValue;\n};\n\nasync function getStakerState(\n\tclient: Client,\n\tstaker: string,\n): Promise<StakerState> {\n\tconst contract = pox5ContractId(client);\n\tconst results = await multicall(client, {\n\t\tallowFailure: false,\n\t\tcalls: [\n\t\t\t{\n\t\t\t\tcontract,\n\t\t\t\tfunctionName: \"get-staker-info\",\n\t\t\t\targs: [Cl.principal(staker)],\n\t\t\t},\n\t\t\t{\n\t\t\t\tcontract,\n\t\t\t\tfunctionName: \"get-bond-membership\",\n\t\t\t\targs: [Cl.principal(staker)],\n\t\t\t},\n\t\t\t{\n\t\t\t\tcontract,\n\t\t\t\tfunctionName: \"get-staker-custodied-sbtc\",\n\t\t\t\targs: [Cl.principal(staker)],\n\t\t\t},\n\t\t\t{ contract, functionName: \"current-pox-reward-cycle\", args: [] },\n\t\t],\n\t});\n\tconst [stakerInfo, bondMembership, custodiedSbtc, currentCycle] =\n\t\tresults as ClarityValue[];\n\treturn {\n\t\tstakerInfo: stakerInfo as ClarityValue,\n\t\tbondMembership: bondMembership as ClarityValue,\n\t\tcustodiedSbtc: custodiedSbtc as ClarityValue,\n\t\tcurrentCycle: currentCycle as ClarityValue,\n\t};\n}\n\n/** Actions provided by the pox5 extension. */\nexport type Pox5Actions = {\n\tpox5: {\n\t\t// activation\n\t\tisActive: () => Promise<boolean>;\n\t\tgetActivation: () => Promise<Pox5Activation | undefined>;\n\t\tgetPoxInfo: () => Promise<Pox5Info>;\n\t\tcontractId: () => string;\n\t\t// batched state\n\t\tgetStakerState: (staker: string) => Promise<StakerState>;\n\t\t// reads\n\t\tgetStakerInfo: (staker: string) => Promise<StakerInfo>;\n\t\tgetBondMembership: (staker: string) => Promise<BondMembership>;\n\t\tgetProtocolBond: (bondIndex: IntegerType) => Promise<ProtocolBond>;\n\t\tgetBondAllowance: (\n\t\t\tbondIndex: IntegerType,\n\t\t\tstaker: string,\n\t\t) => Promise<BondAllowance>;\n\t\tgetTotalSbtcStakedForBond: (bondIndex: IntegerType) => Promise<bigint>;\n\t\tgetStakerCustodiedSbtc: (staker: string) => Promise<bigint>;\n\t\thasAnnouncedL1EarlyExit: (\n\t\t\tbondIndex: IntegerType,\n\t\t\tstaker: string,\n\t\t) => Promise<boolean>;\n\t\tgetBondL1UnlockHeight: (bondIndex: IntegerType) => Promise<bigint>;\n\t\tgetSignerInfo: (signer: string) => Promise<SignerInfo>;\n\t\tverifySignerKeyGrant: (\n\t\t\tsignerManager: string,\n\t\t\tsignerKey: Uint8Array | string,\n\t\t) => Promise<boolean>;\n\t\tgetCurrentRewardCycle: () => Promise<bigint>;\n\t\tgetFirstRewardCycle: () => Promise<bigint>;\n\t\tgetEarned: (params: {\n\t\t\tsigner: string;\n\t\t\trewardCycle: IntegerType;\n\t\t\tbondIndex?: IntegerType;\n\t\t}) => Promise<bigint>;\n\t\tgetEarnedStakerRewards: (params: {\n\t\t\tsigner: string;\n\t\t\trewardCycle: IntegerType;\n\t\t\tbondIndex?: IntegerType;\n\t\t\tstaker: string;\n\t\t}) => Promise<bigint>;\n\t\tgetLastRewardComputeHeight: () => Promise<bigint>;\n\t\tgetTotalSharesStakedForCycle: (\n\t\t\trewardCycle: IntegerType,\n\t\t\tbondIndex?: IntegerType,\n\t\t) => Promise<bigint>;\n\t\t// eligibility preflights (never auto-called from wallet actions)\n\t\teligibleStake: (params: EligibleStakeParams) => Promise<EligibilityResult>;\n\t\teligibleRegisterForBond: (\n\t\t\tparams: EligibleRegisterForBondParams,\n\t\t) => Promise<EligibilityResult>;\n\t\teligibleUnstake: (\n\t\t\tparams: EligibleUnstakeParams,\n\t\t) => Promise<EligibilityResult>;\n\t\teligibleUnstakeSbtc: (\n\t\t\tparams: EligibleUnstakeSbtcParams,\n\t\t) => Promise<EligibilityResult>;\n\t\teligibleClaimRewards: (\n\t\t\tparams: EligibleClaimRewardsParams,\n\t\t) => Promise<EligibilityResult>;\n\t\teligibleGrantSignerKey: (\n\t\t\tparams: EligibleGrantSignerKeyParams,\n\t\t) => Promise<EligibilityResult>;\n\t\teligibleSetBondAdmin: (\n\t\t\tparams: EligibleAdminParams,\n\t\t) => Promise<EligibilityResult>;\n\t\teligiblePauseRewards: (\n\t\t\tparams: EligibleAdminParams,\n\t\t) => Promise<EligibilityResult>;\n\t\t// wallet actions (txids; pair with waitForTransactionReceipt)\n\t\tsetupBond: (params: SetupBondParams) => Promise<string>;\n\t\tregisterForBond: (params: RegisterForBondParams) => Promise<string>;\n\t\tupdateBondRegistration: (\n\t\t\tparams: UpdateBondRegistrationParams,\n\t\t) => Promise<string>;\n\t\tstake: (params: StakeParams) => Promise<string>;\n\t\tstakeUpdate: (params: StakeUpdateParams) => Promise<string>;\n\t\tunstake: (params: UnstakeParams) => Promise<string>;\n\t\tunstakeSbtc: (params: UnstakeSbtcParams) => Promise<string>;\n\t\tannounceL1EarlyExit: (params: AnnounceL1EarlyExitParams) => Promise<string>;\n\t\tcalculateRewards: (params: CalculateRewardsParams) => Promise<string>;\n\t\tclaimRewards: (params: ClaimRewardsParams) => Promise<string>;\n\t\tclaimStakerRewardsForSigner: (\n\t\t\tparams: ClaimStakerRewardsForSignerParams,\n\t\t) => Promise<string>;\n\t\tgrantSignerKey: (params: GrantSignerKeyParams) => Promise<string>;\n\t\trevokeSignerGrant: (params: RevokeSignerGrantParams) => Promise<string>;\n\t\tsetBondAdmin: (params: SetBondAdminParams) => Promise<string>;\n\t\tsetPauseAdmin: (params: SetPauseAdminParams) => Promise<string>;\n\t\tpauseRewards: (params?: PauseRewardsParams) => Promise<string>;\n\t\tbuildLockProof: (opts: {\n\t\t\tsource: ProofSource;\n\t\t\ttxid: string;\n\t\t\tlockScript: Uint8Array;\n\t\t\tunlockBurnHeight: IntegerType;\n\t\t\tvout?: number;\n\t\t}) => Promise<L1LockupOutput>;\n\t};\n};\n\n/**\n * PoX-5 extension for the Stacks client.\n *\n * @example\n * const client = createWalletClient({ chain: mainnet, transport: http(), account })\n *   .extend(pox5());\n *\n * if (await client.pox5.isActive()) {\n *   const txid = await client.pox5.stake({\n *     signerManager: \"SP…​.signer-mgr\",\n *     amountUstx: 100_000_000_000n,\n *     numCycles: 12,\n *     startBurnHeight: 960_231,\n *     fee: \"low\",\n *   });\n *   await client.waitForTransactionReceipt({ txid });\n * }\n */\nexport function pox5(): (client: Client) => Pox5Actions {\n\treturn (client: Client) => ({\n\t\tpox5: {\n\t\t\tisActive: () => isPox5Active(client),\n\t\t\tgetActivation: () => getPox5Activation(client),\n\t\t\tgetPoxInfo: () => getPoxInfo(client),\n\t\t\tcontractId: () => pox5ContractId(client),\n\t\t\tgetStakerState: (staker) => getStakerState(client, staker),\n\t\t\tgetStakerInfo: (staker) => getStakerInfo(client, staker),\n\t\t\tgetBondMembership: (staker) => getBondMembership(client, staker),\n\t\t\tgetProtocolBond: (bondIndex) => getProtocolBond(client, bondIndex),\n\t\t\tgetBondAllowance: (bondIndex, staker) =>\n\t\t\t\tgetBondAllowance(client, bondIndex, staker),\n\t\t\tgetTotalSbtcStakedForBond: (bondIndex) =>\n\t\t\t\tgetTotalSbtcStakedForBond(client, bondIndex),\n\t\t\tgetStakerCustodiedSbtc: (staker) =>\n\t\t\t\tgetStakerCustodiedSbtc(client, staker),\n\t\t\thasAnnouncedL1EarlyExit: (bondIndex, staker) =>\n\t\t\t\thasAnnouncedL1EarlyExit(client, bondIndex, staker),\n\t\t\tgetBondL1UnlockHeight: (bondIndex) =>\n\t\t\t\tgetBondL1UnlockHeight(client, bondIndex),\n\t\t\tgetSignerInfo: (signer) => getSignerInfo(client, signer),\n\t\t\tverifySignerKeyGrant: (signerManager, signerKey) =>\n\t\t\t\tverifySignerKeyGrantOnChain(client, signerManager, signerKey),\n\t\t\tgetCurrentRewardCycle: () => getCurrentRewardCycle(client),\n\t\t\tgetFirstRewardCycle: () => getFirstPox5RewardCycle(client),\n\t\t\tgetEarned: (params) => getEarned(client, params),\n\t\t\tgetEarnedStakerRewards: (params) =>\n\t\t\t\tgetEarnedStakerRewards(client, params),\n\t\t\tgetLastRewardComputeHeight: () => getLastRewardComputeHeight(client),\n\t\t\tgetTotalSharesStakedForCycle: (rewardCycle, bondIndex) =>\n\t\t\t\tgetTotalSharesStakedForCycle(client, rewardCycle, bondIndex),\n\t\t\teligibleStake: (params) => eligibleStake(client, params),\n\t\t\teligibleRegisterForBond: (params) =>\n\t\t\t\teligibleRegisterForBond(client, params),\n\t\t\teligibleUnstake: (params) => eligibleUnstake(client, params),\n\t\t\teligibleUnstakeSbtc: (params) => eligibleUnstakeSbtc(client, params),\n\t\t\teligibleClaimRewards: (params) => eligibleClaimRewards(client, params),\n\t\t\teligibleGrantSignerKey: (params) =>\n\t\t\t\teligibleGrantSignerKey(client, params),\n\t\t\teligibleSetBondAdmin: (params) => eligibleSetBondAdmin(client, params),\n\t\t\teligiblePauseRewards: (params) => eligiblePauseRewards(client, params),\n\t\t\tsetupBond: (params) => setupBond(client, params),\n\t\t\tregisterForBond: (params) => registerForBond(client, params),\n\t\t\tupdateBondRegistration: (params) =>\n\t\t\t\tupdateBondRegistration(client, params),\n\t\t\tstake: (params) => stake(client, params),\n\t\t\tstakeUpdate: (params) => stakeUpdate(client, params),\n\t\t\tunstake: (params) => unstake(client, params),\n\t\t\tunstakeSbtc: (params) => unstakeSbtc(client, params),\n\t\t\tannounceL1EarlyExit: (params) => announceL1EarlyExit(client, params),\n\t\t\tcalculateRewards: (params) => calculateRewards(client, params),\n\t\t\tclaimRewards: (params) => claimRewards(client, params),\n\t\t\tclaimStakerRewardsForSigner: (params) =>\n\t\t\t\tclaimStakerRewardsForSigner(client, params),\n\t\t\tgrantSignerKey: (params) => grantSignerKey(client, params),\n\t\t\trevokeSignerGrant: (params) => revokeSignerGrant(client, params),\n\t\t\tsetBondAdmin: (params) => setBondAdmin(client, params),\n\t\t\tsetPauseAdmin: (params) => setPauseAdmin(client, params),\n\t\t\tpauseRewards: (params) => pauseRewards(client, params),\n\t\t\tbuildLockProof: (opts) => buildPox5LockProof(opts),\n\t\t},\n\t});\n}\n",
    "import { base58, bech32, bech32m } from \"@scure/base\";\nimport {\n\tBITCOIN_NETWORK_PARAMS,\n\tbase58CheckEncode,\n} from \"../bitcoin/address.ts\";\nimport type { BitcoinNetwork } from \"../bitcoin/constants.ts\";\nimport { doubleSha256 } from \"../bitcoin/serialize.ts\";\nimport { POX_ADDRESS_VERSION } from \"../pox/constants.ts\";\n\n/**\n * SIP-005 PoX `pox-addr` tuple, decoded from a Bitcoin address. `version` is\n * the PoX byte (`POX_ADDRESS_VERSION`), not a Bitcoin network version\n * (`p2sh` is 0x01 here, 0x05 on mainnet Bitcoin). `hashbytes` is the 20- or\n * 32-byte payload — unpadded, matching `check-pox-addr-hashbytes`.\n */\nexport type BtcAddressRepr = {\n\tversion: number;\n\thashbytes: Uint8Array;\n};\n\nfunction expectedHashLen(version: number): number {\n\tif (!Number.isInteger(version) || version < 0x00 || version > 0x06) {\n\t\tthrow new Error(`Unknown PoX address version: 0x${version.toString(16)}`);\n\t}\n\treturn version <= 0x04 ? 20 : 32;\n}\n\n/** Strip frozen-pox 32-byte padding; reject a length that doesn't match the version. */\nexport function canonicalizeBtcAddress(repr: BtcAddressRepr): BtcAddressRepr {\n\tconst expected = expectedHashLen(repr.version);\n\tconst { hashbytes } = repr;\n\tif (hashbytes.length === expected)\n\t\treturn { version: repr.version, hashbytes };\n\tif (\n\t\texpected === 20 &&\n\t\thashbytes.length === 32 &&\n\t\thashbytes.slice(20).every((b) => b === 0)\n\t) {\n\t\treturn { version: repr.version, hashbytes: hashbytes.slice(0, 20) };\n\t}\n\tthrow new Error(\n\t\t`Invalid hashbytes length for PoX version 0x${repr.version.toString(16)}: ${hashbytes.length}`,\n\t);\n}\n\n/**\n * Parse a Bitcoin address string into a PoX address tuple.\n * Supports P2PKH, P2SH, P2WPKH, P2WSH, P2TR (mainnet, testnet, regtest).\n */\nexport function parseBtcAddress(address: string): BtcAddressRepr {\n\tif (\n\t\taddress.startsWith(\"bc1\") ||\n\t\taddress.startsWith(\"tb1\") ||\n\t\taddress.startsWith(\"bcrt1\")\n\t) {\n\t\treturn parseSegwitAddress(address);\n\t}\n\treturn parseLegacyAddress(address);\n}\n\nfunction parseSegwitAddress(address: string): BtcAddressRepr {\n\tlet decoded: { prefix: string; words: number[] };\n\ttry {\n\t\tdecoded = bech32.decode(address as `${string}1${string}`);\n\t} catch {\n\t\tdecoded = bech32m.decode(address as `${string}1${string}`);\n\t}\n\n\tconst witnessVersion = decoded.words[0];\n\tif (witnessVersion === undefined) {\n\t\tthrow new Error(\"Invalid segwit address: missing witness version\");\n\t}\n\tconst data = bech32.fromWords(decoded.words.slice(1));\n\tconst hashbytes = new Uint8Array(data);\n\n\tlet version: number;\n\tif (witnessVersion === 0) {\n\t\tif (hashbytes.length === 20) {\n\t\t\tversion = POX_ADDRESS_VERSION.p2wpkh;\n\t\t} else if (hashbytes.length === 32) {\n\t\t\tversion = POX_ADDRESS_VERSION.p2wsh;\n\t\t} else {\n\t\t\tthrow new Error(`Invalid witness v0 program length: ${hashbytes.length}`);\n\t\t}\n\t} else if (witnessVersion === 1) {\n\t\tif (hashbytes.length !== 32) {\n\t\t\tthrow new Error(`Invalid witness v1 program length: ${hashbytes.length}`);\n\t\t}\n\t\tversion = POX_ADDRESS_VERSION.p2tr;\n\t} else {\n\t\tthrow new Error(`Unsupported witness version: ${witnessVersion}`);\n\t}\n\n\treturn { version, hashbytes };\n}\n\nfunction parseLegacyAddress(address: string): BtcAddressRepr {\n\tconst decoded = base58.decode(address);\n\n\tif (decoded.length !== 25) {\n\t\tthrow new Error(`Invalid legacy address length: ${decoded.length}`);\n\t}\n\n\tconst versionByte = decoded[0];\n\tif (versionByte === undefined) {\n\t\tthrow new Error(\"Invalid legacy address: missing version byte\");\n\t}\n\tconst payload = decoded.slice(0, 21);\n\tconst checksum = decoded.slice(21);\n\tconst expected = doubleSha256(payload).slice(0, 4);\n\tif (checksum.length !== 4 || expected.some((b, i) => b !== checksum[i])) {\n\t\tthrow new Error(\"Invalid legacy address checksum\");\n\t}\n\tconst hashbytes = decoded.slice(1, 21);\n\n\tlet version: number;\n\tif (versionByte === 0x00 || versionByte === 0x6f) {\n\t\tversion = POX_ADDRESS_VERSION.p2pkh;\n\t} else if (versionByte === 0x05 || versionByte === 0xc4) {\n\t\tversion = POX_ADDRESS_VERSION.p2sh;\n\t} else {\n\t\tthrow new Error(\n\t\t\t`Unknown legacy address version byte: 0x${versionByte.toString(16)}`,\n\t\t);\n\t}\n\n\treturn { version, hashbytes };\n}\n\nexport function stringifyBtcAddress(\n\trepr: BtcAddressRepr,\n\tnetwork: BitcoinNetwork,\n): string {\n\tconst { version, hashbytes } = canonicalizeBtcAddress(repr);\n\tconst params = BITCOIN_NETWORK_PARAMS[network];\n\tswitch (version) {\n\t\tcase POX_ADDRESS_VERSION.p2pkh:\n\t\t\treturn base58CheckEncode(params.p2pkh, hashbytes);\n\t\tcase POX_ADDRESS_VERSION.p2sh:\n\t\tcase POX_ADDRESS_VERSION.p2sh_p2wpkh:\n\t\tcase POX_ADDRESS_VERSION.p2sh_p2wsh:\n\t\t\treturn base58CheckEncode(params.p2sh, hashbytes);\n\t\tcase POX_ADDRESS_VERSION.p2wpkh:\n\t\tcase POX_ADDRESS_VERSION.p2wsh:\n\t\t\treturn bech32.encode(params.hrp, [0, ...bech32.toWords(hashbytes)]);\n\t\tcase POX_ADDRESS_VERSION.p2tr:\n\t\t\treturn bech32m.encode(params.hrp, [1, ...bech32m.toWords(hashbytes)]);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown PoX address version: 0x${version.toString(16)}`);\n\t}\n}\n\nexport const BtcAddress: {\n\tparse: typeof parseBtcAddress;\n\tstringify: typeof stringifyBtcAddress;\n} = {\n\tparse: parseBtcAddress,\n\tstringify: stringifyBtcAddress,\n};\n",
    "export const POX_CONTRACTS = {\n\tmainnet: {\n\t\taddress: \"SP000000000000000000002Q6VF78\",\n\t\tname: \"pox-4\",\n\t},\n\ttestnet: {\n\t\taddress: \"ST000000000000000000002AMW42H\",\n\t\tname: \"pox-4\",\n\t},\n} as const;\n\nexport const MIN_LOCK_PERIOD = 1;\nexport const MAX_LOCK_PERIOD = 12;\n\n/** PoX address version bytes (maps to Bitcoin address types) */\nexport const POX_ADDRESS_VERSION = {\n\t/** P2PKH - legacy addresses starting with \"1\" */\n\tp2pkh: 0x00,\n\t/** P2SH - script hash addresses starting with \"3\" */\n\tp2sh: 0x01,\n\t/** P2SH-P2WPKH - nested segwit */\n\tp2sh_p2wpkh: 0x02,\n\t/** P2SH-P2WSH - nested segwit script */\n\tp2sh_p2wsh: 0x03,\n\t/** P2WPKH - native segwit \"bc1q\" (20-byte hash) */\n\tp2wpkh: 0x04,\n\t/** P2WSH - native segwit \"bc1q\" (32-byte hash) */\n\tp2wsh: 0x05,\n\t/** P2TR - taproot \"bc1p\" (32-byte key) */\n\tp2tr: 0x06,\n} as const;\n",
    "import { deserializeCVBytes } from \"../clarity/deserialize.ts\";\nimport { serializeCVBytes } from \"../clarity/serialize.ts\";\nimport { Cl } from \"../clarity/values.ts\";\nimport { type IntegerType, hexToBytes } from \"../utils/encoding.ts\";\nimport {\n\ttype BtcAddressRepr,\n\tcanonicalizeBtcAddress,\n\tparseBtcAddress,\n} from \"./btcAddress.ts\";\n\nexport function buildSignerCalldata(opts: {\n\tpoxAddress: string | BtcAddressRepr;\n\tmaxFeeSats: IntegerType;\n}): Uint8Array {\n\tconst repr = canonicalizeBtcAddress(\n\t\ttypeof opts.poxAddress === \"string\"\n\t\t\t? parseBtcAddress(opts.poxAddress)\n\t\t\t: opts.poxAddress,\n\t);\n\treturn serializeCVBytes(\n\t\tCl.tuple({\n\t\t\t\"pox-addr\": Cl.tuple({\n\t\t\t\tversion: Cl.buffer(Uint8Array.of(repr.version)),\n\t\t\t\thashbytes: Cl.buffer(repr.hashbytes),\n\t\t\t}),\n\t\t\t\"max-fee\": Cl.uint(opts.maxFeeSats),\n\t\t}),\n\t);\n}\n\nexport function parseSignerCalldata(calldata: Uint8Array | string): {\n\tpoxAddress: BtcAddressRepr;\n\tmaxFeeSats: bigint;\n} {\n\tconst cv = deserializeCVBytes(calldata);\n\tif (cv.type !== \"tuple\") {\n\t\tthrow new Error(\"signer calldata is not a Clarity tuple\");\n\t}\n\tconst poxAddr = cv.value[\"pox-addr\"];\n\tconst maxFee = cv.value[\"max-fee\"];\n\tif (!poxAddr || poxAddr.type !== \"tuple\") {\n\t\tthrow new Error(\"signer calldata missing pox-addr tuple\");\n\t}\n\tif (!maxFee || maxFee.type !== \"uint\") {\n\t\tthrow new Error(\"signer calldata missing max-fee uint\");\n\t}\n\tconst versionCv = poxAddr.value.version;\n\tconst hashCv = poxAddr.value.hashbytes;\n\tif (!versionCv || versionCv.type !== \"buffer\") {\n\t\tthrow new Error(\"signer calldata pox-addr missing version buffer\");\n\t}\n\tif (!hashCv || hashCv.type !== \"buffer\") {\n\t\tthrow new Error(\"signer calldata pox-addr missing hashbytes buffer\");\n\t}\n\tconst versionBytes = hexToBytes(versionCv.value);\n\tif (versionBytes.length !== 1) {\n\t\tthrow new Error(\n\t\t\t`signer calldata version must be buff 1, got ${versionBytes.length}`,\n\t\t);\n\t}\n\tconst version = versionBytes[0];\n\tif (version === undefined) {\n\t\tthrow new Error(\"signer calldata version buffer is empty\");\n\t}\n\treturn {\n\t\tpoxAddress: canonicalizeBtcAddress({\n\t\t\tversion,\n\t\t\thashbytes: hexToBytes(hashCv.value),\n\t\t}),\n\t\tmaxFeeSats: maxFee.value,\n\t};\n}\n"
  ],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,IAAM,yCAAyC;;;ACN/C,IAAM,qBAAqB;AAG3B,IAAM,2BAAmC,iCAAiC;AAY1E,IAAM,oBAAoB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAUO,IAAM,sCACZ;AASM,IAAM,+BAA+B;AAGrC,IAAM,qBAAqB;AAG3B,IAAM,kBAAkB;AAGxB,IAAM,iBAAiB;AAGvB,IAAM,qBAAqB;AAAA,EACjC,MAAM;AAAA,EACN,SAAS;AACV;AAMO,IAAM,mBAAmB;AAOzB,IAAM,6BAA6B;;;AC5C1C,eAAsB,UAAU,CAAC,QAAmC;AAAA,EACnE,MAAM,OAAQ,MAAM,OAAO,QAAQ,WAAW;AAAA,IAC7C,QAAQ;AAAA,EACT,CAAC;AAAA,EACD,OAAO;AAAA,IACN,YAAY,KAAK;AAAA,IACjB,6BAA6B,KAAK;AAAA,IAClC,2BAA2B,KAAK;AAAA,IAChC,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