@lombard.finance/sdk 5.0.0 → 5.0.1

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 (39) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/btc.cjs +1 -1
  3. package/dist/btc.js +2 -2
  4. package/dist/chunks/{BtcActions-DJJmmyzi.cjs → BtcActions-7QjAN6OW.cjs} +2 -2
  5. package/dist/chunks/{BtcActions-DJJmmyzi.cjs.map → BtcActions-7QjAN6OW.cjs.map} +1 -1
  6. package/dist/chunks/{BtcActions-CFGiDxtv.js → BtcActions-z1Jcw0cF.js} +2 -2
  7. package/dist/chunks/{BtcActions-CFGiDxtv.js.map → BtcActions-z1Jcw0cF.js.map} +1 -1
  8. package/dist/chunks/{EvmActions-CUKBeiUw.js → EvmActions-CtCvQNt7.js} +3 -3
  9. package/dist/chunks/{EvmActions-CUKBeiUw.js.map → EvmActions-CtCvQNt7.js.map} +1 -1
  10. package/dist/chunks/{EvmActions-CxipDb7X.cjs → EvmActions-D9yTiCR0.cjs} +2 -2
  11. package/dist/chunks/{EvmActions-CxipDb7X.cjs.map → EvmActions-D9yTiCR0.cjs.map} +1 -1
  12. package/dist/chunks/{events-B9b3YdgM.cjs → events-CnxJdwys.cjs} +2 -2
  13. package/dist/chunks/{events-B9b3YdgM.cjs.map → events-CnxJdwys.cjs.map} +1 -1
  14. package/dist/chunks/{events-DU2wYlt_.js → events-d7K-dotA.js} +4 -4
  15. package/dist/chunks/{events-DU2wYlt_.js.map → events-d7K-dotA.js.map} +1 -1
  16. package/dist/chunks/{statusConstants-B-7VEYgO.cjs → statusConstants-B9JY-9Dm.cjs} +2 -2
  17. package/dist/chunks/{statusConstants-B-7VEYgO.cjs.map → statusConstants-B9JY-9Dm.cjs.map} +1 -1
  18. package/dist/chunks/{statusConstants-C3JHNUTC.js → statusConstants-BVOiQJFn.js} +2 -2
  19. package/dist/chunks/{statusConstants-C3JHNUTC.js.map → statusConstants-BVOiQJFn.js.map} +1 -1
  20. package/dist/chunks/{unwrapBtceToLbtcv-Dg-yUGpg.cjs → unwrapBtceToLbtcv-BlRUepkS.cjs} +2 -2
  21. package/dist/chunks/{unwrapBtceToLbtcv-Dg-yUGpg.cjs.map → unwrapBtceToLbtcv-BlRUepkS.cjs.map} +1 -1
  22. package/dist/chunks/{unwrapBtceToLbtcv-C4OxoVVU.js → unwrapBtceToLbtcv-Cu9KedO1.js} +3 -3
  23. package/dist/chunks/{unwrapBtceToLbtcv-C4OxoVVU.js.map → unwrapBtceToLbtcv-Cu9KedO1.js.map} +1 -1
  24. package/dist/chunks/{withdrawEarn-CTtVruit.cjs → withdrawEarn-CVQYjOoY.cjs} +3 -3
  25. package/dist/chunks/{withdrawEarn-CTtVruit.cjs.map → withdrawEarn-CVQYjOoY.cjs.map} +1 -1
  26. package/dist/chunks/{withdrawEarn-QFaMhs0t.js → withdrawEarn-D835YnBD.js} +36 -36
  27. package/dist/chunks/{withdrawEarn-QFaMhs0t.js.map → withdrawEarn-D835YnBD.js.map} +1 -1
  28. package/dist/contract-functions/previewWithdrawEarn/previewWithdrawEarn.d.ts.map +1 -1
  29. package/dist/contract-functions/withdrawEarn/withdrawEarn.d.ts +8 -4
  30. package/dist/contract-functions/withdrawEarn/withdrawEarn.d.ts.map +1 -1
  31. package/dist/contracts.cjs +1 -1
  32. package/dist/contracts.js +2 -2
  33. package/dist/core.cjs +1 -1
  34. package/dist/core.js +5 -5
  35. package/dist/evm.cjs +1 -1
  36. package/dist/evm.js +3 -3
  37. package/dist/index.cjs +1 -1
  38. package/dist/index.js +6 -6
  39. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";var H=Object.defineProperty;var F=(n,e,s)=>e in n?H(n,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[e]=s;var a=(n,e,s)=>F(n,typeof e!="symbol"?e+"":e,s);require("axios");const t=require("./statusConstants-B-7VEYgO.cjs"),G=require("./getUserStakeAndBakeSignature-VlC_GHmz.cjs"),S=require("./ReferralsClient-o-3AUm7s.cjs"),I=require("./storeNetworkFeeSignature-DJgBfZp7.cjs"),b=require("./BtcActions-DJJmmyzi.cjs"),D=require("./EvmActions-CxipDb7X.cjs"),m=require("./token-addresses-C7H9E4qz.cjs"),v=require("./satoshi-CZEsHl5X.cjs"),o=require("./index-BKzxeh1Y.cjs"),c=require("./defi-registry-CyMKVT3z.cjs"),Y=require("./get-exchange-ratio-DGztGO7i.cjs"),N=require("./get-vault-withdrawals-Cgx7VsM1.cjs"),O=["debug","info","warn","error","none"];function T(n={}){const{level:e="debug",prefix:s="[Lombard SDK]",timestamp:r=!1}=n,i=O.indexOf(e),u=d=>O.indexOf(d)>=i&&e!=="none",h=d=>{if(r){const p=new Date().toISOString();return`${s} ${p} ${d}`}return`${s} ${d}`},g=d=>!d||Object.keys(d).length===0?[]:[d];return{debug(d,p){u("debug")&&console.debug(h(d),...g(p))},info(d,p){u("info")&&console.info(h(d),...g(p))},warn(d,p){u("warn")&&console.warn(h(d),...g(p))},error(d,p){u("error")&&console.error(h(d),...g(p))}}}function q(){return{debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}}}function U(){return{"X-SDK-Version":t.SDK_VERSION,"X-SDK-Runtime":t.SDK_RUNTIME}}class _{constructor(e=o.p){a(this,"apiVersion","v1");this.env=e}async deposits(e){return S.getDepositsByAddress({address:e,env:this.env})}async unstakes(e,s){return S.getUnstakesByAddress({address:e,env:this.env,options:s})}async points(e,s){return S.getPointsByAddress({address:e,env:this.env,season:s})}async exchangeRatio(){return Y.getExchangeRatio({env:this.env})}async depositAddress(e,s,r){return S.getDepositBtcAddress({address:e,chainId:s,env:this.env,partnerId:r==null?void 0:r.partnerId,token:r==null?void 0:r.token})}async vaultWithdrawals(e,s){const r=e;return s!=null&&s.chainId?N.getEarnWithdrawals({account:r,chainId:s.chainId,rpcUrl:s.rpcUrl,env:this.env}):N.getEarnWithdrawalsAllChains({account:r,rpcUrl:s==null?void 0:s.rpcUrl})}getApiVersion(){return this.apiVersion}}function K(n){if(!n.env)throw t.LombardError.missingParameter("env");const e={env:n.env,providers:n.providers||{}};return n.partner&&(V(n.partner),e.partner=n.partner),e}function V(n){if(typeof n!="object"||n===null)throw t.LombardError.invalidConfiguration("Partner configuration must be an object");const e=n;if(!e.partnerId||typeof e.partnerId!="string")throw t.LombardError.missingParameter("partner.partnerId");if(e.partnerId.trim().length===0)throw t.LombardError.invalidConfiguration("Partner ID cannot be empty")}class j{constructor(e){this.env=e}async generateDepositAddress(e){return G.generateDepositBtcAddress({address:e.address,chainId:e.chainId,signature:e.signature,token:e.token,eip712Data:e.eip712Data,signatureData:e.signatureData,pubKey:e.pubKey,env:this.env,partnerId:e.partnerId,referrerCode:e.referrerCode,captchaToken:e.captchaToken})}async getDepositAddress(e){try{return await S.getDepositBtcAddress({address:e.address,chainId:e.chainId,token:e.token,env:this.env,partnerId:e.partnerId})||void 0}catch{return}}async getDeposits(e){return(await S.getDepositsByAddress({address:e,env:this.env})).map(r=>{var i;return{depositAddress:r.depositAddress??"",blockHeight:r.blockHeight,isClaimed:r.isClaimed,txid:r.txHash,amount:(i=r.amount)==null?void 0:i.toString()}})}async storeFeeSignature(e){await I.storeNetworkFeeSignature({address:e.address,signature:e.signature,typedData:e.typedData,env:this.env,tokenAddress:e.tokenAddress})}async getFeeSignature(e){return I.getNetworkFeeSignature({address:e.address,chainId:e.chainId,env:this.env,tokenAddress:e.tokenAddress})}async storeStakeAndBakeSignature(e){await S.storeStakeAndBakeSignature({signature:e.signature,typedData:e.typedData,env:this.env})}}function $(){return{id:"api",register(n){return new j(n.env)}}}function W(n){const e=new Map,s=[b.btcModule(),D.evmModule(),$()];for(const r of s)e.set(r.id,r);if(n)for(const r of n)e.set(r.id,r);return Array.from(e.values())}function z(n,e){for(const s of n)for(const r of s.requiresProviders??[])if(!X(e,r))throw t.LombardError.providerMissing(r,r)}function X(n,e){var s;return!!((s=n.providers)!=null&&s[e])}function P(n){const e=K(n),s=W(n.modules);z(s,e);let r=n.logger;return!r&&n.debug&&(r=T({level:"debug"})),{...e,modules:s,logger:r}}function E(n){switch(n){case"prod":return"mainnet-beta";case"testnet":case"stage":case"dev":case"ibc":default:return"devnet"}}function L(n){switch(n){case"prod":return m.SOLANA_MAINNET_CHAIN;case"testnet":case"stage":case"dev":case"ibc":default:return m.SOLANA_DEVNET_CHAIN}}const x={routes:[{sourceChains:[t.Chain.SOLANA_MAINNET],destChain:t.Chain.BITCOIN_MAINNET,assetIn:c.AssetId.BTCb,assetOut:c.AssetId.BTC,envs:[o.r.prod]},{sourceChains:[t.Chain.SOLANA_DEVNET],destChain:t.Chain.BITCOIN_SIGNET,assetIn:c.AssetId.BTCb,assetOut:c.AssetId.BTC,envs:[o.r.testnet,o.r.stage,o.r.dev]}],recipientSchema:t.bitcoinAddressSchema};function Z(n,e,s,r,i){return x.routes.some(u=>u.sourceChains.includes(n)&&u.destChain===e&&u.assetIn===s&&u.assetOut===r&&u.envs.includes(i))}class J extends t.BaseAction{constructor(s,r){super(t.NonEvmOperationStatus.IDLE);a(this,"_amount");a(this,"_recipient");a(this,"_txHash");if(this.ctx=s,this.params=r,!Z(r.sourceChain,r.destChain,r.assetIn,r.assetOut,s.env))throw t.LombardError.routeNotFound({assetOut:r.assetOut,sourceChain:r.sourceChain,destChain:r.destChain,env:s.env})}get amount(){return this._amount}get recipient(){return this._recipient}get txHash(){return this._txHash}async prepare(s){return this.assertStatus(t.NonEvmOperationStatus.IDLE,"prepare"),this.act(async()=>{const r=t.validatePrepareParams(this.prepareSchema,s,{destChain:this.params.destChain});this._amount=r.amount,this._recipient=r.recipient,this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.IDLE,releasing:t.StepStatus.IDLE}})},t.NonEvmOperationStatus.READY)}async execute(){return this.assertStatus(t.NonEvmOperationStatus.READY,"execute"),this.act(async()=>{const s=this._amount,r=this._recipient;if(!s||!r)throw t.LombardError.missingParameter("amount or recipient");this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.PENDING,releasing:t.StepStatus.IDLE}});const i=v.toSatoshi(s).toString(),u=E(this.ctx.env),h=m.getSolanaTokenAddress(L(this.ctx.env),this.ctx.env,m.Token.BTCb);if(!h)throw t.LombardError.missingParameter("Solana BTC.b mint for this environment");const{signature:g}=await this.ctx.solana.redeemForBtc({amount:i,btcAddress:r,network:u,env:this.ctx.env,tokenMint:h});return this._txHash=g,this.emitProgress({status:t.NonEvmOperationStatus.COMPLETED,steps:{burning:t.StepStatus.COMPLETE,releasing:t.StepStatus.COMPLETE}}),this.emitCompleted(),{txHash:g}},t.NonEvmOperationStatus.COMPLETED)}get prepareSchema(){return t.objectType({amount:t.amountSchema,recipient:x.recipientSchema})}}const y={routes:[{chain:t.Chain.SOLANA_MAINNET,assetIn:c.AssetId.BTCb,assetOut:c.AssetId.LBTC,envs:[o.r.prod]},{chain:t.Chain.SOLANA_DEVNET,assetIn:c.AssetId.BTCb,assetOut:c.AssetId.LBTC,envs:[o.r.stage,o.r.dev,o.r.testnet]}],recipientSchema:t.solanaAddressSchema};function Q(n,e,s,r){return y.routes.some(i=>i.chain===n&&i.assetIn===e&&i.assetOut===s&&i.envs.includes(r))}class tt extends t.BaseAction{constructor(s,r){super(t.NonEvmOperationStatus.IDLE);a(this,"_amount");a(this,"_recipient");a(this,"_txHash");a(this,"env");if(this.ctx=s,this.params=r,this.env=s.env,!Q(r.chain,r.assetIn,r.assetOut,this.env))throw t.LombardError.routeNotFound({assetOut:r.assetOut,chain:r.chain,env:this.env})}get amount(){return this._amount}get recipient(){return this._recipient}get txHash(){return this._txHash}async prepare(s){return this.assertStatus(t.NonEvmOperationStatus.IDLE,"prepare"),this.act(async()=>{const r=t.validatePrepareParams(this.prepareSchema,s,{destChain:this.params.chain});this._amount=r.amount,this._recipient=r.recipient,this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.IDLE,minting:t.StepStatus.IDLE}})},t.NonEvmOperationStatus.READY)}async execute(){return this.assertStatus(t.NonEvmOperationStatus.READY,"execute"),this.act(async()=>{const s=this._amount,r=this._recipient;if(!s||!r)throw t.LombardError.missingParameter("amount or recipient");this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.PENDING,minting:t.StepStatus.IDLE}});const i=v.toSatoshi(s).toString(),u=E(this.env),{signature:h}=await this.ctx.solana.deposit({amount:i,recipient:r,network:u,env:this.env});return this._txHash=h,this.emitProgress({status:t.NonEvmOperationStatus.CONFIRMING,steps:{burning:t.StepStatus.COMPLETE,minting:t.StepStatus.PENDING},txHash:h}),this.emitCompleted(),{txHash:h}},t.NonEvmOperationStatus.CONFIRMING)}get prepareSchema(){return t.objectType({amount:t.amountSchema,recipient:y.recipientSchema})}}const w={routes:[{sourceChains:[t.Chain.SOLANA_MAINNET],destChain:t.Chain.BITCOIN_MAINNET,assetIn:c.AssetId.LBTC,assetOut:c.AssetId.BTC,envs:[o.r.prod]},{sourceChains:[t.Chain.SOLANA_DEVNET],destChain:t.Chain.BITCOIN_SIGNET,assetIn:c.AssetId.LBTC,assetOut:c.AssetId.BTC,envs:[o.r.testnet,o.r.stage,o.r.dev,o.r.ibc]}],recipientSchema:t.bitcoinAddressSchema},k={routes:[{sourceChains:[t.Chain.SOLANA_MAINNET],destChain:t.Chain.SOLANA_MAINNET,assetIn:c.AssetId.LBTC,assetOut:c.AssetId.BTCb,envs:[o.r.prod]},{sourceChains:[t.Chain.SOLANA_DEVNET],destChain:t.Chain.SOLANA_DEVNET,assetIn:c.AssetId.LBTC,assetOut:c.AssetId.BTCb,envs:[o.r.stage,o.r.dev,o.r.testnet]}],recipientSchema:t.solanaAddressSchema},et=[...w.routes,...k.routes];function st(n,e,s,r,i){return et.some(u=>u.sourceChains.includes(n)&&u.destChain===e&&u.assetIn===s&&u.assetOut===r&&u.envs.includes(i))}class nt extends t.BaseAction{constructor(s,r){super(t.NonEvmOperationStatus.IDLE);a(this,"_amount");a(this,"_recipient");a(this,"_txHash");a(this,"isBtcbOutput");if(this.ctx=s,this.params=r,this.isBtcbOutput=r.assetOut===c.AssetId.BTCb,!st(r.sourceChain,r.destChain,r.assetIn,r.assetOut,s.env))throw t.LombardError.routeNotFound({assetOut:r.assetOut,sourceChain:r.sourceChain,destChain:r.destChain,env:s.env})}get amount(){return this._amount}get recipient(){return this._recipient}get txHash(){return this._txHash}async prepare(s){return this.assertStatus(t.NonEvmOperationStatus.IDLE,"prepare"),this.act(async()=>{const r=t.validatePrepareParams(this.prepareSchema,s,{destChain:this.params.destChain});this._amount=r.amount,this._recipient=r.recipient,this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.IDLE,releasing:t.StepStatus.IDLE}})},t.NonEvmOperationStatus.READY)}async execute(){return this.assertStatus(t.NonEvmOperationStatus.READY,"execute"),this.act(async()=>{const s=this._amount,r=this._recipient;if(!s||!r)throw t.LombardError.missingParameter("amount or recipient");this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.PENDING,releasing:t.StepStatus.IDLE}});const i=v.toSatoshi(s).toString(),u=E(this.ctx.env);let h;if(this.isBtcbOutput)({signature:h}=await this.ctx.solana.redeem({amount:i,recipient:r,network:u,env:this.ctx.env}));else{const g=m.getSolanaTokenAddress(L(this.ctx.env),this.ctx.env,m.Token.LBTC);if(!g)throw t.LombardError.missingParameter("Solana LBTC mint for this environment");({signature:h}=await this.ctx.solana.redeemForBtc({amount:i,btcAddress:r,network:u,env:this.ctx.env,tokenMint:g}))}return this._txHash=h,this.emitProgress({status:t.NonEvmOperationStatus.COMPLETED,steps:{burning:t.StepStatus.COMPLETE,releasing:t.StepStatus.COMPLETE}}),this.emitCompleted(),{txHash:h}},t.NonEvmOperationStatus.COMPLETED)}get prepareSchema(){const s=this.isBtcbOutput?k:w;return t.objectType({amount:t.amountSchema,recipient:s.recipientSchema})}}function rt(n){const s=new t.CapabilityRegistry(n.modules,n).require("solana");return{env:n.env,partner:new t.PartnerConfiguration(n.partner),getProvider:async r=>{const i=t.getProviderGetter(n.providers,r);if(i)return i()},solana:s}}class C{constructor(e){a(this,"_ctx",null);this.config=e}get ctx(){return this._ctx||(this._ctx=rt(this.config)),this._ctx}stake(e){return new tt(this.ctx,e)}unstake(e){return new nt(this.ctx,e)}redeem(e){return new J(this.ctx,e)}}function it(n){return new C(n)}const B={routes:[{sourceChains:[t.Chain.STARKNET_MAINNET],destChain:t.Chain.BITCOIN_MAINNET,envs:[o.r.prod]},{sourceChains:[t.Chain.STARKNET_SEPOLIA],destChain:t.Chain.BITCOIN_SIGNET,envs:[o.r.testnet,o.r.stage,o.r.dev,o.r.ibc]}],recipientSchema:t.bitcoinAddressSchema};function at(n,e){return B.routes.some(s=>s.sourceChains.includes(n)&&s.envs.includes(e))}class ot extends t.BaseAction{constructor(s,r){super(t.NonEvmOperationStatus.IDLE);a(this,"_amount");a(this,"_recipient");a(this,"_txHash");a(this,"env");if(this.ctx=s,this.params=r,this.env=s.env,!at(r.sourceChain,this.env))throw t.LombardError.routeNotFound({assetOut:r.assetOut,sourceChain:r.sourceChain,destChain:r.destChain,env:this.env})}get amount(){return this._amount}get recipient(){return this._recipient}get txHash(){return this._txHash}async prepare(s){return this.assertStatus(t.NonEvmOperationStatus.IDLE,"prepare"),this.act(async()=>{const r=t.validatePrepareParams(this.prepareSchema,s,{destChain:this.params.destChain});this._amount=r.amount,this._recipient=r.recipient,this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.IDLE,releasing:t.StepStatus.IDLE}})},t.NonEvmOperationStatus.READY)}async execute(){return this.assertStatus(t.NonEvmOperationStatus.READY,"execute"),this.act(async()=>{const s=this._amount,r=this._recipient;if(!s||!r)throw t.LombardError.missingParameter("amount or recipient");this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.PENDING,releasing:t.StepStatus.IDLE}});const{txHash:i}=await this.ctx.starknet.unstake({amount:s,btcAddress:r,env:this.env});return this._txHash=i,this.emitProgress({status:t.NonEvmOperationStatus.COMPLETED,steps:{burning:t.StepStatus.COMPLETE,releasing:t.StepStatus.PENDING}}),this.emitCompleted(),{txHash:i}},t.NonEvmOperationStatus.COMPLETED)}get prepareSchema(){return t.objectType({amount:t.amountSchema,recipient:B.recipientSchema})}}function ut(n){const s=new t.CapabilityRegistry(n.modules,n).require("starknet");return{env:n.env,partner:new t.PartnerConfiguration(n.partner),getProvider:async r=>{const i=t.getProviderGetter(n.providers,r);if(i)return i()},starknet:s}}class A{constructor(e){a(this,"_ctx",null);this.config=e}get ctx(){return this._ctx||(this._ctx=ut(this.config)),this._ctx}unstake(e){return new ot(this.ctx,e)}}function ct(n){return new A(n)}const M={routes:[{sourceChains:[t.Chain.SUI_MAINNET],destChain:t.Chain.BITCOIN_MAINNET,envs:[o.r.prod]},{sourceChains:[t.Chain.SUI_TESTNET],destChain:t.Chain.BITCOIN_SIGNET,envs:[o.r.testnet,o.r.stage,o.r.dev,o.r.ibc]}],recipientSchema:t.bitcoinAddressSchema};function ht(n,e){return M.routes.some(s=>s.sourceChains.includes(n)&&s.envs.includes(e))}function dt(n){switch(n){case t.Chain.SUI_MAINNET:return"sui:mainnet";case t.Chain.SUI_TESTNET:return"sui:testnet";default:return"sui:testnet"}}class gt extends t.BaseAction{constructor(s,r){super(t.NonEvmOperationStatus.IDLE);a(this,"_amount");a(this,"_recipient");a(this,"_txHash");a(this,"env");if(this.ctx=s,this.params=r,this.env=s.env,!ht(r.sourceChain,this.env))throw t.LombardError.routeNotFound({assetOut:r.assetOut,sourceChain:r.sourceChain,destChain:r.destChain,env:this.env})}get amount(){return this._amount}get recipient(){return this._recipient}get txHash(){return this._txHash}async prepare(s){return this.assertStatus(t.NonEvmOperationStatus.IDLE,"prepare"),this.act(async()=>{const r=t.validatePrepareParams(this.prepareSchema,s,{destChain:this.params.destChain});this._amount=r.amount,this._recipient=r.recipient,this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.IDLE,releasing:t.StepStatus.IDLE}})},t.NonEvmOperationStatus.READY)}async execute(){return this.assertStatus(t.NonEvmOperationStatus.READY,"execute"),this.act(async()=>{const s=this._amount,r=this._recipient;if(!s||!r)throw t.LombardError.missingParameter("amount or recipient");this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.PENDING,releasing:t.StepStatus.IDLE}});const i=dt(this.params.sourceChain),{txHash:u}=await this.ctx.sui.unstake({amount:s,btcAddress:r,chainId:i,env:this.env});return this._txHash=u,this.emitProgress({status:t.NonEvmOperationStatus.COMPLETED,steps:{burning:t.StepStatus.COMPLETE,releasing:t.StepStatus.PENDING}}),this.emitCompleted(),{txHash:u}},t.NonEvmOperationStatus.COMPLETED)}get prepareSchema(){return t.objectType({amount:t.amountSchema,recipient:M.recipientSchema})}}function pt(n){const s=new t.CapabilityRegistry(n.modules,n).require("sui");return{env:n.env,partner:new t.PartnerConfiguration(n.partner),getProvider:async r=>{const i=t.getProviderGetter(n.providers,r);if(i)return i()},sui:s}}class f{constructor(e){a(this,"_ctx",null);this.config=e}get ctx(){return this._ctx||(this._ctx=pt(this.config)),this._ctx}unstake(e){return new gt(this.ctx,e)}}function St(n){return new f(n)}class mt{constructor(e=o.p,s){a(this,"catalog");this.env=e,this.catalog=s??t.ASSET_CATALOG}getAddress(e,s){return t.getAssetAddress(e,this.env,s,this.catalog)}getDecimals(e){return t.getAssetDecimals(e,this.catalog)}getMetadata(e){return t.getAssetMetadata(e,this.catalog)}usesAssetRouter(e,s){return t.usesAssetRouter(e,this.env,s,this.catalog)}getAssetRouter(e,s){return t.getAssetRouter(e,this.env,s,this.catalog)}getBridgeAdapter(e,s){return t.getBridgeAdapter(e,this.env,s,this.catalog)}getPublicMarketMaker(e,s){return t.getPublicMarketMaker(e,this.env,s,this.catalog)}getByAddress(e,s){return t.getAssetByAddress(e,this.env,s,this.catalog)}isDeployed(e,s){return t.isAssetDeployed(e,this.env,s,this.catalog)}getChains(e){return t.getAssetChains(e,this.env,this.catalog)}getEnvironments(e,s){return t.getAssetEnvironments(e,s,this.catalog)}getSupportedAssets(){return t.getSupportedAssets(this.catalog)}getCatalog(){return this.catalog}}class R{constructor(e){a(this,"config");a(this,"env");a(this,"partnerConfig");a(this,"providerCache",new Map);a(this,"chain");a(this,"assets");a(this,"api");a(this,"referrals");a(this,"capabilities");this.config=e,this.env=e.env,this.partnerConfig=new t.PartnerConfiguration(e.partner),this.capabilities=new t.CapabilityRegistry(this.config.modules,this.config),this.chain={btc:new b.BtcActions(this.config),evm:new D.EvmActions(this.config),solana:new C(this.config),sui:new f(this.config),starknet:new A(this.config)},this.referrals=new S.ReferralsClient(this),this.assets=new mt(this.env),this.api=new _(this.env)}async getProvider(e){const s=e;if(this.providerCache.has(s))return this.providerCache.get(s);const r=t.getProviderGetter(this.config.providers,e);if(!r)throw t.LombardError.providerMissing(e,e);const i=await r();if(!i)throw new t.LombardError(t.ProviderErrorCode.PROVIDER_INITIALIZATION_FAILED,`Failed to initialize ${e} provider`);return this.providerCache.set(s,i),i}configure(e){this.partnerConfig.update(e)}registerAsset(e){throw new Error("Not implemented yet")}getPartnerConfig(){return this.partnerConfig}getPartnerId(){return this.partnerConfig.getPartnerId()}}const l=new Map;function lt(n){return l.has(n)||l.set(n,Promise.resolve(t.ASSET_CATALOG)),l.get(n)}async function vt(n){const e="modules"in n&&Array.isArray(n.modules)?n:P(n),s=await lt(e.env),r={...e,catalog:s};return new R(r)}function Et(n){return typeof n=="object"&&n!==null&&"request"in n&&typeof n.request=="function"}function Ct(n){return typeof n=="object"&&n!==null&&"getAddresses"in n&&typeof n.getAddresses=="function"}function At(n){return typeof n=="object"&&n!==null&&"publicKey"in n&&"signAndSendTransaction"in n}function ft(n){return typeof n=="object"&&n!==null&&"getAddress"in n&&"signAndExecuteTransactionBlock"in n}function It(n){return typeof n=="object"&&n!==null&&"address"in n&&"execute"in n}const Nt={Progress:"progress",StatusChange:"status-change",Completed:"completed",Failed:"failed",Error:"error"},Ot={Progress:"progress",StatusChange:"status-change",Completed:"completed",Failed:"failed",Error:"error"},bt={Progress:"progress",StatusChange:"status-change",Completed:"completed",Failed:"failed",Error:"error"},Dt={Progress:"progress",StatusChange:"status-change",Completed:"completed",Failed:"failed",Error:"error"},Tt={Progress:"progress",StatusChange:"status-change",Completed:"completed",Failed:"failed",Error:"error"},_t={Progress:"progress",StatusChange:"status-change",Completed:"completed",Failed:"failed",Error:"error"};exports.ApiNamespace=_;exports.BridgeEvent=_t;exports.DeployEvent=Tt;exports.DepositEvent=Ot;exports.LombardSDK=R;exports.RedeemEvent=bt;exports.SolanaActions=C;exports.StakeEvent=Nt;exports.StarknetActions=A;exports.SuiActions=f;exports.UnstakeEvent=Dt;exports.createConfig=P;exports.createConsoleLogger=T;exports.createLombardSDK=vt;exports.createSilentLogger=q;exports.getSdkHeaders=U;exports.isBtcProvider=Ct;exports.isEvmProvider=Et;exports.isSolanaProvider=At;exports.isStarknetProvider=It;exports.isSuiProvider=ft;exports.solanaActions=it;exports.starknetActions=ct;exports.suiActions=St;
2
- //# sourceMappingURL=events-B9b3YdgM.cjs.map
1
+ "use strict";var H=Object.defineProperty;var F=(n,e,s)=>e in n?H(n,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[e]=s;var a=(n,e,s)=>F(n,typeof e!="symbol"?e+"":e,s);require("axios");const t=require("./statusConstants-B9JY-9Dm.cjs"),G=require("./getUserStakeAndBakeSignature-VlC_GHmz.cjs"),S=require("./ReferralsClient-o-3AUm7s.cjs"),I=require("./storeNetworkFeeSignature-DJgBfZp7.cjs"),b=require("./BtcActions-7QjAN6OW.cjs"),D=require("./EvmActions-D9yTiCR0.cjs"),m=require("./token-addresses-C7H9E4qz.cjs"),v=require("./satoshi-CZEsHl5X.cjs"),o=require("./index-BKzxeh1Y.cjs"),c=require("./defi-registry-CyMKVT3z.cjs"),Y=require("./get-exchange-ratio-DGztGO7i.cjs"),N=require("./get-vault-withdrawals-Cgx7VsM1.cjs"),O=["debug","info","warn","error","none"];function T(n={}){const{level:e="debug",prefix:s="[Lombard SDK]",timestamp:r=!1}=n,i=O.indexOf(e),u=d=>O.indexOf(d)>=i&&e!=="none",h=d=>{if(r){const p=new Date().toISOString();return`${s} ${p} ${d}`}return`${s} ${d}`},g=d=>!d||Object.keys(d).length===0?[]:[d];return{debug(d,p){u("debug")&&console.debug(h(d),...g(p))},info(d,p){u("info")&&console.info(h(d),...g(p))},warn(d,p){u("warn")&&console.warn(h(d),...g(p))},error(d,p){u("error")&&console.error(h(d),...g(p))}}}function q(){return{debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}}}function U(){return{"X-SDK-Version":t.SDK_VERSION,"X-SDK-Runtime":t.SDK_RUNTIME}}class _{constructor(e=o.p){a(this,"apiVersion","v1");this.env=e}async deposits(e){return S.getDepositsByAddress({address:e,env:this.env})}async unstakes(e,s){return S.getUnstakesByAddress({address:e,env:this.env,options:s})}async points(e,s){return S.getPointsByAddress({address:e,env:this.env,season:s})}async exchangeRatio(){return Y.getExchangeRatio({env:this.env})}async depositAddress(e,s,r){return S.getDepositBtcAddress({address:e,chainId:s,env:this.env,partnerId:r==null?void 0:r.partnerId,token:r==null?void 0:r.token})}async vaultWithdrawals(e,s){const r=e;return s!=null&&s.chainId?N.getEarnWithdrawals({account:r,chainId:s.chainId,rpcUrl:s.rpcUrl,env:this.env}):N.getEarnWithdrawalsAllChains({account:r,rpcUrl:s==null?void 0:s.rpcUrl})}getApiVersion(){return this.apiVersion}}function K(n){if(!n.env)throw t.LombardError.missingParameter("env");const e={env:n.env,providers:n.providers||{}};return n.partner&&(V(n.partner),e.partner=n.partner),e}function V(n){if(typeof n!="object"||n===null)throw t.LombardError.invalidConfiguration("Partner configuration must be an object");const e=n;if(!e.partnerId||typeof e.partnerId!="string")throw t.LombardError.missingParameter("partner.partnerId");if(e.partnerId.trim().length===0)throw t.LombardError.invalidConfiguration("Partner ID cannot be empty")}class j{constructor(e){this.env=e}async generateDepositAddress(e){return G.generateDepositBtcAddress({address:e.address,chainId:e.chainId,signature:e.signature,token:e.token,eip712Data:e.eip712Data,signatureData:e.signatureData,pubKey:e.pubKey,env:this.env,partnerId:e.partnerId,referrerCode:e.referrerCode,captchaToken:e.captchaToken})}async getDepositAddress(e){try{return await S.getDepositBtcAddress({address:e.address,chainId:e.chainId,token:e.token,env:this.env,partnerId:e.partnerId})||void 0}catch{return}}async getDeposits(e){return(await S.getDepositsByAddress({address:e,env:this.env})).map(r=>{var i;return{depositAddress:r.depositAddress??"",blockHeight:r.blockHeight,isClaimed:r.isClaimed,txid:r.txHash,amount:(i=r.amount)==null?void 0:i.toString()}})}async storeFeeSignature(e){await I.storeNetworkFeeSignature({address:e.address,signature:e.signature,typedData:e.typedData,env:this.env,tokenAddress:e.tokenAddress})}async getFeeSignature(e){return I.getNetworkFeeSignature({address:e.address,chainId:e.chainId,env:this.env,tokenAddress:e.tokenAddress})}async storeStakeAndBakeSignature(e){await S.storeStakeAndBakeSignature({signature:e.signature,typedData:e.typedData,env:this.env})}}function $(){return{id:"api",register(n){return new j(n.env)}}}function W(n){const e=new Map,s=[b.btcModule(),D.evmModule(),$()];for(const r of s)e.set(r.id,r);if(n)for(const r of n)e.set(r.id,r);return Array.from(e.values())}function z(n,e){for(const s of n)for(const r of s.requiresProviders??[])if(!X(e,r))throw t.LombardError.providerMissing(r,r)}function X(n,e){var s;return!!((s=n.providers)!=null&&s[e])}function P(n){const e=K(n),s=W(n.modules);z(s,e);let r=n.logger;return!r&&n.debug&&(r=T({level:"debug"})),{...e,modules:s,logger:r}}function E(n){switch(n){case"prod":return"mainnet-beta";case"testnet":case"stage":case"dev":case"ibc":default:return"devnet"}}function L(n){switch(n){case"prod":return m.SOLANA_MAINNET_CHAIN;case"testnet":case"stage":case"dev":case"ibc":default:return m.SOLANA_DEVNET_CHAIN}}const x={routes:[{sourceChains:[t.Chain.SOLANA_MAINNET],destChain:t.Chain.BITCOIN_MAINNET,assetIn:c.AssetId.BTCb,assetOut:c.AssetId.BTC,envs:[o.r.prod]},{sourceChains:[t.Chain.SOLANA_DEVNET],destChain:t.Chain.BITCOIN_SIGNET,assetIn:c.AssetId.BTCb,assetOut:c.AssetId.BTC,envs:[o.r.testnet,o.r.stage,o.r.dev]}],recipientSchema:t.bitcoinAddressSchema};function Z(n,e,s,r,i){return x.routes.some(u=>u.sourceChains.includes(n)&&u.destChain===e&&u.assetIn===s&&u.assetOut===r&&u.envs.includes(i))}class J extends t.BaseAction{constructor(s,r){super(t.NonEvmOperationStatus.IDLE);a(this,"_amount");a(this,"_recipient");a(this,"_txHash");if(this.ctx=s,this.params=r,!Z(r.sourceChain,r.destChain,r.assetIn,r.assetOut,s.env))throw t.LombardError.routeNotFound({assetOut:r.assetOut,sourceChain:r.sourceChain,destChain:r.destChain,env:s.env})}get amount(){return this._amount}get recipient(){return this._recipient}get txHash(){return this._txHash}async prepare(s){return this.assertStatus(t.NonEvmOperationStatus.IDLE,"prepare"),this.act(async()=>{const r=t.validatePrepareParams(this.prepareSchema,s,{destChain:this.params.destChain});this._amount=r.amount,this._recipient=r.recipient,this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.IDLE,releasing:t.StepStatus.IDLE}})},t.NonEvmOperationStatus.READY)}async execute(){return this.assertStatus(t.NonEvmOperationStatus.READY,"execute"),this.act(async()=>{const s=this._amount,r=this._recipient;if(!s||!r)throw t.LombardError.missingParameter("amount or recipient");this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.PENDING,releasing:t.StepStatus.IDLE}});const i=v.toSatoshi(s).toString(),u=E(this.ctx.env),h=m.getSolanaTokenAddress(L(this.ctx.env),this.ctx.env,m.Token.BTCb);if(!h)throw t.LombardError.missingParameter("Solana BTC.b mint for this environment");const{signature:g}=await this.ctx.solana.redeemForBtc({amount:i,btcAddress:r,network:u,env:this.ctx.env,tokenMint:h});return this._txHash=g,this.emitProgress({status:t.NonEvmOperationStatus.COMPLETED,steps:{burning:t.StepStatus.COMPLETE,releasing:t.StepStatus.COMPLETE}}),this.emitCompleted(),{txHash:g}},t.NonEvmOperationStatus.COMPLETED)}get prepareSchema(){return t.objectType({amount:t.amountSchema,recipient:x.recipientSchema})}}const y={routes:[{chain:t.Chain.SOLANA_MAINNET,assetIn:c.AssetId.BTCb,assetOut:c.AssetId.LBTC,envs:[o.r.prod]},{chain:t.Chain.SOLANA_DEVNET,assetIn:c.AssetId.BTCb,assetOut:c.AssetId.LBTC,envs:[o.r.stage,o.r.dev,o.r.testnet]}],recipientSchema:t.solanaAddressSchema};function Q(n,e,s,r){return y.routes.some(i=>i.chain===n&&i.assetIn===e&&i.assetOut===s&&i.envs.includes(r))}class tt extends t.BaseAction{constructor(s,r){super(t.NonEvmOperationStatus.IDLE);a(this,"_amount");a(this,"_recipient");a(this,"_txHash");a(this,"env");if(this.ctx=s,this.params=r,this.env=s.env,!Q(r.chain,r.assetIn,r.assetOut,this.env))throw t.LombardError.routeNotFound({assetOut:r.assetOut,chain:r.chain,env:this.env})}get amount(){return this._amount}get recipient(){return this._recipient}get txHash(){return this._txHash}async prepare(s){return this.assertStatus(t.NonEvmOperationStatus.IDLE,"prepare"),this.act(async()=>{const r=t.validatePrepareParams(this.prepareSchema,s,{destChain:this.params.chain});this._amount=r.amount,this._recipient=r.recipient,this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.IDLE,minting:t.StepStatus.IDLE}})},t.NonEvmOperationStatus.READY)}async execute(){return this.assertStatus(t.NonEvmOperationStatus.READY,"execute"),this.act(async()=>{const s=this._amount,r=this._recipient;if(!s||!r)throw t.LombardError.missingParameter("amount or recipient");this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.PENDING,minting:t.StepStatus.IDLE}});const i=v.toSatoshi(s).toString(),u=E(this.env),{signature:h}=await this.ctx.solana.deposit({amount:i,recipient:r,network:u,env:this.env});return this._txHash=h,this.emitProgress({status:t.NonEvmOperationStatus.CONFIRMING,steps:{burning:t.StepStatus.COMPLETE,minting:t.StepStatus.PENDING},txHash:h}),this.emitCompleted(),{txHash:h}},t.NonEvmOperationStatus.CONFIRMING)}get prepareSchema(){return t.objectType({amount:t.amountSchema,recipient:y.recipientSchema})}}const w={routes:[{sourceChains:[t.Chain.SOLANA_MAINNET],destChain:t.Chain.BITCOIN_MAINNET,assetIn:c.AssetId.LBTC,assetOut:c.AssetId.BTC,envs:[o.r.prod]},{sourceChains:[t.Chain.SOLANA_DEVNET],destChain:t.Chain.BITCOIN_SIGNET,assetIn:c.AssetId.LBTC,assetOut:c.AssetId.BTC,envs:[o.r.testnet,o.r.stage,o.r.dev,o.r.ibc]}],recipientSchema:t.bitcoinAddressSchema},k={routes:[{sourceChains:[t.Chain.SOLANA_MAINNET],destChain:t.Chain.SOLANA_MAINNET,assetIn:c.AssetId.LBTC,assetOut:c.AssetId.BTCb,envs:[o.r.prod]},{sourceChains:[t.Chain.SOLANA_DEVNET],destChain:t.Chain.SOLANA_DEVNET,assetIn:c.AssetId.LBTC,assetOut:c.AssetId.BTCb,envs:[o.r.stage,o.r.dev,o.r.testnet]}],recipientSchema:t.solanaAddressSchema},et=[...w.routes,...k.routes];function st(n,e,s,r,i){return et.some(u=>u.sourceChains.includes(n)&&u.destChain===e&&u.assetIn===s&&u.assetOut===r&&u.envs.includes(i))}class nt extends t.BaseAction{constructor(s,r){super(t.NonEvmOperationStatus.IDLE);a(this,"_amount");a(this,"_recipient");a(this,"_txHash");a(this,"isBtcbOutput");if(this.ctx=s,this.params=r,this.isBtcbOutput=r.assetOut===c.AssetId.BTCb,!st(r.sourceChain,r.destChain,r.assetIn,r.assetOut,s.env))throw t.LombardError.routeNotFound({assetOut:r.assetOut,sourceChain:r.sourceChain,destChain:r.destChain,env:s.env})}get amount(){return this._amount}get recipient(){return this._recipient}get txHash(){return this._txHash}async prepare(s){return this.assertStatus(t.NonEvmOperationStatus.IDLE,"prepare"),this.act(async()=>{const r=t.validatePrepareParams(this.prepareSchema,s,{destChain:this.params.destChain});this._amount=r.amount,this._recipient=r.recipient,this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.IDLE,releasing:t.StepStatus.IDLE}})},t.NonEvmOperationStatus.READY)}async execute(){return this.assertStatus(t.NonEvmOperationStatus.READY,"execute"),this.act(async()=>{const s=this._amount,r=this._recipient;if(!s||!r)throw t.LombardError.missingParameter("amount or recipient");this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.PENDING,releasing:t.StepStatus.IDLE}});const i=v.toSatoshi(s).toString(),u=E(this.ctx.env);let h;if(this.isBtcbOutput)({signature:h}=await this.ctx.solana.redeem({amount:i,recipient:r,network:u,env:this.ctx.env}));else{const g=m.getSolanaTokenAddress(L(this.ctx.env),this.ctx.env,m.Token.LBTC);if(!g)throw t.LombardError.missingParameter("Solana LBTC mint for this environment");({signature:h}=await this.ctx.solana.redeemForBtc({amount:i,btcAddress:r,network:u,env:this.ctx.env,tokenMint:g}))}return this._txHash=h,this.emitProgress({status:t.NonEvmOperationStatus.COMPLETED,steps:{burning:t.StepStatus.COMPLETE,releasing:t.StepStatus.COMPLETE}}),this.emitCompleted(),{txHash:h}},t.NonEvmOperationStatus.COMPLETED)}get prepareSchema(){const s=this.isBtcbOutput?k:w;return t.objectType({amount:t.amountSchema,recipient:s.recipientSchema})}}function rt(n){const s=new t.CapabilityRegistry(n.modules,n).require("solana");return{env:n.env,partner:new t.PartnerConfiguration(n.partner),getProvider:async r=>{const i=t.getProviderGetter(n.providers,r);if(i)return i()},solana:s}}class C{constructor(e){a(this,"_ctx",null);this.config=e}get ctx(){return this._ctx||(this._ctx=rt(this.config)),this._ctx}stake(e){return new tt(this.ctx,e)}unstake(e){return new nt(this.ctx,e)}redeem(e){return new J(this.ctx,e)}}function it(n){return new C(n)}const B={routes:[{sourceChains:[t.Chain.STARKNET_MAINNET],destChain:t.Chain.BITCOIN_MAINNET,envs:[o.r.prod]},{sourceChains:[t.Chain.STARKNET_SEPOLIA],destChain:t.Chain.BITCOIN_SIGNET,envs:[o.r.testnet,o.r.stage,o.r.dev,o.r.ibc]}],recipientSchema:t.bitcoinAddressSchema};function at(n,e){return B.routes.some(s=>s.sourceChains.includes(n)&&s.envs.includes(e))}class ot extends t.BaseAction{constructor(s,r){super(t.NonEvmOperationStatus.IDLE);a(this,"_amount");a(this,"_recipient");a(this,"_txHash");a(this,"env");if(this.ctx=s,this.params=r,this.env=s.env,!at(r.sourceChain,this.env))throw t.LombardError.routeNotFound({assetOut:r.assetOut,sourceChain:r.sourceChain,destChain:r.destChain,env:this.env})}get amount(){return this._amount}get recipient(){return this._recipient}get txHash(){return this._txHash}async prepare(s){return this.assertStatus(t.NonEvmOperationStatus.IDLE,"prepare"),this.act(async()=>{const r=t.validatePrepareParams(this.prepareSchema,s,{destChain:this.params.destChain});this._amount=r.amount,this._recipient=r.recipient,this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.IDLE,releasing:t.StepStatus.IDLE}})},t.NonEvmOperationStatus.READY)}async execute(){return this.assertStatus(t.NonEvmOperationStatus.READY,"execute"),this.act(async()=>{const s=this._amount,r=this._recipient;if(!s||!r)throw t.LombardError.missingParameter("amount or recipient");this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.PENDING,releasing:t.StepStatus.IDLE}});const{txHash:i}=await this.ctx.starknet.unstake({amount:s,btcAddress:r,env:this.env});return this._txHash=i,this.emitProgress({status:t.NonEvmOperationStatus.COMPLETED,steps:{burning:t.StepStatus.COMPLETE,releasing:t.StepStatus.PENDING}}),this.emitCompleted(),{txHash:i}},t.NonEvmOperationStatus.COMPLETED)}get prepareSchema(){return t.objectType({amount:t.amountSchema,recipient:B.recipientSchema})}}function ut(n){const s=new t.CapabilityRegistry(n.modules,n).require("starknet");return{env:n.env,partner:new t.PartnerConfiguration(n.partner),getProvider:async r=>{const i=t.getProviderGetter(n.providers,r);if(i)return i()},starknet:s}}class A{constructor(e){a(this,"_ctx",null);this.config=e}get ctx(){return this._ctx||(this._ctx=ut(this.config)),this._ctx}unstake(e){return new ot(this.ctx,e)}}function ct(n){return new A(n)}const M={routes:[{sourceChains:[t.Chain.SUI_MAINNET],destChain:t.Chain.BITCOIN_MAINNET,envs:[o.r.prod]},{sourceChains:[t.Chain.SUI_TESTNET],destChain:t.Chain.BITCOIN_SIGNET,envs:[o.r.testnet,o.r.stage,o.r.dev,o.r.ibc]}],recipientSchema:t.bitcoinAddressSchema};function ht(n,e){return M.routes.some(s=>s.sourceChains.includes(n)&&s.envs.includes(e))}function dt(n){switch(n){case t.Chain.SUI_MAINNET:return"sui:mainnet";case t.Chain.SUI_TESTNET:return"sui:testnet";default:return"sui:testnet"}}class gt extends t.BaseAction{constructor(s,r){super(t.NonEvmOperationStatus.IDLE);a(this,"_amount");a(this,"_recipient");a(this,"_txHash");a(this,"env");if(this.ctx=s,this.params=r,this.env=s.env,!ht(r.sourceChain,this.env))throw t.LombardError.routeNotFound({assetOut:r.assetOut,sourceChain:r.sourceChain,destChain:r.destChain,env:this.env})}get amount(){return this._amount}get recipient(){return this._recipient}get txHash(){return this._txHash}async prepare(s){return this.assertStatus(t.NonEvmOperationStatus.IDLE,"prepare"),this.act(async()=>{const r=t.validatePrepareParams(this.prepareSchema,s,{destChain:this.params.destChain});this._amount=r.amount,this._recipient=r.recipient,this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.IDLE,releasing:t.StepStatus.IDLE}})},t.NonEvmOperationStatus.READY)}async execute(){return this.assertStatus(t.NonEvmOperationStatus.READY,"execute"),this.act(async()=>{const s=this._amount,r=this._recipient;if(!s||!r)throw t.LombardError.missingParameter("amount or recipient");this.emitProgress({status:t.NonEvmOperationStatus.READY,steps:{burning:t.StepStatus.PENDING,releasing:t.StepStatus.IDLE}});const i=dt(this.params.sourceChain),{txHash:u}=await this.ctx.sui.unstake({amount:s,btcAddress:r,chainId:i,env:this.env});return this._txHash=u,this.emitProgress({status:t.NonEvmOperationStatus.COMPLETED,steps:{burning:t.StepStatus.COMPLETE,releasing:t.StepStatus.PENDING}}),this.emitCompleted(),{txHash:u}},t.NonEvmOperationStatus.COMPLETED)}get prepareSchema(){return t.objectType({amount:t.amountSchema,recipient:M.recipientSchema})}}function pt(n){const s=new t.CapabilityRegistry(n.modules,n).require("sui");return{env:n.env,partner:new t.PartnerConfiguration(n.partner),getProvider:async r=>{const i=t.getProviderGetter(n.providers,r);if(i)return i()},sui:s}}class f{constructor(e){a(this,"_ctx",null);this.config=e}get ctx(){return this._ctx||(this._ctx=pt(this.config)),this._ctx}unstake(e){return new gt(this.ctx,e)}}function St(n){return new f(n)}class mt{constructor(e=o.p,s){a(this,"catalog");this.env=e,this.catalog=s??t.ASSET_CATALOG}getAddress(e,s){return t.getAssetAddress(e,this.env,s,this.catalog)}getDecimals(e){return t.getAssetDecimals(e,this.catalog)}getMetadata(e){return t.getAssetMetadata(e,this.catalog)}usesAssetRouter(e,s){return t.usesAssetRouter(e,this.env,s,this.catalog)}getAssetRouter(e,s){return t.getAssetRouter(e,this.env,s,this.catalog)}getBridgeAdapter(e,s){return t.getBridgeAdapter(e,this.env,s,this.catalog)}getPublicMarketMaker(e,s){return t.getPublicMarketMaker(e,this.env,s,this.catalog)}getByAddress(e,s){return t.getAssetByAddress(e,this.env,s,this.catalog)}isDeployed(e,s){return t.isAssetDeployed(e,this.env,s,this.catalog)}getChains(e){return t.getAssetChains(e,this.env,this.catalog)}getEnvironments(e,s){return t.getAssetEnvironments(e,s,this.catalog)}getSupportedAssets(){return t.getSupportedAssets(this.catalog)}getCatalog(){return this.catalog}}class R{constructor(e){a(this,"config");a(this,"env");a(this,"partnerConfig");a(this,"providerCache",new Map);a(this,"chain");a(this,"assets");a(this,"api");a(this,"referrals");a(this,"capabilities");this.config=e,this.env=e.env,this.partnerConfig=new t.PartnerConfiguration(e.partner),this.capabilities=new t.CapabilityRegistry(this.config.modules,this.config),this.chain={btc:new b.BtcActions(this.config),evm:new D.EvmActions(this.config),solana:new C(this.config),sui:new f(this.config),starknet:new A(this.config)},this.referrals=new S.ReferralsClient(this),this.assets=new mt(this.env),this.api=new _(this.env)}async getProvider(e){const s=e;if(this.providerCache.has(s))return this.providerCache.get(s);const r=t.getProviderGetter(this.config.providers,e);if(!r)throw t.LombardError.providerMissing(e,e);const i=await r();if(!i)throw new t.LombardError(t.ProviderErrorCode.PROVIDER_INITIALIZATION_FAILED,`Failed to initialize ${e} provider`);return this.providerCache.set(s,i),i}configure(e){this.partnerConfig.update(e)}registerAsset(e){throw new Error("Not implemented yet")}getPartnerConfig(){return this.partnerConfig}getPartnerId(){return this.partnerConfig.getPartnerId()}}const l=new Map;function lt(n){return l.has(n)||l.set(n,Promise.resolve(t.ASSET_CATALOG)),l.get(n)}async function vt(n){const e="modules"in n&&Array.isArray(n.modules)?n:P(n),s=await lt(e.env),r={...e,catalog:s};return new R(r)}function Et(n){return typeof n=="object"&&n!==null&&"request"in n&&typeof n.request=="function"}function Ct(n){return typeof n=="object"&&n!==null&&"getAddresses"in n&&typeof n.getAddresses=="function"}function At(n){return typeof n=="object"&&n!==null&&"publicKey"in n&&"signAndSendTransaction"in n}function ft(n){return typeof n=="object"&&n!==null&&"getAddress"in n&&"signAndExecuteTransactionBlock"in n}function It(n){return typeof n=="object"&&n!==null&&"address"in n&&"execute"in n}const Nt={Progress:"progress",StatusChange:"status-change",Completed:"completed",Failed:"failed",Error:"error"},Ot={Progress:"progress",StatusChange:"status-change",Completed:"completed",Failed:"failed",Error:"error"},bt={Progress:"progress",StatusChange:"status-change",Completed:"completed",Failed:"failed",Error:"error"},Dt={Progress:"progress",StatusChange:"status-change",Completed:"completed",Failed:"failed",Error:"error"},Tt={Progress:"progress",StatusChange:"status-change",Completed:"completed",Failed:"failed",Error:"error"},_t={Progress:"progress",StatusChange:"status-change",Completed:"completed",Failed:"failed",Error:"error"};exports.ApiNamespace=_;exports.BridgeEvent=_t;exports.DeployEvent=Tt;exports.DepositEvent=Ot;exports.LombardSDK=R;exports.RedeemEvent=bt;exports.SolanaActions=C;exports.StakeEvent=Nt;exports.StarknetActions=A;exports.SuiActions=f;exports.UnstakeEvent=Dt;exports.createConfig=P;exports.createConsoleLogger=T;exports.createLombardSDK=vt;exports.createSilentLogger=q;exports.getSdkHeaders=U;exports.isBtcProvider=Ct;exports.isEvmProvider=Et;exports.isSolanaProvider=At;exports.isStarknetProvider=It;exports.isSuiProvider=ft;exports.solanaActions=it;exports.starknetActions=ct;exports.suiActions=St;
2
+ //# sourceMappingURL=events-CnxJdwys.cjs.map