@lombard.finance/sdk 2.0.7 → 2.0.8

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 CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var Se=Object.defineProperty;var Ie=(e,t,n)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var R=(e,t,n)=>(Ie(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("axios"),S=require("bignumber.js"),f=require("web3"),_e=require("@bitcoin-js/tiny-secp256k1-asmjs"),x=require("bitcoinjs-lib");function De(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 xe=De(_e),y={prod:"prod",testnet:"testnet",stage:"stage"},s={ethereum:1,holesky:17e3,binanceSmartChain:56,binanceSmartChainTestnet:97,sepolia:11155111,base:8453,baseTestnet:84532,berachainBartioTestnet:80084,corn:21e6,swell:1923},ye=e=>e===y.prod?s.ethereum:s.holesky,ce=e=>e===y.prod?s.binanceSmartChain:s.binanceSmartChainTestnet,le=e=>e===y.prod?s.base:s.baseTestnet,z=y.prod,d="0x0000000000000000000000000000000000000000",Ne={baseApiUrl:"https://staging.prod.lombard.finance"},Me={baseApiUrl:"https://gastald-testnet.prod.lombard.finance"},Pe={baseApiUrl:"https://mainnet.prod.lombard.finance"},v=(e=z)=>{switch(e){case y.prod:return Pe;case y.testnet:return Me;default:return Ne}};function _(e){return typeof e=="string"?e:(n=>{var a;return((a=n==null?void 0:n.data)==null?void 0:a.message)&&typeof n.data.message=="string"})(e)?e.data.message:e instanceof Error?Oe(e):Ue(e)}function Oe(e){return e.response?e.response.data.message:e.message}function Ue(e){return e!=null&&e.message?e.message:"Unknown error"}const C={eth:"DESTINATION_BLOCKCHAIN_ETHEREUM",base:"DESTINATION_BLOCKCHAIN_BASE",bsc:"DESTINATION_BLOCKCHAIN_BSC",mantle:"DESTINATION_BLOCKCHAIN_MANTLE",linea:"DESTINATION_BLOCKCHAIN_LINEA",zcircuit:"DESTINATION_BLOCKCHAIN_ZIRCUIT",scroll:"DESTINATION_BLOCKCHAIN_SCROLL",xlayer:"DESTINATION_BLOCKCHAIN_XLAYER"};function K(e){switch(e){case s.ethereum:case s.holesky:case s.sepolia:return C.eth;case s.base:case s.baseTestnet:return C.base;case s.binanceSmartChain:case s.binanceSmartChainTestnet:return C.bsc;default:throw new Error(`Unknown chain ID: ${e}`)}}const me="sanctioned_address",Be="api/v1/address/generate",Fe="destination address is under sanctions";async function Le({address:e,chainId:t,signature:n,eip712Data:a,env:i,referrerCode:r,partnerId:o,captchaToken:p}){const{baseApiUrl:u}=v(i),w=K(t),T={to_address:e,to_address_signature:n,to_chain:w,partner_id:o,nonce:0,captcha:p,referrer_code:r,eip_712_data:a};try{const{data:h}=await I.post(Be,T,{baseURL:u});return h.address}catch(h){const A=_(h);if(ke(A))return me;throw new Error(A)}}function ke(e){return!!e.includes(Fe)}const Ge="api/v1/address";async function We({address:e,chainId:t,env:n,partnerId:a}){const i=await be({address:e,chainId:t,env:n,partnerId:a}),r=Ve(i);if(!r)throw new Error("No address");return r.btc_address}function Ve(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 be({address:e,chainId:t,env:n,partnerId:a}){const{baseApiUrl:i}=v(n),r=K(t),o={to_address:e,to_blockchain:r,limit:1,offset:0,asc:!1,referralId:a},{data:p}=await I.get(Ge,{baseURL:i,params:o});return(p==null?void 0:p.addresses)||[]}const He=8,X=10**He;function P(e){return+e/X}function ee(e){return Math.floor(+e*X)}function fe(e,t=z){switch(e){case C.eth:return ye(t);case C.base:return le(t);case C.bsc:return ce(t);default:return s.ethereum}}var Te=(e=>(e.NOTARIZATION_STATUS_UNSPECIFIED="NOTARIZATION_STATUS_UNSPECIFIED",e.NOTARIZATION_STATUS_PENDING="NOTARIZATION_STATUS_PENDING",e.NOTARIZATION_STATUS_SUBMITTED="NOTARIZATION_STATUS_SUBMITTED",e.NOTARIZATION_STATUS_SESSION_APPROVED="NOTARIZATION_STATUS_SESSION_APPROVED",e.NOTARIZATION_STATUS_FAILED="NOTARIZATION_STATUS_FAILED",e))(Te||{}),he=(e=>(e.SESSION_STATE_UNSPECIFIED="SESSION_STATE_UNSPECIFIED",e.SESSION_STATE_PENDING="SESSION_STATE_PENDING",e.SESSION_STATE_COMPLETED="SESSION_STATE_COMPLETED",e.SESSION_STATE_EXPIRED="SESSION_STATE_EXPIRED",e))(he||{});async function je({address:e,env:t}){const{baseApiUrl:n}=v(t),{data:a}=await I.get(`api/v1/address/outputs-v2/${e}`,{baseURL:n});return((a==null?void 0:a.outputs)??[]).map($e(t))}function $e(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:new S(P(t.value)),address:t.address,chainId:fe(t.to_chain,e),claimedTxId:t.claim_tx,rawPayload:t.raw_payload,signature:t.proof,isRestricted:!!t.sanctioned,notarizationWaitDur:t.notarization_wait_dur?Number(t.notarization_wait_dur):void 0,payload:t.payload_hash,sessionId:t.session_id,notarizationStatus:t.notarization_status,sessionState:t.session_state})}const qe=2e-4;async function Je({env:e,chainId:t=s.ethereum,amount:n=1}){const{baseApiUrl:a}=v(e),i=K(t),{data:r}=await I.get(`api/v1/exchange/rate/${i}`,{baseURL:a,params:{amount:n}}),o=new S(qe).multipliedBy(X).toFixed();return{exchangeRate:+r.amount_out,minAmount:+o}}async function Ze({address:e,chainId:t,env:n}){const{baseApiUrl:a}=v(n);try{const{data:i}=await I.get(`${a}/api/v1/claimer/get-user-signature`,{params:{user_destination_address:e,chain_id:t}});return{expirationDate:i==null?void 0:i.expiration_date,hasSignature:i==null?void 0:i.has_signature,isDelayed:i==null?void 0:i.is_delayed}}catch(i){const r=_(i);throw new Error(r)}}async function ze({signature:e,typedData:t,address:n,env:a}){const{baseApiUrl:i}=v(a);try{const{data:r}=await I.post(`${i}/api/v1/claimer/save-user-signature`,null,{params:{typed_data:t,signature:e,user_destination_address:n}});return r.status}catch(r){const o=_(r);throw new Error(o)}}const O={[s.ethereum]:"https://rpc.ankr.com/eth",[s.holesky]:"https://rpc.ankr.com/eth_holesky",[s.sepolia]:"https://rpc.ankr.com/eth_sepolia",[s.base]:"https://rpc.ankr.com/base",[s.baseTestnet]:"https://rpc.ankr.com/base_sepolia",[s.binanceSmartChain]:"https://rpc.ankr.com/bsc",[s.binanceSmartChainTestnet]:"https://rpc.ankr.com/bsc_testnet_chapel"};async function Ke(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=f.utils.hexToNumber(n==null?void 0:n.result);return new S(Number(a))}const Xe=2,Ye=25e3;class Y{constructor({chainId:t,rpcUrlConfig:n}){R(this,"chainId");R(this,"rpcConfig");this.chainId=t,this.rpcConfig={...O,...n}}getReadWeb3(){const t=this.getRpcUrl(),n=new f.Web3,a=new f.Web3.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,i]=await Promise.all([t.eth.getBlock("latest"),Ke(n)]);return!(a!=null&&a.baseFeePerGas)&&typeof(a==null?void 0:a.baseFeePerGas)!="bigint"?{}:{maxFeePerGas:+new S(a.baseFeePerGas.toString(10)).multipliedBy(Xe).plus(i),maxPriorityFeePerGas:+i}}async getSafeGasPriceWei(){const t=await this.getReadWeb3().eth.getGasPrice();return new S(t.toString(10)).plus(Ye)}createContract(t,n){const a=this.getReadWeb3();return new a.eth.Contract(t,n)}}class D extends Y{constructor({provider:n,account:a,chainId:i,rpcUrlConfig:r}){super({chainId:i,rpcUrlConfig:r});R(this,"web3");R(this,"account");R(this,"rpcConfig",O);this.web3=new f(n),this.account=a,this.chainId=i,this.rpcConfig={...O,...r}}async signMessage(n){const{account:a}=this,i=`0x${Buffer.from(n,"utf8").toString("hex")}`;return this.web3.currentProvider.request({method:"personal_sign",params:[i,a]})}async sendTransactionAsync(n,a,i){const{chainId:r,web3:o}=this,p=this.getReadWeb3(),{data:u,estimate:w=!1,estimateFee:T=!1,extendedGasLimit:h,gasLimit:A="0",value:Re="0",gasLimitMultiplier:Ce=1}=i;let{nonce:N}=i;N||(N=await p.eth.getTransactionCount(n)),console.log(`Nonce: ${N}`);const c={from:n,to:a,value:f.utils.numberToHex(Re),data:u,nonce:N,chainId:f.utils.numberToHex(r)};if(w)try{const g=await p.eth.estimateGas(c),M=Math.round(Number(g)*Ce);h?c.gas=f.utils.numberToHex(M+h):c.gas=f.utils.numberToHex(M)}catch(g){throw new Error(g.message??"Failed to estimate gas limit for transaction.")}else c.gas=f.utils.numberToHex(A);const{maxFeePerGas:se,maxPriorityFeePerGas:ie}=T?await this.getMaxFees().catch(()=>i):i;if(ie!==void 0&&(c.maxPriorityFeePerGas=f.utils.numberToHex(ie)),se!==void 0&&(c.maxFeePerGas=f.utils.numberToHex(se)),!c.maxFeePerGas&&!c.maxPriorityFeePerGas){const g=await this.getSafeGasPriceWei();c.gasPrice=g.toString(10)}if(!c.maxFeePerGas&&!c.maxPriorityFeePerGas){const g=await this.getSafeGasPriceWei();c.gasPrice=g.toString(10)}return console.log("Sending transaction via Web3: ",c),new Promise((g,M)=>{const re=o.eth.sendTransaction(c);re.once("transactionHash",async oe=>{console.log(`Just signed transaction has is: ${oe}`),g({receiptPromise:re,transactionHash:oe})}).catch(M)})}createContract(n,a){return new this.web3.eth.Contract(n,a)}}function te(e){switch(e){case s.ethereum:return 1.3;case s.holesky:case s.sepolia:return 1.5;default:return 1.3}}function ne(e){return Object.values(s).includes(e)}const Qe={[s.holesky]:"0xED7bfd5C1790576105Af4649817f6d35A75CD818",[s.ethereum]:d,[s.binanceSmartChainTestnet]:"0x731eFa688F3679688cf60A3993b8658138953ED6",[s.binanceSmartChain]:d,[s.sepolia]:"0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",[s.base]:d,[s.baseTestnet]:d,[s.berachainBartioTestnet]:"0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",[s.corn]:d,[s.swell]:d},et={[s.holesky]:"0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2",[s.ethereum]:d,[s.binanceSmartChainTestnet]:"0x107Fc7d90484534704dD2A9e24c7BD45DB4dD1B5",[s.binanceSmartChain]:d,[s.sepolia]:"0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",[s.base]:d,[s.baseTestnet]:d,[s.berachainBartioTestnet]:"0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",[s.corn]:d,[s.swell]:d},tt={[s.ethereum]:"0x8236a87084f8b84306f72007f36f2618a5634494",[s.holesky]:d,[s.sepolia]:d,[s.binanceSmartChainTestnet]:d,[s.binanceSmartChain]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",[s.base]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",[s.baseTestnet]:d,[s.berachainBartioTestnet]:d,[s.corn]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",[s.swell]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1"};function ge(e=z){switch(e){case y.prod:return tt;case y.testnet:return et;default:return Qe}}const nt=[{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"}],at=[{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:"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:[{internalType:"uint256",name:"deadline",type:"uint256"}],name:"ERC2612ExpiredSignature",type:"error"},{inputs:[{internalType:"address",name:"signer",type:"address"},{internalType:"address",name:"owner",type:"address"}],name:"ERC2612InvalidSigner",type:"error"},{inputs:[],name:"EnforcedPause",type:"error"},{inputs:[],name:"ExpectedPause",type:"error"},{inputs:[],name:"FeeGreaterThanAmount",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"uint256",name:"currentNonce",type:"uint256"}],name:"InvalidAccountNonce",type:"error"},{inputs:[],name:"InvalidDustFeeRate",type:"error"},{inputs:[],name:"InvalidInitialization",type:"error"},{inputs:[],name:"InvalidInputLength",type:"error"},{inputs:[],name:"InvalidUserSignature",type:"error"},{inputs:[],name:"KnownDestination",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:"PayloadAlreadyUsed",type:"error"},{inputs:[],name:"ReentrancyGuardReentrantCall",type:"error"},{inputs:[],name:"ScriptPubkeyUnsupported",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"UnauthorizedAccount",type:"error"},{inputs:[{internalType:"bytes4",name:"action",type:"bytes4"}],name:"UnexpectedAction",type:"error"},{inputs:[],name:"UnknownDestination",type:"error"},{inputs:[{internalType:"uint256",name:"fromChainId",type:"uint256"},{internalType:"address",name:"fromContract",type:"address"}],name:"UnknownOriginContract",type:"error"},{inputs:[{internalType:"uint256",name:"expiry",type:"uint256"}],name:"UserSignatureExpired",type:"error"},{inputs:[],name:"WithdrawalsDisabled",type:"error"},{inputs:[],name:"WrongChainId",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{inputs:[],name:"ZeroAmount",type:"error"},{inputs:[],name:"ZeroChainId",type:"error"},{inputs:[],name:"ZeroContractHash",type:"error"},{inputs:[],name:"ZeroFee",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:"address",name:"prevVal",type:"address"},{indexed:!0,internalType:"address",name:"newVal",type:"address"}],name:"BridgeChanged",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:"claimer",type:"address"},{indexed:!1,internalType:"bool",name:"isClaimer",type:"bool"}],name:"ClaimerUpdated",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:!0,internalType:"uint256",name:"oldRate",type:"uint256"},{indexed:!0,internalType:"uint256",name:"newRate",type:"uint256"}],name:"DustFeeRateChanged",type:"event"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"oldFee",type:"uint256"},{indexed:!0,internalType:"uint256",name:"newFee",type:"uint256"}],name:"FeeChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"fee",type:"uint256"},{indexed:!1,internalType:"bytes",name:"userSignature",type:"bytes"}],name:"FeeCharged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"version",type:"uint64"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"recipient",type:"address"},{indexed:!0,internalType:"bytes32",name:"payloadHash",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"payload",type:"bytes"}],name:"MintProofConsumed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"minter",type:"address"},{indexed:!1,internalType:"bool",name:"isMinter",type:"bool"}],name:"MinterUpdated",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:"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:!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:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"acceptOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newClaimer",type:"address"}],name:"addClaimer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newMinter",type:"address"}],name:"addMinter",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:"address[]",name:"to",type:"address[]"},{internalType:"uint256[]",name:"amount",type:"uint256[]"}],name:"batchMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes[]",name:"payload",type:"bytes[]"},{internalType:"bytes[]",name:"proof",type:"bytes[]"}],name:"batchMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes[]",name:"mintPayload",type:"bytes[]"},{internalType:"bytes[]",name:"proof",type:"bytes[]"},{internalType:"bytes[]",name:"feePayload",type:"bytes[]"},{internalType:"bytes[]",name:"userSignature",type:"bytes[]"}],name:"batchMintWithFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{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:"address",name:"newBridge",type:"address"}],name:"changeBridge",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:"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:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBurnCommission",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDustFeeRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getMintFee",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"},{internalType:"address",name:"owner_",type:"address"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"claimer",type:"address"}],name:"isClaimer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"minter",type:"address"}],name:"isMinter",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"payload",type:"bytes"},{internalType:"bytes",name:"proof",type:"bytes"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"mintPayload",type:"bytes"},{internalType:"bytes",name:"proof",type:"bytes"},{internalType:"bytes",name:"feePayload",type:"bytes"},{internalType:"bytes",name:"userSignature",type:"bytes"}],name:"mintWithFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],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:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"scriptPubkey",type:"bytes"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"redeem",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"reinitialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oldClaimer",type:"address"}],name:"removeClaimer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oldMinter",type:"address"}],name:"removeMinter",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"fee",type:"uint256"}],name:"setMintFee",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:[{components:[{internalType:"uint256",name:"fromChain",type:"uint256"},{internalType:"address",name:"fromContract",type:"address"},{internalType:"uint256",name:"toChain",type:"uint256"},{internalType:"address",name:"toContract",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint64",name:"amount",type:"uint64"},{internalType:"bytes32",name:"uniqueActionData",type:"bytes32"}],internalType:"struct Actions.DepositBridgeAction",name:"action",type:"tuple"},{internalType:"bytes32",name:"",type:"bytes32"},{internalType:"bytes",name:"",type:"bytes"}],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"}],st=[{inputs:[{internalType:"address",name:"aDefaultAdmin",type:"address"},{internalType:"address",name:"aPauser",type:"address"},{internalType:"address",name:"aDepositReporter",type:"address"},{internalType:"address",name:"aWithdrawalValidator",type:"address"},{internalType:"uint256",name:"aMaxDeposits",type:"uint256"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"AccessControlBadConfirmation",type:"error"},{inputs:[{internalType:"uint48",name:"schedule",type:"uint48"}],name:"AccessControlEnforcedDefaultAdminDelay",type:"error"},{inputs:[],name:"AccessControlEnforcedDefaultAdminRules",type:"error"},{inputs:[{internalType:"address",name:"defaultAdmin",type:"address"}],name:"AccessControlInvalidDefaultAdmin",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"bytes32",name:"neededRole",type:"bytes32"}],name:"AccessControlUnauthorizedAccount",type:"error"},{inputs:[{internalType:"bytes32",name:"depositID",type:"bytes32"}],name:"AlreadyReported",type:"error"},{inputs:[{internalType:"bytes32",name:"depositID",type:"bytes32"},{internalType:"uint256",name:"withdrawalAmount",type:"uint256"}],name:"AlreadyWithdrawn",type:"error"},{inputs:[],name:"BadDepositReport",type:"error"},{inputs:[],name:"EnforcedPause",type:"error"},{inputs:[],name:"ExpectedPause",type:"error"},{inputs:[{internalType:"uint8",name:"bits",type:"uint8"},{internalType:"uint256",name:"value",type:"uint256"}],name:"SafeCastOverflowedUintDowncast",type:"error"},{inputs:[],name:"SameValidationThreshold",type:"error"},{inputs:[{internalType:"bytes32",name:"depositID",type:"bytes32"},{internalType:"uint256",name:"withdrawalAmount",type:"uint256"}],name:"WithdrawalFailedValidation",type:"error"},{anonymous:!1,inputs:[],name:"DefaultAdminDelayChangeCanceled",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint48",name:"newDelay",type:"uint48"},{indexed:!1,internalType:"uint48",name:"effectSchedule",type:"uint48"}],name:"DefaultAdminDelayChangeScheduled",type:"event"},{anonymous:!1,inputs:[],name:"DefaultAdminTransferCanceled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newAdmin",type:"address"},{indexed:!1,internalType:"uint48",name:"acceptSchedule",type:"uint48"}],name:"DefaultAdminTransferScheduled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"reportId",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"numDeposits",type:"uint256"}],name:"DepositsReported",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"numDeposits",type:"uint256"}],name:"MaxDepositsUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Paused",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"previousAdminRole",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"newAdminRole",type:"bytes32"}],name:"RoleAdminChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!0,internalType:"address",name:"sender",type:"address"}],name:"RoleGranted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!0,internalType:"address",name:"sender",type:"address"}],name:"RoleRevoked",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Unpaused",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"oldThreshold",type:"uint256"},{indexed:!1,internalType:"uint256",name:"newThreshold",type:"uint256"}],name:"UpdateValidateThreshold",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bytes32",name:"depositID",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"withdrawalAmount",type:"uint256"}],name:"WithdrawalNotValidated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bytes32",name:"depositID",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"withdrawalAmount",type:"uint256"}],name:"WithdrawalValidated",type:"event"},{inputs:[],name:"DEFAULT_ADMIN_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"DEPOSIT_REPORTER_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"PAUSER_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"VALIDATION_GUARDIAN_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"WITHDRAWAL_VALIDATOR_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"acceptDefaultAdminTransfer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newAdmin",type:"address"}],name:"beginDefaultAdminTransfer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"cancelDefaultAdminTransfer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint48",name:"newDelay",type:"uint48"}],name:"changeDefaultAdminDelay",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"defaultAdmin",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"defaultAdminDelay",outputs:[{internalType:"uint48",name:"",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[],name:"defaultAdminDelayIncreaseWait",outputs:[{internalType:"uint48",name:"",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"depositID",type:"bytes32"}],name:"depositHistory",outputs:[{internalType:"enum Bascule.DepositState",name:"status",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"}],name:"getRoleAdmin",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"grantRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"hasRole",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"maxDeposits",outputs:[{internalType:"uint256",name:"",type:"uint256"}],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:"pendingDefaultAdmin",outputs:[{internalType:"address",name:"newAdmin",type:"address"},{internalType:"uint48",name:"schedule",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[],name:"pendingDefaultAdminDelay",outputs:[{internalType:"uint48",name:"newDelay",type:"uint48"},{internalType:"uint48",name:"schedule",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"renounceRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"reportId",type:"bytes32"},{internalType:"bytes32[]",name:"depositIDs",type:"bytes32[]"}],name:"reportDeposits",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"revokeRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"rollbackDefaultAdminDelay",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"aMaxDeposits",type:"uint256"}],name:"setMaxDeposits",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newThreshold",type:"uint256"}],name:"updateValidateThreshold",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"validateThreshold",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"depositID",type:"bytes32"},{internalType:"uint256",name:"withdrawalAmount",type:"uint256"}],name:"validateWithdrawal",outputs:[],stateMutability:"nonpayable",type:"function"}];function it(e){switch(e){case"LBTC":return at;default:return nt}}function E(e,t){const n=ge(t),{chainId:a}=e;if(!ne(a))throw new Error(`This chain ${a} is not supported`);const i=n[a];if(!i)throw new Error(`Token address for chain ${a} is not defined`);const r=it("LBTC"),o=e.createContract(r,i);return o.options.address||(o.options.address=i),o}function rt({spender:e,amount:t,env:n,...a}){const i=new D(a),r=E(i,n),o=ee(t),p=r.methods.approve(e,o);return i.sendTransactionAsync(i.account,r.options.address,{data:p.encodeABI(),estimate:!0,estimateFee:!0,gasLimitMultiplier:te(i.chainId)})}const ot="insufficient funds",pt="Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.",pe=e=>e.startsWith("0x")?e:"0x"+e;async function ut({data:e,proofSignature:t,env:n,...a}){const i=new D(a),r=E(i,n),o=r.methods.mint(pe(e),pe(t));try{return await i.sendTransactionAsync(i.account,r.options.address,{data:o.encodeABI(),estimate:!0,estimateFee:!0,gasLimitMultiplier:te(i.chainId)})}catch(p){console.log("error",p);const u=_(p);throw u.includes(ot)?new Error(pt):new Error(u)}}const dt=208,yt=4001,ct=4100,lt=4200,mt=4900,bt=4901,U=-32700,B=-32600,F=-32601,L=-32602,k=-32603,G=-32e3,W=-32001,V=-32002,H=-32003,j=-32004,$=-32005,q=-32006;class we extends Error{constructor(t,n){super(t),Array.isArray(n)?this.cause=new Q(n):this.cause=n,this.name=this.constructor.name,typeof Error.captureStackTrace=="function"?Error.captureStackTrace(new.target.constructor):this.stack=new Error().stack}get innerError(){return this.cause instanceof Q?this.cause.errors:this.cause}set innerError(t){Array.isArray(t)?this.cause=new Q(t):this.cause=t}static convertToString(t,n=!1){if(t==null)return"undefined";const a=JSON.stringify(t,(i,r)=>typeof r=="bigint"?r.toString():r);return n&&["bigint","string"].includes(typeof t)?a.replace(/['\\"]+/g,""):a}toJSON(){return{name:this.name,code:this.code,message:this.message,cause:this.cause,innerError:this.cause}}}class Q extends we{constructor(t){super(`Multiple errors occurred: [${t.map(n=>n.message).join("], [")}]`),this.code=dt,this.errors=t}}const ft="An Rpc error has occured with a code of *code*",l={[U]:{message:"Parse error",description:"Invalid JSON"},[B]:{message:"Invalid request",description:"JSON is not a valid request object "},[F]:{message:"Method not found",description:"Method does not exist "},[L]:{message:"Invalid params",description:"Invalid method parameters"},[k]:{message:"Internal error",description:"Internal JSON-RPC error"},[G]:{message:"Invalid input",description:"Missing or invalid parameters"},[W]:{message:"Resource not found",description:"Requested resource not found"},[V]:{message:"Resource unavailable",description:"Requested resource not available"},[H]:{message:"Transaction rejected",description:"Transaction creation failed"},[j]:{message:"Method not supported",description:"Method is not implemented"},[$]:{message:"Limit exceeded",description:"Request exceeds defined limit"},[q]:{message:"JSON-RPC version not supported",description:"Version of JSON-RPC protocol is not supported"},[yt]:{name:"User Rejected Request",message:"The user rejected the request."},[ct]:{name:"Unauthorized",message:"The requested method and/or account has not been authorized by the user."},[lt]:{name:"Unsupported Method",message:"The Provider does not support the requested method."},[mt]:{name:"Disconnected",message:"The Provider is disconnected from all chains."},[bt]:{name:"Chain Disconnected",message:"The Provider is not connected to the requested chain."},"0-999":{name:"",message:"Not used."},1e3:{name:"Normal Closure",message:"The connection successfully completed the purpose for which it was created."},1001:{name:"Going Away",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."},1002:{name:"Protocol error",message:"The endpoint is terminating the connection due to a protocol error."},1003:{name:"Unsupported Data",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.)"},1004:{name:"Reserved",message:"Reserved. A meaning might be defined in the future."},1005:{name:"No Status Rcvd",message:"Reserved. Indicates that no status code was provided even though one was expected."},1006:{name:"Abnormal Closure",message:"Reserved. Indicates that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."},1007:{name:"Invalid frame payload data",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)."},1008:{name:"Policy Violation",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."},1009:{name:"Message Too Big",message:"The endpoint is terminating the connection because a data frame was received that is too large."},1010:{name:"Mandatory Ext.",message:"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."},1011:{name:"Internal Error",message:"The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."},1012:{name:"Service Restart",message:"The server is terminating the connection because it is restarting."},1013:{name:"Try Again Later",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."},1014:{name:"Bad Gateway",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."},1015:{name:"TLS handshake",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)."},"1016-2999":{name:"",message:"For definition by future revisions of the WebSocket Protocol specification, and for definition by extension specifications."},"3000-3999":{name:"",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."},"4000-4999":{name:"",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."}};class m extends we{constructor(t,n){super(n??ft.replace("*code*",t.error.code.toString())),this.code=t.error.code,this.id=t.id,this.jsonrpc=t.jsonrpc,this.jsonRpcError=t.error}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{error:this.jsonRpcError,id:this.id,jsonRpc:this.jsonrpc})}}class Tt extends m{constructor(t){super(t,l[U].message),this.code=U}}class ht extends m{constructor(t){super(t,l[B].message),this.code=B}}class gt extends m{constructor(t){super(t,l[F].message),this.code=F}}class wt extends m{constructor(t){super(t,l[L].message),this.code=L}}class Et extends m{constructor(t){super(t,l[k].message),this.code=k}}class At extends m{constructor(t){super(t,l[G].message),this.code=G}}class vt extends m{constructor(t){super(t,l[j].message),this.code=j}}class Rt extends m{constructor(t){super(t,l[V].message),this.code=V}}class Ct extends m{constructor(t){super(t,l[W].message),this.code=W}}class St extends m{constructor(t){super(t,l[q].message),this.code=q}}class It extends m{constructor(t){super(t,l[H].message),this.code=H}}class _t extends m{constructor(t){super(t,l[$].message),this.code=$}}const b=new Map;b.set(U,{error:Tt});b.set(B,{error:ht});b.set(F,{error:gt});b.set(L,{error:wt});b.set(k,{error:Et});b.set(G,{error:At});b.set(j,{error:vt});b.set(V,{error:Rt});b.set(H,{error:It});b.set(W,{error:Ct});b.set(q,{error:St});b.set($,{error:_t});const Dt=e=>typeof e=="string"&&/^((-)?0x[0-9a-f]+|(0x))$/i.test(e);var J;(function(e){e.NUMBER="NUMBER_NUMBER",e.HEX="NUMBER_HEX",e.STR="NUMBER_STR",e.BIGINT="NUMBER_BIGINT"})(J||(J={}));var Z;(function(e){e.HEX="BYTES_HEX",e.UINT8ARRAY="BYTES_UINT8ARRAY"})(Z||(Z={}));J.BIGINT,Z.HEX;J.HEX,Z.HEX;var ue;(function(e){e.EARLIEST="earliest",e.LATEST="latest",e.PENDING="pending",e.SAFE="safe",e.FINALIZED="finalized"})(ue||(ue={}));var de;(function(e){e.chainstart="chainstart",e.frontier="frontier",e.homestead="homestead",e.dao="dao",e.tangerineWhistle="tangerineWhistle",e.spuriousDragon="spuriousDragon",e.byzantium="byzantium",e.constantinople="constantinople",e.petersburg="petersburg",e.istanbul="istanbul",e.muirGlacier="muirGlacier",e.berlin="berlin",e.london="london",e.altair="altair",e.arrowGlacier="arrowGlacier",e.grayGlacier="grayGlacier",e.bellatrix="bellatrix",e.merge="merge",e.capella="capella",e.shanghai="shanghai"})(de||(de={}));function xt(e,t){if(!t)throw new Error("The address for bascule module is not defined");const n=e.createContract(st,t);return n.options.address||(n.options.address=t),n}const Nt="No deposit ID provided. Please provide a deposit ID as an argument.",Mt="Invalid deposit ID. Expected a 0x-prefixed 32-byte hex string.";var Ee=(e=>(e[e.UNREPORTED=0]="UNREPORTED",e[e.REPORTED=1]="REPORTED",e[e.WITHDRAWN=2]="WITHDRAWN",e))(Ee||{});async function Pt({txId:e,env:t,...n}){if(!e)throw new Error(Nt);if(!Dt(e))throw new Error(Mt);const a=new D(n),r=await E(a,t).methods.Bascule().call();if(r===d)return 1;const o=xt(a,r);try{const p=await o.methods.depositHistory(Buffer.from(e.replace(/^0x/,""),"hex")).call();return Number(p)}catch(p){const u=_(p);throw new Error(u)}}const Ot=[s.ethereum,s.base,s.binanceSmartChain],Ae=e=>Ot.includes(e)?y.prod:y.stage;function ve(e,t){if(!ne(e))throw new Error(`This chain ${e} is not supported`);const n=t?{[e]:t}:O;if(!n[e])throw new Error(`RPC URL for chainId ${e} not found`);return n}async function Ut({chainId:e,bakeGasEstimate:t=0,rpcUrl:n}){const a=ve(e,n),i=new Y({chainId:e,rpcUrlConfig:a}),r=Ae(e),p=await E(i,r).methods.getMintFee().call(),u=new S(P(p.toString(10)));return t?u.plus(P(t)):u}async function Bt({env:e,rpcUrl:t,chainId:n}){const a={[n]:t},i=new Y({chainId:n,rpcUrlConfig:a});return(await E(i,e).methods.totalSupply().call()).toString()}async function Ft({owner:e,rpcUrl:t,chainId:n}){const a=ve(n,t),i=new Y({chainId:n,rpcUrlConfig:a}),r=Ae(n),o=E(i,r);try{return(await o.methods.nonces(e).call()).toString()}catch(p){const u=_(p);throw new Error(u)}}const ae={[s.sepolia]:{[s.berachainBartioTestnet]:"0xe3748bF0Ec0A76767539eE28610B3367e35fe2C2"},[s.berachainBartioTestnet]:{[s.sepolia]:"0x1977013acaf27856ac8048C42EE2ed0134d53895"}},Lt={...ae},kt={...ae,[s.corn]:{[s.ethereum]:"0xfc7B20D9B59A8A466f4fC3d34aA69a7D98e71d7A"},[s.ethereum]:{[s.corn]:"0x6bc15d7930839ec18a57f6f7df72ae1b439d077f",[s.swell]:"0x37E92d760a15231e652a2C502182a6b44c7510c0"},[s.swell]:{[s.ethereum]:"0x7B3784AD646C10A8Ddf42b47a4f4bd9aFD351E54"}};function Gt(e=z){switch(e){case y.prod:return kt;case y.testnet:return Lt;default:return ae}}async function Wt(e){const t=new D(e),n=`destination chain id is ${e.chainId}`;return t.signMessage(n)}const Vt=24*60*60;function Ht({chainId:e,verifyingContract:t,fee:n,expiry:a}){return{domain:{name:"Lombard Staked Bitcoin",version:"1",chainId:e,verifyingContract:t},message:{chainId:e,fee:n,expiry:a},primaryType:"feeApproval",types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],feeApproval:[{name:"chainId",type:"uint256"},{name:"fee",type:"uint256"},{name:"expiry",type:"uint256"}]}}}const jt="Failed to obtain a valid signature. The response is undefined or invalid.",$t=()=>Math.floor(Date.now()/1e3+Vt);async function qt({address:e,provider:t,fee:n,chainId:a,env:i,expiry:r=$t()}){var h,A;const o=new D({provider:t,account:e,chainId:a}),u=E(o,i).options.address,w=JSON.stringify(Ht({chainId:a,verifyingContract:u,fee:n,expiry:r})),T=await((A=(h=o.web3)==null?void 0:h.currentProvider)==null?void 0:A.request({method:"eth_signTypedData_v4",params:[e,w]}));if(typeof T=="string")return{signature:T,typedData:w};if(!(T!=null&&T.result))throw new Error(jt);return{signature:T.result,typedData:w}}x.initEccLib(xe);function Jt(e,t=y.prod){var r;const n=Zt(e),i=(r=x.payments[n]({address:e,network:t===y.prod?x.networks.bitcoin:x.networks.testnet}).output)==null?void 0:r.toString("hex");if(!i)throw new Error("Output script is not found.");return`0x${i}`}function Zt(e){const t=x.address.fromBech32(e);if(t.version===1&&t.data.length===32)return"p2tr";if(t.version===0&&t.data.length===20)return"p2wpkh";if(zt(e))return"p2wsh";throw new Error("Address type is not supported.")}function zt(e){return(e.startsWith("bc1")||e.startsWith("tb1"))&&e.length===62}function Kt({btcAddress:e,amount:t,env:n,...a}){const i=new D(a),r=E(i,n),o=Jt(e,n),p=ee(t),u=r.methods.redeem(o,p);return i.sendTransactionAsync(i.account,r.options.address,{data:u.encodeABI(),estimate:!0,estimateFee:!0,gasLimitMultiplier:te(i.chainId)})}exports.BasculeDepositStatus=Ee;exports.ENotarizationStatus=Te;exports.ESessionState=he;exports.OChainId=s;exports.OEnv=y;exports.SANCTIONED_ADDRESS=me;exports.SATOSHI_SCALE=X;exports.approveLBTC=rt;exports.claimLBTC=ut;exports.fromSatoshi=P;exports.generateDepositBtcAddress=Le;exports.getApiConfig=v;exports.getBasculeDepositStatus=Pt;exports.getBaseNetworkByEnv=le;exports.getBscNetworkByEnv=ce;exports.getChainIdByName=fe;exports.getChainNameById=K;exports.getDepositBtcAddress=We;exports.getDepositBtcAddresses=be;exports.getDepositsByAddress=je;exports.getEthNetworkByEnv=ye;exports.getLBTCExchangeRate=Je;exports.getLBTCMintingFee=Ut;exports.getLBTCTotalSupply=Bt;exports.getLbtcAddressConfig=ge;exports.getLbtcOFTAdapterAddressConfig=Gt;exports.getNetworkFeeSignature=Ze;exports.getPermitNonce=Ft;exports.isValidChain=ne;exports.signLbtcDestionationAddr=Wt;exports.signNetworkFee=qt;exports.storeNetworkFeeSignature=ze;exports.toSatoshi=ee;exports.unstakeLBTC=Kt;
1
+ "use strict";var ne=Object.defineProperty;var ae=(e,t,n)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var S=(e,t,n)=>(ae(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("axios"),v=require("bignumber.js"),b=require("web3"),T={prod:"prod",testnet:"testnet",stage:"stage"},s={ethereum:1,holesky:17e3,binanceSmartChain:56,binanceSmartChainTestnet:97,sepolia:11155111,base:8453,baseTestnet:84532,berachainBartioTestnet:80084,corn:21e6,swell:1923},H=e=>e===T.prod?s.ethereum:s.holesky,W=e=>e===T.prod?s.binanceSmartChain:s.binanceSmartChainTestnet,$=e=>e===T.prod?s.base:s.baseTestnet,P=T.prod,u="0x0000000000000000000000000000000000000000",se={baseApiUrl:"https://staging.prod.lombard.finance"},ie={baseApiUrl:"https://gastald-testnet.prod.lombard.finance"},re={baseApiUrl:"https://mainnet.prod.lombard.finance"},h=(e=P)=>{switch(e){case T.prod:return re;case T.testnet:return ie;default:return se}};function C(e){return typeof e=="string"?e:(n=>{var a;return((a=n==null?void 0:n.data)==null?void 0:a.message)&&typeof n.data.message=="string"})(e)?e.data.message:e instanceof Error?oe(e):pe(e)}function oe(e){return e.response?e.response.data.message:e.message}function pe(e){return e!=null&&e.message?e.message:"Unknown error"}const A={eth:"DESTINATION_BLOCKCHAIN_ETHEREUM",base:"DESTINATION_BLOCKCHAIN_BASE",bsc:"DESTINATION_BLOCKCHAIN_BSC",mantle:"DESTINATION_BLOCKCHAIN_MANTLE",linea:"DESTINATION_BLOCKCHAIN_LINEA",zcircuit:"DESTINATION_BLOCKCHAIN_ZIRCUIT",scroll:"DESTINATION_BLOCKCHAIN_SCROLL",xlayer:"DESTINATION_BLOCKCHAIN_XLAYER"};function x(e){switch(e){case s.ethereum:case s.holesky:case s.sepolia:return A.eth;case s.base:case s.baseTestnet:return A.base;case s.binanceSmartChain:case s.binanceSmartChainTestnet:return A.bsc;default:throw new Error(`Unknown chain ID: ${e}`)}}const V="sanctioned_address",ue="api/v1/address/generate",ye="destination address is under sanctions";async function de({address:e,chainId:t,signature:n,eip712Data:a,env:i,referrerCode:r,partnerId:o,captchaToken:p}){const{baseApiUrl:d}=h(i),m=x(t),l={to_address:e,to_address_signature:n,to_chain:m,partner_id:o,nonce:0,captcha:p,referrer_code:r,eip_712_data:a};try{const{data:y}=await w.post(ue,l,{baseURL:d});return y.address}catch(y){const f=C(y);if(le(f))return V;throw new Error(f)}}function le(e){return!!e.includes(ye)}const ce="api/v1/address";async function me({address:e,chainId:t,env:n,partnerId:a}){const i=await Z({address:e,chainId:t,env:n,partnerId:a}),r=be(i);if(!r)throw new Error("No address");return r.btc_address}function be(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 Z({address:e,chainId:t,env:n,partnerId:a}){const{baseApiUrl:i}=h(n),r=x(t),o={to_address:e,to_blockchain:r,limit:1,offset:0,asc:!1,referralId:a},{data:p}=await w.get(ce,{baseURL:i,params:o});return(p==null?void 0:p.addresses)||[]}const Te=8,M=10**Te;function N(e){return+e/M}function fe(e){return Math.floor(+e*M)}function K(e,t=P){switch(e){case A.eth:return H(t);case A.base:return $(t);case A.bsc:return W(t);default:return s.ethereum}}var q=(e=>(e.NOTARIZATION_STATUS_UNSPECIFIED="NOTARIZATION_STATUS_UNSPECIFIED",e.NOTARIZATION_STATUS_PENDING="NOTARIZATION_STATUS_PENDING",e.NOTARIZATION_STATUS_SUBMITTED="NOTARIZATION_STATUS_SUBMITTED",e.NOTARIZATION_STATUS_SESSION_APPROVED="NOTARIZATION_STATUS_SESSION_APPROVED",e.NOTARIZATION_STATUS_FAILED="NOTARIZATION_STATUS_FAILED",e))(q||{}),z=(e=>(e.SESSION_STATE_UNSPECIFIED="SESSION_STATE_UNSPECIFIED",e.SESSION_STATE_PENDING="SESSION_STATE_PENDING",e.SESSION_STATE_COMPLETED="SESSION_STATE_COMPLETED",e.SESSION_STATE_EXPIRED="SESSION_STATE_EXPIRED",e))(z||{});async function ge({address:e,env:t}){const{baseApiUrl:n}=h(t),{data:a}=await w.get(`api/v1/address/outputs-v2/${e}`,{baseURL:n});return((a==null?void 0:a.outputs)??[]).map(he(t))}function he(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:new v(N(t.value)),address:t.address,chainId:K(t.to_chain,e),claimedTxId:t.claim_tx,rawPayload:t.raw_payload,signature:t.proof,isRestricted:!!t.sanctioned,notarizationWaitDur:t.notarization_wait_dur?Number(t.notarization_wait_dur):void 0,payload:t.payload_hash,sessionId:t.session_id,notarizationStatus:t.notarization_status,sessionState:t.session_state})}const we=2e-4;async function Se({env:e,chainId:t=s.ethereum,amount:n=1}){const{baseApiUrl:a}=h(e),i=x(t),{data:r}=await w.get(`api/v1/exchange/rate/${i}`,{baseURL:a,params:{amount:n}}),o=new v(we).multipliedBy(M).toFixed();return{exchangeRate:+r.amount_out,minAmount:+o}}async function Ae({address:e,chainId:t,env:n}){const{baseApiUrl:a}=h(n);try{const{data:i}=await w.get(`${a}/api/v1/claimer/get-user-signature`,{params:{user_destination_address:e,chain_id:t}});return{expirationDate:i==null?void 0:i.expiration_date,hasSignature:i==null?void 0:i.has_signature,isDelayed:i==null?void 0:i.is_delayed}}catch(i){const r=C(i);throw new Error(r)}}async function ve({signature:e,typedData:t,address:n,env:a}){const{baseApiUrl:i}=h(a);try{const{data:r}=await w.post(`${i}/api/v1/claimer/save-user-signature`,null,{params:{typed_data:t,signature:e,user_destination_address:n}});return r.status}catch(r){const o=C(r);throw new Error(o)}}async function Ce({signature:e,typedData:t,env:n}){const{baseApiUrl:a}=h(n);try{const{data:i}=await w.post(`${a}/api/v1/claimer/save-stake-and-bake-signature`,null,{params:{typed_data:t,signature:e}});return i.status}catch(i){const r=C(i);throw new Error(r)}}const D={[s.ethereum]:"https://rpc.ankr.com/eth",[s.holesky]:"https://rpc.ankr.com/eth_holesky",[s.sepolia]:"https://rpc.ankr.com/eth_sepolia",[s.base]:"https://rpc.ankr.com/base",[s.baseTestnet]:"https://rpc.ankr.com/base_sepolia",[s.binanceSmartChain]:"https://rpc.ankr.com/bsc",[s.binanceSmartChainTestnet]:"https://rpc.ankr.com/bsc_testnet_chapel"};async function Ee(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=b.utils.hexToNumber(n==null?void 0:n.result);return new v(Number(a))}const _e=2,Ie=25e3;class O{constructor({chainId:t,rpcUrlConfig:n}){S(this,"chainId");S(this,"rpcConfig");this.chainId=t,this.rpcConfig={...D,...n}}getReadWeb3(){const t=this.getRpcUrl(),n=new b.Web3,a=new b.Web3.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,i]=await Promise.all([t.eth.getBlock("latest"),Ee(n)]);return!(a!=null&&a.baseFeePerGas)&&typeof(a==null?void 0:a.baseFeePerGas)!="bigint"?{}:{maxFeePerGas:+new v(a.baseFeePerGas.toString(10)).multipliedBy(_e).plus(i),maxPriorityFeePerGas:+i}}async getSafeGasPriceWei(){const t=await this.getReadWeb3().eth.getGasPrice();return new v(t.toString(10)).plus(Ie)}createContract(t,n){const a=this.getReadWeb3();return new a.eth.Contract(t,n)}}const Ne=[s.ethereum,s.base,s.binanceSmartChain],j=e=>Ne.includes(e)?T.prod:T.stage;function R(e){return Object.values(s).includes(e)}const De={[s.holesky]:"0xED7bfd5C1790576105Af4649817f6d35A75CD818",[s.ethereum]:u,[s.binanceSmartChainTestnet]:"0x731eFa688F3679688cf60A3993b8658138953ED6",[s.binanceSmartChain]:u,[s.sepolia]:"0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",[s.base]:u,[s.baseTestnet]:u,[s.berachainBartioTestnet]:"0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",[s.corn]:u,[s.swell]:u},xe={[s.holesky]:"0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2",[s.ethereum]:u,[s.binanceSmartChainTestnet]:"0x107Fc7d90484534704dD2A9e24c7BD45DB4dD1B5",[s.binanceSmartChain]:u,[s.sepolia]:"0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",[s.base]:u,[s.baseTestnet]:u,[s.berachainBartioTestnet]:"0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",[s.corn]:u,[s.swell]:u},Me={[s.ethereum]:"0x8236a87084f8b84306f72007f36f2618a5634494",[s.holesky]:u,[s.sepolia]:u,[s.binanceSmartChainTestnet]:u,[s.binanceSmartChain]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",[s.base]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",[s.baseTestnet]:u,[s.berachainBartioTestnet]:u,[s.corn]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",[s.swell]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1"};function J(e=P){switch(e){case T.prod:return Me;case T.testnet:return xe;default:return De}}const Pe=[{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"}],Oe=[{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:"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:[{internalType:"uint256",name:"deadline",type:"uint256"}],name:"ERC2612ExpiredSignature",type:"error"},{inputs:[{internalType:"address",name:"signer",type:"address"},{internalType:"address",name:"owner",type:"address"}],name:"ERC2612InvalidSigner",type:"error"},{inputs:[],name:"EnforcedPause",type:"error"},{inputs:[],name:"ExpectedPause",type:"error"},{inputs:[],name:"FeeGreaterThanAmount",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"uint256",name:"currentNonce",type:"uint256"}],name:"InvalidAccountNonce",type:"error"},{inputs:[],name:"InvalidDustFeeRate",type:"error"},{inputs:[],name:"InvalidInitialization",type:"error"},{inputs:[],name:"InvalidInputLength",type:"error"},{inputs:[],name:"InvalidUserSignature",type:"error"},{inputs:[],name:"KnownDestination",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:"PayloadAlreadyUsed",type:"error"},{inputs:[],name:"ReentrancyGuardReentrantCall",type:"error"},{inputs:[],name:"ScriptPubkeyUnsupported",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"UnauthorizedAccount",type:"error"},{inputs:[{internalType:"bytes4",name:"action",type:"bytes4"}],name:"UnexpectedAction",type:"error"},{inputs:[],name:"UnknownDestination",type:"error"},{inputs:[{internalType:"uint256",name:"fromChainId",type:"uint256"},{internalType:"address",name:"fromContract",type:"address"}],name:"UnknownOriginContract",type:"error"},{inputs:[{internalType:"uint256",name:"expiry",type:"uint256"}],name:"UserSignatureExpired",type:"error"},{inputs:[],name:"WithdrawalsDisabled",type:"error"},{inputs:[],name:"WrongChainId",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{inputs:[],name:"ZeroAmount",type:"error"},{inputs:[],name:"ZeroChainId",type:"error"},{inputs:[],name:"ZeroContractHash",type:"error"},{inputs:[],name:"ZeroFee",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:"address",name:"prevVal",type:"address"},{indexed:!0,internalType:"address",name:"newVal",type:"address"}],name:"BridgeChanged",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:"claimer",type:"address"},{indexed:!1,internalType:"bool",name:"isClaimer",type:"bool"}],name:"ClaimerUpdated",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:!0,internalType:"uint256",name:"oldRate",type:"uint256"},{indexed:!0,internalType:"uint256",name:"newRate",type:"uint256"}],name:"DustFeeRateChanged",type:"event"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"oldFee",type:"uint256"},{indexed:!0,internalType:"uint256",name:"newFee",type:"uint256"}],name:"FeeChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"fee",type:"uint256"},{indexed:!1,internalType:"bytes",name:"userSignature",type:"bytes"}],name:"FeeCharged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"version",type:"uint64"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"recipient",type:"address"},{indexed:!0,internalType:"bytes32",name:"payloadHash",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"payload",type:"bytes"}],name:"MintProofConsumed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"minter",type:"address"},{indexed:!1,internalType:"bool",name:"isMinter",type:"bool"}],name:"MinterUpdated",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:"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:!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:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"acceptOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newClaimer",type:"address"}],name:"addClaimer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newMinter",type:"address"}],name:"addMinter",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:"address[]",name:"to",type:"address[]"},{internalType:"uint256[]",name:"amount",type:"uint256[]"}],name:"batchMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes[]",name:"payload",type:"bytes[]"},{internalType:"bytes[]",name:"proof",type:"bytes[]"}],name:"batchMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes[]",name:"mintPayload",type:"bytes[]"},{internalType:"bytes[]",name:"proof",type:"bytes[]"},{internalType:"bytes[]",name:"feePayload",type:"bytes[]"},{internalType:"bytes[]",name:"userSignature",type:"bytes[]"}],name:"batchMintWithFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{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:"address",name:"newBridge",type:"address"}],name:"changeBridge",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:"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:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBurnCommission",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDustFeeRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getMintFee",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"},{internalType:"address",name:"owner_",type:"address"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"claimer",type:"address"}],name:"isClaimer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"minter",type:"address"}],name:"isMinter",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"payload",type:"bytes"},{internalType:"bytes",name:"proof",type:"bytes"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"mintPayload",type:"bytes"},{internalType:"bytes",name:"proof",type:"bytes"},{internalType:"bytes",name:"feePayload",type:"bytes"},{internalType:"bytes",name:"userSignature",type:"bytes"}],name:"mintWithFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],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:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"scriptPubkey",type:"bytes"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"redeem",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"reinitialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oldClaimer",type:"address"}],name:"removeClaimer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oldMinter",type:"address"}],name:"removeMinter",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"fee",type:"uint256"}],name:"setMintFee",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:[{components:[{internalType:"uint256",name:"fromChain",type:"uint256"},{internalType:"address",name:"fromContract",type:"address"},{internalType:"uint256",name:"toChain",type:"uint256"},{internalType:"address",name:"toContract",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint64",name:"amount",type:"uint64"},{internalType:"bytes32",name:"uniqueActionData",type:"bytes32"}],internalType:"struct Actions.DepositBridgeAction",name:"action",type:"tuple"},{internalType:"bytes32",name:"",type:"bytes32"},{internalType:"bytes",name:"",type:"bytes"}],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"}];function Re(e){switch(e){case"LBTC":return Oe;default:return Pe}}function B(e,t){const n=J(t),{chainId:a}=e;if(!R(a))throw new Error(`This chain ${a} is not supported`);const i=n[a];if(!i)throw new Error(`Token address for chain ${a} is not defined`);const r=Re("LBTC"),o=e.createContract(r,i);return o.options.address||(o.options.address=i),o}function X(e,t){if(!R(e))throw new Error(`This chain ${e} is not supported`);const n=t?{[e]:t}:D;if(!n[e])throw new Error(`RPC URL for chainId ${e} not found`);return n}async function Be({chainId:e,bakeGasEstimate:t=0,rpcUrl:n}){const a=X(e,n),i=new O({chainId:e,rpcUrlConfig:a}),r=j(e),p=await B(i,r).methods.getMintFee().call(),d=new v(N(p.toString(10)));return t?d.plus(N(t)):d}class F extends O{constructor({provider:n,account:a,chainId:i,rpcUrlConfig:r}){super({chainId:i,rpcUrlConfig:r});S(this,"web3");S(this,"account");S(this,"rpcConfig",D);this.web3=new b(n),this.account=a,this.chainId=i,this.rpcConfig={...D,...r}}async signMessage(n){const{account:a}=this,i=`0x${Buffer.from(n,"utf8").toString("hex")}`;return this.web3.currentProvider.request({method:"personal_sign",params:[i,a]})}async sendTransactionAsync(n,a,i){const{chainId:r,web3:o}=this,p=this.getReadWeb3(),{data:d,estimate:m=!1,estimateFee:l=!1,extendedGasLimit:y,gasLimit:f="0",value:E="0",gasLimitMultiplier:te=1}=i;let{nonce:_}=i;_||(_=await p.eth.getTransactionCount(n)),console.log(`Nonce: ${_}`);const c={from:n,to:a,value:b.utils.numberToHex(E),data:d,nonce:_,chainId:b.utils.numberToHex(r)};if(m)try{const g=await p.eth.estimateGas(c),I=Math.round(Number(g)*te);y?c.gas=b.utils.numberToHex(I+y):c.gas=b.utils.numberToHex(I)}catch(g){throw new Error(g.message??"Failed to estimate gas limit for transaction.")}else c.gas=b.utils.numberToHex(f);const{maxFeePerGas:k,maxPriorityFeePerGas:U}=l?await this.getMaxFees().catch(()=>i):i;if(U!==void 0&&(c.maxPriorityFeePerGas=b.utils.numberToHex(U)),k!==void 0&&(c.maxFeePerGas=b.utils.numberToHex(k)),!c.maxFeePerGas&&!c.maxPriorityFeePerGas){const g=await this.getSafeGasPriceWei();c.gasPrice=g.toString(10)}if(!c.maxFeePerGas&&!c.maxPriorityFeePerGas){const g=await this.getSafeGasPriceWei();c.gasPrice=g.toString(10)}return console.log("Sending transaction via Web3: ",c),new Promise((g,I)=>{const L=o.eth.sendTransaction(c);L.once("transactionHash",async G=>{console.log(`Just signed transaction has is: ${G}`),g({receiptPromise:L,transactionHash:G})}).catch(I)})}createContract(n,a){return new this.web3.eth.Contract(n,a)}}async function Fe(e){const t=new F(e),n=`destination chain id is ${e.chainId}`;return t.signMessage(n)}const ke=24*60*60;function Ue({chainId:e,verifyingContract:t,fee:n,expiry:a}){return{domain:{name:"Lombard Staked Bitcoin",version:"1",chainId:e,verifyingContract:t},message:{chainId:e,fee:n,expiry:a},primaryType:"feeApproval",types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],feeApproval:[{name:"chainId",type:"uint256"},{name:"fee",type:"uint256"},{name:"expiry",type:"uint256"}]}}}const Le="Failed to obtain a valid signature. The response is undefined or invalid.",Ge=()=>Math.floor(Date.now()/1e3+ke);async function He({address:e,provider:t,fee:n,chainId:a,env:i,expiry:r=Ge()}){var y,f;const o=new F({provider:t,account:e,chainId:a}),d=B(o,i).options.address,m=JSON.stringify(Ue({chainId:a,verifyingContract:d,fee:n,expiry:r})),l=await((f=(y=o.web3)==null?void 0:y.currentProvider)==null?void 0:f.request({method:"eth_signTypedData_v4",params:[e,m]}));if(typeof l=="string")return{signature:l,typedData:m};if(!(l!=null&&l.result))throw new Error(Le);return{signature:l.result,typedData:m}}async function We({owner:e,rpcUrl:t,chainId:n}){const a=X(n,t),i=new O({chainId:n,rpcUrlConfig:a}),r=j(n),o=B(i,r);try{return(await o.methods.nonces(e).call()).toString()}catch(p){const d=C(p);throw new Error(d)}}async function Y({chainId:e,expiryDate:t,owner:n,spender:a,value:i,env:r,rpcUrl:o}){const d=J(r)[e],m=await We({owner:n,chainId:e,rpcUrl:o});return{domain:{name:"Lombard Staked Bitcoin",version:"1",chainId:e,verifyingContract:d},types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},primaryType:"Permit",message:{owner:n,spender:a,value:i,nonce:m,deadline:t.toString()}}}const Q={[s.holesky]:"0x52BD640617eeD47A00dA0da93351092D49208d1d"},ee=e=>{const t=Q[e];if(!t)throw new Error(`No spender address configured for chain ID ${e}`);return t},$e="Failed to obtain a valid signature. The response is undefined or invalid.";async function Ve({address:e,provider:t,chainId:n,value:a,env:i,expiryDate:r,rpcUrl:o}){var f,E;const p=new F({provider:t,account:e,chainId:n}),d=ee(n),m=await Y({chainId:n,expiryDate:r,owner:e,spender:d,value:a,env:i,rpcUrl:o}),l=JSON.stringify(m),y=await((E=(f=p.web3)==null?void 0:f.currentProvider)==null?void 0:E.request({method:"eth_signTypedData_v4",params:[e,l]}));if(typeof y=="string")return{signature:y,typedData:l};if(!(y!=null&&y.result))throw new Error($e);return{signature:y.result,typedData:l}}exports.ENotarizationStatus=q;exports.ESessionState=z;exports.OChainId=s;exports.OEnv=T;exports.SANCTIONED_ADDRESS=V;exports.SATOSHI_SCALE=M;exports.STAKE_AND_BAKE_SPENDER_ADDRESSES=Q;exports.fromSatoshi=N;exports.generateDepositBtcAddress=de;exports.getApiConfig=h;exports.getBaseNetworkByEnv=$;exports.getBscNetworkByEnv=W;exports.getChainIdByName=K;exports.getChainNameById=x;exports.getDepositBtcAddress=me;exports.getDepositBtcAddresses=Z;exports.getDepositsByAddress=ge;exports.getEthNetworkByEnv=H;exports.getLBTCExchangeRate=Se;exports.getLBTCMintingFee=Be;exports.getNetworkFeeSignature=Ae;exports.getStakeAndBakeSpenderAddress=ee;exports.getStakeAndBakeTypedData=Y;exports.isValidChain=R;exports.signLbtcDestionationAddr=Fe;exports.signNetworkFee=He;exports.signStakeAndBake=Ve;exports.storeNetworkFeeSignature=ve;exports.storeStakeAndBakeSignature=Ce;exports.toSatoshi=fe;
2
2
  //# sourceMappingURL=index.cjs.map