{
  "version": 3,
  "sources": ["../src/utils/constants.ts", "../src/utils/address.ts"],
  "sourcesContent": [
    "// 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 { 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"
  ],
  "mappings": ";AACO,IAAM,YAAoB,MAAM,QAAQ;AACxC,IAAM,YAAoB,MAAM,QAAQ;AACxC,IAAM,WAAmB,EAAE,MAAM;AAGjC,IAAM,iBAAiB;AAAA,EAC7B,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,iBAAiB;AAClB;AAKO,IAAM,eAAe;AAErB,IAAM,uBAAuB;AAG7B,IAAM,mBAAmB;;;ACXzB,SAAS,kBAAkB,CACjC,WACA,UAAiC,WACxB;AAAA,EACT,MAAM,QACL,OAAO,cAAc,WAClB,WAAW,UAAU,SAAS,CAAC,IAC/B;AAAA,EACJ,MAAM,UACL,YAAY,YACT,eAAe,mBACf,eAAe;AAAA,EACnB,OAAO,WAAW,SAAS,WAAW,QAAQ,KAAK,CAAC,CAAC;AAAA;AAM/C,IAAM,sBAA8B;AAEpC,SAAS,qBAAqB,CAAC,SAA0B;AAAA,EAC/D,IAAI;AAAA,IACH,iBAAiB,OAAO;AAAA,IACxB,OAAO;AAAA,IACN,MAAM;AAAA,IACP,OAAO;AAAA;AAAA;AAKF,IAAM,iBACZ;AAMM,SAAS,cAAc,CAC7B,OACoD;AAAA,EACpD,MAAM,QAAQ,MAAM,MAAM,GAAG;AAAA,EAC7B,IAAI,MAAM,SAAS;AAAA,IAAG,OAAO;AAAA,EAC7B,OAAO,SAAS,gBAAgB;AAAA,EAChC,IAAI,CAAC,sBAAsB,OAAO;AAAA,IAAG,OAAO;AAAA,EAC5C,IAAI,iBAAiB;AAAA,IAAW,OAAO,EAAE,QAAQ;AAAA,EACjD,IAAI,CAAC,oBAAoB,K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