@lombard.finance/sdk 0.8.2 → 0.8.3

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 ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";var j=Object.defineProperty;var q=(e,t,n)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var c=(e,t,n)=>(q(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("axios"),y=require("web3"),x=require("bignumber.js"),z=require("@bitcoin-js/tiny-secp256k1-asmjs"),f=require("bitcoinjs-lib");function Z(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const K=Z(z),l={prod:"prod",testnet:"testnet",stage:"stage"},r={ethereum:1,holesky:17e3},A=l.prod,M="0x0000000000000000000000000000000000000000",J={baseApiUrl:"https://staging.prod.lombard.finance"},X={baseApiUrl:"https://gastald-testnet.prod.lombard.finance"},Y={baseApiUrl:"https://mainnet.prod.lombard.finance"},T=(e=A)=>{switch(e){case l.prod:return Y;case l.testnet:return X;default:return J}};function F(e){return typeof e=="string"?e:e instanceof Error?Q(e):ee(e)}function Q(e){return e.response?e.response.data.message:e.message}function ee(e){return e!=null&&e.message?e.message:"Unknown error"}const te={eth:"DESTINATION_BLOCKCHAIN_ETHEREUM"};function I(e){switch(e){case r.holesky:case r.ethereum:return te.eth;default:throw new Error(`Unknown chain ID: ${e}`)}}const L="sanctioned_address",ne="api/v1/address/generate",ae="destination address is under sanctions";async function se({address:e,chainId:t,signature:n,referralId:a,env:s,captchaToken:i}){const{baseApiUrl:o}=T(s),p=I(t),m={to_address:e,to_address_signature:n,to_chain:p,referral_id:a,nonce:0,captcha:i};try{const{data:b}=await v.post(ne,m,{baseURL:o});return b.address}catch(b){const g=F(b);if(ie(g))return L;throw new Error(g)}}function ie(e){return!!e.includes(ae)}const re="api/v1/address";async function oe({address:e,chainId:t,env:n,referralId:a}){const s=await k({address:e,chainId:t,env:n,referralId:a}),i=pe(s);if(!i)throw new Error("No address");return i.btc_address}function pe(e){if(!e.length)return;const t=e.reduce((n,a)=>n.created_at<a.created_at?a:n,e[0]);return t.deprecated?void 0:t}async function k({address:e,chainId:t,env:n,referralId:a}){const{baseApiUrl:s}=T(n),i=I(t),o={to_address:e,to_blockchain:i,limit:1,offset:0,asc:!1,referral_id:a},{data:p}=await v.get(re,{baseURL:s,params:o});return(p==null?void 0:p.addresses)||[]}const ue=8,U=10**ue;function N(e){return+e/U}function P(e){return Math.floor(+e*U)}function ye(e,t=A){switch(e){case"DESTINATION_BLOCKCHAIN_ETHEREUM":return t===l.prod?r.ethereum:r.holesky;default:return r.ethereum}}async function de({address:e,env:t}){const{baseApiUrl:n}=T(t),{data:a}=await v.get(`api/v1/address/outputs/${e}`,{baseURL:n});return((a==null?void 0:a.outputs)??[]).map(le(t))}function le(e){return t=>({txid:t.txid,index:t.index??0,blockHeight:t.block_height?Number(t.block_height):void 0,blockTime:t.block_time?Number(t.block_time):void 0,value:N(t.value),address:t.address,chainId:ye(t.to_chain,e),isClaimed:!!t.claim_tx,rawPayload:t.raw_payload,signature:t.signature,isRestricted:!!t.sanctioned,notarizationWaitDur:t.notarization_wait_dur?Number(t.notarization_wait_dur):void 0})}async function me({env:e,chainId:t,amount:n}){const{baseApiUrl:a}=T(e),s=I(t),{data:i}=await v.get(`api/v1/exchange/rate/${s}`,{baseURL:a,params:{amount:n}});return i.amount_out}const G={[r.ethereum]:"https://rpc.ankr.com/eth",[r.holesky]:"https://rpc.ankr.com/eth_holesky"};async function ce(e){const n=await(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"eth_maxPriorityFeePerGas",params:[]})})).json(),a=y.utils.hexToNumber(n==null?void 0:n.result);return new x(Number(a))}const be=2,fe=25e3;class Te{constructor({chainId:t,rpcUrlConfig:n}){c(this,"chainId");c(this,"rpcConfig");this.chainId=t,this.rpcConfig={...G,...n}}getReadWeb3(){const t=this.getRpcUrl(),n=new y,a=new y.providers.HttpProvider(t);return n.setProvider(a),n}getRpcUrl(){var a;const{chainId:t}=this,n=(a=this.rpcConfig)==null?void 0:a[t];if(!n)throw console.error(`You might need to add the rpcConfig for the ${t} chain ID when creating the provider.`),new Error(`RPC URL for chainId ${t} not found`);return n}async getMaxFees(){const t=this.getReadWeb3(),n=this.getRpcUrl(),[a,s]=await Promise.all([t.eth.getBlock("latest"),ce(n)]);return!(a!=null&&a.baseFeePerGas)&&typeof(a==null?void 0:a.baseFeePerGas)!="bigint"?{}:{maxFeePerGas:+new x(a.baseFeePerGas.toString(10)).multipliedBy(be).plus(s),maxPriorityFeePerGas:+s}}async getSafeGasPriceWei(){const t=await this.getReadWeb3().eth.getGasPrice();return new x(t.toString(10)).plus(fe)}createContract(t,n){const a=this.getReadWeb3();return new a.eth.Contract(t,n)}}class C extends Te{constructor({provider:n,account:a,chainId:s,rpcUrlConfig:i}){super({chainId:s,rpcUrlConfig:i});c(this,"web3");c(this,"account");c(this,"rpcConfig");this.web3=new y(n),this.account=a,this.chainId=s,this.rpcConfig={...G,...i}}async signMessage(n){const{account:a}=this,s=`0x${Buffer.from(n,"utf8").toString("hex")}`;return this.web3.currentProvider.request({method:"personal_sign",params:[s,a]})}async sendTransactionAsync(n,a,s){const{chainId:i,web3:o}=this,p=this.getReadWeb3(),{data:m,estimate:b=!1,estimateFee:g=!1,extendedGasLimit:R,gasLimit:H="0",value:V="0",gasLimitMultiplier:$=1}=s;let{nonce:h}=s;h||(h=await p.eth.getTransactionCount(n)),console.log(`Nonce: ${h}`);const u={from:n,to:a,value:y.utils.numberToHex(V),data:m,nonce:h,chainId:y.utils.numberToHex(i)};if(b)try{const d=await p.eth.estimateGas(u),w=Math.round(Number(d)*$);R?u.gas=y.utils.numberToHex(w+R):u.gas=y.utils.numberToHex(w)}catch(d){throw new Error(d.message??"Failed to estimate gas limit for transaction.")}else u.gas=y.utils.numberToHex(H);const{maxFeePerGas:_,maxPriorityFeePerGas:D}=g?await this.getMaxFees().catch(()=>s):s;if(D!==void 0&&(u.maxPriorityFeePerGas=y.utils.numberToHex(D)),_!==void 0&&(u.maxFeePerGas=y.utils.numberToHex(_)),!u.maxFeePerGas&&!u.maxPriorityFeePerGas){const d=await this.getSafeGasPriceWei();u.gasPrice=d.toString(10)}if(!u.maxFeePerGas&&!u.maxPriorityFeePerGas){const d=await this.getSafeGasPriceWei();u.gasPrice=d.toString(10)}return console.log("Sending transaction via Web3: ",u),new Promise((d,w)=>{const B=o.eth.sendTransaction(u);B.once("transactionHash",async O=>{console.log(`Just signed transaction has is: ${O}`),d({receiptPromise:B,transactionHash:O})}).catch(w)})}createContract(n,a){return new this.web3.eth.Contract(n,a)}}function S(e){switch(e){case r.ethereum:return 1.3;case r.holesky:return 1.5;default:return 1.3}}function ge(e){return Object.values(r).includes(e)}const he={[r.holesky]:"0xED7bfd5C1790576105Af4649817f6d35A75CD818",[r.ethereum]:M},we={[r.holesky]:"0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2",[r.ethereum]:M},ve={[r.holesky]:M,[r.ethereum]:"0x8236a87084f8b84306f72007f36f2618a5634494"};function W(e=A){switch(e){case l.prod:return ve;case l.testnet:return we;default:return he}}const Ce=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}],xe=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"uint256",name:"dustLimit",type:"uint256"}],name:"AmountBelowDustLimit",type:"error"},{inputs:[{internalType:"uint256",name:"fee",type:"uint256"}],name:"AmountLessThanCommission",type:"error"},{inputs:[],name:"AmountTooSmallToPayRelativeFee",type:"error"},{inputs:[{internalType:"uint256",name:"expected",type:"uint256"},{internalType:"uint256",name:"received",type:"uint256"}],name:"BadChainId",type:"error"},{inputs:[],name:"BadCommission",type:"error"},{inputs:[],name:"BadDestination",type:"error"},{inputs:[{internalType:"address",name:"expected",type:"address"},{internalType:"address",name:"received",type:"address"}],name:"BadToContractAddress",type:"error"},{inputs:[],name:"ECDSAInvalidSignature",type:"error"},{inputs:[{internalType:"uint256",name:"length",type:"uint256"}],name:"ECDSAInvalidSignatureLength",type:"error"},{inputs:[{internalType:"bytes32",name:"s",type:"bytes32"}],name:"ECDSAInvalidSignatureS",type:"error"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"allowance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientAllowance",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientBalance",type:"error"},{inputs:[{internalType:"address",name:"approver",type:"address"}],name:"ERC20InvalidApprover",type:"error"},{inputs:[{internalType:"address",name:"receiver",type:"address"}],name:"ERC20InvalidReceiver",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"}],name:"ERC20InvalidSender",type:"error"},{inputs:[{internalType:"address",name:"spender",type:"address"}],name:"ERC20InvalidSpender",type:"error"},{inputs:[],name:"EnforcedPause",type:"error"},{inputs:[],name:"ExpectedPause",type:"error"},{inputs:[],name:"InvalidDustFeeRate",type:"error"},{inputs:[],name:"InvalidInitialization",type:"error"},{inputs:[],name:"KnownDestination",type:"error"},{inputs:[],name:"MathOverflowedMulDiv",type:"error"},{inputs:[],name:"NotInitializing",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[],name:"ProofAlreadyUsed",type:"error"},{inputs:[],name:"ReentrancyGuardReentrantCall",type:"error"},{inputs:[],name:"ScriptPubkeyUnsupported",type:"error"},{inputs:[],name:"SignatureVerificationFailed",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"UnauthorizedAccount",type:"error"},{inputs:[],name:"UnknownDestination",type:"error"},{inputs:[],name:"WithdrawalsDisabled",type:"error"},{inputs:[],name:"WrongAddressEncoding",type:"error"},{inputs:[],name:"WrongChainIdEncoding",type:"error"},{inputs:[],name:"WrongDataLength",type:"error"},{inputs:[],name:"WrongDataLength",type:"error"},{inputs:[],name:"WrongTxIdEncoding",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{inputs:[],name:"ZeroAmount",type:"error"},{inputs:[],name:"ZeroAmount",type:"error"},{inputs:[],name:"ZeroChainId",type:"error"},{inputs:[],name:"ZeroChainId",type:"error"},{inputs:[],name:"ZeroContractHash",type:"error"},{inputs:[],name:"ZeroTxHash",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"prevVal",type:"address"},{indexed:!0,internalType:"address",name:"newVal",type:"address"}],name:"BasculeChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"toChain",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"toContract",type:"bytes32"}],name:"BridgeDestinationAdded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"toChain",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"toContract",type:"bytes32"}],name:"BridgeDestinationRemoved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint64",name:"prevValue",type:"uint64"},{indexed:!0,internalType:"uint64",name:"newValue",type:"uint64"}],name:"BurnCommissionChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"prevVal",type:"address"},{indexed:!0,internalType:"address",name:"newVal",type:"address"}],name:"ConsortiumChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"newValue",type:"uint64"},{indexed:!0,internalType:"bytes32",name:"toChain",type:"bytes32"}],name:"DepositAbsoluteCommissionChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint16",name:"newValue",type:"uint16"},{indexed:!0,internalType:"bytes32",name:"toChain",type:"bytes32"}],name:"DepositRelativeCommissionChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"fromAddress",type:"address"},{indexed:!0,internalType:"bytes32",name:"toAddress",type:"bytes32"},{indexed:!1,internalType:"bytes32",name:"toContract",type:"bytes32"},{indexed:!1,internalType:"bytes32",name:"chainId",type:"bytes32"},{indexed:!1,internalType:"uint64",name:"amount",type:"uint64"}],name:"DepositToBridge",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"oldRate",type:"uint256"},{indexed:!0,internalType:"uint256",name:"newRate",type:"uint256"}],name:"DustFeeRateChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"version",type:"uint64"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"string",name:"name",type:"string"},{indexed:!1,internalType:"string",name:"symbol",type:"string"}],name:"NameAndSymbolChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"transactionId",type:"bytes32"},{indexed:!0,internalType:"uint32",name:"index",type:"uint32"},{indexed:!1,internalType:"bytes32",name:"proofHash",type:"bytes32"}],name:"OutputProcessed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferStarted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Paused",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousPauser",type:"address"},{indexed:!0,internalType:"address",name:"newPauser",type:"address"}],name:"PauserRoleTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"prevValue",type:"address"},{indexed:!0,internalType:"address",name:"newValue",type:"address"}],name:"TreasuryAddressChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Unpaused",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"fromAddress",type:"address"},{indexed:!1,internalType:"bytes",name:"scriptPubKey",type:"bytes"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"UnstakeRequest",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"toAddress",type:"address"},{indexed:!0,internalType:"bytes32",name:"txHash",type:"bytes32"},{indexed:!0,internalType:"uint32",name:"eventIndex",type:"uint32"},{indexed:!1,internalType:"bytes32",name:"proofHash",type:"bytes32"},{indexed:!1,internalType:"bytes32",name:"fromContract",type:"bytes32"},{indexed:!1,internalType:"bytes32",name:"fromChainId",type:"bytes32"},{indexed:!1,internalType:"uint64",name:"amount",type:"uint64"}],name:"WithdrawFromBridge",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"",type:"bool"}],name:"WithdrawalsEnabled",type:"event"},{inputs:[],name:"Bascule",outputs:[{internalType:"contract IBascule",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"MAX_COMMISSION",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[],name:"acceptOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"toChain",type:"bytes32"},{internalType:"bytes32",name:"toContract",type:"bytes32"},{internalType:"uint16",name:"relCommission",type:"uint16"},{internalType:"uint64",name:"absCommission",type:"uint64"}],name:"addDestination",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"scriptPubkey",type:"bytes"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"calcUnstakeRequestAmount",outputs:[{internalType:"uint256",name:"amountAfterFee",type:"uint256"},{internalType:"bool",name:"isAboveDust",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newVal",type:"address"}],name:"changeBascule",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint64",name:"newValue",type:"uint64"}],name:"changeBurnCommission",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newVal",type:"address"}],name:"changeConsortium",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint64",name:"newValue",type:"uint64"},{internalType:"bytes32",name:"chain",type:"bytes32"}],name:"changeDepositAbsoluteCommission",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint16",name:"newValue",type:"uint16"},{internalType:"bytes32",name:"chain",type:"bytes32"}],name:"changeDepositRelativeCommission",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newRate",type:"uint256"}],name:"changeDustFeeRate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"string",name:"name_",type:"string"},{internalType:"string",name:"symbol_",type:"string"}],name:"changeNameAndSymbol",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newValue",type:"address"}],name:"changeTreasuryAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"consortium",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"toChain",type:"bytes32"},{internalType:"bytes32",name:"toAddress",type:"bytes32"},{internalType:"uint64",name:"amount",type:"uint64"}],name:"depositToBridge",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"getBurnCommission",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"toChain",type:"bytes32"}],name:"getDepositAbsoluteCommission",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"toChain",type:"bytes32"}],name:"getDepositRelativeCommission",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"chainId",type:"bytes32"}],name:"getDestination",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDustFeeRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getTreasury",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"consortium_",type:"address"},{internalType:"uint64",name:"burnCommission_",type:"uint64"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"proof",type:"bytes32"}],name:"isUsed",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"data",type:"bytes"},{internalType:"bytes",name:"proofSignature",type:"bytes"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"paused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"pauser",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"pendingOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"scriptPubkey",type:"bytes"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"redeem",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"toChain",type:"bytes32"}],name:"removeDestination",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"toggleWithdrawals",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newPauser",type:"address"}],name:"transferPauserRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"data",type:"bytes"},{internalType:"bytes",name:"proofSignature",type:"bytes"}],name:"withdrawFromBridge",outputs:[],stateMutability:"nonpayable",type:"function"}];function Ae(e){switch(e){case"LBTC":return xe;default:return Ce}}function E(e,t){const n=W(t),{chainId:a}=e;if(!ge(a))throw new Error(`This chain ${a} is not supported`);const s=n[a];if(!s)throw new Error(`Token address for chain ${a} is not defined`);const i=Ae("LBTC"),o=e.createContract(i,s);return o.options.address||(o.options.address=s),o}function Me({spender:e,amount:t,env:n,...a}){const s=new C(a),i=E(s,n),o=P(t),p=i.methods.approve(e,o);return s.sendTransactionAsync(s.account,i.options.address,{data:p.encodeABI(),estimate:!0,estimateFee:!0,gasLimitMultiplier:S(s.chainId)})}const Ie="insufficient funds",Pe="Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.";async function Se({data:e,proofSignature:t,env:n,...a}){const s=new C(a),i=E(s,n),o=i.methods.mint(e,t);try{return await s.sendTransactionAsync(s.account,i.options.address,{data:o.encodeABI(),estimate:!0,estimateFee:!0,gasLimitMultiplier:S(s.chainId)})}catch(p){const m=F(p);throw m.includes(Ie)?new Error(Pe):new Error(m)}}async function Ee(e){const t=new C(e),n=`destination chain id is ${e.chainId}`;return t.signMessage(n)}f.initEccLib(K);function Re(e,t=l.prod){var i;const n=_e(e),s=(i=f.payments[n]({address:e,network:t===l.prod?f.networks.bitcoin:f.networks.testnet}).output)==null?void 0:i.toString("hex");if(!s)throw new Error("Output script is not found.");return`0x${s}`}function _e(e){const t=f.address.fromBech32(e);if(t.version===1&&t.data.length===32)return"p2tr";if(t.version===0&&t.data.length===20)return"p2wpkh";throw new Error("Payment type is not supported.")}function De({btcAddress:e,amount:t,env:n,...a}){const s=new C(a),i=E(s,n),o=Re(e,n),p=P(t),m=i.methods.redeem(o,p);return s.sendTransactionAsync(s.account,i.options.address,{data:m.encodeABI(),estimate:!0,estimateFee:!0,gasLimitMultiplier:S(s.chainId)})}exports.OChainId=r;exports.OEnv=l;exports.SANCTIONED_ADDRESS=L;exports.approveLBTC=Me;exports.claimLBTC=Se;exports.fromSatoshi=N;exports.generateDepositBtcAddress=se;exports.getApiConfig=T;exports.getDepositBtcAddress=oe;exports.getDepositBtcAddresses=k;exports.getDepositsByAddress=de;exports.getLBTCExchageRate=me;exports.getLbtcAddressConfig=W;exports.signLbtcDestionationAddr=Ee;exports.toSatoshi=P;exports.unstakeLBTC=De;
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +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/getCainIdByName.ts","../src/sdk/getDepositsByAddress/getDepositsByAddress.ts","../src/sdk/getLBTCExchageRate/getLBTCExchageRate.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/approveLBTC/approveLBTC.ts","../src/web3Sdk/claimLBTC/claimLBTC.ts","../src/web3Sdk/signLbtcDestionationAddr/signLbtcDestionationAddr.ts","../src/btcSdk/utils/getOutputScript.ts","../src/web3Sdk/unstakeLBTC/unstakeLBTC.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} as const;\n\nexport type TChainId = (typeof OChainId)[keyof typeof OChainId];\n\n/**\n * Abstract EIP-1193 provider\n */\nexport interface IEIP1193Provider {\n request: (args: any) => Promise<any>;\n}\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 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} 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.holesky:\n case OChainId.ethereum:\n return OChainName.eth;\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 referral ID.\n */\n referralId: string;\n /**\n * The captcha token.\n */\n captchaToken?: 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 referralId,\n env,\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 referral_id: referralId,\n nonce: 0,\n captcha: captchaToken,\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\ninterface IDepositAddress {\n btc_address: string;\n created_at: string;\n deprecated?: boolean;\n type: string;\n used?: boolean;\n deposit_metadata: {\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 referralId: string;\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 referralId,\n}: IGetDepositBtcAddressParams): Promise<string> {\n const addresses = await getDepositBtcAddresses({\n address,\n chainId,\n env,\n referralId,\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 referralId,\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 referral_id: referralId,\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;\nconst 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 { OChainId, OEnv, TChainId, TEnv } from '../../common/types/types';\nimport { TChainName } from '../internalTypes';\n\n/**\n * @param chainId the chain ID\n *\n * @returns the chain name\n */\nexport function getCainIdByName(\n chain: string,\n env: TEnv = defaultEnv,\n): TChainId {\n switch (chain as TChainName) {\n case 'DESTINATION_BLOCKCHAIN_ETHEREUM':\n return env === OEnv.prod ? OChainId.ethereum : OChainId.holesky;\n\n default:\n return OChainId.ethereum;\n }\n}\n","import axios from 'axios';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { TChainId, TEnv } from '../../common/types/types';\nimport { fromSatoshi } from '../../common/utils/convertSatoshi';\nimport { getApiConfig } from '../apiConfig';\nimport { getCainIdByName } from '../utils/getCainIdByName';\n\ntype Address = string;\ntype Seconds = number;\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?: string;\n signature?: string;\n claim_tx?: string;\n block_height?: string;\n block_time?: string;\n sanctioned?: boolean;\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: number;\n address: Address;\n chainId: TChainId;\n isClaimed: boolean;\n rawPayload?: string;\n signature?: string;\n isRestricted?: boolean;\n notarizationWaitDur?: Seconds;\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/${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: fromSatoshi(data.value),\n address: data.address,\n chainId: getCainIdByName(data.to_chain, env),\n // todo: return claiming tx from the API when it's available\n isClaimed: !!data.claim_tx,\n rawPayload: data.raw_payload,\n signature: data.signature,\n isRestricted: !!data.sanctioned,\n notarizationWaitDur: data.notarization_wait_dur\n ? Number(data.notarization_wait_dur)\n : undefined,\n });\n}\n","import axios from 'axios';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { TChainId } from '../../common/types/types';\nimport { getApiConfig } from '../apiConfig';\nimport { getChainNameById } from '../utils/getChainNameById';\n\ntype ExchangeRateResponse = {\n amount_out: string;\n};\n\nexport interface IGetLBTCExchageRateParams extends IEnvParam {\n /**\n * The chain id of the asset to get the exchange rate for\n */\n chainId: TChainId;\n /**\n * The amount of the asset to get the exchange rate for\n */\n amount: number;\n}\n\n/**\n * Retrieves the exchange rate for LBTC.\n *\n * @param {IGetLBTCExchageRateParams} params\n *\n * @returns {Promise<string>} - The exchange rate.\n */\nexport async function getLBTCExchageRate({\n env,\n chainId,\n amount,\n}: IGetLBTCExchageRateParams): Promise<string> {\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 return data.amount_out;\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};\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;\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 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\nconst testnetConfig: LbtcTokenConfig = {\n [OChainId.holesky]: '0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2',\n [OChainId.ethereum]: PLACEHOLDER_ADDRESS,\n};\n\nconst prodConfig: LbtcTokenConfig = {\n [OChainId.holesky]: PLACEHOLDER_ADDRESS,\n [OChainId.ethereum]: '0x8236a87084f8b84306f72007f36f2618a5634494',\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 { 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, 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 { toSatoshi } from '../../common/utils/convertSatoshi';\nimport { IWeb3SendResult, Provider } from '../../provider';\nimport { IProviderBasedParams } from '../types';\nimport { getGasMultiplier } from '../utils/getGasMultiplier';\nimport { getLbtcTokenContract } from '../utils/getLbtcTokenContract';\n\nexport interface IApproveLBTCParams extends IProviderBasedParams, IEnvParam {\n /**\n * Spender address\n */\n spender: string;\n /**\n * The amount of LBTC to approve\n */\n amount: number;\n}\n\n/**\n * Approves the transfer of a specified amount of LBTC tokens.\n *\n * @param {IApproveLBTCParams} params\n *\n * @returns {Promise<IWeb3SendResult>} transaction promise\n */\nexport function approveLBTC({\n spender,\n amount,\n env,\n ...providerParams\n}: IApproveLBTCParams): Promise<IWeb3SendResult> {\n const provider = new Provider(providerParams);\n const tokenContract = getLbtcTokenContract(provider, env);\n const amountSat = toSatoshi(amount);\n\n const tx = tokenContract.methods.approve(spender, amountSat);\n\n return provider.sendTransactionAsync(\n provider.account,\n tokenContract.options.address,\n {\n data: tx.encodeABI(),\n estimate: true,\n estimateFee: true,\n gasLimitMultiplier: getGasMultiplier(provider.chainId),\n },\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\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 const tokenContract = getLbtcTokenContract(provider, env);\n\n const tx = tokenContract.methods.mint(data, proofSignature);\n\n try {\n const result = await provider.sendTransactionAsync(\n provider.account,\n tokenContract.options.address,\n {\n data: tx.encodeABI(),\n estimate: true,\n estimateFee: true,\n gasLimitMultiplier: getGasMultiplier(provider.chainId),\n },\n );\n\n return result;\n } catch (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","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","import * as ecc from '@bitcoin-js/tiny-secp256k1-asmjs';\nimport {\n address as addressUtils,\n initEccLib,\n networks,\n payments,\n} from 'bitcoinjs-lib';\nimport { OEnv, TEnv } from '../../common/types/types';\n\ninitEccLib(ecc);\n\n/**\n * Get output script from address.\n *\n * @param address - The address.\n * @param networkMode - The network mode.\n *\n * @returns The output script.\n */\nexport function getOutputScript(\n address: string,\n env: TEnv = OEnv.prod,\n): string {\n const paymentType = getPaymentType(address);\n\n const payment = payments[paymentType]({\n address,\n network: env === OEnv.prod ? networks.bitcoin : networks.testnet,\n });\n\n const paymentOutputScript = payment.output?.toString('hex');\n\n if (!paymentOutputScript) {\n throw new Error('Output script is not found.');\n }\n\n return `0x${paymentOutputScript}`;\n}\n\nfunction getPaymentType(address: string): 'p2tr' | 'p2wpkh' {\n const result = addressUtils.fromBech32(address);\n\n const isP2TR = result.version === 1 && result.data.length === 32;\n if (isP2TR) {\n return 'p2tr';\n }\n\n const isP2WPKH = result.version === 0 && result.data.length === 20;\n if (isP2WPKH) {\n return 'p2wpkh';\n }\n\n throw new Error('Payment type is not supported.');\n}\n","import { getOutputScript } from '../../btcSdk/utils/getOutputScript';\nimport { IEnvParam } from '../../common/types/internalTypes';\nimport { toSatoshi } from '../../common/utils/convertSatoshi';\nimport { IWeb3SendResult, Provider } from '../../provider';\nimport { IProviderBasedParams } from '../types';\nimport { getGasMultiplier } from '../utils/getGasMultiplier';\nimport { getLbtcTokenContract } from '../utils/getLbtcTokenContract';\n\nexport interface IUnstakeLBTCParams extends IProviderBasedParams, IEnvParam {\n /**\n * The BTC address to send the unstaked BTC to.\n */\n btcAddress: string;\n /**\n * The amount of LBTC to unstake.\n */\n amount: number;\n}\n\n/**\n * Unstakes LBTC to the specified BTC address.\n *\n * @param {IUnstakeLBTCParams} params\n *\n * @returns {Promise<IWeb3SendResult>} transaction promise\n */\nexport function unstakeLBTC({\n btcAddress,\n amount,\n env,\n ...providerParams\n}: IUnstakeLBTCParams): Promise<IWeb3SendResult> {\n const provider = new Provider(providerParams);\n const tokenContract = getLbtcTokenContract(provider, env);\n const outputScript = getOutputScript(btcAddress, env);\n\n const amountSat = toSatoshi(amount);\n\n const tx = tokenContract.methods.redeem(outputScript, amountSat);\n\n return provider.sendTransactionAsync(\n provider.account,\n tokenContract.options.address,\n {\n data: tx.encodeABI(),\n estimate: true,\n estimateFee: true,\n gasLimitMultiplier: getGasMultiplier(provider.chainId),\n },\n );\n}\n"],"names":["OEnv","OChainId","defaultEnv","ZERO_ADDRESS","stageConfig","testnetConfig","prodConfig","getApiConfig","env","getErrorMessage","error","getAxiosErrorMessage","getErrorMessageFromObject","OChainName","getChainNameById","chainId","SANCTIONED_ADDRESS","ADDRESS_URL","SANCTIONS_MESSAGE","generateDepositBtcAddress","address","signature","referralId","captchaToken","baseApiUrl","toChain","requestParams","data","axios","errorMsg","isSanctioned","getDepositBtcAddress","addresses","getDepositBtcAddresses","addressData","getActualAddress","actualAddress","acc","toBlockchain","requestrParams","BTC_DECIMALS","SATOSHI_SCALE","fromSatoshi","amount","toSatoshi","getCainIdByName","chain","getDepositsByAddress","mapResponse","getLBTCExchageRate","chainIdName","rpcUrlConfig","getMaxPriorityFeePerGas","rpcUrl","convertedHexValue","Web3","BigNumber","FEE_MULTIPLIER","ADDITIONAL_SAFE_GAS_PRICE_WEI","ReadProvider","__publicField","defaultRpcUrlConfig","readWeb3","provider","_a","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","approveLBTC","spender","providerParams","tokenContract","amountSat","INSUFFICIENT_FUNDS_PARTIAL_ERROR","INSUFFICIENT_FUNDS_ERROR","claimLBTC","proofSignature","errorMessage","signLbtcDestionationAddr","params","initEccLib","ecc","getOutputScript","paymentType","getPaymentType","paymentOutputScript","payments","networks","result","addressUtils","unstakeLBTC","btcAddress","outputScript"],"mappings":"gqBAAaA,EAAO,CAClB,KAAM,OACN,QAAS,UACT,MAAO,OACT,EAIaC,EAAW,CACtB,SAAU,EACV,QAAS,IACX,ECTaC,EAAmBF,EAAK,KAMxBG,EAAe,6CCDtBC,EAA0B,CAC9B,WAAY,sCACd,EAEMC,EAA4B,CAChC,WAAY,8CACd,EAEMC,EAAyB,CAC7B,WAAY,sCACd,EAEaC,EAAe,CAACC,EAAYN,IAA2B,CAClE,OAAQM,EAAK,CACX,KAAKR,EAAK,KACD,OAAAM,EACT,KAAKN,EAAK,QACD,OAAAK,EACT,QACS,OAAAD,CACX,CACF,ECpBO,SAASK,EAAgBC,EAAwB,CAClD,OAAA,OAAOA,GAAU,SACZA,EAGLA,aAAiB,MACZC,EAAqBD,CAAmB,EAG1CE,GA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,EAUP,SAASC,GACdvG,EACAZ,EAAYR,EAAK,KACT,OACF,MAAA4H,EAAcC,GAAezG,CAAO,EAOpC0G,GAAsB9D,EALZ+D,WAASH,CAAW,EAAE,CACpC,QAAAxG,EACA,QAASZ,IAAQR,EAAK,KAAOgI,EAAAA,SAAS,QAAUA,EAAAA,SAAS,OAAA,CAC1D,EAEmC,SAAR,YAAAhE,EAAgB,SAAS,OAErD,GAAI,CAAC8D,EACG,MAAA,IAAI,MAAM,6BAA6B,EAG/C,MAAO,KAAKA,CAAmB,EACjC,CAEA,SAASD,GAAezG,EAAoC,CACpD,MAAA6G,EAASC,EAAAA,QAAa,WAAW9G,CAAO,EAG9C,GADe6G,EAAO,UAAY,GAAKA,EAAO,KAAK,SAAW,GAErD,MAAA,OAIT,GADiBA,EAAO,UAAY,GAAKA,EAAO,KAAK,SAAW,GAEvD,MAAA,SAGH,MAAA,IAAI,MAAM,gCAAgC,CAClD,CC3BO,SAASE,GAAY,CAC1B,WAAAC,EACA,OAAAzF,EACA,IAAAnC,EACA,GAAGuG,CACL,EAAiD,CACzC,MAAAhD,EAAW,IAAIO,EAASyC,CAAc,EACtCC,EAAgBP,EAAqB1C,EAAUvD,CAAG,EAClD6H,EAAeV,GAAgBS,EAAY5H,CAAG,EAE9CyG,EAAYrE,EAAUD,CAAM,EAE5B2C,EAAK0B,EAAc,QAAQ,OAAOqB,EAAcpB,CAAS,EAE/D,OAAOlD,EAAS,qBACdA,EAAS,QACTiD,EAAc,QAAQ,QACtB,CACE,KAAM1B,EAAG,UAAU,EACnB,SAAU,GACV,YAAa,GACb,mBAAoBW,EAAiBlC,EAAS,OAAO,CACvD,CAAA,CAEJ"}
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@lombard.finance/sdk",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./dist/index.js",
7
+ "require": "./dist/index.cjs",
7
8
  "types": "./src/index.ts"
8
9
  }
9
10
  },