@babylonlabs-io/ts-sdk 0.77.0 → 0.79.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/{BTCVaultRegistry.abi-CJwWI2EO.js → BTCVaultRegistry.abi-B0x9_Bza.js} +321 -2
  2. package/dist/BTCVaultRegistry.abi-B0x9_Bza.js.map +1 -0
  3. package/dist/BTCVaultRegistry.abi-BQ5tFNSu.cjs +2 -0
  4. package/dist/BTCVaultRegistry.abi-BQ5tFNSu.cjs.map +1 -0
  5. package/dist/{BTCVaultRegistryKeyEpochs.abi-D8cIbMtH.js → BTCVaultRegistryKeyEpochs.abi-BWoxwPQv.js} +57 -20
  6. package/dist/BTCVaultRegistryKeyEpochs.abi-BWoxwPQv.js.map +1 -0
  7. package/dist/BTCVaultRegistryKeyEpochs.abi-DCJnzKer.cjs +2 -0
  8. package/dist/BTCVaultRegistryKeyEpochs.abi-DCJnzKer.cjs.map +1 -0
  9. package/dist/{PeginManager-DNimKlmw.js → PeginManager-BXlh3ar0.js} +289 -348
  10. package/dist/PeginManager-BXlh3ar0.js.map +1 -0
  11. package/dist/PeginManager-BuVSknB0.cjs +2 -0
  12. package/dist/PeginManager-BuVSknB0.cjs.map +1 -0
  13. package/dist/ProtocolParams.abi-Db2USqQm.cjs +2 -0
  14. package/dist/ProtocolParams.abi-Db2USqQm.cjs.map +1 -0
  15. package/dist/ProtocolParams.abi-q0AidvYX.js +526 -0
  16. package/dist/ProtocolParams.abi-q0AidvYX.js.map +1 -0
  17. package/dist/buildAndBroadcastReclaim-N9dXH9dm.cjs +2 -0
  18. package/dist/buildAndBroadcastReclaim-N9dXH9dm.cjs.map +1 -0
  19. package/dist/{buildAndBroadcastReclaim-DCGcupg7.js → buildAndBroadcastReclaim-O6z9kvc4.js} +502 -468
  20. package/dist/buildAndBroadcastReclaim-O6z9kvc4.js.map +1 -0
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +229 -222
  23. package/dist/pegin-registration-client-CZgcU2_0.cjs +2 -0
  24. package/dist/pegin-registration-client-CZgcU2_0.cjs.map +1 -0
  25. package/dist/{pegin-registration-client-CXK3B_D1.js → pegin-registration-client-pcczkzMg.js} +344 -240
  26. package/dist/pegin-registration-client-pcczkzMg.js.map +1 -0
  27. package/dist/tbv/core/clients/eth/index.cjs +1 -1
  28. package/dist/tbv/core/clients/eth/index.d.ts +1 -0
  29. package/dist/tbv/core/clients/eth/index.d.ts.map +1 -1
  30. package/dist/tbv/core/clients/eth/index.js +14 -12
  31. package/dist/tbv/core/clients/eth/pegin-registration-client.d.ts +17 -0
  32. package/dist/tbv/core/clients/eth/pegin-registration-client.d.ts.map +1 -1
  33. package/dist/tbv/core/clients/eth/registration-logs-error.d.ts +20 -0
  34. package/dist/tbv/core/clients/eth/registration-logs-error.d.ts.map +1 -0
  35. package/dist/tbv/core/clients/eth/signer-set-reader.d.ts +2 -0
  36. package/dist/tbv/core/clients/eth/signer-set-reader.d.ts.map +1 -1
  37. package/dist/tbv/core/clients/eth/types.d.ts +40 -0
  38. package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
  39. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +31 -0
  40. package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
  41. package/dist/tbv/core/clients/index.cjs +1 -1
  42. package/dist/tbv/core/clients/index.js +41 -39
  43. package/dist/tbv/core/contracts/__tests__/peginFingerprintAbi.test.d.ts +24 -0
  44. package/dist/tbv/core/contracts/__tests__/peginFingerprintAbi.test.d.ts.map +1 -0
  45. package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts +14 -0
  46. package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts.map +1 -1
  47. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +265 -1
  48. package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
  49. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts +10 -0
  50. package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts.map +1 -1
  51. package/dist/tbv/core/contracts/errors.d.ts +41 -4
  52. package/dist/tbv/core/contracts/errors.d.ts.map +1 -1
  53. package/dist/tbv/core/contracts/index.cjs +1 -1
  54. package/dist/tbv/core/contracts/index.cjs.map +1 -1
  55. package/dist/tbv/core/contracts/index.d.ts +1 -1
  56. package/dist/tbv/core/contracts/index.d.ts.map +1 -1
  57. package/dist/tbv/core/contracts/index.js +15 -492
  58. package/dist/tbv/core/contracts/index.js.map +1 -1
  59. package/dist/tbv/core/deposit-terms/commissionCeiling.d.ts +3 -2
  60. package/dist/tbv/core/deposit-terms/commissionCeiling.d.ts.map +1 -1
  61. package/dist/tbv/core/index.cjs +1 -1
  62. package/dist/tbv/core/index.js +224 -217
  63. package/dist/tbv/core/managers/PeginManager.d.ts +13 -25
  64. package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
  65. package/dist/tbv/core/managers/index.cjs +1 -1
  66. package/dist/tbv/core/managers/index.d.ts +2 -2
  67. package/dist/tbv/core/managers/index.d.ts.map +1 -1
  68. package/dist/tbv/core/managers/index.js +4 -5
  69. package/dist/tbv/core/pegin-fingerprint/index.d.ts +1 -1
  70. package/dist/tbv/core/pegin-fingerprint/index.d.ts.map +1 -1
  71. package/dist/tbv/core/pegin-fingerprint/peginFingerprint.d.ts +10 -0
  72. package/dist/tbv/core/pegin-fingerprint/peginFingerprint.d.ts.map +1 -1
  73. package/dist/tbv/core/services/deposit/index.d.ts +1 -1
  74. package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
  75. package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts +50 -3
  76. package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts.map +1 -1
  77. package/dist/tbv/core/services/index.cjs +1 -1
  78. package/dist/tbv/core/services/index.js +56 -54
  79. package/dist/tbv/core/services/participants/__tests__/fixtures/rotation.d.ts.map +1 -1
  80. package/dist/tbv/index.cjs +1 -1
  81. package/dist/tbv/index.js +224 -217
  82. package/dist/{toRefundInputs-BNSXIymn.js → toRefundInputs-9inv4Ai4.js} +96 -92
  83. package/dist/toRefundInputs-9inv4Ai4.js.map +1 -0
  84. package/dist/toRefundInputs-DitGWAnz.cjs +2 -0
  85. package/dist/toRefundInputs-DitGWAnz.cjs.map +1 -0
  86. package/dist/{types-C5DyrC8F.js → types-B9YhlXe8.js} +109 -83
  87. package/dist/types-B9YhlXe8.js.map +1 -0
  88. package/dist/types-C1tpDycc.cjs +2 -0
  89. package/dist/types-C1tpDycc.cjs.map +1 -0
  90. package/package.json +3 -3
  91. package/dist/BTCVaultRegistry.abi-CJwWI2EO.js.map +0 -1
  92. package/dist/BTCVaultRegistry.abi-z7d_eP22.cjs +0 -2
  93. package/dist/BTCVaultRegistry.abi-z7d_eP22.cjs.map +0 -1
  94. package/dist/BTCVaultRegistryKeyEpochs.abi-CrQiTLfA.cjs +0 -2
  95. package/dist/BTCVaultRegistryKeyEpochs.abi-CrQiTLfA.cjs.map +0 -1
  96. package/dist/BTCVaultRegistryKeyEpochs.abi-D8cIbMtH.js.map +0 -1
  97. package/dist/PeginManager-DEByBX5R.cjs +0 -2
  98. package/dist/PeginManager-DEByBX5R.cjs.map +0 -1
  99. package/dist/PeginManager-DNimKlmw.js.map +0 -1
  100. package/dist/buildAndBroadcastReclaim-Cqc6Jiqk.cjs +0 -2
  101. package/dist/buildAndBroadcastReclaim-Cqc6Jiqk.cjs.map +0 -1
  102. package/dist/buildAndBroadcastReclaim-DCGcupg7.js.map +0 -1
  103. package/dist/pegin-registration-client-CXK3B_D1.js.map +0 -1
  104. package/dist/pegin-registration-client-DLsMNm8Z.cjs +0 -2
  105. package/dist/pegin-registration-client-DLsMNm8Z.cjs.map +0 -1
  106. package/dist/toRefundInputs-BNSXIymn.js.map +0 -1
  107. package/dist/toRefundInputs-meTyor7r.cjs +0 -2
  108. package/dist/toRefundInputs-meTyor7r.cjs.map +0 -1
  109. package/dist/types-BzSOthHH.cjs +0 -2
  110. package/dist/types-BzSOthHH.cjs.map +0 -1
  111. package/dist/types-C5DyrC8F.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-C1tpDycc.cjs","sources":["../src/tbv/core/clients/eth/contract-address-resolver.ts","../src/tbv/core/clients/eth/operation-key-reader.ts","../src/tbv/core/clients/eth/protocol-params-reader.ts","../src/tbv/core/clients/eth/signer-set-reader.ts","../src/tbv/core/clients/eth/types.ts"],"sourcesContent":["/**\n * Contract Address Resolver\n *\n * Resolves ProtocolParams and ApplicationRegistry contract addresses\n * from the BTCVaultRegistry contract. These addresses are needed to\n * construct the SDK's contract readers.\n *\n * @module clients/eth/contract-address-resolver\n */\n\nimport type { Address, PublicClient } from \"viem\";\n\nimport { BTCVaultRegistryABI } from \"../../contracts/abis/BTCVaultRegistry.abi\";\n\nexport interface ProtocolAddresses {\n /** Address of the ProtocolParams contract */\n protocolParams: Address;\n /** Address of the ApplicationRegistry contract */\n applicationRegistry: Address;\n}\n\n/**\n * Resolve ProtocolParams and ApplicationRegistry addresses from BTCVaultRegistry.\n *\n * Uses a single multicall for atomicity and efficiency.\n *\n * @param publicClient - viem PublicClient instance\n * @param btcVaultRegistryAddress - Address of the BTCVaultRegistry contract\n * @returns Resolved contract addresses\n */\nexport async function resolveProtocolAddresses(\n publicClient: PublicClient,\n btcVaultRegistryAddress: Address,\n): Promise<ProtocolAddresses> {\n const [protocolParams, applicationRegistry] = await publicClient.multicall({\n contracts: [\n {\n address: btcVaultRegistryAddress,\n abi: BTCVaultRegistryABI,\n functionName: \"protocolParams\",\n },\n {\n address: btcVaultRegistryAddress,\n abi: BTCVaultRegistryABI,\n functionName: \"applicationRegistry\",\n },\n ],\n allowFailure: false,\n });\n\n return {\n protocolParams: protocolParams as Address,\n applicationRegistry: applicationRegistry as Address,\n };\n}\n","/**\n * Concrete RFC-006 operation-key reader spanning all three registries.\n *\n * This is an optional utility — callers can use their own implementation of\n * the {@link OperationKeyReader} interface.\n */\n\nimport type { Abi, Address, Hex, PublicClient } from \"viem\";\n\nimport { ApplicationRegistryABI } from \"../../contracts/abis/ApplicationRegistry.abi\";\nimport { BTCVaultRegistryABI } from \"../../contracts/abis/BTCVaultRegistry.abi\";\nimport { ProtocolParamsABI } from \"../../contracts/abis/ProtocolParams.abi\";\nimport type {\n KeyEpochs,\n OperationKeyQuery,\n OperationKeyReader,\n RawOperationKeys,\n RawPayoutScripts,\n} from \"./types\";\n\n/** Addresses of the three registries an operation-key resolution spans. */\nexport interface OperationKeyContracts {\n btcVaultRegistry: Address;\n applicationRegistry: Address;\n protocolParams: Address;\n}\n\n/** One `multicall` entry. Loosely typed because the three ABIs differ. */\ntype Call = {\n address: Address;\n abi: Abi;\n functionName: string;\n args: readonly unknown[];\n};\n\n/**\n * Reject a multicall result that is not one-per-call.\n *\n * Every method here relies on positional alignment between calls and results,\n * so a short array does not fail — it silently hands back `undefined` for the\n * tail entries. Downstream that surfaces as a complaint about whichever\n * operator happens to occupy the missing slot, blaming a participant that is\n * perfectly fine for a read that came back incomplete. Assert the length where\n * the array arrives so the error names the real fault.\n */\nfunction assertMulticallLength(\n actual: number,\n expected: number,\n label: string,\n): void {\n if (actual !== expected) {\n throw new Error(\n `${label}: multicall returned ${actual} results for ${expected} calls, ` +\n `so the results are not roster-aligned; refusing to use them`,\n );\n }\n}\n\n/**\n * Split a flat multicall result into VP / keepers / challengers.\n *\n * Every method below builds its calls in the same order — vault provider\n * first, then keepers in roster order, then challengers in roster order — so\n * the results stay index-aligned with `query.vaultKeepers` /\n * `query.universalChallengers`. That alignment is what lets the resolver pair\n * a resolved key back to its admin address; the sorted key arrays it exposes\n * are derived from those pairs, never the other way round.\n */\nfunction partition<T>(\n results: readonly T[],\n keeperCount: number,\n): { vaultProvider: T; vaultKeepers: T[]; universalChallengers: T[] } {\n return {\n vaultProvider: results[0],\n vaultKeepers: results.slice(1, 1 + keeperCount),\n universalChallengers: results.slice(1 + keeperCount),\n };\n}\n\n/**\n * Reads RFC-006 operation keys and payout scripts.\n *\n * Usage:\n * ```ts\n * const reader = new ViemOperationKeyReader(publicClient, contracts);\n * const keys = await reader.getCurrentOperationKeys(query);\n * ```\n */\nexport class ViemOperationKeyReader implements OperationKeyReader {\n constructor(\n private publicClient: PublicClient,\n private contracts: OperationKeyContracts,\n ) {}\n\n /**\n * One multicall, `allowFailure: false`, so every key in the set is read at\n * the same block. A rotation landing between two separate `eth_call`s would\n * otherwise produce a mixed-epoch key set and a lock no counterparty agrees\n * with.\n */\n private async readAll<T>(\n calls: Call[],\n keeperCount: number,\n challengerCount: number,\n label: string,\n blockNumber?: bigint,\n ) {\n const results = (await this.publicClient.multicall({\n contracts: calls,\n allowFailure: false,\n blockNumber,\n })) as readonly T[];\n\n assertMulticallLength(\n results.length,\n 1 + keeperCount + challengerCount,\n label,\n );\n\n return partition(results, keeperCount);\n }\n\n async getCurrentOperationKeys(\n query: OperationKeyQuery,\n blockNumber?: bigint,\n ): Promise<RawOperationKeys> {\n const calls: Call[] = [\n {\n address: this.contracts.btcVaultRegistry,\n abi: BTCVaultRegistryABI as Abi,\n functionName: \"getCurrentOperationBtcKey\",\n args: [query.vaultProviderEthAddress],\n },\n ...query.vaultKeepers.map((keeper) => ({\n address: this.contracts.applicationRegistry,\n abi: ApplicationRegistryABI as Abi,\n functionName: \"getCurrentOperationBtcKey\",\n args: [query.applicationEntryPoint, keeper.ethAddress],\n })),\n ...query.universalChallengers.map((challenger) => ({\n address: this.contracts.protocolParams,\n abi: ProtocolParamsABI as Abi,\n functionName: \"getCurrentOperationBtcKey\",\n args: [challenger.ethAddress],\n })),\n ];\n\n return this.readAll<Hex>(\n calls,\n query.vaultKeepers.length,\n query.universalChallengers.length,\n \"getCurrentOperationKeys\",\n blockNumber,\n );\n }\n\n async getOperationKeysAtEpochs(\n query: OperationKeyQuery,\n epochs: KeyEpochs,\n ): Promise<RawOperationKeys> {\n const calls: Call[] = [\n // The VP takes the plain `AtEpoch` variant: it has no membership\n // version, so its genesis (the registration key at version 0) is\n // unambiguous and the contract resolves it internally.\n {\n address: this.contracts.btcVaultRegistry,\n abi: BTCVaultRegistryABI as Abi,\n functionName: \"getOperationBtcKeyAtEpoch\",\n args: [query.vaultProviderEthAddress, epochs.vpKeyEpoch],\n },\n // Keepers and challengers take `...OrGenesis` with their roster key\n // passed explicitly, because the correct genesis for them is their key\n // in *this vault's frozen membership version*. An operator dropped from\n // the current roster, or listed under a different key in an older\n // version, would otherwise resolve against the wrong genesis.\n ...query.vaultKeepers.map((keeper) => ({\n address: this.contracts.applicationRegistry,\n abi: ApplicationRegistryABI as Abi,\n functionName: \"getOperationBtcKeyAtEpochOrGenesis\",\n args: [\n query.applicationEntryPoint,\n keeper.ethAddress,\n epochs.appKeeperKeyEpoch,\n keeper.btcPubKey,\n ],\n })),\n ...query.universalChallengers.map((challenger) => ({\n address: this.contracts.protocolParams,\n abi: ProtocolParamsABI as Abi,\n functionName: \"getOperationBtcKeyAtEpochOrGenesis\",\n args: [challenger.ethAddress, epochs.ucKeyEpoch, challenger.btcPubKey],\n })),\n ];\n\n return this.readAll<Hex>(\n calls,\n query.vaultKeepers.length,\n query.universalChallengers.length,\n \"getOperationKeysAtEpochs\",\n );\n }\n\n async getPayoutScriptsAtEpochs(\n query: OperationKeyQuery,\n epochs: KeyEpochs,\n ): Promise<RawPayoutScripts> {\n // Universal challengers are never claimers, so they have no payout script\n // and no call here.\n const results = (await this.publicClient.multicall({\n contracts: [\n {\n address: this.contracts.btcVaultRegistry,\n abi: BTCVaultRegistryABI as Abi,\n functionName: \"getPayoutScriptAtEpoch\",\n args: [query.vaultProviderEthAddress, epochs.vpKeyEpoch],\n },\n ...query.vaultKeepers.map((keeper) => ({\n address: this.contracts.applicationRegistry,\n abi: ApplicationRegistryABI as Abi,\n functionName: \"getPayoutScriptAtEpoch\",\n args: [\n query.applicationEntryPoint,\n keeper.ethAddress,\n epochs.appKeeperKeyEpoch,\n ],\n })),\n ],\n allowFailure: false,\n })) as readonly Hex[];\n\n // Expected length is `1 + keepers`, with no challenger term — see the\n // comment above on why universal challengers have no call here.\n assertMulticallLength(\n results.length,\n 1 + query.vaultKeepers.length,\n \"getPayoutScriptsAtEpochs\",\n );\n\n return {\n vaultProvider: results[0],\n vaultKeepers: [...results.slice(1)],\n };\n }\n}\n","/**\n * Concrete ProtocolParams reader using viem's readContract and multicall.\n *\n * This is an optional utility — callers can use their own implementation\n * of the ProtocolParamsReader interface.\n */\n\nimport type { Abi, Address, Hex, PublicClient } from \"viem\";\n\nimport { ProtocolParamsABI } from \"../../contracts/abis/ProtocolParams.abi\";\nimport {\n assertValidOffchainParamsVersion,\n validateOffchainParams,\n validatePegInConfiguration,\n validateTBVProtocolParams,\n} from \"./protocol-params-validation\";\nimport type {\n AllOffchainParamsData,\n OnSkippedOffchainParamsVersion,\n PegInConfiguration,\n ProtocolParamsReader,\n TBVProtocolParams,\n VersionedOffchainParams,\n} from \"./types\";\n\n/**\n * Maximum value for a Solidity uint16.\n * PeginLogic.sol casts timelockAssert to uint16, so values above this are invalid.\n */\nconst UINT16_MAX = 65535;\n\n\n/**\n * Raw shape viem returns for VersionedOffchainParams struct.\n * viem resolves ABI struct outputs to named objects (not tuples).\n */\ninterface RawOffchainParams {\n timelockAssert: bigint;\n timelockChallengeAssert: bigint;\n securityCouncilKeys: readonly Hex[];\n councilQuorum: number;\n feeRate: bigint;\n babeTotalInstances: number;\n babeInstancesToFinalize: number;\n minVpCommissionBps: number;\n tRefund: number;\n tStale: number;\n minPeginFeeRate: bigint;\n proverCircuitVersion: number;\n minPrepeginDepth: number;\n}\n\n/** Raw shape viem returns for TBVProtocolParams struct. */\ninterface RawTBVParams {\n minimumPegInAmount: bigint;\n maxPegInAmount: bigint;\n pegInAckTimeout: bigint;\n pegInActivationTimeout: bigint;\n maxHtlcOutputCount: number;\n expiredPegInGraceBlocks: bigint;\n}\n\n/** Map viem struct result to VersionedOffchainParams. */\nfunction mapOffchainParams(result: RawOffchainParams): VersionedOffchainParams {\n return {\n timelockAssert: result.timelockAssert,\n timelockChallengeAssert: result.timelockChallengeAssert,\n securityCouncilKeys: [...result.securityCouncilKeys],\n councilQuorum: result.councilQuorum,\n feeRate: result.feeRate,\n babeTotalInstances: result.babeTotalInstances,\n babeInstancesToFinalize: result.babeInstancesToFinalize,\n minVpCommissionBps: result.minVpCommissionBps,\n tRefund: result.tRefund,\n tStale: result.tStale,\n minPeginFeeRate: result.minPeginFeeRate,\n proverCircuitVersion: result.proverCircuitVersion,\n minPrepeginDepth: result.minPrepeginDepth,\n };\n}\n\n/** Map viem struct result to TBVProtocolParams. */\nfunction mapTBVParams(result: RawTBVParams): TBVProtocolParams {\n return {\n minimumPegInAmount: result.minimumPegInAmount,\n maxPegInAmount: result.maxPegInAmount,\n pegInAckTimeout: result.pegInAckTimeout,\n pegInActivationTimeout: result.pegInActivationTimeout,\n maxHtlcOutputCount: result.maxHtlcOutputCount,\n expiredPegInGraceBlocks: result.expiredPegInGraceBlocks,\n };\n}\n\n/**\n * Derive timelockPegin from timelockAssert.\n *\n * Matches PeginLogic.sol: `uint16(timelockAssert)`.\n * The contract validates `timelockAssert <= type(uint16).max` on write,\n * but we enforce the same bound here to reject invalid values early\n * rather than silently truncating.\n *\n * @throws if timelockAssert exceeds uint16 max (65535)\n */\nfunction deriveTimelockPegin(timelockAssert: bigint): number {\n if (timelockAssert > BigInt(UINT16_MAX)) {\n throw new Error(\n `timelockAssert value ${timelockAssert} exceeds uint16 max (${UINT16_MAX})`,\n );\n }\n return Number(timelockAssert);\n}\n\n/**\n * Concrete protocol params reader using viem.\n *\n * Every read method runs the matching validator from\n * `protocol-params-validation` before returning, so callers don't have to\n * remember to validate.\n *\n * Usage:\n * ```ts\n * const reader = new ViemProtocolParamsReader(publicClient, protocolParamsAddress);\n * const config = await reader.getPegInConfiguration();\n * ```\n */\nexport class ViemProtocolParamsReader implements ProtocolParamsReader {\n constructor(\n private publicClient: PublicClient,\n private contractAddress: Address,\n ) {}\n\n async getTBVProtocolParams(): Promise<TBVProtocolParams> {\n const result = (await this.publicClient.readContract({\n address: this.contractAddress,\n abi: ProtocolParamsABI,\n functionName: \"getTBVProtocolParams\",\n })) as RawTBVParams;\n\n const params = mapTBVParams(result);\n validateTBVProtocolParams(params);\n return params;\n }\n\n async getLatestOffchainParams(): Promise<VersionedOffchainParams> {\n const result = (await this.publicClient.readContract({\n address: this.contractAddress,\n abi: ProtocolParamsABI,\n functionName: \"getLatestOffchainParams\",\n })) as RawOffchainParams;\n\n const params = mapOffchainParams(result);\n validateOffchainParams(params);\n return params;\n }\n\n async getOffchainParamsByVersion(\n version: number,\n ): Promise<VersionedOffchainParams> {\n const result = (await this.publicClient.readContract({\n address: this.contractAddress,\n abi: ProtocolParamsABI,\n functionName: \"getOffchainParamsByVersion\",\n args: [version],\n })) as RawOffchainParams;\n\n const params = mapOffchainParams(result);\n validateOffchainParams(params);\n return params;\n }\n\n async getLatestOffchainParamsVersion(): Promise<number> {\n const raw = await this.publicClient.readContract({\n address: this.contractAddress,\n abi: ProtocolParamsABI,\n functionName: \"latestOffchainParamsVersion\",\n });\n const version = Number(raw);\n assertValidOffchainParamsVersion(version);\n return version;\n }\n\n async getTimelockPeginByVersion(version: number): Promise<number> {\n const params = await this.getOffchainParamsByVersion(version);\n return deriveTimelockPegin(params.timelockAssert);\n }\n\n /**\n * Returned as `bigint` with no `Number` narrowing: the registry compares it\n * against `block.number`, so callers must do the same arithmetic the\n * contract does. `0` is the documented \"disabled\" case and is returned as\n * `0n`. A missing getter or a non-bigint payload throws — never coerced to\n * `0`, which would fail open and skip the observation window.\n *\n * @throws If the deployment does not expose `peginActivationDelay()`, or\n * the decoded payload is not a `bigint`.\n */\n async getPeginActivationDelay(): Promise<bigint> {\n const raw: unknown = await this.publicClient.readContract({\n address: this.contractAddress,\n abi: ProtocolParamsABI,\n functionName: \"peginActivationDelay\",\n });\n if (typeof raw !== \"bigint\") {\n throw new Error(\n `Invalid peginActivationDelay from contract: must be a bigint, got ${typeof raw}`,\n );\n }\n return raw;\n }\n\n /**\n * Read TBV protocol params, latest offchain params, and the latest version\n * label atomically via multicall. The version is paired with the params so\n * that a governance update between separate reads cannot let JS build BTC\n * scripts with version N params while the contract registers the vault\n * under version N+1.\n *\n * That guarantee holds only within this multicall. A caller that also reads\n * participant keys — every fresh peg-in build does — must pass the same\n * `blockNumber` here and to those reads, or the two describe different\n * blocks and the pairing above buys nothing across the seam.\n */\n async getPegInConfiguration(\n blockNumber?: bigint,\n ): Promise<PegInConfiguration> {\n const results = await this.publicClient.multicall({\n blockNumber,\n contracts: [\n {\n address: this.contractAddress,\n abi: ProtocolParamsABI,\n functionName: \"getTBVProtocolParams\",\n },\n {\n address: this.contractAddress,\n abi: ProtocolParamsABI,\n functionName: \"getLatestOffchainParams\",\n },\n {\n address: this.contractAddress,\n abi: ProtocolParamsABI,\n functionName: \"latestOffchainParamsVersion\",\n },\n {\n address: this.contractAddress,\n abi: ProtocolParamsABI,\n functionName: \"activeVaultCoreVersion\",\n },\n ],\n allowFailure: false,\n });\n\n const tbvParams = mapTBVParams(results[0] as RawTBVParams);\n const offchainParams = mapOffchainParams(results[1] as RawOffchainParams);\n const offchainParamsVersion = Number(results[2]);\n const activeVaultCoreVersion = Number(results[3]);\n\n const config: PegInConfiguration = {\n minimumPegInAmount: tbvParams.minimumPegInAmount,\n maxPegInAmount: tbvParams.maxPegInAmount,\n pegInAckTimeout: tbvParams.pegInAckTimeout,\n pegInActivationTimeout: tbvParams.pegInActivationTimeout,\n maxHtlcOutputCount: tbvParams.maxHtlcOutputCount,\n expiredPegInGraceBlocks: tbvParams.expiredPegInGraceBlocks,\n timelockPegin: deriveTimelockPegin(offchainParams.timelockAssert),\n timelockRefund: offchainParams.tRefund,\n minVpCommissionBps: offchainParams.minVpCommissionBps,\n offchainParams,\n offchainParamsVersion,\n activeVaultCoreVersion,\n };\n\n validatePegInConfiguration(config);\n return config;\n }\n\n /**\n * Fetch every historical offchain params version in a single multicall.\n * Iterates 1..latestVersion and calls `getOffchainParamsByVersion` for each.\n * Versions whose payload fails validation are skipped (not included in the\n * returned map) so a single bad historical version doesn't block the\n * lookup of the rest.\n *\n * @param onSkippedVersion - optional observer invoked once per skipped\n * version. Use to log/telemeter without coupling the SDK to a logger.\n */\n async fetchAllOffchainParams(\n onSkippedVersion?: OnSkippedOffchainParamsVersion,\n ): Promise<AllOffchainParamsData> {\n const latestVersion = await this.getLatestOffchainParamsVersion();\n if (latestVersion === 0) {\n return { byVersion: new Map(), latestVersion: 0 };\n }\n\n const versions = Array.from({ length: latestVersion }, (_, i) => i + 1);\n const contracts = versions.map((v) => ({\n address: this.contractAddress,\n abi: ProtocolParamsABI as Abi,\n functionName: \"getOffchainParamsByVersion\" as const,\n args: [v] as const,\n }));\n\n const results = await this.publicClient.multicall({\n contracts,\n allowFailure: false,\n });\n\n const byVersion = new Map<number, VersionedOffchainParams>();\n for (let i = 0; i < versions.length; i++) {\n const params = mapOffchainParams(results[i] as RawOffchainParams);\n try {\n validateOffchainParams(params);\n byVersion.set(versions[i], params);\n } catch (error) {\n // A malformed historical version mustn't block lookup of the rest.\n // Surface the skip to the caller's observer if one was supplied.\n onSkippedVersion?.(\n versions[i],\n error instanceof Error ? error : new Error(String(error)),\n );\n }\n }\n\n return { byVersion, latestVersion };\n }\n}\n","/**\n * Concrete signer-set readers for vault keepers and universal challengers.\n *\n * These are optional utilities — callers can use their own implementations\n * of the VaultKeeperReader and UniversalChallengerReader interfaces.\n */\n\nimport type { Address, Hex, PublicClient } from \"viem\";\n\nimport { ApplicationRegistryABI } from \"../../contracts/abis/ApplicationRegistry.abi\";\nimport { ProtocolParamsABI } from \"../../contracts/abis/ProtocolParams.abi\";\nimport type {\n AddressBTCKeyPair,\n UniversalChallengerReader,\n VaultKeeperReader,\n} from \"./types\";\n\n/** Map viem tuple array to AddressBTCKeyPair[]. */\nfunction mapKeyPairs(\n result: readonly { ethAddress: Address; btcPubKey: Hex }[],\n): AddressBTCKeyPair[] {\n return result.map((pair) => ({\n ethAddress: pair.ethAddress,\n btcPubKey: pair.btcPubKey,\n }));\n}\n\n/**\n * Both key-epoch getters return `uint64` and feed the peg-in config\n * fingerprint, where the contract encodes them as `uint64`. A `Number`\n * narrowing would silently truncate above 2^53 and produce a fingerprint the\n * registry cannot reproduce, so the payload is asserted to be a `bigint` and\n * carried as one — never coerced, never defaulted.\n */\nfunction assertKeyEpoch(raw: unknown, label: string): bigint {\n if (typeof raw !== \"bigint\") {\n throw new Error(\n `Invalid ${label} from contract: must be a bigint, got ${typeof raw}`,\n );\n }\n return raw;\n}\n\n/**\n * Reads vault keepers from the ApplicationRegistry contract.\n *\n * Usage:\n * ```ts\n * const reader = new ViemVaultKeeperReader(publicClient, applicationRegistryAddress);\n * const keepers = await reader.getCurrentVaultKeepers(appEntryPoint);\n * ```\n */\nexport class ViemVaultKeeperReader implements VaultKeeperReader {\n constructor(\n private publicClient: PublicClient,\n private contractAddress: Address,\n ) {}\n\n async getVaultKeepersByVersion(\n appEntryPoint: Address,\n version: number,\n blockNumber?: bigint,\n ): Promise<AddressBTCKeyPair[]> {\n const result = (await this.publicClient.readContract({\n address: this.contractAddress,\n abi: ApplicationRegistryABI,\n functionName: \"getVaultKeepersByVersion\",\n args: [appEntryPoint, version],\n blockNumber,\n })) as readonly { ethAddress: Address; btcPubKey: Hex }[];\n\n return mapKeyPairs(result);\n }\n\n async getCurrentVaultKeepers(\n appEntryPoint: Address,\n ): Promise<AddressBTCKeyPair[]> {\n const result = (await this.publicClient.readContract({\n address: this.contractAddress,\n abi: ApplicationRegistryABI,\n functionName: \"getCurrentVaultKeepers\",\n args: [appEntryPoint],\n })) as readonly { ethAddress: Address; btcPubKey: Hex }[];\n\n return mapKeyPairs(result);\n }\n\n async getCurrentVaultKeepersVersion(\n appEntryPoint: Address,\n blockNumber?: bigint,\n ): Promise<number> {\n const result = (await this.publicClient.readContract({\n address: this.contractAddress,\n abi: ApplicationRegistryABI,\n functionName: \"getCurrentVaultKeepersVersion\",\n args: [appEntryPoint],\n blockNumber,\n })) as number;\n\n return result;\n }\n\n async getCurrentAppKeeperKeyEpoch(\n appEntryPoint: Address,\n blockNumber?: bigint,\n ): Promise<bigint> {\n const raw: unknown = await this.publicClient.readContract({\n address: this.contractAddress,\n abi: ApplicationRegistryABI,\n functionName: \"appKeeperKeyEpochCurrent\",\n args: [appEntryPoint],\n blockNumber,\n });\n\n return assertKeyEpoch(raw, \"appKeeperKeyEpochCurrent\");\n }\n}\n\n/**\n * Reads universal challengers from the ProtocolParams contract.\n *\n * Usage:\n * ```ts\n * const reader = new ViemUniversalChallengerReader(publicClient, protocolParamsAddress);\n * const challengers = await reader.getCurrentUniversalChallengers();\n * ```\n */\nexport class ViemUniversalChallengerReader implements UniversalChallengerReader {\n constructor(\n private publicClient: PublicClient,\n private contractAddress: Address,\n ) {}\n\n async getUniversalChallengersByVersion(\n version: number,\n blockNumber?: bigint,\n ): Promise<AddressBTCKeyPair[]> {\n const result = (await this.publicClient.readContract({\n address: this.contractAddress,\n abi: ProtocolParamsABI,\n functionName: \"getUniversalChallengersByVersion\",\n args: [version],\n blockNumber,\n })) as readonly { ethAddress: Address; btcPubKey: Hex }[];\n\n return mapKeyPairs(result);\n }\n\n async getCurrentUniversalChallengers(): Promise<AddressBTCKeyPair[]> {\n const result = (await this.publicClient.readContract({\n address: this.contractAddress,\n abi: ProtocolParamsABI,\n functionName: \"getCurrentUniversalChallengers\",\n })) as readonly { ethAddress: Address; btcPubKey: Hex }[];\n\n return mapKeyPairs(result);\n }\n\n async getLatestUniversalChallengersVersion(\n blockNumber?: bigint,\n ): Promise<number> {\n const result = (await this.publicClient.readContract({\n address: this.contractAddress,\n abi: ProtocolParamsABI,\n functionName: \"latestUniversalChallengersVersion\",\n blockNumber,\n })) as number;\n\n return result;\n }\n\n async getCurrentUcKeyEpoch(blockNumber?: bigint): Promise<bigint> {\n const raw: unknown = await this.publicClient.readContract({\n address: this.contractAddress,\n abi: ProtocolParamsABI,\n functionName: \"ucKeyEpochCurrent\",\n blockNumber,\n });\n\n return assertKeyEpoch(raw, \"ucKeyEpochCurrent\");\n }\n}\n","/**\n * Types and interfaces for ETH contract readers.\n *\n * These are optional utilities — callers can use them or build their own.\n * Core service functions never import from this module.\n */\n\nimport type { Address, Hex } from \"viem\";\n\n// ============================================================================\n// Vault Registry Types\n// ============================================================================\n\ndeclare const onChainBtcPubkeyBrand: unique symbol;\n\n/**\n * 64-char lowercase hex (no `0x`) x-only BTC pubkey sourced from an on-chain\n * registry. Minted only by `assertOnChainBtcPubkey`, which is the shared\n * validator behind both producers:\n * {@link VaultRegistryReader.getVaultProviderGenesisBtcPubKey} (the fixed\n * registration key) and {@link OperationKeyReader} (RFC-006 operation keys,\n * resolved current or at a vault's frozen epoch).\n *\n * @stability frozen\n */\nexport type OnChainBtcPubkey = string & {\n readonly [onChainBtcPubkeyBrand]: true;\n};\n\n/**\n * Mirrors `IBTCVaultRegistry.BTCVaultStatus` in BTCVaultRegistry.sol exactly.\n * Use this when consuming `status` from `getVaultBasicInfo` /\n * `getBtcVaultBasicInfo`.\n *\n * Do NOT confuse with the app-side `ContractStatus` enum\n * (`services/deposit/peginState.ts`) — that one is for the indexer and\n * extends this with values 5-7, reassigning 4 to LIQUIDATED. Reading an\n * on-chain status through `ContractStatus[n]` for labels will mislabel\n * Expired(4) as LIQUIDATED.\n */\nexport enum OnChainBtcVaultStatus {\n PENDING = 0,\n VERIFIED = 1,\n ACTIVE = 2,\n REDEEMED = 3,\n EXPIRED = 4,\n}\n\n/** Basic vault info from BTCVaultRegistry.getBtcVaultBasicInfo */\nexport interface VaultBasicInfo {\n depositor: Address;\n depositorBtcPubKey: Hex;\n amount: bigint;\n vaultProvider: Address;\n status: number;\n applicationEntryPoint: Address;\n createdAt: bigint;\n}\n\n/** Protocol info from BTCVaultRegistry.getBtcVaultProtocolInfo */\nexport interface VaultProtocolInfo {\n depositorSignedPeginTx: Hex;\n universalChallengersVersion: number;\n appVaultKeepersVersion: number;\n offchainParamsVersion: number;\n /**\n * ETH block number stamped at the Pending→Verified transition.\n * Compared against `block.number` (inclusive:\n * `block.number >= verifiedAt + peginActivationDelay`), never a unix timestamp.\n */\n verifiedAt: bigint;\n depositorWotsPkHash: Hex;\n hashlock: Hex;\n htlcVout: number;\n depositorPopSignature: Hex;\n prePeginTxHash: Hex;\n vaultProviderCommissionBps: number;\n /** Vault core version (uint16) stamped at registration. VP-side gating only — see #1690. */\n vaultCoreVersion: number;\n}\n\n/** Combined vault data (basic + protocol) */\nexport interface VaultData {\n basic: VaultBasicInfo;\n protocol: VaultProtocolInfo;\n}\n\n/**\n * RFC-006 operation-key epochs a vault froze at `submitPeginRequest`.\n *\n * Each registry keeps a monotonic epoch counter that every key/payout setter\n * pre-increments. A vault stamps the counters live at its creation, and every\n * participant resolves \"which key did this vault bond?\" by asking the registry\n * for the key whose appended version is the latest stamped `<=` this epoch. A\n * rotation after the vault was created therefore never moves its keys.\n *\n * `uint64` — kept as `bigint` end-to-end and passed straight back to the\n * `...AtEpoch` getters, never narrowed through `Number`.\n *\n * Only ever read through {@link VaultRegistryReader.getVaultKeyEpochs}, which\n * uses the extended ABI. See `BTCVaultRegistryKeyEpochs.abi.ts` for why that\n * read is quarantined to its own ABI.\n */\nexport interface KeyEpochs {\n vpKeyEpoch: bigint;\n appKeeperKeyEpoch: bigint;\n ucKeyEpoch: bigint;\n}\n\n/** Interface for reading vault data from the BTCVaultRegistry contract. */\nexport interface VaultRegistryReader {\n getVaultBasicInfo(vaultId: Hex): Promise<VaultBasicInfo>;\n getVaultProtocolInfo(vaultId: Hex): Promise<VaultProtocolInfo>;\n getProtocolInfoBatch(vaultIds: readonly Hex[]): Promise<VaultProtocolInfo[]>;\n getVaultData(vaultId: Hex): Promise<VaultData>;\n /**\n * Read a vault provider's *genesis* (registration) BTC key — the key bonded\n * at version 0, which never moves when the operator rotates.\n *\n * Used only as the genesis fallback for epoch-based resolution and as a\n * candidate when cross-checking an indexer hint. Never the key to build a\n * Bitcoin lock with; that comes from `OperationKeyReader`.\n *\n * Resolves via `getOperationBtcKeyAtEpoch` at epoch 0, so it requires an\n * RFC-006 registry — as does every caller.\n */\n getVaultProviderGenesisBtcPubKey(\n vpAddress: Address,\n blockNumber?: bigint,\n ): Promise<OnChainBtcPubkey>;\n /** Read the protocol pegin fee (in wei) for a given vault provider. */\n getPegInFee(vaultProvider: Address): Promise<bigint>;\n /**\n * Read a vault provider's current commission in basis points.\n *\n * Validates the contract-enforced `[0, 9999]` range — an out-of-range\n * value signals a wrong contract address or ABI drift, not a real rate.\n */\n getVaultProviderCommission(vaultProvider: Address): Promise<number>;\n /**\n * Read a vault's frozen RFC-006 key epochs.\n *\n * Uses the extended `getBtcVaultProtocolInfo` ABI. Against a registry whose\n * `BTCVaultProtocolInfo` struct is not extended this returns silent garbage\n * for a populated vault rather than throwing, so it must only be called\n * against an RFC-006 registry — a deployment invariant, not something this\n * call can detect. A registry missing the operation-key getters altogether is\n * the safer case: key resolution reverts downstream and these epochs are never\n * used. See `BTCVaultRegistryKeyEpochs.abi.ts`.\n */\n getVaultKeyEpochs(vaultId: Hex): Promise<KeyEpochs>;\n /** {@link getVaultKeyEpochs} for many vaults in one multicall. */\n getVaultKeyEpochsBatch(vaultIds: readonly Hex[]): Promise<KeyEpochs[]>;\n /**\n * Read a vault provider's *current* RFC-006 operation BTC key — the key its\n * server signs auth tokens with. Falls back to the registration key when the\n * provider has never rotated.\n */\n getCurrentVaultProviderOperationBtcKey(\n vpAddress: Address,\n ): Promise<OnChainBtcPubkey>;\n /**\n * Read the depositor's commission ceiling (`maxAcceptableCommissionBps`)\n * for vaults registered in the same block `createdAt`, from their\n * `PegInSubmittedV2` logs, in `vaultIds` order. The contract discards the\n * ceiling after bound-checking it, so the log is its only on-chain source.\n *\n * @throws {RegistrationLogsUnavailableError} (transient, retry) when the\n * node answers with no registration logs for the block at all.\n * @throws when a vault has only its `PegInSubmitted` log (a registration\n * that predates the V2 event), none, or more than one V2 log.\n */\n getMaxAcceptableCommissionBpsBatch(\n vaultIds: readonly Hex[],\n createdAt: bigint,\n ): Promise<number[]>;\n /**\n * Read the application entry point a vault provider is registered for.\n *\n * The peg-in submit path resolves this internally and uses it to pick the\n * keeper roster, the roster version and the keeper key epoch a deposit is\n * bonded to. Pass `blockNumber` when the result will shape a Bitcoin lock,\n * so it describes the same block as the roster reads that follow it.\n */\n getVaultProviderApplication(\n vpAddress: Address,\n blockNumber?: bigint,\n ): Promise<Address>;\n}\n\n// ============================================================================\n// Protocol Params Types (from IProtocolParams.sol)\n// ============================================================================\n\n/**\n * TBV protocol parameters from the ProtocolParams contract.\n * Matches Solidity struct `IProtocolParams.TBVProtocolParams` exactly.\n *\n * All uint64 amounts use bigint (satoshi values can exceed 2^53).\n * uint8 uses number (bounded, max 255).\n */\nexport interface TBVProtocolParams {\n minimumPegInAmount: bigint;\n maxPegInAmount: bigint;\n pegInAckTimeout: bigint;\n pegInActivationTimeout: bigint;\n maxHtlcOutputCount: number;\n /**\n * Number of blocks added to the activation deadline as a grace window\n * during which a depositor may still reclaim an expired pegin via the\n * HTLC preimage. Source: `IProtocolParams.TBVProtocolParams.expiredPegInGraceBlocks`.\n */\n expiredPegInGraceBlocks: bigint;\n}\n\n/**\n * Versioned offchain parameters from the ProtocolParams contract.\n * Matches Solidity struct `IProtocolParams.VersionedOffchainParams` exactly.\n *\n * bigint for: uint256 timelocks, uint64 fee rates/amounts.\n * number for: uint8/uint16/uint32 fields (bounded, safe for JS arithmetic).\n */\nexport interface VersionedOffchainParams {\n timelockAssert: bigint;\n timelockChallengeAssert: bigint;\n securityCouncilKeys: Hex[];\n councilQuorum: number;\n feeRate: bigint;\n babeTotalInstances: number;\n babeInstancesToFinalize: number;\n minVpCommissionBps: number;\n tRefund: number;\n tStale: number;\n minPeginFeeRate: bigint;\n proverCircuitVersion: number;\n minPrepeginDepth: number;\n}\n\n/**\n * Combined peg-in configuration read atomically via multicall.\n * Prevents TOCTOU inconsistency if governance updates params between reads.\n */\nexport interface PegInConfiguration {\n minimumPegInAmount: bigint;\n maxPegInAmount: bigint;\n pegInAckTimeout: bigint;\n pegInActivationTimeout: bigint;\n maxHtlcOutputCount: number;\n expiredPegInGraceBlocks: bigint;\n timelockPegin: number;\n timelockRefund: number;\n minVpCommissionBps: number;\n offchainParams: VersionedOffchainParams;\n /**\n * Version label paired atomically with `offchainParams`.\n * Read in the same multicall as the params struct so that, if a parameter\n * update lands between separate reads, the script-construction code and\n * the version label stay consistent.\n */\n offchainParamsVersion: number;\n /**\n * Currently-active vault core (tx-graph) version\n * (`ProtocolParams.activeVaultCoreVersion()`, uint16 ≥ 1). Stamped onto\n * every new vault at peg-in submission; fresh deposits must build this\n * graph version. Read in the same multicall so a governance version bump\n * can't land between reading the params and reading the version.\n */\n activeVaultCoreVersion: number;\n}\n\n/**\n * All offchain params snapshots indexed by version, plus the latest version\n * number known when the snapshot was taken. Used by consumers that need to\n * resolve any historical version (e.g. signing for an existing vault locked\n * to an older version).\n */\nexport interface AllOffchainParamsData {\n byVersion: Map<number, VersionedOffchainParams>;\n latestVersion: number;\n}\n\n/**\n * Optional observer invoked by `fetchAllOffchainParams` when a historical\n * version fails validation. Called once per skipped version so callers can\n * log/telemeter without coupling the SDK to a specific logger.\n */\nexport type OnSkippedOffchainParamsVersion = (\n version: number,\n error: Error,\n) => void;\n\n/** Interface for reading protocol parameters from the ProtocolParams contract. */\nexport interface ProtocolParamsReader {\n getTBVProtocolParams(): Promise<TBVProtocolParams>;\n getOffchainParamsByVersion(version: number): Promise<VersionedOffchainParams>;\n getLatestOffchainParams(): Promise<VersionedOffchainParams>;\n getLatestOffchainParamsVersion(): Promise<number>;\n getTimelockPeginByVersion(version: number): Promise<number>;\n /**\n * Pass `blockNumber` when the result will shape a Bitcoin lock, so this\n * multicall and the participant-key reads describe the same block. Omit it\n * for display-only reads, where a slightly stale value is harmless.\n */\n getPegInConfiguration(blockNumber?: bigint): Promise<PegInConfiguration>;\n /**\n * Observation window enforced between a vault's final ACK and its\n * activation, in ETH blocks measured from `verifiedAt`. `0` disables it.\n *\n * Deliberately its own read rather than a field on\n * {@link PegInConfiguration}: the parameter is absent from deployments that\n * predate it, so folding it into the shared multicall would make every\n * protocol-param read fail wherever it is missing.\n *\n * @throws If the deployment does not expose `peginActivationDelay()`, or\n * the decoded payload is not a `bigint`.\n */\n getPeginActivationDelay(): Promise<bigint>;\n fetchAllOffchainParams(\n onSkippedVersion?: OnSkippedOffchainParamsVersion,\n ): Promise<AllOffchainParamsData>;\n}\n\n// ============================================================================\n// Signer-Set Types (from BTCVaultTypes.sol)\n// ============================================================================\n\n/**\n * Matches Solidity struct `BTCVaultTypes.AddressBTCKeyPair` exactly.\n * Used for vault keepers and universal challengers.\n */\nexport interface AddressBTCKeyPair {\n ethAddress: Address;\n btcPubKey: Hex;\n}\n\n/**\n * Interface for reading vault keepers from the ApplicationRegistry contract.\n *\n * The reads used to build a peg-in — here and on the sibling reader interfaces\n * — take an optional `blockNumber` that pins them to one block instead of\n * `latest`. Omitting it, the historical behaviour, is correct for every read\n * that resolves against a vault's already-frozen epochs, because those are\n * immutable once stamped. It is NOT correct for a fresh peg-in build: the\n * participant keys, roster versions and protocol params that shape the Bitcoin\n * lock must all describe the same block, or the lock commits to a mixture of\n * chain states that never existed at once. See\n * `services/deposit/validateOnChainParticipantKeys`.\n *\n * The `getCurrent*` roster reads are the exception and take no block. Nothing\n * on the build path uses them — it resolves rosters by version instead — so\n * they were left alone rather than given a pin no caller would pass.\n */\nexport interface VaultKeeperReader {\n getVaultKeepersByVersion(\n appEntryPoint: Address,\n version: number,\n blockNumber?: bigint,\n ): Promise<AddressBTCKeyPair[]>;\n getCurrentVaultKeepers(appEntryPoint: Address): Promise<AddressBTCKeyPair[]>;\n getCurrentVaultKeepersVersion(\n appEntryPoint: Address,\n blockNumber?: bigint,\n ): Promise<number>;\n /**\n * Read the application's current vault-keeper operation-key epoch.\n *\n * One counter for the whole application, bumped by any keeper's\n * operation-key or payout-script append. The peg-in config fingerprint\n * commits to it in place of the N resolved keeper keys, so it must be read\n * at the same block as the roster it labels. Returned as `bigint`; the\n * contract encodes it as `uint64` and a `Number` would truncate.\n */\n getCurrentAppKeeperKeyEpoch(\n appEntryPoint: Address,\n blockNumber?: bigint,\n ): Promise<bigint>;\n}\n\n/** Interface for reading universal challengers from the ProtocolParams contract. */\nexport interface UniversalChallengerReader {\n getUniversalChallengersByVersion(\n version: number,\n blockNumber?: bigint,\n ): Promise<AddressBTCKeyPair[]>;\n getCurrentUniversalChallengers(): Promise<AddressBTCKeyPair[]>;\n getLatestUniversalChallengersVersion(blockNumber?: bigint): Promise<number>;\n /**\n * Read the protocol's current universal-challenger operation-key epoch.\n *\n * The challenger-axis counterpart to\n * {@link VaultKeeperReader.getCurrentAppKeeperKeyEpoch}: one protocol-wide\n * counter the fingerprint commits to in place of the M resolved challenger\n * keys. Returned as `bigint` for the same `uint64` reason.\n */\n getCurrentUcKeyEpoch(blockNumber?: bigint): Promise<bigint>;\n}\n\n// ============================================================================\n// RFC-006 Operation-Key Types\n// ============================================================================\n\n/**\n * The participants whose operation keys are being resolved, and the roster\n * they are resolved against.\n *\n * A roster entry's `ethAddress` is the operator's **admin** address — the\n * lookup key for its key history — and its `btcPubKey` is the operator's\n * **genesis** key. Both are needed: the `...AtEpochOrGenesis` getters take the\n * roster key explicitly because the correct genesis for a keeper/challenger is\n * its key in the vault's *frozen membership version*, which an operator that\n * was later dropped from the roster no longer has a current entry for.\n */\nexport interface OperationKeyQuery {\n vaultProviderEthAddress: Address;\n /**\n * The VP's genesis (registration) key, from\n * {@link VaultRegistryReader.getVaultProviderGenesisBtcPubKey}.\n *\n * The VP has no roster entry to carry a genesis key the way keepers and\n * challengers do, so it is supplied here. Every call site already reads it:\n * it is what the indexer hint is compared against, and what makes the VP's\n * `rotated` flag mean the same thing as everyone else's.\n */\n vaultProviderGenesisBtcPubkey: Hex;\n applicationEntryPoint: Address;\n /** Keeper roster at the membership version being resolved against. */\n vaultKeepers: readonly AddressBTCKeyPair[];\n /** Challenger roster at the membership version being resolved against. */\n universalChallengers: readonly AddressBTCKeyPair[];\n}\n\n/** Raw registry-returned operation keys, index-aligned with the query rosters. */\nexport interface RawOperationKeys {\n vaultProvider: Hex;\n vaultKeepers: Hex[];\n universalChallengers: Hex[];\n}\n\n/**\n * Registry-returned payout scriptPubKeys, index-aligned with the query\n * rosters. `universalChallengers` has no counterpart: a UC is never a claimer,\n * so it has no payout script.\n */\nexport interface RawPayoutScripts {\n vaultProvider: Hex;\n vaultKeepers: Hex[];\n}\n\n/**\n * Reads RFC-006 operation keys and payout scripts across all three registries\n * (BTCVaultRegistry, ApplicationRegistry, ProtocolParams).\n *\n * Every method resolves the whole participant set in a **single** multicall so\n * the keys are pinned to one block. That atomicity is load-bearing: a rotation\n * landing between two `eth_call`s would yield a self-inconsistent key set that\n * builds a lock no counterparty agrees with.\n */\nexport interface OperationKeyReader {\n /**\n * Resolve every participant's *current* operation key.\n *\n * Used for new peg-ins and for the VP auth pin. Needs no epoch read at all —\n * each registry's `getCurrentOperationBtcKey` resolves its own genesis\n * fallback, so an operator that never rotated yields its registration key.\n */\n getCurrentOperationKeys(\n query: OperationKeyQuery,\n blockNumber?: bigint,\n ): Promise<RawOperationKeys>;\n /**\n * Resolve every participant's operation key bonded at a vault's frozen\n * epochs. Used for every existing-vault path (resume, payout, refund).\n */\n getOperationKeysAtEpochs(\n query: OperationKeyQuery,\n epochs: KeyEpochs,\n ): Promise<RawOperationKeys>;\n /**\n * Resolve the VP's commission payout script and each keeper's payout script\n * at a vault's frozen epochs.\n *\n * The registry backfills BIP-86 P2TR of the epoch's operation key for any\n * operator that never called `setPayoutScript`, so this returns byte-identical\n * results to local BIP-86 derivation until an operator registers a custom\n * script.\n */\n getPayoutScriptsAtEpochs(\n query: OperationKeyQuery,\n epochs: KeyEpochs,\n ): Promise<RawPayoutScripts>;\n}\n"],"names":["resolveProtocolAddresses","publicClient","btcVaultRegistryAddress","protocolParams","applicationRegistry","BTCVaultRegistryABI","assertMulticallLength","actual","expected","label","partition","results","keeperCount","ViemOperationKeyReader","contracts","calls","challengerCount","blockNumber","query","keeper","ApplicationRegistryABI","challenger","ProtocolParamsABI","epochs","UINT16_MAX","mapOffchainParams","result","mapTBVParams","deriveTimelockPegin","timelockAssert","ViemProtocolParamsReader","contractAddress","params","validateTBVProtocolParams","validateOffchainParams","version","raw","assertValidOffchainParamsVersion","tbvParams","offchainParams","offchainParamsVersion","activeVaultCoreVersion","config","validatePegInConfiguration","onSkippedVersion","latestVersion","versions","_","i","v","byVersion","error","mapKeyPairs","pair","assertKeyEpoch","ViemVaultKeeperReader","appEntryPoint","ViemUniversalChallengerReader","OnChainBtcVaultStatus"],"mappings":"yKA8BA,eAAsBA,EACpBC,EACAC,EAC4B,CAC5B,KAAM,CAACC,EAAgBC,CAAmB,EAAI,MAAMH,EAAa,UAAU,CACzE,UAAW,CACT,CACE,QAASC,EACT,IAAKG,EAAAA,oBACL,aAAc,gBAAA,EAEhB,CACE,QAASH,EACT,IAAKG,EAAAA,oBACL,aAAc,qBAAA,CAChB,EAEF,aAAc,EAAA,CACf,EAED,MAAO,CACL,eAAAF,EACA,oBAAAC,CAAA,CAEJ,CCTA,SAASE,EACPC,EACAC,EACAC,EACM,CACN,GAAIF,IAAWC,EACb,MAAM,IAAI,MACR,GAAGC,CAAK,wBAAwBF,CAAM,gBAAgBC,CAAQ,qEAAA,CAIpE,CAYA,SAASE,EACPC,EACAC,EACoE,CACpE,MAAO,CACL,cAAeD,EAAQ,CAAC,EACxB,aAAcA,EAAQ,MAAM,EAAG,EAAIC,CAAW,EAC9C,qBAAsBD,EAAQ,MAAM,EAAIC,CAAW,CAAA,CAEvD,CAWO,MAAMC,CAAqD,CAChE,YACUZ,EACAa,EACR,CAFQ,KAAA,aAAAb,EACA,KAAA,UAAAa,CACP,CAQH,MAAc,QACZC,EACAH,EACAI,EACAP,EACAQ,EACA,CACA,MAAMN,EAAW,MAAM,KAAK,aAAa,UAAU,CACjD,UAAWI,EACX,aAAc,GAC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AAa,aAAa,CACxD,QAAS,KAAK,gBACd,IAAKd,EAAAA,kBACL,aAAc,oBACd,YAAAL,CAAA,CACD,EAED,OAAOqC,EAAelB,EAAK,mBAAmB,CAChD,CACF,CC7IO,IAAKsB,GAAAA,IACVA,EAAAA,EAAA,QAAU,CAAA,EAAV,UACAA,EAAAA,EAAA,SAAW,CAAA,EAAX,WACAA,EAAAA,EAAA,OAAS,CAAA,EAAT,SACAA,EAAAA,EAAA,SAAW,CAAA,EAAX,WACAA,EAAAA,EAAA,QAAU,CAAA,EAAV,UALUA,IAAAA,GAAA,CAAA,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonlabs-io/ts-sdk",
3
- "version": "0.77.0",
3
+ "version": "0.79.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -158,8 +158,8 @@
158
158
  "vite": "^6.4.1",
159
159
  "vite-plugin-dts": "^4.3.0",
160
160
  "vitest": "4.0.9",
161
- "@babylonlabs-io/babylon-tbv-rust-wasm": "0.19.0",
162
- "@internal/eslint-config": "0.0.0"
161
+ "@internal/eslint-config": "0.0.0",
162
+ "@babylonlabs-io/babylon-tbv-rust-wasm": "0.19.0"
163
163
  },
164
164
  "publishConfig": {
165
165
  "access": "public",
@@ -1 +0,0 @@
1
- {"version":3,"file":"BTCVaultRegistry.abi-CJwWI2EO.js","sources":["../src/tbv/core/contracts/abis/BTCVaultRegistry.abi.ts"],"sourcesContent":["/**\n * BTCVaultRegistry Contract ABI\n *\n * Minimal ABI containing only the functions needed by the SDK.\n * Full ABI is available in the vault service package.\n *\n * @module contracts/abis/BTCVaultRegistry\n */\n\n/**\n * Minimal ABI for BTCVaultRegistry contract.\n * Contains submitPeginRequest, submitPeginRequestBatch, activateVaultWithSecret, getPegInFee, getBtcVaultBasicInfo, and getVaultProviderCommission.\n */\nexport const BTCVaultRegistryABI = [\n {\n type: \"function\",\n name: \"submitPeginRequest\",\n inputs: [\n {\n name: \"depositor\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"btcPopSignature\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"unsignedPrePeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"maxAcceptableCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"hashlock\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"htlcVout\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"depositorPayoutBtcAddress\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n stateMutability: \"payable\",\n },\n {\n type: \"function\",\n name: \"submitPeginRequest\",\n inputs: [\n {\n name: \"depositor\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"btcPopSignature\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"unsignedPrePeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"maxAcceptableCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"hashlock\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"htlcVout\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"referralCode\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n {\n name: \"depositorPayoutBtcAddress\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n stateMutability: \"payable\",\n },\n {\n type: \"function\",\n name: \"submitPeginRequestBatch\",\n inputs: [\n { name: \"depositor\", type: \"address\", internalType: \"address\" },\n { name: \"vaultProvider\", type: \"address\", internalType: \"address\" },\n {\n name: \"maxAcceptableCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"requests\",\n type: \"tuple[]\",\n internalType: \"struct BTCVaultRegistryTypes.BatchPeginRequest[]\",\n components: [\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n { name: \"btcPopSignature\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"unsignedPrePeginTx\", type: \"bytes\", internalType: \"bytes\" },\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n { name: \"hashlock\", type: \"bytes32\", internalType: \"bytes32\" },\n { name: \"htlcVout\", type: \"uint8\", internalType: \"uint8\" },\n { name: \"referralCode\", type: \"uint32\", internalType: \"uint32\" },\n {\n name: \"depositorPayoutBtcAddress\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n },\n ],\n outputs: [\n { name: \"vaultIds\", type: \"bytes32[]\", internalType: \"bytes32[]\" },\n ],\n stateMutability: \"payable\",\n },\n {\n type: \"function\",\n name: \"activateVaultWithSecret\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"s\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"activationMetadata\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"activateVaultWithSecretAndRedeem\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"s\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"getPegInFee\",\n inputs: [\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [\n {\n name: \"totalFee\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n },\n // --- RFC-006 operation-key resolution ---------------------------------\n // A vault provider's BTC key is not a fixed registration key: it is an\n // append-only history of *operation* keys, rotated by the provider's cold ETH\n // admin key. Each vault freezes a `vpKeyEpoch` at `submitPeginRequest` and\n // resolves the key bonded at that epoch, so a later rotation never\n // invalidates a live vault.\n //\n // The dedicated `getVaultProviderBTCKey` / `getVaultProviderKeyPair` getters\n // are deliberately absent: vault-contracts-aave-v4#539 removes them, and\n // keeping them here would let a call compile against a selector the registry\n // no longer exposes. The registration key is read as the operation key at\n // epoch 0 instead — see `getVaultProviderGenesisBtcPubKey`.\n //\n // `getCurrentOperationBtcKey` falls back on-chain to the registration key at\n // version 0, so adopting it is a no-op for a provider that never rotated.\n //\n // `getPayoutScriptAtEpoch` does NOT behave that way, and assuming it did was\n // wrong in an earlier revision of this comment. A payout script is mandatory\n // at registration and stored as version 1, so on an RFC-006 registry this\n // returns the operator's own registered script from the very first epoch —\n // not a BIP-86 derivation of its key. The contract's BIP-86 branch is a\n // migration default for pre-RFC-006 rows and is not reachable from\n // registration. An operator whose registered script happens to equal\n // bip86(key) is a coincidence of what it chose to register, not a fallback.\n //\n // This is why depositor payout validation must accept the legacy BIP-86 form\n // alongside the registered one: a payout graph is built once at BaBe Setup\n // and never rebuilt, so a vault whose graph predates its network's\n // btc-vault#2440 upgrade pays BIP-86 for the rest of its life. See\n // `acceptedPayoutScriptHexes` in `primitives/psbt/payout.ts`.\n {\n type: \"function\",\n name: \"getCurrentOperationBtcKey\",\n inputs: [{ name: \"provider\", type: \"address\", internalType: \"address\" }],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"bytes32\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getOperationBtcKeyAtEpoch\",\n inputs: [\n { name: \"provider\", type: \"address\", internalType: \"address\" },\n { name: \"epoch\", type: \"uint64\", internalType: \"uint64\" },\n ],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"bytes32\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getPayoutScriptAtEpoch\",\n inputs: [\n { name: \"provider\", type: \"address\", internalType: \"address\" },\n { name: \"epoch\", type: \"uint64\", internalType: \"uint64\" },\n ],\n outputs: [{ name: \"\", type: \"bytes\", internalType: \"bytes\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getVaultProviderCommission\",\n inputs: [{ name: \"vpAddr\", type: \"address\", internalType: \"address\" }],\n outputs: [{ name: \"\", type: \"uint16\", internalType: \"uint16\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getBtcVaultBasicInfo\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"vBasic\",\n type: \"tuple\",\n internalType: \"struct BTCVaultTypes.BTCVaultBasicInfo\",\n components: [\n { name: \"depositor\", type: \"address\", internalType: \"address\" },\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n { name: \"amount\", type: \"uint256\", internalType: \"uint256\" },\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"status\",\n type: \"uint8\",\n internalType: \"enum IBTCVaultRegistry.BTCVaultStatus\",\n },\n {\n name: \"applicationEntryPoint\",\n type: \"address\",\n internalType: \"address\",\n },\n { name: \"createdAt\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"error\",\n name: \"InvalidPeginFee\",\n inputs: [\n {\n name: \"provided\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"required\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"InvalidSecret\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"ActivationDeadlineExpired\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"InvalidHashlock\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"DuplicateHashlock\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"CapExceeded\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"InvalidOutputIndex\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"PeginSignaturesIncomplete\",\n inputs: [],\n },\n {\n type: \"function\",\n name: \"getBtcVaultProtocolInfo\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"vProtocol\",\n type: \"tuple\",\n internalType: \"struct BTCVaultRegistryTypes.BTCVaultProtocolInfo\",\n components: [\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"universalChallengersVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"appVaultKeepersVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"offchainParamsVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"verifiedAt\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"hashlock\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"htlcVout\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"depositorPopSignature\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"prePeginTxHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"vaultProviderCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"claimExpiredUntil\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"vaultCoreVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"protocolParams\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"address\",\n internalType: \"contract IProtocolParams\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"applicationRegistry\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"address\",\n internalType: \"contract IApplicationRegistry\",\n },\n ],\n stateMutability: \"view\",\n },\n // ============================================================================\n // Errors — needed so viem can decode revert data into a named error.\n // Without these, every revert surfaces as \"Execution reverted for an\n // unknown reason.\" Mirrors errors thrown from BTCVaultRegistry's reachable\n // code paths (pegin submission, ACK, activation). Source:\n // https://github.com/babylonlabs-io/vault-contracts-aave-v4/blob/652c4582/src/protocol/lib/types/Errors.sol\n // ============================================================================\n { type: \"error\", name: \"ZeroAddress\", inputs: [] },\n { type: \"error\", name: \"Unauthorized\", inputs: [] },\n { type: \"error\", name: \"InvalidAmount\", inputs: [] },\n { type: \"error\", name: \"TransferFailed\", inputs: [] },\n { type: \"error\", name: \"InvalidTransaction\", inputs: [] },\n { type: \"error\", name: \"EmptyPayoutAddress\", inputs: [] },\n { type: \"error\", name: \"PayoutAddressTooLong\", inputs: [] },\n { type: \"error\", name: \"VaultAlreadyExists\", inputs: [] },\n { type: \"error\", name: \"VaultFeeAlreadyEscrowed\", inputs: [] },\n { type: \"error\", name: \"NoEscrowedFees\", inputs: [] },\n { type: \"error\", name: \"BTCVaultNotFound\", inputs: [] },\n { type: \"error\", name: \"InvalidBTCVaultStatus\", inputs: [] },\n { type: \"error\", name: \"PeginNotExpired\", inputs: [] },\n { type: \"error\", name: \"InvalidParticipantsList\", inputs: [] },\n { type: \"error\", name: \"DuplicateParticipant\", inputs: [] },\n { type: \"error\", name: \"ParticipantRoleOverlap\", inputs: [] },\n { type: \"error\", name: \"NotAuthorizedToACK\", inputs: [] },\n { type: \"error\", name: \"UnauthorizedVaultKeeper\", inputs: [] },\n { type: \"error\", name: \"BlocklistedVaultKeeper\", inputs: [] },\n { type: \"error\", name: \"PeginTransactionExpired\", inputs: [] },\n { type: \"error\", name: \"PrePeginOutputAlreadyUsed\", inputs: [] },\n { type: \"error\", name: \"PeginTransactionAlreadyUsed\", inputs: [] },\n {\n type: \"error\",\n name: \"InvalidPeginFee\",\n inputs: [\n { name: \"provided\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"required\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"AmountBelowMinimumThreshold\",\n inputs: [\n { name: \"actual\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"minimum\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"InvalidOutputIndex\",\n inputs: [\n { name: \"provided\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"maxValid\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"TooManyHtlcOutputs\",\n inputs: [\n { name: \"outputCount\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"maxAllowed\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"VaultBelowMinimum\",\n inputs: [\n { name: \"actual\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"minimum\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"VaultAboveMaximum\",\n inputs: [\n { name: \"actual\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"maximum\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n { type: \"error\", name: \"InvalidBTCPublicKey\", inputs: [] },\n { type: \"error\", name: \"InvalidDepositorWotsPkHash\", inputs: [] },\n { type: \"error\", name: \"InvalidBTCProofOfPossession\", inputs: [] },\n { type: \"error\", name: \"EthKeyAlreadyRegistered\", inputs: [] },\n { type: \"error\", name: \"BtcKeyAlreadyRegistered\", inputs: [] },\n { type: \"error\", name: \"InvalidRegistrationFee\", inputs: [] },\n {\n type: \"error\",\n name: \"CommissionBelowMinimum\",\n inputs: [\n { name: \"provided\", type: \"uint16\", internalType: \"uint16\" },\n { name: \"minimum\", type: \"uint16\", internalType: \"uint16\" },\n ],\n },\n {\n type: \"error\",\n name: \"CommissionAboveMaximum\",\n inputs: [{ name: \"provided\", type: \"uint16\", internalType: \"uint16\" }],\n },\n { type: \"error\", name: \"CommissionUnchanged\", inputs: [] },\n {\n type: \"error\",\n name: \"VaultProviderCommissionExceeded\",\n inputs: [\n { name: \"maxAcceptable\", type: \"uint16\", internalType: \"uint16\" },\n { name: \"actual\", type: \"uint16\", internalType: \"uint16\" },\n ],\n },\n { type: \"error\", name: \"VaultProviderNotRegistered\", inputs: [] },\n { type: \"error\", name: \"ApplicationAlreadyRegistered\", inputs: [] },\n { type: \"error\", name: \"ApplicationNotRegistered\", inputs: [] },\n { type: \"error\", name: \"ApplicationNotActive\", inputs: [] },\n { type: \"error\", name: \"InvalidApplicationStatus\", inputs: [] },\n { type: \"error\", name: \"OnlyApplicationEntryPoint\", inputs: [] },\n { type: \"error\", name: \"EmptyVaultKeepers\", inputs: [] },\n { type: \"error\", name: \"NoUniversalChallengersConfigured\", inputs: [] },\n { type: \"error\", name: \"NoAppVaultKeepersConfigured\", inputs: [] },\n { type: \"error\", name: \"PeginSignaturesIncomplete\", inputs: [] },\n { type: \"error\", name: \"InvalidSignatureLength\", inputs: [] },\n { type: \"error\", name: \"PeginInputSignatureAlreadySubmitted\", inputs: [] },\n { type: \"error\", name: \"InvalidHashlock\", inputs: [] },\n { type: \"error\", name: \"DuplicateHashlock\", inputs: [] },\n { type: \"error\", name: \"InvalidSecret\", inputs: [] },\n { type: \"error\", name: \"ActivationDeadlineExpired\", inputs: [] },\n // Lower bound on activation: reverts while\n // `block.number < verifiedAt + peginActivationDelay`. Clears with time, so\n // unlike ActivationDeadlineExpired it is retryable, not terminal.\n { type: \"error\", name: \"ActivationDelayNotElapsed\", inputs: [] },\n { type: \"error\", name: \"PostExpiryGraceWindowElapsed\", inputs: [] },\n { type: \"error\", name: \"CapExceeded\", inputs: [] },\n] as const;\n"],"names":["BTCVaultRegistryABI"],"mappings":"AAaO,MAAMA,IAAsB;AAAA,EACjC;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,MACN;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA,MAAA;AAAA,MAEhB;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA,QACN,cAAc;AAAA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EACrD,EAAE,MAAM,SAAS,MAAM,iBAAiB,QAAQ,CAAA,EAAC;AAAA,EACjD,EAAE,MAAM,SAAS,MAAM,6BAA6B,QAAQ,CAAA,EAAC;AAAA;AAAA;AAAA;AAAA,EAI7D,EAAE,MAAM,SAAS,MAAM,6BAA6B,QAAQ,CAAA,EAAC;AAAA,EAC7D,EAAE,MAAM,SAAS,MAAM,gCAAgC,QAAQ,CAAA,EAAC;AAAA,EAChE,EAAE,MAAM,SAAS,MAAM,eAAe,QAAQ,CAAA,EAAC;AACjD;"}
@@ -1,2 +0,0 @@
1
- "use strict";const e=[{type:"function",name:"submitPeginRequest",inputs:[{name:"depositor",type:"address",internalType:"address"},{name:"depositorBtcPubKey",type:"bytes32",internalType:"bytes32"},{name:"btcPopSignature",type:"bytes",internalType:"bytes"},{name:"unsignedPrePeginTx",type:"bytes",internalType:"bytes"},{name:"depositorSignedPeginTx",type:"bytes",internalType:"bytes"},{name:"vaultProvider",type:"address",internalType:"address"},{name:"maxAcceptableCommissionBps",type:"uint16",internalType:"uint16"},{name:"hashlock",type:"bytes32",internalType:"bytes32"},{name:"htlcVout",type:"uint8",internalType:"uint8"},{name:"depositorPayoutBtcAddress",type:"bytes",internalType:"bytes"},{name:"depositorWotsPkHash",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"payable"},{type:"function",name:"submitPeginRequest",inputs:[{name:"depositor",type:"address",internalType:"address"},{name:"depositorBtcPubKey",type:"bytes32",internalType:"bytes32"},{name:"btcPopSignature",type:"bytes",internalType:"bytes"},{name:"unsignedPrePeginTx",type:"bytes",internalType:"bytes"},{name:"depositorSignedPeginTx",type:"bytes",internalType:"bytes"},{name:"vaultProvider",type:"address",internalType:"address"},{name:"maxAcceptableCommissionBps",type:"uint16",internalType:"uint16"},{name:"hashlock",type:"bytes32",internalType:"bytes32"},{name:"htlcVout",type:"uint8",internalType:"uint8"},{name:"referralCode",type:"uint32",internalType:"uint32"},{name:"depositorPayoutBtcAddress",type:"bytes",internalType:"bytes"},{name:"depositorWotsPkHash",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"payable"},{type:"function",name:"submitPeginRequestBatch",inputs:[{name:"depositor",type:"address",internalType:"address"},{name:"vaultProvider",type:"address",internalType:"address"},{name:"maxAcceptableCommissionBps",type:"uint16",internalType:"uint16"},{name:"requests",type:"tuple[]",internalType:"struct BTCVaultRegistryTypes.BatchPeginRequest[]",components:[{name:"depositorBtcPubKey",type:"bytes32",internalType:"bytes32"},{name:"btcPopSignature",type:"bytes",internalType:"bytes"},{name:"unsignedPrePeginTx",type:"bytes",internalType:"bytes"},{name:"depositorSignedPeginTx",type:"bytes",internalType:"bytes"},{name:"hashlock",type:"bytes32",internalType:"bytes32"},{name:"htlcVout",type:"uint8",internalType:"uint8"},{name:"referralCode",type:"uint32",internalType:"uint32"},{name:"depositorPayoutBtcAddress",type:"bytes",internalType:"bytes"},{name:"depositorWotsPkHash",type:"bytes32",internalType:"bytes32"}]}],outputs:[{name:"vaultIds",type:"bytes32[]",internalType:"bytes32[]"}],stateMutability:"payable"},{type:"function",name:"activateVaultWithSecret",inputs:[{name:"vaultId",type:"bytes32",internalType:"bytes32"},{name:"s",type:"bytes32",internalType:"bytes32"},{name:"activationMetadata",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"activateVaultWithSecretAndRedeem",inputs:[{name:"vaultId",type:"bytes32",internalType:"bytes32"},{name:"s",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"getPegInFee",inputs:[{name:"vaultProvider",type:"address",internalType:"address"}],outputs:[{name:"totalFee",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"getCurrentOperationBtcKey",inputs:[{name:"provider",type:"address",internalType:"address"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"getOperationBtcKeyAtEpoch",inputs:[{name:"provider",type:"address",internalType:"address"},{name:"epoch",type:"uint64",internalType:"uint64"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"getPayoutScriptAtEpoch",inputs:[{name:"provider",type:"address",internalType:"address"},{name:"epoch",type:"uint64",internalType:"uint64"}],outputs:[{name:"",type:"bytes",internalType:"bytes"}],stateMutability:"view"},{type:"function",name:"getVaultProviderCommission",inputs:[{name:"vpAddr",type:"address",internalType:"address"}],outputs:[{name:"",type:"uint16",internalType:"uint16"}],stateMutability:"view"},{type:"function",name:"getBtcVaultBasicInfo",inputs:[{name:"vaultId",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"vBasic",type:"tuple",internalType:"struct BTCVaultTypes.BTCVaultBasicInfo",components:[{name:"depositor",type:"address",internalType:"address"},{name:"depositorBtcPubKey",type:"bytes32",internalType:"bytes32"},{name:"amount",type:"uint256",internalType:"uint256"},{name:"vaultProvider",type:"address",internalType:"address"},{name:"status",type:"uint8",internalType:"enum IBTCVaultRegistry.BTCVaultStatus"},{name:"applicationEntryPoint",type:"address",internalType:"address"},{name:"createdAt",type:"uint256",internalType:"uint256"}]}],stateMutability:"view"},{type:"error",name:"InvalidPeginFee",inputs:[{name:"provided",type:"uint256",internalType:"uint256"},{name:"required",type:"uint256",internalType:"uint256"}]},{type:"error",name:"InvalidSecret",inputs:[]},{type:"error",name:"ActivationDeadlineExpired",inputs:[]},{type:"error",name:"InvalidHashlock",inputs:[]},{type:"error",name:"DuplicateHashlock",inputs:[]},{type:"error",name:"CapExceeded",inputs:[]},{type:"error",name:"InvalidOutputIndex",inputs:[]},{type:"error",name:"PeginSignaturesIncomplete",inputs:[]},{type:"function",name:"getBtcVaultProtocolInfo",inputs:[{name:"vaultId",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"vProtocol",type:"tuple",internalType:"struct BTCVaultRegistryTypes.BTCVaultProtocolInfo",components:[{name:"depositorSignedPeginTx",type:"bytes",internalType:"bytes"},{name:"universalChallengersVersion",type:"uint16",internalType:"uint16"},{name:"appVaultKeepersVersion",type:"uint16",internalType:"uint16"},{name:"offchainParamsVersion",type:"uint16",internalType:"uint16"},{name:"verifiedAt",type:"uint256",internalType:"uint256"},{name:"depositorWotsPkHash",type:"bytes32",internalType:"bytes32"},{name:"hashlock",type:"bytes32",internalType:"bytes32"},{name:"htlcVout",type:"uint8",internalType:"uint8"},{name:"depositorPopSignature",type:"bytes",internalType:"bytes"},{name:"prePeginTxHash",type:"bytes32",internalType:"bytes32"},{name:"vaultProviderCommissionBps",type:"uint16",internalType:"uint16"},{name:"claimExpiredUntil",type:"uint256",internalType:"uint256"},{name:"vaultCoreVersion",type:"uint16",internalType:"uint16"}]}],stateMutability:"view"},{type:"function",name:"protocolParams",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IProtocolParams"}],stateMutability:"view"},{type:"function",name:"applicationRegistry",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IApplicationRegistry"}],stateMutability:"view"},{type:"error",name:"ZeroAddress",inputs:[]},{type:"error",name:"Unauthorized",inputs:[]},{type:"error",name:"InvalidAmount",inputs:[]},{type:"error",name:"TransferFailed",inputs:[]},{type:"error",name:"InvalidTransaction",inputs:[]},{type:"error",name:"EmptyPayoutAddress",inputs:[]},{type:"error",name:"PayoutAddressTooLong",inputs:[]},{type:"error",name:"VaultAlreadyExists",inputs:[]},{type:"error",name:"VaultFeeAlreadyEscrowed",inputs:[]},{type:"error",name:"NoEscrowedFees",inputs:[]},{type:"error",name:"BTCVaultNotFound",inputs:[]},{type:"error",name:"InvalidBTCVaultStatus",inputs:[]},{type:"error",name:"PeginNotExpired",inputs:[]},{type:"error",name:"InvalidParticipantsList",inputs:[]},{type:"error",name:"DuplicateParticipant",inputs:[]},{type:"error",name:"ParticipantRoleOverlap",inputs:[]},{type:"error",name:"NotAuthorizedToACK",inputs:[]},{type:"error",name:"UnauthorizedVaultKeeper",inputs:[]},{type:"error",name:"BlocklistedVaultKeeper",inputs:[]},{type:"error",name:"PeginTransactionExpired",inputs:[]},{type:"error",name:"PrePeginOutputAlreadyUsed",inputs:[]},{type:"error",name:"PeginTransactionAlreadyUsed",inputs:[]},{type:"error",name:"InvalidPeginFee",inputs:[{name:"provided",type:"uint256",internalType:"uint256"},{name:"required",type:"uint256",internalType:"uint256"}]},{type:"error",name:"AmountBelowMinimumThreshold",inputs:[{name:"actual",type:"uint256",internalType:"uint256"},{name:"minimum",type:"uint256",internalType:"uint256"}]},{type:"error",name:"InvalidOutputIndex",inputs:[{name:"provided",type:"uint256",internalType:"uint256"},{name:"maxValid",type:"uint256",internalType:"uint256"}]},{type:"error",name:"TooManyHtlcOutputs",inputs:[{name:"outputCount",type:"uint256",internalType:"uint256"},{name:"maxAllowed",type:"uint256",internalType:"uint256"}]},{type:"error",name:"VaultBelowMinimum",inputs:[{name:"actual",type:"uint256",internalType:"uint256"},{name:"minimum",type:"uint256",internalType:"uint256"}]},{type:"error",name:"VaultAboveMaximum",inputs:[{name:"actual",type:"uint256",internalType:"uint256"},{name:"maximum",type:"uint256",internalType:"uint256"}]},{type:"error",name:"InvalidBTCPublicKey",inputs:[]},{type:"error",name:"InvalidDepositorWotsPkHash",inputs:[]},{type:"error",name:"InvalidBTCProofOfPossession",inputs:[]},{type:"error",name:"EthKeyAlreadyRegistered",inputs:[]},{type:"error",name:"BtcKeyAlreadyRegistered",inputs:[]},{type:"error",name:"InvalidRegistrationFee",inputs:[]},{type:"error",name:"CommissionBelowMinimum",inputs:[{name:"provided",type:"uint16",internalType:"uint16"},{name:"minimum",type:"uint16",internalType:"uint16"}]},{type:"error",name:"CommissionAboveMaximum",inputs:[{name:"provided",type:"uint16",internalType:"uint16"}]},{type:"error",name:"CommissionUnchanged",inputs:[]},{type:"error",name:"VaultProviderCommissionExceeded",inputs:[{name:"maxAcceptable",type:"uint16",internalType:"uint16"},{name:"actual",type:"uint16",internalType:"uint16"}]},{type:"error",name:"VaultProviderNotRegistered",inputs:[]},{type:"error",name:"ApplicationAlreadyRegistered",inputs:[]},{type:"error",name:"ApplicationNotRegistered",inputs:[]},{type:"error",name:"ApplicationNotActive",inputs:[]},{type:"error",name:"InvalidApplicationStatus",inputs:[]},{type:"error",name:"OnlyApplicationEntryPoint",inputs:[]},{type:"error",name:"EmptyVaultKeepers",inputs:[]},{type:"error",name:"NoUniversalChallengersConfigured",inputs:[]},{type:"error",name:"NoAppVaultKeepersConfigured",inputs:[]},{type:"error",name:"PeginSignaturesIncomplete",inputs:[]},{type:"error",name:"InvalidSignatureLength",inputs:[]},{type:"error",name:"PeginInputSignatureAlreadySubmitted",inputs:[]},{type:"error",name:"InvalidHashlock",inputs:[]},{type:"error",name:"DuplicateHashlock",inputs:[]},{type:"error",name:"InvalidSecret",inputs:[]},{type:"error",name:"ActivationDeadlineExpired",inputs:[]},{type:"error",name:"ActivationDelayNotElapsed",inputs:[]},{type:"error",name:"PostExpiryGraceWindowElapsed",inputs:[]},{type:"error",name:"CapExceeded",inputs:[]}];exports.BTCVaultRegistryABI=e;
2
- //# sourceMappingURL=BTCVaultRegistry.abi-z7d_eP22.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BTCVaultRegistry.abi-z7d_eP22.cjs","sources":["../src/tbv/core/contracts/abis/BTCVaultRegistry.abi.ts"],"sourcesContent":["/**\n * BTCVaultRegistry Contract ABI\n *\n * Minimal ABI containing only the functions needed by the SDK.\n * Full ABI is available in the vault service package.\n *\n * @module contracts/abis/BTCVaultRegistry\n */\n\n/**\n * Minimal ABI for BTCVaultRegistry contract.\n * Contains submitPeginRequest, submitPeginRequestBatch, activateVaultWithSecret, getPegInFee, getBtcVaultBasicInfo, and getVaultProviderCommission.\n */\nexport const BTCVaultRegistryABI = [\n {\n type: \"function\",\n name: \"submitPeginRequest\",\n inputs: [\n {\n name: \"depositor\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"btcPopSignature\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"unsignedPrePeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"maxAcceptableCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"hashlock\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"htlcVout\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"depositorPayoutBtcAddress\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n stateMutability: \"payable\",\n },\n {\n type: \"function\",\n name: \"submitPeginRequest\",\n inputs: [\n {\n name: \"depositor\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"btcPopSignature\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"unsignedPrePeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"maxAcceptableCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"hashlock\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"htlcVout\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"referralCode\",\n type: \"uint32\",\n internalType: \"uint32\",\n },\n {\n name: \"depositorPayoutBtcAddress\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n stateMutability: \"payable\",\n },\n {\n type: \"function\",\n name: \"submitPeginRequestBatch\",\n inputs: [\n { name: \"depositor\", type: \"address\", internalType: \"address\" },\n { name: \"vaultProvider\", type: \"address\", internalType: \"address\" },\n {\n name: \"maxAcceptableCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"requests\",\n type: \"tuple[]\",\n internalType: \"struct BTCVaultRegistryTypes.BatchPeginRequest[]\",\n components: [\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n { name: \"btcPopSignature\", type: \"bytes\", internalType: \"bytes\" },\n { name: \"unsignedPrePeginTx\", type: \"bytes\", internalType: \"bytes\" },\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n { name: \"hashlock\", type: \"bytes32\", internalType: \"bytes32\" },\n { name: \"htlcVout\", type: \"uint8\", internalType: \"uint8\" },\n { name: \"referralCode\", type: \"uint32\", internalType: \"uint32\" },\n {\n name: \"depositorPayoutBtcAddress\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n },\n ],\n outputs: [\n { name: \"vaultIds\", type: \"bytes32[]\", internalType: \"bytes32[]\" },\n ],\n stateMutability: \"payable\",\n },\n {\n type: \"function\",\n name: \"activateVaultWithSecret\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"s\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"activationMetadata\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"activateVaultWithSecretAndRedeem\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"s\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n type: \"function\",\n name: \"getPegInFee\",\n inputs: [\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n ],\n outputs: [\n {\n name: \"totalFee\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n ],\n stateMutability: \"view\",\n },\n // --- RFC-006 operation-key resolution ---------------------------------\n // A vault provider's BTC key is not a fixed registration key: it is an\n // append-only history of *operation* keys, rotated by the provider's cold ETH\n // admin key. Each vault freezes a `vpKeyEpoch` at `submitPeginRequest` and\n // resolves the key bonded at that epoch, so a later rotation never\n // invalidates a live vault.\n //\n // The dedicated `getVaultProviderBTCKey` / `getVaultProviderKeyPair` getters\n // are deliberately absent: vault-contracts-aave-v4#539 removes them, and\n // keeping them here would let a call compile against a selector the registry\n // no longer exposes. The registration key is read as the operation key at\n // epoch 0 instead — see `getVaultProviderGenesisBtcPubKey`.\n //\n // `getCurrentOperationBtcKey` falls back on-chain to the registration key at\n // version 0, so adopting it is a no-op for a provider that never rotated.\n //\n // `getPayoutScriptAtEpoch` does NOT behave that way, and assuming it did was\n // wrong in an earlier revision of this comment. A payout script is mandatory\n // at registration and stored as version 1, so on an RFC-006 registry this\n // returns the operator's own registered script from the very first epoch —\n // not a BIP-86 derivation of its key. The contract's BIP-86 branch is a\n // migration default for pre-RFC-006 rows and is not reachable from\n // registration. An operator whose registered script happens to equal\n // bip86(key) is a coincidence of what it chose to register, not a fallback.\n //\n // This is why depositor payout validation must accept the legacy BIP-86 form\n // alongside the registered one: a payout graph is built once at BaBe Setup\n // and never rebuilt, so a vault whose graph predates its network's\n // btc-vault#2440 upgrade pays BIP-86 for the rest of its life. See\n // `acceptedPayoutScriptHexes` in `primitives/psbt/payout.ts`.\n {\n type: \"function\",\n name: \"getCurrentOperationBtcKey\",\n inputs: [{ name: \"provider\", type: \"address\", internalType: \"address\" }],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"bytes32\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getOperationBtcKeyAtEpoch\",\n inputs: [\n { name: \"provider\", type: \"address\", internalType: \"address\" },\n { name: \"epoch\", type: \"uint64\", internalType: \"uint64\" },\n ],\n outputs: [{ name: \"\", type: \"bytes32\", internalType: \"bytes32\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getPayoutScriptAtEpoch\",\n inputs: [\n { name: \"provider\", type: \"address\", internalType: \"address\" },\n { name: \"epoch\", type: \"uint64\", internalType: \"uint64\" },\n ],\n outputs: [{ name: \"\", type: \"bytes\", internalType: \"bytes\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getVaultProviderCommission\",\n inputs: [{ name: \"vpAddr\", type: \"address\", internalType: \"address\" }],\n outputs: [{ name: \"\", type: \"uint16\", internalType: \"uint16\" }],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"getBtcVaultBasicInfo\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"vBasic\",\n type: \"tuple\",\n internalType: \"struct BTCVaultTypes.BTCVaultBasicInfo\",\n components: [\n { name: \"depositor\", type: \"address\", internalType: \"address\" },\n {\n name: \"depositorBtcPubKey\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n { name: \"amount\", type: \"uint256\", internalType: \"uint256\" },\n {\n name: \"vaultProvider\",\n type: \"address\",\n internalType: \"address\",\n },\n {\n name: \"status\",\n type: \"uint8\",\n internalType: \"enum IBTCVaultRegistry.BTCVaultStatus\",\n },\n {\n name: \"applicationEntryPoint\",\n type: \"address\",\n internalType: \"address\",\n },\n { name: \"createdAt\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"error\",\n name: \"InvalidPeginFee\",\n inputs: [\n {\n name: \"provided\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"required\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n ],\n },\n {\n type: \"error\",\n name: \"InvalidSecret\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"ActivationDeadlineExpired\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"InvalidHashlock\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"DuplicateHashlock\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"CapExceeded\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"InvalidOutputIndex\",\n inputs: [],\n },\n {\n type: \"error\",\n name: \"PeginSignaturesIncomplete\",\n inputs: [],\n },\n {\n type: \"function\",\n name: \"getBtcVaultProtocolInfo\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"vProtocol\",\n type: \"tuple\",\n internalType: \"struct BTCVaultRegistryTypes.BTCVaultProtocolInfo\",\n components: [\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"universalChallengersVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"appVaultKeepersVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"offchainParamsVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"verifiedAt\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"hashlock\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"htlcVout\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"depositorPopSignature\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"prePeginTxHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"vaultProviderCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"claimExpiredUntil\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"vaultCoreVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"protocolParams\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"address\",\n internalType: \"contract IProtocolParams\",\n },\n ],\n stateMutability: \"view\",\n },\n {\n type: \"function\",\n name: \"applicationRegistry\",\n inputs: [],\n outputs: [\n {\n name: \"\",\n type: \"address\",\n internalType: \"contract IApplicationRegistry\",\n },\n ],\n stateMutability: \"view\",\n },\n // ============================================================================\n // Errors — needed so viem can decode revert data into a named error.\n // Without these, every revert surfaces as \"Execution reverted for an\n // unknown reason.\" Mirrors errors thrown from BTCVaultRegistry's reachable\n // code paths (pegin submission, ACK, activation). Source:\n // https://github.com/babylonlabs-io/vault-contracts-aave-v4/blob/652c4582/src/protocol/lib/types/Errors.sol\n // ============================================================================\n { type: \"error\", name: \"ZeroAddress\", inputs: [] },\n { type: \"error\", name: \"Unauthorized\", inputs: [] },\n { type: \"error\", name: \"InvalidAmount\", inputs: [] },\n { type: \"error\", name: \"TransferFailed\", inputs: [] },\n { type: \"error\", name: \"InvalidTransaction\", inputs: [] },\n { type: \"error\", name: \"EmptyPayoutAddress\", inputs: [] },\n { type: \"error\", name: \"PayoutAddressTooLong\", inputs: [] },\n { type: \"error\", name: \"VaultAlreadyExists\", inputs: [] },\n { type: \"error\", name: \"VaultFeeAlreadyEscrowed\", inputs: [] },\n { type: \"error\", name: \"NoEscrowedFees\", inputs: [] },\n { type: \"error\", name: \"BTCVaultNotFound\", inputs: [] },\n { type: \"error\", name: \"InvalidBTCVaultStatus\", inputs: [] },\n { type: \"error\", name: \"PeginNotExpired\", inputs: [] },\n { type: \"error\", name: \"InvalidParticipantsList\", inputs: [] },\n { type: \"error\", name: \"DuplicateParticipant\", inputs: [] },\n { type: \"error\", name: \"ParticipantRoleOverlap\", inputs: [] },\n { type: \"error\", name: \"NotAuthorizedToACK\", inputs: [] },\n { type: \"error\", name: \"UnauthorizedVaultKeeper\", inputs: [] },\n { type: \"error\", name: \"BlocklistedVaultKeeper\", inputs: [] },\n { type: \"error\", name: \"PeginTransactionExpired\", inputs: [] },\n { type: \"error\", name: \"PrePeginOutputAlreadyUsed\", inputs: [] },\n { type: \"error\", name: \"PeginTransactionAlreadyUsed\", inputs: [] },\n {\n type: \"error\",\n name: \"InvalidPeginFee\",\n inputs: [\n { name: \"provided\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"required\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"AmountBelowMinimumThreshold\",\n inputs: [\n { name: \"actual\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"minimum\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"InvalidOutputIndex\",\n inputs: [\n { name: \"provided\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"maxValid\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"TooManyHtlcOutputs\",\n inputs: [\n { name: \"outputCount\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"maxAllowed\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"VaultBelowMinimum\",\n inputs: [\n { name: \"actual\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"minimum\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n {\n type: \"error\",\n name: \"VaultAboveMaximum\",\n inputs: [\n { name: \"actual\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"maximum\", type: \"uint256\", internalType: \"uint256\" },\n ],\n },\n { type: \"error\", name: \"InvalidBTCPublicKey\", inputs: [] },\n { type: \"error\", name: \"InvalidDepositorWotsPkHash\", inputs: [] },\n { type: \"error\", name: \"InvalidBTCProofOfPossession\", inputs: [] },\n { type: \"error\", name: \"EthKeyAlreadyRegistered\", inputs: [] },\n { type: \"error\", name: \"BtcKeyAlreadyRegistered\", inputs: [] },\n { type: \"error\", name: \"InvalidRegistrationFee\", inputs: [] },\n {\n type: \"error\",\n name: \"CommissionBelowMinimum\",\n inputs: [\n { name: \"provided\", type: \"uint16\", internalType: \"uint16\" },\n { name: \"minimum\", type: \"uint16\", internalType: \"uint16\" },\n ],\n },\n {\n type: \"error\",\n name: \"CommissionAboveMaximum\",\n inputs: [{ name: \"provided\", type: \"uint16\", internalType: \"uint16\" }],\n },\n { type: \"error\", name: \"CommissionUnchanged\", inputs: [] },\n {\n type: \"error\",\n name: \"VaultProviderCommissionExceeded\",\n inputs: [\n { name: \"maxAcceptable\", type: \"uint16\", internalType: \"uint16\" },\n { name: \"actual\", type: \"uint16\", internalType: \"uint16\" },\n ],\n },\n { type: \"error\", name: \"VaultProviderNotRegistered\", inputs: [] },\n { type: \"error\", name: \"ApplicationAlreadyRegistered\", inputs: [] },\n { type: \"error\", name: \"ApplicationNotRegistered\", inputs: [] },\n { type: \"error\", name: \"ApplicationNotActive\", inputs: [] },\n { type: \"error\", name: \"InvalidApplicationStatus\", inputs: [] },\n { type: \"error\", name: \"OnlyApplicationEntryPoint\", inputs: [] },\n { type: \"error\", name: \"EmptyVaultKeepers\", inputs: [] },\n { type: \"error\", name: \"NoUniversalChallengersConfigured\", inputs: [] },\n { type: \"error\", name: \"NoAppVaultKeepersConfigured\", inputs: [] },\n { type: \"error\", name: \"PeginSignaturesIncomplete\", inputs: [] },\n { type: \"error\", name: \"InvalidSignatureLength\", inputs: [] },\n { type: \"error\", name: \"PeginInputSignatureAlreadySubmitted\", inputs: [] },\n { type: \"error\", name: \"InvalidHashlock\", inputs: [] },\n { type: \"error\", name: \"DuplicateHashlock\", inputs: [] },\n { type: \"error\", name: \"InvalidSecret\", inputs: [] },\n { type: \"error\", name: \"ActivationDeadlineExpired\", inputs: [] },\n // Lower bound on activation: reverts while\n // `block.number < verifiedAt + peginActivationDelay`. Clears with time, so\n // unlike ActivationDeadlineExpired it is retryable, not terminal.\n { type: \"error\", name: \"ActivationDelayNotElapsed\", inputs: [] },\n { type: \"error\", name: \"PostExpiryGraceWindowElapsed\", inputs: [] },\n { type: \"error\", name: \"CapExceeded\", inputs: [] },\n] as const;\n"],"names":["BTCVaultRegistryABI"],"mappings":"aAaO,MAAMA,EAAsB,CACjC,CACE,KAAM,WACN,KAAM,qBACN,OAAQ,CACN,CACE,KAAM,YACN,KAAM,UACN,aAAc,SAAA,EAEhB,CACE,KAAM,qBACN,KAAM,UACN,aAAc,SAAA,EAEhB,CACE,KAAM,kBACN,KAAM,QACN,aAAc,OAAA,EAEhB,CACE,KAAM,qBACN,KAAM,QACN,aAAc,OAAA,EAEhB,CACE,KAAM,yBACN,KAAM,QACN,aAAc,OAAA,EAEhB,CACE,KAAM,gBACN,KAAM,UACN,aAAc,SAAA,EAEhB,CACE,KAAM,6BACN,KAAM,SACN,aAAc,QAAA,EAEhB,CACE,KAAM,WACN,KAAM,UACN,aAAc,SAAA,EAEhB,CACE,KAAM,WACN,KAAM,QACN,aAAc,OAAA,EAEhB,CACE,KAAM,4BACN,KAAM,QACN,aAAc,OAAA,EAEhB,CACE,KAAM,sBACN,KAAM,UACN,aAAc,SAAA,CAChB,EAEF,QAAS,CACP,CACE,KAAM,GACN,KAAM,UACN,aAAc,SAAA,CAChB,EAEF,gBAAiB,SAAA,EAEnB,CACE,KAAM,WACN,KAAM,qBACN,OAAQ,CACN,CACE,KAAM,YACN,KAAM,UACN,aAAc,SAAA,EAEhB,CACE,KAAM,qBACN,KAAM,UACN,aAAc,SAAA,EAEhB,CACE,KAAM,kBACN,KAAM,QACN,aAAc,OAAA,EAEhB,CACE,KAAM,qBACN,KAAM,QACN,aAAc,OAAA,EAEhB,CACE,KAAM,yBACN,KAAM,QACN,aAAc,OAAA,EAEhB,CACE,KAAM,gBACN,KAAM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Q,CAAA,CAAC,EAChE,CAAE,KAAM,QAAS,KAAM,cAAe,OAAQ,CAAA,CAAC,CACjD"}
@@ -1,2 +0,0 @@
1
- "use strict";const i={"0x04aabf33":"Vault already exists: This Bitcoin transaction has already been registered. Please select different UTXOs or use a different amount to create a unique transaction.","0x4fec082d":"Script mismatch: The Bitcoin transaction's taproot output does not match the expected vault script. This may be caused by incorrect vault participants or key configuration.","0x6cc363a5":"Invalid BTC proof of possession: The signature could not be verified. Please ensure you're signing with the correct Bitcoin wallet.","0x6c3f2bf6":"Invalid BTC public key: The Bitcoin public key format is invalid.","0x2c5211c6":"Invalid amount: The deposit amount is invalid or below the minimum required.","0x0405f772":"Application not registered: The application controller is not registered in the system.","0x24e165cc":"Invalid provider status: The vault provider is not in a valid state to accept deposits.","0xd92e233d":"Zero address: One of the required addresses is the zero address.","0x65aa7007":"BTC key mismatch: The Bitcoin public key does not match the expected key.","0x82b42900":"Unauthorized: You must be the depositor or vault provider to submit this transaction.","0x8baa579f":"Invalid signature: The BTC proof of possession signature could not be verified.","0x2f9d01e9":"Invalid BTC transaction: The Bitcoin transaction format is invalid.","0x5a3c6b3e":"Vault provider not registered: The selected vault provider is not registered.","0x979f4518":"Invalid pegin fee: The ETH fee sent does not match the required amount. This may indicate a fee rate change during the transaction.","0x5fad9694":"This pre-pegin output has already been used to activate another vault.","0x7ed061c9":"This pegin transaction has already been used to activate another vault.","0x70f7d5e2":"Duplicate deposit: a BTC Vault with this hashlock is already registered to your wallet. Hashlocks are derived from your BTC wallet and selected UTXOs — use different UTXOs to create a unique deposit."};function o(t){return s(t,0)}function s(t,r){if(r>10||!t||typeof t!="object")return;const e=t;if(typeof e.data=="string"&&e.data.startsWith("0x"))return e.data;if(typeof e.revertData=="string"&&e.revertData.startsWith("0x"))return e.revertData;if(typeof e.signature=="string"&&e.signature.startsWith("0x"))return e.signature;if(typeof e.details=="string"&&e.details.startsWith("0x"))return e.details;if(e.error&&typeof e.error=="object"){const n=e.error.data;if(typeof n=="string"&&n.startsWith("0x"))return n}if(e.cause){const n=s(e.cause,r+1);if(n)return n}if(typeof e.walk=="function")try{let n;if(e.walk(a=>{if(a===t)return!1;const c=s(a,r+1);return c?(n=c,!0):!1}),n)return n}catch{}if(r===0){const a=(typeof e.message=="string"?e.message:"").match(/\b(0x[a-fA-F0-9]{8})\b/);if(a)return a[1]}}function u(t){const r=o(t);if(r){const e=r.substring(0,10);return i[r]??i[e]}}function l(t){const r=o(t);if(r===void 0)return!1;const e=r.substring(0,10);return r in i||e in i}function d(t){console.error("[Contract Error] Raw error:",t);const r=o(t);if(console.error("[Contract Error] Extracted error data:",r),r){const n=r.substring(0,10),a=i[r]??i[n];if(a)throw console.error("[Contract Error] Known error:",a),new Error(a)}const e=(t==null?void 0:t.message)||"";if(e.includes("gas limit too high")||e.includes("21000000")||e.includes("Internal JSON-RPC error")){const n=r?` (error code: ${r})`:"";throw console.error("[Contract Error] Transaction rejected. Error code:",r,"Message:",e),new Error(`Transaction failed: The contract rejected this transaction${n}. Possible causes: (1) Vault already exists for this transaction, (2) Invalid signature, (3) Unauthorized caller. Please check your transaction parameters and try again.`)}throw t instanceof Error?(console.error("[Contract Error] Unhandled error:",t.message),t):new Error(`Contract call failed: ${String(t)}`)}const p=[{type:"function",name:"getBtcVaultProtocolInfo",inputs:[{name:"vaultId",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"vProtocol",type:"tuple",internalType:"struct BTCVaultRegistryTypes.BTCVaultProtocolInfo",components:[{name:"depositorSignedPeginTx",type:"bytes",internalType:"bytes"},{name:"universalChallengersVersion",type:"uint16",internalType:"uint16"},{name:"appVaultKeepersVersion",type:"uint16",internalType:"uint16"},{name:"offchainParamsVersion",type:"uint16",internalType:"uint16"},{name:"verifiedAt",type:"uint256",internalType:"uint256"},{name:"depositorWotsPkHash",type:"bytes32",internalType:"bytes32"},{name:"hashlock",type:"bytes32",internalType:"bytes32"},{name:"htlcVout",type:"uint8",internalType:"uint8"},{name:"depositorPopSignature",type:"bytes",internalType:"bytes"},{name:"prePeginTxHash",type:"bytes32",internalType:"bytes32"},{name:"vaultProviderCommissionBps",type:"uint16",internalType:"uint16"},{name:"claimExpiredUntil",type:"uint256",internalType:"uint256"},{name:"vaultCoreVersion",type:"uint16",internalType:"uint16"},{name:"vpKeyEpoch",type:"uint64",internalType:"uint64"},{name:"appKeeperKeyEpoch",type:"uint64",internalType:"uint64"},{name:"ucKeyEpoch",type:"uint64",internalType:"uint64"}]}],stateMutability:"view"}];exports.BTCVaultRegistryKeyEpochsABI=p;exports.CONTRACT_ERRORS=i;exports.extractErrorData=o;exports.getContractErrorMessage=u;exports.handleContractError=d;exports.isKnownContractError=l;
2
- //# sourceMappingURL=BTCVaultRegistryKeyEpochs.abi-CrQiTLfA.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BTCVaultRegistryKeyEpochs.abi-CrQiTLfA.cjs","sources":["../src/tbv/core/contracts/errors.ts","../src/tbv/core/contracts/abis/BTCVaultRegistryKeyEpochs.abi.ts"],"sourcesContent":["/**\n * Contract Error Handling Utilities\n *\n * Provides utilities for extracting and handling contract revert errors.\n * Maps known error selectors to user-friendly messages.\n *\n * @module contracts/errors\n */\n\n/**\n * Known contract error signatures mapped to user-friendly messages.\n *\n * Error selectors are the first 4 bytes of keccak256(error signature).\n * Example: keccak256(\"VaultAlreadyExists()\") = 0x04aabf33...\n */\nexport const CONTRACT_ERRORS: Record<string, string> = {\n // VaultAlreadyExists()\n \"0x04aabf33\":\n \"Vault already exists: This Bitcoin transaction has already been registered. \" +\n \"Please select different UTXOs or use a different amount to create a unique transaction.\",\n // ScriptPubKeyMismatch() - taproot output doesn't match expected script\n \"0x4fec082d\":\n \"Script mismatch: The Bitcoin transaction's taproot output does not match the expected vault script. \" +\n \"This may be caused by incorrect vault participants or key configuration.\",\n // InvalidBTCProofOfPossession()\n \"0x6cc363a5\":\n \"Invalid BTC proof of possession: The signature could not be verified. \" +\n \"Please ensure you're signing with the correct Bitcoin wallet.\",\n // InvalidBTCPublicKey()\n \"0x6c3f2bf6\":\n \"Invalid BTC public key: The Bitcoin public key format is invalid.\",\n // InvalidAmount()\n \"0x2c5211c6\":\n \"Invalid amount: The deposit amount is invalid or below the minimum required.\",\n // ApplicationNotRegistered()\n \"0x0405f772\":\n \"Application not registered: The application controller is not registered in the system.\",\n // InvalidProviderStatus()\n \"0x24e165cc\":\n \"Invalid provider status: The vault provider is not in a valid state to accept deposits.\",\n // ZeroAddress()\n \"0xd92e233d\":\n \"Zero address: One of the required addresses is the zero address.\",\n // BtcKeyMismatch()\n \"0x65aa7007\":\n \"BTC key mismatch: The Bitcoin public key does not match the expected key.\",\n // Unauthorized()\n \"0x82b42900\":\n \"Unauthorized: You must be the depositor or vault provider to submit this transaction.\",\n // InvalidSignature() - common signature verification error\n \"0x8baa579f\":\n \"Invalid signature: The BTC proof of possession signature could not be verified.\",\n // InvalidBtcTransaction()\n \"0x2f9d01e9\":\n \"Invalid BTC transaction: The Bitcoin transaction format is invalid.\",\n // VaultProviderNotRegistered()\n \"0x5a3c6b3e\":\n \"Vault provider not registered: The selected vault provider is not registered.\",\n // InvalidPeginFee(uint256,uint256)\n \"0x979f4518\":\n \"Invalid pegin fee: The ETH fee sent does not match the required amount. \" +\n \"This may indicate a fee rate change during the transaction.\",\n // PrePeginOutputAlreadyUsed()\n \"0x5fad9694\":\n \"This pre-pegin output has already been used to activate another vault.\",\n // PeginTransactionAlreadyUsed()\n \"0x7ed061c9\":\n \"This pegin transaction has already been used to activate another vault.\",\n // DuplicateHashlock() — keccak256(abi.encodePacked(hashlock, msg.sender))\n // collision in BTCVaultRegistry.hashlockToVaultId. Hashlocks are derived\n // deterministically from the depositor's BTC wallet + selected UTXOs, so\n // reusing the same UTXOs from the same wallet (even after a previous\n // vault expires) produces the same hashlock and reverts here.\n \"0x70f7d5e2\":\n \"Duplicate deposit: a BTC Vault with this hashlock is already registered to your wallet. Hashlocks are derived from your BTC wallet and selected UTXOs — use different UTXOs to create a unique deposit.\",\n};\n\n/**\n * Extract error data from various error formats.\n *\n * Viem and wallet providers wrap errors in multiple levels. This function\n * searches through the error chain to find the revert data.\n *\n * @param error - The error object to extract data from\n * @returns The error data (e.g., \"0x04aabf33\") or undefined\n */\nexport function extractErrorData(error: unknown): string | undefined {\n return walkForErrorData(error, 0);\n}\n\n/**\n * Walk an error chain looking for revert data in any of viem 2.x's known\n * shapes. Covers:\n * - `.data: \"0x...\"` — raw revert hex (most common with `estimateGas`)\n * - `.revertData: \"0x...\"` — alternate viem shape\n * - `.signature: \"0x...\"` — 4-byte selector from a *decoded*\n * ContractFunctionRevertedError (set when the ABI included the error def)\n * - `.error.data: \"0x...\"` — RPC-level error shape from some providers\n * - `.walk(fn)` — viem's chainable error walker (BaseError.walk)\n * - `.cause` chain — viem wraps errors many layers deep\n *\n * Depth-limited (10) and walk-result-deduplicated so a cycle can't loop.\n */\nfunction walkForErrorData(\n error: unknown,\n depth: number,\n): string | undefined {\n if (depth > 10 || !error || typeof error !== \"object\") return undefined;\n\n const err = error as Record<string, unknown>;\n\n if (typeof err.data === \"string\" && err.data.startsWith(\"0x\")) {\n return err.data;\n }\n if (typeof err.revertData === \"string\" && err.revertData.startsWith(\"0x\")) {\n return err.revertData;\n }\n if (typeof err.signature === \"string\" && err.signature.startsWith(\"0x\")) {\n return err.signature;\n }\n if (typeof err.details === \"string\" && err.details.startsWith(\"0x\")) {\n return err.details;\n }\n\n // RPC-level error shape (`{ error: { data: \"0x...\" } }`)\n if (err.error && typeof err.error === \"object\") {\n const inner = (err.error as Record<string, unknown>).data;\n if (typeof inner === \"string\" && inner.startsWith(\"0x\")) {\n return inner;\n }\n }\n\n // Recurse through `.cause`\n if (err.cause) {\n const fromCause = walkForErrorData(err.cause, depth + 1);\n if (fromCause) return fromCause;\n }\n\n // Use viem's `.walk()` if available\n if (typeof err.walk === \"function\") {\n try {\n let found: string | undefined;\n (err.walk as (fn: (e: unknown) => boolean) => unknown)((e) => {\n if (e === error) return false; // avoid self-cycle\n const data = walkForErrorData(e, depth + 1);\n if (data) {\n found = data;\n return true;\n }\n return false;\n });\n if (found) return found;\n } catch {\n // walk failed; ignore\n }\n }\n\n // Last resort: regex an embedded hex selector out of the message\n if (depth === 0) {\n const message = typeof err.message === \"string\" ? err.message : \"\";\n const hexMatch = message.match(/\\b(0x[a-fA-F0-9]{8})\\b/);\n if (hexMatch) return hexMatch[1];\n }\n\n return undefined;\n}\n\n/**\n * Get a user-friendly error message for a contract error.\n *\n * @param error - The error object from a contract call\n * @returns A user-friendly error message, or undefined if error is not recognized\n */\nexport function getContractErrorMessage(error: unknown): string | undefined {\n const errorData = extractErrorData(error);\n if (errorData) {\n // Check exact match first, then match by 4-byte selector prefix.\n // Parametric errors (e.g. InvalidPeginFee(uint256,uint256)) return\n // the selector + ABI-encoded args, so the full string won't match.\n const selector = errorData.substring(0, 10); // \"0x\" + 4 bytes\n return CONTRACT_ERRORS[errorData] ?? CONTRACT_ERRORS[selector];\n }\n return undefined;\n}\n\n/**\n * Check if an error is a known contract error.\n *\n * @param error - The error object to check\n * @returns True if the error is a known contract error\n */\nexport function isKnownContractError(error: unknown): boolean {\n const errorData = extractErrorData(error);\n if (errorData === undefined) return false;\n const selector = errorData.substring(0, 10);\n return errorData in CONTRACT_ERRORS || selector in CONTRACT_ERRORS;\n}\n\n/**\n * Handle a contract error by throwing a user-friendly error.\n *\n * This function extracts error data, maps it to a user-friendly message,\n * and throws an appropriate error. Use this in catch blocks after contract calls.\n *\n * @param error - The error from a contract call\n * @throws Always throws an error with a descriptive message\n */\nexport function handleContractError(error: unknown): never {\n // Log full error for debugging\n console.error(\"[Contract Error] Raw error:\", error);\n\n // Extract error data from the error chain\n const errorData = extractErrorData(error);\n console.error(\"[Contract Error] Extracted error data:\", errorData);\n\n // Check for known contract error signatures (exact match or 4-byte selector prefix)\n if (errorData) {\n const selector = errorData.substring(0, 10);\n const knownError = CONTRACT_ERRORS[errorData] ?? CONTRACT_ERRORS[selector];\n if (knownError) {\n console.error(\"[Contract Error] Known error:\", knownError);\n throw new Error(knownError);\n }\n }\n\n // Check for gas estimation errors or internal JSON-RPC errors\n const errorMsg = (error as Error)?.message || \"\";\n if (\n errorMsg.includes(\"gas limit too high\") ||\n errorMsg.includes(\"21000000\") ||\n errorMsg.includes(\"Internal JSON-RPC error\")\n ) {\n // If we found error data but it's not in our known list, include it\n const errorHint = errorData ? ` (error code: ${errorData})` : \"\";\n console.error(\n \"[Contract Error] Transaction rejected. Error code:\",\n errorData,\n \"Message:\",\n errorMsg,\n );\n throw new Error(\n `Transaction failed: The contract rejected this transaction${errorHint}. ` +\n \"Possible causes: (1) Vault already exists for this transaction, \" +\n \"(2) Invalid signature, (3) Unauthorized caller. \" +\n \"Please check your transaction parameters and try again.\",\n );\n }\n\n // Default: re-throw original error with better context\n if (error instanceof Error) {\n console.error(\"[Contract Error] Unhandled error:\", error.message);\n throw error;\n }\n throw new Error(`Contract call failed: ${String(error)}`);\n}\n","/**\n * BTCVaultRegistry ABI — RFC-006 key-epoch view of `getBtcVaultProtocolInfo`.\n *\n * This is a deliberate second copy of a single function entry, NOT a\n * convenience re-export, and it must never be merged into\n * `BTCVaultRegistryABI`.\n *\n * `getBtcVaultProtocolInfo` returns a *positional* tuple. RFC-006 appended\n * three `uint64` epoch fields (`vpKeyEpoch`, `appKeeperKeyEpoch`,\n * `ucKeyEpoch`) after `vaultCoreVersion`. Declaring those three components\n * against a registry that predates RFC-006 makes viem read past the end of\n * the returndata and throw — and because the shared reader batches this call\n * through `multicall({ allowFailure: false })`, one bad decode fails the\n * whole batch. That would break vault status, resume, payout and refund\n * app-wide, on every network whose registry has not been upgraded yet.\n *\n * So the shared `BTCVaultRegistryABI` keeps the 13-field shape that decodes\n * against every deployed registry, and the extended shape lives here, read\n * only by `ViemVaultRegistryReader.getVaultKeyEpochs*` on the epoch-aware\n * path. Reading the same call through two ABIs is the price of keeping the\n * shared decode path independent of the registry version.\n *\n * The 13 shared components must stay an exact prefix of the 16 below;\n * `__tests__/abi-key-epochs.test.ts` pins that.\n *\n * Generated from vault-contracts-aave-v4\n * `src/protocol/lib/types/BTCVaultRegistryTypes.sol`.\n *\n * @module contracts/abis/BTCVaultRegistryKeyEpochs\n */\n\nexport const BTCVaultRegistryKeyEpochsABI = [\n {\n type: \"function\",\n name: \"getBtcVaultProtocolInfo\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"vProtocol\",\n type: \"tuple\",\n internalType: \"struct BTCVaultRegistryTypes.BTCVaultProtocolInfo\",\n components: [\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"universalChallengersVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"appVaultKeepersVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"offchainParamsVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"verifiedAt\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"hashlock\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"htlcVout\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"depositorPopSignature\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"prePeginTxHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"vaultProviderCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"claimExpiredUntil\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"vaultCoreVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n // RFC-006: per-pegin operation-key epochs, frozen at\n // `submitPeginRequest`. All three pack into one storage slot and were\n // appended after `vaultCoreVersion` so pre-existing rows decode\n // unchanged.\n {\n name: \"vpKeyEpoch\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"appKeeperKeyEpoch\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"ucKeyEpoch\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n] as const;\n"],"names":["CONTRACT_ERRORS","extractErrorData","error","walkForErrorData","depth","err","inner","fromCause","found","e","data","hexMatch","getContractErrorMessage","errorData","selector","isKnownContractError","handleContractError","knownError","errorMsg","errorHint","BTCVaultRegistryKeyEpochsABI"],"mappings":"aAeO,MAAMA,EAA0C,CAErD,aACE,sKAGF,aACE,+KAGF,aACE,sIAGF,aACE,oEAEF,aACE,+EAEF,aACE,0FAEF,aACE,0FAEF,aACE,mEAEF,aACE,4EAEF,aACE,wFAEF,aACE,kFAEF,aACE,sEAEF,aACE,gFAEF,aACE,sIAGF,aACE,yEAEF,aACE,0EAMF,aACE,yMACJ,EAWO,SAASC,EAAiBC,EAAoC,CACnE,OAAOC,EAAiBD,EAAO,CAAC,CAClC,CAeA,SAASC,EACPD,EACAE,EACoB,CACpB,GAAIA,EAAQ,IAAM,CAACF,GAAS,OAAOA,GAAU,SAAU,OAEvD,MAAMG,EAAMH,EAEZ,GAAI,OAAOG,EAAI,MAAS,UAAYA,EAAI,KAAK,WAAW,IAAI,EAC1D,OAAOA,EAAI,KAEb,GAAI,OAAOA,EAAI,YAAe,UAAYA,EAAI,WAAW,WAAW,IAAI,EACtE,OAAOA,EAAI,WAEb,GAAI,OAAOA,EAAI,WAAc,UAAYA,EAAI,UAAU,WAAW,IAAI,EACpE,OAAOA,EAAI,UAEb,GAAI,OAAOA,EAAI,SAAY,UAAYA,EAAI,QAAQ,WAAW,IAAI,EAChE,OAAOA,EAAI,QAIb,GAAIA,EAAI,OAAS,OAAOA,EAAI,OAAU,SAAU,CAC9C,MAAMC,EAASD,EAAI,MAAkC,KACrD,GAAI,OAAOC,GAAU,UAAYA,EAAM,WAAW,IAAI,EACpD,OAAOA,CAEX,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,QAAA,EAEhB,CACE,KAAM,oBACN,KAAM,SACN,aAAc,QAAA,EAEhB,CACE,KAAM,aACN,KAAM,SACN,aAAc,QAAA,CAChB,CACF,CACF,EAEF,gBAAiB,MAAA,CAErB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"BTCVaultRegistryKeyEpochs.abi-D8cIbMtH.js","sources":["../src/tbv/core/contracts/errors.ts","../src/tbv/core/contracts/abis/BTCVaultRegistryKeyEpochs.abi.ts"],"sourcesContent":["/**\n * Contract Error Handling Utilities\n *\n * Provides utilities for extracting and handling contract revert errors.\n * Maps known error selectors to user-friendly messages.\n *\n * @module contracts/errors\n */\n\n/**\n * Known contract error signatures mapped to user-friendly messages.\n *\n * Error selectors are the first 4 bytes of keccak256(error signature).\n * Example: keccak256(\"VaultAlreadyExists()\") = 0x04aabf33...\n */\nexport const CONTRACT_ERRORS: Record<string, string> = {\n // VaultAlreadyExists()\n \"0x04aabf33\":\n \"Vault already exists: This Bitcoin transaction has already been registered. \" +\n \"Please select different UTXOs or use a different amount to create a unique transaction.\",\n // ScriptPubKeyMismatch() - taproot output doesn't match expected script\n \"0x4fec082d\":\n \"Script mismatch: The Bitcoin transaction's taproot output does not match the expected vault script. \" +\n \"This may be caused by incorrect vault participants or key configuration.\",\n // InvalidBTCProofOfPossession()\n \"0x6cc363a5\":\n \"Invalid BTC proof of possession: The signature could not be verified. \" +\n \"Please ensure you're signing with the correct Bitcoin wallet.\",\n // InvalidBTCPublicKey()\n \"0x6c3f2bf6\":\n \"Invalid BTC public key: The Bitcoin public key format is invalid.\",\n // InvalidAmount()\n \"0x2c5211c6\":\n \"Invalid amount: The deposit amount is invalid or below the minimum required.\",\n // ApplicationNotRegistered()\n \"0x0405f772\":\n \"Application not registered: The application controller is not registered in the system.\",\n // InvalidProviderStatus()\n \"0x24e165cc\":\n \"Invalid provider status: The vault provider is not in a valid state to accept deposits.\",\n // ZeroAddress()\n \"0xd92e233d\":\n \"Zero address: One of the required addresses is the zero address.\",\n // BtcKeyMismatch()\n \"0x65aa7007\":\n \"BTC key mismatch: The Bitcoin public key does not match the expected key.\",\n // Unauthorized()\n \"0x82b42900\":\n \"Unauthorized: You must be the depositor or vault provider to submit this transaction.\",\n // InvalidSignature() - common signature verification error\n \"0x8baa579f\":\n \"Invalid signature: The BTC proof of possession signature could not be verified.\",\n // InvalidBtcTransaction()\n \"0x2f9d01e9\":\n \"Invalid BTC transaction: The Bitcoin transaction format is invalid.\",\n // VaultProviderNotRegistered()\n \"0x5a3c6b3e\":\n \"Vault provider not registered: The selected vault provider is not registered.\",\n // InvalidPeginFee(uint256,uint256)\n \"0x979f4518\":\n \"Invalid pegin fee: The ETH fee sent does not match the required amount. \" +\n \"This may indicate a fee rate change during the transaction.\",\n // PrePeginOutputAlreadyUsed()\n \"0x5fad9694\":\n \"This pre-pegin output has already been used to activate another vault.\",\n // PeginTransactionAlreadyUsed()\n \"0x7ed061c9\":\n \"This pegin transaction has already been used to activate another vault.\",\n // DuplicateHashlock() — keccak256(abi.encodePacked(hashlock, msg.sender))\n // collision in BTCVaultRegistry.hashlockToVaultId. Hashlocks are derived\n // deterministically from the depositor's BTC wallet + selected UTXOs, so\n // reusing the same UTXOs from the same wallet (even after a previous\n // vault expires) produces the same hashlock and reverts here.\n \"0x70f7d5e2\":\n \"Duplicate deposit: a BTC Vault with this hashlock is already registered to your wallet. Hashlocks are derived from your BTC wallet and selected UTXOs — use different UTXOs to create a unique deposit.\",\n};\n\n/**\n * Extract error data from various error formats.\n *\n * Viem and wallet providers wrap errors in multiple levels. This function\n * searches through the error chain to find the revert data.\n *\n * @param error - The error object to extract data from\n * @returns The error data (e.g., \"0x04aabf33\") or undefined\n */\nexport function extractErrorData(error: unknown): string | undefined {\n return walkForErrorData(error, 0);\n}\n\n/**\n * Walk an error chain looking for revert data in any of viem 2.x's known\n * shapes. Covers:\n * - `.data: \"0x...\"` — raw revert hex (most common with `estimateGas`)\n * - `.revertData: \"0x...\"` — alternate viem shape\n * - `.signature: \"0x...\"` — 4-byte selector from a *decoded*\n * ContractFunctionRevertedError (set when the ABI included the error def)\n * - `.error.data: \"0x...\"` — RPC-level error shape from some providers\n * - `.walk(fn)` — viem's chainable error walker (BaseError.walk)\n * - `.cause` chain — viem wraps errors many layers deep\n *\n * Depth-limited (10) and walk-result-deduplicated so a cycle can't loop.\n */\nfunction walkForErrorData(\n error: unknown,\n depth: number,\n): string | undefined {\n if (depth > 10 || !error || typeof error !== \"object\") return undefined;\n\n const err = error as Record<string, unknown>;\n\n if (typeof err.data === \"string\" && err.data.startsWith(\"0x\")) {\n return err.data;\n }\n if (typeof err.revertData === \"string\" && err.revertData.startsWith(\"0x\")) {\n return err.revertData;\n }\n if (typeof err.signature === \"string\" && err.signature.startsWith(\"0x\")) {\n return err.signature;\n }\n if (typeof err.details === \"string\" && err.details.startsWith(\"0x\")) {\n return err.details;\n }\n\n // RPC-level error shape (`{ error: { data: \"0x...\" } }`)\n if (err.error && typeof err.error === \"object\") {\n const inner = (err.error as Record<string, unknown>).data;\n if (typeof inner === \"string\" && inner.startsWith(\"0x\")) {\n return inner;\n }\n }\n\n // Recurse through `.cause`\n if (err.cause) {\n const fromCause = walkForErrorData(err.cause, depth + 1);\n if (fromCause) return fromCause;\n }\n\n // Use viem's `.walk()` if available\n if (typeof err.walk === \"function\") {\n try {\n let found: string | undefined;\n (err.walk as (fn: (e: unknown) => boolean) => unknown)((e) => {\n if (e === error) return false; // avoid self-cycle\n const data = walkForErrorData(e, depth + 1);\n if (data) {\n found = data;\n return true;\n }\n return false;\n });\n if (found) return found;\n } catch {\n // walk failed; ignore\n }\n }\n\n // Last resort: regex an embedded hex selector out of the message\n if (depth === 0) {\n const message = typeof err.message === \"string\" ? err.message : \"\";\n const hexMatch = message.match(/\\b(0x[a-fA-F0-9]{8})\\b/);\n if (hexMatch) return hexMatch[1];\n }\n\n return undefined;\n}\n\n/**\n * Get a user-friendly error message for a contract error.\n *\n * @param error - The error object from a contract call\n * @returns A user-friendly error message, or undefined if error is not recognized\n */\nexport function getContractErrorMessage(error: unknown): string | undefined {\n const errorData = extractErrorData(error);\n if (errorData) {\n // Check exact match first, then match by 4-byte selector prefix.\n // Parametric errors (e.g. InvalidPeginFee(uint256,uint256)) return\n // the selector + ABI-encoded args, so the full string won't match.\n const selector = errorData.substring(0, 10); // \"0x\" + 4 bytes\n return CONTRACT_ERRORS[errorData] ?? CONTRACT_ERRORS[selector];\n }\n return undefined;\n}\n\n/**\n * Check if an error is a known contract error.\n *\n * @param error - The error object to check\n * @returns True if the error is a known contract error\n */\nexport function isKnownContractError(error: unknown): boolean {\n const errorData = extractErrorData(error);\n if (errorData === undefined) return false;\n const selector = errorData.substring(0, 10);\n return errorData in CONTRACT_ERRORS || selector in CONTRACT_ERRORS;\n}\n\n/**\n * Handle a contract error by throwing a user-friendly error.\n *\n * This function extracts error data, maps it to a user-friendly message,\n * and throws an appropriate error. Use this in catch blocks after contract calls.\n *\n * @param error - The error from a contract call\n * @throws Always throws an error with a descriptive message\n */\nexport function handleContractError(error: unknown): never {\n // Log full error for debugging\n console.error(\"[Contract Error] Raw error:\", error);\n\n // Extract error data from the error chain\n const errorData = extractErrorData(error);\n console.error(\"[Contract Error] Extracted error data:\", errorData);\n\n // Check for known contract error signatures (exact match or 4-byte selector prefix)\n if (errorData) {\n const selector = errorData.substring(0, 10);\n const knownError = CONTRACT_ERRORS[errorData] ?? CONTRACT_ERRORS[selector];\n if (knownError) {\n console.error(\"[Contract Error] Known error:\", knownError);\n throw new Error(knownError);\n }\n }\n\n // Check for gas estimation errors or internal JSON-RPC errors\n const errorMsg = (error as Error)?.message || \"\";\n if (\n errorMsg.includes(\"gas limit too high\") ||\n errorMsg.includes(\"21000000\") ||\n errorMsg.includes(\"Internal JSON-RPC error\")\n ) {\n // If we found error data but it's not in our known list, include it\n const errorHint = errorData ? ` (error code: ${errorData})` : \"\";\n console.error(\n \"[Contract Error] Transaction rejected. Error code:\",\n errorData,\n \"Message:\",\n errorMsg,\n );\n throw new Error(\n `Transaction failed: The contract rejected this transaction${errorHint}. ` +\n \"Possible causes: (1) Vault already exists for this transaction, \" +\n \"(2) Invalid signature, (3) Unauthorized caller. \" +\n \"Please check your transaction parameters and try again.\",\n );\n }\n\n // Default: re-throw original error with better context\n if (error instanceof Error) {\n console.error(\"[Contract Error] Unhandled error:\", error.message);\n throw error;\n }\n throw new Error(`Contract call failed: ${String(error)}`);\n}\n","/**\n * BTCVaultRegistry ABI — RFC-006 key-epoch view of `getBtcVaultProtocolInfo`.\n *\n * This is a deliberate second copy of a single function entry, NOT a\n * convenience re-export, and it must never be merged into\n * `BTCVaultRegistryABI`.\n *\n * `getBtcVaultProtocolInfo` returns a *positional* tuple. RFC-006 appended\n * three `uint64` epoch fields (`vpKeyEpoch`, `appKeeperKeyEpoch`,\n * `ucKeyEpoch`) after `vaultCoreVersion`. Declaring those three components\n * against a registry that predates RFC-006 makes viem read past the end of\n * the returndata and throw — and because the shared reader batches this call\n * through `multicall({ allowFailure: false })`, one bad decode fails the\n * whole batch. That would break vault status, resume, payout and refund\n * app-wide, on every network whose registry has not been upgraded yet.\n *\n * So the shared `BTCVaultRegistryABI` keeps the 13-field shape that decodes\n * against every deployed registry, and the extended shape lives here, read\n * only by `ViemVaultRegistryReader.getVaultKeyEpochs*` on the epoch-aware\n * path. Reading the same call through two ABIs is the price of keeping the\n * shared decode path independent of the registry version.\n *\n * The 13 shared components must stay an exact prefix of the 16 below;\n * `__tests__/abi-key-epochs.test.ts` pins that.\n *\n * Generated from vault-contracts-aave-v4\n * `src/protocol/lib/types/BTCVaultRegistryTypes.sol`.\n *\n * @module contracts/abis/BTCVaultRegistryKeyEpochs\n */\n\nexport const BTCVaultRegistryKeyEpochsABI = [\n {\n type: \"function\",\n name: \"getBtcVaultProtocolInfo\",\n inputs: [\n {\n name: \"vaultId\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n ],\n outputs: [\n {\n name: \"vProtocol\",\n type: \"tuple\",\n internalType: \"struct BTCVaultRegistryTypes.BTCVaultProtocolInfo\",\n components: [\n {\n name: \"depositorSignedPeginTx\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"universalChallengersVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"appVaultKeepersVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"offchainParamsVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"verifiedAt\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"depositorWotsPkHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"hashlock\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"htlcVout\",\n type: \"uint8\",\n internalType: \"uint8\",\n },\n {\n name: \"depositorPopSignature\",\n type: \"bytes\",\n internalType: \"bytes\",\n },\n {\n name: \"prePeginTxHash\",\n type: \"bytes32\",\n internalType: \"bytes32\",\n },\n {\n name: \"vaultProviderCommissionBps\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n {\n name: \"claimExpiredUntil\",\n type: \"uint256\",\n internalType: \"uint256\",\n },\n {\n name: \"vaultCoreVersion\",\n type: \"uint16\",\n internalType: \"uint16\",\n },\n // RFC-006: per-pegin operation-key epochs, frozen at\n // `submitPeginRequest`. All three pack into one storage slot and were\n // appended after `vaultCoreVersion` so pre-existing rows decode\n // unchanged.\n {\n name: \"vpKeyEpoch\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"appKeeperKeyEpoch\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n {\n name: \"ucKeyEpoch\",\n type: \"uint64\",\n internalType: \"uint64\",\n },\n ],\n },\n ],\n stateMutability: \"view\",\n },\n] as const;\n"],"names":["CONTRACT_ERRORS","extractErrorData","error","walkForErrorData","depth","err","inner","fromCause","found","e","data","hexMatch","getContractErrorMessage","errorData","selector","isKnownContractError","handleContractError","knownError","errorMsg","errorHint","BTCVaultRegistryKeyEpochsABI"],"m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M;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,UAEhB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,UAEhB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,UAEhB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,UAEhB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,UAEhB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAMhB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,UAEhB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,UAEhB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,cAAc;AAAA,UAAA;AAAA,QAChB;AAAA,MACF;AAAA,IACF;AAAA,IAEF,iBAAiB;AAAA,EAAA;AAErB;"}
@@ -1,2 +0,0 @@
1
- "use strict";var ve=Object.defineProperty;var Be=(o,e,t)=>e in o?ve(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var w=(o,e,t)=>Be(o,typeof e!="symbol"?e+"":e,t);const P=require("./sha2-DI0-0SHr.cjs"),$=require("bitcoinjs-lib"),I=require("buffer"),Q=require("viem"),O=require("./pegin-registration-client-DLsMNm8Z.cjs"),pe=require("./tbv/core/clients/mempool/index.cjs"),ne=require("./BTCVaultRegistry.abi-z7d_eP22.cjs"),Z=require("./tbv/core/wasm/index.cjs"),A=require("./verifyScriptPathSchnorrSignature-DaRqvEgW.cjs"),R=require("./verifyKeyPathSchnorrSignature-BjB8Znly.cjs"),u=require("./bitcoin-D-O2GjbC.cjs"),se=require("./signing-BJ3X66b-.cjs"),L=require("./validation-C6XTfZak.cjs"),J=require("./parseFundingOutpoints-B4iQeX6q.cjs"),S=require("./signPsbtsWithFallback-DtwzL5AA.cjs"),ie=require("./psbtInputFields-BrV_ZfL_.cjs"),re=require("./fundPeginTransaction-54-Rwb2k.cjs"),X=require("./constants-BTZdyOuk.cjs"),Ae=require("@bitcoin-js/tiny-secp256k1-asmjs"),W=require("./bip322Verify-B7_gIhRk.cjs");function de(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const ge=de($),Ce=de(Ae),D=BigInt(2**32-1),ae=BigInt(32);function Ie(o,e=!1){return e?{h:Number(o&D),l:Number(o>>ae&D)}:{h:Number(o>>ae&D)|0,l:Number(o&D)|0}}function He(o,e=!1){const t=o.length;let n=new Uint32Array(t),r=new Uint32Array(t);for(let s=0;s<t;s++){const{h:i,l:a}=Ie(o[s],e);[n[s],r[s]]=[i,a]}return[n,r]}const Re=(o,e,t)=>o<<t|e>>>32-t,$e=(o,e,t)=>e<<t|o>>>32-t,Oe=(o,e,t)=>e<<t-32|o>>>64-t,Fe=(o,e,t)=>o<<t-32|e>>>64-t,Ve=64;function fe(o){const e=o.prepeginTxid.toLowerCase();if(!/^[0-9a-f]+$/.test(e)||e.length!==Ve)throw new Error(`buildDepositTerms: prepeginTxid must be 64 hex chars, got "${o.prepeginTxid}"`);if(o.peginAmounts.length===0)throw new Error("buildDepositTerms: at least one pegin amount is required");if(o.timelockPegin<=0||o.timelockAssert<=0||o.timelockRefund<=0)throw new Error("buildDepositTerms: timelocks must be positive");if(!Number.isInteger(o.maxAcceptableCommissionBps)||o.maxAcceptableCommissionBps<0||o.maxAcceptableCommissionBps>=X.MAX_VP_COMMISSION_BPS_EXCLUSIVE)throw new Error(`buildDepositTerms: maxAcceptableCommissionBps must be an integer in [0, ${X.MAX_VP_COMMISSION_BPS_EXCLUSIVE}), got ${o.maxAcceptableCommissionBps}`);const t=BigInt(X.BPS_DENOMINATOR),n=o.peginAmounts.map((r,s)=>({htlcVout:s,vaultProviderBtcPubkey:o.vaultProviderBtcPubkey,peginAmount:r,commissionFee:r*BigInt(o.maxAcceptableCommissionBps)/t,depositorClaimValue:o.depositorClaimValue,peginMaxFee:o.peginMaxFee}));return{vaultCoreVersion:o.vaultCoreVersion,protocolFeeRate:o.protocolFeeRate,timelockPegin:o.timelockPegin,timelockAssert:o.timelockAssert,timelockRefund:o.timelockRefund,prepeginTxid:e,prepeginMaxFee:o.prepeginMaxFee,vaultKeeperBtcPubkeys:[...o.vaultKeeperBtcPubkeys],universalChallengerBtcPubkeys:[...o.universalChallengerBtcPubkeys],vaults:n}}const Me=/^0x[0-9a-f]+$/i,We=/^[0-9a-f]+$/i,De=/^[A-Za-z0-9+/]+={0,2}$/;function C(o){if(typeof o!="string"||o.length===0)throw new Error("BTC wallet returned empty public key");return u.processPublicKeyToXOnly(o).toLowerCase()}function Ne(o){if(typeof o!="string"||o.length===0)throw new Error("BTC wallet returned empty BIP-322 signature");if(o.startsWith("0x")||o.startsWith("0X")){if(!Me.test(o)||o.length<4||o.length%2!==0)throw new Error("BTC wallet returned malformed hex BIP-322 signature");return o.toLowerCase()}if(We.test(o)){if(o.length%2!==0)throw new Error("BTC wallet returned malformed hex BIP-322 signature");return`0x${o.toLowerCase()}`}if(!De.test(o)||o.length%4!==0)throw new Error("BTC wallet returned malformed base64 BIP-322 signature");const e=I.Buffer.from(o,"base64");if(e.length===0||e.toString("base64")!==o)throw new Error("BTC wallet returned malformed base64 BIP-322 signature");return`0x${e.toString("hex")}`}async function me(o){const{wallet:e,depositTerms:t,fundedPrePeginTxHex:n,depositorBtcPubkey:r}=o,s=typeof e.approveDepositTerms=="function"?e.approveDepositTerms:void 0;if(!s&&!t)return;const i=n.startsWith("0x")?n.slice(2):n,c=$.Transaction.fromHex(i).getId();if(t&&t.prepeginTxid.replace(/^0x/,"").toLowerCase()!==c)throw new Error(`Deposit terms do not match the transaction being broadcast: terms are for prepeginTxid ${t.prepeginTxid}, but this transaction is ${c}.`);if(!s)return;if(!t)throw new Error("This wallet requires approved deposit terms before signing the Pre-PegIn transaction, but none were provided. Pass PreparePeginResult.depositTerms (fresh flows) or a resume rebuild.");if(typeof e.deriveContextHash!="function")throw new Error("A deposit-approval wallet must also implement deriveContextHash, but this one does not.");if(typeof e.holdsApprovedDepositTerms=="function"){let m=!1;try{m=await e.holdsApprovedDepositTerms(t)}catch{}if(m)return}typeof e.validateDepositTerms=="function"&&await e.validateDepositTerms(t);const h=J.parseFundingOutpointsFromTx(n);(await J.deriveVaultRoot({deriveContextHash:e.deriveContextHash.bind(e)},{depositorBtcPubkey:u.hexToUint8Array(C(r)),fundingOutpoints:h})).fill(0),await s.call(e,t)}const Ue=BigInt(0),H=BigInt(1),Ke=BigInt(2),Le=BigInt(7),Xe=BigInt(256),qe=BigInt(113),Pe=[],be=[],we=[];for(let o=0,e=H,t=1,n=0;o<24;o++){[t,n]=[n,(2*t+3*n)%5],Pe.push(2*(5*n+t)),be.push((o+1)*(o+2)/2%64);let r=Ue;for(let s=0;s<7;s++)e=(e<<H^(e>>Le)*qe)%Xe,e&Ke&&(r^=H<<(H<<BigInt(s))-H);we.push(r)}const ye=He(we,!0),Ge=ye[0],ze=ye[1],ce=(o,e,t)=>t>32?Oe(o,e,t):Re(o,e,t),le=(o,e,t)=>t>32?Fe(o,e,t):$e(o,e,t);function Ye(o,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let i=0;i<10;i++)t[i]=o[i]^o[i+10]^o[i+20]^o[i+30]^o[i+40];for(let i=0;i<10;i+=2){const a=(i+8)%10,c=(i+2)%10,h=t[c],d=t[c+1],m=ce(h,d,1)^t[a],k=le(h,d,1)^t[a+1];for(let y=0;y<50;y+=10)o[i+y]^=m,o[i+y+1]^=k}let r=o[2],s=o[3];for(let i=0;i<24;i++){const a=be[i],c=ce(r,s,a),h=le(r,s,a),d=Pe[i];r=o[d],s=o[d+1],o[d]=c,o[d+1]=h}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)t[a]=o[i+a];for(let a=0;a<10;a++)o[i+a]^=~t[(a+2)%10]&t[(a+4)%10]}o[0]^=Ge[n],o[1]^=ze[n]}P.clean(t)}class te{constructor(e,t,n,r=!1,s=24){w(this,"state");w(this,"pos",0);w(this,"posOut",0);w(this,"finished",!1);w(this,"state32");w(this,"destroyed",!1);w(this,"blockLen");w(this,"suffix");w(this,"outputLen");w(this,"enableXOF",!1);w(this,"rounds");if(this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=s,P.anumber(n,"outputLen"),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=P.u32(this.state)}clone(){return this._cloneInto()}keccak(){P.swap32IfBE(this.state32),Ye(this.state32,this.rounds),P.swap32IfBE(this.state32),this.posOut=0,this.pos=0}update(e){P.aexists(this),P.abytes(e);const{blockLen:t,state:n}=this,r=e.length;for(let s=0;s<r;){const i=Math.min(t-this.pos,r-s);for(let a=0;a<i;a++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,(t&128)!==0&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){P.aexists(this,!1),P.abytes(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,s=e.length;r<s;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,s-r);e.set(t.subarray(this.posOut,this.posOut+i),r),this.posOut+=i,r+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return P.anumber(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(P.aoutput(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,P.clean(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:s,enableXOF:i}=this;return e||(e=new te(t,n,r,i,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=r,e.enableXOF=i,e.destroyed=this.destroyed,e}}const je=(o,e,t,n={})=>P.createHasher(()=>new te(e,o,t),n),Qe=je(1,136,32),ue=64,x=20,ee=4,xe=2,Ze=0,Je=1,N=[64,64],et=o=>Array.from(o).map(e=>e.toString(16).padStart(2,"0")).join("");function oe(o){return O.ripemd160(P.sha256(o))}function ke(o){return(1<<o)-1}function tt(o){let e=1;for(;e*e<o+1;)e++;return Math.max(e,2)}function ot(o){const e=ee,t=o*ke(e);return{d:e,n:o,checksum_radix:tt(t)}}function q(o,e){const t=[];let n=e;for(;n>0;)t.push(n&255),n>>>=8;const r=new Uint8Array(o.length+t.length);r.set(o);for(let s=0;s<t.length;s++)r[o.length+s]=t[s];return oe(r)}function G(o,e){let t=o;for(let n=0;n<e;n++)t=oe(t);return t}function nt(o,e){const t=ke(e.d),n=e.checksum_radix-1,r=Math.floor(e.n*t/e.checksum_radix),s=[];for(let d=0;d<e.n;d++){const m=q(o,d+xe),k=G(m,t);s.push(Array.from(k))}const i=q(o,Ze),a=G(i,n),c=q(o,Je),h=G(c,r);return{config:e,message_terminals:s,checksum_major_terminal:Array.from(h),checksum_minor_terminal:Array.from(a)}}async function Te(o){try{if(o.length!==ue)throw new Error(`WOTS seed must be exactly ${ue} bytes, got ${o.length}`);const e=[];for(let t=0;t<N.length;t++){const n=N[t],r=ot(n),s=new Uint8Array(o.length+1);s.set(o),s[o.length]=t;const i=oe(s);try{const a=nt(i,r);if(a.config.d!==ee)throw new Error(`Block ${t}: expected d=${ee}, got d=${a.config.d}`);if(a.config.n!==n)throw new Error(`Block ${t}: expected n=${n}, got n=${a.config.n}`);if(a.message_terminals.length!==n)throw new Error(`Block ${t}: expected ${n} message terminals, got ${a.message_terminals.length}`);for(let c=0;c<a.message_terminals.length;c++)if(a.message_terminals[c].length!==x)throw new Error(`Block ${t} terminal ${c}: expected ${x} bytes, got ${a.message_terminals[c].length}`);if(a.checksum_minor_terminal.length!==x)throw new Error(`Block ${t} checksum_minor: expected ${x} bytes`);if(a.checksum_major_terminal.length!==x)throw new Error(`Block ${t} checksum_major: expected ${x} bytes`);e.push(a)}finally{s.fill(0),i.fill(0)}}if(e.length!==N.length)throw new Error(`Expected ${N.length} blocks, got ${e.length}`);return e}finally{o.fill(0)}}function z(o,e,t){if(o.length!==x)throw new Error(`Block ${e} ${t}: expected ${x} bytes, got ${o.length}`);for(let n=0;n<o.length;n++){const r=o[n];if(!Number.isInteger(r)||r<0||r>255)throw new Error(`Block ${e} ${t}[${n}]: invalid byte value ${r}`)}}function Ee(o){if(o.length===0)throw new Error("Public keys array must not be empty");for(let s=0;s<o.length;s++){const i=o[s];z(i.checksum_minor_terminal,s,"checksum_minor_terminal"),z(i.checksum_major_terminal,s,"checksum_major_terminal");for(let a=0;a<i.message_terminals.length;a++)z(i.message_terminals[a],s,`message_terminal[${a}]`)}let e=0;for(const s of o)e+=xe+s.message_terminals.length;const t=new Uint8Array(e*x);let n=0;for(const s of o){t.set(s.checksum_minor_terminal,n),n+=x,t.set(s.checksum_major_terminal,n),n+=x;for(const i of s.message_terminals)t.set(i,n),n+=x}const r=Qe(t);return`0x${et(r)}`}async function Se(o,e){const t=[],n=[],r=[],s=[];try{for(let i=0;i<e;i++){const a=await Z.expandWotsSeed(o,i);try{const h=await Te(a);t.push(h),n.push(Ee(h))}finally{a.fill(0)}const c=await Z.expandHashlockSecret(o,i);try{const h=u.uint8ArrayToHex(c);r.push(h),s.push(S.computeHashlock(u.ensureHexPrefix(h)).slice(2))}finally{c.fill(0)}}}finally{o.fill(0)}return{perVaultWotsKeys:t,wotsPkHashes:n,htlcSecretHexes:r,hashlocks:s}}const st=1,it=2,rt=33,at=2,ct=3,lt=1,U=64,ut=0,Y=1,he=/^[0-9a-f]{64}$/i,ht=/^(?:[0-9a-f]{2})+$/;function pt(o){const e=o.slice(2);if(!ht.test(e))throw new Error("proof of possession witness is not even-length lowercase hex");return R.decodeWitnessStack(Uint8Array.from(I.Buffer.from(e,"hex")),"proof of possession witness")}function dt(o,e,t){var r;const n=pt(t);if(n.length===st){const[s]=n;let i,a;if(s.length===U)i=s,a=ut;else if(s.length===U+1&&s[U]===Y)i=s.subarray(0,U),a=Y;else throw new Error("proof of possession witness item must be a 64-byte Schnorr signature (or 65 bytes ending in 0x01)");if(!he.test(e))throw new Error(`depositor public key must be bare 64-char x-only hex, got "${e}"`);const c=Uint8Array.from(I.Buffer.from(e,"hex"));if(!W.verifyBip322Simple(o,c,i,a))throw new Error("proof of possession signature does not verify against the depositor key");return{kind:"p2tr-verified"}}if(n.length===it){if(!he.test(e))throw new Error(`depositor public key must be bare 64-char x-only hex, got "${e}"`);const[s,i]=n;if(i.length!==rt||i[0]!==at&&i[0]!==ct)throw new Error(`proof of possession P2WPKH witness item 1 is not a compressed public key (${i.length} bytes, prefix 0x${((r=i[0])==null?void 0:r.toString(16))??"none"})`);if(!Ce.isPointCompressed(i))throw new Error("proof of possession P2WPKH witness pubkey is not a valid secp256k1 point");const a=I.Buffer.from(i.subarray(lt)).toString("hex");if(a!==e.toLowerCase())throw new Error(`proof of possession witness pubkey does not match the depositor key: witness carries ${a}, expected ${e}`);if(s.length<W.P2WPKH_ENCODED_SIG_MIN||s.length>W.P2WPKH_ENCODED_SIG_MAX)throw new Error(`proof of possession signature is ${s.length} bytes; vault ingestion accepts only 71/72-byte DER signatures with a sighash byte — try a different account or a Taproot address`);if(s[s.length-1]!==Y)throw new Error(`proof of possession P2WPKH signature must end in a SIGHASH_ALL (0x01) byte, got 0x${s[s.length-1].toString(16)}`);if(!W.verifyBip322P2wpkhSimple(o,i,s))throw new Error("proof of possession signature does not verify against the depositor key");return{kind:"p2wpkh-verified"}}throw new Error(`proof of possession witness has ${n.length} items; expected 1 (P2TR) or 2 (P2WPKH)`)}const j="00".repeat(32),gt="00".repeat(32);function ft(o,e){const t={bitcoin:"bc",testnet:"tb",signet:"tb",regtest:"bcrt"};try{const n=ge.address.fromBech32(o);return n.prefix===t[e]&&n.version===0&&n.data.length===20}catch{return!1}}function mt(o,e,t,n){const r=t==null?void 0:t[`${o}:${e}`];return r?Promise.resolve({txid:o,vout:e,value:r.value,scriptPubKey:r.scriptPubKey}):pe.getUtxoInfo(o,e,n)}class Pt{constructor(e){w(this,"config");this.config=e}async preparePegin(e){if(e.amounts.length===0)throw new Error("amounts must contain at least one entry");const t=await this.config.btcWallet.getPublicKeyHex(),n=C(t);if(S.supportsDepositApproval(this.config.btcWallet)){const l=(await S.requireChangeAddress(this.config.btcWallet)).trim();if(e.changeAddress.trim()!==l)throw new Error(`Pre-PegIn changeAddress "${e.changeAddress}" is not the approval wallet's change address ("${l}"). Refusing to build a tx the signing device would reject.`)}else if(!u.isAddressFromPublicKey(e.changeAddress,t,this.config.btcNetwork))throw new Error(`Pre-PegIn changeAddress "${e.changeAddress}" is not derived from the connected wallet's public key. Refusing to build a tx that would send change to an address the signing key doesn't control.`);const r=await this.prepareSizing(n,e);if(S.supportsDepositApproval(this.config.btcWallet)){const{validateDepositTerms:l}=this.config.btcWallet;typeof l=="function"&&await l.call(this.config.btcWallet,this.buildPeginDepositTerms({params:e,prepeginTxid:gt,prepeginMaxFee:r.fee,depositorClaimValue:r.depositorClaimValue,peginMaxFee:r.minPeginFee}))}const s=r.selectedUTXOs.map(l=>({txid:u.hexToUint8Array(l.txid),vout:l.vout})),i=await J.deriveVaultRoot(this.config.btcWallet,{depositorBtcPubkey:u.hexToUint8Array(n),fundingOutpoints:s});let a,c;try{const l=await Z.expandAuthAnchor(i);try{a=u.uint8ArrayToHex(l),c=u.uint8ArrayToHex(P.sha256(l))}finally{l.fill(0)}}catch(l){throw i.fill(0),l}const h=await Se(i,e.amounts.length),{perVaultWotsKeys:d,wotsPkHashes:m,htlcSecretHexes:k,hashlocks:y}=h,f=await this.preparePeginCommit({depositorBtcPubkeyRaw:t,depositorBtcPubkey:n,hashlocks:y,authAnchorHash:c,sizing:r,params:e});for(let l=0;l<f.perVault.length;l++)if(f.perVault[l].htlcVout!==l)throw new Error(`Internal invariant violation: htlcVout/index mismatch at vault ${l} (expected ${l}, got ${f.perVault[l].htlcVout})`);S.assertAuthAnchorOpReturn(f.fundedPrePeginTxHex,e.amounts.length,c);const{depositTerms:_,...T}=f;return{transaction:{...T,selectedUTXOs:r.selectedUTXOs,fee:r.fee,changeAmount:r.changeAmount},depositorBtcPubkey:n,derivedSecrets:{perVaultWotsKeys:d,wotsPkHashes:m,htlcSecretHexes:k,authAnchorHex:a},depositTerms:_}}async prepareSizing(e,t){const n=t.amounts.map(()=>j),r=t.vaultKeeperBtcPubkeys.length,s=await A.buildPrePeginPsbt({vaultCoreVersion:t.vaultCoreVersion,depositorPubkey:e,vaultProviderPubkey:u.stripHexPrefix(t.vaultProviderBtcPubkey),vaultKeeperPubkeys:t.vaultKeeperBtcPubkeys.map(u.stripHexPrefix),universalChallengerPubkeys:t.universalChallengerBtcPubkeys.map(u.stripHexPrefix),hashlocks:n,timelockRefund:t.timelockRefund,pegInAmounts:t.amounts,feeRate:t.protocolFeeRate,minPeginFeeRate:t.minPeginFeeRate,numLocalChallengers:r,councilQuorum:t.councilQuorum,councilSize:t.councilSize,network:this.config.btcNetwork,authAnchorHash:j}),i=ie.selectUtxosForPegin([...t.availableUTXOs],s.totalOutputValue,t.mempoolFeeRate,re.peginOutputCount(s.htlcValues.length,!0));return{selectedUTXOs:i.selectedUTXOs,fee:i.fee,changeAmount:i.changeAmount,depositorClaimValue:s.depositorClaimValue,minPeginFee:s.minPeginFee}}buildPeginDepositTerms(e){const{params:t}=e;return fe({vaultCoreVersion:t.vaultCoreVersion,protocolFeeRate:t.protocolFeeRate,timelockPegin:t.timelockPegin,timelockAssert:t.timelockAssert,timelockRefund:t.timelockRefund,prepeginTxid:e.prepeginTxid,prepeginMaxFee:e.prepeginMaxFee,vaultProviderBtcPubkey:u.stripHexPrefix(t.vaultProviderBtcPubkey),vaultKeeperBtcPubkeys:t.vaultKeeperBtcPubkeys.map(u.stripHexPrefix),universalChallengerBtcPubkeys:t.universalChallengerBtcPubkeys.map(u.stripHexPrefix),maxAcceptableCommissionBps:O.capMaxAcceptableCommissionBps(t.commissionBps),peginAmounts:t.amounts,depositorClaimValue:e.depositorClaimValue,peginMaxFee:e.peginMaxFee})}async preparePeginCommit(e){const{depositorBtcPubkeyRaw:t,depositorBtcPubkey:n,hashlocks:r,authAnchorHash:s,sizing:i,params:a}=e,c=j.toLowerCase();for(let p=0;p<r.length;p++)if(r[p].toLowerCase()===c)throw new Error(`preparePeginCommit refusing to build with sizing-pass placeholder hashlock at vault ${p} — internal substitution bug`);if(s.toLowerCase()===c)throw new Error("preparePeginCommit refusing to build with sizing-pass placeholder auth-anchor hash — internal substitution bug");const h=u.stripHexPrefix(a.vaultProviderBtcPubkey),d=a.vaultKeeperBtcPubkeys.map(u.stripHexPrefix),m=a.universalChallengerBtcPubkeys.map(u.stripHexPrefix),k=d.length,y={vaultCoreVersion:a.vaultCoreVersion,depositorPubkey:n,vaultProviderPubkey:h,vaultKeeperPubkeys:d,universalChallengerPubkeys:m,hashlocks:r,timelockRefund:a.timelockRefund,pegInAmounts:a.amounts,feeRate:a.protocolFeeRate,minPeginFeeRate:a.minPeginFeeRate,numLocalChallengers:k,councilQuorum:a.councilQuorum,councilSize:a.councilSize,network:this.config.btcNetwork,authAnchorHash:s},f=await A.buildPrePeginPsbt(y);if(f.depositorClaimValue!==i.depositorClaimValue||f.minPeginFee!==i.minPeginFee)throw new Error(`Pre-PegIn sizing/commit divergence: depositorClaimValue ${i.depositorClaimValue} -> ${f.depositorClaimValue}, minPeginFee ${i.minPeginFee} -> ${f.minPeginFee}. The provisional deposit terms validated before derivation would not match the terms sent for approval; refusing to continue.`);const _=u.getNetwork(this.config.btcNetwork),T=re.fundPeginTransaction({unfundedTxHex:f.psbtHex,selectedUTXOs:i.selectedUTXOs,changeAddress:a.changeAddress,changeAmount:i.changeAmount,network:_}),l=i.selectedUTXOs.reduce((p,B)=>p+BigInt(B.value),0n)-f.totalOutputValue-i.changeAmount;if(l!==i.fee)throw new Error(`Pre-PegIn funded fee ${l} does not match the sizing-pass fee ${i.fee}; refusing to publish a deposit-terms fee bound the funded transaction does not pay.`);const F=u.stripHexPrefix(se.calculateBtcTxHash(T)),V=[],g=[],b=[];for(let p=0;p<r.length;p++){const B=await A.buildPeginTxFromFundedPrePegin({prePeginParams:y,timelockPegin:a.timelockPegin,fundedPrePeginTxHex:T,htlcVout:p}),K=await R.buildPeginInputPsbt({vaultCoreVersion:a.vaultCoreVersion,peginTxHex:B.txHex,fundedPrePeginTxHex:T,depositorPubkey:n,vaultProviderPubkey:h,vaultKeeperPubkeys:d,universalChallengerPubkeys:m,hashlock:r[p],timelockRefund:a.timelockRefund,network:this.config.btcNetwork});V.push(B),g.push(K.psbtHex),b.push(se.createTaprootScriptPathSignOptions(t,1))}const E=this.buildPeginDepositTerms({params:a,prepeginTxid:F,prepeginMaxFee:i.fee,depositorClaimValue:f.depositorClaimValue,peginMaxFee:f.minPeginFee});S.supportsDepositApproval(this.config.btcWallet)&&await this.config.btcWallet.approveDepositTerms(E);const v=await S.signPsbtsWithFallback(this.config.btcWallet,g,b),M=[];for(let p=0;p<v.length;p++){A.assertPsbtUnsignedTxMatches({requestedPsbtHex:g[p],returnedPsbtHex:v[p]});const B=R.extractPeginInputSignature(v[p],n);A.assertScriptPathSchnorrSignature({requestedPsbtHex:g[p],signatureHex:B,signerXOnlyPubkeyHex:n,inputIndex:0});const K=R.finalizePeginInputPsbt(v[p]);M.push({htlcVout:p,htlcValue:f.htlcValues[p],peginTxHex:K,peginTxid:V[p].txid,peginInputSignature:B,vaultScriptPubKey:V[p].vaultScriptPubKey})}return{fundedPrePeginTxHex:T,prePeginTxid:F,perVault:M,depositTerms:E}}async signAndBroadcast(e){const{fundedPrePeginTxHex:t,depositorBtcPubkey:n}=e,r=t.startsWith("0x")?t.slice(2):t,s=$.Transaction.fromHex(r);if(s.ins.length===0)throw new Error("Transaction has no inputs");const i=new $.Psbt;i.setVersion(s.version),i.setLocktime(s.locktime);const a=I.Buffer.from(C(n),"hex"),c=this.config.mempoolApiUrl,h=s.ins.map(g=>{const b=I.Buffer.from(g.hash).reverse().toString("hex"),E=g.index;return mt(b,E,e.localPrevouts,c).then(v=>({input:g,utxoData:v,txid:b,vout:E}))}),d=await Promise.all(h),m=d.reduce((g,b)=>g+BigInt(b.utxoData.value),0n),k=s.outs.reduce((g,b)=>g+BigInt(b.value),0n);if(m<k)throw new Error(`UTXO value mismatch: total input value (${m} sat) is less than total output value (${k} sat). This may indicate the mempool API returned manipulated UTXO data.`);const y=m-k;if(y>L.MAX_REASONABLE_FEE_SATS)throw new Error(`Implied transaction fee (${y} sat) exceeds maximum reasonable fee (${L.MAX_REASONABLE_FEE_SATS} sat). This may indicate manipulated UTXO data.`);for(const{input:g,utxoData:b,txid:E,vout:v}of d){const M=ie.getPsbtInputFields({value:b.value,scriptPubKey:b.scriptPubKey},a);i.addInput({hash:g.hash,index:g.index,sequence:g.sequence,...M})}for(const g of s.outs)i.addOutput({script:g.script,value:g.value});await me({wallet:this.config.btcWallet,depositTerms:e.depositTerms,fundedPrePeginTxHex:t,depositorBtcPubkey:n});const f=i.toHex(),_=await this.config.btcWallet.signPsbt(f);A.assertPsbtUnsignedTxMatches({requestedPsbtHex:f,returnedPsbtHex:_});const T=R.assertReturnedKeyPathSignatures({requestedPsbtHex:f,returnedPsbtHex:_});if(S.supportsDepositApproval(this.config.btcWallet)&&T!==i.data.inputs.length)throw new Error(`Key-path verification covered ${T} of ${i.data.inputs.length} Pre-PegIn inputs; an approval wallet signs every input key-path, so the unverified ones must not be broadcast.`);const l=$.Psbt.fromHex(_);try{l.finalizeAllInputs()}catch(g){if(!l.data.inputs.every(E=>E.finalScriptWitness||E.finalScriptSig))throw new Error(`PSBT finalization failed and wallet did not auto-finalize: ${g}`)}const F=l.extractTransaction().toHex();return await pe.pushTx(F,c)}async registerPeginOnChain(e){if(!this.config.ethWallet.account)throw new Error("Ethereum wallet account not found");const t=this.config.ethWallet.account.address;if(!Q.isAddressEqual(e.popSignature.depositorEthAddress,t))throw new Error(`Proof of possession was signed for ${e.popSignature.depositorEthAddress} but the Ethereum wallet is currently connected to ${t}. Reconnect the original account or call signProofOfPossession() again.`);const n=await this.assertPopMatchesBtcWallet(e.popSignature),r=e.depositorPayoutBtcAddress??await this.config.btcWallet.getAddress(),s=this.resolvePayoutScriptPubKey(n,r);return this.createRegistrationClient().registerPeginOnChain({unsignedPrePeginTx:e.unsignedPrePeginTx,depositorSignedPeginTx:e.depositorSignedPeginTx,vaultProvider:e.vaultProvider,hashlock:e.hashlock,htlcVout:e.htlcVout,depositorPayoutScriptPubKey:s,depositorBtcPubkeyRaw:n,depositorWotsPkHash:e.depositorWotsPkHash,popSignature:e.popSignature,quotedCommissionBps:e.quotedCommissionBps})}async registerPeginBatchOnChain(e){if(e.requests.length===0)throw new Error("Batch pegin requires at least one request");if(!this.config.ethWallet.account)throw new Error("Ethereum wallet account not found");const t=this.config.ethWallet.account.address;if(!Q.isAddressEqual(e.popSignature.depositorEthAddress,t))throw new Error(`Proof of possession was signed for ${e.popSignature.depositorEthAddress} but the Ethereum wallet is currently connected to ${t}. Reconnect the original account or call signProofOfPossession() again.`);const n=await this.assertPopMatchesBtcWallet(e.popSignature),r=e.requests.map(s=>this.resolvePayoutScriptPubKey(n,s.depositorPayoutBtcAddress));return this.createRegistrationClient().registerPeginBatchOnChain({vaultProvider:e.vaultProvider,unsignedPrePeginTx:e.unsignedPrePeginTx,popSignature:e.popSignature,depositorBtcPubkeyRaw:n,quotedCommissionBps:e.quotedCommissionBps,requests:e.requests.map((s,i)=>({depositorSignedPeginTx:s.depositorSignedPeginTx,hashlock:s.hashlock,htlcVout:s.htlcVout,depositorPayoutScriptPubKey:r[i],depositorWotsPkHash:s.depositorWotsPkHash}))})}createRegistrationClient(){return new O.ViemPeginRegistrationClient({ethWallet:this.config.ethWallet,ethChain:this.config.ethChain,publicClient:this.config.publicClient,btcVaultRegistry:this.config.vaultContracts.btcVaultRegistry,requireQuotedCommissionBps:S.supportsDepositApproval(this.config.btcWallet)})}resolvePayoutScriptPubKey(e,t){if(!u.isAddressFromPublicKey(t,e,this.config.btcNetwork))throw u.stripHexPrefix(e).length===L.X_ONLY_PUBKEY_HEX_LEN&&ft(t,this.config.btcNetwork)?new Error(`BTC payout address "${t}" is a P2WPKH (Native SegWit) address, but the connected wallet only exposes an x-only public key. P2WPKH validation requires a compressed key with known y-parity. Use a P2TR (Taproot) payout address instead.`):new Error(`BTC payout address "${t}" is not derived from the connected wallet's public key. The payout sink must be controlled by the same key that signs the pegin; refusing to register a mismatched address.`);const n=u.getNetwork(this.config.btcNetwork);let r;try{r=ge.address.toOutputScript(t,n).toString("hex")}catch{throw new Error(`Invalid BTC payout address: "${t}". Please provide a valid Bitcoin address for the ${this.config.btcNetwork} network.`)}return r}async signProofOfPossession(){if(!this.config.ethWallet.account)throw new Error("Ethereum wallet account not found");const e=this.config.ethWallet.account.address,t=C(await this.config.btcWallet.getPublicKeyHex()),n=this.config.vaultContracts.btcVaultRegistry,r=`${e.toLowerCase()}:${this.config.ethChain.id}:pegin:${n.toLowerCase()}`,s=await this.config.btcWallet.signMessage(r,"bip322-simple"),i=Ne(s);return dt(new TextEncoder().encode(r),t,i),{btcPopSignature:i,depositorEthAddress:e,depositorBtcPubkey:t}}async assertPopMatchesBtcWallet(e){const t=await this.config.btcWallet.getPublicKeyHex(),n=C(t),r=C(e.depositorBtcPubkey);if(n!==r)throw new Error(`Proof of possession was signed with BTC pubkey ${r} but the BTC wallet is currently connected to ${n}. Reconnect the original wallet or call signProofOfPossession() again.`);return t}getNetwork(){return this.config.btcNetwork}getVaultContractAddress(){return this.config.vaultContracts.btcVaultRegistry}}const bt=80,wt=250,yt=300,xt=22,_e="ab";function kt(o,e){const t=_e.repeat(yt),n=u.stripHexPrefix(o).toLowerCase(),r=e.toString(16).padStart(8,"0"),s=`${n}${r}`,i=t.slice(s.length);return`0x${s}${i}`}function Tt(o,e){const t=n=>`0x${_e.repeat(n)}`;return{depositorBtcPubKey:t(32),btcPopSignature:t(bt),unsignedPrePeginTx:t(wt),depositorSignedPeginTx:kt(o,e),hashlock:t(32),htlcVout:e,referralCode:O.NO_REFERRAL_CODE,depositorPayoutBtcAddress:t(xt),depositorWotsPkHash:t(32)}}async function Et(o){const{publicClient:e,btcVaultRegistry:t,depositorEthAddress:n,vaultProvider:r,batchSize:s}=o;if(s<=0)throw new Error(`estimateSubmitPeginRequestBatchGas requires batchSize >= 1 (received ${s})`);const a=await e.readContract({address:t,abi:ne.BTCVaultRegistryABI,functionName:"getPegInFee",args:[r]})*BigInt(s),c=Array.from({length:s},(d,m)=>Tt(n,m)),h=Q.encodeFunctionData({abi:ne.BTCVaultRegistryABI,functionName:"submitPeginRequestBatch",args:[n,r,O.MAX_ACCEPTABLE_COMMISSION_BPS_CAP,c]});return e.estimateGas({to:t,data:h,value:a,account:n})}exports.PeginManager=Pt;exports.buildDepositTerms=fe;exports.computeWotsBlockPublicKeysHash=Ee;exports.deriveWotsBlocksFromSeed=Te;exports.ensurePrePeginTermsApproval=me;exports.estimateSubmitPeginRequestBatchGas=Et;exports.expandPerVaultSecrets=Se;
2
- //# sourceMappingURL=PeginManager-DEByBX5R.cjs.map