@lombard.finance/sdk 5.0.3 → 5.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api-functions/storeNetworkFeeSignature/storeNetworkFeeSignature.d.ts +13 -0
  3. package/dist/api-functions/storeNetworkFeeSignature/storeNetworkFeeSignature.d.ts.map +1 -1
  4. package/dist/api.cjs +1 -1
  5. package/dist/api.js +12 -11
  6. package/dist/api.js.map +1 -1
  7. package/dist/btc.cjs +1 -1
  8. package/dist/btc.js +2 -2
  9. package/dist/chains/btc/actions/stake/config/evm.d.ts.map +1 -1
  10. package/dist/chunks/{BtcActions-BE75KQhS.js → BtcActions-D7HekjRg.js} +235 -216
  11. package/dist/chunks/{BtcActions-BE75KQhS.js.map → BtcActions-D7HekjRg.js.map} +1 -1
  12. package/dist/chunks/BtcActions-lp4P72ln.cjs +2 -0
  13. package/dist/chunks/{BtcActions-hLkixDlL.cjs.map → BtcActions-lp4P72ln.cjs.map} +1 -1
  14. package/dist/chunks/EvmActions-CynfSVFq.cjs +7 -0
  15. package/dist/chunks/{EvmActions-DIkhiG2i.cjs.map → EvmActions-CynfSVFq.cjs.map} +1 -1
  16. package/dist/chunks/{EvmActions-DCy8q_l4.js → EvmActions-nbR8cSa4.js} +37 -36
  17. package/dist/chunks/{EvmActions-DCy8q_l4.js.map → EvmActions-nbR8cSa4.js.map} +1 -1
  18. package/dist/chunks/depositStatus-DUXMloTa.cjs +2 -0
  19. package/dist/chunks/{depositStatus-CeoqUgM5.cjs.map → depositStatus-DUXMloTa.cjs.map} +1 -1
  20. package/dist/chunks/{depositStatus-CacTFWfJ.js → depositStatus-hmXphYhu.js} +2 -2
  21. package/dist/chunks/{depositStatus-CacTFWfJ.js.map → depositStatus-hmXphYhu.js.map} +1 -1
  22. package/dist/chunks/{events-Cu4qfdgE.js → events-BP_Ahnsm.js} +42 -41
  23. package/dist/chunks/{events-Cu4qfdgE.js.map → events-BP_Ahnsm.js.map} +1 -1
  24. package/dist/chunks/events-DY2qn8Q0.cjs +2 -0
  25. package/dist/chunks/{events-C3tg6XPm.cjs.map → events-DY2qn8Q0.cjs.map} +1 -1
  26. package/dist/chunks/getNetworkFeeSignature-DqKLslZc.cjs +2 -0
  27. package/dist/chunks/getNetworkFeeSignature-DqKLslZc.cjs.map +1 -0
  28. package/dist/chunks/getNetworkFeeSignature-FuDJWrMC.js +38 -0
  29. package/dist/chunks/getNetworkFeeSignature-FuDJWrMC.js.map +1 -0
  30. package/dist/chunks/statusConstants-D4DN05kK.cjs +2 -0
  31. package/dist/chunks/{statusConstants-BPtrxbYC.cjs.map → statusConstants-D4DN05kK.cjs.map} +1 -1
  32. package/dist/chunks/{statusConstants-8pqtLXvX.js → statusConstants-DLrd03gT.js} +3 -3
  33. package/dist/chunks/{statusConstants-8pqtLXvX.js.map → statusConstants-DLrd03gT.js.map} +1 -1
  34. package/dist/chunks/storeNetworkFeeSignature-BaG3AU8U.cjs +2 -0
  35. package/dist/chunks/storeNetworkFeeSignature-BaG3AU8U.cjs.map +1 -0
  36. package/dist/chunks/storeNetworkFeeSignature-sCt4_nHr.js +52 -0
  37. package/dist/chunks/storeNetworkFeeSignature-sCt4_nHr.js.map +1 -0
  38. package/dist/common/chains.d.ts +3 -0
  39. package/dist/common/chains.d.ts.map +1 -1
  40. package/dist/core.cjs +1 -1
  41. package/dist/core.js +4 -4
  42. package/dist/evm.cjs +1 -1
  43. package/dist/evm.js +2 -2
  44. package/dist/index.cjs +1 -1
  45. package/dist/index.d.ts +1 -1
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +264 -263
  48. package/package.json +1 -1
  49. package/dist/chunks/BtcActions-hLkixDlL.cjs +0 -2
  50. package/dist/chunks/EvmActions-DIkhiG2i.cjs +0 -7
  51. package/dist/chunks/constants-D1FnS2Z8.js +0 -6
  52. package/dist/chunks/constants-D1FnS2Z8.js.map +0 -1
  53. package/dist/chunks/constants-ueShGH9R.cjs +0 -2
  54. package/dist/chunks/constants-ueShGH9R.cjs.map +0 -1
  55. package/dist/chunks/depositStatus-CeoqUgM5.cjs +0 -2
  56. package/dist/chunks/events-C3tg6XPm.cjs +0 -2
  57. package/dist/chunks/statusConstants-BPtrxbYC.cjs +0 -2
  58. package/dist/chunks/storeNetworkFeeSignature-Z0NcQyIn.cjs +0 -2
  59. package/dist/chunks/storeNetworkFeeSignature-Z0NcQyIn.cjs.map +0 -1
  60. package/dist/chunks/storeNetworkFeeSignature-ZdHcFmfP.js +0 -65
  61. package/dist/chunks/storeNetworkFeeSignature-ZdHcFmfP.js.map +0 -1
@@ -0,0 +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-D4DN05kK.cjs"),A=require("./token-addresses-C7H9E4qz.cjs"),u=require("./index-BKzxeh1Y.cjs"),I=require("./tokens-C5rzCTTM.cjs"),f=require("./satoshi-CZEsHl5X.cjs"),c=require("./defi-registry-CyMKVT3z.cjs"),R=require("./getUserStakeAndBakeSignature-Cwwx89pR.cjs"),q=require("./config-BfX8lrdO.cjs"),$=require("./storeNetworkFeeSignature-BaG3AU8U.cjs"),U=require("viem"),G="ERR_NETWORK",j="This may be due to your Adblocker. Please disable any Adblocker and refresh the page to restore full functionality.";function K(s){const{code:r,message:i}=s;throw r===G?new Error(j):new Error(i)}const Z={mempoolApiUrl:"https://mempool.space/signet"},W={mempoolApiUrl:"https://mempool.space"},X=s=>s==="mainnet"?W:Z;async function J(s){const{mempoolApiUrl:r}=X(s),i=Math.floor(Date.now()/1e3),e=`${r}/api/v1/mining/blocks/timestamp/${i}`;try{const{data:n}=await Y.get(e);return n.height}catch(n){K(n)}}class Q{async getCurrentBlockHeight(r){return J(r)}}function tt(){return{id:"btc",chain:"btc",register(){return new Q}}}async function N(s){const{fetchDeposit:r,network:i,btcService:e,requiredConfirmations:n=6,onProgress:a,onComplete:o}=s,h=await r();if(!h)return;const d=h.blockHeight;if(typeof d!="number")return;const C=await e.getCurrentBlockHeight(i),S=Math.max(0,C-d),_=S>=n,y=h.isClaimed??!1,B={confirmations:S,requiredConfirmations:n,hasEnoughConfirmations:_,isClaimed:y,steps:{created:t.StepStatus.COMPLETE,verifying:_?t.StepStatus.COMPLETE:t.StepStatus.PENDING,issuing:y?t.StepStatus.COMPLETE:t.StepStatus.PENDING}};return a==null||a(B),y&&(o==null||o()),B}function m(s){if(s===R.SANCTIONED_ADDRESS)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Destination address is under sanctions")}class T extends t.BaseAction{constructor(i,e,n){super(n);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 n=this.getDepositAddressParams(i),a=await this.ctx.api.generateDepositAddress(n);m(a),this._depositAddress=a;const o=this.getInitialSteps(),h=Object.fromEntries(Object.entries(o).map(([d],C)=>[d,C===0?t.StepStatus.COMPLETE:t.StepStatus.IDLE]));return this.emitProgress({status:e.addressReady,steps:h,metadata:{depositAddress:a}}),a},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(),n=await this.trySendBitcoin(e);return n?{depositAddress:e,txHash:n}:{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 N({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:a=>{this.emitProgress({status:this.status,steps:a.steps,confirmations:a.confirmations,requiredConfirmations:a.requiredConfirmations,metadata:{isClaimed:a.isClaimed}})},onComplete:()=>{this.emitCompleted()}})}async trySendBitcoin(i){const e=this._amount;if(e)try{const n=await this.ctx.getProvider("bitcoin");if(!n)return;const a=n;if(a.sendBitcoin){const o=f.toSatoshi(e).toNumber();return a.sendBitcoin(i,o)}}catch{}}}function l(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 et(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(n){const a=n;throw a.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: ${a.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 st(s){const r=await s.request({method:"eth_chainId"});return parseInt(r,16)}async function D(s,r){await st(s)!==r&&await et(s,r)}const it=[t.Chain.ETHEREUM,t.Chain.SEPOLIA],rt={async getMintingFee(s,r){return s.capabilities.require("evm").getMintingFee(r,A.Token.BTCb)},async restoreFeeSignature(s,r,i){const e=await I.getTokenContractInfo(A.Token.BTCb,r,s.env),n=await s.api.getFeeSignature({address:i,chainId:r,tokenAddress:e.address});return!n.hasSignature||n.expirationDate&&new Date(Number(n.expirationDate)*1e3)<new Date?null:{hasSignature:!0,signature:n.signature,typedData:n.typedData}},async authorizeFee(s,{chainId:r,recipient:i,fee:e}){const n=s.capabilities.require("evm"),a=await s.getProvider("evm");if(!a)throw t.LombardError.providerMissing(String(r),"evm");await D(a,r);const o=f.toSatoshi(e).toString(),h=await I.getTokenContractInfo(A.Token.BTCb,r,s.env),d=await n.signNetworkFee({fee:o,account:i,chainId:r,provider:a,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}}},at={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 it.includes(s)?rt:null},async signDestination(s,r,i){const e=s.capabilities.require("evm"),n=await s.getProvider("evm");if(!n)throw t.LombardError.providerMissing(String(i),"evm");return await D(n,i),{signature:(await e.signLbtcDestination({address:r,chainId:i,provider:n})).signature}}},w=s=>`${s}${t.CAIP2_SEPARATOR}`;function nt(s){return String(s).startsWith(w(t.CHAIN_PREFIXES.EIP155))}function b(s){return String(s).startsWith(w(t.CHAIN_PREFIXES.SOLANA))}function ot(s){return String(s).startsWith(w(t.CHAIN_PREFIXES.SUI))}function ut(s){return String(s).startsWith(w(t.CHAIN_PREFIXES.STARKNET))}function dt(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 ct={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"),n=dt(i),{signature:a}=await e.signLbtcDestination({network:n});return{signature:a}}},ht={evm:at,solana:ct};function pt(s){return ht[s]}function At(s,r){return s.destChains.includes(r)}function St(s,r){return s.supportedAssetsOut.includes(r)}function gt(s,r,i){return s.routes.some(e=>e.envs.includes(i)&&(!r||e.sourceChains.includes(r)))}class k extends T{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 n=t.getChainType(e.destChain),a=pt(n);if(!a)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported destination chain type: ${n} (${e.destChain})`);if(!St(a,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(!At(a,e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for ${n} BTC deposits`);if(!gt(a,e.sourceChain,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:e.sourceChain,destChain:e.destChain,env:i.env});this.config=a,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 l(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 a=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(!(a!=null&&a.hasSignature)){this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION),this.emitInitialProgress();return}a.signature&&(this.authState.signature=a.signature,this.authState.typedData=a.typedData),this.authState.authorized=!0}this.updateStatus(t.BtcActionStatus.ADDRESS_READY),this.emitInitialProgress();return}if(this.feeAuthConfig){const a=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(a!=null&&a.hasSignature){a.signature&&(this.authState.signature=a.signature,this.authState.typedData=a.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 Ct=q.EARN_STAKE_AND_BAKE_CHAINS.map(s=>t.evmChainIdToChain(s)),Et={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:Ct,supportedAssetsOut:[c.AssetId.LBTC],supportedProtocols:Nt(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:n,token:a}){const o=s.capabilities.require("evm"),h=await s.getProvider("evm");if(!h)throw t.LombardError.providerMissing(String(r),"evm");await D(h,r);const d=await o.signStakeAndBake({value:e,account:i,chainId:r,provider:h,vaultKey:n,token:a});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}}},g=Et;function Dt(s){return g.destChains.includes(s)}function lt(s){return g.supportedAssetsOut.includes(s)}function ft(s,r){return s?g.routes.some(i=>i.sourceChains.includes(s)&&i.envs.includes(r)):!0}function O(s){return s in c.DEFI_REGISTRY}function It(s){if(!O(s)){const r=Object.keys(c.DEFI_REGISTRY).join(", ");throw new Error(`Unsupported protocol: ${s}. Supported protocols: ${r}`)}return s}function mt(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]},Tt={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:mt(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:n,token:a}){const o=s.capabilities.require("evm"),h=await s.getProvider("evm");if(!h)throw t.LombardError.providerMissing(String(r),"evm");await D(h,r);const d=await o.signStakeAndBake({value:e,account:i,chainId:r,provider:h,vaultKey:n,token:a});return await s.api.storeStakeAndBakeSignature({signature:d.signature,typedData:d.typedData}),{signature:d.signature,typedData:d.typedData,approvalTxHash:d.approvalTxHash}}},E=Tt;function wt(s){return E.destChains.includes(s)}function yt(s){return E.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 Nt(s){return Object.entries(c.DEFI_REGISTRY).filter(([r,i])=>s in i).map(([r])=>r)}function _t(s,r){return E.routes.some(i=>i.sourceChains.includes(s)&&i.envs.includes(r))}class F extends T{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"chainId");p(this,"authState",{authorized:!1});if(!yt(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(!wt(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 n=e.sourceChain??t.Chain.BITCOIN_MAINNET;if(!_t(n,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:n,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 E.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 l(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 E.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 n=f.toSatoshi(e),a=l(this.params.assetOut,A.Token.BTCb),o=await E.authorizeDepositAndDeploy(this.ctx,{chainId:this.chainId,recipient:i,amount:n.toString(),vaultKey:L(this.params.protocol),token:a});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),n=await this.ctx.api.generateDepositAddress(e);return m(n),this._depositAddress=n,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:n}}),n},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 N({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:a=>{this.emitProgress({status:this.status,steps:{created:t.StepStatus.COMPLETE,verifying:a.hasEnoughConfirmations?t.StepStatus.COMPLETE:t.StepStatus.PENDING,wrapping:a.isClaimed?t.StepStatus.COMPLETE:t.StepStatus.PENDING,depositing:t.StepStatus.PENDING},confirmations:a.confirmations,requiredConfirmations:a.requiredConfirmations,metadata:{isClaimed:a.isClaimed}})},onComplete:()=>{this.emitCompleted()}})}}const Bt=[t.Chain.ETHEREUM,t.Chain.SEPOLIA],vt={async getMintingFee(s,r){return s.capabilities.require("evm").getMintingFee(r)},async restoreFeeSignature(s,r,i){const e=await I.getTokenContractInfo(A.Token.LBTC,r,s.env),n=await s.api.getFeeSignature({address:i,chainId:r,tokenAddress:e.address});return!n.hasSignature||n.expirationDate&&new Date(Number(n.expirationDate)*1e3)<new Date?null:{hasSignature:!0,signature:n.signature,typedData:n.typedData}},async authorizeFee(s,{chainId:r,recipient:i,fee:e}){const n=s.capabilities.require("evm"),a=await s.getProvider("evm");if(!a)throw t.LombardError.providerMissing(String(r),"evm");await D(a,r);const o=f.toSatoshi(e).toString(),h=await I.getTokenContractInfo(A.Token.LBTC,r,s.env),d=await n.signNetworkFee({fee:o,account:i,chainId:r,provider:a,token:A.Token.LBTC});try{await s.api.storeFeeSignature({address:i,signature:d.signature,typedData:d.typedData,tokenAddress:h.address})}catch(C){if(!(C instanceof $.FeeSignatureAlreadyExistsError))throw C;const S=await s.api.getFeeSignature({address:i,chainId:r,tokenAddress:h.address});if(S!=null&&S.hasSignature)return{signature:S.signature??d.signature,typedData:S.typedData??d.typedData};throw new Error("A fee authorization signature already exists for this account but cannot be retrieved. Refresh the page and try again, or contact support if this persists.")}return{signature:d.signature,typedData:d.typedData}}},Lt={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 Bt.includes(s)?vt:null},async getSignature(s,r,i){const e=s.capabilities.require("evm"),n=await s.getProvider("evm");if(!n)throw t.LombardError.providerMissing(String(i),"evm");return await D(n,i),e.signLbtcDestination({chainId:i,address:r,provider:n})}};function Rt(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 bt={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"),n=Rt(i),{signature:a}=await e.signLbtcDestination({network:n});return{signature:a}}},kt={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=>ut(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.starknetAddressSchema,getFeeAuthConfig:()=>null,async getSignature(s,r,i){const e=s.capabilities.require("starknet"),{signature:n,pubKey:a}=await e.signLbtcDestination({chainId:i}),o=U.pad(r,{size:32});return{signature:n,pubKey:a,paddedAddress:o}}},Ot={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=>ot(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.suiAddressSchema,getFeeAuthConfig:()=>null,async getSignature(s,r,i){const e=s.capabilities.require("sui"),{signature:n}=await e.signLbtcDestination({chainId:i});return{signature:n}}},Pt={evm:Lt,solana:bt,sui:Ot,starknet:kt};function Ft(s){return Pt[s]}function xt(s,r,i){return r?s.routes.some(e=>e.sourceChains.includes(r)&&e.envs.includes(i)):!0}function Mt(s,r){return s.destChains.includes(r)}function Vt(s,r){return s.supportedAssetsOut.includes(r)}class x extends T{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 n=t.getChainType(e.destChain),a=Ft(n);if(!a)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported destination chain type: ${n} (${e.destChain})`);if(!Vt(a,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(!Mt(a,e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for ${n}`);if(!xt(a,e.sourceChain,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:e.sourceChain,destChain:e.destChain,env:i.env});this.config=a,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 a;const e=this.ensureRecipient(),n=this.getActiveSignature();if(!n)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Missing signature. Complete authorization first.");return{address:n.paddedAddress??e,chainId:this.chainId,signature:n.signature,token:this.getExpectedToken(),eip712Data:(a=this.authState.networkFee)==null?void 0:a.typedData,pubKey:n.pubKey,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}getExpectedToken(){return l(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 a=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(!(a!=null&&a.hasSignature)){this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION),this.emitInitialProgress();return}a.signature&&(this.authState.networkFee={signature:a.signature,typedData:a.typedData}),this.authState.authorized=!0}this.updateStatus(t.BtcActionStatus.ADDRESS_READY),this.emitInitialProgress();return}if(this.feeAuthConfig){const a=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(a!=null&&a.hasSignature){a.signature&&(this.authState.networkFee={signature:a.signature,typedData:a.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 n=this.ensureMintingFee(),a=await this.feeAuthConfig.authorizeFee(this.ctx,{chainId:this.chainId,recipient:i,fee:n});this.authState.networkFee={signature:a.signature,typedData:a.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),n=await this.ctx.api.generateDepositAddress(e);return m(n),this._depositAddress=n,this.emitProgress({status:t.BtcActionStatus.ADDRESS_READY,steps:{created:t.StepStatus.COMPLETE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE},metadata:{depositAddress:n}}),n},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 T{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"chainId");p(this,"authState",{authorized:!1});if(!lt(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(!Dt(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(!ft(e.sourceChain,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:e.sourceChain,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,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 l(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 g.getStakeAndBakeFee(this.ctx,this.chainId,this.params.protocol),await this.resumeFromExistingDeposit(e.recipient)){const o=await g.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 a=await g.restoreStakeAndBakeSignature(this.ctx,this.chainId,e.recipient);if(a!=null&&a.hasSignature){a.signature&&(this.authState.signature=a.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 n=f.toSatoshi(e),a=this.params.assetIn??c.AssetId.BTC,o=await g.authorizeStakeAndBake(this.ctx,{chainId:this.chainId,recipient:i,amount:n.toString(),vaultKey:It(this.params.protocol),token:a});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),n=await this.ctx.api.generateDepositAddress(e);return m(n),this._depositAddress=n,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:n}}),n},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 N({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:a=>{this.emitProgress({status:this.status,steps:{created:t.StepStatus.COMPLETE,verifying:a.hasEnoughConfirmations?t.StepStatus.COMPLETE:t.StepStatus.PENDING,issuing:a.isClaimed?t.StepStatus.COMPLETE:t.StepStatus.PENDING,depositing:t.StepStatus.PENDING},confirmations:a.confirmations,requiredConfirmations:a.requiredConfirmations,metadata:{isClaimed:a.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 zt(s){return new V(s)}exports.BtcActions=V;exports.BtcDeposit=k;exports.BtcDepositAndDeploy=F;exports.BtcStake=x;exports.BtcStakeAndDeploy=M;exports.btcActions=zt;exports.btcModule=tt;
2
+ //# sourceMappingURL=BtcActions-lp4P72ln.cjs.map