@lombard.finance/sdk 2.0.14 → 2.0.15
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/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/sdk/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.stories.tsx +34 -5
- package/src/sdk/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.ts +10 -2
- package/src/sdk/storeStakeAndBakeSignature/storeStakeAndBakeSignature.stories.tsx +37 -22
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/common/types/types.ts","../src/common/const.ts","../src/sdk/apiConfig.ts","../src/common/utils/getErrorMessage.ts","../src/sdk/internalTypes.ts","../src/sdk/utils/getChainNameById.ts","../src/sdk/generateDepositBtcAddress/generateDepositBtcAddress.ts","../src/sdk/getDepositBtcAddress/getDepositBtcAddress.ts","../src/common/utils/convertSatoshi.ts","../src/sdk/utils/getChainIdByName.ts","../src/sdk/getDepositsByAddress/getDepositsByAddress.ts","../src/sdk/const.ts","../src/sdk/getLBTCExchangeRate/getLBTCExchangeRate.ts","../src/sdk/getNetworkFeeSignature/getNetworkFeeSignature.ts","../src/sdk/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.ts","../src/sdk/storeNetworkFeeSignature/storeNetworkFeeSignature.ts","../src/sdk/storeStakeAndBakeSignature/storeStakeAndBakeSignature.ts","../src/provider/rpcUrlConfig.ts","../src/provider/utils/getMaxPriorityFeePerGas.ts","../src/provider/ReadProvider.ts","../src/provider/Provider.ts","../src/web3Sdk/utils/getGasMultiplier.ts","../src/common/utils/isValidChain.ts","../src/web3Sdk/lbtcAddressConfig.ts","../src/web3Sdk/utils/getTokenABI.ts","../src/web3Sdk/utils/getLbtcTokenContract.ts","../src/web3Sdk/claimLBTC/claimLBTC.ts","../../../node_modules/web3-errors/lib/esm/error_codes.js","../../../node_modules/web3-errors/lib/esm/web3_error_base.js","../../../node_modules/web3-errors/lib/esm/errors/rpc_error_messages.js","../../../node_modules/web3-errors/lib/esm/errors/rpc_errors.js","../../../node_modules/web3-validator/lib/esm/validation/string.js","../../../node_modules/web3-types/lib/esm/data_format_types.js","../../../node_modules/web3-types/lib/esm/eth_types.js","../src/web3Sdk/utils/getBasculeTokenContract.ts","../src/web3Sdk/getBasculeDepositStatus/getBasculeDepositStatus.ts","../src/web3Sdk/utils/chainIdToEnv.ts","../src/web3Sdk/utils/getRpcUrlConfigFromChain.ts","../src/web3Sdk/getLBTCMintingFee/getLBTCMintingFee.tsx","../src/web3Sdk/signLbtcDestionationAddr/signLbtcDestionationAddr.ts","../src/web3Sdk/const.ts","../src/web3Sdk/signNetworkFee/getTypedData.ts","../src/web3Sdk/signNetworkFee/signNetworkFee.ts","../src/web3Sdk/signStakeAndBake/contracts.ts","../src/web3Sdk/getPermitNonce/getPermitNonce.ts","../src/web3Sdk/signStakeAndBake/getTypedData.ts","../src/web3Sdk/signStakeAndBake/utils.ts","../src/web3Sdk/signStakeAndBake/signStakeAndBake.ts","../src/web3Sdk/signStakeAndBake/config.ts"],"sourcesContent":["export const OEnv = {\n prod: 'prod',\n testnet: 'testnet',\n stage: 'stage',\n} as const;\n\nexport type TEnv = (typeof OEnv)[keyof typeof OEnv];\n\nexport const OChainId = {\n ethereum: 1,\n holesky: 17000,\n binanceSmartChain: 56,\n binanceSmartChainTestnet: 97,\n sepolia: 11155111,\n base: 8453,\n baseTestnet: 84532,\n berachainBartioTestnet: 80084,\n\n corn: 21000000,\n swell: 1923,\n} as const;\n\nexport type TChainId = (typeof OChainId)[keyof typeof OChainId];\n\nexport type TOFTChainId =\n | (typeof OChainId)['berachainBartioTestnet']\n | (typeof OChainId)['sepolia']\n | (typeof OChainId)['corn']\n | (typeof OChainId)['ethereum']\n | (typeof OChainId)['swell'];\n\n/**\n * Abstract EIP-1193 provider\n */\nexport interface IEIP1193Provider {\n request: (args: any) => Promise<any>;\n}\n\nexport const getEthNetworkByEnv = (env: TEnv) =>\n env === OEnv.prod ? OChainId.ethereum : OChainId.holesky;\n\nexport const getBscNetworkByEnv = (env: TEnv) =>\n env === OEnv.prod\n ? OChainId.binanceSmartChain\n : OChainId.binanceSmartChainTestnet;\n\nexport const getBaseNetworkByEnv = (env: TEnv) =>\n env === OEnv.prod ? OChainId.base : OChainId.baseTestnet;\n","import { OEnv, TEnv } from './types/types';\n\nexport const defaultEnv: TEnv = OEnv.prod;\n\n/**\n * Address of the zero account.\n * Can also be used as a placeholder for unknown addresses.\n */\nexport const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';\n","import { defaultEnv } from '../common/const';\nimport { OEnv, TEnv } from '../common/types/types';\n\ninterface IApiConfig {\n baseApiUrl: string;\n}\n\nconst stageConfig: IApiConfig = {\n baseApiUrl: 'https://staging.prod.lombard.finance',\n};\n\nconst testnetConfig: IApiConfig = {\n baseApiUrl: 'https://gastald-testnet.prod.lombard.finance',\n};\n\nconst prodConfig: IApiConfig = {\n baseApiUrl: 'https://mainnet.prod.lombard.finance',\n};\n\nexport const getApiConfig = (env: TEnv = defaultEnv): IApiConfig => {\n switch (env) {\n case OEnv.prod:\n return prodConfig;\n case OEnv.testnet:\n return testnetConfig;\n default:\n return stageConfig;\n }\n};\n","import { AxiosError } from 'axios';\n\n/**\n * Retrieves the error message from the given error object.\n *\n * @param error - The error object.\n * @returns The error message as a string.\n */\nexport function getErrorMessage(error: unknown): string {\n if (typeof error === 'string') {\n return error;\n }\n\n const hasDataMessage = (err: any): err is { data: { message: string } } =>\n err?.data?.message && typeof err.data.message === 'string';\n\n if (hasDataMessage(error)) {\n return error.data.message;\n }\n\n if (error instanceof Error) {\n return getAxiosErrorMessage(error as AxiosError);\n }\n\n return getErrorMessageFromObject(error);\n}\n\nfunction getAxiosErrorMessage(error: AxiosError): string {\n if (error.response) {\n return (error.response.data as { message: string }).message;\n }\n\n return error.message;\n}\n\nfunction getErrorMessageFromObject(error: any): string {\n if (error?.message) {\n return error.message;\n }\n\n return 'Unknown error';\n}\n","export const OChainName = {\n eth: 'DESTINATION_BLOCKCHAIN_ETHEREUM',\n base: 'DESTINATION_BLOCKCHAIN_BASE',\n bsc: 'DESTINATION_BLOCKCHAIN_BSC',\n mantle: 'DESTINATION_BLOCKCHAIN_MANTLE',\n linea: 'DESTINATION_BLOCKCHAIN_LINEA',\n zcircuit: 'DESTINATION_BLOCKCHAIN_ZIRCUIT',\n scroll: 'DESTINATION_BLOCKCHAIN_SCROLL',\n xlayer: 'DESTINATION_BLOCKCHAIN_XLAYER',\n} as const;\n\nexport type TChainName = (typeof OChainName)[keyof typeof OChainName];\n","import { OChainId, TChainId } from '../../common/types/types';\nimport { OChainName, TChainName } from '../internalTypes';\n\n/**\n * @param chainId the chain ID\n *\n * @returns the chain name\n */\nexport function getChainNameById(chainId: TChainId): TChainName {\n switch (chainId) {\n case OChainId.ethereum:\n case OChainId.holesky:\n case OChainId.sepolia:\n return OChainName.eth;\n case OChainId.base:\n case OChainId.baseTestnet:\n return OChainName.base;\n case OChainId.binanceSmartChain:\n case OChainId.binanceSmartChainTestnet:\n return OChainName.bsc;\n default:\n throw new Error(`Unknown chain ID: ${chainId}`);\n }\n}\n","import axios from 'axios';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { TChainId } from '../../common/types/types';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { getApiConfig } from '../apiConfig';\nimport { getChainNameById } from '../utils/getChainNameById';\n\n/**\n * The address wich will be returned if the provided EVM address is sanctioned.\n */\nexport const SANCTIONED_ADDRESS = 'sanctioned_address';\nconst ADDRESS_URL = 'api/v1/address/generate';\nconst SANCTIONS_MESSAGE = 'destination address is under sanctions';\n\ninterface IGenerateNewAddressResponse {\n address: string;\n}\n\nexport interface IGenerateDepositBtcAddressParams extends IEnvParam {\n /**\n * The destination EVM user address where LBTC will be claimed.\n */\n address: string;\n /**\n * The destination chain ID where LBTC will be claimed.\n */\n chainId: TChainId;\n /**\n * The signature of the address. The signature is generated by signing the address using EVM wallet.\n */\n signature: 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 captcha token.\n */\n captchaToken?: string;\n /**\n * The referrer code.\n */\n referrerCode?: string;\n /**\n * The referral ID.\n */\n partnerId?: string;\n}\n\n/**\n * Generates a BTC deposit address.\n *\n * If the provided EVM address is sanctioned, the function will return the `SANCTIONED_ADDRESS`.\n *\n * @param {IGenerateDepositBtcAddressParams} params - The parameters for generating the deposit address.\n * @returns {Promise<string>} The generated deposit address.\n */\nexport async function generateDepositBtcAddress({\n address,\n chainId,\n signature,\n eip712Data,\n env,\n referrerCode,\n partnerId,\n captchaToken,\n}: IGenerateDepositBtcAddressParams): Promise<string> {\n const { baseApiUrl } = getApiConfig(env);\n const toChain = getChainNameById(chainId);\n\n const requestParams = {\n to_address: address,\n to_address_signature: signature,\n to_chain: toChain,\n partner_id: partnerId,\n nonce: 0,\n captcha: captchaToken,\n referrer_code: referrerCode,\n eip_712_data: eip712Data,\n };\n\n try {\n const { data } = await axios.post<IGenerateNewAddressResponse>(\n ADDRESS_URL,\n requestParams,\n { baseURL: baseApiUrl },\n );\n\n return data.address;\n } catch (error) {\n const errorMsg = getErrorMessage(error);\n\n if (isSanctioned(errorMsg)) {\n return SANCTIONED_ADDRESS;\n } else {\n throw new Error(errorMsg);\n }\n }\n}\n\nfunction isSanctioned(errorMsg: string): boolean {\n return !!errorMsg.includes(SANCTIONS_MESSAGE);\n}\n","import axios from 'axios';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { TChainId } from '../../common/types/types';\nimport { getApiConfig } from '../apiConfig';\nimport { TChainName } from '../internalTypes';\nimport { getChainNameById } from '../utils/getChainNameById';\n\nconst ADDRESS_URL = 'api/v1/address';\n\ntype TPartnerId = 'lombard' | string;\n\ninterface IDepositAddress {\n btc_address: string;\n created_at: string;\n deprecated?: boolean;\n type: string;\n used?: boolean;\n deposit_metadata: {\n referral: TPartnerId;\n partner_id: TPartnerId;\n to_address: string;\n to_blockchain: TChainName;\n };\n}\n\ninterface IDepositAddressesResponse {\n addresses: IDepositAddress[];\n has_more?: boolean;\n}\n\nexport interface IGetDepositBtcAddressParams extends IEnvParam {\n /**\n * The destination EVM user address where LBTC will be claimed.\n */\n address: string;\n /**\n * The destination chain ID where LBTC will be claimed.\n */\n chainId: TChainId;\n /**\n * The referral ID.\n */\n partnerId: TPartnerId;\n}\n\n/**\n * Returns the address for depositing BTC.\n *\n * @param {IGetDepositBtcAddressParams} params - function parameters\n *\n * @returns {Promise<string>} the address for depositing BTC\n */\nexport async function getDepositBtcAddress({\n address,\n chainId,\n env,\n partnerId,\n}: IGetDepositBtcAddressParams): Promise<string> {\n const addresses = await getDepositBtcAddresses({\n address,\n chainId,\n env,\n partnerId,\n });\n\n const addressData = getActualAddress(addresses);\n\n if (!addressData) {\n throw new Error('No address');\n }\n\n return addressData.btc_address;\n}\n\n/**\n * Retrieves the actual deposit address from a list of deposit addresses.\n *\n * @param addresses - The list of deposit addresses.\n * @returns The actual deposit address or undefined if the last created address is deprecated.\n */\nfunction getActualAddress(\n addresses: IDepositAddress[],\n): IDepositAddress | undefined {\n if (!addresses.length) {\n return undefined;\n }\n\n const actualAddress = addresses.reduce((acc, address) => {\n if (acc.created_at < address.created_at) {\n return address;\n }\n return acc;\n }, addresses[0]);\n\n return actualAddress.deprecated ? undefined : actualAddress;\n}\n\n/**\n * Returns the addresses for depositing BTC.\n *\n * @param {IGetDepositBtcAddressParams} params - function parameters\n *\n * @returns {Promise<IDepositAddress[]>} the deposit addresses\n */\nexport async function getDepositBtcAddresses({\n address,\n chainId,\n env,\n partnerId,\n}: IGetDepositBtcAddressParams): Promise<IDepositAddress[]> {\n const { baseApiUrl } = getApiConfig(env);\n const toBlockchain = getChainNameById(chainId);\n\n const requestrParams = {\n to_address: address,\n to_blockchain: toBlockchain,\n limit: 1,\n offset: 0,\n asc: false,\n referralId: partnerId,\n };\n\n const { data } = await axios.get<IDepositAddressesResponse>(ADDRESS_URL, {\n baseURL: baseApiUrl,\n params: requestrParams,\n });\n\n return data?.addresses || [];\n}\n","const BTC_DECIMALS = 8;\nexport const SATOSHI_SCALE = 10 ** BTC_DECIMALS;\n\n/**\n * Convert Satoshi to BTC\n * @param amount - Satoshi amount\n * @returns BTC amount\n */\nexport function fromSatoshi(amount: number | string) {\n return +amount / SATOSHI_SCALE;\n}\n\n/**\n * Convert BTC to Satoshi\n *\n * @param amount - BTC amount\n * @returns Satoshi amount\n */\nexport function toSatoshi(amount: number | string) {\n return Math.floor(+amount * SATOSHI_SCALE);\n}\n","import { defaultEnv } from '../../common/const';\nimport {\n getBaseNetworkByEnv,\n getBscNetworkByEnv,\n getEthNetworkByEnv,\n OChainId,\n TChainId,\n TEnv,\n} from '../../common/types/types';\nimport { OChainName, TChainName } from '../internalTypes';\n\n/**\n * @param chainId the chain ID\n *\n * @returns the chain name\n */\nexport function getChainIdByName(\n chain: string,\n env: TEnv = defaultEnv,\n): TChainId {\n switch (chain as TChainName) {\n case OChainName.eth:\n return getEthNetworkByEnv(env);\n case OChainName.base:\n return getBaseNetworkByEnv(env);\n case OChainName.bsc:\n return getBscNetworkByEnv(env);\n\n default:\n return OChainId.ethereum;\n }\n}\n","import axios from 'axios';\nimport BigNumber from 'bignumber.js';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { TChainId, TEnv } from '../../common/types/types';\nimport { fromSatoshi } from '../../common/utils/convertSatoshi';\nimport { getApiConfig } from '../apiConfig';\nimport { getChainIdByName } from '../utils/getChainIdByName';\n\ntype Address = string;\ntype Seconds = number;\n\nexport enum ENotarizationStatus {\n NOTARIZATION_STATUS_UNSPECIFIED = 'NOTARIZATION_STATUS_UNSPECIFIED',\n // actually initial status for a deposit tx\n NOTARIZATION_STATUS_PENDING = 'NOTARIZATION_STATUS_PENDING',\n // the deposit was sent to the notarization\n NOTARIZATION_STATUS_SUBMITTED = 'NOTARIZATION_STATUS_SUBMITTED',\n // notarization was approved\n NOTARIZATION_STATUS_SESSION_APPROVED = 'NOTARIZATION_STATUS_SESSION_APPROVED',\n // notarization was failed\n NOTARIZATION_STATUS_FAILED = 'NOTARIZATION_STATUS_FAILED',\n}\n\nexport enum ESessionState {\n SESSION_STATE_UNSPECIFIED = 'SESSION_STATE_UNSPECIFIED',\n SESSION_STATE_PENDING = 'SESSION_STATE_PENDING',\n SESSION_STATE_COMPLETED = 'SESSION_STATE_COMPLETED',\n SESSION_STATE_EXPIRED = 'SESSION_STATE_EXPIRED',\n}\n\ninterface IDepositResponse {\n txid: string;\n value: number;\n address: Address;\n to_chain: string;\n notarization_wait_dur?: string | number;\n index?: number;\n raw_payload?: string;\n payload_hash?: string;\n proof?: string;\n claim_tx?: string; // tx on the destination chain\n block_height?: string;\n block_time?: string;\n sanctioned?: boolean;\n\n session_id: number;\n notarization_status: ENotarizationStatus;\n session_state: ESessionState;\n}\n\ninterface IDepositsByAddressResponse {\n outputs: IDepositResponse[];\n}\n\nexport interface IDeposit {\n txid: string;\n index?: number;\n blockHeight?: number;\n blockTime?: number;\n value: BigNumber;\n address: Address;\n chainId: TChainId;\n isClaimed?: boolean;\n claimedTxId?: string;\n rawPayload?: string;\n signature?: string;\n isRestricted?: boolean;\n notarizationWaitDur?: Seconds;\n // bascule hash id\n payload?: string;\n\n sessionId: number;\n notarizationStatus: ENotarizationStatus;\n sessionState: ESessionState;\n fromChainId?: TChainId;\n toChainId?: TChainId;\n status?: string;\n}\n\nexport interface IGetDepositsByAddressParams extends IEnvParam {\n /**\n * The EVM address to get deposits for\n */\n address: Address;\n}\n\n/**\n * Returns all deposits for a given address\n *\n * @param {IGetDepositsByAddressParams} params\n *\n * @returns {Promise<IDeposit[]>} a list of deposits\n */\nexport async function getDepositsByAddress({\n address,\n env,\n}: IGetDepositsByAddressParams): Promise<IDeposit[]> {\n const { baseApiUrl } = getApiConfig(env);\n\n const { data } = await axios.get<IDepositsByAddressResponse | undefined>(\n `api/v1/address/outputs-v2/${address}`,\n { baseURL: baseApiUrl },\n );\n\n const outputs = data?.outputs ?? [];\n\n return outputs.map(mapResponse(env));\n}\n\nfunction mapResponse(env?: TEnv) {\n return (data: IDepositResponse): IDeposit => ({\n txid: data.txid,\n index: data.index ?? 0,\n blockHeight: data.block_height ? Number(data.block_height) : undefined,\n blockTime: data.block_time ? Number(data.block_time) : undefined,\n value: new BigNumber(fromSatoshi(data.value)),\n address: data.address,\n chainId: getChainIdByName(data.to_chain, env),\n claimedTxId: data.claim_tx,\n rawPayload: data.raw_payload,\n signature: data.proof,\n isRestricted: !!data.sanctioned,\n notarizationWaitDur: data.notarization_wait_dur\n ? Number(data.notarization_wait_dur)\n : undefined,\n payload: data.payload_hash,\n sessionId: data.session_id,\n notarizationStatus: data.notarization_status,\n sessionState: data.session_state,\n });\n}\n","export const MIN_STAKE_AMOUNT_BTC = 0.0002;\n","import axios from 'axios';\nimport BigNumber from 'bignumber.js';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { OChainId, TChainId } from '../../common/types/types';\nimport { SATOSHI_SCALE } from '../../common/utils/convertSatoshi';\nimport { getApiConfig } from '../apiConfig';\nimport { MIN_STAKE_AMOUNT_BTC } from '../const';\nimport { getChainNameById } from '../utils/getChainNameById';\n\ntype ExchangeRateResponse = {\n amount_out: string;\n};\n\nexport interface IgetLBTCExchangeRateParams extends IEnvParam {\n /**\n * The chain id of the asset to get the exchange rate for. Exchange rate is the same for all chains so this param is optional.\n *\n * @default OChainId.ethereum\n */\n chainId?: TChainId;\n /**\n * The amount of the asset to get the exchange rate for. If not provided, the exchange rate will be returned for 1 BTC.\n *\n * @default 1\n */\n amount?: number;\n}\n\nexport interface IgetLBTCExchangeRateResponse {\n /**\n * The exchange rate for LBTC:BTC\n */\n exchangeRate: number;\n /**\n * The minimum amount of the asset to stake\n */\n minAmount: number;\n}\n\n/**\n * Retrieves the exchange rate for LBTC.\n *\n * @param {IgetLBTCExchangeRateParams} params\n *\n * @returns {Promise<IgetLBTCExchangeRateResponse>} - The exchange rate.\n */\nexport async function getLBTCExchangeRate({\n env,\n chainId = OChainId.ethereum,\n amount = 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 minAmount = new BigNumber(MIN_STAKE_AMOUNT_BTC)\n .multipliedBy(SATOSHI_SCALE)\n .toFixed();\n\n return { exchangeRate: +data.amount_out, minAmount: +minAmount };\n}\n","import axios from 'axios';\n\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { getApiConfig } from '../apiConfig';\n\nexport interface IGetNetworkFeeSignatureParams extends IEnvParam {\n /**\n * Chain ID of the network to interact with\n */\n chainId: number;\n /**\n * Destination address\n */\n address: string;\n}\n\ninterface IGetNetworkFeeSignatureResponse {\n /**\n * Expiration date of signature\n */\n expiration_date: string;\n /**\n * The flag signature exists\n */\n has_signature: boolean;\n /**\n * The auto mint is delayed\n */\n is_delayed: boolean;\n}\n\nexport interface IGetNetworkFeeSignatureMappedResponse {\n /**\n * Expiration date of signature\n */\n expirationDate: string;\n /**\n * The flag signature exists\n */\n hasSignature: boolean;\n /**\n * The auto mint is delayed\n */\n isDelayed: boolean;\n}\n\n/**\n * Returns the expiration date and the flag signature exists\n *\n * @returns {Promise<IGetNetworkFeeSignatureResponse>} authorize network fee sign promise\n */\nexport async function getNetworkFeeSignature({\n address,\n chainId,\n env,\n}: IGetNetworkFeeSignatureParams): Promise<IGetNetworkFeeSignatureMappedResponse> {\n const { baseApiUrl } = getApiConfig(env);\n\n try {\n const { data } = await axios.get<IGetNetworkFeeSignatureResponse>(\n `${baseApiUrl}/api/v1/claimer/get-user-signature`,\n {\n params: {\n user_destination_address: address,\n chain_id: chainId,\n },\n },\n );\n\n return {\n expirationDate: data?.expiration_date,\n hasSignature: data?.has_signature,\n isDelayed: data?.is_delayed,\n };\n } catch (error) {\n const errorMessage = getErrorMessage(error);\n\n throw new Error(errorMessage);\n }\n}\n","import axios from 'axios';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { TChainId } from '../../common/types/types';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { getApiConfig } from '../apiConfig';\n\nexport interface IGetUserStakeAndBakeSignatureParams extends IEnvParam {\n /**\n * User's destination address\n */\n userDestinationAddress: string;\n /**\n * Chain ID\n */\n chainId: TChainId;\n}\n\nexport interface IGetUserStakeAndBakeSignatureResponse {\n /**\n * The signature\n */\n signature: string;\n /**\n * The typed data used to generate the signature\n */\n typedData: string;\n}\n\n/**\n * Get user's stake and bake signature from the API\n *\n * @param {IGetUserStakeAndBakeSignatureParams} params - Parameters for getting the signature\n * @returns {Promise<IGetUserStakeAndBakeSignatureResponse>} Promise that resolves to the signature response\n */\nexport async function getUserStakeAndBakeSignature({\n userDestinationAddress,\n chainId,\n env,\n}: IGetUserStakeAndBakeSignatureParams): Promise<IGetUserStakeAndBakeSignatureResponse> {\n const { baseApiUrl } = getApiConfig(env);\n\n try {\n const { data } = await axios.get<IGetUserStakeAndBakeSignatureResponse>(\n `${baseApiUrl}/api/v1/claimer/get-user-stake-and-bake-signature`,\n {\n params: {\n userDestinationAddress,\n chainId: chainId.toString(),\n },\n },\n );\n\n return data;\n } catch (error) {\n const errorMessage = getErrorMessage(error);\n throw new Error(\n `Failed to get user stake and bake signature: ${errorMessage}`,\n );\n }\n}\n","import axios from 'axios';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { getApiConfig } from '../apiConfig';\n\nexport type IStoreNetworkFeeSignatureStatus = 'success';\n\ninterface IStoreNetworkFeeSignatureResponse {\n status: IStoreNetworkFeeSignatureStatus;\n}\n\nexport interface IStoreNetworkFeeSignatureParams extends IEnvParam {\n /**\n * signature\n */\n signature: string;\n /**\n * JSON typed data used for the signature\n */\n typedData: string;\n /**\n * Destination address\n */\n address: string;\n}\n\n/**\n * Authorize network fee\n *\n * @param {IStoreNetworkFeeSignatureParams} params - The parameters for network fee authorization\n *\n * @returns {Promise<IStoreNetworkFeeSignatureResponse>} Response promise with statuses\n *\n */\nexport async function storeNetworkFeeSignature({\n signature,\n typedData,\n address,\n env,\n}: IStoreNetworkFeeSignatureParams): Promise<IStoreNetworkFeeSignatureStatus> {\n const { baseApiUrl } = getApiConfig(env);\n\n try {\n const { data } = await axios.post<IStoreNetworkFeeSignatureResponse>(\n `${baseApiUrl}/api/v1/claimer/save-user-signature`,\n null,\n {\n params: {\n typed_data: typedData,\n signature,\n user_destination_address: address,\n },\n },\n );\n\n return data.status;\n } catch (error) {\n const errorMsg = getErrorMessage(error);\n\n throw new Error(errorMsg);\n }\n}\n","import axios from 'axios';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { getApiConfig } from '../apiConfig';\n\nexport type IStoreStakeAndBakeSignatureStatus = 'success';\n\ninterface IStoreStakeAndBakeSignatureResponse {\n status: IStoreStakeAndBakeSignatureStatus;\n}\n\nexport interface IStoreStakeAndBakeSignatureParams extends IEnvParam {\n /**\n * signature\n */\n signature: string;\n /**\n * JSON typed data used for the signature\n */\n typedData: string;\n}\n\n/**\n * Store stake and bake signature\n *\n * @param {IStoreStakeAndBakeSignatureParams} params - The parameters for storing stake and bake signature\n *\n * @returns {Promise<IStoreStakeAndBakeSignatureStatus>} Response promise with status\n *\n */\nexport async function storeStakeAndBakeSignature({\n signature,\n typedData,\n env,\n}: IStoreStakeAndBakeSignatureParams): Promise<IStoreStakeAndBakeSignatureStatus> {\n const { baseApiUrl } = getApiConfig(env);\n\n try {\n const { data } = await axios.post<IStoreStakeAndBakeSignatureResponse>(\n `${baseApiUrl}/api/v1/claimer/save-stake-and-bake-signature`,\n null,\n {\n params: {\n typed_data: typedData,\n signature,\n },\n },\n );\n\n return data.status;\n } catch (error) {\n const errorMsg = getErrorMessage(error);\n\n throw new Error(errorMsg);\n }\n}","import { OChainId } from '../common/types/types';\n\nexport type TRpcUrlConfig = Record<number, string>;\n\nexport const rpcUrlConfig: TRpcUrlConfig = {\n [OChainId.ethereum]: 'https://rpc.ankr.com/eth',\n [OChainId.holesky]: 'https://rpc.ankr.com/eth_holesky',\n [OChainId.sepolia]: 'https://rpc.ankr.com/eth_sepolia',\n [OChainId.base]: 'https://rpc.ankr.com/base',\n [OChainId.baseTestnet]: 'https://rpc.ankr.com/base_sepolia',\n [OChainId.binanceSmartChain]: 'https://rpc.ankr.com/bsc',\n [OChainId.binanceSmartChainTestnet]:\n 'https://rpc.ankr.com/bsc_testnet_chapel',\n};\n","import BigNumber from 'bignumber.js';\nimport Web3 from 'web3';\n\nexport async function getMaxPriorityFeePerGas(\n rpcUrl: string,\n): Promise<BigNumber> {\n const response = await fetch(rpcUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: 1,\n method: 'eth_maxPriorityFeePerGas',\n params: [],\n }),\n });\n\n const data = await response.json();\n\n const convertedHexValue = Web3.utils.hexToNumber(data?.result);\n\n return new BigNumber(Number(convertedHexValue));\n}\n","import BigNumber from 'bignumber.js';\nimport { Web3, Contract, ContractAbi } from 'web3';\nimport {\n TRpcUrlConfig,\n rpcUrlConfig as defaultRpcUrlConfig,\n} from './rpcUrlConfig';\nimport { IGetMaxFeesResult } from './types';\nimport { getMaxPriorityFeePerGas } from './utils/getMaxPriorityFeePerGas';\n\nconst FEE_MULTIPLIER = 2;\nconst ADDITIONAL_SAFE_GAS_PRICE_WEI = 25_000;\n\nexport interface IReadProviderParams {\n /**\n * Chain ID of the network to interact with.\n */\n chainId: number;\n /**\n * The RPC URL configuration. If not provided, the default configuration will be used.\n */\n rpcUrlConfig?: TRpcUrlConfig;\n}\n\nexport class ReadProvider {\n chainId: number;\n rpcConfig: TRpcUrlConfig;\n\n constructor({ chainId, rpcUrlConfig }: IReadProviderParams) {\n this.chainId = chainId;\n this.rpcConfig = { ...defaultRpcUrlConfig, ...rpcUrlConfig };\n }\n\n /**\n * Returns web3 instance for read operations.\n *\n * @public\n * @returns {Web3} Web3 instance.\n */\n public getReadWeb3(): Web3 {\n const rpcUrl = this.getRpcUrl();\n const readWeb3 = new Web3();\n const provider = new Web3.providers.HttpProvider(rpcUrl);\n readWeb3.setProvider(provider);\n return readWeb3;\n }\n\n /**\n * Retrieves the RPC URL based on the current chain ID.\n * @returns The RPC URL for the current chain ID.\n * @throws Error if the RPC URL for the current chain ID is not found.\n */\n getRpcUrl(): string {\n const { chainId } = this;\n const rpcUrl = this.rpcConfig?.[chainId];\n\n if (!rpcUrl) {\n console.error(\n `You might need to add the rpcConfig for the ${chainId} chain ID when creating the provider.`,\n );\n throw new Error(`RPC URL for chainId ${chainId} not found`);\n }\n\n return rpcUrl;\n }\n\n /**\n * Calculates max fees for transaction. Thess values are available for networks\n * with EIP-1559 support.\n *\n * @public\n * @note If current network is Binance Smart Chain, will return default values.\n * @returns {Promise<IGetMaxFeesResult>} Max fees for transaction.\n */\n public async getMaxFees(): Promise<IGetMaxFeesResult> {\n const web3 = this.getReadWeb3();\n const rpcUrl = this.getRpcUrl();\n\n const [block, maxPriorityFeePerGas] = await Promise.all([\n web3.eth.getBlock('latest'),\n getMaxPriorityFeePerGas(rpcUrl),\n ]);\n\n if (!block?.baseFeePerGas && typeof block?.baseFeePerGas !== 'bigint') {\n return {};\n }\n\n const maxFeePerGas = new BigNumber(block.baseFeePerGas.toString(10))\n .multipliedBy(FEE_MULTIPLIER)\n .plus(maxPriorityFeePerGas);\n\n return {\n maxFeePerGas: +maxFeePerGas,\n maxPriorityFeePerGas: +maxPriorityFeePerGas,\n };\n }\n\n /**\n * Returns safe gas price for transaction.\n *\n * @public\n * @returns {Promise<BigNumber>} Safe gas price.\n */\n public async getSafeGasPriceWei(): Promise<BigNumber> {\n const pureGasPriceWei = await this.getReadWeb3().eth.getGasPrice();\n\n return new BigNumber(pureGasPriceWei.toString(10)).plus(\n ADDITIONAL_SAFE_GAS_PRICE_WEI,\n );\n }\n\n /**\n * Creates a contract instance with the given ABI and address.\n *\n * @template AbiType - The type of the contract ABI.\n * @param {any} abi - The ABI of the contract.\n * @param {string} address - The address of the contract.\n * @returns {Contract<AbiType>} The contract instance.\n */\n public createContract<AbiType extends ContractAbi>(\n abi: any,\n address: string,\n ): Contract<AbiType> {\n const web3 = this.getReadWeb3();\n return new web3.eth.Contract<AbiType>(abi, address);\n }\n}\n","import Web3, { Contract, ContractAbi, Transaction, utils } from 'web3';\nimport { IEIP1193Provider } from '../common/types/types';\nimport { IReadProviderParams, ReadProvider } from './ReadProvider';\nimport {\n TRpcUrlConfig,\n rpcUrlConfig as defaultRpcUrlConfig,\n} from './rpcUrlConfig';\nimport { ISendOptions, IWeb3SendResult } from './types';\n\nexport interface IProviderParams extends IReadProviderParams {\n /**\n * The EIP-1193 provider instance.\n */\n provider: IEIP1193Provider;\n /**\n * The сurrent account address.\n */\n account: string;\n}\n\n/**\n * Provider for interacting with a blockchain network.\n */\nexport class Provider extends ReadProvider {\n web3: Web3;\n account: string;\n rpcConfig: TRpcUrlConfig = defaultRpcUrlConfig;\n\n constructor({ provider, account, chainId, rpcUrlConfig }: IProviderParams) {\n super({ chainId, rpcUrlConfig });\n this.web3 = new Web3(provider);\n this.account = account;\n this.chainId = chainId;\n this.rpcConfig = { ...defaultRpcUrlConfig, ...rpcUrlConfig };\n }\n\n /**\n * Signs a message using the current provider and account.\n * @public\n * @param message - The message to be signed.\n * @returns A promise that resolves to the signed message as a string.\n */\n public async signMessage(message: string): Promise<string> {\n const { account } = this;\n\n const messageHex = `0x${Buffer.from(message, 'utf8').toString('hex')}`;\n\n const ethereum = this.web3.currentProvider as any;\n\n return ethereum.request({\n method: 'personal_sign',\n params: [messageHex, account],\n });\n }\n\n /**\n * Custom replacement for web3js [send](https://docs.web3js.org/libdocs/Contract#send).\n *\n * @public\n * @param {string} from - Address of the sender.\n * @param {string} to - Address of the recipient.\n * @param {ISendOptions} sendOptions - Options for sending transaction.\n * @returns {Promise<IWeb3SendResult>} Promise with transaction hash and receipt promise.\n */\n public async sendTransactionAsync(\n from: string,\n to: string,\n sendOptions: ISendOptions,\n ): Promise<IWeb3SendResult> {\n const { chainId, web3: web3Write } = this;\n const web3Read = this.getReadWeb3();\n\n const {\n data,\n estimate = false,\n estimateFee = false,\n extendedGasLimit,\n gasLimit = '0',\n value = '0',\n gasLimitMultiplier = 1,\n } = sendOptions;\n let { nonce } = sendOptions;\n\n if (!nonce) {\n nonce = await web3Read.eth.getTransactionCount(from);\n }\n\n console.log(`Nonce: ${nonce}`);\n\n const tx: Transaction = {\n from,\n to,\n value: utils.numberToHex(value),\n data,\n nonce,\n chainId: utils.numberToHex(chainId),\n };\n\n if (estimate) {\n try {\n const estimatedGas = await web3Read.eth.estimateGas(tx);\n const multipliedGasLimit = Math.round(\n Number(estimatedGas) * gasLimitMultiplier,\n );\n\n if (extendedGasLimit) {\n tx.gas = utils.numberToHex(multipliedGasLimit + extendedGasLimit);\n } else {\n tx.gas = utils.numberToHex(multipliedGasLimit);\n }\n } catch (e) {\n throw new Error(\n (e as Partial<Error>).message ??\n 'Failed to estimate gas limit for transaction.',\n );\n }\n } else {\n tx.gas = utils.numberToHex(gasLimit);\n }\n\n const { maxFeePerGas, maxPriorityFeePerGas } = estimateFee\n ? await this.getMaxFees().catch(() => sendOptions)\n : sendOptions;\n\n if (maxPriorityFeePerGas !== undefined) {\n tx.maxPriorityFeePerGas = utils.numberToHex(maxPriorityFeePerGas);\n }\n\n if (maxFeePerGas !== undefined) {\n tx.maxFeePerGas = utils.numberToHex(maxFeePerGas);\n }\n\n if (!tx.maxFeePerGas && !tx.maxPriorityFeePerGas) {\n const safeGasPrice = await this.getSafeGasPriceWei();\n tx.gasPrice = safeGasPrice.toString(10);\n }\n\n if (!tx.maxFeePerGas && !tx.maxPriorityFeePerGas) {\n const safeGasPrice = await this.getSafeGasPriceWei();\n tx.gasPrice = safeGasPrice.toString(10);\n }\n\n console.log('Sending transaction via Web3: ', tx);\n\n return new Promise((resolve, reject) => {\n const promise = web3Write.eth.sendTransaction(tx);\n\n promise\n .once('transactionHash', async (transactionHash: string) => {\n console.log(`Just signed transaction has is: ${transactionHash}`);\n\n resolve({\n receiptPromise: promise,\n transactionHash,\n });\n })\n .catch(reject);\n });\n }\n\n public createContract<AbiType extends ContractAbi>(\n abi: any,\n address: string,\n ): Contract<AbiType> {\n return new this.web3.eth.Contract<AbiType>(abi, address);\n }\n}\n","import { OChainId } from '../../common/types/types';\n\n/**\n * Returns the gas multiplier for the given chain ID.\n *\n * @param chainId - Chain ID.\n *\n * @returns Gas multiplier.\n */\nexport function getGasMultiplier(chainId: number): number {\n switch (chainId) {\n case OChainId.ethereum:\n return 1.3;\n case OChainId.holesky:\n case OChainId.sepolia:\n return 1.5;\n default:\n return 1.3;\n }\n}\n","import { OChainId, TChainId } from '../types/types';\n\nexport function isValidChain(chainId: number): chainId is TChainId {\n return Object.values(OChainId).includes(chainId as TChainId);\n}\n","import {\n defaultEnv,\n ZERO_ADDRESS as PLACEHOLDER_ADDRESS,\n} from '../common/const';\nimport { OChainId, OEnv, TChainId, TEnv } from '../common/types/types';\n\ntype LbtcTokenConfig = Record<TChainId, string>;\n\nconst stageConfig: LbtcTokenConfig = {\n [OChainId.holesky]: '0xED7bfd5C1790576105Af4649817f6d35A75CD818',\n [OChainId.ethereum]: PLACEHOLDER_ADDRESS,\n\n [OChainId.binanceSmartChainTestnet]:\n '0x731eFa688F3679688cf60A3993b8658138953ED6',\n [OChainId.binanceSmartChain]: PLACEHOLDER_ADDRESS,\n [OChainId.sepolia]: '0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30',\n\n [OChainId.base]: PLACEHOLDER_ADDRESS,\n // TODO: Add baseTestnet address\n [OChainId.baseTestnet]: PLACEHOLDER_ADDRESS,\n [OChainId.berachainBartioTestnet]:\n '0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30',\n\n [OChainId.corn]: PLACEHOLDER_ADDRESS,\n [OChainId.swell]: PLACEHOLDER_ADDRESS,\n};\n\nconst testnetConfig: LbtcTokenConfig = {\n [OChainId.holesky]: '0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2',\n [OChainId.ethereum]: PLACEHOLDER_ADDRESS,\n\n [OChainId.binanceSmartChainTestnet]:\n '0x107Fc7d90484534704dD2A9e24c7BD45DB4dD1B5',\n [OChainId.binanceSmartChain]: PLACEHOLDER_ADDRESS,\n [OChainId.sepolia]: '0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30',\n\n [OChainId.base]: PLACEHOLDER_ADDRESS,\n [OChainId.baseTestnet]: PLACEHOLDER_ADDRESS,\n [OChainId.berachainBartioTestnet]:\n '0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30',\n\n [OChainId.corn]: PLACEHOLDER_ADDRESS,\n [OChainId.swell]: PLACEHOLDER_ADDRESS,\n};\n\nconst prodConfig: LbtcTokenConfig = {\n [OChainId.ethereum]: '0x8236a87084f8b84306f72007f36f2618a5634494',\n [OChainId.holesky]: PLACEHOLDER_ADDRESS,\n [OChainId.sepolia]: PLACEHOLDER_ADDRESS,\n\n [OChainId.binanceSmartChainTestnet]: PLACEHOLDER_ADDRESS,\n [OChainId.binanceSmartChain]: '0xecAc9C5F704e954931349Da37F60E39f515c11c1',\n\n [OChainId.base]: '0xecAc9C5F704e954931349Da37F60E39f515c11c1',\n [OChainId.baseTestnet]: PLACEHOLDER_ADDRESS,\n\n [OChainId.berachainBartioTestnet]: PLACEHOLDER_ADDRESS,\n\n [OChainId.corn]: '0xecAc9C5F704e954931349Da37F60E39f515c11c1',\n [OChainId.swell]: '0xecAc9C5F704e954931349Da37F60E39f515c11c1',\n};\n\nexport function getLbtcAddressConfig(env: TEnv = defaultEnv): LbtcTokenConfig {\n switch (env) {\n case OEnv.prod:\n return prodConfig;\n case OEnv.testnet:\n return testnetConfig;\n default:\n return stageConfig;\n }\n}\n","import { IERC20, LBTCABI } from '../abi';\n\ntype Token = 'LBTC' | 'ERC20';\n\nexport function getTokenABI(token: Token) {\n switch (token) {\n case 'LBTC':\n return LBTCABI;\n default:\n return IERC20;\n }\n}\n","import { ReadProvider } from '../../provider/ReadProvider';\nimport { TEnv } from '../../common/types/types';\nimport { isValidChain } from '../../common/utils/isValidChain';\nimport { Provider } from '../../provider';\nimport { getLbtcAddressConfig } from '../lbtcAddressConfig';\nimport { getTokenABI } from './getTokenABI';\n\nexport function getLbtcTokenContract(provider: Provider | ReadProvider, env?: TEnv) {\n const lbtcAddressConfig = getLbtcAddressConfig(env);\n const { chainId } = provider;\n\n if (!isValidChain(chainId)) {\n throw new Error(`This chain ${chainId} is not supported`);\n }\n\n const tokenAddress = lbtcAddressConfig[chainId];\n\n if (!tokenAddress) {\n throw new Error(`Token address for chain ${chainId} is not defined`);\n }\n\n const abi = getTokenABI('LBTC');\n\n const contract = provider.createContract(abi, tokenAddress);\n\n if (!contract.options.address) {\n contract.options.address = tokenAddress;\n }\n\n return contract as typeof contract & {\n options: typeof contract.options & { address: string };\n };\n}\n","import { IEnvParam } from '../../common/types/internalTypes';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { IWeb3SendResult, Provider } from '../../provider';\nimport { IProviderBasedParams } from '../types';\nimport { getGasMultiplier } from '../utils/getGasMultiplier';\nimport { getLbtcTokenContract } from '../utils/getLbtcTokenContract';\n\nconst INSUFFICIENT_FUNDS_PARTIAL_ERROR = 'insufficient funds';\n\nconst INSUFFICIENT_FUNDS_ERROR =\n 'Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.';\n\nexport interface IClaimLBTCParams extends IProviderBasedParams, IEnvParam {\n /**\n * Raw payload from deposit notarization.\n */\n data: string;\n /**\n * Signature from deposit notarization.\n */\n proofSignature: string;\n}\n\nconst hexify = (hexString: string) =>\n hexString.startsWith('0x') ? hexString : '0x' + hexString;\n/**\n * Claims LBTC.\n *\n * @param {IClaimLBTCParams} params - The parameters for claiming LBTC.\n *\n * @returns {Promise<IWeb3SendResult>} transaction promise\n */\nexport async function claimLBTC({\n data,\n proofSignature,\n env,\n ...providerParams\n}: IClaimLBTCParams): Promise<IWeb3SendResult> {\n const provider = new Provider(providerParams);\n\n const tokenContract = getLbtcTokenContract(provider, env);\n\n const tx = tokenContract.methods.mint(hexify(data), hexify(proofSignature));\n\n try {\n const result = await provider.sendTransactionAsync(\n provider.account,\n tokenContract.options.address,\n {\n data: tx.encodeABI(),\n // TODO: add getGasOptions from the app for bsc here\n estimate: true,\n estimateFee: true,\n gasLimitMultiplier: getGasMultiplier(provider.chainId),\n },\n );\n\n return result;\n } catch (error) {\n console.log('error', error);\n const errorMessage = getErrorMessage(error);\n\n if (errorMessage.includes(INSUFFICIENT_FUNDS_PARTIAL_ERROR)) {\n throw new Error(INSUFFICIENT_FUNDS_ERROR);\n }\n\n throw new Error(errorMessage);\n }\n}\n","/*\nThis file is part of web3.js.\n\nweb3.js is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nweb3.js is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with web3.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n// Response error\nexport const ERR_RESPONSE = 100;\nexport const ERR_INVALID_RESPONSE = 101;\n// Generic errors\nexport const ERR_PARAM = 200;\nexport const ERR_FORMATTERS = 201;\nexport const ERR_METHOD_NOT_IMPLEMENTED = 202;\nexport const ERR_OPERATION_TIMEOUT = 203;\nexport const ERR_OPERATION_ABORT = 204;\nexport const ERR_ABI_ENCODING = 205;\nexport const ERR_EXISTING_PLUGIN_NAMESPACE = 206;\nexport const ERR_INVALID_METHOD_PARAMS = 207;\nexport const ERR_MULTIPLE_ERRORS = 208;\n// Contract error codes\nexport const ERR_CONTRACT = 300;\nexport const ERR_CONTRACT_RESOLVER_MISSING = 301;\nexport const ERR_CONTRACT_ABI_MISSING = 302;\nexport const ERR_CONTRACT_REQUIRED_CALLBACK = 303;\nexport const ERR_CONTRACT_EVENT_NOT_EXISTS = 304;\nexport const ERR_CONTRACT_RESERVED_EVENT = 305;\nexport const ERR_CONTRACT_MISSING_DEPLOY_DATA = 306;\nexport const ERR_CONTRACT_MISSING_ADDRESS = 307;\nexport const ERR_CONTRACT_MISSING_FROM_ADDRESS = 308;\nexport const ERR_CONTRACT_INSTANTIATION = 309;\nexport const ERR_CONTRACT_EXECUTION_REVERTED = 310;\nexport const ERR_CONTRACT_TX_DATA_AND_INPUT = 311;\n// Transaction error codes\nexport const ERR_TX = 400;\nexport const ERR_TX_REVERT_INSTRUCTION = 401;\nexport const ERR_TX_REVERT_TRANSACTION = 402;\nexport const ERR_TX_NO_CONTRACT_ADDRESS = 403;\nexport const ERR_TX_CONTRACT_NOT_STORED = 404;\nexport const ERR_TX_REVERT_WITHOUT_REASON = 405;\nexport const ERR_TX_OUT_OF_GAS = 406;\nexport const ERR_RAW_TX_UNDEFINED = 407;\nexport const ERR_TX_INVALID_SENDER = 408;\nexport const ERR_TX_INVALID_CALL = 409;\nexport const ERR_TX_MISSING_CUSTOM_CHAIN = 410;\nexport const ERR_TX_MISSING_CUSTOM_CHAIN_ID = 411;\nexport const ERR_TX_CHAIN_ID_MISMATCH = 412;\nexport const ERR_TX_INVALID_CHAIN_INFO = 413;\nexport const ERR_TX_MISSING_CHAIN_INFO = 414;\nexport const ERR_TX_MISSING_GAS = 415;\nexport const ERR_TX_INVALID_LEGACY_GAS = 416;\nexport const ERR_TX_INVALID_FEE_MARKET_GAS = 417;\nexport const ERR_TX_INVALID_FEE_MARKET_GAS_PRICE = 418;\nexport const ERR_TX_INVALID_LEGACY_FEE_MARKET = 419;\nexport const ERR_TX_INVALID_OBJECT = 420;\nexport const ERR_TX_INVALID_NONCE_OR_CHAIN_ID = 421;\nexport const ERR_TX_UNABLE_TO_POPULATE_NONCE = 422;\nexport const ERR_TX_UNSUPPORTED_EIP_1559 = 423;\nexport const ERR_TX_UNSUPPORTED_TYPE = 424;\nexport const ERR_TX_DATA_AND_INPUT = 425;\nexport const ERR_TX_POLLING_TIMEOUT = 426;\nexport const ERR_TX_RECEIPT_MISSING_OR_BLOCKHASH_NULL = 427;\nexport const ERR_TX_RECEIPT_MISSING_BLOCK_NUMBER = 428;\nexport const ERR_TX_LOCAL_WALLET_NOT_AVAILABLE = 429;\nexport const ERR_TX_NOT_FOUND = 430;\nexport const ERR_TX_SEND_TIMEOUT = 431;\nexport const ERR_TX_BLOCK_TIMEOUT = 432;\nexport const ERR_TX_SIGNING = 433;\nexport const ERR_TX_GAS_MISMATCH = 434;\nexport const ERR_TX_CHAIN_MISMATCH = 435;\nexport const ERR_TX_HARDFORK_MISMATCH = 436;\nexport const ERR_TX_INVALID_RECEIVER = 437;\nexport const ERR_TX_REVERT_TRANSACTION_CUSTOM_ERROR = 438;\nexport const ERR_TX_INVALID_PROPERTIES_FOR_TYPE = 439;\nexport const ERR_TX_MISSING_GAS_INNER_ERROR = 440;\nexport const ERR_TX_GAS_MISMATCH_INNER_ERROR = 441;\n// Connection error codes\nexport const ERR_CONN = 500;\nexport const ERR_CONN_INVALID = 501;\nexport const ERR_CONN_TIMEOUT = 502;\nexport const ERR_CONN_NOT_OPEN = 503;\nexport const ERR_CONN_CLOSE = 504;\nexport const ERR_CONN_MAX_ATTEMPTS = 505;\nexport const ERR_CONN_PENDING_REQUESTS = 506;\nexport const ERR_REQ_ALREADY_SENT = 507;\n// Provider error codes\nexport const ERR_PROVIDER = 600;\nexport const ERR_INVALID_PROVIDER = 601;\nexport const ERR_INVALID_CLIENT = 602;\nexport const ERR_SUBSCRIPTION = 603;\nexport const ERR_WS_PROVIDER = 604;\n// Account error codes\nexport const ERR_PRIVATE_KEY_LENGTH = 701;\nexport const ERR_INVALID_PRIVATE_KEY = 702;\nexport const ERR_UNSUPPORTED_KDF = 703;\nexport const ERR_KEY_DERIVATION_FAIL = 704;\nexport const ERR_KEY_VERSION_UNSUPPORTED = 705;\nexport const ERR_INVALID_PASSWORD = 706;\nexport const ERR_IV_LENGTH = 707;\nexport const ERR_INVALID_KEYSTORE = 708;\nexport const ERR_PBKDF2_ITERATIONS = 709;\n// Signature error codes\nexport const ERR_SIGNATURE_FAILED = 801;\nexport const ERR_INVALID_SIGNATURE = 802;\nexport const GENESIS_BLOCK_NUMBER = '0x0';\n// RPC error codes (EIP-1193)\n// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md#provider-errors\nexport const JSONRPC_ERR_REJECTED_REQUEST = 4001;\nexport const JSONRPC_ERR_UNAUTHORIZED = 4100;\nexport const JSONRPC_ERR_UNSUPPORTED_METHOD = 4200;\nexport const JSONRPC_ERR_DISCONNECTED = 4900;\nexport const JSONRPC_ERR_CHAIN_DISCONNECTED = 4901;\n// ENS error codes\nexport const ERR_ENS_CHECK_INTERFACE_SUPPORT = 901;\nexport const ERR_ENS_UNSUPPORTED_NETWORK = 902;\nexport const ERR_ENS_NETWORK_NOT_SYNCED = 903;\n// Utils error codes\nexport const ERR_INVALID_STRING = 1001;\nexport const ERR_INVALID_BYTES = 1002;\nexport const ERR_INVALID_NUMBER = 1003;\nexport const ERR_INVALID_UNIT = 1004;\nexport const ERR_INVALID_ADDRESS = 1005;\nexport const ERR_INVALID_HEX = 1006;\nexport const ERR_INVALID_TYPE = 1007;\nexport const ERR_INVALID_BOOLEAN = 1008;\nexport const ERR_INVALID_UNSIGNED_INTEGER = 1009;\nexport const ERR_INVALID_SIZE = 1010;\nexport const ERR_INVALID_LARGE_VALUE = 1011;\nexport const ERR_INVALID_BLOCK = 1012;\nexport const ERR_INVALID_TYPE_ABI = 1013;\nexport const ERR_INVALID_NIBBLE_WIDTH = 1014;\nexport const ERR_INVALID_INTEGER = 1015;\n// Validation error codes\nexport const ERR_VALIDATION = 1100;\n// Core error codes\nexport const ERR_CORE_HARDFORK_MISMATCH = 1101;\nexport const ERR_CORE_CHAIN_MISMATCH = 1102;\n// Schema error codes\nexport const ERR_SCHEMA_FORMAT = 1200;\n// RPC error codes (EIP-1474)\n// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md\nexport const ERR_RPC_INVALID_JSON = -32700;\nexport const ERR_RPC_INVALID_REQUEST = -32600;\nexport const ERR_RPC_INVALID_METHOD = -32601;\nexport const ERR_RPC_INVALID_PARAMS = -32602;\nexport const ERR_RPC_INTERNAL_ERROR = -32603;\nexport const ERR_RPC_INVALID_INPUT = -32000;\nexport const ERR_RPC_MISSING_RESOURCE = -32001;\nexport const ERR_RPC_UNAVAILABLE_RESOURCE = -32002;\nexport const ERR_RPC_TRANSACTION_REJECTED = -32003;\nexport const ERR_RPC_UNSUPPORTED_METHOD = -32004;\nexport const ERR_RPC_LIMIT_EXCEEDED = -32005;\nexport const ERR_RPC_NOT_SUPPORTED = -32006;\n//# sourceMappingURL=error_codes.js.map","/*\nThis file is part of web3.js.\n\nweb3.js is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nweb3.js is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with web3.js. If not, see <http://www.gnu.org/licenses/>.\n*/\nimport { ERR_MULTIPLE_ERRORS } from './error_codes.js';\n/**\n * Base class for Web3 errors.\n */\nexport class BaseWeb3Error extends Error {\n constructor(msg, cause) {\n super(msg);\n if (Array.isArray(cause)) {\n // eslint-disable-next-line no-use-before-define\n this.cause = new MultipleErrors(cause);\n }\n else {\n this.cause = cause;\n }\n this.name = this.constructor.name;\n if (typeof Error.captureStackTrace === 'function') {\n Error.captureStackTrace(new.target.constructor);\n }\n else {\n this.stack = new Error().stack;\n }\n }\n /**\n * @deprecated Use the `cause` property instead.\n */\n get innerError() {\n // eslint-disable-next-line no-use-before-define\n if (this.cause instanceof MultipleErrors) {\n return this.cause.errors;\n }\n return this.cause;\n }\n /**\n * @deprecated Use the `cause` property instead.\n */\n set innerError(cause) {\n if (Array.isArray(cause)) {\n // eslint-disable-next-line no-use-before-define\n this.cause = new MultipleErrors(cause);\n }\n else {\n this.cause = cause;\n }\n }\n static convertToString(value, unquotValue = false) {\n // Using \"null\" value intentionally for validation\n // eslint-disable-next-line no-null/no-null\n if (value === null || value === undefined)\n return 'undefined';\n const result = JSON.stringify(value, (_, v) => (typeof v === 'bigint' ? v.toString() : v));\n return unquotValue && ['bigint', 'string'].includes(typeof value)\n ? result.replace(/['\\\\\"]+/g, '')\n : result;\n }\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n cause: this.cause,\n // deprecated\n innerError: this.cause,\n };\n }\n}\nexport class MultipleErrors extends BaseWeb3Error {\n constructor(errors) {\n super(`Multiple errors occurred: [${errors.map(e => e.message).join('], [')}]`);\n this.code = ERR_MULTIPLE_ERRORS;\n this.errors = errors;\n }\n}\nexport class InvalidValueError extends BaseWeb3Error {\n constructor(value, msg) {\n super(`Invalid value given \"${BaseWeb3Error.convertToString(value, true)}\". Error: ${msg}.`);\n this.name = this.constructor.name;\n }\n}\n//# sourceMappingURL=web3_error_base.js.map","/*\nThis file is part of web3.js.\n\nweb3.js is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nweb3.js is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with web3.js. If not, see <http://www.gnu.org/licenses/>.\n*/\nimport { ERR_RPC_INTERNAL_ERROR, ERR_RPC_INVALID_INPUT, ERR_RPC_INVALID_JSON, ERR_RPC_INVALID_METHOD, ERR_RPC_INVALID_PARAMS, ERR_RPC_INVALID_REQUEST, ERR_RPC_LIMIT_EXCEEDED, ERR_RPC_MISSING_RESOURCE, ERR_RPC_NOT_SUPPORTED, ERR_RPC_TRANSACTION_REJECTED, ERR_RPC_UNAVAILABLE_RESOURCE, ERR_RPC_UNSUPPORTED_METHOD, JSONRPC_ERR_CHAIN_DISCONNECTED, JSONRPC_ERR_DISCONNECTED, JSONRPC_ERR_REJECTED_REQUEST, JSONRPC_ERR_UNAUTHORIZED, JSONRPC_ERR_UNSUPPORTED_METHOD, } from '../error_codes.js';\n/**\n * A template string for a generic Rpc Error. The `*code*` will be replaced with the code number.\n * Note: consider in next version that a spelling mistake could be corrected for `occured` and the value could be:\n * \t`An Rpc error has occurred with a code of *code*`\n */\nexport const genericRpcErrorMessageTemplate = 'An Rpc error has occured with a code of *code*';\n/* eslint-disable @typescript-eslint/naming-convention */\nexport const RpcErrorMessages = {\n // EIP-1474 & JSON RPC 2.0\n // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md\n [ERR_RPC_INVALID_JSON]: {\n message: 'Parse error',\n description: 'Invalid JSON',\n },\n [ERR_RPC_INVALID_REQUEST]: {\n message: 'Invalid request',\n description: 'JSON is not a valid request object\t',\n },\n [ERR_RPC_INVALID_METHOD]: {\n message: 'Method not found',\n description: 'Method does not exist\t',\n },\n [ERR_RPC_INVALID_PARAMS]: {\n message: 'Invalid params',\n description: 'Invalid method parameters',\n },\n [ERR_RPC_INTERNAL_ERROR]: {\n message: 'Internal error',\n description: 'Internal JSON-RPC error',\n },\n [ERR_RPC_INVALID_INPUT]: {\n message: 'Invalid input',\n description: 'Missing or invalid parameters',\n },\n [ERR_RPC_MISSING_RESOURCE]: {\n message: 'Resource not found',\n description: 'Requested resource not found',\n },\n [ERR_RPC_UNAVAILABLE_RESOURCE]: {\n message: 'Resource unavailable',\n description: 'Requested resource not available',\n },\n [ERR_RPC_TRANSACTION_REJECTED]: {\n message: 'Transaction rejected',\n description: 'Transaction creation failed',\n },\n [ERR_RPC_UNSUPPORTED_METHOD]: {\n message: 'Method not supported',\n description: 'Method is not implemented',\n },\n [ERR_RPC_LIMIT_EXCEEDED]: {\n message: 'Limit exceeded',\n description: 'Request exceeds defined limit',\n },\n [ERR_RPC_NOT_SUPPORTED]: {\n message: 'JSON-RPC version not supported',\n description: 'Version of JSON-RPC protocol is not supported',\n },\n // EIP-1193\n // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md#provider-errors\n [JSONRPC_ERR_REJECTED_REQUEST]: {\n name: 'User Rejected Request',\n message: 'The user rejected the request.',\n },\n [JSONRPC_ERR_UNAUTHORIZED]: {\n name: 'Unauthorized',\n message: 'The requested method and/or account has not been authorized by the user.',\n },\n [JSONRPC_ERR_UNSUPPORTED_METHOD]: {\n name: 'Unsupported Method',\n message: 'The Provider does not support the requested method.',\n },\n [JSONRPC_ERR_DISCONNECTED]: {\n name: 'Disconnected',\n message: 'The Provider is disconnected from all chains.',\n },\n [JSONRPC_ERR_CHAIN_DISCONNECTED]: {\n name: 'Chain Disconnected',\n message: 'The Provider is not connected to the requested chain.',\n },\n // EIP-1193 - CloseEvent\n // https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code\n '0-999': {\n name: '',\n message: 'Not used.',\n },\n 1000: {\n name: 'Normal Closure',\n message: 'The connection successfully completed the purpose for which it was created.',\n },\n 1001: {\n name: 'Going Away',\n message: 'The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection.',\n },\n 1002: {\n name: 'Protocol error',\n message: 'The endpoint is terminating the connection due to a protocol error.',\n },\n 1003: {\n name: 'Unsupported Data',\n message: 'The connection is being terminated because the endpoint received data of a type it cannot accept. (For example, a text-only endpoint received binary data.)',\n },\n 1004: {\n name: 'Reserved',\n message: 'Reserved. A meaning might be defined in the future.',\n },\n 1005: {\n name: 'No Status Rcvd',\n message: 'Reserved. Indicates that no status code was provided even though one was expected.',\n },\n 1006: {\n name: 'Abnormal Closure',\n message: 'Reserved. Indicates that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected.',\n },\n 1007: {\n name: 'Invalid frame payload data',\n message: 'The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message).',\n },\n 1008: {\n name: 'Policy Violation',\n message: 'The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable.',\n },\n 1009: {\n name: 'Message Too Big',\n message: 'The endpoint is terminating the connection because a data frame was received that is too large.',\n },\n 1010: {\n name: 'Mandatory Ext.',\n message: \"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't.\",\n },\n 1011: {\n name: 'Internal Error',\n message: 'The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.',\n },\n 1012: {\n name: 'Service Restart',\n message: 'The server is terminating the connection because it is restarting.',\n },\n 1013: {\n name: 'Try Again Later',\n message: 'The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients.',\n },\n 1014: {\n name: 'Bad Gateway',\n message: 'The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code.',\n },\n 1015: {\n name: 'TLS handshake',\n message: \"Reserved. Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified).\",\n },\n '1016-2999': {\n name: '',\n message: 'For definition by future revisions of the WebSocket Protocol specification, and for definition by extension specifications.',\n },\n '3000-3999': {\n name: '',\n message: 'For use by libraries, frameworks, and applications. These status codes are registered directly with IANA. The interpretation of these codes is undefined by the WebSocket protocol.',\n },\n '4000-4999': {\n name: '',\n message: \"For private use, and thus can't be registered. Such codes can be used by prior agreements between WebSocket applications. The interpretation of these codes is undefined by the WebSocket protocol.\",\n },\n};\n//# sourceMappingURL=rpc_error_messages.js.map","/*\nThis file is part of web3.js.\n\nweb3.js is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nweb3.js is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with web3.js. If not, see <http://www.gnu.org/licenses/>.\n*/\nimport { BaseWeb3Error } from '../web3_error_base.js';\nimport { ERR_RPC_INTERNAL_ERROR, ERR_RPC_INVALID_INPUT, ERR_RPC_INVALID_JSON, ERR_RPC_INVALID_METHOD, ERR_RPC_INVALID_PARAMS, ERR_RPC_INVALID_REQUEST, ERR_RPC_LIMIT_EXCEEDED, ERR_RPC_MISSING_RESOURCE, ERR_RPC_NOT_SUPPORTED, ERR_RPC_TRANSACTION_REJECTED, ERR_RPC_UNAVAILABLE_RESOURCE, ERR_RPC_UNSUPPORTED_METHOD, } from '../error_codes.js';\nimport { RpcErrorMessages, genericRpcErrorMessageTemplate } from './rpc_error_messages.js';\nexport class RpcError extends BaseWeb3Error {\n constructor(rpcError, message) {\n super(message !== null && message !== void 0 ? message : genericRpcErrorMessageTemplate.replace('*code*', rpcError.error.code.toString()));\n this.code = rpcError.error.code;\n this.id = rpcError.id;\n this.jsonrpc = rpcError.jsonrpc;\n this.jsonRpcError = rpcError.error;\n }\n toJSON() {\n return Object.assign(Object.assign({}, super.toJSON()), { error: this.jsonRpcError, id: this.id, jsonRpc: this.jsonrpc });\n }\n}\nexport class EIP1193ProviderRpcError extends BaseWeb3Error {\n constructor(code, data) {\n var _a, _b, _c, _d;\n if (!code) {\n // this case should ideally not happen\n super();\n }\n else if ((_a = RpcErrorMessages[code]) === null || _a === void 0 ? void 0 : _a.message) {\n super(RpcErrorMessages[code].message);\n }\n else {\n // Retrieve the status code object for the given code from the table, by searching through the appropriate range\n const statusCodeRange = Object.keys(RpcErrorMessages).find(statusCode => typeof statusCode === 'string' &&\n code >= parseInt(statusCode.split('-')[0], 10) &&\n code <= parseInt(statusCode.split('-')[1], 10));\n super((_c = (_b = RpcErrorMessages[statusCodeRange !== null && statusCodeRange !== void 0 ? statusCodeRange : '']) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : genericRpcErrorMessageTemplate.replace('*code*', (_d = code === null || code === void 0 ? void 0 : code.toString()) !== null && _d !== void 0 ? _d : '\"\"'));\n }\n this.code = code;\n this.data = data;\n }\n}\nexport class ParseError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_INVALID_JSON].message);\n this.code = ERR_RPC_INVALID_JSON;\n }\n}\nexport class InvalidRequestError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_INVALID_REQUEST].message);\n this.code = ERR_RPC_INVALID_REQUEST;\n }\n}\nexport class MethodNotFoundError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_INVALID_METHOD].message);\n this.code = ERR_RPC_INVALID_METHOD;\n }\n}\nexport class InvalidParamsError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_INVALID_PARAMS].message);\n this.code = ERR_RPC_INVALID_PARAMS;\n }\n}\nexport class InternalError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_INTERNAL_ERROR].message);\n this.code = ERR_RPC_INTERNAL_ERROR;\n }\n}\nexport class InvalidInputError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_INVALID_INPUT].message);\n this.code = ERR_RPC_INVALID_INPUT;\n }\n}\nexport class MethodNotSupported extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_UNSUPPORTED_METHOD].message);\n this.code = ERR_RPC_UNSUPPORTED_METHOD;\n }\n}\nexport class ResourceUnavailableError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_UNAVAILABLE_RESOURCE].message);\n this.code = ERR_RPC_UNAVAILABLE_RESOURCE;\n }\n}\nexport class ResourcesNotFoundError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_MISSING_RESOURCE].message);\n this.code = ERR_RPC_MISSING_RESOURCE;\n }\n}\nexport class VersionNotSupportedError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_NOT_SUPPORTED].message);\n this.code = ERR_RPC_NOT_SUPPORTED;\n }\n}\nexport class TransactionRejectedError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_TRANSACTION_REJECTED].message);\n this.code = ERR_RPC_TRANSACTION_REJECTED;\n }\n}\nexport class LimitExceededError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_LIMIT_EXCEEDED].message);\n this.code = ERR_RPC_LIMIT_EXCEEDED;\n }\n}\nexport const rpcErrorsMap = new Map();\nrpcErrorsMap.set(ERR_RPC_INVALID_JSON, { error: ParseError });\nrpcErrorsMap.set(ERR_RPC_INVALID_REQUEST, {\n error: InvalidRequestError,\n});\nrpcErrorsMap.set(ERR_RPC_INVALID_METHOD, {\n error: MethodNotFoundError,\n});\nrpcErrorsMap.set(ERR_RPC_INVALID_PARAMS, { error: InvalidParamsError });\nrpcErrorsMap.set(ERR_RPC_INTERNAL_ERROR, { error: InternalError });\nrpcErrorsMap.set(ERR_RPC_INVALID_INPUT, { error: InvalidInputError });\nrpcErrorsMap.set(ERR_RPC_UNSUPPORTED_METHOD, {\n error: MethodNotSupported,\n});\nrpcErrorsMap.set(ERR_RPC_UNAVAILABLE_RESOURCE, {\n error: ResourceUnavailableError,\n});\nrpcErrorsMap.set(ERR_RPC_TRANSACTION_REJECTED, {\n error: TransactionRejectedError,\n});\nrpcErrorsMap.set(ERR_RPC_MISSING_RESOURCE, {\n error: ResourcesNotFoundError,\n});\nrpcErrorsMap.set(ERR_RPC_NOT_SUPPORTED, {\n error: VersionNotSupportedError,\n});\nrpcErrorsMap.set(ERR_RPC_LIMIT_EXCEEDED, { error: LimitExceededError });\n//# sourceMappingURL=rpc_errors.js.map","/*\nThis file is part of web3.js.\n\nweb3.js is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nweb3.js is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with web3.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/**\n * checks input if typeof data is valid string input\n */\nexport const isString = (value) => typeof value === 'string';\nexport const isHexStrict = (hex) => typeof hex === 'string' && /^((-)?0x[0-9a-f]+|(0x))$/i.test(hex);\n/**\n * Is the string a hex string.\n *\n * @param value\n * @param length\n * @returns output the string is a hex string\n */\nexport function isHexString(value, length) {\n if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/))\n return false;\n if (typeof length !== 'undefined' && length > 0 && value.length !== 2 + 2 * length)\n return false;\n return true;\n}\nexport const isHex = (hex) => typeof hex === 'number' ||\n typeof hex === 'bigint' ||\n (typeof hex === 'string' && /^((-0x|0x|-)?[0-9a-f]+|(0x))$/i.test(hex));\nexport const isHexString8Bytes = (value, prefixed = true) => prefixed ? isHexStrict(value) && value.length === 18 : isHex(value) && value.length === 16;\nexport const isHexString32Bytes = (value, prefixed = true) => prefixed ? isHexStrict(value) && value.length === 66 : isHex(value) && value.length === 64;\n/**\n * Returns a `Boolean` on whether or not the a `String` starts with '0x'\n * @param str the string input value\n * @return a boolean if it is or is not hex prefixed\n * @throws if the str input is not a string\n */\nexport function isHexPrefixed(str) {\n if (typeof str !== 'string') {\n throw new Error(`[isHexPrefixed] input must be type 'string', received type ${typeof str}`);\n }\n return str.startsWith('0x');\n}\n/**\n * Checks provided Uint8Array for leading zeroes and throws if found.\n *\n * Examples:\n *\n * Valid values: 0x1, 0x, 0x01, 0x1234\n * Invalid values: 0x0, 0x00, 0x001, 0x0001\n *\n * Note: This method is useful for validating that RLP encoded integers comply with the rule that all\n * integer values encoded to RLP must be in the most compact form and contain no leading zero bytes\n * @param values An object containing string keys and Uint8Array values\n * @throws if any provided value is found to have leading zero bytes\n */\nexport const validateNoLeadingZeroes = function (values) {\n for (const [k, v] of Object.entries(values)) {\n if (v !== undefined && v.length > 0 && v[0] === 0) {\n throw new Error(`${k} cannot have leading zeroes, received: ${v.toString()}`);\n }\n }\n};\n//# sourceMappingURL=string.js.map","/*\nThis file is part of web3.js.\n\nweb3.js is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nweb3.js is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with web3.js. If not, see <http://www.gnu.org/licenses/>.\n*/\nexport var FMT_NUMBER;\n(function (FMT_NUMBER) {\n FMT_NUMBER[\"NUMBER\"] = \"NUMBER_NUMBER\";\n FMT_NUMBER[\"HEX\"] = \"NUMBER_HEX\";\n FMT_NUMBER[\"STR\"] = \"NUMBER_STR\";\n FMT_NUMBER[\"BIGINT\"] = \"NUMBER_BIGINT\";\n})(FMT_NUMBER || (FMT_NUMBER = {}));\nexport var FMT_BYTES;\n(function (FMT_BYTES) {\n FMT_BYTES[\"HEX\"] = \"BYTES_HEX\";\n FMT_BYTES[\"UINT8ARRAY\"] = \"BYTES_UINT8ARRAY\";\n})(FMT_BYTES || (FMT_BYTES = {}));\nexport const DEFAULT_RETURN_FORMAT = {\n number: FMT_NUMBER.BIGINT,\n bytes: FMT_BYTES.HEX,\n};\nexport const ETH_DATA_FORMAT = { number: FMT_NUMBER.HEX, bytes: FMT_BYTES.HEX };\n//# sourceMappingURL=data_format_types.js.map","export var BlockTags;\n(function (BlockTags) {\n BlockTags[\"EARLIEST\"] = \"earliest\";\n BlockTags[\"LATEST\"] = \"latest\";\n BlockTags[\"PENDING\"] = \"pending\";\n BlockTags[\"SAFE\"] = \"safe\";\n BlockTags[\"FINALIZED\"] = \"finalized\";\n})(BlockTags || (BlockTags = {}));\n// This list of hardforks is expected to be in order\n// keep this in mind when making changes to it\nexport var HardforksOrdered;\n(function (HardforksOrdered) {\n HardforksOrdered[\"chainstart\"] = \"chainstart\";\n HardforksOrdered[\"frontier\"] = \"frontier\";\n HardforksOrdered[\"homestead\"] = \"homestead\";\n HardforksOrdered[\"dao\"] = \"dao\";\n HardforksOrdered[\"tangerineWhistle\"] = \"tangerineWhistle\";\n HardforksOrdered[\"spuriousDragon\"] = \"spuriousDragon\";\n HardforksOrdered[\"byzantium\"] = \"byzantium\";\n HardforksOrdered[\"constantinople\"] = \"constantinople\";\n HardforksOrdered[\"petersburg\"] = \"petersburg\";\n HardforksOrdered[\"istanbul\"] = \"istanbul\";\n HardforksOrdered[\"muirGlacier\"] = \"muirGlacier\";\n HardforksOrdered[\"berlin\"] = \"berlin\";\n HardforksOrdered[\"london\"] = \"london\";\n HardforksOrdered[\"altair\"] = \"altair\";\n HardforksOrdered[\"arrowGlacier\"] = \"arrowGlacier\";\n HardforksOrdered[\"grayGlacier\"] = \"grayGlacier\";\n HardforksOrdered[\"bellatrix\"] = \"bellatrix\";\n HardforksOrdered[\"merge\"] = \"merge\";\n HardforksOrdered[\"capella\"] = \"capella\";\n HardforksOrdered[\"shanghai\"] = \"shanghai\";\n})(HardforksOrdered || (HardforksOrdered = {}));\n//# sourceMappingURL=eth_types.js.map","import { Provider } from '../../provider';\nimport { BASCULE_ABI } from '../abi';\n\nexport function getBasculeTokenContract(\n provider: Provider,\n contractAddress: string,\n) {\n if (!contractAddress) {\n throw new Error(`The address for bascule module is not defined`);\n }\n\n const contract = provider.createContract(BASCULE_ABI, contractAddress);\n\n if (!contract.options.address) {\n contract.options.address = contractAddress;\n }\n\n return contract as typeof contract & {\n options: typeof contract.options & { address: string };\n };\n}\n","import { isHexStrict } from 'web3-validator';\n\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { Provider } from '../../provider';\nimport { IProviderBasedParams } from '../types';\nimport { getBasculeTokenContract } from '../utils/getBasculeTokenContract';\nimport { getLbtcTokenContract } from '../utils/getLbtcTokenContract';\nimport { ZERO_ADDRESS } from '../../common/const';\n\nconst NO_DEPOSIT_ID_ERROR =\n 'No deposit ID provided. Please provide a deposit ID as an argument.';\n\nconst INVALID_DEPOSIT_ID_ERROR =\n 'Invalid deposit ID. Expected a 0x-prefixed 32-byte hex string.';\n\n// Deposit status enum\nexport enum BasculeDepositStatus {\n UNREPORTED = 0, // potentially pending\n REPORTED = 1,\n WITHDRAWN = 2,\n}\n\nexport interface ICheckBasculeDepositStatusParams\n extends IProviderBasedParams,\n IEnvParam {\n /**\n * id of the transaction.\n */\n txId?: string;\n}\n\n/**\n * Check bascule contract deposit status.\n *\n * @param {ICheckBasculeDepositStatusParams} params - The parameters to get status base on Bascule contract.\n *\n * @returns {Promise<BasculeDepositStatus>} Deposit status promise\n */\nexport async function getBasculeDepositStatus({\n txId,\n env,\n ...providerParams\n}: ICheckBasculeDepositStatusParams): Promise<BasculeDepositStatus> {\n if (!txId) {\n throw new Error(NO_DEPOSIT_ID_ERROR);\n }\n\n if (!isHexStrict(txId)) {\n throw new Error(INVALID_DEPOSIT_ID_ERROR);\n }\n\n const provider = new Provider(providerParams);\n\n const tokenContract = getLbtcTokenContract(provider, env);\n\n const basculeAddress: string = await tokenContract.methods.Bascule().call();\n\n if (basculeAddress === ZERO_ADDRESS) {\n return BasculeDepositStatus.REPORTED;\n }\n\n const basculeContract = getBasculeTokenContract(provider, basculeAddress);\n\n try {\n const status: bigint = await basculeContract.methods\n .depositHistory(Buffer.from(txId.replace(/^0x/, ''), 'hex'))\n .call();\n\n const depositStatus: BasculeDepositStatus = Number(status);\n\n return depositStatus;\n } catch (error) {\n const errorMessage = getErrorMessage(error);\n\n throw new Error(errorMessage);\n }\n}\n","import { OChainId, OEnv, TChainId, TEnv } from '../../common/types/types';\n\nconst PROD_NATIVE_MINT_CHAINS = [\n OChainId.ethereum,\n OChainId.base,\n OChainId.binanceSmartChain,\n] as TChainId[];\n\nexport const chainIdToEnv = (chainId: TChainId): TEnv => {\n return PROD_NATIVE_MINT_CHAINS.includes(chainId) ? OEnv.prod : OEnv.stage;\n};\n","import { TChainId } from '../../common/types/types';\nimport { isValidChain } from '../../common/utils/isValidChain';\nimport {\n rpcUrlConfig as defaultRpcUrlConfig,\n TRpcUrlConfig,\n} from '../../provider/rpcUrlConfig';\n\n/**\n * Get RPC URL configuration for a specific chain.\n * Validates chain support and RPC URL availability.\n *\n * @param {TChainId} chainId - Chain ID to get RPC config for\n * @param {string} [rpcUrl] - Optional custom RPC URL\n * @returns {TRpcUrlConfig} RPC URL configuration for the chain\n * @throws {Error} If chain is not supported or RPC URL is not found\n */\nexport function getRpcUrlConfigFromChain(\n chainId: TChainId,\n rpcUrl?: string,\n): TRpcUrlConfig {\n if (!isValidChain(chainId)) {\n throw new Error(`This chain ${chainId} is not supported`);\n }\n\n const rpcUrlConfig: TRpcUrlConfig = rpcUrl\n ? { [chainId]: rpcUrl }\n : defaultRpcUrlConfig;\n\n if (!rpcUrlConfig[chainId]) {\n throw new Error(`RPC URL for chainId ${chainId} not found`);\n }\n\n return rpcUrlConfig;\n}\n","import BigNumber from 'bignumber.js';\nimport { TChainId } from '../../common/types/types';\nimport { fromSatoshi } from '../../common/utils/convertSatoshi';\nimport { ReadProvider } from '../../provider/ReadProvider';\nimport { chainIdToEnv } from '../utils/chainIdToEnv';\nimport { getLbtcTokenContract } from '../utils/getLbtcTokenContract';\nimport { getRpcUrlConfigFromChain } from '../utils/getRpcUrlConfigFromChain';\n\nexport interface IGetLBTCMintingFeeParams {\n /**\n * Chain ID\n */\n chainId: TChainId;\n /**\n * RPC URL\n */\n rpcUrl?: string;\n}\n\n/**\n * Get LBTC minting fee.\n *\n * @param chainId - Chain ID\n * @param rpcUrl - RPC URL (optional)\n *\n * @returns LBTC minting fee\n */\nexport async function getLBTCMintingFee({\n chainId,\n rpcUrl,\n}: IGetLBTCMintingFeeParams): Promise<BigNumber> {\n const rpcUrlConfig = getRpcUrlConfigFromChain(chainId, rpcUrl);\n const provider = new ReadProvider({ chainId, rpcUrlConfig });\n const env = chainIdToEnv(chainId);\n const tokenContract = getLbtcTokenContract(provider, env);\n\n const fee: bigint = await tokenContract.methods.getMintFee().call();\n const feeBtc = new BigNumber(fromSatoshi(fee.toString(10)));\n\n return feeBtc;\n}\n","import { Provider } from '../../provider';\nimport { IProviderBasedParams } from '../types';\n\nexport type SignLbtcDestionationAddrParams = IProviderBasedParams;\n\n/**\n * Signs the destination address for the LBTC in active chain\n * in the current account. Signing is necessary for the\n * generation of the deposit address.\n *\n * @param {SignLbtcDestionationAddrParams} params\n *\n * @returns {Promise<string>} The signature of the message.\n */\nexport async function signLbtcDestionationAddr(\n params: SignLbtcDestionationAddrParams,\n): Promise<string> {\n const provider = new Provider(params);\n\n const message = `destination chain id is ${params.chainId}`;\n\n return provider.signMessage(message);\n}\n","export const SECONDS_PER_DAY = 24 * 60 * 60;\nexport const MS_PER_DAY = SECONDS_PER_DAY * 1000;\n","interface IGetTypedData {\n chainId: number;\n verifyingContract: string;\n fee: string;\n expiry: number;\n}\n\nexport function getTypedData({\n chainId,\n verifyingContract,\n fee,\n expiry,\n}: IGetTypedData) {\n return {\n domain: {\n name: 'Lombard Staked Bitcoin',\n version: '1',\n chainId,\n verifyingContract,\n },\n message: {\n chainId,\n fee,\n expiry,\n },\n primaryType: 'feeApproval',\n types: {\n EIP712Domain: [\n { name: 'name', type: 'string' },\n { name: 'version', type: 'string' },\n { name: 'chainId', type: 'uint256' },\n { name: 'verifyingContract', type: 'address' },\n ],\n feeApproval: [\n { name: 'chainId', type: 'uint256' },\n { name: 'fee', type: 'uint256' },\n { name: 'expiry', type: 'uint256' },\n ],\n },\n };\n}\n","import { IEnvParam } from '../../common/types/internalTypes';\nimport { Provider } from '../../provider';\nimport { SECONDS_PER_DAY } from '../const';\nimport { IProviderBasedParams } from '../types';\nimport { getLbtcTokenContract } from '../utils/getLbtcTokenContract';\nimport { getTypedData } from './getTypedData';\n\nconst NO_SIGNATURE_ERROR =\n 'Failed to obtain a valid signature. The response is undefined or invalid.';\n\nexport interface ISignNetworkFeeParams\n extends Pick<IProviderBasedParams, 'provider' | 'chainId'>,\n IEnvParam {\n /**\n * User address\n */\n address: string;\n /**\n * Authorization fee\n */\n fee: string;\n /**\n * Expiration time\n */\n expiry: number;\n}\n\nexport interface ISignNetworkFeeResponse {\n /**\n * signature\n */\n signature: string;\n /**\n * JSON typed data used for the signature\n */\n typedData: string;\n}\n\nconst getDefaultExpiryUnix = () => {\n return Math.floor(Date.now() / 1000 + SECONDS_PER_DAY);\n};\n\n/**\n * Signs the network fee transaction in the current account.\n * Signing is necessary for the auto-mint.\n *\n * @param {ISignNetworkFeeParams} params - The parameters for signing network fee\n * @returns {Promise<ISignNetworkFeeResponse>} A promise that resolves to the signature and typed data\n */\nexport async function signNetworkFee({\n address,\n provider,\n fee,\n chainId,\n env,\n expiry = getDefaultExpiryUnix(),\n}: ISignNetworkFeeParams): Promise<ISignNetworkFeeResponse> {\n const providerInstance = new Provider({\n provider,\n account: address,\n chainId,\n });\n\n const tokenContract = getLbtcTokenContract(providerInstance, env);\n const verifyingContract = tokenContract.options.address;\n const typedData = JSON.stringify(\n getTypedData({\n chainId,\n verifyingContract,\n fee,\n expiry,\n }),\n );\n\n const signature = await providerInstance.web3?.currentProvider?.request<\n 'eth_signTypedData_v4',\n string\n >({\n method: 'eth_signTypedData_v4',\n params: [address, typedData],\n });\n\n if (typeof signature === 'string') {\n return { signature, typedData: typedData };\n }\n\n if (!signature?.result) {\n throw new Error(NO_SIGNATURE_ERROR);\n }\n\n return { signature: signature.result, typedData: typedData };\n}\n","import { OChainId, TChainId } from '../../common/types/types';\n\nexport const STAKE_AND_BAKE_SPENDER_CONTRACTS: Record<number, string> = {\n [OChainId.holesky]: '0x52BD640617eeD47A00dA0da93351092D49208d1d',\n} as const;\n\nexport const SUPPORTED_STAKE_AND_BAKE_CHAINS = Object.keys(\n STAKE_AND_BAKE_SPENDER_CONTRACTS,\n).map(Number);\n\nexport const getStakeAndBakeSpenderContract = (chainId: TChainId): string => {\n return STAKE_AND_BAKE_SPENDER_CONTRACTS[chainId];\n};\n","import { TChainId } from '../../common/types/types';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { ReadProvider } from '../../provider/ReadProvider';\nimport { chainIdToEnv } from '../utils/chainIdToEnv';\nimport { getLbtcTokenContract } from '../utils/getLbtcTokenContract';\nimport { getRpcUrlConfigFromChain } from '../utils/getRpcUrlConfigFromChain';\n\nexport interface IGetPermitNonceParams {\n /**\n * Owner address to check permit nonce for\n */\n owner: string;\n /**\n * Chain ID of the network\n */\n chainId: TChainId;\n /**\n * RPC URL for the network (optional)\n */\n rpcUrl?: string;\n}\n\n/**\n * Get permit nonce for a specific owner address from LBTC contract.\n * This nonce is used in EIP-2612 permit operations.\n *\n * @param {IGetPermitNonceParams} params - Parameters for getting permit nonce\n * @returns {Promise<string>} Promise that resolves to the permit nonce value\n */\nexport async function getPermitNonce({\n owner,\n rpcUrl,\n chainId,\n}: IGetPermitNonceParams): Promise<string> {\n const rpcUrlConfig = getRpcUrlConfigFromChain(chainId, rpcUrl);\n const provider = new ReadProvider({ chainId, rpcUrlConfig });\n const env = chainIdToEnv(chainId);\n const tokenContract = getLbtcTokenContract(provider, env);\n\n try {\n const nonce: bigint = await tokenContract.methods.nonces(owner).call();\n return nonce.toString();\n } catch (error) {\n const errorMessage = getErrorMessage(error);\n throw new Error(errorMessage);\n }\n}\n","import { TChainId } from '../../common/types/types';\nimport { getPermitNonce } from '../getPermitNonce';\n\nexport interface IStakeAndBakeTypedData {\n chainId: TChainId;\n expiry: number;\n owner: string;\n spender: string;\n value: string;\n rpcUrl?: string;\n verifyingContract: string;\n}\n\n/**\n * Generates EIP-712 typed data for stake and bake signature\n *\n * @param {IStakeAndBakeTypedData} params - Parameters for generating typed data\n * @returns {object} The typed data object conforming to EIP-712\n */\nexport async function getStakeAndBakeTypedData({\n chainId,\n expiry,\n owner,\n spender,\n value,\n rpcUrl,\n verifyingContract,\n}: IStakeAndBakeTypedData) {\n const nonce = await getPermitNonce({\n owner,\n chainId,\n rpcUrl,\n });\n\n return {\n domain: {\n name: 'Lombard Staked Bitcoin',\n version: '1',\n chainId,\n verifyingContract,\n },\n types: {\n EIP712Domain: [\n {\n name: 'name',\n type: 'string',\n },\n {\n name: 'version',\n type: 'string',\n },\n {\n name: 'chainId',\n type: 'uint256',\n },\n {\n name: 'verifyingContract',\n type: 'address',\n },\n ],\n Permit: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'nonce', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n },\n primaryType: 'Permit',\n message: {\n owner,\n spender,\n value,\n nonce,\n deadline: expiry.toString(),\n },\n };\n}\n","import { TChainId } from '../../common/types/types';\nimport { getLbtcAddressConfig } from '../lbtcAddressConfig';\n\n/**\n * Gets the LBTC contract address for a given chain ID\n * @param chainId The chain ID\n * @returns The LBTC contract address for the chain\n */\nexport const getVerifyingContract = (chainId: TChainId): string => {\n const lbtcAddressConfig = getLbtcAddressConfig('stage');\n const address = lbtcAddressConfig[chainId];\n if (!address) {\n throw new Error(`No LBTC contract address configured for chain ID ${chainId}`);\n }\n return address;\n};","import { TChainId } from '../../common/types/types';\nimport { Provider } from '../../provider';\nimport { IProviderBasedParams } from '../types';\nimport { getStakeAndBakeTypedData } from './getTypedData';\nimport { getVerifyingContract } from './utils';\n\nconst NO_SIGNATURE_ERROR =\n 'Failed to obtain a valid signature. The response is undefined or invalid.';\n\nexport interface ISignStakeAndBakeParams\n extends Pick<IProviderBasedParams, 'provider'> {\n /**\n * The address to sign with (owner)\n */\n address: string;\n /**\n * Chain ID for the signature\n */\n chainId: TChainId;\n /**\n * The value to approve\n */\n value: string;\n /**\n * Expiry date as a unix timestamp\n */\n expiry: number;\n /**\n * Optional RPC URL for the network\n */\n rpcUrl?: string;\n /**\n * The spender address that will be authorized to spend tokens\n */\n spender: string;\n}\n\nexport interface ISignStakeAndBakeResult {\n /**\n * The signature\n */\n signature: string;\n /**\n * The typed data used to generate the signature\n */\n typedData: string;\n}\n\n/**\n * Signs stake and bake authorization with EIP-712\n *\n * @param {ISignStakeAndBakeParams} params - Parameters for signing\n * @returns {Promise<ISignStakeAndBakeResult>} The signature and typed data\n */\nexport async function signStakeAndBake({\n address,\n provider,\n chainId,\n value,\n expiry,\n rpcUrl,\n spender,\n}: ISignStakeAndBakeParams): Promise<ISignStakeAndBakeResult> {\n const providerInstance = new Provider({\n provider,\n account: address,\n chainId,\n });\n\n const verifyingContract = getVerifyingContract(chainId);\n\n const typedDataObject = await getStakeAndBakeTypedData({\n chainId,\n expiry,\n owner: address,\n spender,\n value,\n rpcUrl,\n verifyingContract,\n });\n\n const typedData = JSON.stringify(typedDataObject);\n\n const signature = await providerInstance.web3?.currentProvider?.request<\n 'eth_signTypedData_v4',\n string\n >({\n method: 'eth_signTypedData_v4',\n params: [address, typedData],\n });\n\n if (typeof signature === 'string') {\n return { signature, typedData };\n }\n\n if (!signature?.result) {\n throw new Error(NO_SIGNATURE_ERROR);\n }\n\n return { signature: signature.result, typedData };\n}\n","import { TChainId } from '../../common/types/types';\nimport { STAKE_AND_BAKE_SPENDER_CONTRACTS } from './contracts';\n\nexport const getStakeAndBakeSpenderAddress = (chainId: TChainId): string => {\n const address = STAKE_AND_BAKE_SPENDER_CONTRACTS[chainId];\n if (!address) {\n throw new Error(`No spender address configured for chain ID ${chainId}`);\n }\n return address;\n};\n"],"names":["OEnv","OChainId","getEthNetworkByEnv","env","getBscNetworkByEnv","getBaseNetworkByEnv","defaultEnv","ZERO_ADDRESS","stageConfig","testnetConfig","prodConfig","getApiConfig","getErrorMessage","error","err","_a","getAxiosErrorMessage","getErrorMessageFromObject","OChainName","getChainNameById","chainId","SANCTIONED_ADDRESS","ADDRESS_URL","SANCTIONS_MESSAGE","generateDepositBtcAddress","address","signature","eip712Data","referrerCode","partnerId","captchaToken","baseApiUrl","toChain","requestParams","data","axios","errorMsg","isSanctioned","getDepositBtcAddress","addresses","getDepositBtcAddresses","addressData","getActualAddress","actualAddress","acc","toBlockchain","requestrParams","BTC_DECIMALS","SATOSHI_SCALE","fromSatoshi","amount","toSatoshi","getChainIdByName","chain","ENotarizationStatus","ESessionState","getDepositsByAddress","mapResponse","BigNumber","MIN_STAKE_AMOUNT_BTC","getLBTCExchangeRate","chainIdName","minAmount","getNetworkFeeSignature","errorMessage","getUserStakeAndBakeSignature","userDestinationAddress","storeNetworkFeeSignature","typedData","storeStakeAndBakeSignature","rpcUrlConfig","getMaxPriorityFeePerGas","rpcUrl","convertedHexValue","Web3","FEE_MULTIPLIER","ADDITIONAL_SAFE_GAS_PRICE_WEI","ReadProvider","__publicField","defaultRpcUrlConfig","readWeb3","provider","web3","block","maxPriorityFeePerGas","pureGasPriceWei","abi","Provider","account","message","messageHex","from","to","sendOptions","web3Write","web3Read","estimate","estimateFee","extendedGasLimit","gasLimit","value","gasLimitMultiplier","nonce","tx","utils","estimatedGas","multipliedGasLimit","e","maxFeePerGas","safeGasPrice","resolve","reject","promise","transactionHash","getGasMultiplier","isValidChain","PLACEHOLDER_ADDRESS","getLbtcAddressConfig","getTokenABI","token","LBTCABI","IERC20","getLbtcTokenContract","lbtcAddressConfig","tokenAddress","contract","INSUFFICIENT_FUNDS_PARTIAL_ERROR","INSUFFICIENT_FUNDS_ERROR","hexify","hexString","claimLBTC","proofSignature","providerParams","tokenContract","ERR_MULTIPLE_ERRORS","JSONRPC_ERR_REJECTED_REQUEST","JSONRPC_ERR_UNAUTHORIZED","JSONRPC_ERR_UNSUPPORTED_METHOD","JSONRPC_ERR_DISCONNECTED","JSONRPC_ERR_CHAIN_DISCONNECTED","ERR_RPC_INVALID_JSON","ERR_RPC_INVALID_REQUEST","ERR_RPC_INVALID_METHOD","ERR_RPC_INVALID_PARAMS","ERR_RPC_INTERNAL_ERROR","ERR_RPC_INVALID_INPUT","ERR_RPC_MISSING_RESOURCE","ERR_RPC_UNAVAILABLE_RESOURCE","ERR_RPC_TRANSACTION_REJECTED","ERR_RPC_UNSUPPORTED_METHOD","ERR_RPC_LIMIT_EXCEEDED","ERR_RPC_NOT_SUPPORTED","BaseWeb3Error","msg","cause","MultipleErrors","unquotValue","result","_","v","errors","genericRpcErrorMessageTemplate","RpcErrorMessages","RpcError","rpcError","ParseError","InvalidRequestError","MethodNotFoundError","InvalidParamsError","InternalError","InvalidInputError","MethodNotSupported","ResourceUnavailableError","ResourcesNotFoundError","VersionNotSupportedError","TransactionRejectedError","LimitExceededError","rpcErrorsMap","isHexStrict","hex","FMT_NUMBER","FMT_BYTES","BlockTags","HardforksOrdered","getBasculeTokenContract","contractAddress","BASCULE_ABI","NO_DEPOSIT_ID_ERROR","INVALID_DEPOSIT_ID_ERROR","BasculeDepositStatus","getBasculeDepositStatus","txId","basculeAddress","basculeContract","status","PROD_NATIVE_MINT_CHAINS","chainIdToEnv","getRpcUrlConfigFromChain","getLBTCMintingFee","fee","signLbtcDestionationAddr","params","SECONDS_PER_DAY","getTypedData","verifyingContract","expiry","NO_SIGNATURE_ERROR","getDefaultExpiryUnix","signNetworkFee","providerInstance","_b","STAKE_AND_BAKE_SPENDER_CONTRACTS","SUPPORTED_STAKE_AND_BAKE_CHAINS","getStakeAndBakeSpenderContract","getPermitNonce","owner","getStakeAndBakeTypedData","spender","getVerifyingContract","signStakeAndBake","typedDataObject","getStakeAndBakeSpenderAddress"],"mappings":"iUAAaA,EAAO,CAClB,KAAM,OACN,QAAS,U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,EACT,QAAAL,CAAA,CACD,EAEKwL,EAAoBc,GAAqBtM,CAAO,EAEhDwM,EAAkB,MAAMJ,GAAyB,CACrD,QAAApM,EACA,OAAAyL,EACA,MAAOpL,EACP,QAAAgM,EACA,MAAArH,EACA,OAAA5B,EACA,kBAAAoI,CAAA,CACD,EAEKxI,EAAY,KAAK,UAAUwJ,CAAe,EAE1ClM,EAAY,OAAMwL,GAAAnM,EAAAkM,EAAiB,OAAjB,YAAAlM,EAAuB,kBAAvB,YAAAmM,EAAwC,QAG9D,CACA,OAAQ,uBACR,OAAQ,CAACzL,EAAS2C,CAAS,CAAA,IAGzB,GAAA,OAAO1C,GAAc,SAChB,MAAA,CAAE,UAAAA,EAAW,UAAA0C,GAGlB,GAAA,EAAC1C,GAAA,MAAAA,EAAW,QACR,MAAA,IAAI,MAAMoL,EAAkB,EAGpC,MAAO,CAAE,UAAWpL,EAAU,OAAQ,UAAA0C,CAAU,CAClD,CCjGa,MAAAyJ,GAAiCzM,GAA8B,CACpE,MAAAK,EAAU0L,EAAiC/L,CAAO,EACxD,GAAI,CAACK,EACH,MAAM,IAAI,MAAM,8CAA8CL,CAAO,EAAE,EAElE,OAAAK,CACT","x_google_ignoreList":[27,28,29,30,31,32,33]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/common/types/types.ts","../src/common/const.ts","../src/sdk/apiConfig.ts","../src/common/utils/getErrorMessage.ts","../src/sdk/internalTypes.ts","../src/sdk/utils/getChainNameById.ts","../src/sdk/generateDepositBtcAddress/generateDepositBtcAddress.ts","../src/sdk/getDepositBtcAddress/getDepositBtcAddress.ts","../src/common/utils/convertSatoshi.ts","../src/sdk/utils/getChainIdByName.ts","../src/sdk/getDepositsByAddress/getDepositsByAddress.ts","../src/sdk/const.ts","../src/sdk/getLBTCExchangeRate/getLBTCExchangeRate.ts","../src/sdk/getNetworkFeeSignature/getNetworkFeeSignature.ts","../src/sdk/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.ts","../src/sdk/storeNetworkFeeSignature/storeNetworkFeeSignature.ts","../src/sdk/storeStakeAndBakeSignature/storeStakeAndBakeSignature.ts","../src/provider/rpcUrlConfig.ts","../src/provider/utils/getMaxPriorityFeePerGas.ts","../src/provider/ReadProvider.ts","../src/provider/Provider.ts","../src/web3Sdk/utils/getGasMultiplier.ts","../src/common/utils/isValidChain.ts","../src/web3Sdk/lbtcAddressConfig.ts","../src/web3Sdk/utils/getTokenABI.ts","../src/web3Sdk/utils/getLbtcTokenContract.ts","../src/web3Sdk/claimLBTC/claimLBTC.ts","../../../node_modules/web3-errors/lib/esm/error_codes.js","../../../node_modules/web3-errors/lib/esm/web3_error_base.js","../../../node_modules/web3-errors/lib/esm/errors/rpc_error_messages.js","../../../node_modules/web3-errors/lib/esm/errors/rpc_errors.js","../../../node_modules/web3-validator/lib/esm/validation/string.js","../../../node_modules/web3-types/lib/esm/data_format_types.js","../../../node_modules/web3-types/lib/esm/eth_types.js","../src/web3Sdk/utils/getBasculeTokenContract.ts","../src/web3Sdk/getBasculeDepositStatus/getBasculeDepositStatus.ts","../src/web3Sdk/utils/chainIdToEnv.ts","../src/web3Sdk/utils/getRpcUrlConfigFromChain.ts","../src/web3Sdk/getLBTCMintingFee/getLBTCMintingFee.tsx","../src/web3Sdk/signLbtcDestionationAddr/signLbtcDestionationAddr.ts","../src/web3Sdk/const.ts","../src/web3Sdk/signNetworkFee/getTypedData.ts","../src/web3Sdk/signNetworkFee/signNetworkFee.ts","../src/web3Sdk/signStakeAndBake/contracts.ts","../src/web3Sdk/getPermitNonce/getPermitNonce.ts","../src/web3Sdk/signStakeAndBake/getTypedData.ts","../src/web3Sdk/signStakeAndBake/utils.ts","../src/web3Sdk/signStakeAndBake/signStakeAndBake.ts","../src/web3Sdk/signStakeAndBake/config.ts"],"sourcesContent":["export const OEnv = {\n prod: 'prod',\n testnet: 'testnet',\n stage: 'stage',\n} as const;\n\nexport type TEnv = (typeof OEnv)[keyof typeof OEnv];\n\nexport const OChainId = {\n ethereum: 1,\n holesky: 17000,\n binanceSmartChain: 56,\n binanceSmartChainTestnet: 97,\n sepolia: 11155111,\n base: 8453,\n baseTestnet: 84532,\n berachainBartioTestnet: 80084,\n\n corn: 21000000,\n swell: 1923,\n} as const;\n\nexport type TChainId = (typeof OChainId)[keyof typeof OChainId];\n\nexport type TOFTChainId =\n | (typeof OChainId)['berachainBartioTestnet']\n | (typeof OChainId)['sepolia']\n | (typeof OChainId)['corn']\n | (typeof OChainId)['ethereum']\n | (typeof OChainId)['swell'];\n\n/**\n * Abstract EIP-1193 provider\n */\nexport interface IEIP1193Provider {\n request: (args: any) => Promise<any>;\n}\n\nexport const getEthNetworkByEnv = (env: TEnv) =>\n env === OEnv.prod ? OChainId.ethereum : OChainId.holesky;\n\nexport const getBscNetworkByEnv = (env: TEnv) =>\n env === OEnv.prod\n ? OChainId.binanceSmartChain\n : OChainId.binanceSmartChainTestnet;\n\nexport const getBaseNetworkByEnv = (env: TEnv) =>\n env === OEnv.prod ? OChainId.base : OChainId.baseTestnet;\n","import { OEnv, TEnv } from './types/types';\n\nexport const defaultEnv: TEnv = OEnv.prod;\n\n/**\n * Address of the zero account.\n * Can also be used as a placeholder for unknown addresses.\n */\nexport const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';\n","import { defaultEnv } from '../common/const';\nimport { OEnv, TEnv } from '../common/types/types';\n\ninterface IApiConfig {\n baseApiUrl: string;\n}\n\nconst stageConfig: IApiConfig = {\n baseApiUrl: 'https://staging.prod.lombard.finance',\n};\n\nconst testnetConfig: IApiConfig = {\n baseApiUrl: 'https://gastald-testnet.prod.lombard.finance',\n};\n\nconst prodConfig: IApiConfig = {\n baseApiUrl: 'https://mainnet.prod.lombard.finance',\n};\n\nexport const getApiConfig = (env: TEnv = defaultEnv): IApiConfig => {\n switch (env) {\n case OEnv.prod:\n return prodConfig;\n case OEnv.testnet:\n return testnetConfig;\n default:\n return stageConfig;\n }\n};\n","import { AxiosError } from 'axios';\n\n/**\n * Retrieves the error message from the given error object.\n *\n * @param error - The error object.\n * @returns The error message as a string.\n */\nexport function getErrorMessage(error: unknown): string {\n if (typeof error === 'string') {\n return error;\n }\n\n const hasDataMessage = (err: any): err is { data: { message: string } } =>\n err?.data?.message && typeof err.data.message === 'string';\n\n if (hasDataMessage(error)) {\n return error.data.message;\n }\n\n if (error instanceof Error) {\n return getAxiosErrorMessage(error as AxiosError);\n }\n\n return getErrorMessageFromObject(error);\n}\n\nfunction getAxiosErrorMessage(error: AxiosError): string {\n if (error.response) {\n return (error.response.data as { message: string }).message;\n }\n\n return error.message;\n}\n\nfunction getErrorMessageFromObject(error: any): string {\n if (error?.message) {\n return error.message;\n }\n\n return 'Unknown error';\n}\n","export const OChainName = {\n eth: 'DESTINATION_BLOCKCHAIN_ETHEREUM',\n base: 'DESTINATION_BLOCKCHAIN_BASE',\n bsc: 'DESTINATION_BLOCKCHAIN_BSC',\n mantle: 'DESTINATION_BLOCKCHAIN_MANTLE',\n linea: 'DESTINATION_BLOCKCHAIN_LINEA',\n zcircuit: 'DESTINATION_BLOCKCHAIN_ZIRCUIT',\n scroll: 'DESTINATION_BLOCKCHAIN_SCROLL',\n xlayer: 'DESTINATION_BLOCKCHAIN_XLAYER',\n} as const;\n\nexport type TChainName = (typeof OChainName)[keyof typeof OChainName];\n","import { OChainId, TChainId } from '../../common/types/types';\nimport { OChainName, TChainName } from '../internalTypes';\n\n/**\n * @param chainId the chain ID\n *\n * @returns the chain name\n */\nexport function getChainNameById(chainId: TChainId): TChainName {\n switch (chainId) {\n case OChainId.ethereum:\n case OChainId.holesky:\n case OChainId.sepolia:\n return OChainName.eth;\n case OChainId.base:\n case OChainId.baseTestnet:\n return OChainName.base;\n case OChainId.binanceSmartChain:\n case OChainId.binanceSmartChainTestnet:\n return OChainName.bsc;\n default:\n throw new Error(`Unknown chain ID: ${chainId}`);\n }\n}\n","import axios from 'axios';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { TChainId } from '../../common/types/types';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { getApiConfig } from '../apiConfig';\nimport { getChainNameById } from '../utils/getChainNameById';\n\n/**\n * The address wich will be returned if the provided EVM address is sanctioned.\n */\nexport const SANCTIONED_ADDRESS = 'sanctioned_address';\nconst ADDRESS_URL = 'api/v1/address/generate';\nconst SANCTIONS_MESSAGE = 'destination address is under sanctions';\n\ninterface IGenerateNewAddressResponse {\n address: string;\n}\n\nexport interface IGenerateDepositBtcAddressParams extends IEnvParam {\n /**\n * The destination EVM user address where LBTC will be claimed.\n */\n address: string;\n /**\n * The destination chain ID where LBTC will be claimed.\n */\n chainId: TChainId;\n /**\n * The signature of the address. The signature is generated by signing the address using EVM wallet.\n */\n signature: 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 captcha token.\n */\n captchaToken?: string;\n /**\n * The referrer code.\n */\n referrerCode?: string;\n /**\n * The referral ID.\n */\n partnerId?: string;\n}\n\n/**\n * Generates a BTC deposit address.\n *\n * If the provided EVM address is sanctioned, the function will return the `SANCTIONED_ADDRESS`.\n *\n * @param {IGenerateDepositBtcAddressParams} params - The parameters for generating the deposit address.\n * @returns {Promise<string>} The generated deposit address.\n */\nexport async function generateDepositBtcAddress({\n address,\n chainId,\n signature,\n eip712Data,\n env,\n referrerCode,\n partnerId,\n captchaToken,\n}: IGenerateDepositBtcAddressParams): Promise<string> {\n const { baseApiUrl } = getApiConfig(env);\n const toChain = getChainNameById(chainId);\n\n const requestParams = {\n to_address: address,\n to_address_signature: signature,\n to_chain: toChain,\n partner_id: partnerId,\n nonce: 0,\n captcha: captchaToken,\n referrer_code: referrerCode,\n eip_712_data: eip712Data,\n };\n\n try {\n const { data } = await axios.post<IGenerateNewAddressResponse>(\n ADDRESS_URL,\n requestParams,\n { baseURL: baseApiUrl },\n );\n\n return data.address;\n } catch (error) {\n const errorMsg = getErrorMessage(error);\n\n if (isSanctioned(errorMsg)) {\n return SANCTIONED_ADDRESS;\n } else {\n throw new Error(errorMsg);\n }\n }\n}\n\nfunction isSanctioned(errorMsg: string): boolean {\n return !!errorMsg.includes(SANCTIONS_MESSAGE);\n}\n","import axios from 'axios';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { TChainId } from '../../common/types/types';\nimport { getApiConfig } from '../apiConfig';\nimport { TChainName } from '../internalTypes';\nimport { getChainNameById } from '../utils/getChainNameById';\n\nconst ADDRESS_URL = 'api/v1/address';\n\ntype TPartnerId = 'lombard' | string;\n\ninterface IDepositAddress {\n btc_address: string;\n created_at: string;\n deprecated?: boolean;\n type: string;\n used?: boolean;\n deposit_metadata: {\n referral: TPartnerId;\n partner_id: TPartnerId;\n to_address: string;\n to_blockchain: TChainName;\n };\n}\n\ninterface IDepositAddressesResponse {\n addresses: IDepositAddress[];\n has_more?: boolean;\n}\n\nexport interface IGetDepositBtcAddressParams extends IEnvParam {\n /**\n * The destination EVM user address where LBTC will be claimed.\n */\n address: string;\n /**\n * The destination chain ID where LBTC will be claimed.\n */\n chainId: TChainId;\n /**\n * The referral ID.\n */\n partnerId: TPartnerId;\n}\n\n/**\n * Returns the address for depositing BTC.\n *\n * @param {IGetDepositBtcAddressParams} params - function parameters\n *\n * @returns {Promise<string>} the address for depositing BTC\n */\nexport async function getDepositBtcAddress({\n address,\n chainId,\n env,\n partnerId,\n}: IGetDepositBtcAddressParams): Promise<string> {\n const addresses = await getDepositBtcAddresses({\n address,\n chainId,\n env,\n partnerId,\n });\n\n const addressData = getActualAddress(addresses);\n\n if (!addressData) {\n throw new Error('No address');\n }\n\n return addressData.btc_address;\n}\n\n/**\n * Retrieves the actual deposit address from a list of deposit addresses.\n *\n * @param addresses - The list of deposit addresses.\n * @returns The actual deposit address or undefined if the last created address is deprecated.\n */\nfunction getActualAddress(\n addresses: IDepositAddress[],\n): IDepositAddress | undefined {\n if (!addresses.length) {\n return undefined;\n }\n\n const actualAddress = addresses.reduce((acc, address) => {\n if (acc.created_at < address.created_at) {\n return address;\n }\n return acc;\n }, addresses[0]);\n\n return actualAddress.deprecated ? undefined : actualAddress;\n}\n\n/**\n * Returns the addresses for depositing BTC.\n *\n * @param {IGetDepositBtcAddressParams} params - function parameters\n *\n * @returns {Promise<IDepositAddress[]>} the deposit addresses\n */\nexport async function getDepositBtcAddresses({\n address,\n chainId,\n env,\n partnerId,\n}: IGetDepositBtcAddressParams): Promise<IDepositAddress[]> {\n const { baseApiUrl } = getApiConfig(env);\n const toBlockchain = getChainNameById(chainId);\n\n const requestrParams = {\n to_address: address,\n to_blockchain: toBlockchain,\n limit: 1,\n offset: 0,\n asc: false,\n referralId: partnerId,\n };\n\n const { data } = await axios.get<IDepositAddressesResponse>(ADDRESS_URL, {\n baseURL: baseApiUrl,\n params: requestrParams,\n });\n\n return data?.addresses || [];\n}\n","const BTC_DECIMALS = 8;\nexport const SATOSHI_SCALE = 10 ** BTC_DECIMALS;\n\n/**\n * Convert Satoshi to BTC\n * @param amount - Satoshi amount\n * @returns BTC amount\n */\nexport function fromSatoshi(amount: number | string) {\n return +amount / SATOSHI_SCALE;\n}\n\n/**\n * Convert BTC to Satoshi\n *\n * @param amount - BTC amount\n * @returns Satoshi amount\n */\nexport function toSatoshi(amount: number | string) {\n return Math.floor(+amount * SATOSHI_SCALE);\n}\n","import { defaultEnv } from '../../common/const';\nimport {\n getBaseNetworkByEnv,\n getBscNetworkByEnv,\n getEthNetworkByEnv,\n OChainId,\n TChainId,\n TEnv,\n} from '../../common/types/types';\nimport { OChainName, TChainName } from '../internalTypes';\n\n/**\n * @param chainId the chain ID\n *\n * @returns the chain name\n */\nexport function getChainIdByName(\n chain: string,\n env: TEnv = defaultEnv,\n): TChainId {\n switch (chain as TChainName) {\n case OChainName.eth:\n return getEthNetworkByEnv(env);\n case OChainName.base:\n return getBaseNetworkByEnv(env);\n case OChainName.bsc:\n return getBscNetworkByEnv(env);\n\n default:\n return OChainId.ethereum;\n }\n}\n","import axios from 'axios';\nimport BigNumber from 'bignumber.js';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { TChainId, TEnv } from '../../common/types/types';\nimport { fromSatoshi } from '../../common/utils/convertSatoshi';\nimport { getApiConfig } from '../apiConfig';\nimport { getChainIdByName } from '../utils/getChainIdByName';\n\ntype Address = string;\ntype Seconds = number;\n\nexport enum ENotarizationStatus {\n NOTARIZATION_STATUS_UNSPECIFIED = 'NOTARIZATION_STATUS_UNSPECIFIED',\n // actually initial status for a deposit tx\n NOTARIZATION_STATUS_PENDING = 'NOTARIZATION_STATUS_PENDING',\n // the deposit was sent to the notarization\n NOTARIZATION_STATUS_SUBMITTED = 'NOTARIZATION_STATUS_SUBMITTED',\n // notarization was approved\n NOTARIZATION_STATUS_SESSION_APPROVED = 'NOTARIZATION_STATUS_SESSION_APPROVED',\n // notarization was failed\n NOTARIZATION_STATUS_FAILED = 'NOTARIZATION_STATUS_FAILED',\n}\n\nexport enum ESessionState {\n SESSION_STATE_UNSPECIFIED = 'SESSION_STATE_UNSPECIFIED',\n SESSION_STATE_PENDING = 'SESSION_STATE_PENDING',\n SESSION_STATE_COMPLETED = 'SESSION_STATE_COMPLETED',\n SESSION_STATE_EXPIRED = 'SESSION_STATE_EXPIRED',\n}\n\ninterface IDepositResponse {\n txid: string;\n value: number;\n address: Address;\n to_chain: string;\n notarization_wait_dur?: string | number;\n index?: number;\n raw_payload?: string;\n payload_hash?: string;\n proof?: string;\n claim_tx?: string; // tx on the destination chain\n block_height?: string;\n block_time?: string;\n sanctioned?: boolean;\n\n session_id: number;\n notarization_status: ENotarizationStatus;\n session_state: ESessionState;\n}\n\ninterface IDepositsByAddressResponse {\n outputs: IDepositResponse[];\n}\n\nexport interface IDeposit {\n txid: string;\n index?: number;\n blockHeight?: number;\n blockTime?: number;\n value: BigNumber;\n address: Address;\n chainId: TChainId;\n isClaimed?: boolean;\n claimedTxId?: string;\n rawPayload?: string;\n signature?: string;\n isRestricted?: boolean;\n notarizationWaitDur?: Seconds;\n // bascule hash id\n payload?: string;\n\n sessionId: number;\n notarizationStatus: ENotarizationStatus;\n sessionState: ESessionState;\n fromChainId?: TChainId;\n toChainId?: TChainId;\n status?: string;\n}\n\nexport interface IGetDepositsByAddressParams extends IEnvParam {\n /**\n * The EVM address to get deposits for\n */\n address: Address;\n}\n\n/**\n * Returns all deposits for a given address\n *\n * @param {IGetDepositsByAddressParams} params\n *\n * @returns {Promise<IDeposit[]>} a list of deposits\n */\nexport async function getDepositsByAddress({\n address,\n env,\n}: IGetDepositsByAddressParams): Promise<IDeposit[]> {\n const { baseApiUrl } = getApiConfig(env);\n\n const { data } = await axios.get<IDepositsByAddressResponse | undefined>(\n `api/v1/address/outputs-v2/${address}`,\n { baseURL: baseApiUrl },\n );\n\n const outputs = data?.outputs ?? [];\n\n return outputs.map(mapResponse(env));\n}\n\nfunction mapResponse(env?: TEnv) {\n return (data: IDepositResponse): IDeposit => ({\n txid: data.txid,\n index: data.index ?? 0,\n blockHeight: data.block_height ? Number(data.block_height) : undefined,\n blockTime: data.block_time ? Number(data.block_time) : undefined,\n value: new BigNumber(fromSatoshi(data.value)),\n address: data.address,\n chainId: getChainIdByName(data.to_chain, env),\n claimedTxId: data.claim_tx,\n rawPayload: data.raw_payload,\n signature: data.proof,\n isRestricted: !!data.sanctioned,\n notarizationWaitDur: data.notarization_wait_dur\n ? Number(data.notarization_wait_dur)\n : undefined,\n payload: data.payload_hash,\n sessionId: data.session_id,\n notarizationStatus: data.notarization_status,\n sessionState: data.session_state,\n });\n}\n","export const MIN_STAKE_AMOUNT_BTC = 0.0002;\n","import axios from 'axios';\nimport BigNumber from 'bignumber.js';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { OChainId, TChainId } from '../../common/types/types';\nimport { SATOSHI_SCALE } from '../../common/utils/convertSatoshi';\nimport { getApiConfig } from '../apiConfig';\nimport { MIN_STAKE_AMOUNT_BTC } from '../const';\nimport { getChainNameById } from '../utils/getChainNameById';\n\ntype ExchangeRateResponse = {\n amount_out: string;\n};\n\nexport interface IgetLBTCExchangeRateParams extends IEnvParam {\n /**\n * The chain id of the asset to get the exchange rate for. Exchange rate is the same for all chains so this param is optional.\n *\n * @default OChainId.ethereum\n */\n chainId?: TChainId;\n /**\n * The amount of the asset to get the exchange rate for. If not provided, the exchange rate will be returned for 1 BTC.\n *\n * @default 1\n */\n amount?: number;\n}\n\nexport interface IgetLBTCExchangeRateResponse {\n /**\n * The exchange rate for LBTC:BTC\n */\n exchangeRate: number;\n /**\n * The minimum amount of the asset to stake\n */\n minAmount: number;\n}\n\n/**\n * Retrieves the exchange rate for LBTC.\n *\n * @param {IgetLBTCExchangeRateParams} params\n *\n * @returns {Promise<IgetLBTCExchangeRateResponse>} - The exchange rate.\n */\nexport async function getLBTCExchangeRate({\n env,\n chainId = OChainId.ethereum,\n amount = 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 minAmount = new BigNumber(MIN_STAKE_AMOUNT_BTC)\n .multipliedBy(SATOSHI_SCALE)\n .toFixed();\n\n return { exchangeRate: +data.amount_out, minAmount: +minAmount };\n}\n","import axios from 'axios';\n\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { getApiConfig } from '../apiConfig';\n\nexport interface IGetNetworkFeeSignatureParams extends IEnvParam {\n /**\n * Chain ID of the network to interact with\n */\n chainId: number;\n /**\n * Destination address\n */\n address: string;\n}\n\ninterface IGetNetworkFeeSignatureResponse {\n /**\n * Expiration date of signature\n */\n expiration_date: string;\n /**\n * The flag signature exists\n */\n has_signature: boolean;\n /**\n * The auto mint is delayed\n */\n is_delayed: boolean;\n}\n\nexport interface IGetNetworkFeeSignatureMappedResponse {\n /**\n * Expiration date of signature\n */\n expirationDate: string;\n /**\n * The flag signature exists\n */\n hasSignature: boolean;\n /**\n * The auto mint is delayed\n */\n isDelayed: boolean;\n}\n\n/**\n * Returns the expiration date and the flag signature exists\n *\n * @returns {Promise<IGetNetworkFeeSignatureResponse>} authorize network fee sign promise\n */\nexport async function getNetworkFeeSignature({\n address,\n chainId,\n env,\n}: IGetNetworkFeeSignatureParams): Promise<IGetNetworkFeeSignatureMappedResponse> {\n const { baseApiUrl } = getApiConfig(env);\n\n try {\n const { data } = await axios.get<IGetNetworkFeeSignatureResponse>(\n `${baseApiUrl}/api/v1/claimer/get-user-signature`,\n {\n params: {\n user_destination_address: address,\n chain_id: chainId,\n },\n },\n );\n\n return {\n expirationDate: data?.expiration_date,\n hasSignature: data?.has_signature,\n isDelayed: data?.is_delayed,\n };\n } catch (error) {\n const errorMessage = getErrorMessage(error);\n\n throw new Error(errorMessage);\n }\n}\n","import axios from 'axios';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { TChainId } from '../../common/types/types';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { getApiConfig } from '../apiConfig';\n\nexport interface IGetUserStakeAndBakeSignatureParams extends IEnvParam {\n /**\n * User's destination address\n */\n userDestinationAddress: string;\n /**\n * Chain ID\n */\n chainId: TChainId;\n}\n\nexport interface IGetUserStakeAndBakeSignatureResponse {\n /**\n * The signature\n */\n signature: string;\n /**\n * The expiration date\n */\n expirationDate: string;\n /**\n * The deposit amount\n */\n depositAmount: string;\n /**\n * The chain ID\n */\n chainId: string;\n}\n\n/**\n * Get user's stake and bake signature from the API\n *\n * @param {IGetUserStakeAndBakeSignatureParams} params - Parameters for getting the signature\n * @returns {Promise<IGetUserStakeAndBakeSignatureResponse>} Promise that resolves to the signature response\n */\nexport async function getUserStakeAndBakeSignature({\n userDestinationAddress,\n chainId,\n env,\n}: IGetUserStakeAndBakeSignatureParams): Promise<IGetUserStakeAndBakeSignatureResponse> {\n const { baseApiUrl } = getApiConfig(env);\n\n try {\n const { data } = await axios.get<IGetUserStakeAndBakeSignatureResponse>(\n `${baseApiUrl}/api/v1/claimer/get-user-stake-and-bake-signature`,\n {\n params: {\n userDestinationAddress,\n chainId: chainId.toString(),\n },\n },\n );\n\n return data;\n } catch (error) {\n const errorMessage = getErrorMessage(error);\n throw new Error(\n `Failed to get user stake and bake signature: ${errorMessage}`,\n );\n }\n}\n","import axios from 'axios';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { getApiConfig } from '../apiConfig';\n\nexport type IStoreNetworkFeeSignatureStatus = 'success';\n\ninterface IStoreNetworkFeeSignatureResponse {\n status: IStoreNetworkFeeSignatureStatus;\n}\n\nexport interface IStoreNetworkFeeSignatureParams extends IEnvParam {\n /**\n * signature\n */\n signature: string;\n /**\n * JSON typed data used for the signature\n */\n typedData: string;\n /**\n * Destination address\n */\n address: string;\n}\n\n/**\n * Authorize network fee\n *\n * @param {IStoreNetworkFeeSignatureParams} params - The parameters for network fee authorization\n *\n * @returns {Promise<IStoreNetworkFeeSignatureResponse>} Response promise with statuses\n *\n */\nexport async function storeNetworkFeeSignature({\n signature,\n typedData,\n address,\n env,\n}: IStoreNetworkFeeSignatureParams): Promise<IStoreNetworkFeeSignatureStatus> {\n const { baseApiUrl } = getApiConfig(env);\n\n try {\n const { data } = await axios.post<IStoreNetworkFeeSignatureResponse>(\n `${baseApiUrl}/api/v1/claimer/save-user-signature`,\n null,\n {\n params: {\n typed_data: typedData,\n signature,\n user_destination_address: address,\n },\n },\n );\n\n return data.status;\n } catch (error) {\n const errorMsg = getErrorMessage(error);\n\n throw new Error(errorMsg);\n }\n}\n","import axios from 'axios';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { getApiConfig } from '../apiConfig';\n\nexport type IStoreStakeAndBakeSignatureStatus = 'success';\n\ninterface IStoreStakeAndBakeSignatureResponse {\n status: IStoreStakeAndBakeSignatureStatus;\n}\n\nexport interface IStoreStakeAndBakeSignatureParams extends IEnvParam {\n /**\n * signature\n */\n signature: string;\n /**\n * JSON typed data used for the signature\n */\n typedData: string;\n}\n\n/**\n * Store stake and bake signature\n *\n * @param {IStoreStakeAndBakeSignatureParams} params - The parameters for storing stake and bake signature\n *\n * @returns {Promise<IStoreStakeAndBakeSignatureStatus>} Response promise with status\n *\n */\nexport async function storeStakeAndBakeSignature({\n signature,\n typedData,\n env,\n}: IStoreStakeAndBakeSignatureParams): Promise<IStoreStakeAndBakeSignatureStatus> {\n const { baseApiUrl } = getApiConfig(env);\n\n try {\n const { data } = await axios.post<IStoreStakeAndBakeSignatureResponse>(\n `${baseApiUrl}/api/v1/claimer/save-stake-and-bake-signature`,\n null,\n {\n params: {\n typed_data: typedData,\n signature,\n },\n },\n );\n\n return data.status;\n } catch (error) {\n const errorMsg = getErrorMessage(error);\n\n throw new Error(errorMsg);\n }\n}","import { OChainId } from '../common/types/types';\n\nexport type TRpcUrlConfig = Record<number, string>;\n\nexport const rpcUrlConfig: TRpcUrlConfig = {\n [OChainId.ethereum]: 'https://rpc.ankr.com/eth',\n [OChainId.holesky]: 'https://rpc.ankr.com/eth_holesky',\n [OChainId.sepolia]: 'https://rpc.ankr.com/eth_sepolia',\n [OChainId.base]: 'https://rpc.ankr.com/base',\n [OChainId.baseTestnet]: 'https://rpc.ankr.com/base_sepolia',\n [OChainId.binanceSmartChain]: 'https://rpc.ankr.com/bsc',\n [OChainId.binanceSmartChainTestnet]:\n 'https://rpc.ankr.com/bsc_testnet_chapel',\n};\n","import BigNumber from 'bignumber.js';\nimport Web3 from 'web3';\n\nexport async function getMaxPriorityFeePerGas(\n rpcUrl: string,\n): Promise<BigNumber> {\n const response = await fetch(rpcUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: 1,\n method: 'eth_maxPriorityFeePerGas',\n params: [],\n }),\n });\n\n const data = await response.json();\n\n const convertedHexValue = Web3.utils.hexToNumber(data?.result);\n\n return new BigNumber(Number(convertedHexValue));\n}\n","import BigNumber from 'bignumber.js';\nimport { Web3, Contract, ContractAbi } from 'web3';\nimport {\n TRpcUrlConfig,\n rpcUrlConfig as defaultRpcUrlConfig,\n} from './rpcUrlConfig';\nimport { IGetMaxFeesResult } from './types';\nimport { getMaxPriorityFeePerGas } from './utils/getMaxPriorityFeePerGas';\n\nconst FEE_MULTIPLIER = 2;\nconst ADDITIONAL_SAFE_GAS_PRICE_WEI = 25_000;\n\nexport interface IReadProviderParams {\n /**\n * Chain ID of the network to interact with.\n */\n chainId: number;\n /**\n * The RPC URL configuration. If not provided, the default configuration will be used.\n */\n rpcUrlConfig?: TRpcUrlConfig;\n}\n\nexport class ReadProvider {\n chainId: number;\n rpcConfig: TRpcUrlConfig;\n\n constructor({ chainId, rpcUrlConfig }: IReadProviderParams) {\n this.chainId = chainId;\n this.rpcConfig = { ...defaultRpcUrlConfig, ...rpcUrlConfig };\n }\n\n /**\n * Returns web3 instance for read operations.\n *\n * @public\n * @returns {Web3} Web3 instance.\n */\n public getReadWeb3(): Web3 {\n const rpcUrl = this.getRpcUrl();\n const readWeb3 = new Web3();\n const provider = new Web3.providers.HttpProvider(rpcUrl);\n readWeb3.setProvider(provider);\n return readWeb3;\n }\n\n /**\n * Retrieves the RPC URL based on the current chain ID.\n * @returns The RPC URL for the current chain ID.\n * @throws Error if the RPC URL for the current chain ID is not found.\n */\n getRpcUrl(): string {\n const { chainId } = this;\n const rpcUrl = this.rpcConfig?.[chainId];\n\n if (!rpcUrl) {\n console.error(\n `You might need to add the rpcConfig for the ${chainId} chain ID when creating the provider.`,\n );\n throw new Error(`RPC URL for chainId ${chainId} not found`);\n }\n\n return rpcUrl;\n }\n\n /**\n * Calculates max fees for transaction. Thess values are available for networks\n * with EIP-1559 support.\n *\n * @public\n * @note If current network is Binance Smart Chain, will return default values.\n * @returns {Promise<IGetMaxFeesResult>} Max fees for transaction.\n */\n public async getMaxFees(): Promise<IGetMaxFeesResult> {\n const web3 = this.getReadWeb3();\n const rpcUrl = this.getRpcUrl();\n\n const [block, maxPriorityFeePerGas] = await Promise.all([\n web3.eth.getBlock('latest'),\n getMaxPriorityFeePerGas(rpcUrl),\n ]);\n\n if (!block?.baseFeePerGas && typeof block?.baseFeePerGas !== 'bigint') {\n return {};\n }\n\n const maxFeePerGas = new BigNumber(block.baseFeePerGas.toString(10))\n .multipliedBy(FEE_MULTIPLIER)\n .plus(maxPriorityFeePerGas);\n\n return {\n maxFeePerGas: +maxFeePerGas,\n maxPriorityFeePerGas: +maxPriorityFeePerGas,\n };\n }\n\n /**\n * Returns safe gas price for transaction.\n *\n * @public\n * @returns {Promise<BigNumber>} Safe gas price.\n */\n public async getSafeGasPriceWei(): Promise<BigNumber> {\n const pureGasPriceWei = await this.getReadWeb3().eth.getGasPrice();\n\n return new BigNumber(pureGasPriceWei.toString(10)).plus(\n ADDITIONAL_SAFE_GAS_PRICE_WEI,\n );\n }\n\n /**\n * Creates a contract instance with the given ABI and address.\n *\n * @template AbiType - The type of the contract ABI.\n * @param {any} abi - The ABI of the contract.\n * @param {string} address - The address of the contract.\n * @returns {Contract<AbiType>} The contract instance.\n */\n public createContract<AbiType extends ContractAbi>(\n abi: any,\n address: string,\n ): Contract<AbiType> {\n const web3 = this.getReadWeb3();\n return new web3.eth.Contract<AbiType>(abi, address);\n }\n}\n","import Web3, { Contract, ContractAbi, Transaction, utils } from 'web3';\nimport { IEIP1193Provider } from '../common/types/types';\nimport { IReadProviderParams, ReadProvider } from './ReadProvider';\nimport {\n TRpcUrlConfig,\n rpcUrlConfig as defaultRpcUrlConfig,\n} from './rpcUrlConfig';\nimport { ISendOptions, IWeb3SendResult } from './types';\n\nexport interface IProviderParams extends IReadProviderParams {\n /**\n * The EIP-1193 provider instance.\n */\n provider: IEIP1193Provider;\n /**\n * The сurrent account address.\n */\n account: string;\n}\n\n/**\n * Provider for interacting with a blockchain network.\n */\nexport class Provider extends ReadProvider {\n web3: Web3;\n account: string;\n rpcConfig: TRpcUrlConfig = defaultRpcUrlConfig;\n\n constructor({ provider, account, chainId, rpcUrlConfig }: IProviderParams) {\n super({ chainId, rpcUrlConfig });\n this.web3 = new Web3(provider);\n this.account = account;\n this.chainId = chainId;\n this.rpcConfig = { ...defaultRpcUrlConfig, ...rpcUrlConfig };\n }\n\n /**\n * Signs a message using the current provider and account.\n * @public\n * @param message - The message to be signed.\n * @returns A promise that resolves to the signed message as a string.\n */\n public async signMessage(message: string): Promise<string> {\n const { account } = this;\n\n const messageHex = `0x${Buffer.from(message, 'utf8').toString('hex')}`;\n\n const ethereum = this.web3.currentProvider as any;\n\n return ethereum.request({\n method: 'personal_sign',\n params: [messageHex, account],\n });\n }\n\n /**\n * Custom replacement for web3js [send](https://docs.web3js.org/libdocs/Contract#send).\n *\n * @public\n * @param {string} from - Address of the sender.\n * @param {string} to - Address of the recipient.\n * @param {ISendOptions} sendOptions - Options for sending transaction.\n * @returns {Promise<IWeb3SendResult>} Promise with transaction hash and receipt promise.\n */\n public async sendTransactionAsync(\n from: string,\n to: string,\n sendOptions: ISendOptions,\n ): Promise<IWeb3SendResult> {\n const { chainId, web3: web3Write } = this;\n const web3Read = this.getReadWeb3();\n\n const {\n data,\n estimate = false,\n estimateFee = false,\n extendedGasLimit,\n gasLimit = '0',\n value = '0',\n gasLimitMultiplier = 1,\n } = sendOptions;\n let { nonce } = sendOptions;\n\n if (!nonce) {\n nonce = await web3Read.eth.getTransactionCount(from);\n }\n\n console.log(`Nonce: ${nonce}`);\n\n const tx: Transaction = {\n from,\n to,\n value: utils.numberToHex(value),\n data,\n nonce,\n chainId: utils.numberToHex(chainId),\n };\n\n if (estimate) {\n try {\n const estimatedGas = await web3Read.eth.estimateGas(tx);\n const multipliedGasLimit = Math.round(\n Number(estimatedGas) * gasLimitMultiplier,\n );\n\n if (extendedGasLimit) {\n tx.gas = utils.numberToHex(multipliedGasLimit + extendedGasLimit);\n } else {\n tx.gas = utils.numberToHex(multipliedGasLimit);\n }\n } catch (e) {\n throw new Error(\n (e as Partial<Error>).message ??\n 'Failed to estimate gas limit for transaction.',\n );\n }\n } else {\n tx.gas = utils.numberToHex(gasLimit);\n }\n\n const { maxFeePerGas, maxPriorityFeePerGas } = estimateFee\n ? await this.getMaxFees().catch(() => sendOptions)\n : sendOptions;\n\n if (maxPriorityFeePerGas !== undefined) {\n tx.maxPriorityFeePerGas = utils.numberToHex(maxPriorityFeePerGas);\n }\n\n if (maxFeePerGas !== undefined) {\n tx.maxFeePerGas = utils.numberToHex(maxFeePerGas);\n }\n\n if (!tx.maxFeePerGas && !tx.maxPriorityFeePerGas) {\n const safeGasPrice = await this.getSafeGasPriceWei();\n tx.gasPrice = safeGasPrice.toString(10);\n }\n\n if (!tx.maxFeePerGas && !tx.maxPriorityFeePerGas) {\n const safeGasPrice = await this.getSafeGasPriceWei();\n tx.gasPrice = safeGasPrice.toString(10);\n }\n\n console.log('Sending transaction via Web3: ', tx);\n\n return new Promise((resolve, reject) => {\n const promise = web3Write.eth.sendTransaction(tx);\n\n promise\n .once('transactionHash', async (transactionHash: string) => {\n console.log(`Just signed transaction has is: ${transactionHash}`);\n\n resolve({\n receiptPromise: promise,\n transactionHash,\n });\n })\n .catch(reject);\n });\n }\n\n public createContract<AbiType extends ContractAbi>(\n abi: any,\n address: string,\n ): Contract<AbiType> {\n return new this.web3.eth.Contract<AbiType>(abi, address);\n }\n}\n","import { OChainId } from '../../common/types/types';\n\n/**\n * Returns the gas multiplier for the given chain ID.\n *\n * @param chainId - Chain ID.\n *\n * @returns Gas multiplier.\n */\nexport function getGasMultiplier(chainId: number): number {\n switch (chainId) {\n case OChainId.ethereum:\n return 1.3;\n case OChainId.holesky:\n case OChainId.sepolia:\n return 1.5;\n default:\n return 1.3;\n }\n}\n","import { OChainId, TChainId } from '../types/types';\n\nexport function isValidChain(chainId: number): chainId is TChainId {\n return Object.values(OChainId).includes(chainId as TChainId);\n}\n","import {\n defaultEnv,\n ZERO_ADDRESS as PLACEHOLDER_ADDRESS,\n} from '../common/const';\nimport { OChainId, OEnv, TChainId, TEnv } from '../common/types/types';\n\ntype LbtcTokenConfig = Record<TChainId, string>;\n\nconst stageConfig: LbtcTokenConfig = {\n [OChainId.holesky]: '0xED7bfd5C1790576105Af4649817f6d35A75CD818',\n [OChainId.ethereum]: PLACEHOLDER_ADDRESS,\n\n [OChainId.binanceSmartChainTestnet]:\n '0x731eFa688F3679688cf60A3993b8658138953ED6',\n [OChainId.binanceSmartChain]: PLACEHOLDER_ADDRESS,\n [OChainId.sepolia]: '0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30',\n\n [OChainId.base]: PLACEHOLDER_ADDRESS,\n // TODO: Add baseTestnet address\n [OChainId.baseTestnet]: PLACEHOLDER_ADDRESS,\n [OChainId.berachainBartioTestnet]:\n '0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30',\n\n [OChainId.corn]: PLACEHOLDER_ADDRESS,\n [OChainId.swell]: PLACEHOLDER_ADDRESS,\n};\n\nconst testnetConfig: LbtcTokenConfig = {\n [OChainId.holesky]: '0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2',\n [OChainId.ethereum]: PLACEHOLDER_ADDRESS,\n\n [OChainId.binanceSmartChainTestnet]:\n '0x107Fc7d90484534704dD2A9e24c7BD45DB4dD1B5',\n [OChainId.binanceSmartChain]: PLACEHOLDER_ADDRESS,\n [OChainId.sepolia]: '0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30',\n\n [OChainId.base]: PLACEHOLDER_ADDRESS,\n [OChainId.baseTestnet]: PLACEHOLDER_ADDRESS,\n [OChainId.berachainBartioTestnet]:\n '0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30',\n\n [OChainId.corn]: PLACEHOLDER_ADDRESS,\n [OChainId.swell]: PLACEHOLDER_ADDRESS,\n};\n\nconst prodConfig: LbtcTokenConfig = {\n [OChainId.ethereum]: '0x8236a87084f8b84306f72007f36f2618a5634494',\n [OChainId.holesky]: PLACEHOLDER_ADDRESS,\n [OChainId.sepolia]: PLACEHOLDER_ADDRESS,\n\n [OChainId.binanceSmartChainTestnet]: PLACEHOLDER_ADDRESS,\n [OChainId.binanceSmartChain]: '0xecAc9C5F704e954931349Da37F60E39f515c11c1',\n\n [OChainId.base]: '0xecAc9C5F704e954931349Da37F60E39f515c11c1',\n [OChainId.baseTestnet]: PLACEHOLDER_ADDRESS,\n\n [OChainId.berachainBartioTestnet]: PLACEHOLDER_ADDRESS,\n\n [OChainId.corn]: '0xecAc9C5F704e954931349Da37F60E39f515c11c1',\n [OChainId.swell]: '0xecAc9C5F704e954931349Da37F60E39f515c11c1',\n};\n\nexport function getLbtcAddressConfig(env: TEnv = defaultEnv): LbtcTokenConfig {\n switch (env) {\n case OEnv.prod:\n return prodConfig;\n case OEnv.testnet:\n return testnetConfig;\n default:\n return stageConfig;\n }\n}\n","import { IERC20, LBTCABI } from '../abi';\n\ntype Token = 'LBTC' | 'ERC20';\n\nexport function getTokenABI(token: Token) {\n switch (token) {\n case 'LBTC':\n return LBTCABI;\n default:\n return IERC20;\n }\n}\n","import { ReadProvider } from '../../provider/ReadProvider';\nimport { TEnv } from '../../common/types/types';\nimport { isValidChain } from '../../common/utils/isValidChain';\nimport { Provider } from '../../provider';\nimport { getLbtcAddressConfig } from '../lbtcAddressConfig';\nimport { getTokenABI } from './getTokenABI';\n\nexport function getLbtcTokenContract(provider: Provider | ReadProvider, env?: TEnv) {\n const lbtcAddressConfig = getLbtcAddressConfig(env);\n const { chainId } = provider;\n\n if (!isValidChain(chainId)) {\n throw new Error(`This chain ${chainId} is not supported`);\n }\n\n const tokenAddress = lbtcAddressConfig[chainId];\n\n if (!tokenAddress) {\n throw new Error(`Token address for chain ${chainId} is not defined`);\n }\n\n const abi = getTokenABI('LBTC');\n\n const contract = provider.createContract(abi, tokenAddress);\n\n if (!contract.options.address) {\n contract.options.address = tokenAddress;\n }\n\n return contract as typeof contract & {\n options: typeof contract.options & { address: string };\n };\n}\n","import { IEnvParam } from '../../common/types/internalTypes';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { IWeb3SendResult, Provider } from '../../provider';\nimport { IProviderBasedParams } from '../types';\nimport { getGasMultiplier } from '../utils/getGasMultiplier';\nimport { getLbtcTokenContract } from '../utils/getLbtcTokenContract';\n\nconst INSUFFICIENT_FUNDS_PARTIAL_ERROR = 'insufficient funds';\n\nconst INSUFFICIENT_FUNDS_ERROR =\n 'Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.';\n\nexport interface IClaimLBTCParams extends IProviderBasedParams, IEnvParam {\n /**\n * Raw payload from deposit notarization.\n */\n data: string;\n /**\n * Signature from deposit notarization.\n */\n proofSignature: string;\n}\n\nconst hexify = (hexString: string) =>\n hexString.startsWith('0x') ? hexString : '0x' + hexString;\n/**\n * Claims LBTC.\n *\n * @param {IClaimLBTCParams} params - The parameters for claiming LBTC.\n *\n * @returns {Promise<IWeb3SendResult>} transaction promise\n */\nexport async function claimLBTC({\n data,\n proofSignature,\n env,\n ...providerParams\n}: IClaimLBTCParams): Promise<IWeb3SendResult> {\n const provider = new Provider(providerParams);\n\n const tokenContract = getLbtcTokenContract(provider, env);\n\n const tx = tokenContract.methods.mint(hexify(data), hexify(proofSignature));\n\n try {\n const result = await provider.sendTransactionAsync(\n provider.account,\n tokenContract.options.address,\n {\n data: tx.encodeABI(),\n // TODO: add getGasOptions from the app for bsc here\n estimate: true,\n estimateFee: true,\n gasLimitMultiplier: getGasMultiplier(provider.chainId),\n },\n );\n\n return result;\n } catch (error) {\n console.log('error', error);\n const errorMessage = getErrorMessage(error);\n\n if (errorMessage.includes(INSUFFICIENT_FUNDS_PARTIAL_ERROR)) {\n throw new Error(INSUFFICIENT_FUNDS_ERROR);\n }\n\n throw new Error(errorMessage);\n }\n}\n","/*\nThis file is part of web3.js.\n\nweb3.js is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nweb3.js is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with web3.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n// Response error\nexport const ERR_RESPONSE = 100;\nexport const ERR_INVALID_RESPONSE = 101;\n// Generic errors\nexport const ERR_PARAM = 200;\nexport const ERR_FORMATTERS = 201;\nexport const ERR_METHOD_NOT_IMPLEMENTED = 202;\nexport const ERR_OPERATION_TIMEOUT = 203;\nexport const ERR_OPERATION_ABORT = 204;\nexport const ERR_ABI_ENCODING = 205;\nexport const ERR_EXISTING_PLUGIN_NAMESPACE = 206;\nexport const ERR_INVALID_METHOD_PARAMS = 207;\nexport const ERR_MULTIPLE_ERRORS = 208;\n// Contract error codes\nexport const ERR_CONTRACT = 300;\nexport const ERR_CONTRACT_RESOLVER_MISSING = 301;\nexport const ERR_CONTRACT_ABI_MISSING = 302;\nexport const ERR_CONTRACT_REQUIRED_CALLBACK = 303;\nexport const ERR_CONTRACT_EVENT_NOT_EXISTS = 304;\nexport const ERR_CONTRACT_RESERVED_EVENT = 305;\nexport const ERR_CONTRACT_MISSING_DEPLOY_DATA = 306;\nexport const ERR_CONTRACT_MISSING_ADDRESS = 307;\nexport const ERR_CONTRACT_MISSING_FROM_ADDRESS = 308;\nexport const ERR_CONTRACT_INSTANTIATION = 309;\nexport const ERR_CONTRACT_EXECUTION_REVERTED = 310;\nexport const ERR_CONTRACT_TX_DATA_AND_INPUT = 311;\n// Transaction error codes\nexport const ERR_TX = 400;\nexport const ERR_TX_REVERT_INSTRUCTION = 401;\nexport const ERR_TX_REVERT_TRANSACTION = 402;\nexport const ERR_TX_NO_CONTRACT_ADDRESS = 403;\nexport const ERR_TX_CONTRACT_NOT_STORED = 404;\nexport const ERR_TX_REVERT_WITHOUT_REASON = 405;\nexport const ERR_TX_OUT_OF_GAS = 406;\nexport const ERR_RAW_TX_UNDEFINED = 407;\nexport const ERR_TX_INVALID_SENDER = 408;\nexport const ERR_TX_INVALID_CALL = 409;\nexport const ERR_TX_MISSING_CUSTOM_CHAIN = 410;\nexport const ERR_TX_MISSING_CUSTOM_CHAIN_ID = 411;\nexport const ERR_TX_CHAIN_ID_MISMATCH = 412;\nexport const ERR_TX_INVALID_CHAIN_INFO = 413;\nexport const ERR_TX_MISSING_CHAIN_INFO = 414;\nexport const ERR_TX_MISSING_GAS = 415;\nexport const ERR_TX_INVALID_LEGACY_GAS = 416;\nexport const ERR_TX_INVALID_FEE_MARKET_GAS = 417;\nexport const ERR_TX_INVALID_FEE_MARKET_GAS_PRICE = 418;\nexport const ERR_TX_INVALID_LEGACY_FEE_MARKET = 419;\nexport const ERR_TX_INVALID_OBJECT = 420;\nexport const ERR_TX_INVALID_NONCE_OR_CHAIN_ID = 421;\nexport const ERR_TX_UNABLE_TO_POPULATE_NONCE = 422;\nexport const ERR_TX_UNSUPPORTED_EIP_1559 = 423;\nexport const ERR_TX_UNSUPPORTED_TYPE = 424;\nexport const ERR_TX_DATA_AND_INPUT = 425;\nexport const ERR_TX_POLLING_TIMEOUT = 426;\nexport const ERR_TX_RECEIPT_MISSING_OR_BLOCKHASH_NULL = 427;\nexport const ERR_TX_RECEIPT_MISSING_BLOCK_NUMBER = 428;\nexport const ERR_TX_LOCAL_WALLET_NOT_AVAILABLE = 429;\nexport const ERR_TX_NOT_FOUND = 430;\nexport const ERR_TX_SEND_TIMEOUT = 431;\nexport const ERR_TX_BLOCK_TIMEOUT = 432;\nexport const ERR_TX_SIGNING = 433;\nexport const ERR_TX_GAS_MISMATCH = 434;\nexport const ERR_TX_CHAIN_MISMATCH = 435;\nexport const ERR_TX_HARDFORK_MISMATCH = 436;\nexport const ERR_TX_INVALID_RECEIVER = 437;\nexport const ERR_TX_REVERT_TRANSACTION_CUSTOM_ERROR = 438;\nexport const ERR_TX_INVALID_PROPERTIES_FOR_TYPE = 439;\nexport const ERR_TX_MISSING_GAS_INNER_ERROR = 440;\nexport const ERR_TX_GAS_MISMATCH_INNER_ERROR = 441;\n// Connection error codes\nexport const ERR_CONN = 500;\nexport const ERR_CONN_INVALID = 501;\nexport const ERR_CONN_TIMEOUT = 502;\nexport const ERR_CONN_NOT_OPEN = 503;\nexport const ERR_CONN_CLOSE = 504;\nexport const ERR_CONN_MAX_ATTEMPTS = 505;\nexport const ERR_CONN_PENDING_REQUESTS = 506;\nexport const ERR_REQ_ALREADY_SENT = 507;\n// Provider error codes\nexport const ERR_PROVIDER = 600;\nexport const ERR_INVALID_PROVIDER = 601;\nexport const ERR_INVALID_CLIENT = 602;\nexport const ERR_SUBSCRIPTION = 603;\nexport const ERR_WS_PROVIDER = 604;\n// Account error codes\nexport const ERR_PRIVATE_KEY_LENGTH = 701;\nexport const ERR_INVALID_PRIVATE_KEY = 702;\nexport const ERR_UNSUPPORTED_KDF = 703;\nexport const ERR_KEY_DERIVATION_FAIL = 704;\nexport const ERR_KEY_VERSION_UNSUPPORTED = 705;\nexport const ERR_INVALID_PASSWORD = 706;\nexport const ERR_IV_LENGTH = 707;\nexport const ERR_INVALID_KEYSTORE = 708;\nexport const ERR_PBKDF2_ITERATIONS = 709;\n// Signature error codes\nexport const ERR_SIGNATURE_FAILED = 801;\nexport const ERR_INVALID_SIGNATURE = 802;\nexport const GENESIS_BLOCK_NUMBER = '0x0';\n// RPC error codes (EIP-1193)\n// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md#provider-errors\nexport const JSONRPC_ERR_REJECTED_REQUEST = 4001;\nexport const JSONRPC_ERR_UNAUTHORIZED = 4100;\nexport const JSONRPC_ERR_UNSUPPORTED_METHOD = 4200;\nexport const JSONRPC_ERR_DISCONNECTED = 4900;\nexport const JSONRPC_ERR_CHAIN_DISCONNECTED = 4901;\n// ENS error codes\nexport const ERR_ENS_CHECK_INTERFACE_SUPPORT = 901;\nexport const ERR_ENS_UNSUPPORTED_NETWORK = 902;\nexport const ERR_ENS_NETWORK_NOT_SYNCED = 903;\n// Utils error codes\nexport const ERR_INVALID_STRING = 1001;\nexport const ERR_INVALID_BYTES = 1002;\nexport const ERR_INVALID_NUMBER = 1003;\nexport const ERR_INVALID_UNIT = 1004;\nexport const ERR_INVALID_ADDRESS = 1005;\nexport const ERR_INVALID_HEX = 1006;\nexport const ERR_INVALID_TYPE = 1007;\nexport const ERR_INVALID_BOOLEAN = 1008;\nexport const ERR_INVALID_UNSIGNED_INTEGER = 1009;\nexport const ERR_INVALID_SIZE = 1010;\nexport const ERR_INVALID_LARGE_VALUE = 1011;\nexport const ERR_INVALID_BLOCK = 1012;\nexport const ERR_INVALID_TYPE_ABI = 1013;\nexport const ERR_INVALID_NIBBLE_WIDTH = 1014;\nexport const ERR_INVALID_INTEGER = 1015;\n// Validation error codes\nexport const ERR_VALIDATION = 1100;\n// Core error codes\nexport const ERR_CORE_HARDFORK_MISMATCH = 1101;\nexport const ERR_CORE_CHAIN_MISMATCH = 1102;\n// Schema error codes\nexport const ERR_SCHEMA_FORMAT = 1200;\n// RPC error codes (EIP-1474)\n// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md\nexport const ERR_RPC_INVALID_JSON = -32700;\nexport const ERR_RPC_INVALID_REQUEST = -32600;\nexport const ERR_RPC_INVALID_METHOD = -32601;\nexport const ERR_RPC_INVALID_PARAMS = -32602;\nexport const ERR_RPC_INTERNAL_ERROR = -32603;\nexport const ERR_RPC_INVALID_INPUT = -32000;\nexport const ERR_RPC_MISSING_RESOURCE = -32001;\nexport const ERR_RPC_UNAVAILABLE_RESOURCE = -32002;\nexport const ERR_RPC_TRANSACTION_REJECTED = -32003;\nexport const ERR_RPC_UNSUPPORTED_METHOD = -32004;\nexport const ERR_RPC_LIMIT_EXCEEDED = -32005;\nexport const ERR_RPC_NOT_SUPPORTED = -32006;\n//# sourceMappingURL=error_codes.js.map","/*\nThis file is part of web3.js.\n\nweb3.js is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nweb3.js is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with web3.js. If not, see <http://www.gnu.org/licenses/>.\n*/\nimport { ERR_MULTIPLE_ERRORS } from './error_codes.js';\n/**\n * Base class for Web3 errors.\n */\nexport class BaseWeb3Error extends Error {\n constructor(msg, cause) {\n super(msg);\n if (Array.isArray(cause)) {\n // eslint-disable-next-line no-use-before-define\n this.cause = new MultipleErrors(cause);\n }\n else {\n this.cause = cause;\n }\n this.name = this.constructor.name;\n if (typeof Error.captureStackTrace === 'function') {\n Error.captureStackTrace(new.target.constructor);\n }\n else {\n this.stack = new Error().stack;\n }\n }\n /**\n * @deprecated Use the `cause` property instead.\n */\n get innerError() {\n // eslint-disable-next-line no-use-before-define\n if (this.cause instanceof MultipleErrors) {\n return this.cause.errors;\n }\n return this.cause;\n }\n /**\n * @deprecated Use the `cause` property instead.\n */\n set innerError(cause) {\n if (Array.isArray(cause)) {\n // eslint-disable-next-line no-use-before-define\n this.cause = new MultipleErrors(cause);\n }\n else {\n this.cause = cause;\n }\n }\n static convertToString(value, unquotValue = false) {\n // Using \"null\" value intentionally for validation\n // eslint-disable-next-line no-null/no-null\n if (value === null || value === undefined)\n return 'undefined';\n const result = JSON.stringify(value, (_, v) => (typeof v === 'bigint' ? v.toString() : v));\n return unquotValue && ['bigint', 'string'].includes(typeof value)\n ? result.replace(/['\\\\\"]+/g, '')\n : result;\n }\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n cause: this.cause,\n // deprecated\n innerError: this.cause,\n };\n }\n}\nexport class MultipleErrors extends BaseWeb3Error {\n constructor(errors) {\n super(`Multiple errors occurred: [${errors.map(e => e.message).join('], [')}]`);\n this.code = ERR_MULTIPLE_ERRORS;\n this.errors = errors;\n }\n}\nexport class InvalidValueError extends BaseWeb3Error {\n constructor(value, msg) {\n super(`Invalid value given \"${BaseWeb3Error.convertToString(value, true)}\". Error: ${msg}.`);\n this.name = this.constructor.name;\n }\n}\n//# sourceMappingURL=web3_error_base.js.map","/*\nThis file is part of web3.js.\n\nweb3.js is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nweb3.js is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with web3.js. If not, see <http://www.gnu.org/licenses/>.\n*/\nimport { ERR_RPC_INTERNAL_ERROR, ERR_RPC_INVALID_INPUT, ERR_RPC_INVALID_JSON, ERR_RPC_INVALID_METHOD, ERR_RPC_INVALID_PARAMS, ERR_RPC_INVALID_REQUEST, ERR_RPC_LIMIT_EXCEEDED, ERR_RPC_MISSING_RESOURCE, ERR_RPC_NOT_SUPPORTED, ERR_RPC_TRANSACTION_REJECTED, ERR_RPC_UNAVAILABLE_RESOURCE, ERR_RPC_UNSUPPORTED_METHOD, JSONRPC_ERR_CHAIN_DISCONNECTED, JSONRPC_ERR_DISCONNECTED, JSONRPC_ERR_REJECTED_REQUEST, JSONRPC_ERR_UNAUTHORIZED, JSONRPC_ERR_UNSUPPORTED_METHOD, } from '../error_codes.js';\n/**\n * A template string for a generic Rpc Error. The `*code*` will be replaced with the code number.\n * Note: consider in next version that a spelling mistake could be corrected for `occured` and the value could be:\n * \t`An Rpc error has occurred with a code of *code*`\n */\nexport const genericRpcErrorMessageTemplate = 'An Rpc error has occured with a code of *code*';\n/* eslint-disable @typescript-eslint/naming-convention */\nexport const RpcErrorMessages = {\n // EIP-1474 & JSON RPC 2.0\n // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md\n [ERR_RPC_INVALID_JSON]: {\n message: 'Parse error',\n description: 'Invalid JSON',\n },\n [ERR_RPC_INVALID_REQUEST]: {\n message: 'Invalid request',\n description: 'JSON is not a valid request object\t',\n },\n [ERR_RPC_INVALID_METHOD]: {\n message: 'Method not found',\n description: 'Method does not exist\t',\n },\n [ERR_RPC_INVALID_PARAMS]: {\n message: 'Invalid params',\n description: 'Invalid method parameters',\n },\n [ERR_RPC_INTERNAL_ERROR]: {\n message: 'Internal error',\n description: 'Internal JSON-RPC error',\n },\n [ERR_RPC_INVALID_INPUT]: {\n message: 'Invalid input',\n description: 'Missing or invalid parameters',\n },\n [ERR_RPC_MISSING_RESOURCE]: {\n message: 'Resource not found',\n description: 'Requested resource not found',\n },\n [ERR_RPC_UNAVAILABLE_RESOURCE]: {\n message: 'Resource unavailable',\n description: 'Requested resource not available',\n },\n [ERR_RPC_TRANSACTION_REJECTED]: {\n message: 'Transaction rejected',\n description: 'Transaction creation failed',\n },\n [ERR_RPC_UNSUPPORTED_METHOD]: {\n message: 'Method not supported',\n description: 'Method is not implemented',\n },\n [ERR_RPC_LIMIT_EXCEEDED]: {\n message: 'Limit exceeded',\n description: 'Request exceeds defined limit',\n },\n [ERR_RPC_NOT_SUPPORTED]: {\n message: 'JSON-RPC version not supported',\n description: 'Version of JSON-RPC protocol is not supported',\n },\n // EIP-1193\n // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md#provider-errors\n [JSONRPC_ERR_REJECTED_REQUEST]: {\n name: 'User Rejected Request',\n message: 'The user rejected the request.',\n },\n [JSONRPC_ERR_UNAUTHORIZED]: {\n name: 'Unauthorized',\n message: 'The requested method and/or account has not been authorized by the user.',\n },\n [JSONRPC_ERR_UNSUPPORTED_METHOD]: {\n name: 'Unsupported Method',\n message: 'The Provider does not support the requested method.',\n },\n [JSONRPC_ERR_DISCONNECTED]: {\n name: 'Disconnected',\n message: 'The Provider is disconnected from all chains.',\n },\n [JSONRPC_ERR_CHAIN_DISCONNECTED]: {\n name: 'Chain Disconnected',\n message: 'The Provider is not connected to the requested chain.',\n },\n // EIP-1193 - CloseEvent\n // https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code\n '0-999': {\n name: '',\n message: 'Not used.',\n },\n 1000: {\n name: 'Normal Closure',\n message: 'The connection successfully completed the purpose for which it was created.',\n },\n 1001: {\n name: 'Going Away',\n message: 'The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection.',\n },\n 1002: {\n name: 'Protocol error',\n message: 'The endpoint is terminating the connection due to a protocol error.',\n },\n 1003: {\n name: 'Unsupported Data',\n message: 'The connection is being terminated because the endpoint received data of a type it cannot accept. (For example, a text-only endpoint received binary data.)',\n },\n 1004: {\n name: 'Reserved',\n message: 'Reserved. A meaning might be defined in the future.',\n },\n 1005: {\n name: 'No Status Rcvd',\n message: 'Reserved. Indicates that no status code was provided even though one was expected.',\n },\n 1006: {\n name: 'Abnormal Closure',\n message: 'Reserved. Indicates that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected.',\n },\n 1007: {\n name: 'Invalid frame payload data',\n message: 'The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message).',\n },\n 1008: {\n name: 'Policy Violation',\n message: 'The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable.',\n },\n 1009: {\n name: 'Message Too Big',\n message: 'The endpoint is terminating the connection because a data frame was received that is too large.',\n },\n 1010: {\n name: 'Mandatory Ext.',\n message: \"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't.\",\n },\n 1011: {\n name: 'Internal Error',\n message: 'The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.',\n },\n 1012: {\n name: 'Service Restart',\n message: 'The server is terminating the connection because it is restarting.',\n },\n 1013: {\n name: 'Try Again Later',\n message: 'The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients.',\n },\n 1014: {\n name: 'Bad Gateway',\n message: 'The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code.',\n },\n 1015: {\n name: 'TLS handshake',\n message: \"Reserved. Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified).\",\n },\n '1016-2999': {\n name: '',\n message: 'For definition by future revisions of the WebSocket Protocol specification, and for definition by extension specifications.',\n },\n '3000-3999': {\n name: '',\n message: 'For use by libraries, frameworks, and applications. These status codes are registered directly with IANA. The interpretation of these codes is undefined by the WebSocket protocol.',\n },\n '4000-4999': {\n name: '',\n message: \"For private use, and thus can't be registered. Such codes can be used by prior agreements between WebSocket applications. The interpretation of these codes is undefined by the WebSocket protocol.\",\n },\n};\n//# sourceMappingURL=rpc_error_messages.js.map","/*\nThis file is part of web3.js.\n\nweb3.js is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nweb3.js is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with web3.js. If not, see <http://www.gnu.org/licenses/>.\n*/\nimport { BaseWeb3Error } from '../web3_error_base.js';\nimport { ERR_RPC_INTERNAL_ERROR, ERR_RPC_INVALID_INPUT, ERR_RPC_INVALID_JSON, ERR_RPC_INVALID_METHOD, ERR_RPC_INVALID_PARAMS, ERR_RPC_INVALID_REQUEST, ERR_RPC_LIMIT_EXCEEDED, ERR_RPC_MISSING_RESOURCE, ERR_RPC_NOT_SUPPORTED, ERR_RPC_TRANSACTION_REJECTED, ERR_RPC_UNAVAILABLE_RESOURCE, ERR_RPC_UNSUPPORTED_METHOD, } from '../error_codes.js';\nimport { RpcErrorMessages, genericRpcErrorMessageTemplate } from './rpc_error_messages.js';\nexport class RpcError extends BaseWeb3Error {\n constructor(rpcError, message) {\n super(message !== null && message !== void 0 ? message : genericRpcErrorMessageTemplate.replace('*code*', rpcError.error.code.toString()));\n this.code = rpcError.error.code;\n this.id = rpcError.id;\n this.jsonrpc = rpcError.jsonrpc;\n this.jsonRpcError = rpcError.error;\n }\n toJSON() {\n return Object.assign(Object.assign({}, super.toJSON()), { error: this.jsonRpcError, id: this.id, jsonRpc: this.jsonrpc });\n }\n}\nexport class EIP1193ProviderRpcError extends BaseWeb3Error {\n constructor(code, data) {\n var _a, _b, _c, _d;\n if (!code) {\n // this case should ideally not happen\n super();\n }\n else if ((_a = RpcErrorMessages[code]) === null || _a === void 0 ? void 0 : _a.message) {\n super(RpcErrorMessages[code].message);\n }\n else {\n // Retrieve the status code object for the given code from the table, by searching through the appropriate range\n const statusCodeRange = Object.keys(RpcErrorMessages).find(statusCode => typeof statusCode === 'string' &&\n code >= parseInt(statusCode.split('-')[0], 10) &&\n code <= parseInt(statusCode.split('-')[1], 10));\n super((_c = (_b = RpcErrorMessages[statusCodeRange !== null && statusCodeRange !== void 0 ? statusCodeRange : '']) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : genericRpcErrorMessageTemplate.replace('*code*', (_d = code === null || code === void 0 ? void 0 : code.toString()) !== null && _d !== void 0 ? _d : '\"\"'));\n }\n this.code = code;\n this.data = data;\n }\n}\nexport class ParseError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_INVALID_JSON].message);\n this.code = ERR_RPC_INVALID_JSON;\n }\n}\nexport class InvalidRequestError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_INVALID_REQUEST].message);\n this.code = ERR_RPC_INVALID_REQUEST;\n }\n}\nexport class MethodNotFoundError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_INVALID_METHOD].message);\n this.code = ERR_RPC_INVALID_METHOD;\n }\n}\nexport class InvalidParamsError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_INVALID_PARAMS].message);\n this.code = ERR_RPC_INVALID_PARAMS;\n }\n}\nexport class InternalError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_INTERNAL_ERROR].message);\n this.code = ERR_RPC_INTERNAL_ERROR;\n }\n}\nexport class InvalidInputError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_INVALID_INPUT].message);\n this.code = ERR_RPC_INVALID_INPUT;\n }\n}\nexport class MethodNotSupported extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_UNSUPPORTED_METHOD].message);\n this.code = ERR_RPC_UNSUPPORTED_METHOD;\n }\n}\nexport class ResourceUnavailableError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_UNAVAILABLE_RESOURCE].message);\n this.code = ERR_RPC_UNAVAILABLE_RESOURCE;\n }\n}\nexport class ResourcesNotFoundError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_MISSING_RESOURCE].message);\n this.code = ERR_RPC_MISSING_RESOURCE;\n }\n}\nexport class VersionNotSupportedError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_NOT_SUPPORTED].message);\n this.code = ERR_RPC_NOT_SUPPORTED;\n }\n}\nexport class TransactionRejectedError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_TRANSACTION_REJECTED].message);\n this.code = ERR_RPC_TRANSACTION_REJECTED;\n }\n}\nexport class LimitExceededError extends RpcError {\n constructor(rpcError) {\n super(rpcError, RpcErrorMessages[ERR_RPC_LIMIT_EXCEEDED].message);\n this.code = ERR_RPC_LIMIT_EXCEEDED;\n }\n}\nexport const rpcErrorsMap = new Map();\nrpcErrorsMap.set(ERR_RPC_INVALID_JSON, { error: ParseError });\nrpcErrorsMap.set(ERR_RPC_INVALID_REQUEST, {\n error: InvalidRequestError,\n});\nrpcErrorsMap.set(ERR_RPC_INVALID_METHOD, {\n error: MethodNotFoundError,\n});\nrpcErrorsMap.set(ERR_RPC_INVALID_PARAMS, { error: InvalidParamsError });\nrpcErrorsMap.set(ERR_RPC_INTERNAL_ERROR, { error: InternalError });\nrpcErrorsMap.set(ERR_RPC_INVALID_INPUT, { error: InvalidInputError });\nrpcErrorsMap.set(ERR_RPC_UNSUPPORTED_METHOD, {\n error: MethodNotSupported,\n});\nrpcErrorsMap.set(ERR_RPC_UNAVAILABLE_RESOURCE, {\n error: ResourceUnavailableError,\n});\nrpcErrorsMap.set(ERR_RPC_TRANSACTION_REJECTED, {\n error: TransactionRejectedError,\n});\nrpcErrorsMap.set(ERR_RPC_MISSING_RESOURCE, {\n error: ResourcesNotFoundError,\n});\nrpcErrorsMap.set(ERR_RPC_NOT_SUPPORTED, {\n error: VersionNotSupportedError,\n});\nrpcErrorsMap.set(ERR_RPC_LIMIT_EXCEEDED, { error: LimitExceededError });\n//# sourceMappingURL=rpc_errors.js.map","/*\nThis file is part of web3.js.\n\nweb3.js is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nweb3.js is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with web3.js. If not, see <http://www.gnu.org/licenses/>.\n*/\n/**\n * checks input if typeof data is valid string input\n */\nexport const isString = (value) => typeof value === 'string';\nexport const isHexStrict = (hex) => typeof hex === 'string' && /^((-)?0x[0-9a-f]+|(0x))$/i.test(hex);\n/**\n * Is the string a hex string.\n *\n * @param value\n * @param length\n * @returns output the string is a hex string\n */\nexport function isHexString(value, length) {\n if (typeof value !== 'string' || !value.match(/^0x[0-9A-Fa-f]*$/))\n return false;\n if (typeof length !== 'undefined' && length > 0 && value.length !== 2 + 2 * length)\n return false;\n return true;\n}\nexport const isHex = (hex) => typeof hex === 'number' ||\n typeof hex === 'bigint' ||\n (typeof hex === 'string' && /^((-0x|0x|-)?[0-9a-f]+|(0x))$/i.test(hex));\nexport const isHexString8Bytes = (value, prefixed = true) => prefixed ? isHexStrict(value) && value.length === 18 : isHex(value) && value.length === 16;\nexport const isHexString32Bytes = (value, prefixed = true) => prefixed ? isHexStrict(value) && value.length === 66 : isHex(value) && value.length === 64;\n/**\n * Returns a `Boolean` on whether or not the a `String` starts with '0x'\n * @param str the string input value\n * @return a boolean if it is or is not hex prefixed\n * @throws if the str input is not a string\n */\nexport function isHexPrefixed(str) {\n if (typeof str !== 'string') {\n throw new Error(`[isHexPrefixed] input must be type 'string', received type ${typeof str}`);\n }\n return str.startsWith('0x');\n}\n/**\n * Checks provided Uint8Array for leading zeroes and throws if found.\n *\n * Examples:\n *\n * Valid values: 0x1, 0x, 0x01, 0x1234\n * Invalid values: 0x0, 0x00, 0x001, 0x0001\n *\n * Note: This method is useful for validating that RLP encoded integers comply with the rule that all\n * integer values encoded to RLP must be in the most compact form and contain no leading zero bytes\n * @param values An object containing string keys and Uint8Array values\n * @throws if any provided value is found to have leading zero bytes\n */\nexport const validateNoLeadingZeroes = function (values) {\n for (const [k, v] of Object.entries(values)) {\n if (v !== undefined && v.length > 0 && v[0] === 0) {\n throw new Error(`${k} cannot have leading zeroes, received: ${v.toString()}`);\n }\n }\n};\n//# sourceMappingURL=string.js.map","/*\nThis file is part of web3.js.\n\nweb3.js is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nweb3.js is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with web3.js. If not, see <http://www.gnu.org/licenses/>.\n*/\nexport var FMT_NUMBER;\n(function (FMT_NUMBER) {\n FMT_NUMBER[\"NUMBER\"] = \"NUMBER_NUMBER\";\n FMT_NUMBER[\"HEX\"] = \"NUMBER_HEX\";\n FMT_NUMBER[\"STR\"] = \"NUMBER_STR\";\n FMT_NUMBER[\"BIGINT\"] = \"NUMBER_BIGINT\";\n})(FMT_NUMBER || (FMT_NUMBER = {}));\nexport var FMT_BYTES;\n(function (FMT_BYTES) {\n FMT_BYTES[\"HEX\"] = \"BYTES_HEX\";\n FMT_BYTES[\"UINT8ARRAY\"] = \"BYTES_UINT8ARRAY\";\n})(FMT_BYTES || (FMT_BYTES = {}));\nexport const DEFAULT_RETURN_FORMAT = {\n number: FMT_NUMBER.BIGINT,\n bytes: FMT_BYTES.HEX,\n};\nexport const ETH_DATA_FORMAT = { number: FMT_NUMBER.HEX, bytes: FMT_BYTES.HEX };\n//# sourceMappingURL=data_format_types.js.map","export var BlockTags;\n(function (BlockTags) {\n BlockTags[\"EARLIEST\"] = \"earliest\";\n BlockTags[\"LATEST\"] = \"latest\";\n BlockTags[\"PENDING\"] = \"pending\";\n BlockTags[\"SAFE\"] = \"safe\";\n BlockTags[\"FINALIZED\"] = \"finalized\";\n})(BlockTags || (BlockTags = {}));\n// This list of hardforks is expected to be in order\n// keep this in mind when making changes to it\nexport var HardforksOrdered;\n(function (HardforksOrdered) {\n HardforksOrdered[\"chainstart\"] = \"chainstart\";\n HardforksOrdered[\"frontier\"] = \"frontier\";\n HardforksOrdered[\"homestead\"] = \"homestead\";\n HardforksOrdered[\"dao\"] = \"dao\";\n HardforksOrdered[\"tangerineWhistle\"] = \"tangerineWhistle\";\n HardforksOrdered[\"spuriousDragon\"] = \"spuriousDragon\";\n HardforksOrdered[\"byzantium\"] = \"byzantium\";\n HardforksOrdered[\"constantinople\"] = \"constantinople\";\n HardforksOrdered[\"petersburg\"] = \"petersburg\";\n HardforksOrdered[\"istanbul\"] = \"istanbul\";\n HardforksOrdered[\"muirGlacier\"] = \"muirGlacier\";\n HardforksOrdered[\"berlin\"] = \"berlin\";\n HardforksOrdered[\"london\"] = \"london\";\n HardforksOrdered[\"altair\"] = \"altair\";\n HardforksOrdered[\"arrowGlacier\"] = \"arrowGlacier\";\n HardforksOrdered[\"grayGlacier\"] = \"grayGlacier\";\n HardforksOrdered[\"bellatrix\"] = \"bellatrix\";\n HardforksOrdered[\"merge\"] = \"merge\";\n HardforksOrdered[\"capella\"] = \"capella\";\n HardforksOrdered[\"shanghai\"] = \"shanghai\";\n})(HardforksOrdered || (HardforksOrdered = {}));\n//# sourceMappingURL=eth_types.js.map","import { Provider } from '../../provider';\nimport { BASCULE_ABI } from '../abi';\n\nexport function getBasculeTokenContract(\n provider: Provider,\n contractAddress: string,\n) {\n if (!contractAddress) {\n throw new Error(`The address for bascule module is not defined`);\n }\n\n const contract = provider.createContract(BASCULE_ABI, contractAddress);\n\n if (!contract.options.address) {\n contract.options.address = contractAddress;\n }\n\n return contract as typeof contract & {\n options: typeof contract.options & { address: string };\n };\n}\n","import { isHexStrict } from 'web3-validator';\n\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { Provider } from '../../provider';\nimport { IProviderBasedParams } from '../types';\nimport { getBasculeTokenContract } from '../utils/getBasculeTokenContract';\nimport { getLbtcTokenContract } from '../utils/getLbtcTokenContract';\nimport { ZERO_ADDRESS } from '../../common/const';\n\nconst NO_DEPOSIT_ID_ERROR =\n 'No deposit ID provided. Please provide a deposit ID as an argument.';\n\nconst INVALID_DEPOSIT_ID_ERROR =\n 'Invalid deposit ID. Expected a 0x-prefixed 32-byte hex string.';\n\n// Deposit status enum\nexport enum BasculeDepositStatus {\n UNREPORTED = 0, // potentially pending\n REPORTED = 1,\n WITHDRAWN = 2,\n}\n\nexport interface ICheckBasculeDepositStatusParams\n extends IProviderBasedParams,\n IEnvParam {\n /**\n * id of the transaction.\n */\n txId?: string;\n}\n\n/**\n * Check bascule contract deposit status.\n *\n * @param {ICheckBasculeDepositStatusParams} params - The parameters to get status base on Bascule contract.\n *\n * @returns {Promise<BasculeDepositStatus>} Deposit status promise\n */\nexport async function getBasculeDepositStatus({\n txId,\n env,\n ...providerParams\n}: ICheckBasculeDepositStatusParams): Promise<BasculeDepositStatus> {\n if (!txId) {\n throw new Error(NO_DEPOSIT_ID_ERROR);\n }\n\n if (!isHexStrict(txId)) {\n throw new Error(INVALID_DEPOSIT_ID_ERROR);\n }\n\n const provider = new Provider(providerParams);\n\n const tokenContract = getLbtcTokenContract(provider, env);\n\n const basculeAddress: string = await tokenContract.methods.Bascule().call();\n\n if (basculeAddress === ZERO_ADDRESS) {\n return BasculeDepositStatus.REPORTED;\n }\n\n const basculeContract = getBasculeTokenContract(provider, basculeAddress);\n\n try {\n const status: bigint = await basculeContract.methods\n .depositHistory(Buffer.from(txId.replace(/^0x/, ''), 'hex'))\n .call();\n\n const depositStatus: BasculeDepositStatus = Number(status);\n\n return depositStatus;\n } catch (error) {\n const errorMessage = getErrorMessage(error);\n\n throw new Error(errorMessage);\n }\n}\n","import { OChainId, OEnv, TChainId, TEnv } from '../../common/types/types';\n\nconst PROD_NATIVE_MINT_CHAINS = [\n OChainId.ethereum,\n OChainId.base,\n OChainId.binanceSmartChain,\n] as TChainId[];\n\nexport const chainIdToEnv = (chainId: TChainId): TEnv => {\n return PROD_NATIVE_MINT_CHAINS.includes(chainId) ? OEnv.prod : OEnv.stage;\n};\n","import { TChainId } from '../../common/types/types';\nimport { isValidChain } from '../../common/utils/isValidChain';\nimport {\n rpcUrlConfig as defaultRpcUrlConfig,\n TRpcUrlConfig,\n} from '../../provider/rpcUrlConfig';\n\n/**\n * Get RPC URL configuration for a specific chain.\n * Validates chain support and RPC URL availability.\n *\n * @param {TChainId} chainId - Chain ID to get RPC config for\n * @param {string} [rpcUrl] - Optional custom RPC URL\n * @returns {TRpcUrlConfig} RPC URL configuration for the chain\n * @throws {Error} If chain is not supported or RPC URL is not found\n */\nexport function getRpcUrlConfigFromChain(\n chainId: TChainId,\n rpcUrl?: string,\n): TRpcUrlConfig {\n if (!isValidChain(chainId)) {\n throw new Error(`This chain ${chainId} is not supported`);\n }\n\n const rpcUrlConfig: TRpcUrlConfig = rpcUrl\n ? { [chainId]: rpcUrl }\n : defaultRpcUrlConfig;\n\n if (!rpcUrlConfig[chainId]) {\n throw new Error(`RPC URL for chainId ${chainId} not found`);\n }\n\n return rpcUrlConfig;\n}\n","import BigNumber from 'bignumber.js';\nimport { TChainId } from '../../common/types/types';\nimport { fromSatoshi } from '../../common/utils/convertSatoshi';\nimport { ReadProvider } from '../../provider/ReadProvider';\nimport { chainIdToEnv } from '../utils/chainIdToEnv';\nimport { getLbtcTokenContract } from '../utils/getLbtcTokenContract';\nimport { getRpcUrlConfigFromChain } from '../utils/getRpcUrlConfigFromChain';\n\nexport interface IGetLBTCMintingFeeParams {\n /**\n * Chain ID\n */\n chainId: TChainId;\n /**\n * RPC URL\n */\n rpcUrl?: string;\n}\n\n/**\n * Get LBTC minting fee.\n *\n * @param chainId - Chain ID\n * @param rpcUrl - RPC URL (optional)\n *\n * @returns LBTC minting fee\n */\nexport async function getLBTCMintingFee({\n chainId,\n rpcUrl,\n}: IGetLBTCMintingFeeParams): Promise<BigNumber> {\n const rpcUrlConfig = getRpcUrlConfigFromChain(chainId, rpcUrl);\n const provider = new ReadProvider({ chainId, rpcUrlConfig });\n const env = chainIdToEnv(chainId);\n const tokenContract = getLbtcTokenContract(provider, env);\n\n const fee: bigint = await tokenContract.methods.getMintFee().call();\n const feeBtc = new BigNumber(fromSatoshi(fee.toString(10)));\n\n return feeBtc;\n}\n","import { Provider } from '../../provider';\nimport { IProviderBasedParams } from '../types';\n\nexport type SignLbtcDestionationAddrParams = IProviderBasedParams;\n\n/**\n * Signs the destination address for the LBTC in active chain\n * in the current account. Signing is necessary for the\n * generation of the deposit address.\n *\n * @param {SignLbtcDestionationAddrParams} params\n *\n * @returns {Promise<string>} The signature of the message.\n */\nexport async function signLbtcDestionationAddr(\n params: SignLbtcDestionationAddrParams,\n): Promise<string> {\n const provider = new Provider(params);\n\n const message = `destination chain id is ${params.chainId}`;\n\n return provider.signMessage(message);\n}\n","export const SECONDS_PER_DAY = 24 * 60 * 60;\nexport const MS_PER_DAY = SECONDS_PER_DAY * 1000;\n","interface IGetTypedData {\n chainId: number;\n verifyingContract: string;\n fee: string;\n expiry: number;\n}\n\nexport function getTypedData({\n chainId,\n verifyingContract,\n fee,\n expiry,\n}: IGetTypedData) {\n return {\n domain: {\n name: 'Lombard Staked Bitcoin',\n version: '1',\n chainId,\n verifyingContract,\n },\n message: {\n chainId,\n fee,\n expiry,\n },\n primaryType: 'feeApproval',\n types: {\n EIP712Domain: [\n { name: 'name', type: 'string' },\n { name: 'version', type: 'string' },\n { name: 'chainId', type: 'uint256' },\n { name: 'verifyingContract', type: 'address' },\n ],\n feeApproval: [\n { name: 'chainId', type: 'uint256' },\n { name: 'fee', type: 'uint256' },\n { name: 'expiry', type: 'uint256' },\n ],\n },\n };\n}\n","import { IEnvParam } from '../../common/types/internalTypes';\nimport { Provider } from '../../provider';\nimport { SECONDS_PER_DAY } from '../const';\nimport { IProviderBasedParams } from '../types';\nimport { getLbtcTokenContract } from '../utils/getLbtcTokenContract';\nimport { getTypedData } from './getTypedData';\n\nconst NO_SIGNATURE_ERROR =\n 'Failed to obtain a valid signature. The response is undefined or invalid.';\n\nexport interface ISignNetworkFeeParams\n extends Pick<IProviderBasedParams, 'provider' | 'chainId'>,\n IEnvParam {\n /**\n * User address\n */\n address: string;\n /**\n * Authorization fee\n */\n fee: string;\n /**\n * Expiration time\n */\n expiry: number;\n}\n\nexport interface ISignNetworkFeeResponse {\n /**\n * signature\n */\n signature: string;\n /**\n * JSON typed data used for the signature\n */\n typedData: string;\n}\n\nconst getDefaultExpiryUnix = () => {\n return Math.floor(Date.now() / 1000 + SECONDS_PER_DAY);\n};\n\n/**\n * Signs the network fee transaction in the current account.\n * Signing is necessary for the auto-mint.\n *\n * @param {ISignNetworkFeeParams} params - The parameters for signing network fee\n * @returns {Promise<ISignNetworkFeeResponse>} A promise that resolves to the signature and typed data\n */\nexport async function signNetworkFee({\n address,\n provider,\n fee,\n chainId,\n env,\n expiry = getDefaultExpiryUnix(),\n}: ISignNetworkFeeParams): Promise<ISignNetworkFeeResponse> {\n const providerInstance = new Provider({\n provider,\n account: address,\n chainId,\n });\n\n const tokenContract = getLbtcTokenContract(providerInstance, env);\n const verifyingContract = tokenContract.options.address;\n const typedData = JSON.stringify(\n getTypedData({\n chainId,\n verifyingContract,\n fee,\n expiry,\n }),\n );\n\n const signature = await providerInstance.web3?.currentProvider?.request<\n 'eth_signTypedData_v4',\n string\n >({\n method: 'eth_signTypedData_v4',\n params: [address, typedData],\n });\n\n if (typeof signature === 'string') {\n return { signature, typedData: typedData };\n }\n\n if (!signature?.result) {\n throw new Error(NO_SIGNATURE_ERROR);\n }\n\n return { signature: signature.result, typedData: typedData };\n}\n","import { OChainId, TChainId } from '../../common/types/types';\n\nexport const STAKE_AND_BAKE_SPENDER_CONTRACTS: Record<number, string> = {\n [OChainId.holesky]: '0x52BD640617eeD47A00dA0da93351092D49208d1d',\n} as const;\n\nexport const SUPPORTED_STAKE_AND_BAKE_CHAINS = Object.keys(\n STAKE_AND_BAKE_SPENDER_CONTRACTS,\n).map(Number);\n\nexport const getStakeAndBakeSpenderContract = (chainId: TChainId): string => {\n return STAKE_AND_BAKE_SPENDER_CONTRACTS[chainId];\n};\n","import { TChainId } from '../../common/types/types';\nimport { getErrorMessage } from '../../common/utils/getErrorMessage';\nimport { ReadProvider } from '../../provider/ReadProvider';\nimport { chainIdToEnv } from '../utils/chainIdToEnv';\nimport { getLbtcTokenContract } from '../utils/getLbtcTokenContract';\nimport { getRpcUrlConfigFromChain } from '../utils/getRpcUrlConfigFromChain';\n\nexport interface IGetPermitNonceParams {\n /**\n * Owner address to check permit nonce for\n */\n owner: string;\n /**\n * Chain ID of the network\n */\n chainId: TChainId;\n /**\n * RPC URL for the network (optional)\n */\n rpcUrl?: string;\n}\n\n/**\n * Get permit nonce for a specific owner address from LBTC contract.\n * This nonce is used in EIP-2612 permit operations.\n *\n * @param {IGetPermitNonceParams} params - Parameters for getting permit nonce\n * @returns {Promise<string>} Promise that resolves to the permit nonce value\n */\nexport async function getPermitNonce({\n owner,\n rpcUrl,\n chainId,\n}: IGetPermitNonceParams): Promise<string> {\n const rpcUrlConfig = getRpcUrlConfigFromChain(chainId, rpcUrl);\n const provider = new ReadProvider({ chainId, rpcUrlConfig });\n const env = chainIdToEnv(chainId);\n const tokenContract = getLbtcTokenContract(provider, env);\n\n try {\n const nonce: bigint = await tokenContract.methods.nonces(owner).call();\n return nonce.toString();\n } catch (error) {\n const errorMessage = getErrorMessage(error);\n throw new Error(errorMessage);\n }\n}\n","import { TChainId } from '../../common/types/types';\nimport { getPermitNonce } from '../getPermitNonce';\n\nexport interface IStakeAndBakeTypedData {\n chainId: TChainId;\n expiry: number;\n owner: string;\n spender: string;\n value: string;\n rpcUrl?: string;\n verifyingContract: string;\n}\n\n/**\n * Generates EIP-712 typed data for stake and bake signature\n *\n * @param {IStakeAndBakeTypedData} params - Parameters for generating typed data\n * @returns {object} The typed data object conforming to EIP-712\n */\nexport async function getStakeAndBakeTypedData({\n chainId,\n expiry,\n owner,\n spender,\n value,\n rpcUrl,\n verifyingContract,\n}: IStakeAndBakeTypedData) {\n const nonce = await getPermitNonce({\n owner,\n chainId,\n rpcUrl,\n });\n\n return {\n domain: {\n name: 'Lombard Staked Bitcoin',\n version: '1',\n chainId,\n verifyingContract,\n },\n types: {\n EIP712Domain: [\n {\n name: 'name',\n type: 'string',\n },\n {\n name: 'version',\n type: 'string',\n },\n {\n name: 'chainId',\n type: 'uint256',\n },\n {\n name: 'verifyingContract',\n type: 'address',\n },\n ],\n Permit: [\n { name: 'owner', type: 'address' },\n { name: 'spender', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'nonce', type: 'uint256' },\n { name: 'deadline', type: 'uint256' },\n ],\n },\n primaryType: 'Permit',\n message: {\n owner,\n spender,\n value,\n nonce,\n deadline: expiry.toString(),\n },\n };\n}\n","import { TChainId } from '../../common/types/types';\nimport { getLbtcAddressConfig } from '../lbtcAddressConfig';\n\n/**\n * Gets the LBTC contract address for a given chain ID\n * @param chainId The chain ID\n * @returns The LBTC contract address for the chain\n */\nexport const getVerifyingContract = (chainId: TChainId): string => {\n const lbtcAddressConfig = getLbtcAddressConfig('stage');\n const address = lbtcAddressConfig[chainId];\n if (!address) {\n throw new Error(`No LBTC contract address configured for chain ID ${chainId}`);\n }\n return address;\n};","import { TChainId } from '../../common/types/types';\nimport { Provider } from '../../provider';\nimport { IProviderBasedParams } from '../types';\nimport { getStakeAndBakeTypedData } from './getTypedData';\nimport { getVerifyingContract } from './utils';\n\nconst NO_SIGNATURE_ERROR =\n 'Failed to obtain a valid signature. The response is undefined or invalid.';\n\nexport interface ISignStakeAndBakeParams\n extends Pick<IProviderBasedParams, 'provider'> {\n /**\n * The address to sign with (owner)\n */\n address: string;\n /**\n * Chain ID for the signature\n */\n chainId: TChainId;\n /**\n * The value to approve\n */\n value: string;\n /**\n * Expiry date as a unix timestamp\n */\n expiry: number;\n /**\n * Optional RPC URL for the network\n */\n rpcUrl?: string;\n /**\n * The spender address that will be authorized to spend tokens\n */\n spender: string;\n}\n\nexport interface ISignStakeAndBakeResult {\n /**\n * The signature\n */\n signature: string;\n /**\n * The typed data used to generate the signature\n */\n typedData: string;\n}\n\n/**\n * Signs stake and bake authorization with EIP-712\n *\n * @param {ISignStakeAndBakeParams} params - Parameters for signing\n * @returns {Promise<ISignStakeAndBakeResult>} The signature and typed data\n */\nexport async function signStakeAndBake({\n address,\n provider,\n chainId,\n value,\n expiry,\n rpcUrl,\n spender,\n}: ISignStakeAndBakeParams): Promise<ISignStakeAndBakeResult> {\n const providerInstance = new Provider({\n provider,\n account: address,\n chainId,\n });\n\n const verifyingContract = getVerifyingContract(chainId);\n\n const typedDataObject = await getStakeAndBakeTypedData({\n chainId,\n expiry,\n owner: address,\n spender,\n value,\n rpcUrl,\n verifyingContract,\n });\n\n const typedData = JSON.stringify(typedDataObject);\n\n const signature = await providerInstance.web3?.currentProvider?.request<\n 'eth_signTypedData_v4',\n string\n >({\n method: 'eth_signTypedData_v4',\n params: [address, typedData],\n });\n\n if (typeof signature === 'string') {\n return { signature, typedData };\n }\n\n if (!signature?.result) {\n throw new Error(NO_SIGNATURE_ERROR);\n }\n\n return { signature: signature.result, typedData };\n}\n","import { TChainId } from '../../common/types/types';\nimport { STAKE_AND_BAKE_SPENDER_CONTRACTS } from './contracts';\n\nexport const getStakeAndBakeSpenderAddress = (chainId: TChainId): string => {\n const address = STAKE_AND_BAKE_SPENDER_CONTRACTS[chainId];\n if (!address) {\n throw new Error(`No spender address configured for chain ID ${chainId}`);\n }\n return address;\n};\n"],"names":["OEnv","OChainId","getEthNetworkByEnv","env","getBscNetworkByEnv","getBaseNetworkByEnv","defaultEnv","ZERO_ADDRESS","stageConfig","testnetConfig","prodConfig","getApiConfig","getErrorMessage","error","err","_a","getAxiosErrorMessage","getErrorMessageFromObject","OChainName","getChainNameById","chainId","SANCTIONED_ADDRESS","ADDRESS_URL","SANCTIONS_MESSAGE","generateDepositBtcAddress","address","signature","eip712Data","referrerCode","partnerId","captchaToken","baseApiUrl","toChain","requestParams","data","axios","errorMsg","isSanctioned","getDepositBtcAddress","addresses","getDepositBtcAddresses","addressData","getActualAddress","actualAddress","acc","toBlockchain","requestrParams","BTC_DECIMALS","SATOSHI_SCALE","fromSatoshi","amount","toSatoshi","getChainIdByName","chain","ENotarizationStatus","ESessionState","getDepositsByAddress","mapResponse","BigNumber","MIN_STAKE_AMOUNT_BTC","getLBTCExchangeRate","chainIdName","minAmount","getNetworkFeeSignature","errorMessage","getUserStakeAndBakeSignature","userDestinationAddress","storeNetworkFeeSignature","typedData","storeStakeAndBakeSignature","rpcUrlConfig","getMaxPriorityFeePerGas","rpcUrl","convertedHexValue","Web3","FEE_MULTIPLIER","ADDITIONAL_SAFE_GAS_PRICE_WEI","ReadProvider","__publicField","defaultRpcUrlConfig","readWeb3","provider","web3","block","maxPriorityFeePerGas","pureGasPriceWei","abi","Provider","account","message","messageHex","from","to","sendOptions","web3Write","web3Read","estimate","estimateFee","extendedGasLimit","gasLimit","value","gasLimitMultiplier","nonce","tx","utils","estimatedGas","multipliedGasLimit","e","maxFeePerGas","safeGasPrice","resolve","reject","promise","transactionHash","getGasMultiplier","isValidChain","PLACEHOLDER_ADDRESS","getLbtcAddressConfig","getTokenABI","token","LBTCABI","IERC20","getLbtcTokenContract","lbtcAddressConfig","tokenAddress","contract","INSUFFICIENT_FUNDS_PARTIAL_ERROR","INSUFFICIENT_FUNDS_ERROR","hexify","hexString","claimLBTC","proofSignature","providerParams","tokenContract","ERR_MULTIPLE_ERRORS","JSONRPC_ERR_REJECTED_REQUEST","JSONRPC_ERR_UNAUTHORIZED","JSONRPC_ERR_UNSUPPORTED_METHOD","JSONRPC_ERR_DISCONNECTED","JSONRPC_ERR_CHAIN_DISCONNECTED","ERR_RPC_INVALID_JSON","ERR_RPC_INVALID_REQUEST","ERR_RPC_INVALID_METHOD","ERR_RPC_INVALID_PARAMS","ERR_RPC_INTERNAL_ERROR","ERR_RPC_INVALID_INPUT","ERR_RPC_MISSING_RESOURCE","ERR_RPC_UNAVAILABLE_RESOURCE","ERR_RPC_TRANSACTION_REJECTED","ERR_RPC_UNSUPPORTED_METHOD","ERR_RPC_LIMIT_EXCEEDED","ERR_RPC_NOT_SUPPORTED","BaseWeb3Error","msg","cause","MultipleErrors","unquotValue","result","_","v","errors","genericRpcErrorMessageTemplate","RpcErrorMessages","RpcError","rpcError","ParseError","InvalidRequestError","MethodNotFoundError","InvalidParamsError","InternalError","InvalidInputError","MethodNotSupported","ResourceUnavailableError","ResourcesNotFoundError","VersionNotSupportedError","TransactionRejectedError","LimitExceededError","rpcErrorsMap","isHexStrict","hex","FMT_NUMBER","FMT_BYTES","BlockTags","HardforksOrdered","getBasculeTokenContract","contractAddress","BASCULE_ABI","NO_DEPOSIT_ID_ERROR","INVALID_DEPOSIT_ID_ERROR","BasculeDepositStatus","getBasculeDepositStatus","txId","basculeAddress","basculeContract","status","PROD_NATIVE_MINT_CHAINS","chainIdToEnv","getRpcUrlConfigFromChain","getLBTCMintingFee","fee","signLbtcDestionationAddr","params","SECONDS_PER_DAY","getTypedData","verifyingContract","expiry","NO_SIGNATURE_ERROR","getDefaultExpiryUnix","signNetworkFee","providerInstance","_b","STAKE_AND_BAKE_SPENDER_CONTRACTS","SUPPORTED_STAKE_AND_BAKE_CHAINS","getStakeAndBakeSpenderContract","getPermitNonce","owner","getStakeAndBakeTypedData","spender","getVerifyingContract","signStakeAndBake","typedDataObject","getStakeAndBakeSpenderAddress"],"mappings":"iUAAaA,EAAO,CAClB,KAAM,OACN,QAAS,UACT,MAAO,OACT,EAIaC,EAAW,CACtB,SAAU,EACV,QAAS,KACT,kBAAmB,GACnB,yBAA0B,GAC1B,QAAS,SACT,KAAM,KACN,YAAa,MACb,uBAAwB,MAExB,KAAM,KACN,MAAO,IACT,EAkBaC,GAAsBC,GACjCA,IAAQH,EAAK,KAAOC,EAAS,SAAWA,EAAS,QAEtCG,GAAsBD,GACjCA,IAAQH,EAAK,KACTC,EAAS,kBACTA,EAAS,yBAEFI,GAAuBF,GAClCA,IAAQH,EAAK,KAAOC,EAAS,KAAOA,EAAS,YC7ClCK,EAAmBN,EAAK,KAMxBO,EAAe,6CCDtBC,GAA0B,CAC9B,WAAY,sCACd,EAEMC,GAA4B,CAChC,WAAY,8CACd,EAEMC,GAAyB,CAC7B,WAAY,sCACd,EAEaC,EAAe,CAACR,EAAYG,IAA2B,CAClE,OAAQH,EAAK,CACX,KAAKH,EAAK,KACD,OAAAU,GACT,KAAKV,EAAK,QACD,OAAAS,GACT,QACS,OAAAD,EACX,CACF,ECpBO,SAASI,EAAgBC,EAAwB,CAClD,OAAA,OAAOA,GAAU,SACZA,GAGeC,GACtB,OAAA,QAAAC,EAAAD,GAAA,YAAAA,EAAK,OAAL,YAAAC,EAAW,UAAW,OAAOD,EAAI,KAAK,SAAY,WAEjCD,CA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