@babylonlabs-io/ts-sdk 0.72.0 → 0.73.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.
- package/README.md +56 -13
- package/dist/BTCVaultRegistryKeyEpochs.abi-CrQiTLfA.cjs +2 -0
- package/dist/BTCVaultRegistryKeyEpochs.abi-CrQiTLfA.cjs.map +1 -0
- package/dist/BTCVaultRegistryKeyEpochs.abi-D8cIbMtH.js +229 -0
- package/dist/BTCVaultRegistryKeyEpochs.abi-D8cIbMtH.js.map +1 -0
- package/dist/PeginManager-C9RPOd0L.js +1216 -0
- package/dist/PeginManager-C9RPOd0L.js.map +1 -0
- package/dist/PeginManager-E-UHA1un.cjs +2 -0
- package/dist/PeginManager-E-UHA1un.cjs.map +1 -0
- package/dist/bip322Verify-B7_gIhRk.cjs +2 -0
- package/dist/bip322Verify-B7_gIhRk.cjs.map +1 -0
- package/dist/bip322Verify-D6sBBUHE.js +79 -0
- package/dist/bip322Verify-D6sBBUHE.js.map +1 -0
- package/dist/{buildAndBroadcastReclaim-YvWDRAN8.js → buildAndBroadcastReclaim-BXclIcu_.js} +366 -357
- package/dist/buildAndBroadcastReclaim-BXclIcu_.js.map +1 -0
- package/dist/buildAndBroadcastReclaim-U-PyFfDg.cjs +2 -0
- package/dist/buildAndBroadcastReclaim-U-PyFfDg.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +209 -205
- package/dist/index.js.map +1 -1
- package/dist/onChainBtcPubkey-BbxRrbvg.cjs +2 -0
- package/dist/onChainBtcPubkey-BbxRrbvg.cjs.map +1 -0
- package/dist/onChainBtcPubkey-C-6UWpD8.js +34 -0
- package/dist/onChainBtcPubkey-C-6UWpD8.js.map +1 -0
- package/dist/{parseFundingOutpoints-BkgGihaY.cjs → parseFundingOutpoints-B4iQeX6q.cjs} +2 -2
- package/dist/{parseFundingOutpoints-BkgGihaY.cjs.map → parseFundingOutpoints-B4iQeX6q.cjs.map} +1 -1
- package/dist/{parseFundingOutpoints-DlINgQ3X.js → parseFundingOutpoints-B67CoXpF.js} +2 -2
- package/dist/{parseFundingOutpoints-DlINgQ3X.js.map → parseFundingOutpoints-B67CoXpF.js.map} +1 -1
- package/dist/pegin-registration-client-6vLk2itL.cjs +2 -0
- package/dist/pegin-registration-client-6vLk2itL.cjs.map +1 -0
- package/dist/pegin-registration-client-BdRiR8br.js +2635 -0
- package/dist/pegin-registration-client-BdRiR8br.js.map +1 -0
- package/dist/primeVpAuth-DBHohVKM.cjs +2 -0
- package/dist/primeVpAuth-DBHohVKM.cjs.map +1 -0
- package/dist/primeVpAuth-DvaD45q_.js +745 -0
- package/dist/primeVpAuth-DvaD45q_.js.map +1 -0
- package/dist/psbtInputFields-B3e05Xe6.js +171 -0
- package/dist/psbtInputFields-B3e05Xe6.js.map +1 -0
- package/dist/psbtInputFields-BIxBpPj2.cjs +2 -0
- package/dist/psbtInputFields-BIxBpPj2.cjs.map +1 -0
- package/dist/sha2-CrlWM5S8.js +312 -0
- package/dist/{sha2-BYVxyZzX.js.map → sha2-CrlWM5S8.js.map} +1 -1
- package/dist/sha2-DI0-0SHr.cjs +2 -0
- package/dist/{sha2-DsrLC4NM.cjs.map → sha2-DI0-0SHr.cjs.map} +1 -1
- package/dist/{signPsbtsWithFallback-CCFTzE0o.js → signPsbtsWithFallback-0VBALhjS.js} +2 -2
- package/dist/{signPsbtsWithFallback-CCFTzE0o.js.map → signPsbtsWithFallback-0VBALhjS.js.map} +1 -1
- package/dist/{signPsbtsWithFallback-CrkvpSJz.cjs → signPsbtsWithFallback-DMSpIQWH.cjs} +2 -2
- package/dist/{signPsbtsWithFallback-CrkvpSJz.cjs.map → signPsbtsWithFallback-DMSpIQWH.cjs.map} +1 -1
- package/dist/tbv/core/clients/eth/__tests__/eth-import-boundary.test.d.ts +2 -0
- package/dist/tbv/core/clients/eth/__tests__/eth-import-boundary.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/__tests__/onChainBtcPubkey.test.d.ts +2 -0
- package/dist/tbv/core/clients/eth/__tests__/onChainBtcPubkey.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/__tests__/payout-script.test.d.ts +2 -0
- package/dist/tbv/core/clients/eth/__tests__/payout-script.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/__tests__/pegin-registration-calldata.test.d.ts +2 -0
- package/dist/tbv/core/clients/eth/__tests__/pegin-registration-calldata.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/__tests__/pegin-registration-client.test.d.ts +2 -0
- package/dist/tbv/core/clients/eth/__tests__/pegin-registration-client.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/__tests__/pegin-transaction.test.d.ts +2 -0
- package/dist/tbv/core/clients/eth/__tests__/pegin-transaction.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/index.cjs +2 -0
- package/dist/tbv/core/clients/eth/index.cjs.map +1 -0
- package/dist/tbv/core/clients/eth/index.d.ts +4 -0
- package/dist/tbv/core/clients/eth/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/index.js +22 -0
- package/dist/tbv/core/clients/eth/index.js.map +1 -0
- package/dist/tbv/core/clients/eth/onChainBtcPubkey.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/operation-key-reader.d.ts +1 -1
- package/dist/tbv/core/clients/eth/operation-key-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/payout-script.d.ts +4 -0
- package/dist/tbv/core/clients/eth/payout-script.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/pegin-registration-client.d.ts +99 -0
- package/dist/tbv/core/clients/eth/pegin-registration-client.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/pegin-transaction.d.ts +14 -0
- package/dist/tbv/core/clients/eth/pegin-transaction.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/protocol-params-reader.d.ts +6 -1
- package/dist/tbv/core/clients/eth/protocol-params-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/signer-set-reader.d.ts +4 -4
- package/dist/tbv/core/clients/eth/signer-set-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/types.d.ts +29 -8
- package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts +1 -1
- package/dist/tbv/core/clients/eth/vault-registry-reader.d.ts.map +1 -1
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +55 -48
- package/dist/tbv/core/clients/index.js.map +1 -1
- package/dist/tbv/core/clients/mempool/index.cjs +2 -0
- package/dist/tbv/core/clients/mempool/index.cjs.map +1 -0
- package/dist/tbv/core/clients/mempool/index.js +222 -0
- package/dist/tbv/core/clients/mempool/index.js.map +1 -0
- package/dist/tbv/core/contracts/index.cjs +1 -1
- package/dist/tbv/core/contracts/index.cjs.map +1 -1
- package/dist/tbv/core/contracts/index.js +491 -12
- package/dist/tbv/core/contracts/index.js.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.d.ts +1 -0
- package/dist/tbv/core/index.d.ts.map +1 -1
- package/dist/tbv/core/index.js +207 -203
- package/dist/tbv/core/index.js.map +1 -1
- package/dist/tbv/core/managers/PeginManager.d.ts +38 -30
- package/dist/tbv/core/managers/PeginManager.d.ts.map +1 -1
- package/dist/tbv/core/managers/index.cjs +1 -1
- package/dist/tbv/core/managers/index.d.ts +2 -1
- package/dist/tbv/core/managers/index.d.ts.map +1 -1
- package/dist/tbv/core/managers/index.js +2 -2
- package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts +20 -0
- package/dist/tbv/core/services/deposit/validateOnChainParticipantKeys.d.ts.map +1 -1
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.js +2 -2
- package/dist/tbv/core/services/participants/resolveParticipantKeys.d.ts +8 -0
- package/dist/tbv/core/services/participants/resolveParticipantKeys.d.ts.map +1 -1
- package/dist/tbv/core/utils/eth/index.cjs +2 -0
- package/dist/tbv/core/utils/eth/index.cjs.map +1 -0
- package/dist/tbv/core/utils/eth/index.js +109 -0
- package/dist/tbv/core/utils/eth/index.js.map +1 -0
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +41 -40
- package/dist/tbv/core/utils/index.js.map +1 -1
- package/dist/tbv/core/vault-secrets/index.cjs +1 -1
- package/dist/tbv/core/vault-secrets/index.js +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +207 -203
- package/dist/tbv/index.js.map +1 -1
- package/dist/testing/index.cjs +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/{toRefundInputs-Df1vi23S.js → toRefundInputs-BkcFhvDp.js} +5 -5
- package/dist/{toRefundInputs-Df1vi23S.js.map → toRefundInputs-BkcFhvDp.js.map} +1 -1
- package/dist/{toRefundInputs-CY9u84U9.cjs → toRefundInputs-CatCKniS.cjs} +2 -2
- package/dist/{toRefundInputs-CY9u84U9.cjs.map → toRefundInputs-CatCKniS.cjs.map} +1 -1
- package/dist/types-CPDLZm3l.js +430 -0
- package/dist/types-CPDLZm3l.js.map +1 -0
- package/dist/types-DSlcXtog.cjs +2 -0
- package/dist/types-DSlcXtog.cjs.map +1 -0
- package/package.json +32 -3
- package/dist/BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js +0 -111
- package/dist/BTCVaultRegistryKeyEpochs.abi-CXjhRZbm.js.map +0 -1
- package/dist/BTCVaultRegistryKeyEpochs.abi-_NERAdc5.cjs +0 -2
- package/dist/BTCVaultRegistryKeyEpochs.abi-_NERAdc5.cjs.map +0 -1
- package/dist/PeginManager-Bn8FxM35.cjs +0 -2
- package/dist/PeginManager-Bn8FxM35.cjs.map +0 -1
- package/dist/PeginManager-C3ojNTlv.js +0 -1503
- package/dist/PeginManager-C3ojNTlv.js.map +0 -1
- package/dist/ProtocolParams.abi-C0TSRaHV.js +0 -486
- package/dist/ProtocolParams.abi-C0TSRaHV.js.map +0 -1
- package/dist/ProtocolParams.abi-CYZoV2EI.cjs +0 -2
- package/dist/ProtocolParams.abi-CYZoV2EI.cjs.map +0 -1
- package/dist/buildAndBroadcastReclaim-YvWDRAN8.js.map +0 -1
- package/dist/buildAndBroadcastReclaim-zfjDI5__.cjs +0 -2
- package/dist/buildAndBroadcastReclaim-zfjDI5__.cjs.map +0 -1
- package/dist/errors-Blc-JWnI.js +0 -121
- package/dist/errors-Blc-JWnI.js.map +0 -1
- package/dist/errors-CGcNP0rV.cjs +0 -2
- package/dist/errors-CGcNP0rV.cjs.map +0 -1
- package/dist/mempoolApi-CKD_IbrM.js +0 -611
- package/dist/mempoolApi-CKD_IbrM.js.map +0 -1
- package/dist/mempoolApi-DronQ5xn.cjs +0 -2
- package/dist/mempoolApi-DronQ5xn.cjs.map +0 -1
- package/dist/onChainBtcPubkey-B5ZvWCCF.cjs +0 -2
- package/dist/onChainBtcPubkey-B5ZvWCCF.cjs.map +0 -1
- package/dist/onChainBtcPubkey-DATNfAAl.js +0 -19
- package/dist/onChainBtcPubkey-DATNfAAl.js.map +0 -1
- package/dist/primeVpAuth-Cjq6qFHq.cjs +0 -2
- package/dist/primeVpAuth-Cjq6qFHq.cjs.map +0 -1
- package/dist/primeVpAuth-tLRjdHwZ.js +0 -1159
- package/dist/primeVpAuth-tLRjdHwZ.js.map +0 -1
- package/dist/sha2-BYVxyZzX.js +0 -274
- package/dist/sha2-DsrLC4NM.cjs +0 -2
- package/dist/waitForTransactionReceiptSmartAware-DpQ69ySe.cjs +0 -2
- package/dist/waitForTransactionReceiptSmartAware-DpQ69ySe.cjs.map +0 -1
- package/dist/waitForTransactionReceiptSmartAware-z3Xfmo44.js +0 -277
- package/dist/waitForTransactionReceiptSmartAware-z3Xfmo44.js.map +0 -1
package/README.md
CHANGED
|
@@ -56,22 +56,35 @@ targets — see the [Troubleshooting Guide](./docs/get-started/troubleshooting.m
|
|
|
56
56
|
|
|
57
57
|
### Install
|
|
58
58
|
|
|
59
|
+
`viem ^2.38.2` is the only required peer. An Ethereum-only consumer installs
|
|
60
|
+
the SDK and viem:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pnpm add @babylonlabs-io/ts-sdk viem
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The Bitcoin peers are optional. Add their exact supported versions before you
|
|
67
|
+
import a root or Bitcoin entry:
|
|
68
|
+
|
|
59
69
|
```bash
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
pnpm add bitcoinjs-lib@6.1.7 @bitcoin-js/tiny-secp256k1-asmjs@2.2.3
|
|
71
|
+
```
|
|
62
72
|
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
The WASM engine is also optional. Add it only for Bitcoin construction and
|
|
74
|
+
signing paths:
|
|
65
75
|
|
|
66
|
-
|
|
67
|
-
pnpm add @babylonlabs-io/
|
|
76
|
+
```bash
|
|
77
|
+
pnpm add @babylonlabs-io/babylon-tbv-rust-wasm
|
|
68
78
|
```
|
|
69
79
|
|
|
70
|
-
|
|
80
|
+
The source manifest uses `workspace:*` for the WASM peer. The release process
|
|
81
|
+
replaces it with the exact engine version used in the release rehearsal.
|
|
82
|
+
|
|
83
|
+
### ECC Library Initialization (Bitcoin flows only)
|
|
71
84
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
Bitcoin address**:
|
|
85
|
+
ETH-only consumers do not need an ECC library. If your application uses the
|
|
86
|
+
SDK's Bitcoin/Taproot operations, call `initEccLib()` once **before any SDK call
|
|
87
|
+
that builds a PSBT or derives a Bitcoin address**:
|
|
75
88
|
|
|
76
89
|
```typescript
|
|
77
90
|
import * as ecc from "@bitcoin-js/tiny-secp256k1-asmjs";
|
|
@@ -103,12 +116,35 @@ Run with: `npx tsx verify-install.ts`
|
|
|
103
116
|
|
|
104
117
|
## Package Structure
|
|
105
118
|
|
|
106
|
-
The SDK uses subpath exports for
|
|
119
|
+
The SDK uses subpath exports for hard dependency boundaries as well as
|
|
120
|
+
tree-shaking. ETH-only code should import the dedicated `/eth` entries rather
|
|
121
|
+
than a broad compatibility barrel:
|
|
107
122
|
|
|
108
123
|
```typescript
|
|
109
124
|
// High-level managers (recommended for most users)
|
|
110
125
|
import { PeginManager, PayoutManager } from "@babylonlabs-io/ts-sdk/tbv/core";
|
|
111
126
|
|
|
127
|
+
// Ethereum-only readers and prepared peg-in registration (no BTC wallet,
|
|
128
|
+
// bitcoinjs-lib, tiny-secp256k1, or WASM required)
|
|
129
|
+
import {
|
|
130
|
+
ViemProtocolParamsReader,
|
|
131
|
+
ViemVaultRegistryReader,
|
|
132
|
+
ViemPeginRegistrationClient,
|
|
133
|
+
} from "@babylonlabs-io/ts-sdk/tbv/core/clients/eth";
|
|
134
|
+
|
|
135
|
+
// Ethereum-only transaction receipt helper
|
|
136
|
+
import { waitForTransactionReceiptSmartAware } from "@babylonlabs-io/ts-sdk/tbv/core/utils/eth";
|
|
137
|
+
|
|
138
|
+
// Unauthenticated VP polling without the Bitcoin-auth implementation
|
|
139
|
+
import {
|
|
140
|
+
VaultProviderRpcClient,
|
|
141
|
+
batchPollByProvider,
|
|
142
|
+
DaemonStatus,
|
|
143
|
+
} from "@babylonlabs-io/ts-sdk/tbv/core/clients/vault-provider/status";
|
|
144
|
+
|
|
145
|
+
// Mempool reads without bitcoinjs-lib, tiny-secp256k1, or WASM
|
|
146
|
+
import { getTxInfo } from "@babylonlabs-io/ts-sdk/tbv/core/clients/mempool";
|
|
147
|
+
|
|
112
148
|
// Low-level primitives (advanced use cases)
|
|
113
149
|
import {
|
|
114
150
|
buildPrePeginPsbt,
|
|
@@ -140,8 +176,8 @@ import { BitcoinWallet } from "@babylonlabs-io/ts-sdk/shared";
|
|
|
140
176
|
// UTXO type lives in the core utils module
|
|
141
177
|
import { UTXO } from "@babylonlabs-io/ts-sdk/tbv/core";
|
|
142
178
|
|
|
143
|
-
// Contract ABIs
|
|
144
|
-
import { BTCVaultRegistryABI } from "@babylonlabs-io/ts-sdk/tbv/core";
|
|
179
|
+
// Contract ABIs (also dependency-clean for ETH consumers)
|
|
180
|
+
import { BTCVaultRegistryABI } from "@babylonlabs-io/ts-sdk/tbv/core/contracts";
|
|
145
181
|
|
|
146
182
|
// Protocol integrations (Aave)
|
|
147
183
|
import {
|
|
@@ -152,6 +188,13 @@ import {
|
|
|
152
188
|
} from "@babylonlabs-io/ts-sdk/tbv/integrations/aave";
|
|
153
189
|
```
|
|
154
190
|
|
|
191
|
+
`ViemPeginRegistrationClient` owns only the Ethereum submission half of a
|
|
192
|
+
peg-in. It accepts a signed PegIn transaction, PoP,
|
|
193
|
+
`depositorPayoutScriptPubKey`, and `depositorBtcPubkeyRaw` prepared earlier. It
|
|
194
|
+
never asks for a BTC wallet. It validates the payout script against the raw key
|
|
195
|
+
and the PoP key before any contract read or wallet call. `PeginManager` also
|
|
196
|
+
checks the wallet address before it delegates to the ETH client.
|
|
197
|
+
|
|
155
198
|
## Where to start
|
|
156
199
|
|
|
157
200
|
The SDK exposes several peer entry points — **managers**, **services**, **primitives**, **utils**, **clients**, and **integrations** — and you compose the pieces you need. The two most common starting points for a new integration are:
|
|
@@ -0,0 +1,2 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,CA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OAAA,EAEhB,CACE,KAAM,8BACN,KAAM,SACN,aAAc,QAAA,EAEhB,CACE,KAAM,yBACN,KAAM,SACN,aAAc,QAAA,EAEhB,CACE,KAAM,wBACN,KAAM,SACN,aAAc,QAAA,EAEhB,CACE,KAAM,aACN,KAAM,UACN,aAAc,SAAA,EAEhB,CACE,KAAM,sBACN,KAAM,UACN,aAAc,SAAA,EAEhB,CACE,KAAM,WACN,KAAM,UACN,aAAc,SAAA,EAEhB,CACE,KAAM,WACN,KAAM,QACN,aAAc,OAAA,EAEhB,CACE,KAAM,wBACN,KAAM,QACN,aAAc,OAAA,EAEhB,CACE,KAAM,iBACN,KAAM,UACN,aAAc,SAAA,EAEhB,CACE,KAAM,6BACN,KAAM,SACN,aAAc,QAAA,EAEhB,CACE,KAAM,oBACN,KAAM,UACN,aAAc,SAAA,EAEhB,CACE,KAAM,mBACN,KAAM,SACN,aAAc,QAAA,EAMhB,CACE,KAAM,aACN,KAAM,SACN,aAAc,QAAA,EAEhB,CACE,KAAM,oBACN,KAAM,SACN,aAAc,QAAA,EAEhB,CACE,KAAM,aACN,KAAM,SACN,aAAc,QAAA,CAChB,CACF,CACF,EAEF,gBAAiB,MAAA,CAErB"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
const i = {
|
|
2
|
+
// VaultAlreadyExists()
|
|
3
|
+
"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.",
|
|
4
|
+
// ScriptPubKeyMismatch() - taproot output doesn't match expected script
|
|
5
|
+
"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.",
|
|
6
|
+
// InvalidBTCProofOfPossession()
|
|
7
|
+
"0x6cc363a5": "Invalid BTC proof of possession: The signature could not be verified. Please ensure you're signing with the correct Bitcoin wallet.",
|
|
8
|
+
// InvalidBTCPublicKey()
|
|
9
|
+
"0x6c3f2bf6": "Invalid BTC public key: The Bitcoin public key format is invalid.",
|
|
10
|
+
// InvalidAmount()
|
|
11
|
+
"0x2c5211c6": "Invalid amount: The deposit amount is invalid or below the minimum required.",
|
|
12
|
+
// ApplicationNotRegistered()
|
|
13
|
+
"0x0405f772": "Application not registered: The application controller is not registered in the system.",
|
|
14
|
+
// InvalidProviderStatus()
|
|
15
|
+
"0x24e165cc": "Invalid provider status: The vault provider is not in a valid state to accept deposits.",
|
|
16
|
+
// ZeroAddress()
|
|
17
|
+
"0xd92e233d": "Zero address: One of the required addresses is the zero address.",
|
|
18
|
+
// BtcKeyMismatch()
|
|
19
|
+
"0x65aa7007": "BTC key mismatch: The Bitcoin public key does not match the expected key.",
|
|
20
|
+
// Unauthorized()
|
|
21
|
+
"0x82b42900": "Unauthorized: You must be the depositor or vault provider to submit this transaction.",
|
|
22
|
+
// InvalidSignature() - common signature verification error
|
|
23
|
+
"0x8baa579f": "Invalid signature: The BTC proof of possession signature could not be verified.",
|
|
24
|
+
// InvalidBtcTransaction()
|
|
25
|
+
"0x2f9d01e9": "Invalid BTC transaction: The Bitcoin transaction format is invalid.",
|
|
26
|
+
// VaultProviderNotRegistered()
|
|
27
|
+
"0x5a3c6b3e": "Vault provider not registered: The selected vault provider is not registered.",
|
|
28
|
+
// InvalidPeginFee(uint256,uint256)
|
|
29
|
+
"0x979f4518": "Invalid pegin fee: The ETH fee sent does not match the required amount. This may indicate a fee rate change during the transaction.",
|
|
30
|
+
// PrePeginOutputAlreadyUsed()
|
|
31
|
+
"0x5fad9694": "This pre-pegin output has already been used to activate another vault.",
|
|
32
|
+
// PeginTransactionAlreadyUsed()
|
|
33
|
+
"0x7ed061c9": "This pegin transaction has already been used to activate another vault.",
|
|
34
|
+
// DuplicateHashlock() — keccak256(abi.encodePacked(hashlock, msg.sender))
|
|
35
|
+
// collision in BTCVaultRegistry.hashlockToVaultId. Hashlocks are derived
|
|
36
|
+
// deterministically from the depositor's BTC wallet + selected UTXOs, so
|
|
37
|
+
// reusing the same UTXOs from the same wallet (even after a previous
|
|
38
|
+
// vault expires) produces the same hashlock and reverts here.
|
|
39
|
+
"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."
|
|
40
|
+
};
|
|
41
|
+
function s(t) {
|
|
42
|
+
return o(t, 0);
|
|
43
|
+
}
|
|
44
|
+
function o(t, r) {
|
|
45
|
+
if (r > 10 || !t || typeof t != "object") return;
|
|
46
|
+
const e = t;
|
|
47
|
+
if (typeof e.data == "string" && e.data.startsWith("0x"))
|
|
48
|
+
return e.data;
|
|
49
|
+
if (typeof e.revertData == "string" && e.revertData.startsWith("0x"))
|
|
50
|
+
return e.revertData;
|
|
51
|
+
if (typeof e.signature == "string" && e.signature.startsWith("0x"))
|
|
52
|
+
return e.signature;
|
|
53
|
+
if (typeof e.details == "string" && e.details.startsWith("0x"))
|
|
54
|
+
return e.details;
|
|
55
|
+
if (e.error && typeof e.error == "object") {
|
|
56
|
+
const n = e.error.data;
|
|
57
|
+
if (typeof n == "string" && n.startsWith("0x"))
|
|
58
|
+
return n;
|
|
59
|
+
}
|
|
60
|
+
if (e.cause) {
|
|
61
|
+
const n = o(e.cause, r + 1);
|
|
62
|
+
if (n) return n;
|
|
63
|
+
}
|
|
64
|
+
if (typeof e.walk == "function")
|
|
65
|
+
try {
|
|
66
|
+
let n;
|
|
67
|
+
if (e.walk((a) => {
|
|
68
|
+
if (a === t) return !1;
|
|
69
|
+
const c = o(a, r + 1);
|
|
70
|
+
return c ? (n = c, !0) : !1;
|
|
71
|
+
}), n) return n;
|
|
72
|
+
} catch {
|
|
73
|
+
}
|
|
74
|
+
if (r === 0) {
|
|
75
|
+
const a = (typeof e.message == "string" ? e.message : "").match(/\b(0x[a-fA-F0-9]{8})\b/);
|
|
76
|
+
if (a) return a[1];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function u(t) {
|
|
80
|
+
const r = s(t);
|
|
81
|
+
if (r) {
|
|
82
|
+
const e = r.substring(0, 10);
|
|
83
|
+
return i[r] ?? i[e];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function l(t) {
|
|
87
|
+
const r = s(t);
|
|
88
|
+
if (r === void 0) return !1;
|
|
89
|
+
const e = r.substring(0, 10);
|
|
90
|
+
return r in i || e in i;
|
|
91
|
+
}
|
|
92
|
+
function d(t) {
|
|
93
|
+
console.error("[Contract Error] Raw error:", t);
|
|
94
|
+
const r = s(t);
|
|
95
|
+
if (console.error("[Contract Error] Extracted error data:", r), r) {
|
|
96
|
+
const n = r.substring(0, 10), a = i[r] ?? i[n];
|
|
97
|
+
if (a)
|
|
98
|
+
throw console.error("[Contract Error] Known error:", a), new Error(a);
|
|
99
|
+
}
|
|
100
|
+
const e = (t == null ? void 0 : t.message) || "";
|
|
101
|
+
if (e.includes("gas limit too high") || e.includes("21000000") || e.includes("Internal JSON-RPC error")) {
|
|
102
|
+
const n = r ? ` (error code: ${r})` : "";
|
|
103
|
+
throw console.error(
|
|
104
|
+
"[Contract Error] Transaction rejected. Error code:",
|
|
105
|
+
r,
|
|
106
|
+
"Message:",
|
|
107
|
+
e
|
|
108
|
+
), new Error(
|
|
109
|
+
`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.`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
throw t instanceof Error ? (console.error("[Contract Error] Unhandled error:", t.message), t) : new Error(`Contract call failed: ${String(t)}`);
|
|
113
|
+
}
|
|
114
|
+
const p = [
|
|
115
|
+
{
|
|
116
|
+
type: "function",
|
|
117
|
+
name: "getBtcVaultProtocolInfo",
|
|
118
|
+
inputs: [
|
|
119
|
+
{
|
|
120
|
+
name: "vaultId",
|
|
121
|
+
type: "bytes32",
|
|
122
|
+
internalType: "bytes32"
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
outputs: [
|
|
126
|
+
{
|
|
127
|
+
name: "vProtocol",
|
|
128
|
+
type: "tuple",
|
|
129
|
+
internalType: "struct BTCVaultRegistryTypes.BTCVaultProtocolInfo",
|
|
130
|
+
components: [
|
|
131
|
+
{
|
|
132
|
+
name: "depositorSignedPeginTx",
|
|
133
|
+
type: "bytes",
|
|
134
|
+
internalType: "bytes"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "universalChallengersVersion",
|
|
138
|
+
type: "uint16",
|
|
139
|
+
internalType: "uint16"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "appVaultKeepersVersion",
|
|
143
|
+
type: "uint16",
|
|
144
|
+
internalType: "uint16"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "offchainParamsVersion",
|
|
148
|
+
type: "uint16",
|
|
149
|
+
internalType: "uint16"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "verifiedAt",
|
|
153
|
+
type: "uint256",
|
|
154
|
+
internalType: "uint256"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: "depositorWotsPkHash",
|
|
158
|
+
type: "bytes32",
|
|
159
|
+
internalType: "bytes32"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "hashlock",
|
|
163
|
+
type: "bytes32",
|
|
164
|
+
internalType: "bytes32"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "htlcVout",
|
|
168
|
+
type: "uint8",
|
|
169
|
+
internalType: "uint8"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: "depositorPopSignature",
|
|
173
|
+
type: "bytes",
|
|
174
|
+
internalType: "bytes"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: "prePeginTxHash",
|
|
178
|
+
type: "bytes32",
|
|
179
|
+
internalType: "bytes32"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: "vaultProviderCommissionBps",
|
|
183
|
+
type: "uint16",
|
|
184
|
+
internalType: "uint16"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: "claimExpiredUntil",
|
|
188
|
+
type: "uint256",
|
|
189
|
+
internalType: "uint256"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "vaultCoreVersion",
|
|
193
|
+
type: "uint16",
|
|
194
|
+
internalType: "uint16"
|
|
195
|
+
},
|
|
196
|
+
// RFC-006: per-pegin operation-key epochs, frozen at
|
|
197
|
+
// `submitPeginRequest`. All three pack into one storage slot and were
|
|
198
|
+
// appended after `vaultCoreVersion` so pre-existing rows decode
|
|
199
|
+
// unchanged.
|
|
200
|
+
{
|
|
201
|
+
name: "vpKeyEpoch",
|
|
202
|
+
type: "uint64",
|
|
203
|
+
internalType: "uint64"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: "appKeeperKeyEpoch",
|
|
207
|
+
type: "uint64",
|
|
208
|
+
internalType: "uint64"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
name: "ucKeyEpoch",
|
|
212
|
+
type: "uint64",
|
|
213
|
+
internalType: "uint64"
|
|
214
|
+
}
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
],
|
|
218
|
+
stateMutability: "view"
|
|
219
|
+
}
|
|
220
|
+
];
|
|
221
|
+
export {
|
|
222
|
+
p as B,
|
|
223
|
+
i as C,
|
|
224
|
+
s as e,
|
|
225
|
+
u as g,
|
|
226
|
+
d as h,
|
|
227
|
+
l as i
|
|
228
|
+
};
|
|
229
|
+
//# sourceMappingURL=BTCVaultRegistryKeyEpochs.abi-D8cIbMtH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"],"mappings":"AAeO,MAAMA,IAA0C;AAAA;AAAA,EAErD,cACE;AAAA;AAAA,EAGF,cACE;AAAA;AAAA,EAGF,cACE;AAAA;AAAA,EAGF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAEF,cACE;AAAA;AAAA,EAGF,cACE;AAAA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