@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.
- package/CHANGELOG.md +12 -0
- package/dist/api-functions/storeNetworkFeeSignature/storeNetworkFeeSignature.d.ts +13 -0
- package/dist/api-functions/storeNetworkFeeSignature/storeNetworkFeeSignature.d.ts.map +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.js +12 -11
- package/dist/api.js.map +1 -1
- package/dist/btc.cjs +1 -1
- package/dist/btc.js +2 -2
- package/dist/chains/btc/actions/stake/config/evm.d.ts.map +1 -1
- package/dist/chunks/{BtcActions-BE75KQhS.js → BtcActions-D7HekjRg.js} +235 -216
- package/dist/chunks/{BtcActions-BE75KQhS.js.map → BtcActions-D7HekjRg.js.map} +1 -1
- package/dist/chunks/BtcActions-lp4P72ln.cjs +2 -0
- package/dist/chunks/{BtcActions-hLkixDlL.cjs.map → BtcActions-lp4P72ln.cjs.map} +1 -1
- package/dist/chunks/EvmActions-CynfSVFq.cjs +7 -0
- package/dist/chunks/{EvmActions-DIkhiG2i.cjs.map → EvmActions-CynfSVFq.cjs.map} +1 -1
- package/dist/chunks/{EvmActions-DCy8q_l4.js → EvmActions-nbR8cSa4.js} +37 -36
- package/dist/chunks/{EvmActions-DCy8q_l4.js.map → EvmActions-nbR8cSa4.js.map} +1 -1
- package/dist/chunks/depositStatus-DUXMloTa.cjs +2 -0
- package/dist/chunks/{depositStatus-CeoqUgM5.cjs.map → depositStatus-DUXMloTa.cjs.map} +1 -1
- package/dist/chunks/{depositStatus-CacTFWfJ.js → depositStatus-hmXphYhu.js} +2 -2
- package/dist/chunks/{depositStatus-CacTFWfJ.js.map → depositStatus-hmXphYhu.js.map} +1 -1
- package/dist/chunks/{events-Cu4qfdgE.js → events-BP_Ahnsm.js} +42 -41
- package/dist/chunks/{events-Cu4qfdgE.js.map → events-BP_Ahnsm.js.map} +1 -1
- package/dist/chunks/events-DY2qn8Q0.cjs +2 -0
- package/dist/chunks/{events-C3tg6XPm.cjs.map → events-DY2qn8Q0.cjs.map} +1 -1
- package/dist/chunks/getNetworkFeeSignature-DqKLslZc.cjs +2 -0
- package/dist/chunks/getNetworkFeeSignature-DqKLslZc.cjs.map +1 -0
- package/dist/chunks/getNetworkFeeSignature-FuDJWrMC.js +38 -0
- package/dist/chunks/getNetworkFeeSignature-FuDJWrMC.js.map +1 -0
- package/dist/chunks/statusConstants-D4DN05kK.cjs +2 -0
- package/dist/chunks/{statusConstants-BPtrxbYC.cjs.map → statusConstants-D4DN05kK.cjs.map} +1 -1
- package/dist/chunks/{statusConstants-8pqtLXvX.js → statusConstants-DLrd03gT.js} +3 -3
- package/dist/chunks/{statusConstants-8pqtLXvX.js.map → statusConstants-DLrd03gT.js.map} +1 -1
- package/dist/chunks/storeNetworkFeeSignature-BaG3AU8U.cjs +2 -0
- package/dist/chunks/storeNetworkFeeSignature-BaG3AU8U.cjs.map +1 -0
- package/dist/chunks/storeNetworkFeeSignature-sCt4_nHr.js +52 -0
- package/dist/chunks/storeNetworkFeeSignature-sCt4_nHr.js.map +1 -0
- package/dist/common/chains.d.ts +3 -0
- package/dist/common/chains.d.ts.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +4 -4
- 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 +264 -263
- package/package.json +1 -1
- package/dist/chunks/BtcActions-hLkixDlL.cjs +0 -2
- package/dist/chunks/EvmActions-DIkhiG2i.cjs +0 -7
- package/dist/chunks/constants-D1FnS2Z8.js +0 -6
- package/dist/chunks/constants-D1FnS2Z8.js.map +0 -1
- package/dist/chunks/constants-ueShGH9R.cjs +0 -2
- package/dist/chunks/constants-ueShGH9R.cjs.map +0 -1
- package/dist/chunks/depositStatus-CeoqUgM5.cjs +0 -2
- package/dist/chunks/events-C3tg6XPm.cjs +0 -2
- package/dist/chunks/statusConstants-BPtrxbYC.cjs +0 -2
- package/dist/chunks/storeNetworkFeeSignature-Z0NcQyIn.cjs +0 -2
- package/dist/chunks/storeNetworkFeeSignature-Z0NcQyIn.cjs.map +0 -1
- package/dist/chunks/storeNetworkFeeSignature-ZdHcFmfP.js +0 -65
- package/dist/chunks/storeNetworkFeeSignature-ZdHcFmfP.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const S=require("axios"),_=require("bignumber.js"),p=require("./api-config-DkXqqfCK.cjs"),g=require("./blockchain-identifier-DWfC3Es2.cjs"),I=require("./token-addresses-C7H9E4qz.cjs"),T=require("./storeNetworkFeeSignature-BaG3AU8U.cjs"),N=require("./satoshi-CZEsHl5X.cjs"),E=require("./tokens-C5rzCTTM.cjs"),s=require("./ReferralsClient-B65Nsk21.cjs");async function C({env:e,chainId:t=I.ChainId.ethereum,amount:i=N.toSatoshi(1)}){const{baseApiUrl:r}=p.getApiConfig(e),n=g.getChainNameById(t),{data:o}=await S.get(`api/v1/exchange/rate/${n}`,{baseURL:r,params:{amount:i}}),u=_(o.amount_out).toNumber(),c=_(i).dividedBy(o.amount_out).toNumber(),a=N.toSatoshi(T.MIN_STAKE_AMOUNT_BTC).toNumber();return{amountOut:u,exchangeRate:c,minAmount:a}}const b="api/v1/referral-system/referrer/";async function O({address:e,signature:t,eip712Data:i,referrerCode:r,pubKey:n,env:o}){const{baseApiUrl:u}=p.getApiConfig(o),c={referrer_code:r,signature:t,signature_typed_data:i,...n&&{public_key:n}};try{await S.post(`${b}${e}`,c,{baseURL:u});return}catch(a){const m=E.getErrorMessage(a);throw new Error(m)}}const f=6,R=T.MIN_STAKE_AMOUNT_BTC;function d(e,t){return!t||!e?0:Math.max(0,e-t+1)}function y(e,t,i=f){if(e===void 0||t===void 0)return null;const r=d(e,t),n=Math.min(100,Math.round(r/i*100));return{current:r,required:i,percentage:n,isComplete:r>=i}}function l(e,t,i=f){var a,m;if(e.sanctioned)return"restricted";if(e.isClaimed||e.claimTxHash)return"claimed";if(e.notarizationStatus===s.ENotarizationStatus.NOTARIZATION_STATUS_GMP_HANDLED)return"auto_claimed";const r=((m=(a=e.amount)==null?void 0:a.toNumber)==null?void 0:m.call(a))??Number(e.amount);if(r>0&&r<T.MIN_STAKE_AMOUNT_BTC)return"too_small";if(e.notarizationStatus===s.ENotarizationStatus.NOTARIZATION_STATUS_FAILED)return"failed";if(e.sessionState===s.ESessionState.SESSION_STATE_EXPIRED)return"expired";const n=!!e.proof&&!!e.rawPayload,o=e.notarizationStatus,u=d(t,e.blockHeight),c=t===void 0||u>=i;switch(o){case s.ENotarizationStatus.NOTARIZATION_STATUS_PENDING:case s.ENotarizationStatus.NOTARIZATION_STATUS_GMP_PENDING:case s.ENotarizationStatus.NOTARIZATION_STATUS_SUBMITTED:return t!==void 0&&!c?"pending_confirmations":"pending_notarization";case s.ENotarizationStatus.NOTARIZATION_STATUS_SESSION_APPROVED:return n?"claimable":"pending_notarization";case s.ENotarizationStatus.NOTARIZATION_STATUS_UNSPECIFIED:default:return t!==void 0&&!c?"pending_confirmations":"pending_notarization"}}function A(e){switch(e){case"pending_confirmations":return{label:"Pending Confirmations",severity:"warning",description:`Waiting for Bitcoin block confirmations (${f} required)`,isTerminal:!1,requiresAction:!1};case"pending_notarization":return{label:"Pending Notarization",severity:"info",description:"Confirmations complete, waiting for notarization service to generate proof",isTerminal:!1,requiresAction:!1};case"claimable":return{label:"Claimable",severity:"success",description:"Ready to mint - proof available, claim to receive tokens",isTerminal:!1,requiresAction:!0};case"claiming":return{label:"Claiming",severity:"info",description:"Claim transaction in progress",isTerminal:!1,requiresAction:!1};case"claimed":return{label:"Claimed",severity:"neutral",description:"Tokens have been minted to your address",isTerminal:!0,requiresAction:!1};case"auto_claimed":return{label:"Auto-Claimed",severity:"success",description:"Automatically claimed via cross-chain messaging (GMP)",isTerminal:!0,requiresAction:!1};case"expired":return{label:"Expired",severity:"error",description:"Fee signature expired, requires re-authorization",isTerminal:!1,requiresAction:!0};case"failed":return{label:"Failed",severity:"error",description:"Notarization failed - contact support",isTerminal:!0,requiresAction:!1};case"restricted":return{label:"Restricted",severity:"error",description:"This deposit is restricted or sanctioned",isTerminal:!0,requiresAction:!1};case"too_small":return{label:"Too Small",severity:"neutral",description:`Amount below minimum claimable amount (${T.MIN_STAKE_AMOUNT_BTC} BTC)`,isTerminal:!0,requiresAction:!1}}}function M(e,t){return l(e,t)==="claimable"}function q(e,t){const i=l(e,t);return i==="pending_confirmations"||i==="pending_notarization"}function v(e,t){const i=l(e,t);return A(i).isTerminal}function D(e,t){const i=l(e,t);return A(i).requiresAction}exports.MIN_CLAIM_AMOUNT_BTC=R;exports.REQUIRED_CONFIRMATIONS=f;exports.calcConfirmations=d;exports.depositRequiresAction=D;exports.getConfirmationProgress=y;exports.getDepositStatus=l;exports.getDepositStatusDisplay=A;exports.getLBTCExchangeRate=C;exports.isDepositClaimable=M;exports.isDepositPending=q;exports.isDepositTerminal=v;exports.setReferral=O;
|
|
2
|
+
//# sourceMappingURL=depositStatus-DUXMloTa.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depositStatus-CeoqUgM5.cjs","sources":["../../src/api-functions/getLBTCExchangeRate/getLBTCExchangeRate.ts","../../src/api-functions/setReferral/setReferral.ts","../../src/shared/deposits/depositStatus.ts"],"sourcesContent":["import axios from 'axios';\nimport BigNumber from 'bignumber.js';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { getChainNameById } from '../../common/blockchain-identifier';\nimport { ChainId } from '../../common/chains';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\nimport { IEnvParam } from '../../common/parameters';\nimport { toSatoshi } from '../../utils/satoshi';\n\ntype ExchangeRateResponse = {\n amount_out: string;\n};\n\nexport interface IgetLBTCExchangeRateParams extends IEnvParam {\n /**\n * The optional chain id of the asset to get the exchange rate for.\n * Note: Exchange rate it the same for all chains.\n *\n * @default OChainId.ethereum\n */\n chainId?: ChainId;\n /**\n * The amount of the LBTC (in satoshis) that a user would like to exchange to BTC.\n */\n amount?: BigNumber.Value;\n}\n\nexport interface IgetLBTCExchangeRateResponse {\n /**\n * The exchanged amount (in satoshis).\n */\n amountOut: number;\n /**\n * The exchange rate for LBTC/BTC.\n */\n exchangeRate: number;\n /**\n * The minimum amount of BTC eligible for staking (in satoshis).\n */\n minAmount: number;\n}\n\n/**\n * Retrieves the exchange rate for LBTC.\n *\n * @deprecated This API endpoint is deprecated and will be removed in a future version.\n * The exchange rate is now always 1:1 as LBTC is a rebasing token.\n *\n * @param {IgetLBTCExchangeRateParams} parameters - The parameters.\n * @param {BigNumber.Value} parameters.amount - The optional amount to be exchanged.\n * @param {ChainId} parameters.chainId - The optional chain id.\n * @param {Env} parameters.env - The optional environment identifier.\n *\n * @returns {Promise<IgetLBTCExchangeRateResponse>} - The exchange rate.\n */\nexport async function getLBTCExchangeRate({\n env,\n chainId = ChainId.ethereum,\n amount = toSatoshi(1),\n}: IgetLBTCExchangeRateParams): Promise<IgetLBTCExchangeRateResponse> {\n const { baseApiUrl } = getApiConfig(env);\n const chainIdName = getChainNameById(chainId);\n\n const { data } = await axios.get<ExchangeRateResponse>(\n `api/v1/exchange/rate/${chainIdName}`,\n { baseURL: baseApiUrl, params: { amount } },\n );\n\n const amountOut = BigNumber(data.amount_out).toNumber();\n const exchangeRate = BigNumber(amount).dividedBy(data.amount_out).toNumber();\n const minAmount = toSatoshi(MIN_STAKE_AMOUNT_BTC).toNumber();\n\n return { amountOut, exchangeRate, minAmount };\n}\n","import axios from 'axios';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { IEnvParam } from '../../common/parameters';\nimport { getErrorMessage } from '../../utils/err';\n\nconst URL = 'api/v1/referral-system/referrer/';\n\nexport interface ISetReferralParams extends IEnvParam {\n /**\n * The destination EVM user address where LBTC will be claimed.\n */\n address: string;\n /**\n * The signature of the address. The signature is generated by signing the address using wallet.\n * Use `signTermsOfService` or `signLbtcDestinationAddr` functions.\n */\n signature: string;\n /**\n * The captcha token.\n */\n referrerCode: string;\n /**\n * The typed data object used to generate the signature if using a network fee authorization signature.\n */\n eip712Data?: string;\n /**\n * The public key (required for Starknet).\n */\n pubKey?: string;\n}\n\n/**\n * Set a referral code.\n *\n * @param {ISetReferralParams} The parameters for set referral.\n * @returns {Promise<void>} Nothing.\n * @exception {Error}\n */\nexport async function setReferral({\n address,\n signature,\n eip712Data,\n referrerCode,\n pubKey,\n env,\n}: ISetReferralParams): Promise<void> {\n const { baseApiUrl } = getApiConfig(env);\n\n const requestParams = {\n referrer_code: referrerCode,\n signature,\n signature_typed_data: eip712Data,\n ...(pubKey && { public_key: pubKey }),\n };\n\n try {\n await axios.post(`${URL}${address}`, requestParams, {\n baseURL: baseApiUrl,\n });\n\n return undefined;\n } catch (error) {\n const errorMsg = getErrorMessage(error);\n throw new Error(errorMsg);\n }\n}\n","/**\n * Deposit Status Utilities\n *\n * Centralized logic for determining deposit status based on notarization state,\n * confirmations, and other factors. This module provides a single source of truth\n * for deposit status that can be used by the SDK demo, apps/main, and other consumers.\n *\n * Status determination is based on both notarization status and block confirmations.\n * The notarization status from the backend is the primary source of truth for where\n * in the flow a deposit currently is.\n *\n * @module shared/deposits/depositStatus\n */\n\nimport {\n type Deposit,\n ENotarizationStatus,\n ESessionState,\n} from '../../api-functions/getDepositsByAddress/getDepositsByAddress';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Constants\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Number of confirmations required before a deposit can be claimed.\n * Production/Testnet: 6, Stage/Dev: 3\n */\nexport const REQUIRED_CONFIRMATIONS = 6;\n\n/**\n * Minimum deposit amount that can be claimed (in BTC).\n * Deposits below this amount cannot be minted.\n *\n * @deprecated Use `MIN_STAKE_AMOUNT_BTC` from `@lombard.finance/sdk` instead.\n * This constant is an alias kept for backwards compatibility.\n */\nexport const MIN_CLAIM_AMOUNT_BTC = MIN_STAKE_AMOUNT_BTC;\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Types\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Possible deposit statuses - ordered by lifecycle\n */\nexport type DepositStatus =\n | 'pending_confirmations' // Waiting for BTC block confirmations\n | 'pending_notarization' // Confirmations complete, waiting for notarization service\n | 'claimable' // Notarization approved, ready to be claimed manually\n | 'claiming' // Claim transaction submitted\n | 'claimed' // Successfully claimed (has claimTxHash)\n | 'auto_claimed' // Claimed via GMP (cross-chain messaging)\n | 'expired' // Signature expired, needs re-auth\n | 'failed' // Notarization failed\n | 'restricted' // Sanctioned or restricted\n | 'too_small'; // Amount below minimum\n\n/**\n * Status severity for UI styling\n */\nexport type StatusSeverity =\n | 'info'\n | 'warning'\n | 'success'\n | 'error'\n | 'neutral';\n\n/**\n * Status display configuration\n */\nexport interface DepositStatusDisplay {\n /** Human-readable label for the status */\n label: string;\n /** Severity level for styling */\n severity: StatusSeverity;\n /** Detailed description of the status */\n description: string;\n /** Whether the deposit is in a terminal state (claimed, failed, restricted) */\n isTerminal: boolean;\n /** Whether user action is required */\n requiresAction: boolean;\n}\n\n/**\n * Confirmation progress information\n */\nexport interface ConfirmationProgress {\n /** Current number of confirmations */\n current: number;\n /** Required number of confirmations */\n required: number;\n /** Percentage complete (0-100) */\n percentage: number;\n /** Whether enough confirmations have been received */\n isComplete: boolean;\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Core Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Calculate the number of confirmations for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @returns Number of confirmations (0 if either height is missing)\n */\nexport function calcConfirmations(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n): number {\n if (!depositBlockHeight || !currentBlockHeight) {\n return 0;\n }\n // Deposit block height counts as the first confirmation\n return Math.max(0, currentBlockHeight - depositBlockHeight + 1);\n}\n\n/**\n * Get confirmation progress for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @param requiredConfirmations - Number of confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns Confirmation progress info, or null if block heights unavailable\n */\nexport function getConfirmationProgress(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): ConfirmationProgress | null {\n if (currentBlockHeight === undefined || depositBlockHeight === undefined) {\n return null;\n }\n\n const current = calcConfirmations(currentBlockHeight, depositBlockHeight);\n const percentage = Math.min(\n 100,\n Math.round((current / requiredConfirmations) * 100),\n );\n\n return {\n current,\n required: requiredConfirmations,\n percentage,\n isComplete: current >= requiredConfirmations,\n };\n}\n\n/**\n * Determine the status of a deposit\n *\n * Logic priority:\n * 1. Sanctioned → restricted\n * 2. Already claimed → claimed\n * 3. GMP handled → auto_claimed (definitive success, overrides expired/failed)\n * 4. Amount too small → too_small (permanent, re-auth won't help)\n * 5. Notarization failed → failed (terminal, overrides expired)\n * 6. Session expired → expired (recoverable via re-auth)\n * 7. Based on notarization status + proof availability:\n * - PENDING/SUBMITTED without enough confirmations → pending_confirmations\n * - PENDING/SUBMITTED with confirmations → pending_notarization\n * - SESSION_APPROVED with proof → claimable\n * - SESSION_APPROVED without proof → pending_notarization (edge case)\n *\n * @param deposit - The deposit object from the SDK\n * @param currentBlockHeight - Current BTC block height (optional, enhances accuracy)\n * @param requiredConfirmations - Confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns The deposit status\n */\nexport function getDepositStatus(\n deposit: Deposit,\n currentBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): DepositStatus {\n // 1. Check for sanctioned/restricted first\n if (deposit.sanctioned) {\n return 'restricted';\n }\n\n // 2. Check if already claimed\n if (deposit.isClaimed || deposit.claimTxHash) {\n return 'claimed';\n }\n\n // 3. Check for GMP auto-claim (definitive success, overrides expired/failed)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_GMP_HANDLED\n ) {\n return 'auto_claimed';\n }\n\n // 4. Check if amount is too small (permanent, re-auth won't help)\n const amountBtc = deposit.amount?.toNumber?.() ?? Number(deposit.amount);\n if (amountBtc > 0 && amountBtc < MIN_STAKE_AMOUNT_BTC) {\n return 'too_small';\n }\n\n // 5. Check for notarization failure (terminal, overrides expired)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_FAILED\n ) {\n return 'failed';\n }\n\n // 6. Check if the notarization session has expired (recoverable via re-auth)\n if (deposit.sessionState === ESessionState.SESSION_STATE_EXPIRED) {\n return 'expired';\n }\n\n // 7. Determine status based on notarization status and proof availability\n const hasProof = !!deposit.proof && !!deposit.rawPayload;\n const notarizationStatus = deposit.notarizationStatus;\n\n // Check confirmations only if we have block height data\n const confirmations = calcConfirmations(\n currentBlockHeight,\n deposit.blockHeight,\n );\n const hasEnoughConfirmations =\n currentBlockHeight === undefined || confirmations >= requiredConfirmations;\n\n switch (notarizationStatus) {\n case ENotarizationStatus.NOTARIZATION_STATUS_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_GMP_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_SUBMITTED:\n // Still in notarization queue\n // If we know block height and not enough confirmations, show that\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n // Otherwise, we're waiting for notarization\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_SESSION_APPROVED:\n // Notarization approved\n if (hasProof) {\n return 'claimable';\n }\n // Edge case: approved but no proof yet (should be rare)\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_UNSPECIFIED:\n default:\n // Unknown status - check confirmations if we can\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n return 'pending_notarization';\n }\n}\n\n/**\n * Get display configuration for a deposit status\n *\n * @param status - The deposit status\n * @returns Display configuration with label, severity, and description\n */\nexport function getDepositStatusDisplay(\n status: DepositStatus,\n): DepositStatusDisplay {\n switch (status) {\n case 'pending_confirmations':\n return {\n label: 'Pending Confirmations',\n severity: 'warning',\n description: `Waiting for Bitcoin block confirmations (${REQUIRED_CONFIRMATIONS} required)`,\n isTerminal: false,\n requiresAction: false,\n };\n case 'pending_notarization':\n return {\n label: 'Pending Notarization',\n severity: 'info',\n description:\n 'Confirmations complete, waiting for notarization service to generate proof',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimable':\n return {\n label: 'Claimable',\n severity: 'success',\n description: 'Ready to mint - proof available, claim to receive tokens',\n isTerminal: false,\n requiresAction: true,\n };\n case 'claiming':\n return {\n label: 'Claiming',\n severity: 'info',\n description: 'Claim transaction in progress',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimed':\n return {\n label: 'Claimed',\n severity: 'neutral',\n description: 'Tokens have been minted to your address',\n isTerminal: true,\n requiresAction: false,\n };\n case 'auto_claimed':\n return {\n label: 'Auto-Claimed',\n severity: 'success',\n description: 'Automatically claimed via cross-chain messaging (GMP)',\n isTerminal: true,\n requiresAction: false,\n };\n case 'expired':\n return {\n label: 'Expired',\n severity: 'error',\n description: 'Fee signature expired, requires re-authorization',\n isTerminal: false,\n requiresAction: true,\n };\n case 'failed':\n return {\n label: 'Failed',\n severity: 'error',\n description: 'Notarization failed - contact support',\n isTerminal: true,\n requiresAction: false,\n };\n case 'restricted':\n return {\n label: 'Restricted',\n severity: 'error',\n description: 'This deposit is restricted or sanctioned',\n isTerminal: true,\n requiresAction: false,\n };\n case 'too_small':\n return {\n label: 'Too Small',\n severity: 'neutral',\n description: `Amount below minimum claimable amount (${MIN_STAKE_AMOUNT_BTC} BTC)`,\n isTerminal: true,\n requiresAction: false,\n };\n }\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Helper Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Check if a deposit can be claimed manually\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if the deposit is in claimable state\n */\nexport function isDepositClaimable(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n return getDepositStatus(deposit, currentBlockHeight) === 'claimable';\n}\n\n/**\n * Check if a deposit is in a pending state (confirmations or notarization)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is pending\n */\nexport function isDepositPending(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n return (\n status === 'pending_confirmations' || status === 'pending_notarization'\n );\n}\n\n/**\n * Check if a deposit is in a terminal state (no further action possible)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is in terminal state\n */\nexport function isDepositTerminal(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.isTerminal;\n}\n\n/**\n * Check if a deposit requires user action\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if user action is required\n */\nexport function depositRequiresAction(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.requiresAction;\n}\n"],"names":["getLBTCExchangeRate","env","chainId","ChainId","amount","toSatoshi","baseApiUrl","getApiConfig","chainIdName","getChainNameById","data","axios","amountOut","BigNumber","exchangeRate","minAmount","MIN_STAKE_AMOUNT_BTC","URL","setReferral","address","signature","eip712Data","referrerCode","pubKey","requestParams","error","errorMsg","getErrorMessage","REQUIRED_CONFIRMATIONS","MIN_CLAIM_AMOUNT_BTC","calcConfirmations","currentBlockHeight","depositBlockHeight","getConfirmationProgress","requiredConfirmations","current","percentage","getDepositStatus","deposit","ENotarizationStatus","amountBtc","_b","_a","ESessionState","hasProof","notarizationStatus","confirmations","hasEnoughConfirmations","getDepositStatusDisplay","status","isDepositClaimable","isDepositPending","isDepositTerminal","depositRequiresAction"],"mappings":"8VAwDA,eAAsBA,EAAoB,CACxC,IAAAC,EACA,QAAAC,EAAUC,EAAAA,QAAQ,SAClB,OAAAC,EAASC,EAAAA,UAAU,CAAC,CACtB,EAAsE,CACpE,KAAM,CAAE,WAAAC,CAAA,EAAeC,EAAAA,aAAaN,CAAG,EACjCO,EAAcC,EAAAA,iBAAiBP,CAAO,EAEtC,CAAE,KAAAQ,CAAA,EAAS,MAAMC,EAAM,IAC3B,wBAAwBH,CAAW,GACnC,CAAE,QAASF,EAAY,OAAQ,CAAE,OAAAF,EAAO,CAAE,EAGtCQ,EAAYC,EAAUH,EAAK,UAAU,EAAE,SAAA,EACvCI,EAAeD,EAAUT,CAAM,EAAE,UAAUM,EAAK,UAAU,EAAE,SAAA,EAC5DK,EAAYV,EAAAA,UAAUW,EAAAA,oBAAoB,EAAE,SAAA,EAElD,MAAO,CAAE,UAAAJ,EAAW,aAAAE,EAAc,UAAAC,CAAA,CACpC,CCpEA,MAAME,EAAM,mCAiCZ,eAAsBC,EAAY,CAChC,QAAAC,EACA,UAAAC,EACA,WAAAC,EACA,aAAAC,EACA,OAAAC,EACA,IAAAtB,CACF,EAAsC,CACpC,KAAM,CAAE,WAAAK,CAAA,EAAeC,EAAAA,aAAaN,CAAG,EAEjCuB,EAAgB,CACpB,cAAeF,EACf,UAAAF,EACA,qBAAsBC,EACtB,GAAIE,GAAU,CAAE,WAAYA,CAAA,CAAO,EAGrC,GAAI,CACF,MAAMZ,EAAM,KAAK,GAAGM,CAAG,GAAGE,CAAO,GAAIK,EAAe,CAClD,QAASlB,CAAA,CACV,EAED,MACF,OAASmB,EAAO,CACd,MAAMC,EAAWC,EAAAA,gBAAgBF,CAAK,EACtC,MAAM,IAAI,MAAMC,CAAQ,CAC1B,CACF,CCrCO,MAAME,EAAyB,EASzBC,EAAuBb,EAAAA,qBAwE7B,SAASc,EACdC,EACA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3D,OACEkB,IAAW,yBAA2BA,IAAW,sBAErD,CASO,SAASG,EACdd,EACAP,EACS,CACT,MAAMkB,EAASZ,EAAiBC,EAASP,CAAkB,EAE3D,OADgBiB,EAAwBC,CAAM,EAC/B,UACjB,CASO,SAASI,EACdf,EACAP,EACS,CACT,MAAMkB,EAASZ,EAAiBC,EAASP,CAAkB,EAE3D,OADgBiB,EAAwBC,CAAM,EAC/B,cACjB"}
|
|
1
|
+
{"version":3,"file":"depositStatus-DUXMloTa.cjs","sources":["../../src/api-functions/getLBTCExchangeRate/getLBTCExchangeRate.ts","../../src/api-functions/setReferral/setReferral.ts","../../src/shared/deposits/depositStatus.ts"],"sourcesContent":["import axios from 'axios';\nimport BigNumber from 'bignumber.js';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { getChainNameById } from '../../common/blockchain-identifier';\nimport { ChainId } from '../../common/chains';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\nimport { IEnvParam } from '../../common/parameters';\nimport { toSatoshi } from '../../utils/satoshi';\n\ntype ExchangeRateResponse = {\n amount_out: string;\n};\n\nexport interface IgetLBTCExchangeRateParams extends IEnvParam {\n /**\n * The optional chain id of the asset to get the exchange rate for.\n * Note: Exchange rate it the same for all chains.\n *\n * @default OChainId.ethereum\n */\n chainId?: ChainId;\n /**\n * The amount of the LBTC (in satoshis) that a user would like to exchange to BTC.\n */\n amount?: BigNumber.Value;\n}\n\nexport interface IgetLBTCExchangeRateResponse {\n /**\n * The exchanged amount (in satoshis).\n */\n amountOut: number;\n /**\n * The exchange rate for LBTC/BTC.\n */\n exchangeRate: number;\n /**\n * The minimum amount of BTC eligible for staking (in satoshis).\n */\n minAmount: number;\n}\n\n/**\n * Retrieves the exchange rate for LBTC.\n *\n * @deprecated This API endpoint is deprecated and will be removed in a future version.\n * The exchange rate is now always 1:1 as LBTC is a rebasing token.\n *\n * @param {IgetLBTCExchangeRateParams} parameters - The parameters.\n * @param {BigNumber.Value} parameters.amount - The optional amount to be exchanged.\n * @param {ChainId} parameters.chainId - The optional chain id.\n * @param {Env} parameters.env - The optional environment identifier.\n *\n * @returns {Promise<IgetLBTCExchangeRateResponse>} - The exchange rate.\n */\nexport async function getLBTCExchangeRate({\n env,\n chainId = ChainId.ethereum,\n amount = toSatoshi(1),\n}: IgetLBTCExchangeRateParams): Promise<IgetLBTCExchangeRateResponse> {\n const { baseApiUrl } = getApiConfig(env);\n const chainIdName = getChainNameById(chainId);\n\n const { data } = await axios.get<ExchangeRateResponse>(\n `api/v1/exchange/rate/${chainIdName}`,\n { baseURL: baseApiUrl, params: { amount } },\n );\n\n const amountOut = BigNumber(data.amount_out).toNumber();\n const exchangeRate = BigNumber(amount).dividedBy(data.amount_out).toNumber();\n const minAmount = toSatoshi(MIN_STAKE_AMOUNT_BTC).toNumber();\n\n return { amountOut, exchangeRate, minAmount };\n}\n","import axios from 'axios';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { IEnvParam } from '../../common/parameters';\nimport { getErrorMessage } from '../../utils/err';\n\nconst URL = 'api/v1/referral-system/referrer/';\n\nexport interface ISetReferralParams extends IEnvParam {\n /**\n * The destination EVM user address where LBTC will be claimed.\n */\n address: string;\n /**\n * The signature of the address. The signature is generated by signing the address using wallet.\n * Use `signTermsOfService` or `signLbtcDestinationAddr` functions.\n */\n signature: string;\n /**\n * The captcha token.\n */\n referrerCode: string;\n /**\n * The typed data object used to generate the signature if using a network fee authorization signature.\n */\n eip712Data?: string;\n /**\n * The public key (required for Starknet).\n */\n pubKey?: string;\n}\n\n/**\n * Set a referral code.\n *\n * @param {ISetReferralParams} The parameters for set referral.\n * @returns {Promise<void>} Nothing.\n * @exception {Error}\n */\nexport async function setReferral({\n address,\n signature,\n eip712Data,\n referrerCode,\n pubKey,\n env,\n}: ISetReferralParams): Promise<void> {\n const { baseApiUrl } = getApiConfig(env);\n\n const requestParams = {\n referrer_code: referrerCode,\n signature,\n signature_typed_data: eip712Data,\n ...(pubKey && { public_key: pubKey }),\n };\n\n try {\n await axios.post(`${URL}${address}`, requestParams, {\n baseURL: baseApiUrl,\n });\n\n return undefined;\n } catch (error) {\n const errorMsg = getErrorMessage(error);\n throw new Error(errorMsg);\n }\n}\n","/**\n * Deposit Status Utilities\n *\n * Centralized logic for determining deposit status based on notarization state,\n * confirmations, and other factors. This module provides a single source of truth\n * for deposit status that can be used by the SDK demo, apps/main, and other consumers.\n *\n * Status determination is based on both notarization status and block confirmations.\n * The notarization status from the backend is the primary source of truth for where\n * in the flow a deposit currently is.\n *\n * @module shared/deposits/depositStatus\n */\n\nimport {\n type Deposit,\n ENotarizationStatus,\n ESessionState,\n} from '../../api-functions/getDepositsByAddress/getDepositsByAddress';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Constants\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Number of confirmations required before a deposit can be claimed.\n * Production/Testnet: 6, Stage/Dev: 3\n */\nexport const REQUIRED_CONFIRMATIONS = 6;\n\n/**\n * Minimum deposit amount that can be claimed (in BTC).\n * Deposits below this amount cannot be minted.\n *\n * @deprecated Use `MIN_STAKE_AMOUNT_BTC` from `@lombard.finance/sdk` instead.\n * This constant is an alias kept for backwards compatibility.\n */\nexport const MIN_CLAIM_AMOUNT_BTC = MIN_STAKE_AMOUNT_BTC;\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Types\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Possible deposit statuses - ordered by lifecycle\n */\nexport type DepositStatus =\n | 'pending_confirmations' // Waiting for BTC block confirmations\n | 'pending_notarization' // Confirmations complete, waiting for notarization service\n | 'claimable' // Notarization approved, ready to be claimed manually\n | 'claiming' // Claim transaction submitted\n | 'claimed' // Successfully claimed (has claimTxHash)\n | 'auto_claimed' // Claimed via GMP (cross-chain messaging)\n | 'expired' // Signature expired, needs re-auth\n | 'failed' // Notarization failed\n | 'restricted' // Sanctioned or restricted\n | 'too_small'; // Amount below minimum\n\n/**\n * Status severity for UI styling\n */\nexport type StatusSeverity =\n | 'info'\n | 'warning'\n | 'success'\n | 'error'\n | 'neutral';\n\n/**\n * Status display configuration\n */\nexport interface DepositStatusDisplay {\n /** Human-readable label for the status */\n label: string;\n /** Severity level for styling */\n severity: StatusSeverity;\n /** Detailed description of the status */\n description: string;\n /** Whether the deposit is in a terminal state (claimed, failed, restricted) */\n isTerminal: boolean;\n /** Whether user action is required */\n requiresAction: boolean;\n}\n\n/**\n * Confirmation progress information\n */\nexport interface ConfirmationProgress {\n /** Current number of confirmations */\n current: number;\n /** Required number of confirmations */\n required: number;\n /** Percentage complete (0-100) */\n percentage: number;\n /** Whether enough confirmations have been received */\n isComplete: boolean;\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Core Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Calculate the number of confirmations for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @returns Number of confirmations (0 if either height is missing)\n */\nexport function calcConfirmations(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n): number {\n if (!depositBlockHeight || !currentBlockHeight) {\n return 0;\n }\n // Deposit block height counts as the first confirmation\n return Math.max(0, currentBlockHeight - depositBlockHeight + 1);\n}\n\n/**\n * Get confirmation progress for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @param requiredConfirmations - Number of confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns Confirmation progress info, or null if block heights unavailable\n */\nexport function getConfirmationProgress(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): ConfirmationProgress | null {\n if (currentBlockHeight === undefined || depositBlockHeight === undefined) {\n return null;\n }\n\n const current = calcConfirmations(currentBlockHeight, depositBlockHeight);\n const percentage = Math.min(\n 100,\n Math.round((current / requiredConfirmations) * 100),\n );\n\n return {\n current,\n required: requiredConfirmations,\n percentage,\n isComplete: current >= requiredConfirmations,\n };\n}\n\n/**\n * Determine the status of a deposit\n *\n * Logic priority:\n * 1. Sanctioned → restricted\n * 2. Already claimed → claimed\n * 3. GMP handled → auto_claimed (definitive success, overrides expired/failed)\n * 4. Amount too small → too_small (permanent, re-auth won't help)\n * 5. Notarization failed → failed (terminal, overrides expired)\n * 6. Session expired → expired (recoverable via re-auth)\n * 7. Based on notarization status + proof availability:\n * - PENDING/SUBMITTED without enough confirmations → pending_confirmations\n * - PENDING/SUBMITTED with confirmations → pending_notarization\n * - SESSION_APPROVED with proof → claimable\n * - SESSION_APPROVED without proof → pending_notarization (edge case)\n *\n * @param deposit - The deposit object from the SDK\n * @param currentBlockHeight - Current BTC block height (optional, enhances accuracy)\n * @param requiredConfirmations - Confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns The deposit status\n */\nexport function getDepositStatus(\n deposit: Deposit,\n currentBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): DepositStatus {\n // 1. Check for sanctioned/restricted first\n if (deposit.sanctioned) {\n return 'restricted';\n }\n\n // 2. Check if already claimed\n if (deposit.isClaimed || deposit.claimTxHash) {\n return 'claimed';\n }\n\n // 3. Check for GMP auto-claim (definitive success, overrides expired/failed)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_GMP_HANDLED\n ) {\n return 'auto_claimed';\n }\n\n // 4. Check if amount is too small (permanent, re-auth won't help)\n const amountBtc = deposit.amount?.toNumber?.() ?? Number(deposit.amount);\n if (amountBtc > 0 && amountBtc < MIN_STAKE_AMOUNT_BTC) {\n return 'too_small';\n }\n\n // 5. Check for notarization failure (terminal, overrides expired)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_FAILED\n ) {\n return 'failed';\n }\n\n // 6. Check if the notarization session has expired (recoverable via re-auth)\n if (deposit.sessionState === ESessionState.SESSION_STATE_EXPIRED) {\n return 'expired';\n }\n\n // 7. Determine status based on notarization status and proof availability\n const hasProof = !!deposit.proof && !!deposit.rawPayload;\n const notarizationStatus = deposit.notarizationStatus;\n\n // Check confirmations only if we have block height data\n const confirmations = calcConfirmations(\n currentBlockHeight,\n deposit.blockHeight,\n );\n const hasEnoughConfirmations =\n currentBlockHeight === undefined || confirmations >= requiredConfirmations;\n\n switch (notarizationStatus) {\n case ENotarizationStatus.NOTARIZATION_STATUS_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_GMP_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_SUBMITTED:\n // Still in notarization queue\n // If we know block height and not enough confirmations, show that\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n // Otherwise, we're waiting for notarization\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_SESSION_APPROVED:\n // Notarization approved\n if (hasProof) {\n return 'claimable';\n }\n // Edge case: approved but no proof yet (should be rare)\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_UNSPECIFIED:\n default:\n // Unknown status - check confirmations if we can\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n return 'pending_notarization';\n }\n}\n\n/**\n * Get display configuration for a deposit status\n *\n * @param status - The deposit status\n * @returns Display configuration with label, severity, and description\n */\nexport function getDepositStatusDisplay(\n status: DepositStatus,\n): DepositStatusDisplay {\n switch (status) {\n case 'pending_confirmations':\n return {\n label: 'Pending Confirmations',\n severity: 'warning',\n description: `Waiting for Bitcoin block confirmations (${REQUIRED_CONFIRMATIONS} required)`,\n isTerminal: false,\n requiresAction: false,\n };\n case 'pending_notarization':\n return {\n label: 'Pending Notarization',\n severity: 'info',\n description:\n 'Confirmations complete, waiting for notarization service to generate proof',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimable':\n return {\n label: 'Claimable',\n severity: 'success',\n description: 'Ready to mint - proof available, claim to receive tokens',\n isTerminal: false,\n requiresAction: true,\n };\n case 'claiming':\n return {\n label: 'Claiming',\n severity: 'info',\n description: 'Claim transaction in progress',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimed':\n return {\n label: 'Claimed',\n severity: 'neutral',\n description: 'Tokens have been minted to your address',\n isTerminal: true,\n requiresAction: false,\n };\n case 'auto_claimed':\n return {\n label: 'Auto-Claimed',\n severity: 'success',\n description: 'Automatically claimed via cross-chain messaging (GMP)',\n isTerminal: true,\n requiresAction: false,\n };\n case 'expired':\n return {\n label: 'Expired',\n severity: 'error',\n description: 'Fee signature expired, requires re-authorization',\n isTerminal: false,\n requiresAction: true,\n };\n case 'failed':\n return {\n label: 'Failed',\n severity: 'error',\n description: 'Notarization failed - contact support',\n isTerminal: true,\n requiresAction: false,\n };\n case 'restricted':\n return {\n label: 'Restricted',\n severity: 'error',\n description: 'This deposit is restricted or sanctioned',\n isTerminal: true,\n requiresAction: false,\n };\n case 'too_small':\n return {\n label: 'Too Small',\n severity: 'neutral',\n description: `Amount below minimum claimable amount (${MIN_STAKE_AMOUNT_BTC} BTC)`,\n isTerminal: true,\n requiresAction: false,\n };\n }\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Helper Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Check if a deposit can be claimed manually\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if the deposit is in claimable state\n */\nexport function isDepositClaimable(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n return getDepositStatus(deposit, currentBlockHeight) === 'claimable';\n}\n\n/**\n * Check if a deposit is in a pending state (confirmations or notarization)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is pending\n */\nexport function isDepositPending(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n return (\n status === 'pending_confirmations' || status === 'pending_notarization'\n );\n}\n\n/**\n * Check if a deposit is in a terminal state (no further action possible)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is in terminal state\n */\nexport function isDepositTerminal(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.isTerminal;\n}\n\n/**\n * Check if a deposit requires user action\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if user action is required\n */\nexport function depositRequiresAction(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.requiresAction;\n}\n"],"names":["getLBTCExchangeRate","env","chainId","ChainId","amount","toSatoshi","baseApiUrl","getApiConfig","chainIdName","getChainNameById","data","axios","amountOut","BigNumber","exchangeRate","minAmount","MIN_STAKE_AMOUNT_BTC","URL","setReferral","address","signature","eip712Data","referrerCode","pubKey","requestParams","error","errorMsg","getErrorMessage","REQUIRED_CONFIRMATIONS","MIN_CLAIM_AMOUNT_BTC","calcConfirmations","currentBlockHeight","depositBlockHeight","getConfirmationProgress","requiredConfirmations","current","percentage","getDepositStatus","deposit","ENotarizationStatus","amountBtc","_b","_a","ESessionState","hasProof","notarizationStatus","confirmations","hasEnoughConfirmations","getDepositStatusDisplay","status","isDepositClaimable","isDepositPending","isDepositTerminal","depositRequiresAction"],"mappings":"6WAwDA,eAAsBA,EAAoB,CACxC,IAAAC,EACA,QAAAC,EAAUC,EAAAA,QAAQ,SAClB,OAAAC,EAASC,EAAAA,UAAU,CAAC,CACtB,EAAsE,CACpE,KAAM,CAAE,WAAAC,CAAA,EAAeC,EAAAA,aAAaN,CAAG,EACjCO,EAAcC,EAAAA,iBAAiBP,CAAO,EAEtC,CAAE,KAAAQ,CAAA,EAAS,MAAMC,EAAM,IAC3B,wBAAwBH,CAAW,GACnC,CAAE,QAASF,EAAY,OAAQ,CAAE,OAAAF,EAAO,CAAE,EA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pB,IAAK,WACH,MAAO,CACL,MAAO,WACP,SAAU,OACV,YAAa,gCACb,WAAY,GACZ,eAAgB,EAAA,EAEpB,IAAK,UACH,MAAO,CACL,MAAO,UACP,SAAU,UACV,YAAa,0CACb,WAAY,GACZ,eAAgB,EAAA,EAEpB,IAAK,eACH,MAAO,CACL,MAAO,eACP,SAAU,UACV,YAAa,wDACb,WAAY,GACZ,eAAgB,EAAA,EAEpB,IAAK,UACH,MAAO,CACL,MAAO,UACP,SAAU,QACV,YAAa,mDACb,WAAY,GACZ,eAAgB,EAAA,EAEpB,IAAK,SACH,MAAO,CACL,MAAO,SACP,SAAU,QACV,YAAa,wCACb,WAAY,GACZ,eAAgB,EAAA,EAEpB,IAAK,aACH,MAAO,CACL,MAAO,aACP,SAAU,QACV,YAAa,2CACb,WAAY,GACZ,eAAgB,EAAA,EAEpB,IAAK,YACH,MAAO,CACL,MAAO,YACP,SAAU,UACV,YAAa,0CAA0CZ,EAAAA,oBAAoB,QAC3E,WAAY,GACZ,eAAgB,EAAA,CAClB,CAEN,CAaO,SAASkC,EACdZ,EACAP,EACS,CACT,OAAOM,EAAiBC,EAASP,CAAkB,IAAM,WAC3D,CASO,SAASoB,EACdb,EACAP,EACS,CACT,MAAMkB,EAASZ,EAAiBC,EAASP,CAAkB,EAC3D,OACEkB,IAAW,yBAA2BA,IAAW,sBAErD,CASO,SAASG,EACdd,EACAP,EACS,CACT,MAAMkB,EAASZ,EAAiBC,EAASP,CAAkB,EAE3D,OADgBiB,EAAwBC,CAAM,EAC/B,UACjB,CASO,SAASI,EACdf,EACAP,EACS,CACT,MAAMkB,EAASZ,EAAiBC,EAASP,CAAkB,EAE3D,OADgBiB,EAAwBC,CAAM,EAC/B,cACjB"}
|
|
@@ -3,7 +3,7 @@ import T from "bignumber.js";
|
|
|
3
3
|
import { getApiConfig as _ } from "./api-config-Dm6dR85f.js";
|
|
4
4
|
import { getChainNameById as g } from "./blockchain-identifier-BkASqCgZ.js";
|
|
5
5
|
import { ChainId as I } from "./token-addresses-DVnRPyu4.js";
|
|
6
|
-
import { MIN_STAKE_AMOUNT_BTC as m } from "./
|
|
6
|
+
import { MIN_STAKE_AMOUNT_BTC as m } from "./storeNetworkFeeSignature-sCt4_nHr.js";
|
|
7
7
|
import { toSatoshi as p } from "./satoshi-CSoJBXc6.js";
|
|
8
8
|
import { getErrorMessage as b } from "./tokens-BUrC15ra.js";
|
|
9
9
|
import { ENotarizationStatus as o, ESessionState as y } from "./ReferralsClient-BNwB6wO4.js";
|
|
@@ -205,4 +205,4 @@ export {
|
|
|
205
205
|
F as isDepositTerminal,
|
|
206
206
|
z as setReferral
|
|
207
207
|
};
|
|
208
|
-
//# sourceMappingURL=depositStatus-
|
|
208
|
+
//# sourceMappingURL=depositStatus-hmXphYhu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depositStatus-CacTFWfJ.js","sources":["../../src/api-functions/getLBTCExchangeRate/getLBTCExchangeRate.ts","../../src/api-functions/setReferral/setReferral.ts","../../src/shared/deposits/depositStatus.ts"],"sourcesContent":["import axios from 'axios';\nimport BigNumber from 'bignumber.js';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { getChainNameById } from '../../common/blockchain-identifier';\nimport { ChainId } from '../../common/chains';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\nimport { IEnvParam } from '../../common/parameters';\nimport { toSatoshi } from '../../utils/satoshi';\n\ntype ExchangeRateResponse = {\n amount_out: string;\n};\n\nexport interface IgetLBTCExchangeRateParams extends IEnvParam {\n /**\n * The optional chain id of the asset to get the exchange rate for.\n * Note: Exchange rate it the same for all chains.\n *\n * @default OChainId.ethereum\n */\n chainId?: ChainId;\n /**\n * The amount of the LBTC (in satoshis) that a user would like to exchange to BTC.\n */\n amount?: BigNumber.Value;\n}\n\nexport interface IgetLBTCExchangeRateResponse {\n /**\n * The exchanged amount (in satoshis).\n */\n amountOut: number;\n /**\n * The exchange rate for LBTC/BTC.\n */\n exchangeRate: number;\n /**\n * The minimum amount of BTC eligible for staking (in satoshis).\n */\n minAmount: number;\n}\n\n/**\n * Retrieves the exchange rate for LBTC.\n *\n * @deprecated This API endpoint is deprecated and will be removed in a future version.\n * The exchange rate is now always 1:1 as LBTC is a rebasing token.\n *\n * @param {IgetLBTCExchangeRateParams} parameters - The parameters.\n * @param {BigNumber.Value} parameters.amount - The optional amount to be exchanged.\n * @param {ChainId} parameters.chainId - The optional chain id.\n * @param {Env} parameters.env - The optional environment identifier.\n *\n * @returns {Promise<IgetLBTCExchangeRateResponse>} - The exchange rate.\n */\nexport async function getLBTCExchangeRate({\n env,\n chainId = ChainId.ethereum,\n amount = toSatoshi(1),\n}: IgetLBTCExchangeRateParams): Promise<IgetLBTCExchangeRateResponse> {\n const { baseApiUrl } = getApiConfig(env);\n const chainIdName = getChainNameById(chainId);\n\n const { data } = await axios.get<ExchangeRateResponse>(\n `api/v1/exchange/rate/${chainIdName}`,\n { baseURL: baseApiUrl, params: { amount } },\n );\n\n const amountOut = BigNumber(data.amount_out).toNumber();\n const exchangeRate = BigNumber(amount).dividedBy(data.amount_out).toNumber();\n const minAmount = toSatoshi(MIN_STAKE_AMOUNT_BTC).toNumber();\n\n return { amountOut, exchangeRate, minAmount };\n}\n","import axios from 'axios';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { IEnvParam } from '../../common/parameters';\nimport { getErrorMessage } from '../../utils/err';\n\nconst URL = 'api/v1/referral-system/referrer/';\n\nexport interface ISetReferralParams extends IEnvParam {\n /**\n * The destination EVM user address where LBTC will be claimed.\n */\n address: string;\n /**\n * The signature of the address. The signature is generated by signing the address using wallet.\n * Use `signTermsOfService` or `signLbtcDestinationAddr` functions.\n */\n signature: string;\n /**\n * The captcha token.\n */\n referrerCode: string;\n /**\n * The typed data object used to generate the signature if using a network fee authorization signature.\n */\n eip712Data?: string;\n /**\n * The public key (required for Starknet).\n */\n pubKey?: string;\n}\n\n/**\n * Set a referral code.\n *\n * @param {ISetReferralParams} The parameters for set referral.\n * @returns {Promise<void>} Nothing.\n * @exception {Error}\n */\nexport async function setReferral({\n address,\n signature,\n eip712Data,\n referrerCode,\n pubKey,\n env,\n}: ISetReferralParams): Promise<void> {\n const { baseApiUrl } = getApiConfig(env);\n\n const requestParams = {\n referrer_code: referrerCode,\n signature,\n signature_typed_data: eip712Data,\n ...(pubKey && { public_key: pubKey }),\n };\n\n try {\n await axios.post(`${URL}${address}`, requestParams, {\n baseURL: baseApiUrl,\n });\n\n return undefined;\n } catch (error) {\n const errorMsg = getErrorMessage(error);\n throw new Error(errorMsg);\n }\n}\n","/**\n * Deposit Status Utilities\n *\n * Centralized logic for determining deposit status based on notarization state,\n * confirmations, and other factors. This module provides a single source of truth\n * for deposit status that can be used by the SDK demo, apps/main, and other consumers.\n *\n * Status determination is based on both notarization status and block confirmations.\n * The notarization status from the backend is the primary source of truth for where\n * in the flow a deposit currently is.\n *\n * @module shared/deposits/depositStatus\n */\n\nimport {\n type Deposit,\n ENotarizationStatus,\n ESessionState,\n} from '../../api-functions/getDepositsByAddress/getDepositsByAddress';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Constants\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Number of confirmations required before a deposit can be claimed.\n * Production/Testnet: 6, Stage/Dev: 3\n */\nexport const REQUIRED_CONFIRMATIONS = 6;\n\n/**\n * Minimum deposit amount that can be claimed (in BTC).\n * Deposits below this amount cannot be minted.\n *\n * @deprecated Use `MIN_STAKE_AMOUNT_BTC` from `@lombard.finance/sdk` instead.\n * This constant is an alias kept for backwards compatibility.\n */\nexport const MIN_CLAIM_AMOUNT_BTC = MIN_STAKE_AMOUNT_BTC;\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Types\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Possible deposit statuses - ordered by lifecycle\n */\nexport type DepositStatus =\n | 'pending_confirmations' // Waiting for BTC block confirmations\n | 'pending_notarization' // Confirmations complete, waiting for notarization service\n | 'claimable' // Notarization approved, ready to be claimed manually\n | 'claiming' // Claim transaction submitted\n | 'claimed' // Successfully claimed (has claimTxHash)\n | 'auto_claimed' // Claimed via GMP (cross-chain messaging)\n | 'expired' // Signature expired, needs re-auth\n | 'failed' // Notarization failed\n | 'restricted' // Sanctioned or restricted\n | 'too_small'; // Amount below minimum\n\n/**\n * Status severity for UI styling\n */\nexport type StatusSeverity =\n | 'info'\n | 'warning'\n | 'success'\n | 'error'\n | 'neutral';\n\n/**\n * Status display configuration\n */\nexport interface DepositStatusDisplay {\n /** Human-readable label for the status */\n label: string;\n /** Severity level for styling */\n severity: StatusSeverity;\n /** Detailed description of the status */\n description: string;\n /** Whether the deposit is in a terminal state (claimed, failed, restricted) */\n isTerminal: boolean;\n /** Whether user action is required */\n requiresAction: boolean;\n}\n\n/**\n * Confirmation progress information\n */\nexport interface ConfirmationProgress {\n /** Current number of confirmations */\n current: number;\n /** Required number of confirmations */\n required: number;\n /** Percentage complete (0-100) */\n percentage: number;\n /** Whether enough confirmations have been received */\n isComplete: boolean;\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Core Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Calculate the number of confirmations for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @returns Number of confirmations (0 if either height is missing)\n */\nexport function calcConfirmations(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n): number {\n if (!depositBlockHeight || !currentBlockHeight) {\n return 0;\n }\n // Deposit block height counts as the first confirmation\n return Math.max(0, currentBlockHeight - depositBlockHeight + 1);\n}\n\n/**\n * Get confirmation progress for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @param requiredConfirmations - Number of confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns Confirmation progress info, or null if block heights unavailable\n */\nexport function getConfirmationProgress(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): ConfirmationProgress | null {\n if (currentBlockHeight === undefined || depositBlockHeight === undefined) {\n return null;\n }\n\n const current = calcConfirmations(currentBlockHeight, depositBlockHeight);\n const percentage = Math.min(\n 100,\n Math.round((current / requiredConfirmations) * 100),\n );\n\n return {\n current,\n required: requiredConfirmations,\n percentage,\n isComplete: current >= requiredConfirmations,\n };\n}\n\n/**\n * Determine the status of a deposit\n *\n * Logic priority:\n * 1. Sanctioned → restricted\n * 2. Already claimed → claimed\n * 3. GMP handled → auto_claimed (definitive success, overrides expired/failed)\n * 4. Amount too small → too_small (permanent, re-auth won't help)\n * 5. Notarization failed → failed (terminal, overrides expired)\n * 6. Session expired → expired (recoverable via re-auth)\n * 7. Based on notarization status + proof availability:\n * - PENDING/SUBMITTED without enough confirmations → pending_confirmations\n * - PENDING/SUBMITTED with confirmations → pending_notarization\n * - SESSION_APPROVED with proof → claimable\n * - SESSION_APPROVED without proof → pending_notarization (edge case)\n *\n * @param deposit - The deposit object from the SDK\n * @param currentBlockHeight - Current BTC block height (optional, enhances accuracy)\n * @param requiredConfirmations - Confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns The deposit status\n */\nexport function getDepositStatus(\n deposit: Deposit,\n currentBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): DepositStatus {\n // 1. Check for sanctioned/restricted first\n if (deposit.sanctioned) {\n return 'restricted';\n }\n\n // 2. Check if already claimed\n if (deposit.isClaimed || deposit.claimTxHash) {\n return 'claimed';\n }\n\n // 3. Check for GMP auto-claim (definitive success, overrides expired/failed)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_GMP_HANDLED\n ) {\n return 'auto_claimed';\n }\n\n // 4. Check if amount is too small (permanent, re-auth won't help)\n const amountBtc = deposit.amount?.toNumber?.() ?? Number(deposit.amount);\n if (amountBtc > 0 && amountBtc < MIN_STAKE_AMOUNT_BTC) {\n return 'too_small';\n }\n\n // 5. Check for notarization failure (terminal, overrides expired)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_FAILED\n ) {\n return 'failed';\n }\n\n // 6. Check if the notarization session has expired (recoverable via re-auth)\n if (deposit.sessionState === ESessionState.SESSION_STATE_EXPIRED) {\n return 'expired';\n }\n\n // 7. Determine status based on notarization status and proof availability\n const hasProof = !!deposit.proof && !!deposit.rawPayload;\n const notarizationStatus = deposit.notarizationStatus;\n\n // Check confirmations only if we have block height data\n const confirmations = calcConfirmations(\n currentBlockHeight,\n deposit.blockHeight,\n );\n const hasEnoughConfirmations =\n currentBlockHeight === undefined || confirmations >= requiredConfirmations;\n\n switch (notarizationStatus) {\n case ENotarizationStatus.NOTARIZATION_STATUS_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_GMP_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_SUBMITTED:\n // Still in notarization queue\n // If we know block height and not enough confirmations, show that\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n // Otherwise, we're waiting for notarization\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_SESSION_APPROVED:\n // Notarization approved\n if (hasProof) {\n return 'claimable';\n }\n // Edge case: approved but no proof yet (should be rare)\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_UNSPECIFIED:\n default:\n // Unknown status - check confirmations if we can\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n return 'pending_notarization';\n }\n}\n\n/**\n * Get display configuration for a deposit status\n *\n * @param status - The deposit status\n * @returns Display configuration with label, severity, and description\n */\nexport function getDepositStatusDisplay(\n status: DepositStatus,\n): DepositStatusDisplay {\n switch (status) {\n case 'pending_confirmations':\n return {\n label: 'Pending Confirmations',\n severity: 'warning',\n description: `Waiting for Bitcoin block confirmations (${REQUIRED_CONFIRMATIONS} required)`,\n isTerminal: false,\n requiresAction: false,\n };\n case 'pending_notarization':\n return {\n label: 'Pending Notarization',\n severity: 'info',\n description:\n 'Confirmations complete, waiting for notarization service to generate proof',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimable':\n return {\n label: 'Claimable',\n severity: 'success',\n description: 'Ready to mint - proof available, claim to receive tokens',\n isTerminal: false,\n requiresAction: true,\n };\n case 'claiming':\n return {\n label: 'Claiming',\n severity: 'info',\n description: 'Claim transaction in progress',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimed':\n return {\n label: 'Claimed',\n severity: 'neutral',\n description: 'Tokens have been minted to your address',\n isTerminal: true,\n requiresAction: false,\n };\n case 'auto_claimed':\n return {\n label: 'Auto-Claimed',\n severity: 'success',\n description: 'Automatically claimed via cross-chain messaging (GMP)',\n isTerminal: true,\n requiresAction: false,\n };\n case 'expired':\n return {\n label: 'Expired',\n severity: 'error',\n description: 'Fee signature expired, requires re-authorization',\n isTerminal: false,\n requiresAction: true,\n };\n case 'failed':\n return {\n label: 'Failed',\n severity: 'error',\n description: 'Notarization failed - contact support',\n isTerminal: true,\n requiresAction: false,\n };\n case 'restricted':\n return {\n label: 'Restricted',\n severity: 'error',\n description: 'This deposit is restricted or sanctioned',\n isTerminal: true,\n requiresAction: false,\n };\n case 'too_small':\n return {\n label: 'Too Small',\n severity: 'neutral',\n description: `Amount below minimum claimable amount (${MIN_STAKE_AMOUNT_BTC} BTC)`,\n isTerminal: true,\n requiresAction: false,\n };\n }\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Helper Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Check if a deposit can be claimed manually\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if the deposit is in claimable state\n */\nexport function isDepositClaimable(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n return getDepositStatus(deposit, currentBlockHeight) === 'claimable';\n}\n\n/**\n * Check if a deposit is in a pending state (confirmations or notarization)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is pending\n */\nexport function isDepositPending(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n return (\n status === 'pending_confirmations' || status === 'pending_notarization'\n );\n}\n\n/**\n * Check if a deposit is in a terminal state (no further action possible)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is in terminal state\n */\nexport function isDepositTerminal(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.isTerminal;\n}\n\n/**\n * Check if a deposit requires user action\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if user action is required\n */\nexport function depositRequiresAction(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.requiresAction;\n}\n"],"names":["getLBTCExchangeRate","env","chainId","ChainId","amount","toSatoshi","baseApiUrl","getApiConfig","chainIdName","getChainNameById","data","axios","amountOut","BigNumber","exchangeRate","minAmount","MIN_STAKE_AMOUNT_BTC","URL","setReferral","address","signature","eip712Data","referrerCode","pubKey","requestParams","error","errorMsg","getErrorMessage","REQUIRED_CONFIRMATIONS","MIN_CLAIM_AMOUNT_BTC","calcConfirmations","currentBlockHeight","depositBlockHeight","getConfirmationProgress","requiredConfirmations","current","percentage","getDepositStatus","deposit","ENotarizationStatus","amountBtc","_b","_a","ESessionState","hasProof","notarizationStatus","confirmations","hasEnoughConfirmations","getDepositStatusDisplay","status","isDepositClaimable","isDepositPending","isDepositTerminal","depositRequiresAction"],"mappings":";;;;;;;;;AAwDA,eAAsBA,EAAoB;AAAA,EACxC,KAAAC;AAAA,EACA,SAAAC,IAAUC,EAAQ;AAAA,EAClB,QAAAC,IAAS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AA;AAAA,IAEpB,KAAK;AACH,aAAO;AAAA,QACL,OAAO;AAAA,QACP,UAAU;AAAA,QACV,aAAa,0CAA0CZ,CAAoB;AAAA,QAC3E,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAAA;AAAA,EAClB;AAEN;AAaO,SAASkC,EACdZ,GACAP,GACS;AACT,SAAOM,EAAiBC,GAASP,CAAkB,MAAM;AAC3D;AASO,SAASoB,EACdb,GACAP,GACS;AACT,QAAMkB,IAASZ,EAAiBC,GAASP,CAAkB;AAC3D,SACEkB,MAAW,2BAA2BA,MAAW;AAErD;AASO,SAASG,EACdd,GACAP,GACS;AACT,QAAMkB,IAASZ,EAAiBC,GAASP,CAAkB;AAE3D,SADgBiB,EAAwBC,CAAM,EAC/B;AACjB;AASO,SAASI,EACdf,GACAP,GACS;AACT,QAAMkB,IAASZ,EAAiBC,GAASP,CAAkB;AAE3D,SADgBiB,EAAwBC,CAAM,EAC/B;AACjB;"}
|
|
1
|
+
{"version":3,"file":"depositStatus-hmXphYhu.js","sources":["../../src/api-functions/getLBTCExchangeRate/getLBTCExchangeRate.ts","../../src/api-functions/setReferral/setReferral.ts","../../src/shared/deposits/depositStatus.ts"],"sourcesContent":["import axios from 'axios';\nimport BigNumber from 'bignumber.js';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { getChainNameById } from '../../common/blockchain-identifier';\nimport { ChainId } from '../../common/chains';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\nimport { IEnvParam } from '../../common/parameters';\nimport { toSatoshi } from '../../utils/satoshi';\n\ntype ExchangeRateResponse = {\n amount_out: string;\n};\n\nexport interface IgetLBTCExchangeRateParams extends IEnvParam {\n /**\n * The optional chain id of the asset to get the exchange rate for.\n * Note: Exchange rate it the same for all chains.\n *\n * @default OChainId.ethereum\n */\n chainId?: ChainId;\n /**\n * The amount of the LBTC (in satoshis) that a user would like to exchange to BTC.\n */\n amount?: BigNumber.Value;\n}\n\nexport interface IgetLBTCExchangeRateResponse {\n /**\n * The exchanged amount (in satoshis).\n */\n amountOut: number;\n /**\n * The exchange rate for LBTC/BTC.\n */\n exchangeRate: number;\n /**\n * The minimum amount of BTC eligible for staking (in satoshis).\n */\n minAmount: number;\n}\n\n/**\n * Retrieves the exchange rate for LBTC.\n *\n * @deprecated This API endpoint is deprecated and will be removed in a future version.\n * The exchange rate is now always 1:1 as LBTC is a rebasing token.\n *\n * @param {IgetLBTCExchangeRateParams} parameters - The parameters.\n * @param {BigNumber.Value} parameters.amount - The optional amount to be exchanged.\n * @param {ChainId} parameters.chainId - The optional chain id.\n * @param {Env} parameters.env - The optional environment identifier.\n *\n * @returns {Promise<IgetLBTCExchangeRateResponse>} - The exchange rate.\n */\nexport async function getLBTCExchangeRate({\n env,\n chainId = ChainId.ethereum,\n amount = toSatoshi(1),\n}: IgetLBTCExchangeRateParams): Promise<IgetLBTCExchangeRateResponse> {\n const { baseApiUrl } = getApiConfig(env);\n const chainIdName = getChainNameById(chainId);\n\n const { data } = await axios.get<ExchangeRateResponse>(\n `api/v1/exchange/rate/${chainIdName}`,\n { baseURL: baseApiUrl, params: { amount } },\n );\n\n const amountOut = BigNumber(data.amount_out).toNumber();\n const exchangeRate = BigNumber(amount).dividedBy(data.amount_out).toNumber();\n const minAmount = toSatoshi(MIN_STAKE_AMOUNT_BTC).toNumber();\n\n return { amountOut, exchangeRate, minAmount };\n}\n","import axios from 'axios';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { IEnvParam } from '../../common/parameters';\nimport { getErrorMessage } from '../../utils/err';\n\nconst URL = 'api/v1/referral-system/referrer/';\n\nexport interface ISetReferralParams extends IEnvParam {\n /**\n * The destination EVM user address where LBTC will be claimed.\n */\n address: string;\n /**\n * The signature of the address. The signature is generated by signing the address using wallet.\n * Use `signTermsOfService` or `signLbtcDestinationAddr` functions.\n */\n signature: string;\n /**\n * The captcha token.\n */\n referrerCode: string;\n /**\n * The typed data object used to generate the signature if using a network fee authorization signature.\n */\n eip712Data?: string;\n /**\n * The public key (required for Starknet).\n */\n pubKey?: string;\n}\n\n/**\n * Set a referral code.\n *\n * @param {ISetReferralParams} The parameters for set referral.\n * @returns {Promise<void>} Nothing.\n * @exception {Error}\n */\nexport async function setReferral({\n address,\n signature,\n eip712Data,\n referrerCode,\n pubKey,\n env,\n}: ISetReferralParams): Promise<void> {\n const { baseApiUrl } = getApiConfig(env);\n\n const requestParams = {\n referrer_code: referrerCode,\n signature,\n signature_typed_data: eip712Data,\n ...(pubKey && { public_key: pubKey }),\n };\n\n try {\n await axios.post(`${URL}${address}`, requestParams, {\n baseURL: baseApiUrl,\n });\n\n return undefined;\n } catch (error) {\n const errorMsg = getErrorMessage(error);\n throw new Error(errorMsg);\n }\n}\n","/**\n * Deposit Status Utilities\n *\n * Centralized logic for determining deposit status based on notarization state,\n * confirmations, and other factors. This module provides a single source of truth\n * for deposit status that can be used by the SDK demo, apps/main, and other consumers.\n *\n * Status determination is based on both notarization status and block confirmations.\n * The notarization status from the backend is the primary source of truth for where\n * in the flow a deposit currently is.\n *\n * @module shared/deposits/depositStatus\n */\n\nimport {\n type Deposit,\n ENotarizationStatus,\n ESessionState,\n} from '../../api-functions/getDepositsByAddress/getDepositsByAddress';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Constants\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Number of confirmations required before a deposit can be claimed.\n * Production/Testnet: 6, Stage/Dev: 3\n */\nexport const REQUIRED_CONFIRMATIONS = 6;\n\n/**\n * Minimum deposit amount that can be claimed (in BTC).\n * Deposits below this amount cannot be minted.\n *\n * @deprecated Use `MIN_STAKE_AMOUNT_BTC` from `@lombard.finance/sdk` instead.\n * This constant is an alias kept for backwards compatibility.\n */\nexport const MIN_CLAIM_AMOUNT_BTC = MIN_STAKE_AMOUNT_BTC;\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Types\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Possible deposit statuses - ordered by lifecycle\n */\nexport type DepositStatus =\n | 'pending_confirmations' // Waiting for BTC block confirmations\n | 'pending_notarization' // Confirmations complete, waiting for notarization service\n | 'claimable' // Notarization approved, ready to be claimed manually\n | 'claiming' // Claim transaction submitted\n | 'claimed' // Successfully claimed (has claimTxHash)\n | 'auto_claimed' // Claimed via GMP (cross-chain messaging)\n | 'expired' // Signature expired, needs re-auth\n | 'failed' // Notarization failed\n | 'restricted' // Sanctioned or restricted\n | 'too_small'; // Amount below minimum\n\n/**\n * Status severity for UI styling\n */\nexport type StatusSeverity =\n | 'info'\n | 'warning'\n | 'success'\n | 'error'\n | 'neutral';\n\n/**\n * Status display configuration\n */\nexport interface DepositStatusDisplay {\n /** Human-readable label for the status */\n label: string;\n /** Severity level for styling */\n severity: StatusSeverity;\n /** Detailed description of the status */\n description: string;\n /** Whether the deposit is in a terminal state (claimed, failed, restricted) */\n isTerminal: boolean;\n /** Whether user action is required */\n requiresAction: boolean;\n}\n\n/**\n * Confirmation progress information\n */\nexport interface ConfirmationProgress {\n /** Current number of confirmations */\n current: number;\n /** Required number of confirmations */\n required: number;\n /** Percentage complete (0-100) */\n percentage: number;\n /** Whether enough confirmations have been received */\n isComplete: boolean;\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Core Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Calculate the number of confirmations for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @returns Number of confirmations (0 if either height is missing)\n */\nexport function calcConfirmations(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n): number {\n if (!depositBlockHeight || !currentBlockHeight) {\n return 0;\n }\n // Deposit block height counts as the first confirmation\n return Math.max(0, currentBlockHeight - depositBlockHeight + 1);\n}\n\n/**\n * Get confirmation progress for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @param requiredConfirmations - Number of confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns Confirmation progress info, or null if block heights unavailable\n */\nexport function getConfirmationProgress(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): ConfirmationProgress | null {\n if (currentBlockHeight === undefined || depositBlockHeight === undefined) {\n return null;\n }\n\n const current = calcConfirmations(currentBlockHeight, depositBlockHeight);\n const percentage = Math.min(\n 100,\n Math.round((current / requiredConfirmations) * 100),\n );\n\n return {\n current,\n required: requiredConfirmations,\n percentage,\n isComplete: current >= requiredConfirmations,\n };\n}\n\n/**\n * Determine the status of a deposit\n *\n * Logic priority:\n * 1. Sanctioned → restricted\n * 2. Already claimed → claimed\n * 3. GMP handled → auto_claimed (definitive success, overrides expired/failed)\n * 4. Amount too small → too_small (permanent, re-auth won't help)\n * 5. Notarization failed → failed (terminal, overrides expired)\n * 6. Session expired → expired (recoverable via re-auth)\n * 7. Based on notarization status + proof availability:\n * - PENDING/SUBMITTED without enough confirmations → pending_confirmations\n * - PENDING/SUBMITTED with confirmations → pending_notarization\n * - SESSION_APPROVED with proof → claimable\n * - SESSION_APPROVED without proof → pending_notarization (edge case)\n *\n * @param deposit - The deposit object from the SDK\n * @param currentBlockHeight - Current BTC block height (optional, enhances accuracy)\n * @param requiredConfirmations - Confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns The deposit status\n */\nexport function getDepositStatus(\n deposit: Deposit,\n currentBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): DepositStatus {\n // 1. Check for sanctioned/restricted first\n if (deposit.sanctioned) {\n return 'restricted';\n }\n\n // 2. Check if already claimed\n if (deposit.isClaimed || deposit.claimTxHash) {\n return 'claimed';\n }\n\n // 3. Check for GMP auto-claim (definitive success, overrides expired/failed)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_GMP_HANDLED\n ) {\n return 'auto_claimed';\n }\n\n // 4. Check if amount is too small (permanent, re-auth won't help)\n const amountBtc = deposit.amount?.toNumber?.() ?? Number(deposit.amount);\n if (amountBtc > 0 && amountBtc < MIN_STAKE_AMOUNT_BTC) {\n return 'too_small';\n }\n\n // 5. Check for notarization failure (terminal, overrides expired)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_FAILED\n ) {\n return 'failed';\n }\n\n // 6. Check if the notarization session has expired (recoverable via re-auth)\n if (deposit.sessionState === ESessionState.SESSION_STATE_EXPIRED) {\n return 'expired';\n }\n\n // 7. Determine status based on notarization status and proof availability\n const hasProof = !!deposit.proof && !!deposit.rawPayload;\n const notarizationStatus = deposit.notarizationStatus;\n\n // Check confirmations only if we have block height data\n const confirmations = calcConfirmations(\n currentBlockHeight,\n deposit.blockHeight,\n );\n const hasEnoughConfirmations =\n currentBlockHeight === undefined || confirmations >= requiredConfirmations;\n\n switch (notarizationStatus) {\n case ENotarizationStatus.NOTARIZATION_STATUS_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_GMP_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_SUBMITTED:\n // Still in notarization queue\n // If we know block height and not enough confirmations, show that\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n // Otherwise, we're waiting for notarization\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_SESSION_APPROVED:\n // Notarization approved\n if (hasProof) {\n return 'claimable';\n }\n // Edge case: approved but no proof yet (should be rare)\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_UNSPECIFIED:\n default:\n // Unknown status - check confirmations if we can\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n return 'pending_notarization';\n }\n}\n\n/**\n * Get display configuration for a deposit status\n *\n * @param status - The deposit status\n * @returns Display configuration with label, severity, and description\n */\nexport function getDepositStatusDisplay(\n status: DepositStatus,\n): DepositStatusDisplay {\n switch (status) {\n case 'pending_confirmations':\n return {\n label: 'Pending Confirmations',\n severity: 'warning',\n description: `Waiting for Bitcoin block confirmations (${REQUIRED_CONFIRMATIONS} required)`,\n isTerminal: false,\n requiresAction: false,\n };\n case 'pending_notarization':\n return {\n label: 'Pending Notarization',\n severity: 'info',\n description:\n 'Confirmations complete, waiting for notarization service to generate proof',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimable':\n return {\n label: 'Claimable',\n severity: 'success',\n description: 'Ready to mint - proof available, claim to receive tokens',\n isTerminal: false,\n requiresAction: true,\n };\n case 'claiming':\n return {\n label: 'Claiming',\n severity: 'info',\n description: 'Claim transaction in progress',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimed':\n return {\n label: 'Claimed',\n severity: 'neutral',\n description: 'Tokens have been minted to your address',\n isTerminal: true,\n requiresAction: false,\n };\n case 'auto_claimed':\n return {\n label: 'Auto-Claimed',\n severity: 'success',\n description: 'Automatically claimed via cross-chain messaging (GMP)',\n isTerminal: true,\n requiresAction: false,\n };\n case 'expired':\n return {\n label: 'Expired',\n severity: 'error',\n description: 'Fee signature expired, requires re-authorization',\n isTerminal: false,\n requiresAction: true,\n };\n case 'failed':\n return {\n label: 'Failed',\n severity: 'error',\n description: 'Notarization failed - contact support',\n isTerminal: true,\n requiresAction: false,\n };\n case 'restricted':\n return {\n label: 'Restricted',\n severity: 'error',\n description: 'This deposit is restricted or sanctioned',\n isTerminal: true,\n requiresAction: false,\n };\n case 'too_small':\n return {\n label: 'Too Small',\n severity: 'neutral',\n description: `Amount below minimum claimable amount (${MIN_STAKE_AMOUNT_BTC} BTC)`,\n isTerminal: true,\n requiresAction: false,\n };\n }\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Helper Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Check if a deposit can be claimed manually\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if the deposit is in claimable state\n */\nexport function isDepositClaimable(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n return getDepositStatus(deposit, currentBlockHeight) === 'claimable';\n}\n\n/**\n * Check if a deposit is in a pending state (confirmations or notarization)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is pending\n */\nexport function isDepositPending(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n return (\n status === 'pending_confirmations' || status === 'pending_notarization'\n );\n}\n\n/**\n * Check if a deposit is in a terminal state (no further action possible)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is in terminal state\n */\nexport function isDepositTerminal(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.isTerminal;\n}\n\n/**\n * Check if a deposit requires user action\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if user action is required\n */\nexport function depositRequiresAction(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.requiresAction;\n}\n"],"names":["getLBTCExchangeRate","env","chainId","ChainId","amount","toSatoshi","baseApiUrl","getApiConfig","chainIdName","getChainNameById","data","axios","amountOut","BigNumber","exchangeRate","minAmount","MIN_STAKE_AMOUNT_BTC","URL","setReferral","address","signature","eip712Data","referrerCode","pubKey","requestParams","error","errorMsg","getErrorMessage","REQUIRED_CONFIRMATIONS","MIN_CLAIM_AMOUNT_BTC","calcConfirmations","currentBlockHeight","depositBlockHeight","getConfirmationProgress","requiredConfirmations","current","percentage","getDepositStatus","deposit","ENotarizationStatus","amountBtc","_b","_a","ESessionState","hasProof","notarizationStatus","confirmations","hasEnoughConfirmations","getDepositStatusDisplay","status","isDepositClaimable","isDepositPending","isDepositTerminal","depositRequiresAction"],"mappings":";;;;;;;;;AAwDA,eAAsBA,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O;AAAA,QACP,UAAU;AAAA,QACV,aAAa;AAAA,QACb,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAAA;AAAA,IAEpB,KAAK;AACH,aAAO;AAAA,QACL,OAAO;AAAA,QACP,UAAU;AAAA,QACV,aAAa,0CAA0CZ,CAAoB;AAAA,QAC3E,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAAA;AAAA,EAClB;AAEN;AAaO,SAASkC,EACdZ,GACAP,GACS;AACT,SAAOM,EAAiBC,GAASP,CAAkB,MAAM;AAC3D;AASO,SAASoB,EACdb,GACAP,GACS;AACT,QAAMkB,IAASZ,EAAiBC,GAASP,CAAkB;AAC3D,SACEkB,MAAW,2BAA2BA,MAAW;AAErD;AASO,SAASG,EACdd,GACAP,GACS;AACT,QAAMkB,IAASZ,EAAiBC,GAASP,CAAkB;AAE3D,SADgBiB,EAAwBC,CAAM,EAC/B;AACjB;AASO,SAASI,EACdf,GACAP,GACS;AACT,QAAMkB,IAASZ,EAAiBC,GAASP,CAAkB;AAE3D,SADgBiB,EAAwBC,CAAM,EAC/B;AACjB;"}
|
|
@@ -2,12 +2,13 @@ var $ = Object.defineProperty;
|
|
|
2
2
|
var q = (s, t, e) => t in s ? $(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
3
|
var a = (s, t, e) => q(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import "axios";
|
|
5
|
-
import { SDK_RUNTIME as z, SDK_VERSION as W, LombardError as d, bitcoinAddressSchema as I, Chain as h, BaseAction as C, NonEvmOperationStatus as r, validatePrepareParams as f, StepStatus as o, objectType as E, amountSchema as A, solanaAddressSchema as w, CapabilityRegistry as S, PartnerConfiguration as _, getProviderGetter as D, ASSET_CATALOG as b, getAssetAddress as X, getAssetDecimals as Z, getAssetMetadata as J, usesAssetRouter as Q, getAssetRouter as tt, getBridgeAdapter as et, getPublicMarketMaker as st, getAssetByAddress as nt, isAssetDeployed as rt, getAssetChains as it, getAssetEnvironments as at, getSupportedAssets as ot, ProviderErrorCode as ct } from "./statusConstants-
|
|
5
|
+
import { SDK_RUNTIME as z, SDK_VERSION as W, LombardError as d, bitcoinAddressSchema as I, Chain as h, BaseAction as C, NonEvmOperationStatus as r, validatePrepareParams as f, StepStatus as o, objectType as E, amountSchema as A, solanaAddressSchema as w, CapabilityRegistry as S, PartnerConfiguration as _, getProviderGetter as D, ASSET_CATALOG as b, getAssetAddress as X, getAssetDecimals as Z, getAssetMetadata as J, usesAssetRouter as Q, getAssetRouter as tt, getBridgeAdapter as et, getPublicMarketMaker as st, getAssetByAddress as nt, isAssetDeployed as rt, getAssetChains as it, getAssetEnvironments as at, getSupportedAssets as ot, ProviderErrorCode as ct } from "./statusConstants-DLrd03gT.js";
|
|
6
6
|
import { generateDepositBtcAddress as ut } from "./getUserStakeAndBakeSignature-CQsvL79O.js";
|
|
7
7
|
import { getDepositsByAddress as O, getUnstakesByAddress as ht, getPointsByAddress as dt, getDepositBtcAddress as y, storeStakeAndBakeSignature as gt, ReferralsClient as lt } from "./ReferralsClient-BNwB6wO4.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { getNetworkFeeSignature as pt } from "./getNetworkFeeSignature-FuDJWrMC.js";
|
|
9
|
+
import { storeNetworkFeeSignature as mt } from "./storeNetworkFeeSignature-sCt4_nHr.js";
|
|
10
|
+
import { btcModule as vt, BtcActions as Ct } from "./BtcActions-D7HekjRg.js";
|
|
11
|
+
import { evmModule as ft, EvmActions as Et } from "./EvmActions-nbR8cSa4.js";
|
|
11
12
|
import { SOLANA_DEVNET_CHAIN as At, SOLANA_MAINNET_CHAIN as It, getSolanaTokenAddress as L, Token as k } from "./token-addresses-DVnRPyu4.js";
|
|
12
13
|
import { toSatoshi as T } from "./satoshi-CSoJBXc6.js";
|
|
13
14
|
import { p as B, r as c } from "./index-CfcQ_g3t.js";
|
|
@@ -42,7 +43,7 @@ function Nt(s = {}) {
|
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
+
function pe() {
|
|
46
47
|
return {
|
|
47
48
|
debug: () => {
|
|
48
49
|
},
|
|
@@ -54,7 +55,7 @@ function le() {
|
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
|
-
function
|
|
58
|
+
function me() {
|
|
58
59
|
return {
|
|
59
60
|
"X-SDK-Version": W,
|
|
60
61
|
"X-SDK-Runtime": z
|
|
@@ -313,7 +314,7 @@ class wt {
|
|
|
313
314
|
* Store network fee signature
|
|
314
315
|
*/
|
|
315
316
|
async storeFeeSignature(t) {
|
|
316
|
-
await
|
|
317
|
+
await mt({
|
|
317
318
|
address: t.address,
|
|
318
319
|
signature: t.signature,
|
|
319
320
|
typedData: t.typedData,
|
|
@@ -325,7 +326,7 @@ class wt {
|
|
|
325
326
|
* Get stored network fee signature
|
|
326
327
|
*/
|
|
327
328
|
async getFeeSignature(t) {
|
|
328
|
-
return
|
|
329
|
+
return pt({
|
|
329
330
|
address: t.address,
|
|
330
331
|
chainId: t.chainId,
|
|
331
332
|
env: this.env,
|
|
@@ -783,7 +784,7 @@ class G {
|
|
|
783
784
|
return new Mt(this.ctx, t);
|
|
784
785
|
}
|
|
785
786
|
}
|
|
786
|
-
function
|
|
787
|
+
function ve(s) {
|
|
787
788
|
return new G(s);
|
|
788
789
|
}
|
|
789
790
|
const U = {
|
|
@@ -900,7 +901,7 @@ class K {
|
|
|
900
901
|
return new Vt(this.ctx, t);
|
|
901
902
|
}
|
|
902
903
|
}
|
|
903
|
-
function
|
|
904
|
+
function Ce(s) {
|
|
904
905
|
return new K(s);
|
|
905
906
|
}
|
|
906
907
|
const V = {
|
|
@@ -1028,7 +1029,7 @@ class j {
|
|
|
1028
1029
|
return new zt(this.ctx, t);
|
|
1029
1030
|
}
|
|
1030
1031
|
}
|
|
1031
|
-
function
|
|
1032
|
+
function fe(s) {
|
|
1032
1033
|
return new j(s);
|
|
1033
1034
|
}
|
|
1034
1035
|
class Xt {
|
|
@@ -1180,29 +1181,29 @@ const N = /* @__PURE__ */ new Map();
|
|
|
1180
1181
|
function Jt(s) {
|
|
1181
1182
|
return N.has(s) || N.set(s, Promise.resolve(b)), N.get(s);
|
|
1182
1183
|
}
|
|
1183
|
-
async function
|
|
1184
|
+
async function Ee(s) {
|
|
1184
1185
|
const t = "modules" in s && Array.isArray(s.modules) ? s : kt(s), e = await Jt(t.env), n = {
|
|
1185
1186
|
...t,
|
|
1186
1187
|
catalog: e
|
|
1187
1188
|
};
|
|
1188
1189
|
return new Zt(n);
|
|
1189
1190
|
}
|
|
1190
|
-
function
|
|
1191
|
+
function Ae(s) {
|
|
1191
1192
|
return typeof s == "object" && s !== null && "request" in s && typeof s.request == "function";
|
|
1192
1193
|
}
|
|
1193
|
-
function
|
|
1194
|
+
function Ie(s) {
|
|
1194
1195
|
return typeof s == "object" && s !== null && "getAddresses" in s && typeof s.getAddresses == "function";
|
|
1195
1196
|
}
|
|
1196
|
-
function
|
|
1197
|
+
function Se(s) {
|
|
1197
1198
|
return typeof s == "object" && s !== null && "publicKey" in s && "signAndSendTransaction" in s;
|
|
1198
1199
|
}
|
|
1199
|
-
function
|
|
1200
|
+
function _e(s) {
|
|
1200
1201
|
return typeof s == "object" && s !== null && "getAddress" in s && "signAndExecuteTransactionBlock" in s;
|
|
1201
1202
|
}
|
|
1202
|
-
function
|
|
1203
|
+
function De(s) {
|
|
1203
1204
|
return typeof s == "object" && s !== null && "address" in s && "execute" in s;
|
|
1204
1205
|
}
|
|
1205
|
-
const
|
|
1206
|
+
const Ne = {
|
|
1206
1207
|
/** Progress update with detailed step information */
|
|
1207
1208
|
Progress: "progress",
|
|
1208
1209
|
/** Status change (e.g., 'idle' → 'preparing' → 'ready') */
|
|
@@ -1213,31 +1214,31 @@ const De = {
|
|
|
1213
1214
|
Failed: "failed",
|
|
1214
1215
|
/** Error occurred */
|
|
1215
1216
|
Error: "error"
|
|
1216
|
-
},
|
|
1217
|
+
}, Te = {
|
|
1217
1218
|
Progress: "progress",
|
|
1218
1219
|
StatusChange: "status-change",
|
|
1219
1220
|
Completed: "completed",
|
|
1220
1221
|
Failed: "failed",
|
|
1221
1222
|
Error: "error"
|
|
1222
|
-
},
|
|
1223
|
+
}, xe = {
|
|
1223
1224
|
Progress: "progress",
|
|
1224
1225
|
StatusChange: "status-change",
|
|
1225
1226
|
Completed: "completed",
|
|
1226
1227
|
Failed: "failed",
|
|
1227
1228
|
Error: "error"
|
|
1228
|
-
},
|
|
1229
|
+
}, Pe = {
|
|
1229
1230
|
Progress: "progress",
|
|
1230
1231
|
StatusChange: "status-change",
|
|
1231
1232
|
Completed: "completed",
|
|
1232
1233
|
Failed: "failed",
|
|
1233
1234
|
Error: "error"
|
|
1234
|
-
},
|
|
1235
|
+
}, we = {
|
|
1235
1236
|
Progress: "progress",
|
|
1236
1237
|
StatusChange: "status-change",
|
|
1237
1238
|
Completed: "completed",
|
|
1238
1239
|
Failed: "failed",
|
|
1239
1240
|
Error: "error"
|
|
1240
|
-
},
|
|
1241
|
+
}, be = {
|
|
1241
1242
|
Progress: "progress",
|
|
1242
1243
|
StatusChange: "status-change",
|
|
1243
1244
|
Completed: "completed",
|
|
@@ -1246,28 +1247,28 @@ const De = {
|
|
|
1246
1247
|
};
|
|
1247
1248
|
export {
|
|
1248
1249
|
Tt as ApiNamespace,
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1250
|
+
be as BridgeEvent,
|
|
1251
|
+
we as DeployEvent,
|
|
1252
|
+
Te as DepositEvent,
|
|
1252
1253
|
Zt as LombardSDK,
|
|
1253
|
-
|
|
1254
|
+
xe as RedeemEvent,
|
|
1254
1255
|
G as SolanaActions,
|
|
1255
|
-
|
|
1256
|
+
Ne as StakeEvent,
|
|
1256
1257
|
K as StarknetActions,
|
|
1257
1258
|
j as SuiActions,
|
|
1258
|
-
|
|
1259
|
+
Pe as UnstakeEvent,
|
|
1259
1260
|
kt as createConfig,
|
|
1260
1261
|
Nt as createConsoleLogger,
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1262
|
+
Ee as createLombardSDK,
|
|
1263
|
+
pe as createSilentLogger,
|
|
1264
|
+
me as getSdkHeaders,
|
|
1265
|
+
Ie as isBtcProvider,
|
|
1266
|
+
Ae as isEvmProvider,
|
|
1267
|
+
Se as isSolanaProvider,
|
|
1268
|
+
De as isStarknetProvider,
|
|
1269
|
+
_e as isSuiProvider,
|
|
1270
|
+
ve as solanaActions,
|
|
1271
|
+
Ce as starknetActions,
|
|
1272
|
+
fe as suiActions
|
|
1272
1273
|
};
|
|
1273
|
-
//# sourceMappingURL=events-
|
|
1274
|
+
//# sourceMappingURL=events-BP_Ahnsm.js.map
|