@dfinity/cketh
Version:
A library for interfacing with ckETH.
3 lines (2 loc) • 27.4 kB
JavaScript
"use strict";var ae=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var ge=Object.prototype.hasOwnProperty;var xe=(e,t)=>{for(var r in t)ae(e,r,{get:t[r],enumerable:!0})},Te=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of Ne(t))!ge.call(e,c)&&c!==r&&ae(e,c,{get:()=>t[c],enumerable:!(a=he(t,c))||a.enumerable});return e};var be=e=>Te(ae({},"__esModule",{value:!0}),e);var ye={};xe(ye,{CkETHMinterCanister:()=>H,CkETHOrchestratorCanister:()=>G,DetailedError:()=>E,LedgerAmountTooLowError:()=>B,LedgerError:()=>m,LedgerGenericError:()=>ce,LedgerInsufficientAllowanceError:()=>q,LedgerInsufficientFundsError:()=>z,LedgerTemporaryUnavailableError:()=>W,LedgerWithdrawalError:()=>U,MinterAmountTooLowError:()=>F,MinterError:()=>d,MinterGenericError:()=>A,MinterInsufficientAllowanceError:()=>C,MinterInsufficientFundsError:()=>S,MinterRecipientAddressBlockedError:()=>V,MinterTemporaryUnavailableError:()=>v,MinterTokenNotSupported:()=>M,createWithdrawErc20Error:()=>ie,createWithdrawEthError:()=>ne,encodePrincipalToEthAddress:()=>ke});module.exports=be(ye);var oe=require("@dfinity/utils"),E=class extends Error{details;constructor({msg:t,details:r}){super(t),this.details=r}},A=class extends Error{},d=class extends E{},v=class extends A{},S=class extends d{},C=class extends d{},F=class extends d{},V=class extends d{},M=class extends d{},ce=class extends Error{},m=class extends E{},U=class extends m{},W=class extends m{},q=class extends m{},B=class extends m{},z=class extends m{},ne=e=>"TemporarilyUnavailable"in e?new v(e.TemporarilyUnavailable):"InsufficientAllowance"in e?new C({details:e.InsufficientAllowance.allowance}):"AmountTooLow"in e?new F({details:e.AmountTooLow.min_withdrawal_amount}):"RecipientAddressBlocked"in e?new V({details:e.RecipientAddressBlocked.address}):"InsufficientFunds"in e?new S({details:e.InsufficientFunds.balance}):new d({msg:"Unsupported response type in minter.withdrawEth",details:e}),ie=e=>{if("TemporarilyUnavailable"in e)return new v(e.TemporarilyUnavailable);if("RecipientAddressBlocked"in e)return new V({details:e.RecipientAddressBlocked.address});if("TokenNotSupported"in e)return new M({details:e.TokenNotSupported.supported_tokens});let t=({Err:r,ckEthBlockIndex:a})=>{let c=n=>({error:n,ckEthBlockIndex:a});return"TemporarilyUnavailable"in r?new W({msg:r.TemporarilyUnavailable,...(0,oe.nonNullish)(a)&&{details:{ckEthBlockIndex:a}}}):"InsufficientAllowance"in r?new q({details:c(r.InsufficientAllowance)}):"AmountTooLow"in r?new B({details:c(r.AmountTooLow)}):"InsufficientFunds"in r?new z({details:c(r.InsufficientFunds)}):new U({msg:"Unsupported response type in ledger for minter.withdrawErc20",details:c(r)})};return"CkErc20LedgerError"in e?t({Err:e.CkErc20LedgerError.error,ckEthBlockIndex:e.CkErc20LedgerError.cketh_block_index}):"CkEthLedgerError"in e?t({Err:e.CkEthLedgerError.error}):new d({msg:"Unsupported response type in minter.withdrawErc20",details:e})};var h=require("@dfinity/utils");var se=({IDL:e})=>{let t=e.Variant({Safe:e.Null,Finalized:e.Null,Latest:e.Null}),r=e.Record({deposit_with_subaccount_helper_contract_address:e.Opt(e.Text),next_transaction_nonce:e.Opt(e.Nat),evm_rpc_id:e.Opt(e.Principal),ledger_suite_orchestrator_id:e.Opt(e.Principal),erc20_helper_contract_address:e.Opt(e.Text),last_erc20_scraped_block_number:e.Opt(e.Nat),ethereum_contract_address:e.Opt(e.Text),minimum_withdrawal_amount:e.Opt(e.Nat),last_deposit_with_subaccount_scraped_block_number:e.Opt(e.Nat),ethereum_block_height:e.Opt(t)}),a=e.Variant({Mainnet:e.Null,Sepolia:e.Null}),c=e.Record({ethereum_network:a,last_scraped_block_number:e.Nat,ecdsa_key_name:e.Text,next_transaction_nonce:e.Nat,evm_rpc_id:e.Opt(e.Principal),ledger_id:e.Principal,ethereum_contract_address:e.Opt(e.Text),minimum_withdrawal_amount:e.Nat,ethereum_block_height:t}),n=e.Variant({UpgradeArg:r,InitArg:c}),l=e.Record({ckerc20_ledger_id:e.Principal,chain_id:e.Nat,address:e.Text,ckerc20_token_symbol:e.Text}),i=e.Record({ckerc20_ledger_id:e.Principal}),N=e.Record({max_priority_fee_per_gas:e.Nat,max_fee_per_gas:e.Nat,max_transaction_fee:e.Nat,timestamp:e.Opt(e.Nat64),gas_limit:e.Nat}),g=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),O=e.Variant({controllers:e.Null,public:e.Null,allowed_viewers:e.Vec(e.Principal)}),x=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:O,wasm_memory_limit:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),T=e.Record({response_payload_bytes_total:e.Nat,num_instructions_total:e.Nat,num_calls_total:e.Nat,request_payload_bytes_total:e.Nat}),b=e.Record({status:g,memory_size:e.Nat,cycles:e.Nat,settings:x,query_stats:T,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),o=e.Vec(e.Nat8),s=e.Record({transaction_hash:e.Text,log_index:e.Nat}),p=e.Record({destination:e.Text,value:e.Nat,max_priority_fee_per_gas:e.Nat,data:e.Vec(e.Nat8),max_fee_per_gas:e.Nat,chain_id:e.Nat,nonce:e.Nat,gas_limit:e.Nat,access_list:e.Vec(e.Record({storage_keys:e.Vec(e.Vec(e.Nat8)),address:e.Text}))}),_=e.Variant({CkErc20:e.Record({cketh_ledger_burn_index:e.Nat,ledger_id:e.Principal,ckerc20_ledger_burn_index:e.Nat}),CkEth:e.Record({ledger_burn_index:e.Nat})}),k=e.Record({effective_gas_price:e.Nat,status:e.Variant({Success:e.Null,Failure:e.Null}),transaction_hash:e.Text,block_hash:e.Text,block_number:e.Nat,gas_used:e.Nat}),R=e.Record({timestamp:e.Nat64,payload:e.Variant({SkippedBlock:e.Record({block_number:e.Nat,contract_address:e.Opt(e.Text)}),AcceptedErc20Deposit:e.Record({principal:e.Principal,transaction_hash:e.Text,value:e.Nat,log_index:e.Nat,subaccount:e.Opt(o),block_number:e.Nat,erc20_contract_address:e.Text,from_address:e.Text}),SignedTransaction:e.Record({raw_transaction:e.Text,withdrawal_id:e.Nat}),Upgrade:r,Init:c,AddedCkErc20Token:e.Record({ckerc20_ledger_id:e.Principal,chain_id:e.Nat,address:e.Text,ckerc20_token_symbol:e.Text}),SyncedDepositWithSubaccountToBlock:e.Record({block_number:e.Nat}),QuarantinedDeposit:e.Record({event_source:s}),SyncedToBlock:e.Record({block_number:e.Nat}),AcceptedDeposit:e.Record({principal:e.Principal,transaction_hash:e.Text,value:e.Nat,log_index:e.Nat,subaccount:e.Opt(o),block_number:e.Nat,from_address:e.Text}),ReplacedTransaction:e.Record({withdrawal_id:e.Nat,transaction:p}),QuarantinedReimbursement:e.Record({index:_}),MintedCkEth:e.Record({event_source:s,mint_block_index:e.Nat}),ReimbursedEthWithdrawal:e.Record({transaction_hash:e.Opt(e.Text),withdrawal_id:e.Nat,reimbursed_amount:e.Nat,reimbursed_in_block:e.Nat}),FailedErc20WithdrawalRequest:e.Record({to:e.Principal,withdrawal_id:e.Nat,reimbursed_amount:e.Nat,to_subaccount:e.Opt(e.Vec(e.Nat8))}),ReimbursedErc20Withdrawal:e.Record({burn_in_block:e.Nat,transaction_hash:e.Opt(e.Text),withdrawal_id:e.Nat,reimbursed_amount:e.Nat,ledger_id:e.Principal,reimbursed_in_block:e.Nat}),MintedCkErc20:e.Record({event_source:s,erc20_contract_address:e.Text,mint_block_index:e.Nat,ckerc20_token_symbol:e.Text}),CreatedTransaction:e.Record({withdrawal_id:e.Nat,transaction:p}),InvalidDeposit:e.Record({event_source:s,reason:e.Text}),SyncedErc20ToBlock:e.Record({block_number:e.Nat}),AcceptedErc20WithdrawalRequest:e.Record({cketh_ledger_burn_index:e.Nat,destination:e.Text,ckerc20_ledger_id:e.Principal,withdrawal_amount:e.Nat,from:e.Principal,created_at:e.Nat64,from_subaccount:e.Opt(e.Vec(e.Nat8)),erc20_contract_address:e.Text,ckerc20_ledger_burn_index:e.Nat,max_transaction_fee:e.Nat}),AcceptedEthWithdrawalRequest:e.Record({ledger_burn_index:e.Nat,destination:e.Text,withdrawal_amount:e.Nat,from:e.Principal,created_at:e.Opt(e.Nat64),from_subaccount:e.Opt(e.Vec(e.Nat8))}),FinalizedTransaction:e.Record({withdrawal_id:e.Nat,transaction_receipt:k})})}),u=e.Record({erc20_contract_address:e.Text,ledger_canister_id:e.Principal,ckerc20_token_symbol:e.Text}),y=e.Record({max_priority_fee_per_gas:e.Nat,max_fee_per_gas:e.Nat,timestamp:e.Nat64}),J=e.Record({deposit_with_subaccount_helper_contract_address:e.Opt(e.Text),eth_balance:e.Opt(e.Nat),eth_helper_contract_address:e.Opt(e.Text),last_observed_block_number:e.Opt(e.Nat),evm_rpc_id:e.Opt(e.Principal),erc20_helper_contract_address:e.Opt(e.Text),last_erc20_scraped_block_number:e.Opt(e.Nat),supported_ckerc20_tokens:e.Opt(e.Vec(u)),last_gas_fee_estimate:e.Opt(y),cketh_ledger_id:e.Opt(e.Principal),smart_contract_address:e.Opt(e.Text),last_eth_scraped_block_number:e.Opt(e.Nat),minimum_withdrawal_amount:e.Opt(e.Nat),erc20_balances:e.Opt(e.Vec(e.Record({balance:e.Nat,erc20_contract_address:e.Text}))),minter_address:e.Opt(e.Text),last_deposit_with_subaccount_scraped_block_number:e.Opt(e.Nat),ethereum_block_height:e.Opt(t)}),w=e.Record({transaction_hash:e.Text}),f=e.Variant({Success:e.Record({transaction_hash:e.Text,effective_transaction_fee:e.Opt(e.Nat)}),Reimbursed:e.Record({transaction_hash:e.Text,reimbursed_amount:e.Nat,reimbursed_in_block:e.Nat}),PendingReimbursement:w}),K=e.Variant({NotFound:e.Null,TxFinalized:f,TxSent:w,TxCreated:e.Null,Pending:e.Null}),X=e.Record({ckerc20_ledger_id:e.Principal,recipient:e.Text,from_cketh_subaccount:e.Opt(o),from_ckerc20_subaccount:e.Opt(o),amount:e.Nat}),Y=e.Record({ckerc20_block_index:e.Nat,cketh_block_index:e.Nat}),P=e.Variant({TemporarilyUnavailable:e.Text,InsufficientAllowance:e.Record({token_symbol:e.Text,ledger_id:e.Principal,allowance:e.Nat,failed_burn_amount:e.Nat}),AmountTooLow:e.Record({minimum_burn_amount:e.Nat,token_symbol:e.Text,ledger_id:e.Principal,failed_burn_amount:e.Nat}),InsufficientFunds:e.Record({balance:e.Nat,token_symbol:e.Text,ledger_id:e.Principal,failed_burn_amount:e.Nat})}),Z=e.Variant({TokenNotSupported:e.Record({supported_tokens:e.Vec(u)}),TemporarilyUnavailable:e.Text,CkErc20LedgerError:e.Record({error:P,cketh_block_index:e.Nat}),CkEthLedgerError:e.Record({error:P}),RecipientAddressBlocked:e.Record({address:e.Text})}),$=e.Record({recipient:e.Text,from_subaccount:e.Opt(o),amount:e.Nat}),I=e.Record({block_index:e.Nat}),L=e.Variant({TemporarilyUnavailable:e.Text,InsufficientAllowance:e.Record({allowance:e.Nat}),AmountTooLow:e.Record({min_withdrawal_amount:e.Nat}),RecipientAddressBlocked:e.Record({address:e.Text}),InsufficientFunds:e.Record({balance:e.Nat})}),D=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),ee=e.Variant({ByRecipient:e.Text,BySenderAccount:D,ByWithdrawalId:e.Nat64}),te=e.Variant({TxFinalized:f,TxSent:w,TxCreated:e.Null,Pending:e.Null}),re=e.Record({status:te,token_symbol:e.Text,withdrawal_amount:e.Nat,withdrawal_id:e.Nat64,from:e.Principal,from_subaccount:e.Opt(e.Vec(e.Nat8)),max_transaction_fee:e.Opt(e.Nat),recipient_address:e.Text});return e.Service({add_ckerc20_token:e.Func([l],[],[]),eip_1559_transaction_price:e.Func([e.Opt(i)],[N],[]),get_canister_status:e.Func([],[b],[]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Record({total_event_count:e.Nat64,events:e.Vec(R)})],[]),get_minter_info:e.Func([],[J],[]),is_address_blocked:e.Func([e.Text],[e.Bool],[]),minter_address:e.Func([],[e.Text],[]),retrieve_eth_status:e.Func([e.Nat64],[K],[]),smart_contract_address:e.Func([],[e.Text],[]),withdraw_erc20:e.Func([X],[e.Variant({Ok:Y,Err:Z})],[]),withdraw_eth:e.Func([$],[e.Variant({Ok:I,Err:L})],[]),withdrawal_status:e.Func([ee],[e.Vec(re)],[])})};var _e=({IDL:e})=>{let t=e.Variant({Safe:e.Null,Finalized:e.Null,Latest:e.Null}),r=e.Record({deposit_with_subaccount_helper_contract_address:e.Opt(e.Text),next_transaction_nonce:e.Opt(e.Nat),evm_rpc_id:e.Opt(e.Principal),ledger_suite_orchestrator_id:e.Opt(e.Principal),erc20_helper_contract_address:e.Opt(e.Text),last_erc20_scraped_block_number:e.Opt(e.Nat),ethereum_contract_address:e.Opt(e.Text),minimum_withdrawal_amount:e.Opt(e.Nat),last_deposit_with_subaccount_scraped_block_number:e.Opt(e.Nat),ethereum_block_height:e.Opt(t)}),a=e.Variant({Mainnet:e.Null,Sepolia:e.Null}),c=e.Record({ethereum_network:a,last_scraped_block_number:e.Nat,ecdsa_key_name:e.Text,next_transaction_nonce:e.Nat,evm_rpc_id:e.Opt(e.Principal),ledger_id:e.Principal,ethereum_contract_address:e.Opt(e.Text),minimum_withdrawal_amount:e.Nat,ethereum_block_height:t}),n=e.Variant({UpgradeArg:r,InitArg:c}),l=e.Record({ckerc20_ledger_id:e.Principal,chain_id:e.Nat,address:e.Text,ckerc20_token_symbol:e.Text}),i=e.Record({ckerc20_ledger_id:e.Principal}),N=e.Record({max_priority_fee_per_gas:e.Nat,max_fee_per_gas:e.Nat,max_transaction_fee:e.Nat,timestamp:e.Opt(e.Nat64),gas_limit:e.Nat}),g=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),O=e.Variant({controllers:e.Null,public:e.Null,allowed_viewers:e.Vec(e.Principal)}),x=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:O,wasm_memory_limit:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),T=e.Record({response_payload_bytes_total:e.Nat,num_instructions_total:e.Nat,num_calls_total:e.Nat,request_payload_bytes_total:e.Nat}),b=e.Record({status:g,memory_size:e.Nat,cycles:e.Nat,settings:x,query_stats:T,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),o=e.Vec(e.Nat8),s=e.Record({transaction_hash:e.Text,log_index:e.Nat}),p=e.Record({destination:e.Text,value:e.Nat,max_priority_fee_per_gas:e.Nat,data:e.Vec(e.Nat8),max_fee_per_gas:e.Nat,chain_id:e.Nat,nonce:e.Nat,gas_limit:e.Nat,access_list:e.Vec(e.Record({storage_keys:e.Vec(e.Vec(e.Nat8)),address:e.Text}))}),_=e.Variant({CkErc20:e.Record({cketh_ledger_burn_index:e.Nat,ledger_id:e.Principal,ckerc20_ledger_burn_index:e.Nat}),CkEth:e.Record({ledger_burn_index:e.Nat})}),k=e.Record({effective_gas_price:e.Nat,status:e.Variant({Success:e.Null,Failure:e.Null}),transaction_hash:e.Text,block_hash:e.Text,block_number:e.Nat,gas_used:e.Nat}),R=e.Record({timestamp:e.Nat64,payload:e.Variant({SkippedBlock:e.Record({block_number:e.Nat,contract_address:e.Opt(e.Text)}),AcceptedErc20Deposit:e.Record({principal:e.Principal,transaction_hash:e.Text,value:e.Nat,log_index:e.Nat,subaccount:e.Opt(o),block_number:e.Nat,erc20_contract_address:e.Text,from_address:e.Text}),SignedTransaction:e.Record({raw_transaction:e.Text,withdrawal_id:e.Nat}),Upgrade:r,Init:c,AddedCkErc20Token:e.Record({ckerc20_ledger_id:e.Principal,chain_id:e.Nat,address:e.Text,ckerc20_token_symbol:e.Text}),SyncedDepositWithSubaccountToBlock:e.Record({block_number:e.Nat}),QuarantinedDeposit:e.Record({event_source:s}),SyncedToBlock:e.Record({block_number:e.Nat}),AcceptedDeposit:e.Record({principal:e.Principal,transaction_hash:e.Text,value:e.Nat,log_index:e.Nat,subaccount:e.Opt(o),block_number:e.Nat,from_address:e.Text}),ReplacedTransaction:e.Record({withdrawal_id:e.Nat,transaction:p}),QuarantinedReimbursement:e.Record({index:_}),MintedCkEth:e.Record({event_source:s,mint_block_index:e.Nat}),ReimbursedEthWithdrawal:e.Record({transaction_hash:e.Opt(e.Text),withdrawal_id:e.Nat,reimbursed_amount:e.Nat,reimbursed_in_block:e.Nat}),FailedErc20WithdrawalRequest:e.Record({to:e.Principal,withdrawal_id:e.Nat,reimbursed_amount:e.Nat,to_subaccount:e.Opt(e.Vec(e.Nat8))}),ReimbursedErc20Withdrawal:e.Record({burn_in_block:e.Nat,transaction_hash:e.Opt(e.Text),withdrawal_id:e.Nat,reimbursed_amount:e.Nat,ledger_id:e.Principal,reimbursed_in_block:e.Nat}),MintedCkErc20:e.Record({event_source:s,erc20_contract_address:e.Text,mint_block_index:e.Nat,ckerc20_token_symbol:e.Text}),CreatedTransaction:e.Record({withdrawal_id:e.Nat,transaction:p}),InvalidDeposit:e.Record({event_source:s,reason:e.Text}),SyncedErc20ToBlock:e.Record({block_number:e.Nat}),AcceptedErc20WithdrawalRequest:e.Record({cketh_ledger_burn_index:e.Nat,destination:e.Text,ckerc20_ledger_id:e.Principal,withdrawal_amount:e.Nat,from:e.Principal,created_at:e.Nat64,from_subaccount:e.Opt(e.Vec(e.Nat8)),erc20_contract_address:e.Text,ckerc20_ledger_burn_index:e.Nat,max_transaction_fee:e.Nat}),AcceptedEthWithdrawalRequest:e.Record({ledger_burn_index:e.Nat,destination:e.Text,withdrawal_amount:e.Nat,from:e.Principal,created_at:e.Opt(e.Nat64),from_subaccount:e.Opt(e.Vec(e.Nat8))}),FinalizedTransaction:e.Record({withdrawal_id:e.Nat,transaction_receipt:k})})}),u=e.Record({erc20_contract_address:e.Text,ledger_canister_id:e.Principal,ckerc20_token_symbol:e.Text}),y=e.Record({max_priority_fee_per_gas:e.Nat,max_fee_per_gas:e.Nat,timestamp:e.Nat64}),J=e.Record({deposit_with_subaccount_helper_contract_address:e.Opt(e.Text),eth_balance:e.Opt(e.Nat),eth_helper_contract_address:e.Opt(e.Text),last_observed_block_number:e.Opt(e.Nat),evm_rpc_id:e.Opt(e.Principal),erc20_helper_contract_address:e.Opt(e.Text),last_erc20_scraped_block_number:e.Opt(e.Nat),supported_ckerc20_tokens:e.Opt(e.Vec(u)),last_gas_fee_estimate:e.Opt(y),cketh_ledger_id:e.Opt(e.Principal),smart_contract_address:e.Opt(e.Text),last_eth_scraped_block_number:e.Opt(e.Nat),minimum_withdrawal_amount:e.Opt(e.Nat),erc20_balances:e.Opt(e.Vec(e.Record({balance:e.Nat,erc20_contract_address:e.Text}))),minter_address:e.Opt(e.Text),last_deposit_with_subaccount_scraped_block_number:e.Opt(e.Nat),ethereum_block_height:e.Opt(t)}),w=e.Record({transaction_hash:e.Text}),f=e.Variant({Success:e.Record({transaction_hash:e.Text,effective_transaction_fee:e.Opt(e.Nat)}),Reimbursed:e.Record({transaction_hash:e.Text,reimbursed_amount:e.Nat,reimbursed_in_block:e.Nat}),PendingReimbursement:w}),K=e.Variant({NotFound:e.Null,TxFinalized:f,TxSent:w,TxCreated:e.Null,Pending:e.Null}),X=e.Record({ckerc20_ledger_id:e.Principal,recipient:e.Text,from_cketh_subaccount:e.Opt(o),from_ckerc20_subaccount:e.Opt(o),amount:e.Nat}),Y=e.Record({ckerc20_block_index:e.Nat,cketh_block_index:e.Nat}),P=e.Variant({TemporarilyUnavailable:e.Text,InsufficientAllowance:e.Record({token_symbol:e.Text,ledger_id:e.Principal,allowance:e.Nat,failed_burn_amount:e.Nat}),AmountTooLow:e.Record({minimum_burn_amount:e.Nat,token_symbol:e.Text,ledger_id:e.Principal,failed_burn_amount:e.Nat}),InsufficientFunds:e.Record({balance:e.Nat,token_symbol:e.Text,ledger_id:e.Principal,failed_burn_amount:e.Nat})}),Z=e.Variant({TokenNotSupported:e.Record({supported_tokens:e.Vec(u)}),TemporarilyUnavailable:e.Text,CkErc20LedgerError:e.Record({error:P,cketh_block_index:e.Nat}),CkEthLedgerError:e.Record({error:P}),RecipientAddressBlocked:e.Record({address:e.Text})}),$=e.Record({recipient:e.Text,from_subaccount:e.Opt(o),amount:e.Nat}),I=e.Record({block_index:e.Nat}),L=e.Variant({TemporarilyUnavailable:e.Text,InsufficientAllowance:e.Record({allowance:e.Nat}),AmountTooLow:e.Record({min_withdrawal_amount:e.Nat}),RecipientAddressBlocked:e.Record({address:e.Text}),InsufficientFunds:e.Record({balance:e.Nat})}),D=e.Record({owner:e.Principal,subaccount:e.Opt(e.Vec(e.Nat8))}),ee=e.Variant({ByRecipient:e.Text,BySenderAccount:D,ByWithdrawalId:e.Nat64}),te=e.Variant({TxFinalized:f,TxSent:w,TxCreated:e.Null,Pending:e.Null}),re=e.Record({status:te,token_symbol:e.Text,withdrawal_amount:e.Nat,withdrawal_id:e.Nat64,from:e.Principal,from_subaccount:e.Opt(e.Vec(e.Nat8)),max_transaction_fee:e.Opt(e.Nat),recipient_address:e.Text});return e.Service({add_ckerc20_token:e.Func([l],[],[]),eip_1559_transaction_price:e.Func([e.Opt(i)],[N],["query"]),get_canister_status:e.Func([],[b],[]),get_events:e.Func([e.Record({start:e.Nat64,length:e.Nat64})],[e.Record({total_event_count:e.Nat64,events:e.Vec(R)})],["query"]),get_minter_info:e.Func([],[J],["query"]),is_address_blocked:e.Func([e.Text],[e.Bool],["query"]),minter_address:e.Func([],[e.Text],[]),retrieve_eth_status:e.Func([e.Nat64],[K],[]),smart_contract_address:e.Func([],[e.Text],["query"]),withdraw_erc20:e.Func([X],[e.Variant({Ok:Y,Err:Z})],[]),withdraw_eth:e.Func([$],[e.Variant({Ok:I,Err:L})],[]),withdrawal_status:e.Func([ee],[e.Vec(re)],["query"])})};var Q=require("@dfinity/utils"),de=({ckErc20LedgerId:e})=>(0,Q.toNullable)((0,Q.isNullish)(e)?void 0:{ckerc20_ledger_id:e});var H=class e extends h.Canister{static create(t){let{service:r,certifiedService:a,canisterId:c}=(0,h.createServices)({options:t,idlFactory:_e,certifiedIdlFactory:se});return new e(c,r,a)}getSmartContractAddress=({certified:t}={})=>{let{smart_contract_address:r}=this.caller({certified:t});return r()};withdrawEth=async({address:t,fromSubaccount:r,...a})=>{let{withdraw_eth:c}=this.caller({certified:!0}),n=await c({recipient:t,from_subaccount:(0,h.toNullable)(r),...a});if("Err"in n)throw ne(n.Err);return n.Ok};withdrawErc20=async({address:t,ledgerCanisterId:r,fromCkEthSubaccount:a,fromCkErc20Subaccount:c,...n})=>{let{withdraw_erc20:l}=this.caller({certified:!0}),i=await l({recipient:t,ckerc20_ledger_id:r,from_cketh_subaccount:(0,h.toNullable)(a),from_ckerc20_subaccount:(0,h.toNullable)(c),...n});if("Err"in i)throw ie(i.Err);return i.Ok};eip1559TransactionPrice=({certified:t,...r})=>{let{eip_1559_transaction_price:a}=this.caller({certified:t});return a(de(r))};retrieveEthStatus=t=>{let{retrieve_eth_status:r}=this.caller({certified:!0});return r(t)};getMinterInfo=({certified:t})=>{let{get_minter_info:r}=this.caller({certified:t});return r()}};var j=require("@dfinity/utils");var le=({IDL:e})=>{let t=e.Record({canister_id:e.Principal,installed_wasm_hash:e.Text}),r=e.Record({token_symbol:e.Text,ledger:t,index:t,archives:e.Opt(e.Vec(e.Principal))}),a=e.Record({cycles_top_up_increment:e.Opt(e.Nat),cycles_for_ledger_creation:e.Opt(e.Nat),cycles_for_archive_creation:e.Opt(e.Nat),cycles_for_index_creation:e.Opt(e.Nat)}),c=e.Record({manage_ledger_suites:e.Opt(e.Vec(r)),cycles_management:e.Opt(a),archive_compressed_wasm_hash:e.Opt(e.Text),git_commit_hash:e.Opt(e.Text),ledger_compressed_wasm_hash:e.Opt(e.Text),index_compressed_wasm_hash:e.Opt(e.Text)}),n=e.Record({cycles_top_up_increment:e.Nat,cycles_for_ledger_creation:e.Nat,cycles_for_archive_creation:e.Nat,cycles_for_index_creation:e.Nat}),l=e.Record({cycles_management:e.Opt(n),more_controller_ids:e.Vec(e.Principal),minter_id:e.Opt(e.Principal)}),i=e.Record({chain_id:e.Nat,address:e.Text}),N=e.Record({decimals:e.Nat8,token_symbol:e.Text,transfer_fee:e.Nat,token_logo:e.Text,token_name:e.Text}),g=e.Record({contract:i,ledger_init_arg:N}),O=e.Variant({UpgradeArg:c,InitArg:l,AddErc20Arg:g}),x=e.Record({ledger:e.Opt(e.Principal),index:e.Opt(e.Principal),archives:e.Vec(e.Principal)}),T=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),b=e.Variant({controllers:e.Null,public:e.Null,allowed_viewers:e.Vec(e.Principal)}),o=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:b,wasm_memory_limit:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),s=e.Record({response_payload_bytes_total:e.Nat,num_instructions_total:e.Nat,num_calls_total:e.Nat,request_payload_bytes_total:e.Nat}),p=e.Record({status:T,memory_size:e.Nat,cycles:e.Nat,settings:o,query_stats:s,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),_=e.Variant({Created:e.Record({canister_id:e.Principal}),Installed:e.Record({canister_id:e.Principal,installed_wasm_hash:e.Text})}),k=e.Record({erc20_contract:i,ledger:e.Opt(_),index:e.Opt(_),archives:e.Vec(e.Principal),ckerc20_token_symbol:e.Text}),R=e.Record({token_symbol:e.Text,ledger:e.Opt(_),index:e.Opt(_),archives:e.Vec(e.Principal)}),u=e.Record({archive_compressed_wasm_hash:e.Text,ledger_compressed_wasm_hash:e.Text,index_compressed_wasm_hash:e.Text}),y=e.Record({cycles_management:n,managed_canisters:e.Vec(k),managed_pre_existing_ledger_suites:e.Opt(e.Vec(R)),more_controller_ids:e.Vec(e.Principal),ledger_suite_version:e.Opt(u),minter_id:e.Opt(e.Principal)});return e.Service({canister_ids:e.Func([i],[e.Opt(x)],[]),get_canister_status:e.Func([],[p],[]),get_orchestrator_info:e.Func([],[y],[])})};var pe=({IDL:e})=>{let t=e.Record({canister_id:e.Principal,installed_wasm_hash:e.Text}),r=e.Record({token_symbol:e.Text,ledger:t,index:t,archives:e.Opt(e.Vec(e.Principal))}),a=e.Record({cycles_top_up_increment:e.Opt(e.Nat),cycles_for_ledger_creation:e.Opt(e.Nat),cycles_for_archive_creation:e.Opt(e.Nat),cycles_for_index_creation:e.Opt(e.Nat)}),c=e.Record({manage_ledger_suites:e.Opt(e.Vec(r)),cycles_management:e.Opt(a),archive_compressed_wasm_hash:e.Opt(e.Text),git_commit_hash:e.Opt(e.Text),ledger_compressed_wasm_hash:e.Opt(e.Text),index_compressed_wasm_hash:e.Opt(e.Text)}),n=e.Record({cycles_top_up_increment:e.Nat,cycles_for_ledger_creation:e.Nat,cycles_for_archive_creation:e.Nat,cycles_for_index_creation:e.Nat}),l=e.Record({cycles_management:e.Opt(n),more_controller_ids:e.Vec(e.Principal),minter_id:e.Opt(e.Principal)}),i=e.Record({chain_id:e.Nat,address:e.Text}),N=e.Record({decimals:e.Nat8,token_symbol:e.Text,transfer_fee:e.Nat,token_logo:e.Text,token_name:e.Text}),g=e.Record({contract:i,ledger_init_arg:N}),O=e.Variant({UpgradeArg:c,InitArg:l,AddErc20Arg:g}),x=e.Record({ledger:e.Opt(e.Principal),index:e.Opt(e.Principal),archives:e.Vec(e.Principal)}),T=e.Variant({stopped:e.Null,stopping:e.Null,running:e.Null}),b=e.Variant({controllers:e.Null,public:e.Null,allowed_viewers:e.Vec(e.Principal)}),o=e.Record({freezing_threshold:e.Nat,controllers:e.Vec(e.Principal),reserved_cycles_limit:e.Nat,log_visibility:b,wasm_memory_limit:e.Nat,memory_allocation:e.Nat,compute_allocation:e.Nat}),s=e.Record({response_payload_bytes_total:e.Nat,num_instructions_total:e.Nat,num_calls_total:e.Nat,request_payload_bytes_total:e.Nat}),p=e.Record({status:T,memory_size:e.Nat,cycles:e.Nat,settings:o,query_stats:s,idle_cycles_burned_per_day:e.Nat,module_hash:e.Opt(e.Vec(e.Nat8)),reserved_cycles:e.Nat}),_=e.Variant({Created:e.Record({canister_id:e.Principal}),Installed:e.Record({canister_id:e.Principal,installed_wasm_hash:e.Text})}),k=e.Record({erc20_contract:i,ledger:e.Opt(_),index:e.Opt(_),archives:e.Vec(e.Principal),ckerc20_token_symbol:e.Text}),R=e.Record({token_symbol:e.Text,ledger:e.Opt(_),index:e.Opt(_),archives:e.Vec(e.Principal)}),u=e.Record({archive_compressed_wasm_hash:e.Text,ledger_compressed_wasm_hash:e.Text,index_compressed_wasm_hash:e.Text}),y=e.Record({cycles_management:n,managed_canisters:e.Vec(k),managed_pre_existing_ledger_suites:e.Opt(e.Vec(R)),more_controller_ids:e.Vec(e.Principal),ledger_suite_version:e.Opt(u),minter_id:e.Opt(e.Principal)});return e.Service({canister_ids:e.Func([i],[e.Opt(x)],["query"]),get_canister_status:e.Func([],[p],[]),get_orchestrator_info:e.Func([],[y],["query"])})};var G=class e extends j.Canister{static create(t){let{service:r,certifiedService:a,canisterId:c}=(0,j.createServices)({options:t,idlFactory:pe,certifiedIdlFactory:le});return new e(c,r,a)}getOrchestratorInfo=({certified:t}={})=>{let{get_orchestrator_info:r}=this.caller({certified:t});return r()}};var me=require("@dfinity/utils"),ke=e=>{let t=(0,me.decodeBase32)(e.toText().replace(/-/g,""));return Re(t.slice(4))},ue=({stringToAppend:e,bytes:t})=>(e+=(t>>4&15).toString(16),e+=(t&15).toString(16),e),Re=e=>{let t=e.length,r="0x";r=ue({stringToAppend:r,bytes:t});for(let a=0;a<e.length;a++)r=ue({stringToAppend:r,bytes:e[a]});for(let a=0;a<31-e.length;a++)r+="00";return r};0&&(module.exports={CkETHMinterCanister,CkETHOrchestratorCanister,DetailedError,LedgerAmountTooLowError,LedgerError,LedgerGenericError,LedgerInsufficientAllowanceError,LedgerInsufficientFundsError,LedgerTemporaryUnavailableError,LedgerWithdrawalError,MinterAmountTooLowError,MinterError,MinterGenericError,MinterInsufficientAllowanceError,MinterInsufficientFundsError,MinterRecipientAddressBlockedError,MinterTemporaryUnavailableError,MinterTokenNotSupported,createWithdrawErc20Error,createWithdrawEthError,encodePrincipalToEthAddress});
//# sourceMappingURL=index.cjs.js.map