@dfinity/sns
Version:
A library for interfacing with a Service Nervous System (SNS) project.
3 lines (2 loc) • 19.8 kB
JavaScript
import{Canister as Et,createServices as qt,fromDefinedNullable as g,fromNullable as y}from"@dfinity/utils";var Ft=({IDL:t})=>{let i=t.Record({dissolve_delay_interval_seconds:t.Nat64,count:t.Nat64}),e=t.Record({slope_numerator:t.Opt(t.Nat64),intercept_icp_e8s:t.Opt(t.Nat64),from_direct_participation_icp_e8s:t.Opt(t.Nat64),slope_denominator:t.Opt(t.Nat64),to_direct_participation_icp_e8s:t.Opt(t.Nat64)}),s=t.Record({serialized_representation:t.Opt(t.Text)}),n=t.Record({coefficient_intervals:t.Vec(e),max_neurons_fund_participation_icp_e8s:t.Opt(t.Nat64),min_direct_participation_threshold_icp_e8s:t.Opt(t.Nat64),ideal_matched_participation_function:t.Opt(s)}),r=t.Record({iso_codes:t.Vec(t.Text)}),a=t.Record({nns_proposal_id:t.Opt(t.Nat64),sns_root_canister_id:t.Text,neurons_fund_participation:t.Opt(t.Bool),min_participant_icp_e8s:t.Opt(t.Nat64),neuron_basket_construction_parameters:t.Opt(i),fallback_controller_principal_ids:t.Vec(t.Text),max_icp_e8s:t.Opt(t.Nat64),neuron_minimum_stake_e8s:t.Opt(t.Nat64),confirmation_text:t.Opt(t.Text),swap_start_timestamp_seconds:t.Opt(t.Nat64),swap_due_timestamp_seconds:t.Opt(t.Nat64),min_participants:t.Opt(t.Nat32),sns_token_e8s:t.Opt(t.Nat64),nns_governance_canister_id:t.Text,transaction_fee_e8s:t.Opt(t.Nat64),icp_ledger_canister_id:t.Text,sns_ledger_canister_id:t.Text,neurons_fund_participation_constraints:t.Opt(n),should_auto_finalize:t.Opt(t.Bool),max_participant_icp_e8s:t.Opt(t.Nat64),sns_governance_canister_id:t.Text,min_direct_participation_icp_e8s:t.Opt(t.Nat64),restricted_countries:t.Opt(r),min_icp_e8s:t.Opt(t.Nat64),max_direct_participation_icp_e8s:t.Opt(t.Nat64)}),k=t.Record({source_principal_id:t.Opt(t.Principal)}),w=t.Record({block_height:t.Opt(t.Nat64)}),h=t.Record({description:t.Opt(t.Text),error_type:t.Opt(t.Int32)}),P=t.Variant({Ok:w,Err:h}),b=t.Record({result:t.Opt(P)}),o=t.Record({code:t.Opt(t.Int32),description:t.Text}),F=t.Record({err:t.Opt(o),dapp_canister_id:t.Opt(t.Principal)}),v=t.Record({failed_updates:t.Vec(F)}),V=t.Variant({Ok:v,Err:o}),C=t.Record({possibility:t.Opt(V)}),c=t.Record({failure:t.Nat32,skipped:t.Nat32,invalid:t.Nat32,success:t.Nat32,global_failures:t.Nat32}),B=t.Record({error_message:t.Text,error_type:t.Int32}),z=t.Record({governance_error:t.Opt(B)}),E=t.Variant({Ok:z,Err:o}),q=t.Record({possibility:t.Opt(E)}),G=t.Record({neurons_fund_participation_icp_e8s:t.Opt(t.Nat64),neurons_fund_neurons_count:t.Opt(t.Nat64)}),A=t.Record({message:t.Opt(t.Text)}),U=t.Variant({Ok:G,Err:A}),Q=t.Record({possibility:t.Opt(U)}),M=t.Variant({Ok:t.Record({}),Err:o}),j=t.Record({possibility:t.Opt(M)}),p=t.Record({set_dapp_controllers_call_result:t.Opt(C),create_sns_neuron_recipes_result:t.Opt(c),settle_community_fund_participation_result:t.Opt(q),error_message:t.Opt(t.Text),settle_neurons_fund_participation_result:t.Opt(Q),set_mode_call_result:t.Opt(j),sweep_icp_result:t.Opt(c),claim_neuron_result:t.Opt(c),sweep_sns_result:t.Opt(c)}),H=t.Record({auto_finalize_swap_response:t.Opt(p),has_auto_finalize_been_attempted:t.Opt(t.Bool),is_auto_finalize_enabled:t.Opt(t.Bool)}),J=t.Record({principal_id:t.Opt(t.Principal)}),u=t.Record({transfer_fee_paid_e8s:t.Opt(t.Nat64),transfer_start_timestamp_seconds:t.Nat64,amount_e8s:t.Nat64,amount_transferred_e8s:t.Opt(t.Nat64),transfer_success_timestamp_seconds:t.Nat64}),_=t.Record({icp:t.Opt(u),has_created_neuron_recipes:t.Opt(t.Bool)}),K=t.Record({buyer_state:t.Opt(_)}),W=t.Record({buyers_total:t.Nat64}),X=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),Y=t.Record({freezing_threshold:t.Nat,wasm_memory_threshold:t.Opt(t.Nat),controllers:t.Vec(t.Principal),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Nat,compute_allocation:t.Nat}),Z=t.Record({response_payload_bytes_total:t.Opt(t.Nat),num_instructions_total:t.Opt(t.Nat),num_calls_total:t.Opt(t.Nat),request_payload_bytes_total:t.Opt(t.Nat)}),$=t.Record({status:X,memory_size:t.Nat,cycles:t.Nat,settings:Y,query_stats:t.Opt(Z),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),I=t.Record({sns_tokens_per_icp:t.Opt(t.Float64),buyer_total_icp_e8s:t.Opt(t.Nat64),cf_participant_count:t.Opt(t.Nat64),neurons_fund_participation_icp_e8s:t.Opt(t.Nat64),direct_participation_icp_e8s:t.Opt(t.Nat64),direct_participant_count:t.Opt(t.Nat64),cf_neuron_count:t.Opt(t.Nat64)}),D=t.Record({init:t.Opt(a)}),L=t.Record({decentralization_sale_open_timestamp_seconds:t.Opt(t.Nat64),lifecycle:t.Opt(t.Int32),decentralization_swap_termination_timestamp_seconds:t.Opt(t.Nat64)}),tt=t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))}),l=t.Record({creation_time:t.Nat64,ticket_id:t.Nat64,account:t.Opt(tt),amount_icp_e8s:t.Nat64}),d=t.Record({ticket:t.Opt(l)}),et=t.Record({error_type:t.Opt(t.Int32)}),st=t.Variant({Ok:d,Err:et}),it=t.Record({result:t.Opt(st)}),m=t.Record({min_participant_icp_e8s:t.Nat64,neuron_basket_construction_parameters:t.Opt(i),max_icp_e8s:t.Nat64,swap_due_timestamp_seconds:t.Nat64,min_participants:t.Nat32,sns_token_e8s:t.Nat64,sale_delay_seconds:t.Opt(t.Nat64),max_participant_icp_e8s:t.Nat64,min_direct_participation_icp_e8s:t.Opt(t.Nat64),min_icp_e8s:t.Nat64,max_direct_participation_icp_e8s:t.Opt(t.Nat64)}),nt=t.Record({params:t.Opt(m)}),rt=t.Record({id:t.Vec(t.Nat8)}),at=t.Record({dissolve_delay_seconds:t.Nat64,memo:t.Nat64,followees:t.Vec(rt)}),O=t.Record({principals:t.Vec(t.Principal)}),ot=t.Record({controller:t.Opt(t.Principal),hotkey_principal:t.Text,hotkeys:t.Opt(O),nns_neuron_id:t.Nat64}),ct=t.Record({buyer_principal:t.Text}),pt=t.Variant({CommunityFund:ot,Direct:ct}),N=t.Record({sns:t.Opt(u),claimed_status:t.Opt(t.Int32),neuron_attributes:t.Opt(at),investor:t.Opt(pt)}),R=t.Record({last_spawned_timestamp_seconds:t.Opt(t.Nat64),last_reset_timestamp_seconds:t.Opt(t.Nat64),requires_periodic_tasks:t.Opt(t.Bool)}),_t=t.Record({has_created_neuron_recipes:t.Opt(t.Bool),hotkeys:t.Opt(O),nns_neuron_id:t.Nat64,amount_icp_e8s:t.Nat64}),f=t.Record({controller:t.Opt(t.Principal),hotkey_principal:t.Text,cf_neurons:t.Vec(_t)}),dt=t.Record({auto_finalize_swap_response:t.Opt(p),neuron_recipes:t.Vec(N),next_ticket_id:t.Opt(t.Nat64),decentralization_sale_open_timestamp_seconds:t.Opt(t.Nat64),finalize_swap_in_progress:t.Opt(t.Bool),timers:t.Opt(R),cf_participants:t.Vec(f),init:t.Opt(a),already_tried_to_auto_finalize:t.Opt(t.Bool),neurons_fund_participation_icp_e8s:t.Opt(t.Nat64),purge_old_tickets_last_completion_timestamp_nanoseconds:t.Opt(t.Nat64),direct_participation_icp_e8s:t.Opt(t.Nat64),lifecycle:t.Int32,purge_old_tickets_next_principal:t.Opt(t.Vec(t.Nat8)),decentralization_swap_termination_timestamp_seconds:t.Opt(t.Nat64),buyers:t.Vec(t.Tuple(t.Text,_)),params:t.Opt(m),open_sns_token_swap_proposal_id:t.Opt(t.Nat64)}),ut=t.Record({sns_tokens_per_icp:t.Float32,buyer_total_icp_e8s:t.Nat64,cf_participant_count:t.Opt(t.Nat64),neurons_fund_participation_icp_e8s:t.Opt(t.Nat64),direct_participation_icp_e8s:t.Opt(t.Nat64),direct_participant_count:t.Opt(t.Nat64),cf_neuron_count:t.Opt(t.Nat64)}),lt=t.Record({swap:t.Opt(dt),derived:t.Opt(ut)}),mt=t.Record({timers:t.Opt(R)}),Ot=t.Record({offset:t.Opt(t.Nat64),limit:t.Opt(t.Nat32)}),Nt=t.Record({cf_participants:t.Vec(f)}),Rt=t.Record({offset:t.Opt(t.Nat32),limit:t.Opt(t.Nat32)}),ft=t.Record({participation:t.Opt(_),participant_id:t.Opt(t.Principal)}),yt=t.Record({participants:t.Vec(ft)}),kt=t.Record({offset:t.Opt(t.Nat64),limit:t.Opt(t.Nat32)}),Tt=t.Record({sns_neuron_recipes:t.Vec(N)}),xt=t.Record({subaccount:t.Opt(t.Vec(t.Nat8)),amount_icp_e8s:t.Nat64}),St=t.Record({min_amount_icp_e8s_included:t.Nat64,max_amount_icp_e8s_included:t.Nat64}),gt=t.Record({invalid_user_amount:t.Opt(St),existing_ticket:t.Opt(l),error_type:t.Int32}),wt=t.Variant({Ok:d,Err:gt}),ht=t.Record({result:t.Opt(wt)}),Pt=t.Record({confirmation_text:t.Opt(t.Text),buyer:t.Text}),bt=t.Record({icp_accepted_participation_e8s:t.Nat64,icp_ledger_account_balance_e8s:t.Nat64});return t.Service({error_refund_icp:t.Func([k],[b],[]),finalize_swap:t.Func([t.Record({})],[p],[]),get_auto_finalization_status:t.Func([t.Record({})],[H],[]),get_buyer_state:t.Func([J],[K],[]),get_buyers_total:t.Func([t.Record({})],[W],[]),get_canister_status:t.Func([t.Record({})],[$],[]),get_derived_state:t.Func([t.Record({})],[I],[]),get_init:t.Func([t.Record({})],[D],[]),get_lifecycle:t.Func([t.Record({})],[L],[]),get_open_ticket:t.Func([t.Record({})],[it],[]),get_sale_parameters:t.Func([t.Record({})],[nt],[]),get_state:t.Func([t.Record({})],[lt],[]),get_timers:t.Func([t.Record({})],[mt],[]),list_community_fund_participants:t.Func([Ot],[Nt],[]),list_direct_participants:t.Func([Rt],[yt],[]),list_sns_neuron_recipes:t.Func([kt],[Tt],[]),new_sale_ticket:t.Func([xt],[ht],[]),notify_payment_failure:t.Func([t.Record({})],[d],[]),refresh_buyer_tokens:t.Func([Pt],[bt],[]),reset_timers:t.Func([t.Record({})],[t.Record({})],[])})};var vt=({IDL:t})=>{let i=t.Record({dissolve_delay_interval_seconds:t.Nat64,count:t.Nat64}),e=t.Record({slope_numerator:t.Opt(t.Nat64),intercept_icp_e8s:t.Opt(t.Nat64),from_direct_participation_icp_e8s:t.Opt(t.Nat64),slope_denominator:t.Opt(t.Nat64),to_direct_participation_icp_e8s:t.Opt(t.Nat64)}),s=t.Record({serialized_representation:t.Opt(t.Text)}),n=t.Record({coefficient_intervals:t.Vec(e),max_neurons_fund_participation_icp_e8s:t.Opt(t.Nat64),min_direct_participation_threshold_icp_e8s:t.Opt(t.Nat64),ideal_matched_participation_function:t.Opt(s)}),r=t.Record({iso_codes:t.Vec(t.Text)}),a=t.Record({nns_proposal_id:t.Opt(t.Nat64),sns_root_canister_id:t.Text,neurons_fund_participation:t.Opt(t.Bool),min_participant_icp_e8s:t.Opt(t.Nat64),neuron_basket_construction_parameters:t.Opt(i),fallback_controller_principal_ids:t.Vec(t.Text),max_icp_e8s:t.Opt(t.Nat64),neuron_minimum_stake_e8s:t.Opt(t.Nat64),confirmation_text:t.Opt(t.Text),swap_start_timestamp_seconds:t.Opt(t.Nat64),swap_due_timestamp_seconds:t.Opt(t.Nat64),min_participants:t.Opt(t.Nat32),sns_token_e8s:t.Opt(t.Nat64),nns_governance_canister_id:t.Text,transaction_fee_e8s:t.Opt(t.Nat64),icp_ledger_canister_id:t.Text,sns_ledger_canister_id:t.Text,neurons_fund_participation_constraints:t.Opt(n),should_auto_finalize:t.Opt(t.Bool),max_participant_icp_e8s:t.Opt(t.Nat64),sns_governance_canister_id:t.Text,min_direct_participation_icp_e8s:t.Opt(t.Nat64),restricted_countries:t.Opt(r),min_icp_e8s:t.Opt(t.Nat64),max_direct_participation_icp_e8s:t.Opt(t.Nat64)}),k=t.Record({source_principal_id:t.Opt(t.Principal)}),w=t.Record({block_height:t.Opt(t.Nat64)}),h=t.Record({description:t.Opt(t.Text),error_type:t.Opt(t.Int32)}),P=t.Variant({Ok:w,Err:h}),b=t.Record({result:t.Opt(P)}),o=t.Record({code:t.Opt(t.Int32),description:t.Text}),F=t.Record({err:t.Opt(o),dapp_canister_id:t.Opt(t.Principal)}),v=t.Record({failed_updates:t.Vec(F)}),V=t.Variant({Ok:v,Err:o}),C=t.Record({possibility:t.Opt(V)}),c=t.Record({failure:t.Nat32,skipped:t.Nat32,invalid:t.Nat32,success:t.Nat32,global_failures:t.Nat32}),B=t.Record({error_message:t.Text,error_type:t.Int32}),z=t.Record({governance_error:t.Opt(B)}),E=t.Variant({Ok:z,Err:o}),q=t.Record({possibility:t.Opt(E)}),G=t.Record({neurons_fund_participation_icp_e8s:t.Opt(t.Nat64),neurons_fund_neurons_count:t.Opt(t.Nat64)}),A=t.Record({message:t.Opt(t.Text)}),U=t.Variant({Ok:G,Err:A}),Q=t.Record({possibility:t.Opt(U)}),M=t.Variant({Ok:t.Record({}),Err:o}),j=t.Record({possibility:t.Opt(M)}),p=t.Record({set_dapp_controllers_call_result:t.Opt(C),create_sns_neuron_recipes_result:t.Opt(c),settle_community_fund_participation_result:t.Opt(q),error_message:t.Opt(t.Text),settle_neurons_fund_participation_result:t.Opt(Q),set_mode_call_result:t.Opt(j),sweep_icp_result:t.Opt(c),claim_neuron_result:t.Opt(c),sweep_sns_result:t.Opt(c)}),H=t.Record({auto_finalize_swap_response:t.Opt(p),has_auto_finalize_been_attempted:t.Opt(t.Bool),is_auto_finalize_enabled:t.Opt(t.Bool)}),J=t.Record({principal_id:t.Opt(t.Principal)}),u=t.Record({transfer_fee_paid_e8s:t.Opt(t.Nat64),transfer_start_timestamp_seconds:t.Nat64,amount_e8s:t.Nat64,amount_transferred_e8s:t.Opt(t.Nat64),transfer_success_timestamp_seconds:t.Nat64}),_=t.Record({icp:t.Opt(u),has_created_neuron_recipes:t.Opt(t.Bool)}),K=t.Record({buyer_state:t.Opt(_)}),W=t.Record({buyers_total:t.Nat64}),X=t.Variant({stopped:t.Null,stopping:t.Null,running:t.Null}),Y=t.Record({freezing_threshold:t.Nat,wasm_memory_threshold:t.Opt(t.Nat),controllers:t.Vec(t.Principal),wasm_memory_limit:t.Opt(t.Nat),memory_allocation:t.Nat,compute_allocation:t.Nat}),Z=t.Record({response_payload_bytes_total:t.Opt(t.Nat),num_instructions_total:t.Opt(t.Nat),num_calls_total:t.Opt(t.Nat),request_payload_bytes_total:t.Opt(t.Nat)}),$=t.Record({status:X,memory_size:t.Nat,cycles:t.Nat,settings:Y,query_stats:t.Opt(Z),idle_cycles_burned_per_day:t.Nat,module_hash:t.Opt(t.Vec(t.Nat8))}),I=t.Record({sns_tokens_per_icp:t.Opt(t.Float64),buyer_total_icp_e8s:t.Opt(t.Nat64),cf_participant_count:t.Opt(t.Nat64),neurons_fund_participation_icp_e8s:t.Opt(t.Nat64),direct_participation_icp_e8s:t.Opt(t.Nat64),direct_participant_count:t.Opt(t.Nat64),cf_neuron_count:t.Opt(t.Nat64)}),D=t.Record({init:t.Opt(a)}),L=t.Record({decentralization_sale_open_timestamp_seconds:t.Opt(t.Nat64),lifecycle:t.Opt(t.Int32),decentralization_swap_termination_timestamp_seconds:t.Opt(t.Nat64)}),tt=t.Record({owner:t.Opt(t.Principal),subaccount:t.Opt(t.Vec(t.Nat8))}),l=t.Record({creation_time:t.Nat64,ticket_id:t.Nat64,account:t.Opt(tt),amount_icp_e8s:t.Nat64}),d=t.Record({ticket:t.Opt(l)}),et=t.Record({error_type:t.Opt(t.Int32)}),st=t.Variant({Ok:d,Err:et}),it=t.Record({result:t.Opt(st)}),m=t.Record({min_participant_icp_e8s:t.Nat64,neuron_basket_construction_parameters:t.Opt(i),max_icp_e8s:t.Nat64,swap_due_timestamp_seconds:t.Nat64,min_participants:t.Nat32,sns_token_e8s:t.Nat64,sale_delay_seconds:t.Opt(t.Nat64),max_participant_icp_e8s:t.Nat64,min_direct_participation_icp_e8s:t.Opt(t.Nat64),min_icp_e8s:t.Nat64,max_direct_participation_icp_e8s:t.Opt(t.Nat64)}),nt=t.Record({params:t.Opt(m)}),rt=t.Record({id:t.Vec(t.Nat8)}),at=t.Record({dissolve_delay_seconds:t.Nat64,memo:t.Nat64,followees:t.Vec(rt)}),O=t.Record({principals:t.Vec(t.Principal)}),ot=t.Record({controller:t.Opt(t.Principal),hotkey_principal:t.Text,hotkeys:t.Opt(O),nns_neuron_id:t.Nat64}),ct=t.Record({buyer_principal:t.Text}),pt=t.Variant({CommunityFund:ot,Direct:ct}),N=t.Record({sns:t.Opt(u),claimed_status:t.Opt(t.Int32),neuron_attributes:t.Opt(at),investor:t.Opt(pt)}),R=t.Record({last_spawned_timestamp_seconds:t.Opt(t.Nat64),last_reset_timestamp_seconds:t.Opt(t.Nat64),requires_periodic_tasks:t.Opt(t.Bool)}),_t=t.Record({has_created_neuron_recipes:t.Opt(t.Bool),hotkeys:t.Opt(O),nns_neuron_id:t.Nat64,amount_icp_e8s:t.Nat64}),f=t.Record({controller:t.Opt(t.Principal),hotkey_principal:t.Text,cf_neurons:t.Vec(_t)}),dt=t.Record({auto_finalize_swap_response:t.Opt(p),neuron_recipes:t.Vec(N),next_ticket_id:t.Opt(t.Nat64),decentralization_sale_open_timestamp_seconds:t.Opt(t.Nat64),finalize_swap_in_progress:t.Opt(t.Bool),timers:t.Opt(R),cf_participants:t.Vec(f),init:t.Opt(a),already_tried_to_auto_finalize:t.Opt(t.Bool),neurons_fund_participation_icp_e8s:t.Opt(t.Nat64),purge_old_tickets_last_completion_timestamp_nanoseconds:t.Opt(t.Nat64),direct_participation_icp_e8s:t.Opt(t.Nat64),lifecycle:t.Int32,purge_old_tickets_next_principal:t.Opt(t.Vec(t.Nat8)),decentralization_swap_termination_timestamp_seconds:t.Opt(t.Nat64),buyers:t.Vec(t.Tuple(t.Text,_)),params:t.Opt(m),open_sns_token_swap_proposal_id:t.Opt(t.Nat64)}),ut=t.Record({sns_tokens_per_icp:t.Float32,buyer_total_icp_e8s:t.Nat64,cf_participant_count:t.Opt(t.Nat64),neurons_fund_participation_icp_e8s:t.Opt(t.Nat64),direct_participation_icp_e8s:t.Opt(t.Nat64),direct_participant_count:t.Opt(t.Nat64),cf_neuron_count:t.Opt(t.Nat64)}),lt=t.Record({swap:t.Opt(dt),derived:t.Opt(ut)}),mt=t.Record({timers:t.Opt(R)}),Ot=t.Record({offset:t.Opt(t.Nat64),limit:t.Opt(t.Nat32)}),Nt=t.Record({cf_participants:t.Vec(f)}),Rt=t.Record({offset:t.Opt(t.Nat32),limit:t.Opt(t.Nat32)}),ft=t.Record({participation:t.Opt(_),participant_id:t.Opt(t.Principal)}),yt=t.Record({participants:t.Vec(ft)}),kt=t.Record({offset:t.Opt(t.Nat64),limit:t.Opt(t.Nat32)}),Tt=t.Record({sns_neuron_recipes:t.Vec(N)}),xt=t.Record({subaccount:t.Opt(t.Vec(t.Nat8)),amount_icp_e8s:t.Nat64}),St=t.Record({min_amount_icp_e8s_included:t.Nat64,max_amount_icp_e8s_included:t.Nat64}),gt=t.Record({invalid_user_amount:t.Opt(St),existing_ticket:t.Opt(l),error_type:t.Int32}),wt=t.Variant({Ok:d,Err:gt}),ht=t.Record({result:t.Opt(wt)}),Pt=t.Record({confirmation_text:t.Opt(t.Text),buyer:t.Text}),bt=t.Record({icp_accepted_participation_e8s:t.Nat64,icp_ledger_account_balance_e8s:t.Nat64});return t.Service({error_refund_icp:t.Func([k],[b],[]),finalize_swap:t.Func([t.Record({})],[p],[]),get_auto_finalization_status:t.Func([t.Record({})],[H],["query"]),get_buyer_state:t.Func([J],[K],["query"]),get_buyers_total:t.Func([t.Record({})],[W],[]),get_canister_status:t.Func([t.Record({})],[$],[]),get_derived_state:t.Func([t.Record({})],[I],["query"]),get_init:t.Func([t.Record({})],[D],["query"]),get_lifecycle:t.Func([t.Record({})],[L],["query"]),get_open_ticket:t.Func([t.Record({})],[it],["query"]),get_sale_parameters:t.Func([t.Record({})],[nt],["query"]),get_state:t.Func([t.Record({})],[lt],["query"]),get_timers:t.Func([t.Record({})],[mt],["query"]),list_community_fund_participants:t.Func([Ot],[Nt],["query"]),list_direct_participants:t.Func([Rt],[yt],["query"]),list_sns_neuron_recipes:t.Func([kt],[Tt],["query"]),new_sale_ticket:t.Func([xt],[ht],[]),notify_payment_failure:t.Func([t.Record({})],[d],[]),refresh_buyer_tokens:t.Func([Pt],[bt],[]),reset_timers:t.Func([t.Record({})],[t.Record({})],[])})};var Vt=({subaccount:t,amount_icp_e8s:i})=>({subaccount:t===void 0?[]:[t],amount_icp_e8s:i});var T=class extends Error{constructor(e){super();this.methodName=e}};var x=class extends Error{constructor({errorType:i,invalidUserAmount:e,existingTicket:s}){super(),this.errorType=i,this.invalidUserAmount=e,this.existingTicket=s}},S=class extends Error{constructor(e){super();this.errorType=e}};import{nonNullish as zt}from"@dfinity/utils";var Ct=t=>{if(typeof t=="object"&&zt(t)&&"message"in t){let i=t.message;return i.includes("has no update method")||i.includes("has no query method")}return!1};var Bt=class t extends Et{constructor(){super(...arguments);this.state=e=>this.caller(e).get_state({});this.notifyPaymentFailure=async()=>{let{ticket:e}=await this.caller({certified:!0}).notify_payment_failure({});return y(e)};this.notifyParticipation=async e=>await this.caller({certified:!0}).refresh_buyer_tokens(e);this.getUserCommitment=async e=>{let{buyer_state:s}=await this.caller({certified:e.certified}).get_buyer_state({principal_id:e.principal_id});return y(s)};this.getDerivedState=async({certified:e})=>this.caller({certified:e}).get_derived_state({});this.getSaleParameters=async({certified:e})=>this.caller({certified:e}).get_sale_parameters({});this.getOpenTicket=async e=>{let{result:s}=await this.caller({certified:e.certified}).get_open_ticket({}),n=g(s);if("Ok"in n)return y(n.Ok.ticket);let r=g(n?.Err?.error_type);throw new S(r)};this.newSaleTicket=async e=>{let s=Vt(e),{result:n}=await this.caller({certified:!0}).new_sale_ticket(s),r=g(n);if("Ok"in r)return g(r.Ok.ticket);let a=r.Err;throw new x({errorType:a.error_type,invalidUserAmount:y(a.invalid_user_amount??[]),existingTicket:y(a.existing_ticket??[])})};this.getLifecycle=async e=>this.caller(e).get_lifecycle({});this.getFinalizationStatus=async e=>{try{return await this.caller(e).get_auto_finalization_status({})}catch(s){throw Ct(s)?new T("getFinalizationStatus"):s}}}static create(e){let{service:s,certifiedService:n,canisterId:r}=qt({options:e,idlFactory:vt,certifiedIdlFactory:Ft});return new t(r,s,n)}};export{T as a,x as b,S as c,Bt as d};
//# sourceMappingURL=chunk-7RSE53BN.js.map