@babylonlabs-io/ts-sdk 0.18.0 → 0.20.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 -12
- package/dist/bitcoin-CNnPFU6Y.cjs +2 -0
- package/dist/bitcoin-CNnPFU6Y.cjs.map +1 -0
- package/dist/{constants-Q7v2O7Ps.js → bitcoin-nOOgeRyl.js} +64 -76
- package/dist/bitcoin-nOOgeRyl.js.map +1 -0
- package/dist/buildAndBroadcastRefund-DWEQvj9T.cjs +2 -0
- package/dist/buildAndBroadcastRefund-DWEQvj9T.cjs.map +1 -0
- package/dist/buildAndBroadcastRefund-DnTQkCgG.js +1331 -0
- package/dist/buildAndBroadcastRefund-DnTQkCgG.js.map +1 -0
- package/dist/challengeAssert-D1lpvuMv.js +283 -0
- package/dist/challengeAssert-D1lpvuMv.js.map +1 -0
- package/dist/challengeAssert-nYlgeAI8.cjs +2 -0
- package/dist/challengeAssert-nYlgeAI8.cjs.map +1 -0
- package/dist/errors-BZON3Wmn.cjs +2 -0
- package/dist/errors-BZON3Wmn.cjs.map +1 -0
- package/dist/errors-CHY4WNi-.js +1226 -0
- package/dist/errors-CHY4WNi-.js.map +1 -0
- package/dist/fundPeginTransaction-BLYXxLBv.js +70 -0
- package/dist/fundPeginTransaction-BLYXxLBv.js.map +1 -0
- package/dist/fundPeginTransaction-DxNOeyNI.cjs +2 -0
- package/dist/fundPeginTransaction-DxNOeyNI.cjs.map +1 -0
- package/dist/index-BpXpESWu.cjs +2 -0
- package/dist/index-BpXpESWu.cjs.map +1 -0
- package/dist/index-CFwoGJNQ.js +1141 -0
- package/dist/index-CFwoGJNQ.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +134 -100
- package/dist/payout-DzGsAnhf.js +261 -0
- package/dist/payout-DzGsAnhf.js.map +1 -0
- package/dist/payout-RFIh7GLN.cjs +2 -0
- package/dist/payout-RFIh7GLN.cjs.map +1 -0
- package/dist/psbtInputFields-C-zYR1z7.cjs +2 -0
- package/dist/psbtInputFields-C-zYR1z7.cjs.map +1 -0
- package/dist/psbtInputFields-Dx41_IoI.js +229 -0
- package/dist/psbtInputFields-Dx41_IoI.js.map +1 -0
- package/dist/signing-DeWVBl7m.js +64 -0
- package/dist/signing-DeWVBl7m.js.map +1 -0
- package/dist/signing-cl-lowxV.cjs +2 -0
- package/dist/signing-cl-lowxV.cjs.map +1 -0
- package/dist/tbv/core/clients/eth/__tests__/protocol-params-reader.test.d.ts +2 -0
- package/dist/tbv/core/clients/eth/__tests__/protocol-params-reader.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/__tests__/signer-set-reader.test.d.ts +2 -0
- package/dist/tbv/core/clients/eth/__tests__/signer-set-reader.test.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/contract-address-resolver.d.ts +18 -0
- package/dist/tbv/core/clients/eth/contract-address-resolver.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/index.d.ts +4 -1
- package/dist/tbv/core/clients/eth/index.d.ts.map +1 -1
- package/dist/tbv/core/clients/eth/protocol-params-reader.d.ts +27 -0
- package/dist/tbv/core/clients/eth/protocol-params-reader.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/signer-set-reader.d.ts +37 -0
- package/dist/tbv/core/clients/eth/signer-set-reader.d.ts.map +1 -0
- package/dist/tbv/core/clients/eth/types.d.ts +80 -0
- package/dist/tbv/core/clients/eth/types.d.ts.map +1 -1
- package/dist/tbv/core/clients/index.cjs +1 -1
- package/dist/tbv/core/clients/index.js +25 -21
- package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts +74 -0
- package/dist/tbv/core/contracts/abis/ApplicationRegistry.abi.d.ts.map +1 -0
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts +20 -0
- package/dist/tbv/core/contracts/abis/BTCVaultRegistry.abi.d.ts.map +1 -1
- package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts +233 -0
- package/dist/tbv/core/contracts/abis/ProtocolParams.abi.d.ts.map +1 -0
- package/dist/tbv/core/contracts/index.d.ts +2 -0
- package/dist/tbv/core/contracts/index.d.ts.map +1 -1
- package/dist/tbv/core/index.cjs +1 -1
- package/dist/tbv/core/index.d.ts +3 -1
- package/dist/tbv/core/index.d.ts.map +1 -1
- package/dist/tbv/core/index.js +129 -95
- package/dist/tbv/core/managers/PeginManager.d.ts +1 -1
- package/dist/tbv/core/primitives/index.cjs +1 -1
- package/dist/tbv/core/primitives/index.d.ts +3 -2
- package/dist/tbv/core/primitives/index.d.ts.map +1 -1
- package/dist/tbv/core/primitives/index.js +24 -23
- package/dist/tbv/core/primitives/psbt/__tests__/helpers.d.ts +1 -1
- package/dist/tbv/core/primitives/psbt/index.d.ts +1 -1
- package/dist/tbv/core/primitives/psbt/payout.d.ts.map +1 -1
- package/dist/tbv/core/primitives/psbt/pegin.d.ts +2 -3
- package/dist/tbv/core/primitives/psbt/pegin.d.ts.map +1 -1
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts +4 -0
- package/dist/tbv/core/primitives/utils/bitcoin.d.ts.map +1 -1
- package/dist/tbv/core/primitives/utils/index.d.ts +1 -1
- package/dist/tbv/core/primitives/utils/index.d.ts.map +1 -1
- package/dist/tbv/core/services/activation/__tests__/activateVault.test.d.ts +2 -0
- package/dist/tbv/core/services/activation/__tests__/activateVault.test.d.ts.map +1 -0
- package/dist/tbv/core/services/activation/activateVault.d.ts +77 -0
- package/dist/tbv/core/services/activation/activateVault.d.ts.map +1 -0
- package/dist/tbv/core/services/activation/index.d.ts +7 -0
- package/dist/tbv/core/services/activation/index.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/__tests__/peginState.test.d.ts +2 -0
- package/dist/tbv/core/services/deposit/__tests__/peginState.test.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/__tests__/validation.test.d.ts +5 -0
- package/dist/tbv/core/services/deposit/__tests__/validation.test.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/index.d.ts +4 -0
- package/dist/tbv/core/services/deposit/index.d.ts.map +1 -1
- package/dist/tbv/core/services/deposit/peginState.d.ts +93 -0
- package/dist/tbv/core/services/deposit/peginState.d.ts.map +1 -0
- package/dist/tbv/core/services/deposit/validation.d.ts +114 -0
- package/dist/tbv/core/services/deposit/validation.d.ts.map +1 -0
- package/dist/tbv/core/services/htlc/__tests__/htlc.test.d.ts +2 -0
- package/dist/tbv/core/services/htlc/__tests__/htlc.test.d.ts.map +1 -0
- package/dist/tbv/core/services/htlc/index.d.ts +25 -0
- package/dist/tbv/core/services/htlc/index.d.ts.map +1 -0
- package/dist/tbv/core/services/index.cjs +1 -1
- package/dist/tbv/core/services/index.d.ts +4 -0
- package/dist/tbv/core/services/index.d.ts.map +1 -1
- package/dist/tbv/core/services/index.js +25 -5
- package/dist/tbv/core/services/index.js.map +1 -1
- package/dist/tbv/core/services/pegout/__tests__/state.test.d.ts +2 -0
- package/dist/tbv/core/services/pegout/__tests__/state.test.d.ts.map +1 -0
- package/dist/tbv/core/services/pegout/index.d.ts +2 -0
- package/dist/tbv/core/services/pegout/index.d.ts.map +1 -0
- package/dist/tbv/core/services/pegout/state.d.ts +30 -0
- package/dist/tbv/core/services/pegout/state.d.ts.map +1 -0
- package/dist/tbv/core/services/refund/__tests__/buildAndBroadcastRefund.test.d.ts +2 -0
- package/dist/tbv/core/services/refund/__tests__/buildAndBroadcastRefund.test.d.ts.map +1 -0
- package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts +103 -0
- package/dist/tbv/core/services/refund/buildAndBroadcastRefund.d.ts.map +1 -0
- package/dist/tbv/core/services/refund/errors.d.ts +13 -0
- package/dist/tbv/core/services/refund/errors.d.ts.map +1 -0
- package/dist/tbv/core/services/refund/index.d.ts +8 -0
- package/dist/tbv/core/services/refund/index.d.ts.map +1 -0
- package/dist/tbv/core/utils/index.cjs +1 -1
- package/dist/tbv/core/utils/index.js +30 -24
- package/dist/tbv/core/utils/transaction/fundPeginTransaction.d.ts +1 -1
- package/dist/tbv/core/utils/utxo/__tests__/availability.test.d.ts +3 -0
- package/dist/tbv/core/utils/utxo/__tests__/availability.test.d.ts.map +1 -0
- package/dist/tbv/core/utils/utxo/__tests__/reservation.test.d.ts +3 -0
- package/dist/tbv/core/utils/utxo/__tests__/reservation.test.d.ts.map +1 -0
- package/dist/tbv/core/utils/utxo/availability.d.ts +62 -0
- package/dist/tbv/core/utils/utxo/availability.d.ts.map +1 -0
- package/dist/tbv/core/utils/utxo/index.d.ts +2 -0
- package/dist/tbv/core/utils/utxo/index.d.ts.map +1 -1
- package/dist/tbv/core/utils/utxo/reservation.d.ts +65 -0
- package/dist/tbv/core/utils/utxo/reservation.d.ts.map +1 -0
- package/dist/tbv/core/wots/__tests__/blockDerivation.test.d.ts +2 -0
- package/dist/tbv/core/wots/__tests__/blockDerivation.test.d.ts.map +1 -0
- package/dist/tbv/core/wots/blockDerivation.d.ts +36 -0
- package/dist/tbv/core/wots/blockDerivation.d.ts.map +1 -0
- package/dist/tbv/core/wots/index.d.ts +1 -0
- package/dist/tbv/core/wots/index.d.ts.map +1 -1
- package/dist/tbv/index.cjs +1 -1
- package/dist/tbv/index.js +129 -95
- package/dist/tbv/integrations/aave/index.cjs +1 -1
- package/dist/tbv/integrations/aave/index.cjs.map +1 -1
- package/dist/tbv/integrations/aave/index.d.ts +3 -3
- package/dist/tbv/integrations/aave/index.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/index.js +145 -169
- package/dist/tbv/integrations/aave/index.js.map +1 -1
- package/dist/tbv/integrations/aave/utils/healthFactor.d.ts +0 -30
- package/dist/tbv/integrations/aave/utils/healthFactor.d.ts.map +1 -1
- package/dist/tbv/integrations/aave/utils/index.d.ts +2 -2
- package/dist/tbv/integrations/aave/utils/index.d.ts.map +1 -1
- package/dist/types-B-p4dhEH.cjs +2 -0
- package/dist/types-B-p4dhEH.cjs.map +1 -0
- package/dist/types-DWjaqVfP.js +608 -0
- package/dist/types-DWjaqVfP.js.map +1 -0
- package/package.json +5 -1
- package/dist/challengeAssert-D_k_ADgP.cjs +0 -2
- package/dist/challengeAssert-D_k_ADgP.cjs.map +0 -1
- package/dist/challengeAssert-k5_LWUtO.js +0 -362
- package/dist/challengeAssert-k5_LWUtO.js.map +0 -1
- package/dist/constants-EiyZkXce.cjs +0 -2
- package/dist/constants-EiyZkXce.cjs.map +0 -1
- package/dist/constants-Q7v2O7Ps.js.map +0 -1
- package/dist/errors-DAKpPfl7.cjs +0 -2
- package/dist/errors-DAKpPfl7.cjs.map +0 -1
- package/dist/errors-DARTQrP3.js +0 -1510
- package/dist/errors-DARTQrP3.js.map +0 -1
- package/dist/fundPeginTransaction-DpwnDslW.js +0 -50
- package/dist/fundPeginTransaction-DpwnDslW.js.map +0 -1
- package/dist/fundPeginTransaction-EbrZzlrh.cjs +0 -2
- package/dist/fundPeginTransaction-EbrZzlrh.cjs.map +0 -1
- package/dist/index-DKfhZvdn.cjs +0 -2
- package/dist/index-DKfhZvdn.cjs.map +0 -1
- package/dist/index-qIcjkxLw.js +0 -911
- package/dist/index-qIcjkxLw.js.map +0 -1
- package/dist/payout-Ce9vSs9e.js +0 -164
- package/dist/payout-Ce9vSs9e.js.map +0 -1
- package/dist/payout-CfsDnjKI.cjs +0 -2
- package/dist/payout-CfsDnjKI.cjs.map +0 -1
- package/dist/psbtInputFields-C0nKn_GD.cjs +0 -2
- package/dist/psbtInputFields-C0nKn_GD.cjs.map +0 -1
- package/dist/psbtInputFields-DO0ELwiv.js +0 -116
- package/dist/psbtInputFields-DO0ELwiv.js.map +0 -1
- package/dist/signAndSubmitPayouts-CAOEAQp9.js +0 -490
- package/dist/signAndSubmitPayouts-CAOEAQp9.js.map +0 -1
- package/dist/signAndSubmitPayouts-CSJmcPQN.cjs +0 -2
- package/dist/signAndSubmitPayouts-CSJmcPQN.cjs.map +0 -1
- package/dist/signing-Deg5lCoC.cjs +0 -2
- package/dist/signing-Deg5lCoC.cjs.map +0 -1
- package/dist/signing-Drwr3bXB.js +0 -16
- package/dist/signing-Drwr3bXB.js.map +0 -1
- package/dist/types-D1rYwwCu.js +0 -235
- package/dist/types-D1rYwwCu.js.map +0 -1
- package/dist/types-DEWiqXYp.cjs +0 -2
- package/dist/types-DEWiqXYp.cjs.map +0 -1
package/dist/index-qIcjkxLw.js
DELETED
|
@@ -1,911 +0,0 @@
|
|
|
1
|
-
var E = Object.defineProperty;
|
|
2
|
-
var A = (n, t, e) => t in n ? E(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
-
var g = (n, t, e) => A(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
import { D as I, J as S } from "./types-D1rYwwCu.js";
|
|
5
|
-
const F = 21e6 * 1e8, m = 3e4;
|
|
6
|
-
async function d(n, t) {
|
|
7
|
-
const e = new AbortController(), r = setTimeout(
|
|
8
|
-
() => e.abort(),
|
|
9
|
-
m
|
|
10
|
-
), o = [e.signal, t == null ? void 0 : t.signal].filter(
|
|
11
|
-
Boolean
|
|
12
|
-
);
|
|
13
|
-
try {
|
|
14
|
-
return await fetch(n, {
|
|
15
|
-
...t,
|
|
16
|
-
signal: AbortSignal.any(o)
|
|
17
|
-
});
|
|
18
|
-
} catch (s) {
|
|
19
|
-
throw clearTimeout(r), s != null && typeof s == "object" && "name" in s && s.name === "AbortError" ? new Error(
|
|
20
|
-
`Mempool API request timed out after ${m}ms: ${n}`
|
|
21
|
-
) : s;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const P = 1e4;
|
|
25
|
-
function v(n) {
|
|
26
|
-
return Number.isInteger(n) && n > 0 && n <= F;
|
|
27
|
-
}
|
|
28
|
-
function k(n) {
|
|
29
|
-
return Number.isInteger(n) && n > 0 && n <= P;
|
|
30
|
-
}
|
|
31
|
-
function T(n, t) {
|
|
32
|
-
return !Number.isInteger(n) || n < 0 ? !1 : t === void 0 || n < t;
|
|
33
|
-
}
|
|
34
|
-
const j = {
|
|
35
|
-
mainnet: "https://mempool.space/api",
|
|
36
|
-
testnet: "https://mempool.space/testnet/api",
|
|
37
|
-
signet: "https://mempool.space/signet/api"
|
|
38
|
-
};
|
|
39
|
-
async function c(n, t) {
|
|
40
|
-
try {
|
|
41
|
-
const e = await d(n, t);
|
|
42
|
-
if (!e.ok) {
|
|
43
|
-
const o = await e.text();
|
|
44
|
-
throw new Error(
|
|
45
|
-
`Mempool API error (${e.status}): ${o || e.statusText}`
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
const r = e.headers.get("content-type");
|
|
49
|
-
return r != null && r.includes("application/json") ? await e.json() : await e.text();
|
|
50
|
-
} catch (e) {
|
|
51
|
-
throw e instanceof Error ? new Error(`Failed to fetch from mempool API: ${e.message}`) : new Error("Failed to fetch from mempool API: Unknown error");
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async function Y(n, t) {
|
|
55
|
-
try {
|
|
56
|
-
const e = await d(`${t}/tx`, {
|
|
57
|
-
method: "POST",
|
|
58
|
-
body: n,
|
|
59
|
-
headers: {
|
|
60
|
-
"Content-Type": "text/plain"
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
if (!e.ok) {
|
|
64
|
-
const o = await e.text();
|
|
65
|
-
let s;
|
|
66
|
-
try {
|
|
67
|
-
s = JSON.parse(o).message;
|
|
68
|
-
} catch {
|
|
69
|
-
s = o;
|
|
70
|
-
}
|
|
71
|
-
throw new Error(
|
|
72
|
-
s || `Failed to broadcast transaction: ${e.statusText}`
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
return await e.text();
|
|
76
|
-
} catch (e) {
|
|
77
|
-
throw e instanceof Error ? new Error(`Failed to broadcast BTC transaction: ${e.message}`) : new Error("Failed to broadcast BTC transaction: Unknown error");
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
async function B(n, t) {
|
|
81
|
-
return c(`${t}/tx/${n}`);
|
|
82
|
-
}
|
|
83
|
-
async function z(n, t) {
|
|
84
|
-
try {
|
|
85
|
-
const e = await d(`${t}/tx/${n}/hex`);
|
|
86
|
-
if (!e.ok) {
|
|
87
|
-
const r = await e.text();
|
|
88
|
-
throw new Error(
|
|
89
|
-
`Mempool API error (${e.status}): ${r || e.statusText}`
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
return await e.text();
|
|
93
|
-
} catch (e) {
|
|
94
|
-
throw e instanceof Error ? new Error(`Failed to get transaction hex for ${n}: ${e.message}`) : new Error(`Failed to get transaction hex for ${n}: Unknown error`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
async function Q(n, t, e) {
|
|
98
|
-
const r = await B(n, e);
|
|
99
|
-
if (!T(t, r.vout.length))
|
|
100
|
-
throw new Error(
|
|
101
|
-
`Invalid vout ${t} for transaction ${n} (has ${r.vout.length} outputs)`
|
|
102
|
-
);
|
|
103
|
-
const o = r.vout[t];
|
|
104
|
-
if (!v(o.value))
|
|
105
|
-
throw new Error(`Invalid UTXO value ${o.value} for ${n}:${t}`);
|
|
106
|
-
return {
|
|
107
|
-
txid: n,
|
|
108
|
-
vout: t,
|
|
109
|
-
value: o.value,
|
|
110
|
-
scriptPubKey: o.scriptpubkey
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
async function Z(n, t) {
|
|
114
|
-
try {
|
|
115
|
-
const e = await c(`${t}/address/${n}/utxo`), r = await c(`${t}/v1/validate-address/${n}`);
|
|
116
|
-
if (!r.isvalid)
|
|
117
|
-
throw new Error(
|
|
118
|
-
`Invalid Bitcoin address: ${n}. Mempool API validation failed.`
|
|
119
|
-
);
|
|
120
|
-
for (const s of e) {
|
|
121
|
-
if (!T(s.vout))
|
|
122
|
-
throw new Error(`Invalid vout ${s.vout} for ${s.txid}`);
|
|
123
|
-
if (!v(s.value))
|
|
124
|
-
throw new Error(
|
|
125
|
-
`Invalid UTXO value ${s.value} for ${s.txid}:${s.vout}`
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
return e.sort((s, f) => f.value - s.value).map((s) => ({
|
|
129
|
-
txid: s.txid,
|
|
130
|
-
vout: s.vout,
|
|
131
|
-
value: s.value,
|
|
132
|
-
scriptPubKey: r.scriptPubKey,
|
|
133
|
-
confirmed: s.status.confirmed
|
|
134
|
-
}));
|
|
135
|
-
} catch (e) {
|
|
136
|
-
throw e instanceof Error ? new Error(
|
|
137
|
-
`Failed to get UTXOs for address ${n}: ${e.message}`
|
|
138
|
-
) : new Error(
|
|
139
|
-
`Failed to get UTXOs for address ${n}: Unknown error`
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
function ee(n) {
|
|
144
|
-
return j[n];
|
|
145
|
-
}
|
|
146
|
-
async function te(n, t) {
|
|
147
|
-
return c(`${t}/address/${n}/txs`);
|
|
148
|
-
}
|
|
149
|
-
async function ne(n) {
|
|
150
|
-
const t = await d(`${n}/v1/fees/recommended`);
|
|
151
|
-
if (!t.ok)
|
|
152
|
-
throw new Error(
|
|
153
|
-
`Failed to fetch network fees: ${t.status} ${t.statusText}`
|
|
154
|
-
);
|
|
155
|
-
const e = await t.json(), r = [
|
|
156
|
-
"fastestFee",
|
|
157
|
-
"halfHourFee",
|
|
158
|
-
"hourFee",
|
|
159
|
-
"economyFee",
|
|
160
|
-
"minimumFee"
|
|
161
|
-
];
|
|
162
|
-
for (const o of r)
|
|
163
|
-
if (!k(e[o]))
|
|
164
|
-
throw new Error(
|
|
165
|
-
`Invalid fee rate ${o}=${e[o]} from mempool API: expected a positive number ≤ ${P}`
|
|
166
|
-
);
|
|
167
|
-
if (e.minimumFee > e.economyFee || e.economyFee > e.hourFee || e.hourFee > e.halfHourFee || e.halfHourFee > e.fastestFee)
|
|
168
|
-
throw new Error(
|
|
169
|
-
`Fee rate ordering violation from mempool API: expected minimumFee (${e.minimumFee}) <= economyFee (${e.economyFee}) <= hourFee (${e.hourFee}) <= halfHourFee (${e.halfHourFee}) <= fastestFee (${e.fastestFee}).`
|
|
170
|
-
);
|
|
171
|
-
return e;
|
|
172
|
-
}
|
|
173
|
-
const h = [
|
|
174
|
-
{
|
|
175
|
-
type: "function",
|
|
176
|
-
name: "submitPeginRequest",
|
|
177
|
-
inputs: [
|
|
178
|
-
{
|
|
179
|
-
name: "depositor",
|
|
180
|
-
type: "address",
|
|
181
|
-
internalType: "address"
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
name: "depositorBtcPubKey",
|
|
185
|
-
type: "bytes32",
|
|
186
|
-
internalType: "bytes32"
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
name: "btcPopSignature",
|
|
190
|
-
type: "bytes",
|
|
191
|
-
internalType: "bytes"
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
name: "unsignedPrePeginTx",
|
|
195
|
-
type: "bytes",
|
|
196
|
-
internalType: "bytes"
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
name: "depositorSignedPeginTx",
|
|
200
|
-
type: "bytes",
|
|
201
|
-
internalType: "bytes"
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
name: "vaultProvider",
|
|
205
|
-
type: "address",
|
|
206
|
-
internalType: "address"
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
name: "hashlock",
|
|
210
|
-
type: "bytes32",
|
|
211
|
-
internalType: "bytes32"
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
name: "htlcVout",
|
|
215
|
-
type: "uint8",
|
|
216
|
-
internalType: "uint8"
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
name: "depositorPayoutBtcAddress",
|
|
220
|
-
type: "bytes",
|
|
221
|
-
internalType: "bytes"
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
name: "depositorWotsPkHash",
|
|
225
|
-
type: "bytes32",
|
|
226
|
-
internalType: "bytes32"
|
|
227
|
-
}
|
|
228
|
-
],
|
|
229
|
-
outputs: [
|
|
230
|
-
{
|
|
231
|
-
name: "",
|
|
232
|
-
type: "bytes32",
|
|
233
|
-
internalType: "bytes32"
|
|
234
|
-
}
|
|
235
|
-
],
|
|
236
|
-
stateMutability: "payable"
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
type: "function",
|
|
240
|
-
name: "submitPeginRequest",
|
|
241
|
-
inputs: [
|
|
242
|
-
{
|
|
243
|
-
name: "depositor",
|
|
244
|
-
type: "address",
|
|
245
|
-
internalType: "address"
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
name: "depositorBtcPubKey",
|
|
249
|
-
type: "bytes32",
|
|
250
|
-
internalType: "bytes32"
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
name: "btcPopSignature",
|
|
254
|
-
type: "bytes",
|
|
255
|
-
internalType: "bytes"
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
name: "unsignedPrePeginTx",
|
|
259
|
-
type: "bytes",
|
|
260
|
-
internalType: "bytes"
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
name: "depositorSignedPeginTx",
|
|
264
|
-
type: "bytes",
|
|
265
|
-
internalType: "bytes"
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
name: "vaultProvider",
|
|
269
|
-
type: "address",
|
|
270
|
-
internalType: "address"
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
name: "hashlock",
|
|
274
|
-
type: "bytes32",
|
|
275
|
-
internalType: "bytes32"
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
name: "htlcVout",
|
|
279
|
-
type: "uint8",
|
|
280
|
-
internalType: "uint8"
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
name: "referralCode",
|
|
284
|
-
type: "uint32",
|
|
285
|
-
internalType: "uint32"
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
name: "depositorPayoutBtcAddress",
|
|
289
|
-
type: "bytes",
|
|
290
|
-
internalType: "bytes"
|
|
291
|
-
},
|
|
292
|
-
{
|
|
293
|
-
name: "depositorWotsPkHash",
|
|
294
|
-
type: "bytes32",
|
|
295
|
-
internalType: "bytes32"
|
|
296
|
-
}
|
|
297
|
-
],
|
|
298
|
-
outputs: [
|
|
299
|
-
{
|
|
300
|
-
name: "",
|
|
301
|
-
type: "bytes32",
|
|
302
|
-
internalType: "bytes32"
|
|
303
|
-
}
|
|
304
|
-
],
|
|
305
|
-
stateMutability: "payable"
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
type: "function",
|
|
309
|
-
name: "submitPeginRequestBatch",
|
|
310
|
-
inputs: [
|
|
311
|
-
{ name: "depositor", type: "address", internalType: "address" },
|
|
312
|
-
{ name: "vaultProvider", type: "address", internalType: "address" },
|
|
313
|
-
{
|
|
314
|
-
name: "requests",
|
|
315
|
-
type: "tuple[]",
|
|
316
|
-
internalType: "struct IBTCVaultRegistry.BatchPeginRequest[]",
|
|
317
|
-
components: [
|
|
318
|
-
{ name: "depositorBtcPubKey", type: "bytes32", internalType: "bytes32" },
|
|
319
|
-
{ name: "btcPopSignature", type: "bytes", internalType: "bytes" },
|
|
320
|
-
{ name: "unsignedPrePeginTx", type: "bytes", internalType: "bytes" },
|
|
321
|
-
{ name: "depositorSignedPeginTx", type: "bytes", internalType: "bytes" },
|
|
322
|
-
{ name: "hashlock", type: "bytes32", internalType: "bytes32" },
|
|
323
|
-
{ name: "htlcVout", type: "uint8", internalType: "uint8" },
|
|
324
|
-
{ name: "referralCode", type: "uint32", internalType: "uint32" },
|
|
325
|
-
{ name: "depositorPayoutBtcAddress", type: "bytes", internalType: "bytes" },
|
|
326
|
-
{ name: "depositorWotsPkHash", type: "bytes32", internalType: "bytes32" }
|
|
327
|
-
]
|
|
328
|
-
}
|
|
329
|
-
],
|
|
330
|
-
outputs: [
|
|
331
|
-
{ name: "vaultIds", type: "bytes32[]", internalType: "bytes32[]" }
|
|
332
|
-
],
|
|
333
|
-
stateMutability: "payable"
|
|
334
|
-
},
|
|
335
|
-
{
|
|
336
|
-
type: "function",
|
|
337
|
-
name: "activateVaultWithSecret",
|
|
338
|
-
inputs: [
|
|
339
|
-
{
|
|
340
|
-
name: "vaultId",
|
|
341
|
-
type: "bytes32",
|
|
342
|
-
internalType: "bytes32"
|
|
343
|
-
},
|
|
344
|
-
{
|
|
345
|
-
name: "s",
|
|
346
|
-
type: "bytes32",
|
|
347
|
-
internalType: "bytes32"
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
name: "activationMetadata",
|
|
351
|
-
type: "bytes",
|
|
352
|
-
internalType: "bytes"
|
|
353
|
-
}
|
|
354
|
-
],
|
|
355
|
-
outputs: [],
|
|
356
|
-
stateMutability: "nonpayable"
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
type: "function",
|
|
360
|
-
name: "getPegInFee",
|
|
361
|
-
inputs: [
|
|
362
|
-
{
|
|
363
|
-
name: "vaultProvider",
|
|
364
|
-
type: "address",
|
|
365
|
-
internalType: "address"
|
|
366
|
-
}
|
|
367
|
-
],
|
|
368
|
-
outputs: [
|
|
369
|
-
{
|
|
370
|
-
name: "totalFee",
|
|
371
|
-
type: "uint256",
|
|
372
|
-
internalType: "uint256"
|
|
373
|
-
}
|
|
374
|
-
],
|
|
375
|
-
stateMutability: "view"
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
type: "function",
|
|
379
|
-
name: "getBtcVaultBasicInfo",
|
|
380
|
-
inputs: [
|
|
381
|
-
{
|
|
382
|
-
name: "vaultId",
|
|
383
|
-
type: "bytes32",
|
|
384
|
-
internalType: "bytes32"
|
|
385
|
-
}
|
|
386
|
-
],
|
|
387
|
-
outputs: [
|
|
388
|
-
{ name: "depositor", type: "address", internalType: "address" },
|
|
389
|
-
{ name: "depositorBtcPubKey", type: "bytes32", internalType: "bytes32" },
|
|
390
|
-
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
391
|
-
{ name: "vaultProvider", type: "address", internalType: "address" },
|
|
392
|
-
{ name: "status", type: "uint8", internalType: "enum IBTCVaultRegistry.BTCVaultStatus" },
|
|
393
|
-
{ name: "applicationEntryPoint", type: "address", internalType: "address" },
|
|
394
|
-
{ name: "createdAt", type: "uint256", internalType: "uint256" }
|
|
395
|
-
],
|
|
396
|
-
stateMutability: "view"
|
|
397
|
-
},
|
|
398
|
-
{
|
|
399
|
-
type: "error",
|
|
400
|
-
name: "InvalidPeginFee",
|
|
401
|
-
inputs: [
|
|
402
|
-
{
|
|
403
|
-
name: "provided",
|
|
404
|
-
type: "uint256",
|
|
405
|
-
internalType: "uint256"
|
|
406
|
-
},
|
|
407
|
-
{
|
|
408
|
-
name: "required",
|
|
409
|
-
type: "uint256",
|
|
410
|
-
internalType: "uint256"
|
|
411
|
-
}
|
|
412
|
-
]
|
|
413
|
-
},
|
|
414
|
-
{
|
|
415
|
-
type: "error",
|
|
416
|
-
name: "InvalidSecret",
|
|
417
|
-
inputs: []
|
|
418
|
-
},
|
|
419
|
-
{
|
|
420
|
-
type: "error",
|
|
421
|
-
name: "ActivationDeadlineExpired",
|
|
422
|
-
inputs: []
|
|
423
|
-
},
|
|
424
|
-
{
|
|
425
|
-
type: "error",
|
|
426
|
-
name: "InvalidHashlock",
|
|
427
|
-
inputs: []
|
|
428
|
-
},
|
|
429
|
-
{
|
|
430
|
-
type: "error",
|
|
431
|
-
name: "DuplicateHashlock",
|
|
432
|
-
inputs: []
|
|
433
|
-
},
|
|
434
|
-
{
|
|
435
|
-
type: "error",
|
|
436
|
-
name: "CapExceeded",
|
|
437
|
-
inputs: []
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
type: "error",
|
|
441
|
-
name: "InvalidOutputIndex",
|
|
442
|
-
inputs: []
|
|
443
|
-
},
|
|
444
|
-
{
|
|
445
|
-
type: "error",
|
|
446
|
-
name: "PeginSignaturesIncomplete",
|
|
447
|
-
inputs: []
|
|
448
|
-
},
|
|
449
|
-
{
|
|
450
|
-
type: "function",
|
|
451
|
-
name: "getBtcVaultProtocolInfo",
|
|
452
|
-
inputs: [
|
|
453
|
-
{
|
|
454
|
-
name: "vaultId",
|
|
455
|
-
type: "bytes32",
|
|
456
|
-
internalType: "bytes32"
|
|
457
|
-
}
|
|
458
|
-
],
|
|
459
|
-
outputs: [
|
|
460
|
-
{
|
|
461
|
-
name: "depositorSignedPeginTx",
|
|
462
|
-
type: "bytes",
|
|
463
|
-
internalType: "bytes"
|
|
464
|
-
},
|
|
465
|
-
{
|
|
466
|
-
name: "universalChallengersVersion",
|
|
467
|
-
type: "uint32",
|
|
468
|
-
internalType: "uint32"
|
|
469
|
-
},
|
|
470
|
-
{
|
|
471
|
-
name: "appVaultKeepersVersion",
|
|
472
|
-
type: "uint32",
|
|
473
|
-
internalType: "uint32"
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
name: "offchainParamsVersion",
|
|
477
|
-
type: "uint32",
|
|
478
|
-
internalType: "uint32"
|
|
479
|
-
},
|
|
480
|
-
{
|
|
481
|
-
name: "verifiedAt",
|
|
482
|
-
type: "uint256",
|
|
483
|
-
internalType: "uint256"
|
|
484
|
-
},
|
|
485
|
-
{
|
|
486
|
-
name: "depositorWotsPkHash",
|
|
487
|
-
type: "bytes32",
|
|
488
|
-
internalType: "bytes32"
|
|
489
|
-
},
|
|
490
|
-
{
|
|
491
|
-
name: "hashlock",
|
|
492
|
-
type: "bytes32",
|
|
493
|
-
internalType: "bytes32"
|
|
494
|
-
},
|
|
495
|
-
{
|
|
496
|
-
name: "htlcVout",
|
|
497
|
-
type: "uint8",
|
|
498
|
-
internalType: "uint8"
|
|
499
|
-
},
|
|
500
|
-
{
|
|
501
|
-
name: "depositorPopSignature",
|
|
502
|
-
type: "bytes",
|
|
503
|
-
internalType: "bytes"
|
|
504
|
-
},
|
|
505
|
-
{
|
|
506
|
-
name: "prePeginTxHash",
|
|
507
|
-
type: "bytes32",
|
|
508
|
-
internalType: "bytes32"
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
name: "vaultProviderCommissionBps",
|
|
512
|
-
type: "uint16",
|
|
513
|
-
internalType: "uint16"
|
|
514
|
-
}
|
|
515
|
-
],
|
|
516
|
-
stateMutability: "view"
|
|
517
|
-
}
|
|
518
|
-
], b = new Set(Object.values(I)), C = 200;
|
|
519
|
-
function i(n) {
|
|
520
|
-
var t;
|
|
521
|
-
return ((t = JSON.stringify(n)) == null ? void 0 : t.slice(0, C)) ?? "undefined";
|
|
522
|
-
}
|
|
523
|
-
const R = "The vault provider returned an unexpected response. Please try again or contact support.";
|
|
524
|
-
class a extends Error {
|
|
525
|
-
constructor(e) {
|
|
526
|
-
super(R);
|
|
527
|
-
g(this, "detail");
|
|
528
|
-
this.name = "VpResponseValidationError", this.detail = e;
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
const D = /^[0-9a-fA-F]+$/, _ = 64, w = 66, y = 64;
|
|
532
|
-
function p(n) {
|
|
533
|
-
return typeof n == "string" && n.length > 0 && D.test(n);
|
|
534
|
-
}
|
|
535
|
-
function x(n) {
|
|
536
|
-
return typeof n == "string" && n.length > 0;
|
|
537
|
-
}
|
|
538
|
-
function $(n, t) {
|
|
539
|
-
if (!p(n))
|
|
540
|
-
throw new a(
|
|
541
|
-
`VP response validation failed: "${t}" must be a non-empty hex string, got ${i(n)}`
|
|
542
|
-
);
|
|
543
|
-
}
|
|
544
|
-
function u(n, t) {
|
|
545
|
-
if (!x(n))
|
|
546
|
-
throw new a(
|
|
547
|
-
`VP response validation failed: "${t}" must be a non-empty string, got ${i(n)}`
|
|
548
|
-
);
|
|
549
|
-
}
|
|
550
|
-
function V(n, t) {
|
|
551
|
-
if (!p(n) || n.length !== _ && n.length !== w)
|
|
552
|
-
throw new a(
|
|
553
|
-
`VP response validation failed: "${t}" must be a ${_} or ${w}-char hex string (BTC pubkey), got ${i(n)}`
|
|
554
|
-
);
|
|
555
|
-
}
|
|
556
|
-
function M(n) {
|
|
557
|
-
const t = n.presigning;
|
|
558
|
-
if (t == null) return;
|
|
559
|
-
if (typeof t != "object" || Array.isArray(t))
|
|
560
|
-
throw new a(
|
|
561
|
-
'VP response validation failed: "progress.presigning" must be an object if present'
|
|
562
|
-
);
|
|
563
|
-
const e = t;
|
|
564
|
-
if (e.depositor_graph_created !== void 0 && typeof e.depositor_graph_created != "boolean")
|
|
565
|
-
throw new a(
|
|
566
|
-
`VP response validation failed: "progress.presigning.depositor_graph_created" must be a boolean if present, got ${i(e.depositor_graph_created)}`
|
|
567
|
-
);
|
|
568
|
-
if (e.vk_challenger_presigning_completed !== void 0 && typeof e.vk_challenger_presigning_completed != "number")
|
|
569
|
-
throw new a(
|
|
570
|
-
`VP response validation failed: "progress.presigning.vk_challenger_presigning_completed" must be a number if present, got ${i(e.vk_challenger_presigning_completed)}`
|
|
571
|
-
);
|
|
572
|
-
if (e.vk_challenger_presigning_total !== void 0 && typeof e.vk_challenger_presigning_total != "number")
|
|
573
|
-
throw new a(
|
|
574
|
-
`VP response validation failed: "progress.presigning.vk_challenger_presigning_total" must be a number if present, got ${i(e.vk_challenger_presigning_total)}`
|
|
575
|
-
);
|
|
576
|
-
}
|
|
577
|
-
function O(n) {
|
|
578
|
-
if (n === null || typeof n != "object")
|
|
579
|
-
throw new a(
|
|
580
|
-
"VP response validation failed: getPeginStatus response is not an object"
|
|
581
|
-
);
|
|
582
|
-
const t = n;
|
|
583
|
-
if (!p(t.pegin_txid) || t.pegin_txid.length !== y)
|
|
584
|
-
throw new a(
|
|
585
|
-
`VP response validation failed: "pegin_txid" must be a ${y}-char hex string (txid), got ${i(t.pegin_txid)}`
|
|
586
|
-
);
|
|
587
|
-
if (typeof t.status != "string")
|
|
588
|
-
throw new a(
|
|
589
|
-
'VP response validation failed: "status" must be a string'
|
|
590
|
-
);
|
|
591
|
-
if (!b.has(t.status))
|
|
592
|
-
throw new a(
|
|
593
|
-
`VP response validation failed: unrecognized status "${t.status}". Expected one of: ${[...b].join(", ")}`
|
|
594
|
-
);
|
|
595
|
-
if (t.progress === null || typeof t.progress != "object" || Array.isArray(t.progress))
|
|
596
|
-
throw new a(
|
|
597
|
-
'VP response validation failed: "progress" must be an object'
|
|
598
|
-
);
|
|
599
|
-
if (M(t.progress), typeof t.health_info != "string")
|
|
600
|
-
throw new a(
|
|
601
|
-
'VP response validation failed: "health_info" must be a string'
|
|
602
|
-
);
|
|
603
|
-
if (t.last_error !== void 0 && typeof t.last_error != "string")
|
|
604
|
-
throw new a(
|
|
605
|
-
`VP response validation failed: "last_error" must be a string if present, got ${i(t.last_error)}`
|
|
606
|
-
);
|
|
607
|
-
}
|
|
608
|
-
function H(n) {
|
|
609
|
-
if (n === null || typeof n != "object")
|
|
610
|
-
throw new a(
|
|
611
|
-
"VP response validation failed: requestDepositorPresignTransactions response is not an object"
|
|
612
|
-
);
|
|
613
|
-
const t = n;
|
|
614
|
-
if (!Array.isArray(t.txs))
|
|
615
|
-
throw new a(
|
|
616
|
-
'VP response validation failed: "txs" must be an array'
|
|
617
|
-
);
|
|
618
|
-
for (let e = 0; e < t.txs.length; e++)
|
|
619
|
-
U(t.txs[e], `txs[${e}]`);
|
|
620
|
-
if (t.depositor_graph === null || typeof t.depositor_graph != "object")
|
|
621
|
-
throw new a(
|
|
622
|
-
'VP response validation failed: "depositor_graph" must be an object'
|
|
623
|
-
);
|
|
624
|
-
L(
|
|
625
|
-
t.depositor_graph
|
|
626
|
-
);
|
|
627
|
-
}
|
|
628
|
-
function l(n, t) {
|
|
629
|
-
if (n === null || typeof n != "object")
|
|
630
|
-
throw new a(
|
|
631
|
-
`VP response validation failed: "${t}" must be an object`
|
|
632
|
-
);
|
|
633
|
-
$(n.tx_hex, `${t}.tx_hex`);
|
|
634
|
-
}
|
|
635
|
-
function U(n, t) {
|
|
636
|
-
if (n === null || typeof n != "object")
|
|
637
|
-
throw new a(
|
|
638
|
-
`VP response validation failed: "${t}" must be an object`
|
|
639
|
-
);
|
|
640
|
-
const e = n;
|
|
641
|
-
V(e.claimer_pubkey, `${t}.claimer_pubkey`), l(e.claim_tx, `${t}.claim_tx`), l(e.assert_tx, `${t}.assert_tx`), l(e.payout_tx, `${t}.payout_tx`), u(e.payout_psbt, `${t}.payout_psbt`);
|
|
642
|
-
}
|
|
643
|
-
function N(n, t) {
|
|
644
|
-
if (n === null || typeof n != "object")
|
|
645
|
-
throw new a(
|
|
646
|
-
`VP response validation failed: "${t}" must be an object`
|
|
647
|
-
);
|
|
648
|
-
const e = n;
|
|
649
|
-
u(e.wots_pks_json, `${t}.wots_pks_json`), u(e.gc_wots_keys_json, `${t}.gc_wots_keys_json`);
|
|
650
|
-
}
|
|
651
|
-
function q(n, t) {
|
|
652
|
-
if (n === null || typeof n != "object")
|
|
653
|
-
throw new a(
|
|
654
|
-
`VP response validation failed: "${t}" must be an object`
|
|
655
|
-
);
|
|
656
|
-
const e = n;
|
|
657
|
-
if (V(e.challenger_pubkey, `${t}.challenger_pubkey`), l(
|
|
658
|
-
e.challenge_assert_x_tx,
|
|
659
|
-
`${t}.challenge_assert_x_tx`
|
|
660
|
-
), l(
|
|
661
|
-
e.challenge_assert_y_tx,
|
|
662
|
-
`${t}.challenge_assert_y_tx`
|
|
663
|
-
), l(e.nopayout_tx, `${t}.nopayout_tx`), u(e.nopayout_psbt, `${t}.nopayout_psbt`), !Array.isArray(e.challenge_assert_connectors))
|
|
664
|
-
throw new a(
|
|
665
|
-
`VP response validation failed: "${t}.challenge_assert_connectors" must be an array`
|
|
666
|
-
);
|
|
667
|
-
for (let r = 0; r < e.challenge_assert_connectors.length; r++)
|
|
668
|
-
N(
|
|
669
|
-
e.challenge_assert_connectors[r],
|
|
670
|
-
`${t}.challenge_assert_connectors[${r}]`
|
|
671
|
-
);
|
|
672
|
-
if (!Array.isArray(e.output_label_hashes))
|
|
673
|
-
throw new a(
|
|
674
|
-
`VP response validation failed: "${t}.output_label_hashes" must be an array`
|
|
675
|
-
);
|
|
676
|
-
for (let r = 0; r < e.output_label_hashes.length; r++)
|
|
677
|
-
$(
|
|
678
|
-
e.output_label_hashes[r],
|
|
679
|
-
`${t}.output_label_hashes[${r}]`
|
|
680
|
-
);
|
|
681
|
-
}
|
|
682
|
-
function X(n) {
|
|
683
|
-
if (n === null || typeof n != "object")
|
|
684
|
-
throw new a(
|
|
685
|
-
"VP response validation failed: requestDepositorClaimerArtifacts response is not an object"
|
|
686
|
-
);
|
|
687
|
-
const t = n;
|
|
688
|
-
if (!x(t.tx_graph_json))
|
|
689
|
-
throw new a(
|
|
690
|
-
`VP response validation failed: "tx_graph_json" must be a non-empty string, got ${i(t.tx_graph_json)}`
|
|
691
|
-
);
|
|
692
|
-
if (!p(t.verifying_key_hex))
|
|
693
|
-
throw new a(
|
|
694
|
-
`VP response validation failed: "verifying_key_hex" must be a non-empty hex string, got ${i(t.verifying_key_hex)}`
|
|
695
|
-
);
|
|
696
|
-
if (t.babe_sessions === null || typeof t.babe_sessions != "object")
|
|
697
|
-
throw new a(
|
|
698
|
-
'VP response validation failed: "babe_sessions" must be an object'
|
|
699
|
-
);
|
|
700
|
-
for (const [e, r] of Object.entries(
|
|
701
|
-
t.babe_sessions
|
|
702
|
-
)) {
|
|
703
|
-
if (r === null || typeof r != "object")
|
|
704
|
-
throw new a(
|
|
705
|
-
`VP response validation failed: "babe_sessions.${e}" must be an object`
|
|
706
|
-
);
|
|
707
|
-
const o = r;
|
|
708
|
-
if (!p(o.decryptor_artifacts_hex))
|
|
709
|
-
throw new a(
|
|
710
|
-
`VP response validation failed: "babe_sessions.${e}.decryptor_artifacts_hex" must be a non-empty hex string, got ${i(o.decryptor_artifacts_hex)}`
|
|
711
|
-
);
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
function K(n) {
|
|
715
|
-
if (n === null || typeof n != "object")
|
|
716
|
-
throw new a(
|
|
717
|
-
"VP response validation failed: getPegoutStatus response is not an object"
|
|
718
|
-
);
|
|
719
|
-
const t = n;
|
|
720
|
-
if (!p(t.pegin_txid) || t.pegin_txid.length !== y)
|
|
721
|
-
throw new a(
|
|
722
|
-
`VP response validation failed: "pegin_txid" must be a ${y}-char hex string (txid), got ${i(t.pegin_txid)}`
|
|
723
|
-
);
|
|
724
|
-
if (typeof t.found != "boolean")
|
|
725
|
-
throw new a(
|
|
726
|
-
`VP response validation failed: "found" must be a boolean, got ${i(t.found)}`
|
|
727
|
-
);
|
|
728
|
-
if (t.claimer !== void 0) {
|
|
729
|
-
if (t.claimer === null || typeof t.claimer != "object")
|
|
730
|
-
throw new a(
|
|
731
|
-
'VP response validation failed: "claimer" must be an object if present'
|
|
732
|
-
);
|
|
733
|
-
const e = t.claimer;
|
|
734
|
-
if (typeof e.status != "string")
|
|
735
|
-
throw new a(
|
|
736
|
-
`VP response validation failed: "claimer.status" must be a string, got ${i(e.status)}`
|
|
737
|
-
);
|
|
738
|
-
if (typeof e.failed != "boolean")
|
|
739
|
-
throw new a(
|
|
740
|
-
`VP response validation failed: "claimer.failed" must be a boolean, got ${i(e.failed)}`
|
|
741
|
-
);
|
|
742
|
-
}
|
|
743
|
-
if (t.challenger !== void 0) {
|
|
744
|
-
if (t.challenger === null || typeof t.challenger != "object")
|
|
745
|
-
throw new a(
|
|
746
|
-
'VP response validation failed: "challenger" must be an object if present'
|
|
747
|
-
);
|
|
748
|
-
const e = t.challenger;
|
|
749
|
-
if (typeof e.status != "string")
|
|
750
|
-
throw new a(
|
|
751
|
-
`VP response validation failed: "challenger.status" must be a string, got ${i(e.status)}`
|
|
752
|
-
);
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
function L(n) {
|
|
756
|
-
if (l(n.claim_tx, "depositor_graph.claim_tx"), l(n.assert_tx, "depositor_graph.assert_tx"), l(n.payout_tx, "depositor_graph.payout_tx"), u(n.payout_psbt, "depositor_graph.payout_psbt"), !Array.isArray(n.challenger_presign_data))
|
|
757
|
-
throw new a(
|
|
758
|
-
'VP response validation failed: "depositor_graph.challenger_presign_data" must be an array'
|
|
759
|
-
);
|
|
760
|
-
for (let t = 0; t < n.challenger_presign_data.length; t++)
|
|
761
|
-
q(
|
|
762
|
-
n.challenger_presign_data[t],
|
|
763
|
-
`depositor_graph.challenger_presign_data[${t}]`
|
|
764
|
-
);
|
|
765
|
-
if (typeof n.offchain_params_version != "number")
|
|
766
|
-
throw new a(
|
|
767
|
-
'VP response validation failed: "depositor_graph.offchain_params_version" must be a number'
|
|
768
|
-
);
|
|
769
|
-
}
|
|
770
|
-
const W = 6e4;
|
|
771
|
-
class re {
|
|
772
|
-
constructor(t, e) {
|
|
773
|
-
g(this, "client");
|
|
774
|
-
const r = {
|
|
775
|
-
baseUrl: t,
|
|
776
|
-
timeout: (e == null ? void 0 : e.timeout) ?? W,
|
|
777
|
-
retries: e == null ? void 0 : e.retries,
|
|
778
|
-
retryDelay: e == null ? void 0 : e.retryDelay,
|
|
779
|
-
retryableFor: e == null ? void 0 : e.retryableFor,
|
|
780
|
-
headers: e == null ? void 0 : e.headers
|
|
781
|
-
};
|
|
782
|
-
this.client = new S(r);
|
|
783
|
-
}
|
|
784
|
-
/**
|
|
785
|
-
* Request the payout/claim/assert transactions that the depositor
|
|
786
|
-
* needs to pre-sign before the vault can be activated on Bitcoin.
|
|
787
|
-
*/
|
|
788
|
-
async requestDepositorPresignTransactions(t, e) {
|
|
789
|
-
const r = await this.client.call("vaultProvider_requestDepositorPresignTransactions", t, e);
|
|
790
|
-
return H(r), r;
|
|
791
|
-
}
|
|
792
|
-
/**
|
|
793
|
-
* Submit the depositor's pre-signatures for the payout transactions
|
|
794
|
-
* and the depositor-as-claimer graph.
|
|
795
|
-
*/
|
|
796
|
-
async submitDepositorPresignatures(t, e) {
|
|
797
|
-
return this.client.call(
|
|
798
|
-
"vaultProvider_submitDepositorPresignatures",
|
|
799
|
-
t,
|
|
800
|
-
e
|
|
801
|
-
);
|
|
802
|
-
}
|
|
803
|
-
/**
|
|
804
|
-
* Submit the depositor's WOTS public key to the vault provider.
|
|
805
|
-
* Called after the pegin is finalized on Ethereum, when the VP is in
|
|
806
|
-
* `PendingDepositorWotsPK` status.
|
|
807
|
-
*/
|
|
808
|
-
async submitDepositorWotsKey(t, e) {
|
|
809
|
-
return this.client.call(
|
|
810
|
-
"vaultProvider_submitDepositorWotsKey",
|
|
811
|
-
t,
|
|
812
|
-
e
|
|
813
|
-
);
|
|
814
|
-
}
|
|
815
|
-
/**
|
|
816
|
-
* Request the BaBe DecryptorArtifacts needed for the depositor to
|
|
817
|
-
* independently evaluate garbled circuits during a challenge.
|
|
818
|
-
*/
|
|
819
|
-
async requestDepositorClaimerArtifacts(t, e) {
|
|
820
|
-
const r = await this.client.call("vaultProvider_requestDepositorClaimerArtifacts", t, e);
|
|
821
|
-
return X(r), r;
|
|
822
|
-
}
|
|
823
|
-
/** Get the current pegin status from the vault provider daemon. */
|
|
824
|
-
async getPeginStatus(t, e) {
|
|
825
|
-
const r = await this.client.call(
|
|
826
|
-
"vaultProvider_getPeginStatus",
|
|
827
|
-
t,
|
|
828
|
-
e
|
|
829
|
-
);
|
|
830
|
-
return O(r), r;
|
|
831
|
-
}
|
|
832
|
-
/** Get the current pegout status from the vault provider daemon. */
|
|
833
|
-
async getPegoutStatus(t, e) {
|
|
834
|
-
const r = await this.client.call(
|
|
835
|
-
"vaultProvider_getPegoutStatus",
|
|
836
|
-
t,
|
|
837
|
-
e
|
|
838
|
-
);
|
|
839
|
-
return K(r), r;
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
class ae {
|
|
843
|
-
constructor(t, e) {
|
|
844
|
-
this.publicClient = t, this.contractAddress = e;
|
|
845
|
-
}
|
|
846
|
-
async getVaultBasicInfo(t) {
|
|
847
|
-
const e = await this.publicClient.readContract({
|
|
848
|
-
address: this.contractAddress,
|
|
849
|
-
abi: h,
|
|
850
|
-
functionName: "getBtcVaultBasicInfo",
|
|
851
|
-
args: [t]
|
|
852
|
-
});
|
|
853
|
-
return {
|
|
854
|
-
depositor: e[0],
|
|
855
|
-
depositorBtcPubKey: e[1],
|
|
856
|
-
amount: e[2],
|
|
857
|
-
vaultProvider: e[3],
|
|
858
|
-
status: e[4],
|
|
859
|
-
applicationEntryPoint: e[5],
|
|
860
|
-
createdAt: e[6]
|
|
861
|
-
};
|
|
862
|
-
}
|
|
863
|
-
async getVaultProtocolInfo(t) {
|
|
864
|
-
const e = await this.publicClient.readContract({
|
|
865
|
-
address: this.contractAddress,
|
|
866
|
-
abi: h,
|
|
867
|
-
functionName: "getBtcVaultProtocolInfo",
|
|
868
|
-
args: [t]
|
|
869
|
-
});
|
|
870
|
-
return {
|
|
871
|
-
depositorSignedPeginTx: e[0],
|
|
872
|
-
universalChallengersVersion: e[1],
|
|
873
|
-
appVaultKeepersVersion: e[2],
|
|
874
|
-
offchainParamsVersion: e[3],
|
|
875
|
-
verifiedAt: e[4],
|
|
876
|
-
depositorWotsPkHash: e[5],
|
|
877
|
-
hashlock: e[6],
|
|
878
|
-
htlcVout: e[7],
|
|
879
|
-
depositorPopSignature: e[8],
|
|
880
|
-
prePeginTxHash: e[9],
|
|
881
|
-
vaultProviderCommissionBps: e[10]
|
|
882
|
-
};
|
|
883
|
-
}
|
|
884
|
-
async getVaultData(t) {
|
|
885
|
-
const [e, r] = await Promise.all([
|
|
886
|
-
this.getVaultBasicInfo(t),
|
|
887
|
-
this.getVaultProtocolInfo(t)
|
|
888
|
-
]);
|
|
889
|
-
if (!r.depositorSignedPeginTx || r.depositorSignedPeginTx === "0x")
|
|
890
|
-
throw new Error(
|
|
891
|
-
`Vault ${t} not found on-chain or has no pegin transaction`
|
|
892
|
-
);
|
|
893
|
-
return { basic: e, protocol: r };
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
export {
|
|
897
|
-
h as B,
|
|
898
|
-
j as M,
|
|
899
|
-
re as V,
|
|
900
|
-
Z as a,
|
|
901
|
-
ee as b,
|
|
902
|
-
ne as c,
|
|
903
|
-
z as d,
|
|
904
|
-
B as e,
|
|
905
|
-
Q as f,
|
|
906
|
-
te as g,
|
|
907
|
-
a as h,
|
|
908
|
-
ae as i,
|
|
909
|
-
Y as p
|
|
910
|
-
};
|
|
911
|
-
//# sourceMappingURL=index-qIcjkxLw.js.map
|