import{i as b,j as S,k as v,l as _}from"../chunk-HWE3WYGL.js";import{nonNullish as R}from"@dfinity/utils";var c=class extends Error{details;constructor({msg:r,details:t}){super(r),this.details=t}},h=class extends Error{},s=class extends c{},d=class extends h{},m=class extends s{},u=class extends s{},f=class extends s{},p=class extends s{},k=class extends s{},M=class extends Error{},a=class extends c{},x=class extends a{},C=class extends a{},E=class extends a{},y=class extends a{},T=class extends a{},O=e=>"TemporarilyUnavailable"in e?new d(e.TemporarilyUnavailable):"InsufficientAllowance"in e?new u({details:e.InsufficientAllowance.allowance}):"AmountTooLow"in e?new f({details:e.AmountTooLow.min_withdrawal_amount}):"RecipientAddressBlocked"in e?new p({details:e.RecipientAddressBlocked.address}):"InsufficientFunds"in e?new m({details:e.InsufficientFunds.balance}):new s({msg:"Unsupported response type in minter.withdrawEth",details:e}),D=e=>{if("TemporarilyUnavailable"in e)return new d(e.TemporarilyUnavailable);if("RecipientAddressBlocked"in e)return new p({details:e.RecipientAddressBlocked.address});if("TokenNotSupported"in e)return new k({details:e.TokenNotSupported.supported_tokens});let r=({Err:t,ckEthBlockIndex:i})=>{let n=o=>({error:o,ckEthBlockIndex:i});return"TemporarilyUnavailable"in t?new C({msg:t.TemporarilyUnavailable,...R(i)&&{details:{ckEthBlockIndex:i}}}):"InsufficientAllowance"in t?new E({details:n(t.InsufficientAllowance)}):"AmountTooLow"in t?new y({details:n(t.AmountTooLow)}):"InsufficientFunds"in t?new T({details:n(t.InsufficientFunds)}):new x({msg:"Unsupported response type in ledger for minter.withdrawErc20",details:n(t)})};return"CkErc20LedgerError"in e?r({Err:e.CkErc20LedgerError.error,ckEthBlockIndex:e.CkErc20LedgerError.cketh_block_index}):"CkEthLedgerError"in e?r({Err:e.CkEthLedgerError.error}):new s({msg:"Unsupported response type in minter.withdrawErc20",details:e})};import{Canister as Q,createServices as L,toNullable as w}from"@dfinity/utils";import{isNullish as U,toNullable as B}from"@dfinity/utils";var I=({ckErc20LedgerId:e})=>B(U(e)?void 0:{ckerc20_ledger_id:e});var P=class e extends Q{static create(r){let{service:t,certifiedService:i,canisterId:n}=L({options:r,idlFactory:S,certifiedIdlFactory:b});return new e(n,t,i)}getSmartContractAddress=({certified:r}={})=>{let{smart_contract_address:t}=this.caller({certified:r});return t()};withdrawEth=async({address:r,fromSubaccount:t,...i})=>{let{withdraw_eth:n}=this.caller({certified:!0}),o=await n({recipient:r,from_subaccount:w(t),...i});if("Err"in o)throw O(o.Err);return o.Ok};withdrawErc20=async({address:r,ledgerCanisterId:t,fromCkEthSubaccount:i,fromCkErc20Subaccount:n,...o})=>{let{withdraw_erc20:F}=this.caller({certified:!0}),l=await F({recipient:r,ckerc20_ledger_id:t,from_cketh_subaccount:w(i),from_ckerc20_subaccount:w(n),...o});if("Err"in l)throw D(l.Err);return l.Ok};eip1559TransactionPrice=({certified:r,...t})=>{let{eip_1559_transaction_price:i}=this.caller({certified:r});return i(I(t))};retrieveEthStatus=r=>{let{retrieve_eth_status:t}=this.caller({certified:!0});return t(r)};getMinterInfo=({certified:r})=>{let{get_minter_info:t}=this.caller({certified:r});return t()}};import{Canister as N,createServices as W}from"@dfinity/utils";var g=class e extends N{static create(r){let{service:t,certifiedService:i,canisterId:n}=W({options:r,idlFactory:_,certifiedIdlFactory:v});return new e(n,t,i)}getOrchestratorInfo=({certified:r}={})=>{let{get_orchestrator_info:t}=this.caller({certified:r});return t()}};import{decodeBase32 as q}from"@dfinity/utils";var ie=e=>{let r=q(e.toText().replace(/-/g,""));return G(r.slice(4))},A=({stringToAppend:e,bytes:r})=>(e+=(r>>4&15).toString(16),e+=(r&15).toString(16),e),G=e=>{let r=e.length,t="0x";t=A({stringToAppend:t,bytes:r});for(let i=0;i<e.length;i++)t=A({stringToAppend:t,bytes:e[i]});for(let i=0;i<31-e.length;i++)t+="00";return t};export{P as CkEthMinterCanister,g as CkEthOrchestratorCanister,c as DetailedError,y as LedgerAmountTooLowError,a as LedgerError,M as LedgerGenericError,E as LedgerInsufficientAllowanceError,T as LedgerInsufficientFundsError,C as LedgerTemporaryUnavailableError,x as LedgerWithdrawalError,f as MinterAmountTooLowError,s as MinterError,h as MinterGenericError,u as MinterInsufficientAllowanceError,m as MinterInsufficientFundsError,p as MinterRecipientAddressBlockedError,d as MinterTemporaryUnavailableError,k as MinterTokenNotSupported,D as createWithdrawErc20Error,O as createWithdrawEthError,ie as encodePrincipalToEthAddress};
//# sourceMappingURL=index.js.map
