@lombard.finance/sdk 4.7.0-canary.0.4 → 4.7.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/CHANGELOG.md +1 -0
- package/dist/btc.cjs +1 -1
- package/dist/btc.js +2 -2
- package/dist/chains/solana/actions/redeem/SolanaRedeem.d.ts +2 -2
- package/dist/chains/solana/actions/redeem/SolanaRedeem.d.ts.map +1 -1
- package/dist/chains/solana/actions/redeem/types.d.ts +4 -4
- package/dist/chains/solana/actions/redeem/types.d.ts.map +1 -1
- package/dist/chains/solana/actions/stake/SolanaStake.d.ts +2 -2
- package/dist/chains/solana/actions/stake/SolanaStake.d.ts.map +1 -1
- package/dist/chains/solana/actions/stake/types.d.ts +4 -4
- package/dist/chains/solana/actions/stake/types.d.ts.map +1 -1
- package/dist/chains/solana/actions/unstake/SolanaUnstake.d.ts +2 -2
- package/dist/chains/solana/actions/unstake/SolanaUnstake.d.ts.map +1 -1
- package/dist/chains/solana/actions/unstake/types.d.ts +4 -4
- package/dist/chains/solana/actions/unstake/types.d.ts.map +1 -1
- package/dist/chains/starknet/actions/unstake/StarknetUnstake.d.ts +2 -2
- package/dist/chains/starknet/actions/unstake/StarknetUnstake.d.ts.map +1 -1
- package/dist/chains/starknet/actions/unstake/types.d.ts +4 -4
- package/dist/chains/starknet/actions/unstake/types.d.ts.map +1 -1
- package/dist/chains/sui/actions/unstake/SuiUnstake.d.ts +2 -2
- package/dist/chains/sui/actions/unstake/SuiUnstake.d.ts.map +1 -1
- package/dist/chains/sui/actions/unstake/types.d.ts +4 -4
- package/dist/chains/sui/actions/unstake/types.d.ts.map +1 -1
- package/dist/chunks/{BtcActions-Bd4yFvv6.cjs → BtcActions-CWFHlbUP.cjs} +2 -2
- package/dist/chunks/{BtcActions-Bd4yFvv6.cjs.map → BtcActions-CWFHlbUP.cjs.map} +1 -1
- package/dist/chunks/{BtcActions-BVD-tORS.js → BtcActions-jvzGFmpz.js} +2 -2
- package/dist/chunks/{BtcActions-BVD-tORS.js.map → BtcActions-jvzGFmpz.js.map} +1 -1
- package/dist/chunks/{EvmActions-DYu5Ghtm.cjs → EvmActions-BTKQAXTE.cjs} +2 -2
- package/dist/chunks/{EvmActions-DYu5Ghtm.cjs.map → EvmActions-BTKQAXTE.cjs.map} +1 -1
- package/dist/chunks/{EvmActions-LQG214wM.js → EvmActions-hb-FhsLJ.js} +2 -2
- package/dist/chunks/{EvmActions-LQG214wM.js.map → EvmActions-hb-FhsLJ.js.map} +1 -1
- package/dist/chunks/events-BTPDrUUu.cjs +2 -0
- package/dist/chunks/events-BTPDrUUu.cjs.map +1 -0
- package/dist/chunks/{events-Dig2vx7-.js → events-DAiXVdGv.js} +15 -15
- package/dist/chunks/events-DAiXVdGv.js.map +1 -0
- package/dist/chunks/statusConstants-BTQAvx1I.cjs +2 -0
- package/dist/chunks/{statusConstants-DHmPgh2J.cjs.map → statusConstants-BTQAvx1I.cjs.map} +1 -1
- package/dist/chunks/{statusConstants-Zy_OMItT.js → statusConstants-D9eSk91U.js} +38 -38
- package/dist/chunks/{statusConstants-Zy_OMItT.js.map → statusConstants-D9eSk91U.js.map} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +31 -31
- package/dist/entries/core.d.ts +1 -1
- package/dist/entries/core.d.ts.map +1 -1
- package/dist/evm.cjs +1 -1
- package/dist/evm.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -21
- package/dist/shared/constants/statusConstants.d.ts +7 -3
- package/dist/shared/constants/statusConstants.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/events-CtqmtrMN.cjs +0 -2
- package/dist/chunks/events-CtqmtrMN.cjs.map +0 -1
- package/dist/chunks/events-Dig2vx7-.js.map +0 -1
- package/dist/chunks/statusConstants-DHmPgh2J.cjs +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
- `solana.redeem()` now routes through the Asset Router `redeemForBtc` flow (replacing the direct GMP dispatch used previously). Route semantics (BTC.b → BTC) and `SolanaRedeemParams` are unchanged.
|
|
14
14
|
- `SolanaRedeem` terminal status changed from `CONFIRMING` to `COMPLETED`. Integrations that treated `CONFIRMING` as the end-of-flow marker for this action should switch to `COMPLETED`.
|
|
15
15
|
- `SolanaUnstake` route config reshaped: `unstake/config/solana.ts` merged into `unstake/config/btc.ts`, and `RouteDefinition` now carries `assetIn`/`assetOut` to disambiguate BTC vs BTC.b destinations.
|
|
16
|
+
- Renamed `NonEvmUnstakeStatus` to `NonEvmOperationStatus` in `statusConstants.ts` — the constant is now shared by all non-EVM actions (Solana Stake/Unstake/Redeem, Sui Unstake, Starknet Unstake). Update imports if you reference the old name directly.
|
|
16
17
|
|
|
17
18
|
### Fixed
|
|
18
19
|
|
package/dist/btc.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./chunks/BtcActions-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./chunks/BtcActions-CWFHlbUP.cjs"),c=require("./chunks/statusConstants-BTQAvx1I.cjs");exports.BtcActions=t.BtcActions;exports.BtcDeposit=t.BtcDeposit;exports.BtcDepositAndDeploy=t.BtcDepositAndDeploy;exports.BtcStake=t.BtcStake;exports.BtcStakeAndDeploy=t.BtcStakeAndDeploy;exports.btcActions=t.btcActions;exports.btcModule=t.btcModule;exports.BtcActionStatus=c.BtcActionStatus;
|
|
2
2
|
//# sourceMappingURL=btc.cjs.map
|
package/dist/btc.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BtcActions as c, BtcDeposit as e, BtcDepositAndDeploy as p, BtcStake as B, BtcStakeAndDeploy as i, btcActions as n, btcModule as s } from "./chunks/BtcActions-
|
|
2
|
-
import { BtcActionStatus as r } from "./chunks/statusConstants-
|
|
1
|
+
import { BtcActions as c, BtcDeposit as e, BtcDepositAndDeploy as p, BtcStake as B, BtcStakeAndDeploy as i, btcActions as n, btcModule as s } from "./chunks/BtcActions-jvzGFmpz.js";
|
|
2
|
+
import { BtcActionStatus as r } from "./chunks/statusConstants-D9eSk91U.js";
|
|
3
3
|
export {
|
|
4
4
|
r as BtcActionStatus,
|
|
5
5
|
c as BtcActions,
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
* @module chains/solana/actions/redeem/SolanaRedeem
|
|
11
11
|
*/
|
|
12
12
|
import { BaseAction } from '../../../../shared/actions/BaseAction';
|
|
13
|
-
import {
|
|
13
|
+
import { NonEvmOperationStatus } from '../../../../shared/constants/statusConstants';
|
|
14
14
|
import type { SolanaCoreContext } from '../../../../shared/context';
|
|
15
15
|
import type { RedeemEventMap } from '../../../../shared/events';
|
|
16
16
|
import type { ISolanaRedeem, SolanaRedeemParams, SolanaRedeemPrepareParams } from './types';
|
|
17
|
-
export declare class SolanaRedeem extends BaseAction<RedeemEventMap,
|
|
17
|
+
export declare class SolanaRedeem extends BaseAction<RedeemEventMap, NonEvmOperationStatus> implements ISolanaRedeem {
|
|
18
18
|
private readonly ctx;
|
|
19
19
|
private readonly params;
|
|
20
20
|
private _amount?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolanaRedeem.d.ts","sourceRoot":"","sources":["../../../../../src/chains/solana/actions/redeem/SolanaRedeem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"SolanaRedeem.d.ts","sourceRoot":"","sources":["../../../../../src/chains/solana/actions/redeem/SolanaRedeem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAShE,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAEjB,qBAAa,YACX,SAAQ,UAAU,CAAC,cAAc,EAAE,qBAAqB,CACxD,YAAW,aAAa;IAOtB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAC,CAAS;gBAGN,GAAG,EAAE,iBAAiB,EACtB,MAAM,EAAE,kBAAkB;IAsB7C,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAEK,OAAO,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBzD,OAAO,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAiD5C,OAAO,KAAK,aAAa,GAKxB;CACF"}
|
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { AssetId, Chain, StepStatus, StrategyProgress } from '../../../../core';
|
|
9
9
|
import type { MonitorableAction } from '../../../../shared/actions/BaseAction';
|
|
10
|
-
import type {
|
|
10
|
+
import type { NonEvmOperationStatus } from '../../../../shared/constants/statusConstants';
|
|
11
11
|
export interface SolanaRedeemParams {
|
|
12
12
|
assetIn: AssetId;
|
|
13
13
|
assetOut: AssetId;
|
|
14
14
|
sourceChain: Chain;
|
|
15
15
|
destChain: Chain;
|
|
16
16
|
}
|
|
17
|
-
export interface SolanaRedeemProgress extends StrategyProgress<
|
|
18
|
-
status:
|
|
17
|
+
export interface SolanaRedeemProgress extends StrategyProgress<NonEvmOperationStatus> {
|
|
18
|
+
status: NonEvmOperationStatus;
|
|
19
19
|
steps: {
|
|
20
20
|
burning: StepStatus;
|
|
21
21
|
releasing: StepStatus;
|
|
@@ -28,7 +28,7 @@ export interface SolanaRedeemPrepareParams {
|
|
|
28
28
|
recipient: string;
|
|
29
29
|
}
|
|
30
30
|
export interface ISolanaRedeem extends MonitorableAction {
|
|
31
|
-
readonly status:
|
|
31
|
+
readonly status: NonEvmOperationStatus;
|
|
32
32
|
readonly amount?: string;
|
|
33
33
|
readonly recipient?: string;
|
|
34
34
|
readonly txHash?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/chains/solana/actions/redeem/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,UAAU,EACV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/chains/solana/actions/redeem/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,UAAU,EACV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAE1F,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC;CAClB;AAED,MAAM,WAAW,oBACf,SAAQ,gBAAgB,CAAC,qBAAqB,CAAC;IAC/C,MAAM,EAAE,qBAAqB,CAAC;IAC9B,KAAK,EAAE;QACL,OAAO,EAAE,UAAU,CAAC;QACpB,SAAS,EAAE,UAAU,CAAC;KACvB,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,OAAO,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxC"}
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
* @module chains/solana/actions/stake/SolanaStake
|
|
10
10
|
*/
|
|
11
11
|
import { BaseAction } from '../../../../shared/actions/BaseAction';
|
|
12
|
-
import {
|
|
12
|
+
import { NonEvmOperationStatus } from '../../../../shared/constants/statusConstants';
|
|
13
13
|
import type { SolanaCoreContext } from '../../../../shared/context';
|
|
14
14
|
import type { StakeEventMap } from '../../../../shared/events';
|
|
15
15
|
import type { ISolanaStake, SolanaStakeParams, SolanaStakePrepareParams } from './types';
|
|
16
|
-
export declare class SolanaStake extends BaseAction<StakeEventMap,
|
|
16
|
+
export declare class SolanaStake extends BaseAction<StakeEventMap, NonEvmOperationStatus> implements ISolanaStake {
|
|
17
17
|
private readonly ctx;
|
|
18
18
|
private readonly params;
|
|
19
19
|
private _amount?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolanaStake.d.ts","sourceRoot":"","sources":["../../../../../src/chains/solana/actions/stake/SolanaStake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"SolanaStake.d.ts","sourceRoot":"","sources":["../../../../../src/chains/solana/actions/stake/SolanaStake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAQ/D,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,qBAAa,WACX,SAAQ,UAAU,CAAC,aAAa,EAAE,qBAAqB,CACvD,YAAW,YAAY;IAQrB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAPzB,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;gBAGP,GAAG,EAAE,iBAAiB,EACtB,MAAM,EAAE,iBAAiB;IAqB5C,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAEK,OAAO,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBxD,OAAO,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAwC5C,OAAO,KAAK,aAAa,GAKxB;CACF"}
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { AssetId, Chain, StepStatus, StrategyProgress } from '../../../../core';
|
|
9
9
|
import type { MonitorableAction } from '../../../../shared/actions/BaseAction';
|
|
10
|
-
import type {
|
|
10
|
+
import type { NonEvmOperationStatus } from '../../../../shared/constants/statusConstants';
|
|
11
11
|
export interface SolanaStakeParams {
|
|
12
12
|
assetIn: AssetId;
|
|
13
13
|
assetOut: AssetId;
|
|
14
14
|
chain: Chain;
|
|
15
15
|
}
|
|
16
|
-
export interface SolanaStakeProgress extends StrategyProgress<
|
|
17
|
-
status:
|
|
16
|
+
export interface SolanaStakeProgress extends StrategyProgress<NonEvmOperationStatus> {
|
|
17
|
+
status: NonEvmOperationStatus;
|
|
18
18
|
steps: {
|
|
19
19
|
burning: StepStatus;
|
|
20
20
|
minting: StepStatus;
|
|
@@ -27,7 +27,7 @@ export interface SolanaStakePrepareParams {
|
|
|
27
27
|
recipient: string;
|
|
28
28
|
}
|
|
29
29
|
export interface ISolanaStake extends MonitorableAction {
|
|
30
|
-
readonly status:
|
|
30
|
+
readonly status: NonEvmOperationStatus;
|
|
31
31
|
readonly amount?: string;
|
|
32
32
|
readonly recipient?: string;
|
|
33
33
|
readonly txHash?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/chains/solana/actions/stake/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,UAAU,EACV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/chains/solana/actions/stake/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,UAAU,EACV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAE1F,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,mBACf,SAAQ,gBAAgB,CAAC,qBAAqB,CAAC;IAC/C,MAAM,EAAE,qBAAqB,CAAC;IAC9B,KAAK,EAAE;QACL,OAAO,EAAE,UAAU,CAAC;QACpB,OAAO,EAAE,UAAU,CAAC;KACrB,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAa,SAAQ,iBAAiB;IACrD,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,OAAO,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxC"}
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
* @module chains/solana/actions/unstake/SolanaUnstake
|
|
10
10
|
*/
|
|
11
11
|
import { BaseAction } from '../../../../shared/actions/BaseAction';
|
|
12
|
-
import {
|
|
12
|
+
import { NonEvmOperationStatus } from '../../../../shared/constants/statusConstants';
|
|
13
13
|
import type { SolanaCoreContext } from '../../../../shared/context';
|
|
14
14
|
import type { UnstakeEventMap } from '../../../../shared/events';
|
|
15
15
|
import type { ISolanaUnstake, SolanaUnstakeParams, SolanaUnstakePrepareParams } from './types';
|
|
16
|
-
export declare class SolanaUnstake extends BaseAction<UnstakeEventMap,
|
|
16
|
+
export declare class SolanaUnstake extends BaseAction<UnstakeEventMap, NonEvmOperationStatus> implements ISolanaUnstake {
|
|
17
17
|
private readonly ctx;
|
|
18
18
|
private readonly params;
|
|
19
19
|
private _amount?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SolanaUnstake.d.ts","sourceRoot":"","sources":["../../../../../src/chains/solana/actions/unstake/SolanaUnstake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"SolanaUnstake.d.ts","sourceRoot":"","sources":["../../../../../src/chains/solana/actions/unstake/SolanaUnstake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAajE,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AAEjB,qBAAa,aACX,SAAQ,UAAU,CAAC,eAAe,EAAE,qBAAqB,CACzD,YAAW,cAAc;IAQvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAPzB,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;gBAGpB,GAAG,EAAE,iBAAiB,EACtB,MAAM,EAAE,mBAAmB;IAwB9C,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAEK,OAAO,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB1D,OAAO,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IA4D5C,OAAO,KAAK,aAAa,GAMxB;CACF"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { AssetId, Chain, StepStatus, StrategyProgress } from '../../../../core';
|
|
7
7
|
import type { MonitorableAction } from '../../../../shared/actions/BaseAction';
|
|
8
|
-
import type {
|
|
8
|
+
import type { NonEvmOperationStatus } from '../../../../shared/constants/statusConstants';
|
|
9
9
|
/**
|
|
10
10
|
* Solana Unstake parameters
|
|
11
11
|
*/
|
|
@@ -18,8 +18,8 @@ export interface SolanaUnstakeParams {
|
|
|
18
18
|
/**
|
|
19
19
|
* Solana Unstake progress
|
|
20
20
|
*/
|
|
21
|
-
export interface SolanaUnstakeProgress extends StrategyProgress<
|
|
22
|
-
status:
|
|
21
|
+
export interface SolanaUnstakeProgress extends StrategyProgress<NonEvmOperationStatus> {
|
|
22
|
+
status: NonEvmOperationStatus;
|
|
23
23
|
steps: {
|
|
24
24
|
burning: StepStatus;
|
|
25
25
|
releasing: StepStatus;
|
|
@@ -38,7 +38,7 @@ export interface SolanaUnstakePrepareParams {
|
|
|
38
38
|
* Solana Unstake interface
|
|
39
39
|
*/
|
|
40
40
|
export interface ISolanaUnstake extends MonitorableAction {
|
|
41
|
-
readonly status:
|
|
41
|
+
readonly status: NonEvmOperationStatus;
|
|
42
42
|
readonly amount?: string;
|
|
43
43
|
readonly recipient?: string;
|
|
44
44
|
prepare(params: SolanaUnstakePrepareParams): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/chains/solana/actions/unstake/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,UAAU,EACV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/chains/solana/actions/unstake/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,UAAU,EACV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAE1F;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,qBACf,SAAQ,gBAAgB,CAAC,qBAAqB,CAAC;IAC/C,MAAM,EAAE,qBAAqB,CAAC;IAC9B,KAAK,EAAE;QACL,OAAO,EAAE,UAAU,CAAC;QACpB,SAAS,EAAE,UAAU,CAAC;KACvB,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,iBAAiB;IACvD,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B,OAAO,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,OAAO,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxC"}
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* @module chains/starknet/actions/unstake/StarknetUnstake
|
|
7
7
|
*/
|
|
8
8
|
import { BaseAction } from '../../../../shared/actions/BaseAction';
|
|
9
|
-
import {
|
|
9
|
+
import { NonEvmOperationStatus } from '../../../../shared/constants/statusConstants';
|
|
10
10
|
import type { StarknetCoreContext } from '../../../../shared/context';
|
|
11
11
|
import type { UnstakeEventMap } from '../../../../shared/events';
|
|
12
12
|
import type { IStarknetUnstake, StarknetUnstakeParams, StarknetUnstakePrepareParams } from './types';
|
|
13
|
-
export declare class StarknetUnstake extends BaseAction<UnstakeEventMap,
|
|
13
|
+
export declare class StarknetUnstake extends BaseAction<UnstakeEventMap, NonEvmOperationStatus> implements IStarknetUnstake {
|
|
14
14
|
private readonly ctx;
|
|
15
15
|
private readonly params;
|
|
16
16
|
private _amount?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StarknetUnstake.d.ts","sourceRoot":"","sources":["../../../../../src/chains/starknet/actions/unstake/StarknetUnstake.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"StarknetUnstake.d.ts","sourceRoot":"","sources":["../../../../../src/chains/starknet/actions/unstake/StarknetUnstake.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAMjE,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,4BAA4B,EAC7B,MAAM,SAAS,CAAC;AAEjB,qBAAa,eACX,SAAQ,UAAU,CAAC,eAAe,EAAE,qBAAqB,CACzD,YAAW,gBAAgB;IAQzB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAPzB,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;gBAGP,GAAG,EAAE,mBAAmB,EACxB,MAAM,EAAE,qBAAqB;IAehD,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAEK,OAAO,CAAC,MAAM,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB5D,OAAO,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAsC5C,OAAO,KAAK,aAAa,GAKxB;CACF"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { AssetId, Chain, StepStatus, StrategyProgress } from '../../../../core';
|
|
7
7
|
import type { MonitorableAction } from '../../../../shared/actions/BaseAction';
|
|
8
|
-
import type {
|
|
8
|
+
import type { NonEvmOperationStatus } from '../../../../shared/constants/statusConstants';
|
|
9
9
|
/**
|
|
10
10
|
* Starknet Unstake parameters
|
|
11
11
|
*/
|
|
@@ -18,8 +18,8 @@ export interface StarknetUnstakeParams {
|
|
|
18
18
|
/**
|
|
19
19
|
* Starknet Unstake progress
|
|
20
20
|
*/
|
|
21
|
-
export interface StarknetUnstakeProgress extends StrategyProgress<
|
|
22
|
-
status:
|
|
21
|
+
export interface StarknetUnstakeProgress extends StrategyProgress<NonEvmOperationStatus> {
|
|
22
|
+
status: NonEvmOperationStatus;
|
|
23
23
|
steps: {
|
|
24
24
|
burning: StepStatus;
|
|
25
25
|
releasing: StepStatus;
|
|
@@ -37,7 +37,7 @@ export interface StarknetUnstakePrepareParams {
|
|
|
37
37
|
* Starknet Unstake interface
|
|
38
38
|
*/
|
|
39
39
|
export interface IStarknetUnstake extends MonitorableAction {
|
|
40
|
-
readonly status:
|
|
40
|
+
readonly status: NonEvmOperationStatus;
|
|
41
41
|
readonly amount?: string;
|
|
42
42
|
readonly recipient?: string;
|
|
43
43
|
prepare(params: StarknetUnstakePrepareParams): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/chains/starknet/actions/unstake/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,UAAU,EACV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/chains/starknet/actions/unstake/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,UAAU,EACV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAE1F;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,uBACf,SAAQ,gBAAgB,CAAC,qBAAqB,CAAC;IAC/C,MAAM,EAAE,qBAAqB,CAAC;IAC9B,KAAK,EAAE;QACL,OAAO,EAAE,UAAU,CAAC;QACpB,SAAS,EAAE,UAAU,CAAC;KACvB,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B,OAAO,CAAC,MAAM,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,OAAO,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxC"}
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* @module chains/sui/actions/unstake/SuiUnstake
|
|
7
7
|
*/
|
|
8
8
|
import { BaseAction } from '../../../../shared/actions/BaseAction';
|
|
9
|
-
import {
|
|
9
|
+
import { NonEvmOperationStatus } from '../../../../shared/constants/statusConstants';
|
|
10
10
|
import type { SuiCoreContext } from '../../../../shared/context';
|
|
11
11
|
import type { UnstakeEventMap } from '../../../../shared/events';
|
|
12
12
|
import type { ISuiUnstake, SuiUnstakeParams, SuiUnstakePrepareParams } from './types';
|
|
13
|
-
export declare class SuiUnstake extends BaseAction<UnstakeEventMap,
|
|
13
|
+
export declare class SuiUnstake extends BaseAction<UnstakeEventMap, NonEvmOperationStatus> implements ISuiUnstake {
|
|
14
14
|
private readonly ctx;
|
|
15
15
|
private readonly params;
|
|
16
16
|
private _amount?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SuiUnstake.d.ts","sourceRoot":"","sources":["../../../../../src/chains/sui/actions/unstake/SuiUnstake.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"SuiUnstake.d.ts","sourceRoot":"","sources":["../../../../../src/chains/sui/actions/unstake/SuiUnstake.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAMjE,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAgBjB,qBAAa,UACX,SAAQ,UAAU,CAAC,eAAe,EAAE,qBAAqB,CACzD,YAAW,WAAW;IAQpB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAPzB,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;gBAGP,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,gBAAgB;IAe3C,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAEK,OAAO,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBvD,OAAO,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IA0C5C,OAAO,KAAK,aAAa,GAKxB;CACF"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { AssetId, Chain, StepStatus, StrategyProgress } from '../../../../core';
|
|
7
7
|
import type { MonitorableAction } from '../../../../shared/actions/BaseAction';
|
|
8
|
-
import type {
|
|
8
|
+
import type { NonEvmOperationStatus } from '../../../../shared/constants/statusConstants';
|
|
9
9
|
/**
|
|
10
10
|
* Sui Unstake parameters
|
|
11
11
|
*/
|
|
@@ -18,8 +18,8 @@ export interface SuiUnstakeParams {
|
|
|
18
18
|
/**
|
|
19
19
|
* Sui Unstake progress
|
|
20
20
|
*/
|
|
21
|
-
export interface SuiUnstakeProgress extends StrategyProgress<
|
|
22
|
-
status:
|
|
21
|
+
export interface SuiUnstakeProgress extends StrategyProgress<NonEvmOperationStatus> {
|
|
22
|
+
status: NonEvmOperationStatus;
|
|
23
23
|
steps: {
|
|
24
24
|
burning: StepStatus;
|
|
25
25
|
releasing: StepStatus;
|
|
@@ -37,7 +37,7 @@ export interface SuiUnstakePrepareParams {
|
|
|
37
37
|
* Sui Unstake interface
|
|
38
38
|
*/
|
|
39
39
|
export interface ISuiUnstake extends MonitorableAction {
|
|
40
|
-
readonly status:
|
|
40
|
+
readonly status: NonEvmOperationStatus;
|
|
41
41
|
readonly amount?: string;
|
|
42
42
|
readonly recipient?: string;
|
|
43
43
|
prepare(params: SuiUnstakePrepareParams): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/chains/sui/actions/unstake/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,UAAU,EACV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/chains/sui/actions/unstake/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,UAAU,EACV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAE1F;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBACf,SAAQ,gBAAgB,CAAC,qBAAqB,CAAC;IAC/C,MAAM,EAAE,qBAAqB,CAAC;IAC9B,KAAK,EAAE;QACL,OAAO,EAAE,UAAU,CAAC;QACpB,SAAS,EAAE,UAAU,CAAC;KACvB,CAAC;IACF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,iBAAiB;IACpD,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B,OAAO,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,OAAO,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var z=Object.defineProperty;var H=(s,r,i)=>r in s?z(s,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[r]=i;var p=(s,r,i)=>H(s,typeof r!="symbol"?r+"":r,i);const Y=require("axios"),t=require("./statusConstants-DHmPgh2J.cjs"),A=require("./token-addresses-DvY-Mw7b.cjs"),u=require("./index-BKzxeh1Y.cjs"),l=require("./tokens-CBsz6l_2.cjs"),D=require("./satoshi-CZEsHl5X.cjs"),c=require("./defi-registry-B8V6dRVB.cjs"),R=require("./getUserStakeAndBakeSignature-BmY5j0OM.cjs"),$=require("./config-ow9X5H0c.cjs"),q=require("viem"),U="ERR_NETWORK",G="This may be due to your Adblocker. Please disable any Adblocker and refresh the page to restore full functionality.";function j(s){const{code:r,message:i}=s;throw r===U?new Error(G):new Error(i)}const K={mempoolApiUrl:"https://mempool.space/signet"},Z={mempoolApiUrl:"https://mempool.space"},W=s=>s==="mainnet"?Z:K;async function X(s){const{mempoolApiUrl:r}=W(s),i=Math.floor(Date.now()/1e3),e=`${r}/api/v1/mining/blocks/timestamp/${i}`;try{const{data:a}=await Y.get(e);return a.height}catch(a){j(a)}}class J{async getCurrentBlockHeight(r){return X(r)}}function Q(){return{id:"btc",chain:"btc",register(){return new J}}}async function y(s){const{fetchDeposit:r,network:i,btcService:e,requiredConfirmations:a=6,onProgress:n,onComplete:o}=s,h=await r();if(!h)return;const d=h.blockHeight;if(typeof d!="number")return;const T=await e.getCurrentBlockHeight(i),_=Math.max(0,T-d),N=_>=a,w=h.isClaimed??!1,B={confirmations:_,requiredConfirmations:a,hasEnoughConfirmations:N,isClaimed:w,steps:{created:t.StepStatus.COMPLETE,verifying:N?t.StepStatus.COMPLETE:t.StepStatus.PENDING,issuing:w?t.StepStatus.COMPLETE:t.StepStatus.PENDING}};return n==null||n(B),w&&(o==null||o()),B}function f(s){if(s===R.SANCTIONED_ADDRESS)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Destination address is under sanctions")}class I extends t.BaseAction{constructor(i,e,a){super(a);p(this,"_amount");p(this,"_recipient");p(this,"_depositAddress");p(this,"_referralCode");p(this,"_chainId");this.ctx=i,this.params=e}get amount(){return this._amount}get recipient(){return this._recipient}get depositAddress(){return this._depositAddress}get referralCode(){return this._referralCode}get bitcoinNetwork(){return this.params.sourceChain===t.Chain.BITCOIN_MAINNET?"mainnet":"testnet"}get prepareSchema(){return t.objectType({amount:t.btcStakeAmountSchema,recipient:this.getAddressSchema(),referralCode:t.referralCodeSchema})}validatePrepareParams(i){return t.validatePrepareParams(this.prepareSchema,i,{destChain:this.params.destChain})}ensureRecipient(){if(!this._recipient)throw t.LombardError.missingParameter("recipient");return this._recipient}ensureAmount(){if(!this._amount)throw t.LombardError.missingParameter("amount");return this._amount}ensureDepositAddress(){if(!this._depositAddress)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Deposit address not generated. Call generateDepositAddress() first.");return this._depositAddress}getAuthRequiredMessage(){return"Authorization required. Complete the authorization step first."}ensureAuthorized(){if(!this.isAuthorized())throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,this.getAuthRequiredMessage())}async resumeFromExistingDeposit(i){try{const e=await this.ctx.api.getDepositAddress({address:i,chainId:this.getChainId(),token:this.getExpectedToken(),partnerId:this.ctx.partner.getPartnerId()});return e?(this._depositAddress=e,!0):!1}catch{return!1}}async generateDepositAddressImpl(i){const e=this.getStatusConfig();return this.assertStatus(e.ready,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress?this._depositAddress:this.act(async()=>{const a=this.getDepositAddressParams(i),n=await this.ctx.api.generateDepositAddress(a);f(n),this._depositAddress=n;const o=this.getInitialSteps(),h=Object.fromEntries(Object.entries(o).map(([d],T)=>[d,T===0?t.StepStatus.COMPLETE:t.StepStatus.IDLE]));return this.emitProgress({status:e.addressReady,steps:h,metadata:{depositAddress:n}}),n},e.addressReady)}async executeImpl(){const i=this.getStatusConfig();return this.act(async()=>{this.assertStatus(i.addressReady,"execute"),this._depositAddress||await this.generateDepositAddressImpl();const e=this.ensureDepositAddress(),a=await this.trySendBitcoin(e);return a?{depositAddress:e,txHash:a}:{depositAddress:e}})}emitInitialProgress(){this.emitProgress({status:this.status,steps:this.getInitialSteps()})}async monitorDeposit(){const i=this._depositAddress,e=this._recipient;if(!i||!e)throw t.LombardError.missingParameter("depositAddress or recipient");return await y({network:this.bitcoinNetwork,btcService:this.ctx.btc,fetchDeposit:async()=>{const o=(await this.ctx.api.getDeposits(e)).find(h=>h.depositAddress===i);if(o)return{blockHeight:o.blockHeight,isClaimed:o.isClaimed}},onProgress:n=>{this.emitProgress({status:this.status,steps:n.steps,confirmations:n.confirmations,requiredConfirmations:n.requiredConfirmations,metadata:{isClaimed:n.isClaimed}})},onComplete:()=>{this.emitCompleted()}})}async trySendBitcoin(i){const e=this._amount;if(e)try{const a=await this.ctx.getProvider("bitcoin");if(!a)return;const n=a;if(n.sendBitcoin){const o=D.toSatoshi(e).toNumber();return n.sendBitcoin(i,o)}}catch{}}}function E(s,r=A.Token.LBTC){switch(s){case c.AssetId.LBTC:return A.Token.LBTC;case c.AssetId.BTCb:return A.Token.BTCb;default:return r}}async function tt(s,r){try{await s.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${r.toString(16)}`}]})}catch(i){const e=i;if(e.code===4902)try{await A.addChain({provider:s,chainId:r}),await s.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${r.toString(16)}`}]});return}catch(a){const n=a;throw n.code===4001?new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"User rejected adding chain to wallet."):new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Failed to add chain ${r} to wallet: ${n.message||"Unknown error"}`)}throw e.code===4001?new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"User rejected chain switch request."):new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Failed to switch to chain ${r}: ${e.message||"Unknown error"}`)}}async function et(s){const r=await s.request({method:"eth_chainId"});return parseInt(r,16)}async function C(s,r){await et(s)!==r&&await tt(s,r)}const st=[t.Chain.ETHEREUM,t.Chain.SEPOLIA],it={async getMintingFee(s,r){return s.capabilities.require("evm").getMintingFee(r,A.Token.BTCb)},async restoreFeeSignature(s,r,i){const e=await l.getTokenContractInfo(A.Token.BTCb,r,s.env),a=await s.api.getFeeSignature({address:i,chainId:r,tokenAddress:e.address});return!a.hasSignature||a.expirationDate&&new Date(Number(a.expirationDate)*1e3)<new Date?null:{hasSignature:!0,signature:a.signature,typedData:a.typedData}},async authorizeFee(s,{chainId:r,recipient:i,fee:e}){const a=s.capabilities.require("evm"),n=await s.getProvider("evm");if(!n)throw t.LombardError.providerMissing(String(r),"evm");await C(n,r);const o=D.toSatoshi(e).toString(),h=await l.getTokenContractInfo(A.Token.BTCb,r,s.env),d=await a.signNetworkFee({fee:o,account:i,chainId:r,provider:n,token:A.Token.BTCb});return await s.api.storeFeeSignature({address:i,signature:d.signature,typedData:d.typedData,tokenAddress:h.address}),{signature:d.signature,typedData:d.typedData}}},rt={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.BTCb).filter(s=>t.isEvmChain(s)),supportedAssetsOut:[c.AssetId.BTCb],addressSchema:t.evmAddressSchema,getFeeAuthConfig(s){return st.includes(s)?it:null},async signDestination(s,r,i){const e=s.capabilities.require("evm"),a=await s.getProvider("evm");if(!a)throw t.LombardError.providerMissing(String(i),"evm");return await C(a,i),{signature:(await e.signLbtcDestination({address:r,chainId:i,provider:a})).signature}}},m=s=>`${s}${t.CAIP2_SEPARATOR}`;function nt(s){return String(s).startsWith(m(t.CHAIN_PREFIXES.EIP155))}function b(s){return String(s).startsWith(m(t.CHAIN_PREFIXES.SOLANA))}function at(s){return String(s).startsWith(m(t.CHAIN_PREFIXES.SUI))}function ot(s){return String(s).startsWith(m(t.CHAIN_PREFIXES.STARKNET))}function ut(s){const r={[t.Chain.SOLANA_MAINNET]:"mainnet-beta",[t.Chain.SOLANA_DEVNET]:"devnet",[t.Chain.SOLANA_TESTNET]:"testnet","solana:mainnet-beta":"mainnet-beta","solana:devnet":"devnet","solana:testnet":"testnet"},i=r[s];if(!i)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unknown Solana chain: ${s}. Expected one of: ${Object.keys(r).join(", ")}`);return i}const dt={chainType:"solana",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet]}],destChains:t.getAllAssetChains(c.AssetId.BTCb).filter(s=>b(s)),supportedAssetsOut:[c.AssetId.BTCb],addressSchema:t.solanaAddressSchema,getFeeAuthConfig:()=>null,async signDestination(s,r,i){const e=s.capabilities.require("solana"),a=ut(i),{signature:n}=await e.signLbtcDestination({network:a});return{signature:n}}},ct={evm:rt,solana:dt};function ht(s){return ct[s]}function pt(s,r){return s.destChains.includes(r)}function At(s,r){return s.supportedAssetsOut.includes(r)}function St(s,r,i){return s.routes.some(e=>e.envs.includes(i)&&(!r||e.sourceChains.includes(r)))}class k extends I{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"config");p(this,"chainId");p(this,"authState",{authorized:!1});p(this,"feeAuthConfig",null);const a=t.getChainType(e.destChain),n=ht(a);if(!n)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported destination chain type: ${a} (${e.destChain})`);if(!At(n,e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for BTC deposits. BTC Deposit produces BTC.b. For LBTC, use BtcStake instead.`);if(!pt(n,e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for ${a} BTC deposits`);if(!St(n,e.sourceChain,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:e.sourceChain,destChain:e.destChain,env:i.env});this.config=n,this.chainId=t.parseChainIdentifier(e.destChain)}getAddressSchema(){return this.config.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}get mintingFee(){return this.authState.mintingFee}getDepositAddressParams(i){return{address:this.ensureRecipient(),chainId:this.chainId,signature:this.authState.signature,token:this.getExpectedToken(),eip712Data:this.authState.typedData,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}async generateDepositAddress(i){if(!this.authState.signature){const e=await this.config.signDestination(this.ctx,this.ensureRecipient(),this.chainId);this.authState.signature=e.signature,this.authState.typedData=e.typedData}return this.generateDepositAddressImpl(i)}getExpectedToken(){return E(this.params.assetOut,A.Token.BTCb)}getAuthRequiredMessage(){return this.feeAuthConfig?"Fee authorization required. Call authorizeFee() first.":"Address confirmation required. Call confirmAddress() first."}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);if(this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.feeAuthConfig=this.config.getFeeAuthConfig(this.params.destChain),await this.resumeFromExistingDeposit(e.recipient)){if(this.feeAuthConfig){const n=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(!(n!=null&&n.hasSignature)){this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION),this.emitInitialProgress();return}n.signature&&(this.authState.signature=n.signature,this.authState.typedData=n.typedData),this.authState.authorized=!0}this.updateStatus(t.BtcActionStatus.ADDRESS_READY),this.emitInitialProgress();return}if(this.feeAuthConfig){const n=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(n!=null&&n.hasSignature){n.signature&&(this.authState.signature=n.signature,this.authState.typedData=n.typedData),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.READY),this.emitInitialProgress();return}this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION)}else this.updateStatus(t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION);this.emitInitialProgress()})}async authorizeFee(){if(this.assertStatus([t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION,t.BtcActionStatus.READY],"authorizeFee"),this.status===t.BtcActionStatus.READY)return;if(!this.feeAuthConfig)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Fee authorization is not required for this destination chain. Use confirmAddress() instead.");const i=this.ensureRecipient();if(!this.authState.mintingFee)throw new t.LombardError(t.ValidationErrorCode.INVALID_STATE,"Minting fee not available. Call prepare() first.");return this.act(async()=>{const e=await this.feeAuthConfig.authorizeFee(this.ctx,{chainId:this.chainId,recipient:i,fee:this.authState.mintingFee});this.authState.signature=e.signature,this.authState.typedData=e.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async confirmAddress(){if(this.assertStatus([t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION,t.BtcActionStatus.READY],"confirmAddress"),this.status===t.BtcActionStatus.READY)return;if(this.feeAuthConfig)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"This destination chain requires fee authorization. Use authorizeFee() instead.");const i=this.ensureRecipient();return this.act(async()=>{const e=await this.config.signDestination(this.ctx,i,this.chainId);this.authState.signature=e.signature,this.authState.typedData=e.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async execute(){return this.executeImpl()}async monitorDeposit(){return super.monitorDeposit()}}const gt=$.VEDA_VAULT_STAKE_AND_BAKE_CHAINS.map(s=>t.evmChainIdToChain(s)),Ct={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet,u.r.ibc]}],destChains:gt,supportedAssetsOut:[c.AssetId.LBTC],supportedProtocols:yt(c.AssetId.LBTC),addressSchema:t.evmAddressSchema,async getStakeAndBakeFee(s,r,i){return s.capabilities.require("evm").getStakeAndBakeFee(r,i)},async authorizeStakeAndBake(s,{chainId:r,recipient:i,amount:e,vaultKey:a,token:n}){const o=s.capabilities.require("evm"),h=await s.getProvider("evm");if(!h)throw t.LombardError.providerMissing(String(r),"evm");await C(h,r);const d=await o.signStakeAndBake({value:e,account:i,chainId:r,provider:h,vaultKey:a,token:n});return await s.api.storeStakeAndBakeSignature({signature:d.signature,typedData:d.typedData}),{signature:d.signature,typedData:d.typedData}},async restoreStakeAndBakeSignature(s,r,i){try{const e=await R.getUserStakeAndBakeSignature({userDestinationAddress:i,chainId:r,env:s.env});return!(e.signature||e.expirationDate)||e.expirationDate&&Number(e.expirationDate)*1e3<Date.now()?null:{hasSignature:!0,signature:e.signature,depositAmount:e.depositAmount,expirationDate:e.expirationDate}}catch{return null}}},S=Ct;function Et(s){return S.destChains.includes(s)}function Dt(s){return S.supportedAssetsOut.includes(s)}function lt(s,r){return s?S.routes.some(i=>i.sourceChains.includes(s)&&i.envs.includes(r)):!0}function O(s){return s in c.DEFI_REGISTRY}function ft(s){if(!O(s)){const r=Object.keys(c.DEFI_REGISTRY).join(", ");throw new Error(`Unsupported protocol: ${s}. Supported protocols: ${r}`)}return s}function It(s){return Object.entries(c.DEFI_REGISTRY).filter(([r,i])=>s in i).map(([r])=>r)}const v={mainnet:[t.Chain.AVALANCHE],testnet:[t.Chain.AVALANCHE_FUJI]},mt={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet,u.r.ibc]}],destChains:[...v.mainnet,...v.testnet],supportedAssetsOut:[c.AssetId.BTCb],supportedProtocols:It(c.AssetId.BTCb),addressSchema:t.evmAddressSchema,async getDepositAndDeployFee(s,r,i){return s.capabilities.require("evm").getStakeAndBakeFee(r,i)},async authorizeDepositAndDeploy(s,{chainId:r,recipient:i,amount:e,vaultKey:a,token:n}){const o=s.capabilities.require("evm"),h=await s.getProvider("evm");if(!h)throw t.LombardError.providerMissing(String(r),"evm");await C(h,r);const d=await o.signStakeAndBake({value:e,account:i,chainId:r,provider:h,vaultKey:a,token:n});return await s.api.storeStakeAndBakeSignature({signature:d.signature,typedData:d.typedData}),{signature:d.signature,typedData:d.typedData,approvalTxHash:d.approvalTxHash}}},g=mt;function Tt(s){return g.destChains.includes(s)}function wt(s){return g.supportedAssetsOut.includes(s)}function P(s){return s in c.DEFI_REGISTRY}function L(s){if(!P(s)){const r=Object.keys(c.DEFI_REGISTRY).join(", ");throw new Error(`Unsupported protocol: ${s}. Supported protocols: ${r}`)}return s}function yt(s){return Object.entries(c.DEFI_REGISTRY).filter(([r,i])=>s in i).map(([r])=>r)}function _t(s,r){return g.routes.some(i=>i.sourceChains.includes(s)&&i.envs.includes(r))}class F extends I{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"chainId");p(this,"authState",{authorized:!1});if(!wt(e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for deposit and deploy. DepositAndDeploy produces BTC.b which is then deployed to a vault like Silo.`);if(!Tt(e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for deposit and deploy. Supported chains: Avalanche, Avalanche Fuji`);if(!P(e.protocol))throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,`Protocol ${e.protocol} is not supported for deposit and deploy. DepositAndDeploy with BTC.b only supports Silo protocol.`);const a=e.sourceChain??t.Chain.BITCOIN_MAINNET;if(!_t(a,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:a,destChain:e.destChain,env:i.env});const n=t.parseChainIdentifier(e.destChain);if(typeof n!="number"||!A.isValidChain(n))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported EVM chain: ${e.destChain}`);this.chainId=n}getAddressSchema(){return g.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,wrapping:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}getDepositAddressParams(i){return{address:this.ensureRecipient(),chainId:this.chainId,signature:this.authState.signature,token:this.getExpectedToken(),signatureData:this.authState.typedData,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}getExpectedToken(){return E(this.params.assetOut,A.Token.BTCb)}getAuthRequiredMessage(){return"Deposit authorization required. Call authorizeDeposit() first."}get fee(){return this.authState.fee}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.authState.fee=await g.getDepositAndDeployFee(this.ctx,this.chainId,L(this.params.protocol)),this.updateStatus(t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION),this.emitInitialProgress()},t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION)}async authorizeDeposit(){if(this.assertStatus([t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION,t.BtcActionStatus.READY],"authorizeDeposit"),this.status===t.BtcActionStatus.READY)return;const i=this.ensureRecipient(),e=this.ensureAmount();return this.act(async()=>{const a=D.toSatoshi(e),n=E(this.params.assetOut,A.Token.BTCb),o=await g.authorizeDepositAndDeploy(this.ctx,{chainId:this.chainId,recipient:i,amount:a.toString(),vaultKey:L(this.params.protocol),token:n});this.authState.signature=o.signature,this.authState.typedData=o.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async generateDepositAddress(i){return this.assertStatus(t.BtcActionStatus.READY,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress?this._depositAddress:this.act(async()=>{const e=this.getDepositAddressParams(i),a=await this.ctx.api.generateDepositAddress(e);return f(a),this._depositAddress=a,this.emitProgress({status:t.BtcActionStatus.ADDRESS_READY,steps:{created:t.StepStatus.COMPLETE,verifying:t.StepStatus.IDLE,wrapping:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE},metadata:{depositAddress:a}}),a},t.BtcActionStatus.ADDRESS_READY)}async execute(){return this.act(async()=>{this.assertStatus(t.BtcActionStatus.ADDRESS_READY,"execute"),this._depositAddress||await this.generateDepositAddress();const i=this.ensureDepositAddress(),e=await this.trySendBitcoin(i);return e?{depositAddress:i,txHash:e}:{depositAddress:i}})}async monitorDeposit(){const i=this._depositAddress,e=this._recipient;if(!i||!e)throw t.LombardError.missingParameter("depositAddress or recipient");return await y({network:this.bitcoinNetwork,btcService:this.ctx.btc,fetchDeposit:async()=>{const o=(await this.ctx.api.getDeposits(e)).find(h=>h.depositAddress===i);if(o)return{blockHeight:o.blockHeight,isClaimed:o.isClaimed}},onProgress:n=>{this.emitProgress({status:this.status,steps:{created:t.StepStatus.COMPLETE,verifying:n.hasEnoughConfirmations?t.StepStatus.COMPLETE:t.StepStatus.PENDING,wrapping:n.isClaimed?t.StepStatus.COMPLETE:t.StepStatus.PENDING,depositing:t.StepStatus.PENDING},confirmations:n.confirmations,requiredConfirmations:n.requiredConfirmations,metadata:{isClaimed:n.isClaimed}})},onComplete:()=>{this.emitCompleted()}})}}const Nt=[t.Chain.ETHEREUM,t.Chain.SEPOLIA],Bt={async getMintingFee(s,r){return s.capabilities.require("evm").getMintingFee(r)},async restoreFeeSignature(s,r,i){const e=await l.getTokenContractInfo(A.Token.LBTC,r,s.env),a=await s.api.getFeeSignature({address:i,chainId:r,tokenAddress:e.address});return!a.hasSignature||a.expirationDate&&new Date(Number(a.expirationDate)*1e3)<new Date?null:{hasSignature:!0,signature:a.signature,typedData:a.typedData}},async authorizeFee(s,{chainId:r,recipient:i,fee:e}){const a=s.capabilities.require("evm"),n=await s.getProvider("evm");if(!n)throw t.LombardError.providerMissing(String(r),"evm");await C(n,r);const o=D.toSatoshi(e).toString(),h=await l.getTokenContractInfo(A.Token.LBTC,r,s.env),d=await a.signNetworkFee({fee:o,account:i,chainId:r,provider:n,token:A.Token.LBTC});return await s.api.storeFeeSignature({address:i,signature:d.signature,typedData:d.typedData,tokenAddress:h.address}),{signature:d.signature,typedData:d.typedData}}},vt={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>nt(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.evmAddressSchema,getFeeAuthConfig(s){return Nt.includes(s)?Bt:null},async getSignature(s,r,i){const e=s.capabilities.require("evm"),a=await s.getProvider("evm");if(!a)throw t.LombardError.providerMissing(String(i),"evm");return await C(a,i),e.signLbtcDestination({chainId:i,address:r,provider:a})}};function Lt(s){const r={[t.Chain.SOLANA_MAINNET]:"mainnet-beta",[t.Chain.SOLANA_DEVNET]:"devnet",[t.Chain.SOLANA_TESTNET]:"testnet","solana:mainnet-beta":"mainnet-beta","solana:devnet":"devnet","solana:testnet":"testnet"},i=r[s];if(!i)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unknown Solana chain: ${s}. Expected one of: ${Object.keys(r).join(", ")}`);return i}const Rt={chainType:"solana",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>b(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.solanaAddressSchema,getFeeAuthConfig:()=>null,async getSignature(s,r,i){const e=s.capabilities.require("solana"),a=Lt(i),{signature:n}=await e.signLbtcDestination({network:a});return{signature:n}}},bt={chainType:"starknet",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>ot(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.starknetAddressSchema,getFeeAuthConfig:()=>null,async getSignature(s,r,i){const e=s.capabilities.require("starknet"),{signature:a,pubKey:n}=await e.signLbtcDestination({chainId:i}),o=q.pad(r,{size:32});return{signature:a,pubKey:n,paddedAddress:o}}},kt={chainType:"sui",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>at(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.suiAddressSchema,getFeeAuthConfig:()=>null,async getSignature(s,r,i){const e=s.capabilities.require("sui"),{signature:a}=await e.signLbtcDestination({chainId:i});return{signature:a}}},Ot={evm:vt,solana:Rt,sui:kt,starknet:bt};function Pt(s){return Ot[s]}function Ft(s,r,i){return r?s.routes.some(e=>e.sourceChains.includes(r)&&e.envs.includes(i)):!0}function xt(s,r){return s.destChains.includes(r)}function Mt(s,r){return s.supportedAssetsOut.includes(r)}class x extends I{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"config");p(this,"chainId");p(this,"authState",{authorized:!1});p(this,"feeAuthConfig",null);const a=t.getChainType(e.destChain),n=Pt(a);if(!n)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported destination chain type: ${a} (${e.destChain})`);if(!Mt(n,e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for BTC staking. BTC Stake produces LBTC. For BTC.b, use BtcDeposit instead.`);if(!xt(n,e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for ${a}`);if(!Ft(n,e.sourceChain,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:e.sourceChain,destChain:e.destChain,env:i.env});this.config=n,this.chainId=t.parseChainIdentifier(e.destChain)}getAddressSchema(){return this.config.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}getDepositAddressParams(i){var n;const e=this.ensureRecipient(),a=this.getActiveSignature();if(!a)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Missing signature. Complete authorization first.");return{address:a.paddedAddress??e,chainId:this.chainId,signature:a.signature,token:this.getExpectedToken(),eip712Data:(n=this.authState.networkFee)==null?void 0:n.typedData,pubKey:a.pubKey,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}getExpectedToken(){return E(this.params.assetOut,A.Token.LBTC)}getAuthRequiredMessage(){return"Authorization required. Call authorize() first."}get mintingFee(){return this.authState.mintingFee}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);if(this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.feeAuthConfig=this.config.getFeeAuthConfig(this.params.destChain),await this.resumeFromExistingDeposit(e.recipient)){if(this.feeAuthConfig){const n=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(!(n!=null&&n.hasSignature)){this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION),this.emitInitialProgress();return}n.signature&&(this.authState.networkFee={signature:n.signature,typedData:n.typedData}),this.authState.authorized=!0}this.updateStatus(t.BtcActionStatus.ADDRESS_READY),this.emitInitialProgress();return}if(this.feeAuthConfig){const n=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(n!=null&&n.hasSignature){n.signature&&(this.authState.networkFee={signature:n.signature,typedData:n.typedData}),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.READY),this.emitInitialProgress();return}this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION)}else this.updateStatus(t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION);this.emitInitialProgress()})}async authorize(){if(this.assertStatus([t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION,t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION,t.BtcActionStatus.READY],"authorize"),this.status===t.BtcActionStatus.READY)return;const i=this.ensureRecipient(),e=this.feeAuthConfig!==null;return this.act(async()=>{if(e){const a=this.ensureMintingFee(),n=await this.feeAuthConfig.authorizeFee(this.ctx,{chainId:this.chainId,recipient:i,fee:a});this.authState.networkFee={signature:n.signature,typedData:n.typedData}}else this.authState.destinationSignature=await this.config.getSignature(this.ctx,i,this.chainId);this.authState.authorized=!0},t.BtcActionStatus.READY)}async generateDepositAddress(i){if(this.assertStatus(t.BtcActionStatus.READY,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress)return this._depositAddress;if(!this.getActiveSignature()){const e=await this.config.getSignature(this.ctx,this.ensureRecipient(),this.chainId);this.authState.destinationSignature=e}return this.act(async()=>{const e=this.getDepositAddressParams(i),a=await this.ctx.api.generateDepositAddress(e);return f(a),this._depositAddress=a,this.emitProgress({status:t.BtcActionStatus.ADDRESS_READY,steps:{created:t.StepStatus.COMPLETE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE},metadata:{depositAddress:a}}),a},t.BtcActionStatus.ADDRESS_READY)}async execute(){return this.executeImpl()}async monitorDeposit(){return super.monitorDeposit()}ensureMintingFee(){if(!this.authState.mintingFee)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Minting fee not fetched. Call prepare() first.");return this.authState.mintingFee}getActiveSignature(){var i;return(i=this.authState.networkFee)!=null&&i.signature?{signature:this.authState.networkFee.signature}:this.authState.destinationSignature}}class M extends I{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"chainId");p(this,"authState",{authorized:!1});if(!Dt(e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for stake and deploy. StakeAndDeploy produces LBTC which is then deployed to a vault.`);if(!Et(e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for stake and deploy`);if(!O(e.protocol))throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,`Protocol ${e.protocol} is not supported for stake and deploy`);if(!lt(e.sourceChain,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:e.sourceChain,destChain:e.destChain,env:i.env});const a=t.parseChainIdentifier(e.destChain);if(typeof a!="number"||!A.isValidChain(a))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported EVM chain: ${e.destChain}`);this.chainId=a}getAddressSchema(){return S.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}getDepositAddressParams(i){return{address:this.ensureRecipient(),chainId:this.chainId,signature:this.authState.signature,token:this.getExpectedToken(),signatureData:this.authState.typedData,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}getExpectedToken(){return E(this.params.assetOut,A.Token.LBTC)}getAuthRequiredMessage(){return"Deposit authorization required. Call authorizeDeposit() first."}get fee(){return this.authState.fee}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);if(this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.authState.fee=await S.getStakeAndBakeFee(this.ctx,this.chainId,this.params.protocol),await this.resumeFromExistingDeposit(e.recipient)){const o=await S.restoreStakeAndBakeSignature(this.ctx,this.chainId,e.recipient);if(o!=null&&o.hasSignature){o.signature&&(this.authState.signature=o.signature),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.ADDRESS_READY),this.emitInitialProgress();return}this.updateStatus(t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION),this.emitInitialProgress();return}const n=await S.restoreStakeAndBakeSignature(this.ctx,this.chainId,e.recipient);if(n!=null&&n.hasSignature){n.signature&&(this.authState.signature=n.signature),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.READY),this.emitInitialProgress();return}this.updateStatus(t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION),this.emitInitialProgress()})}async authorizeDeposit(){if(this.assertStatus([t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION,t.BtcActionStatus.READY],"authorizeDeposit"),this.status===t.BtcActionStatus.READY)return;const i=this.ensureRecipient(),e=this.ensureAmount();return this.act(async()=>{const a=D.toSatoshi(e),n=this.params.assetIn??c.AssetId.BTC,o=await S.authorizeStakeAndBake(this.ctx,{chainId:this.chainId,recipient:i,amount:a.toString(),vaultKey:ft(this.params.protocol),token:n});this.authState.signature=o.signature,this.authState.typedData=o.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async generateDepositAddress(i){return this.assertStatus(t.BtcActionStatus.READY,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress?this._depositAddress:this.act(async()=>{const e=this.getDepositAddressParams(i),a=await this.ctx.api.generateDepositAddress(e);return f(a),this._depositAddress=a,this.emitProgress({status:t.BtcActionStatus.ADDRESS_READY,steps:{created:t.StepStatus.COMPLETE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE},metadata:{depositAddress:a}}),a},t.BtcActionStatus.ADDRESS_READY)}async execute(){return this.act(async()=>{this.assertStatus(t.BtcActionStatus.ADDRESS_READY,"execute"),this._depositAddress||await this.generateDepositAddress();const i=this.ensureDepositAddress(),e=await this.trySendBitcoin(i);return e?{depositAddress:i,txHash:e}:{depositAddress:i}})}async monitorDeposit(){const i=this._depositAddress,e=this._recipient;if(!i||!e)throw t.LombardError.missingParameter("depositAddress or recipient");return await y({network:this.bitcoinNetwork,btcService:this.ctx.btc,fetchDeposit:async()=>{const o=(await this.ctx.api.getDeposits(e)).find(h=>h.depositAddress===i);if(o)return{blockHeight:o.blockHeight,isClaimed:o.isClaimed}},onProgress:n=>{this.emitProgress({status:this.status,steps:{created:t.StepStatus.COMPLETE,verifying:n.hasEnoughConfirmations?t.StepStatus.COMPLETE:t.StepStatus.PENDING,issuing:n.isClaimed?t.StepStatus.COMPLETE:t.StepStatus.PENDING,depositing:t.StepStatus.PENDING},confirmations:n.confirmations,requiredConfirmations:n.requiredConfirmations,metadata:{isClaimed:n.isClaimed}})},onComplete:()=>{this.emitCompleted()}})}}class V{constructor(r){p(this,"ctx");this.ctx=t.createBtcCoreContext(r)}stake(r){return new x(this.ctx,r)}stakeAndDeploy(r){return new M(this.ctx,r)}deposit(r){return new k(this.ctx,r)}depositAndDeploy(r){return new F(this.ctx,r)}}function Vt(s){return new V(s)}exports.BtcActions=V;exports.BtcDeposit=k;exports.BtcDepositAndDeploy=F;exports.BtcStake=x;exports.BtcStakeAndDeploy=M;exports.btcActions=Vt;exports.btcModule=Q;
|
|
2
|
-
//# sourceMappingURL=BtcActions-
|
|
1
|
+
"use strict";var z=Object.defineProperty;var H=(s,r,i)=>r in s?z(s,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[r]=i;var p=(s,r,i)=>H(s,typeof r!="symbol"?r+"":r,i);const Y=require("axios"),t=require("./statusConstants-BTQAvx1I.cjs"),A=require("./token-addresses-DvY-Mw7b.cjs"),u=require("./index-BKzxeh1Y.cjs"),l=require("./tokens-CBsz6l_2.cjs"),D=require("./satoshi-CZEsHl5X.cjs"),c=require("./defi-registry-B8V6dRVB.cjs"),R=require("./getUserStakeAndBakeSignature-BmY5j0OM.cjs"),$=require("./config-ow9X5H0c.cjs"),q=require("viem"),U="ERR_NETWORK",G="This may be due to your Adblocker. Please disable any Adblocker and refresh the page to restore full functionality.";function j(s){const{code:r,message:i}=s;throw r===U?new Error(G):new Error(i)}const K={mempoolApiUrl:"https://mempool.space/signet"},Z={mempoolApiUrl:"https://mempool.space"},W=s=>s==="mainnet"?Z:K;async function X(s){const{mempoolApiUrl:r}=W(s),i=Math.floor(Date.now()/1e3),e=`${r}/api/v1/mining/blocks/timestamp/${i}`;try{const{data:a}=await Y.get(e);return a.height}catch(a){j(a)}}class J{async getCurrentBlockHeight(r){return X(r)}}function Q(){return{id:"btc",chain:"btc",register(){return new J}}}async function y(s){const{fetchDeposit:r,network:i,btcService:e,requiredConfirmations:a=6,onProgress:n,onComplete:o}=s,h=await r();if(!h)return;const d=h.blockHeight;if(typeof d!="number")return;const T=await e.getCurrentBlockHeight(i),_=Math.max(0,T-d),N=_>=a,w=h.isClaimed??!1,B={confirmations:_,requiredConfirmations:a,hasEnoughConfirmations:N,isClaimed:w,steps:{created:t.StepStatus.COMPLETE,verifying:N?t.StepStatus.COMPLETE:t.StepStatus.PENDING,issuing:w?t.StepStatus.COMPLETE:t.StepStatus.PENDING}};return n==null||n(B),w&&(o==null||o()),B}function f(s){if(s===R.SANCTIONED_ADDRESS)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Destination address is under sanctions")}class I extends t.BaseAction{constructor(i,e,a){super(a);p(this,"_amount");p(this,"_recipient");p(this,"_depositAddress");p(this,"_referralCode");p(this,"_chainId");this.ctx=i,this.params=e}get amount(){return this._amount}get recipient(){return this._recipient}get depositAddress(){return this._depositAddress}get referralCode(){return this._referralCode}get bitcoinNetwork(){return this.params.sourceChain===t.Chain.BITCOIN_MAINNET?"mainnet":"testnet"}get prepareSchema(){return t.objectType({amount:t.btcStakeAmountSchema,recipient:this.getAddressSchema(),referralCode:t.referralCodeSchema})}validatePrepareParams(i){return t.validatePrepareParams(this.prepareSchema,i,{destChain:this.params.destChain})}ensureRecipient(){if(!this._recipient)throw t.LombardError.missingParameter("recipient");return this._recipient}ensureAmount(){if(!this._amount)throw t.LombardError.missingParameter("amount");return this._amount}ensureDepositAddress(){if(!this._depositAddress)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Deposit address not generated. Call generateDepositAddress() first.");return this._depositAddress}getAuthRequiredMessage(){return"Authorization required. Complete the authorization step first."}ensureAuthorized(){if(!this.isAuthorized())throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,this.getAuthRequiredMessage())}async resumeFromExistingDeposit(i){try{const e=await this.ctx.api.getDepositAddress({address:i,chainId:this.getChainId(),token:this.getExpectedToken(),partnerId:this.ctx.partner.getPartnerId()});return e?(this._depositAddress=e,!0):!1}catch{return!1}}async generateDepositAddressImpl(i){const e=this.getStatusConfig();return this.assertStatus(e.ready,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress?this._depositAddress:this.act(async()=>{const a=this.getDepositAddressParams(i),n=await this.ctx.api.generateDepositAddress(a);f(n),this._depositAddress=n;const o=this.getInitialSteps(),h=Object.fromEntries(Object.entries(o).map(([d],T)=>[d,T===0?t.StepStatus.COMPLETE:t.StepStatus.IDLE]));return this.emitProgress({status:e.addressReady,steps:h,metadata:{depositAddress:n}}),n},e.addressReady)}async executeImpl(){const i=this.getStatusConfig();return this.act(async()=>{this.assertStatus(i.addressReady,"execute"),this._depositAddress||await this.generateDepositAddressImpl();const e=this.ensureDepositAddress(),a=await this.trySendBitcoin(e);return a?{depositAddress:e,txHash:a}:{depositAddress:e}})}emitInitialProgress(){this.emitProgress({status:this.status,steps:this.getInitialSteps()})}async monitorDeposit(){const i=this._depositAddress,e=this._recipient;if(!i||!e)throw t.LombardError.missingParameter("depositAddress or recipient");return await y({network:this.bitcoinNetwork,btcService:this.ctx.btc,fetchDeposit:async()=>{const o=(await this.ctx.api.getDeposits(e)).find(h=>h.depositAddress===i);if(o)return{blockHeight:o.blockHeight,isClaimed:o.isClaimed}},onProgress:n=>{this.emitProgress({status:this.status,steps:n.steps,confirmations:n.confirmations,requiredConfirmations:n.requiredConfirmations,metadata:{isClaimed:n.isClaimed}})},onComplete:()=>{this.emitCompleted()}})}async trySendBitcoin(i){const e=this._amount;if(e)try{const a=await this.ctx.getProvider("bitcoin");if(!a)return;const n=a;if(n.sendBitcoin){const o=D.toSatoshi(e).toNumber();return n.sendBitcoin(i,o)}}catch{}}}function E(s,r=A.Token.LBTC){switch(s){case c.AssetId.LBTC:return A.Token.LBTC;case c.AssetId.BTCb:return A.Token.BTCb;default:return r}}async function tt(s,r){try{await s.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${r.toString(16)}`}]})}catch(i){const e=i;if(e.code===4902)try{await A.addChain({provider:s,chainId:r}),await s.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${r.toString(16)}`}]});return}catch(a){const n=a;throw n.code===4001?new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"User rejected adding chain to wallet."):new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Failed to add chain ${r} to wallet: ${n.message||"Unknown error"}`)}throw e.code===4001?new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"User rejected chain switch request."):new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Failed to switch to chain ${r}: ${e.message||"Unknown error"}`)}}async function et(s){const r=await s.request({method:"eth_chainId"});return parseInt(r,16)}async function C(s,r){await et(s)!==r&&await tt(s,r)}const st=[t.Chain.ETHEREUM,t.Chain.SEPOLIA],it={async getMintingFee(s,r){return s.capabilities.require("evm").getMintingFee(r,A.Token.BTCb)},async restoreFeeSignature(s,r,i){const e=await l.getTokenContractInfo(A.Token.BTCb,r,s.env),a=await s.api.getFeeSignature({address:i,chainId:r,tokenAddress:e.address});return!a.hasSignature||a.expirationDate&&new Date(Number(a.expirationDate)*1e3)<new Date?null:{hasSignature:!0,signature:a.signature,typedData:a.typedData}},async authorizeFee(s,{chainId:r,recipient:i,fee:e}){const a=s.capabilities.require("evm"),n=await s.getProvider("evm");if(!n)throw t.LombardError.providerMissing(String(r),"evm");await C(n,r);const o=D.toSatoshi(e).toString(),h=await l.getTokenContractInfo(A.Token.BTCb,r,s.env),d=await a.signNetworkFee({fee:o,account:i,chainId:r,provider:n,token:A.Token.BTCb});return await s.api.storeFeeSignature({address:i,signature:d.signature,typedData:d.typedData,tokenAddress:h.address}),{signature:d.signature,typedData:d.typedData}}},rt={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.BTCb).filter(s=>t.isEvmChain(s)),supportedAssetsOut:[c.AssetId.BTCb],addressSchema:t.evmAddressSchema,getFeeAuthConfig(s){return st.includes(s)?it:null},async signDestination(s,r,i){const e=s.capabilities.require("evm"),a=await s.getProvider("evm");if(!a)throw t.LombardError.providerMissing(String(i),"evm");return await C(a,i),{signature:(await e.signLbtcDestination({address:r,chainId:i,provider:a})).signature}}},m=s=>`${s}${t.CAIP2_SEPARATOR}`;function nt(s){return String(s).startsWith(m(t.CHAIN_PREFIXES.EIP155))}function b(s){return String(s).startsWith(m(t.CHAIN_PREFIXES.SOLANA))}function at(s){return String(s).startsWith(m(t.CHAIN_PREFIXES.SUI))}function ot(s){return String(s).startsWith(m(t.CHAIN_PREFIXES.STARKNET))}function ut(s){const r={[t.Chain.SOLANA_MAINNET]:"mainnet-beta",[t.Chain.SOLANA_DEVNET]:"devnet",[t.Chain.SOLANA_TESTNET]:"testnet","solana:mainnet-beta":"mainnet-beta","solana:devnet":"devnet","solana:testnet":"testnet"},i=r[s];if(!i)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unknown Solana chain: ${s}. Expected one of: ${Object.keys(r).join(", ")}`);return i}const dt={chainType:"solana",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet]}],destChains:t.getAllAssetChains(c.AssetId.BTCb).filter(s=>b(s)),supportedAssetsOut:[c.AssetId.BTCb],addressSchema:t.solanaAddressSchema,getFeeAuthConfig:()=>null,async signDestination(s,r,i){const e=s.capabilities.require("solana"),a=ut(i),{signature:n}=await e.signLbtcDestination({network:a});return{signature:n}}},ct={evm:rt,solana:dt};function ht(s){return ct[s]}function pt(s,r){return s.destChains.includes(r)}function At(s,r){return s.supportedAssetsOut.includes(r)}function St(s,r,i){return s.routes.some(e=>e.envs.includes(i)&&(!r||e.sourceChains.includes(r)))}class k extends I{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"config");p(this,"chainId");p(this,"authState",{authorized:!1});p(this,"feeAuthConfig",null);const a=t.getChainType(e.destChain),n=ht(a);if(!n)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported destination chain type: ${a} (${e.destChain})`);if(!At(n,e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for BTC deposits. BTC Deposit produces BTC.b. For LBTC, use BtcStake instead.`);if(!pt(n,e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for ${a} BTC deposits`);if(!St(n,e.sourceChain,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:e.sourceChain,destChain:e.destChain,env:i.env});this.config=n,this.chainId=t.parseChainIdentifier(e.destChain)}getAddressSchema(){return this.config.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}get mintingFee(){return this.authState.mintingFee}getDepositAddressParams(i){return{address:this.ensureRecipient(),chainId:this.chainId,signature:this.authState.signature,token:this.getExpectedToken(),eip712Data:this.authState.typedData,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}async generateDepositAddress(i){if(!this.authState.signature){const e=await this.config.signDestination(this.ctx,this.ensureRecipient(),this.chainId);this.authState.signature=e.signature,this.authState.typedData=e.typedData}return this.generateDepositAddressImpl(i)}getExpectedToken(){return E(this.params.assetOut,A.Token.BTCb)}getAuthRequiredMessage(){return this.feeAuthConfig?"Fee authorization required. Call authorizeFee() first.":"Address confirmation required. Call confirmAddress() first."}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);if(this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.feeAuthConfig=this.config.getFeeAuthConfig(this.params.destChain),await this.resumeFromExistingDeposit(e.recipient)){if(this.feeAuthConfig){const n=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(!(n!=null&&n.hasSignature)){this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION),this.emitInitialProgress();return}n.signature&&(this.authState.signature=n.signature,this.authState.typedData=n.typedData),this.authState.authorized=!0}this.updateStatus(t.BtcActionStatus.ADDRESS_READY),this.emitInitialProgress();return}if(this.feeAuthConfig){const n=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(n!=null&&n.hasSignature){n.signature&&(this.authState.signature=n.signature,this.authState.typedData=n.typedData),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.READY),this.emitInitialProgress();return}this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION)}else this.updateStatus(t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION);this.emitInitialProgress()})}async authorizeFee(){if(this.assertStatus([t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION,t.BtcActionStatus.READY],"authorizeFee"),this.status===t.BtcActionStatus.READY)return;if(!this.feeAuthConfig)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Fee authorization is not required for this destination chain. Use confirmAddress() instead.");const i=this.ensureRecipient();if(!this.authState.mintingFee)throw new t.LombardError(t.ValidationErrorCode.INVALID_STATE,"Minting fee not available. Call prepare() first.");return this.act(async()=>{const e=await this.feeAuthConfig.authorizeFee(this.ctx,{chainId:this.chainId,recipient:i,fee:this.authState.mintingFee});this.authState.signature=e.signature,this.authState.typedData=e.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async confirmAddress(){if(this.assertStatus([t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION,t.BtcActionStatus.READY],"confirmAddress"),this.status===t.BtcActionStatus.READY)return;if(this.feeAuthConfig)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"This destination chain requires fee authorization. Use authorizeFee() instead.");const i=this.ensureRecipient();return this.act(async()=>{const e=await this.config.signDestination(this.ctx,i,this.chainId);this.authState.signature=e.signature,this.authState.typedData=e.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async execute(){return this.executeImpl()}async monitorDeposit(){return super.monitorDeposit()}}const gt=$.VEDA_VAULT_STAKE_AND_BAKE_CHAINS.map(s=>t.evmChainIdToChain(s)),Ct={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet,u.r.ibc]}],destChains:gt,supportedAssetsOut:[c.AssetId.LBTC],supportedProtocols:yt(c.AssetId.LBTC),addressSchema:t.evmAddressSchema,async getStakeAndBakeFee(s,r,i){return s.capabilities.require("evm").getStakeAndBakeFee(r,i)},async authorizeStakeAndBake(s,{chainId:r,recipient:i,amount:e,vaultKey:a,token:n}){const o=s.capabilities.require("evm"),h=await s.getProvider("evm");if(!h)throw t.LombardError.providerMissing(String(r),"evm");await C(h,r);const d=await o.signStakeAndBake({value:e,account:i,chainId:r,provider:h,vaultKey:a,token:n});return await s.api.storeStakeAndBakeSignature({signature:d.signature,typedData:d.typedData}),{signature:d.signature,typedData:d.typedData}},async restoreStakeAndBakeSignature(s,r,i){try{const e=await R.getUserStakeAndBakeSignature({userDestinationAddress:i,chainId:r,env:s.env});return!(e.signature||e.expirationDate)||e.expirationDate&&Number(e.expirationDate)*1e3<Date.now()?null:{hasSignature:!0,signature:e.signature,depositAmount:e.depositAmount,expirationDate:e.expirationDate}}catch{return null}}},S=Ct;function Et(s){return S.destChains.includes(s)}function Dt(s){return S.supportedAssetsOut.includes(s)}function lt(s,r){return s?S.routes.some(i=>i.sourceChains.includes(s)&&i.envs.includes(r)):!0}function O(s){return s in c.DEFI_REGISTRY}function ft(s){if(!O(s)){const r=Object.keys(c.DEFI_REGISTRY).join(", ");throw new Error(`Unsupported protocol: ${s}. Supported protocols: ${r}`)}return s}function It(s){return Object.entries(c.DEFI_REGISTRY).filter(([r,i])=>s in i).map(([r])=>r)}const v={mainnet:[t.Chain.AVALANCHE],testnet:[t.Chain.AVALANCHE_FUJI]},mt={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet,u.r.ibc]}],destChains:[...v.mainnet,...v.testnet],supportedAssetsOut:[c.AssetId.BTCb],supportedProtocols:It(c.AssetId.BTCb),addressSchema:t.evmAddressSchema,async getDepositAndDeployFee(s,r,i){return s.capabilities.require("evm").getStakeAndBakeFee(r,i)},async authorizeDepositAndDeploy(s,{chainId:r,recipient:i,amount:e,vaultKey:a,token:n}){const o=s.capabilities.require("evm"),h=await s.getProvider("evm");if(!h)throw t.LombardError.providerMissing(String(r),"evm");await C(h,r);const d=await o.signStakeAndBake({value:e,account:i,chainId:r,provider:h,vaultKey:a,token:n});return await s.api.storeStakeAndBakeSignature({signature:d.signature,typedData:d.typedData}),{signature:d.signature,typedData:d.typedData,approvalTxHash:d.approvalTxHash}}},g=mt;function Tt(s){return g.destChains.includes(s)}function wt(s){return g.supportedAssetsOut.includes(s)}function P(s){return s in c.DEFI_REGISTRY}function L(s){if(!P(s)){const r=Object.keys(c.DEFI_REGISTRY).join(", ");throw new Error(`Unsupported protocol: ${s}. Supported protocols: ${r}`)}return s}function yt(s){return Object.entries(c.DEFI_REGISTRY).filter(([r,i])=>s in i).map(([r])=>r)}function _t(s,r){return g.routes.some(i=>i.sourceChains.includes(s)&&i.envs.includes(r))}class F extends I{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"chainId");p(this,"authState",{authorized:!1});if(!wt(e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for deposit and deploy. DepositAndDeploy produces BTC.b which is then deployed to a vault like Silo.`);if(!Tt(e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for deposit and deploy. Supported chains: Avalanche, Avalanche Fuji`);if(!P(e.protocol))throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,`Protocol ${e.protocol} is not supported for deposit and deploy. DepositAndDeploy with BTC.b only supports Silo protocol.`);const a=e.sourceChain??t.Chain.BITCOIN_MAINNET;if(!_t(a,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:a,destChain:e.destChain,env:i.env});const n=t.parseChainIdentifier(e.destChain);if(typeof n!="number"||!A.isValidChain(n))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported EVM chain: ${e.destChain}`);this.chainId=n}getAddressSchema(){return g.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,wrapping:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}getDepositAddressParams(i){return{address:this.ensureRecipient(),chainId:this.chainId,signature:this.authState.signature,token:this.getExpectedToken(),signatureData:this.authState.typedData,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}getExpectedToken(){return E(this.params.assetOut,A.Token.BTCb)}getAuthRequiredMessage(){return"Deposit authorization required. Call authorizeDeposit() first."}get fee(){return this.authState.fee}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.authState.fee=await g.getDepositAndDeployFee(this.ctx,this.chainId,L(this.params.protocol)),this.updateStatus(t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION),this.emitInitialProgress()},t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION)}async authorizeDeposit(){if(this.assertStatus([t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION,t.BtcActionStatus.READY],"authorizeDeposit"),this.status===t.BtcActionStatus.READY)return;const i=this.ensureRecipient(),e=this.ensureAmount();return this.act(async()=>{const a=D.toSatoshi(e),n=E(this.params.assetOut,A.Token.BTCb),o=await g.authorizeDepositAndDeploy(this.ctx,{chainId:this.chainId,recipient:i,amount:a.toString(),vaultKey:L(this.params.protocol),token:n});this.authState.signature=o.signature,this.authState.typedData=o.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async generateDepositAddress(i){return this.assertStatus(t.BtcActionStatus.READY,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress?this._depositAddress:this.act(async()=>{const e=this.getDepositAddressParams(i),a=await this.ctx.api.generateDepositAddress(e);return f(a),this._depositAddress=a,this.emitProgress({status:t.BtcActionStatus.ADDRESS_READY,steps:{created:t.StepStatus.COMPLETE,verifying:t.StepStatus.IDLE,wrapping:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE},metadata:{depositAddress:a}}),a},t.BtcActionStatus.ADDRESS_READY)}async execute(){return this.act(async()=>{this.assertStatus(t.BtcActionStatus.ADDRESS_READY,"execute"),this._depositAddress||await this.generateDepositAddress();const i=this.ensureDepositAddress(),e=await this.trySendBitcoin(i);return e?{depositAddress:i,txHash:e}:{depositAddress:i}})}async monitorDeposit(){const i=this._depositAddress,e=this._recipient;if(!i||!e)throw t.LombardError.missingParameter("depositAddress or recipient");return await y({network:this.bitcoinNetwork,btcService:this.ctx.btc,fetchDeposit:async()=>{const o=(await this.ctx.api.getDeposits(e)).find(h=>h.depositAddress===i);if(o)return{blockHeight:o.blockHeight,isClaimed:o.isClaimed}},onProgress:n=>{this.emitProgress({status:this.status,steps:{created:t.StepStatus.COMPLETE,verifying:n.hasEnoughConfirmations?t.StepStatus.COMPLETE:t.StepStatus.PENDING,wrapping:n.isClaimed?t.StepStatus.COMPLETE:t.StepStatus.PENDING,depositing:t.StepStatus.PENDING},confirmations:n.confirmations,requiredConfirmations:n.requiredConfirmations,metadata:{isClaimed:n.isClaimed}})},onComplete:()=>{this.emitCompleted()}})}}const Nt=[t.Chain.ETHEREUM,t.Chain.SEPOLIA],Bt={async getMintingFee(s,r){return s.capabilities.require("evm").getMintingFee(r)},async restoreFeeSignature(s,r,i){const e=await l.getTokenContractInfo(A.Token.LBTC,r,s.env),a=await s.api.getFeeSignature({address:i,chainId:r,tokenAddress:e.address});return!a.hasSignature||a.expirationDate&&new Date(Number(a.expirationDate)*1e3)<new Date?null:{hasSignature:!0,signature:a.signature,typedData:a.typedData}},async authorizeFee(s,{chainId:r,recipient:i,fee:e}){const a=s.capabilities.require("evm"),n=await s.getProvider("evm");if(!n)throw t.LombardError.providerMissing(String(r),"evm");await C(n,r);const o=D.toSatoshi(e).toString(),h=await l.getTokenContractInfo(A.Token.LBTC,r,s.env),d=await a.signNetworkFee({fee:o,account:i,chainId:r,provider:n,token:A.Token.LBTC});return await s.api.storeFeeSignature({address:i,signature:d.signature,typedData:d.typedData,tokenAddress:h.address}),{signature:d.signature,typedData:d.typedData}}},vt={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>nt(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.evmAddressSchema,getFeeAuthConfig(s){return Nt.includes(s)?Bt:null},async getSignature(s,r,i){const e=s.capabilities.require("evm"),a=await s.getProvider("evm");if(!a)throw t.LombardError.providerMissing(String(i),"evm");return await C(a,i),e.signLbtcDestination({chainId:i,address:r,provider:a})}};function Lt(s){const r={[t.Chain.SOLANA_MAINNET]:"mainnet-beta",[t.Chain.SOLANA_DEVNET]:"devnet",[t.Chain.SOLANA_TESTNET]:"testnet","solana:mainnet-beta":"mainnet-beta","solana:devnet":"devnet","solana:testnet":"testnet"},i=r[s];if(!i)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unknown Solana chain: ${s}. Expected one of: ${Object.keys(r).join(", ")}`);return i}const Rt={chainType:"solana",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>b(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.solanaAddressSchema,getFeeAuthConfig:()=>null,async getSignature(s,r,i){const e=s.capabilities.require("solana"),a=Lt(i),{signature:n}=await e.signLbtcDestination({network:a});return{signature:n}}},bt={chainType:"starknet",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>ot(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.starknetAddressSchema,getFeeAuthConfig:()=>null,async getSignature(s,r,i){const e=s.capabilities.require("starknet"),{signature:a,pubKey:n}=await e.signLbtcDestination({chainId:i}),o=q.pad(r,{size:32});return{signature:a,pubKey:n,paddedAddress:o}}},kt={chainType:"sui",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>at(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.suiAddressSchema,getFeeAuthConfig:()=>null,async getSignature(s,r,i){const e=s.capabilities.require("sui"),{signature:a}=await e.signLbtcDestination({chainId:i});return{signature:a}}},Ot={evm:vt,solana:Rt,sui:kt,starknet:bt};function Pt(s){return Ot[s]}function Ft(s,r,i){return r?s.routes.some(e=>e.sourceChains.includes(r)&&e.envs.includes(i)):!0}function xt(s,r){return s.destChains.includes(r)}function Mt(s,r){return s.supportedAssetsOut.includes(r)}class x extends I{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"config");p(this,"chainId");p(this,"authState",{authorized:!1});p(this,"feeAuthConfig",null);const a=t.getChainType(e.destChain),n=Pt(a);if(!n)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported destination chain type: ${a} (${e.destChain})`);if(!Mt(n,e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for BTC staking. BTC Stake produces LBTC. For BTC.b, use BtcDeposit instead.`);if(!xt(n,e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for ${a}`);if(!Ft(n,e.sourceChain,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:e.sourceChain,destChain:e.destChain,env:i.env});this.config=n,this.chainId=t.parseChainIdentifier(e.destChain)}getAddressSchema(){return this.config.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}getDepositAddressParams(i){var n;const e=this.ensureRecipient(),a=this.getActiveSignature();if(!a)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Missing signature. Complete authorization first.");return{address:a.paddedAddress??e,chainId:this.chainId,signature:a.signature,token:this.getExpectedToken(),eip712Data:(n=this.authState.networkFee)==null?void 0:n.typedData,pubKey:a.pubKey,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}getExpectedToken(){return E(this.params.assetOut,A.Token.LBTC)}getAuthRequiredMessage(){return"Authorization required. Call authorize() first."}get mintingFee(){return this.authState.mintingFee}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);if(this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.feeAuthConfig=this.config.getFeeAuthConfig(this.params.destChain),await this.resumeFromExistingDeposit(e.recipient)){if(this.feeAuthConfig){const n=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(!(n!=null&&n.hasSignature)){this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION),this.emitInitialProgress();return}n.signature&&(this.authState.networkFee={signature:n.signature,typedData:n.typedData}),this.authState.authorized=!0}this.updateStatus(t.BtcActionStatus.ADDRESS_READY),this.emitInitialProgress();return}if(this.feeAuthConfig){const n=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(n!=null&&n.hasSignature){n.signature&&(this.authState.networkFee={signature:n.signature,typedData:n.typedData}),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.READY),this.emitInitialProgress();return}this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION)}else this.updateStatus(t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION);this.emitInitialProgress()})}async authorize(){if(this.assertStatus([t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION,t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION,t.BtcActionStatus.READY],"authorize"),this.status===t.BtcActionStatus.READY)return;const i=this.ensureRecipient(),e=this.feeAuthConfig!==null;return this.act(async()=>{if(e){const a=this.ensureMintingFee(),n=await this.feeAuthConfig.authorizeFee(this.ctx,{chainId:this.chainId,recipient:i,fee:a});this.authState.networkFee={signature:n.signature,typedData:n.typedData}}else this.authState.destinationSignature=await this.config.getSignature(this.ctx,i,this.chainId);this.authState.authorized=!0},t.BtcActionStatus.READY)}async generateDepositAddress(i){if(this.assertStatus(t.BtcActionStatus.READY,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress)return this._depositAddress;if(!this.getActiveSignature()){const e=await this.config.getSignature(this.ctx,this.ensureRecipient(),this.chainId);this.authState.destinationSignature=e}return this.act(async()=>{const e=this.getDepositAddressParams(i),a=await this.ctx.api.generateDepositAddress(e);return f(a),this._depositAddress=a,this.emitProgress({status:t.BtcActionStatus.ADDRESS_READY,steps:{created:t.StepStatus.COMPLETE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE},metadata:{depositAddress:a}}),a},t.BtcActionStatus.ADDRESS_READY)}async execute(){return this.executeImpl()}async monitorDeposit(){return super.monitorDeposit()}ensureMintingFee(){if(!this.authState.mintingFee)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Minting fee not fetched. Call prepare() first.");return this.authState.mintingFee}getActiveSignature(){var i;return(i=this.authState.networkFee)!=null&&i.signature?{signature:this.authState.networkFee.signature}:this.authState.destinationSignature}}class M extends I{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"chainId");p(this,"authState",{authorized:!1});if(!Dt(e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for stake and deploy. StakeAndDeploy produces LBTC which is then deployed to a vault.`);if(!Et(e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for stake and deploy`);if(!O(e.protocol))throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,`Protocol ${e.protocol} is not supported for stake and deploy`);if(!lt(e.sourceChain,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:e.sourceChain,destChain:e.destChain,env:i.env});const a=t.parseChainIdentifier(e.destChain);if(typeof a!="number"||!A.isValidChain(a))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported EVM chain: ${e.destChain}`);this.chainId=a}getAddressSchema(){return S.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}getDepositAddressParams(i){return{address:this.ensureRecipient(),chainId:this.chainId,signature:this.authState.signature,token:this.getExpectedToken(),signatureData:this.authState.typedData,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}getExpectedToken(){return E(this.params.assetOut,A.Token.LBTC)}getAuthRequiredMessage(){return"Deposit authorization required. Call authorizeDeposit() first."}get fee(){return this.authState.fee}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);if(this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.authState.fee=await S.getStakeAndBakeFee(this.ctx,this.chainId,this.params.protocol),await this.resumeFromExistingDeposit(e.recipient)){const o=await S.restoreStakeAndBakeSignature(this.ctx,this.chainId,e.recipient);if(o!=null&&o.hasSignature){o.signature&&(this.authState.signature=o.signature),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.ADDRESS_READY),this.emitInitialProgress();return}this.updateStatus(t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION),this.emitInitialProgress();return}const n=await S.restoreStakeAndBakeSignature(this.ctx,this.chainId,e.recipient);if(n!=null&&n.hasSignature){n.signature&&(this.authState.signature=n.signature),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.READY),this.emitInitialProgress();return}this.updateStatus(t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION),this.emitInitialProgress()})}async authorizeDeposit(){if(this.assertStatus([t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION,t.BtcActionStatus.READY],"authorizeDeposit"),this.status===t.BtcActionStatus.READY)return;const i=this.ensureRecipient(),e=this.ensureAmount();return this.act(async()=>{const a=D.toSatoshi(e),n=this.params.assetIn??c.AssetId.BTC,o=await S.authorizeStakeAndBake(this.ctx,{chainId:this.chainId,recipient:i,amount:a.toString(),vaultKey:ft(this.params.protocol),token:n});this.authState.signature=o.signature,this.authState.typedData=o.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async generateDepositAddress(i){return this.assertStatus(t.BtcActionStatus.READY,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress?this._depositAddress:this.act(async()=>{const e=this.getDepositAddressParams(i),a=await this.ctx.api.generateDepositAddress(e);return f(a),this._depositAddress=a,this.emitProgress({status:t.BtcActionStatus.ADDRESS_READY,steps:{created:t.StepStatus.COMPLETE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE},metadata:{depositAddress:a}}),a},t.BtcActionStatus.ADDRESS_READY)}async execute(){return this.act(async()=>{this.assertStatus(t.BtcActionStatus.ADDRESS_READY,"execute"),this._depositAddress||await this.generateDepositAddress();const i=this.ensureDepositAddress(),e=await this.trySendBitcoin(i);return e?{depositAddress:i,txHash:e}:{depositAddress:i}})}async monitorDeposit(){const i=this._depositAddress,e=this._recipient;if(!i||!e)throw t.LombardError.missingParameter("depositAddress or recipient");return await y({network:this.bitcoinNetwork,btcService:this.ctx.btc,fetchDeposit:async()=>{const o=(await this.ctx.api.getDeposits(e)).find(h=>h.depositAddress===i);if(o)return{blockHeight:o.blockHeight,isClaimed:o.isClaimed}},onProgress:n=>{this.emitProgress({status:this.status,steps:{created:t.StepStatus.COMPLETE,verifying:n.hasEnoughConfirmations?t.StepStatus.COMPLETE:t.StepStatus.PENDING,issuing:n.isClaimed?t.StepStatus.COMPLETE:t.StepStatus.PENDING,depositing:t.StepStatus.PENDING},confirmations:n.confirmations,requiredConfirmations:n.requiredConfirmations,metadata:{isClaimed:n.isClaimed}})},onComplete:()=>{this.emitCompleted()}})}}class V{constructor(r){p(this,"ctx");this.ctx=t.createBtcCoreContext(r)}stake(r){return new x(this.ctx,r)}stakeAndDeploy(r){return new M(this.ctx,r)}deposit(r){return new k(this.ctx,r)}depositAndDeploy(r){return new F(this.ctx,r)}}function Vt(s){return new V(s)}exports.BtcActions=V;exports.BtcDeposit=k;exports.BtcDepositAndDeploy=F;exports.BtcStake=x;exports.BtcStakeAndDeploy=M;exports.btcActions=Vt;exports.btcModule=Q;
|
|
2
|
+
//# sourceMappingURL=BtcActions-CWFHlbUP.cjs.map
|