@dfinity/sns
Version:
A library for interfacing with a Service Nervous System (SNS) project.
3 lines (2 loc) • 19.7 kB
JavaScript
import{Canister as Et,createServices as qt,fromDefinedNullable as S,fromNullable as y}from"@dfinity/utils";var Ft=({IDL:t})=>{let e=t.Record({dissolve_delay_interval_seconds:t.Nat64,count:t.Nat64}),s=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)}),i=t.Record({serialized_representation:t.Opt(t.Text)}),n=t.Record({coefficient_intervals:t.Vec(s),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(i)}),o=t.Record({iso_codes:t.Vec(t.Text)}),d=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(e),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(o),min_icp_e8s:t.Opt(t.Nat64),max_direct_participation_icp_e8s:t.Opt(t.Nat64)}),g=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)}),r=t.Record({code:t.Opt(t.Int32),description:t.Text}),F=t.Record({err:t.Opt(r),dapp_canister_id:t.Opt(t.Principal)}),v=t.Record({failed_updates:t.Vec(F)}),V=t.Variant({Ok:v,Err:r}),C=t.Record({possibility:t.Opt(V)}),a=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:r}),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:r}),j=t.Record({possibility:t.Opt(M)}),c=t.Record({set_dapp_controllers_call_result:t.Opt(C),create_sns_neuron_recipes_result:t.Opt(a),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(a),claim_neuron_result:t.Opt(a),sweep_sns_result:t.Opt(a)}),H=t.Record({auto_finalize_swap_response:t.Opt(c),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}),p=t.Record({icp:t.Opt(u),has_created_neuron_recipes:t.Opt(t.Bool)}),K=t.Record({buyer_state:t.Opt(p)}),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(d)}),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}),_=t.Record({ticket:t.Opt(l)}),et=t.Record({error_type:t.Opt(t.Int32)}),st=t.Variant({Ok:_,Err:et}),it=t.Record({result:t.Opt(st)}),m=t.Record({min_participant_icp_e8s:t.Nat64,neuron_basket_construction_parameters:t.Opt(e),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(c),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(d),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,p)),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(p),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:_,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([g],[b],[]),finalize_swap:t.Func([t.Record({})],[c],[]),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({})],[_],[]),refresh_buyer_tokens:t.Func([Pt],[bt],[]),reset_timers:t.Func([t.Record({})],[t.Record({})],[])})};var vt=({IDL:t})=>{let e=t.Record({dissolve_delay_interval_seconds:t.Nat64,count:t.Nat64}),s=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)}),i=t.Record({serialized_representation:t.Opt(t.Text)}),n=t.Record({coefficient_intervals:t.Vec(s),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(i)}),o=t.Record({iso_codes:t.Vec(t.Text)}),d=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(e),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(o),min_icp_e8s:t.Opt(t.Nat64),max_direct_participation_icp_e8s:t.Opt(t.Nat64)}),g=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)}),r=t.Record({code:t.Opt(t.Int32),description:t.Text}),F=t.Record({err:t.Opt(r),dapp_canister_id:t.Opt(t.Principal)}),v=t.Record({failed_updates:t.Vec(F)}),V=t.Variant({Ok:v,Err:r}),C=t.Record({possibility:t.Opt(V)}),a=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:r}),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:r}),j=t.Record({possibility:t.Opt(M)}),c=t.Record({set_dapp_controllers_call_result:t.Opt(C),create_sns_neuron_recipes_result:t.Opt(a),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(a),claim_neuron_result:t.Opt(a),sweep_sns_result:t.Opt(a)}),H=t.Record({auto_finalize_swap_response:t.Opt(c),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}),p=t.Record({icp:t.Opt(u),has_created_neuron_recipes:t.Opt(t.Bool)}),K=t.Record({buyer_state:t.Opt(p)}),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(d)}),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}),_=t.Record({ticket:t.Opt(l)}),et=t.Record({error_type:t.Opt(t.Int32)}),st=t.Variant({Ok:_,Err:et}),it=t.Record({result:t.Opt(st)}),m=t.Record({min_participant_icp_e8s:t.Nat64,neuron_basket_construction_parameters:t.Opt(e),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(c),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(d),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,p)),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(p),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:_,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([g],[b],[]),finalize_swap:t.Func([t.Record({})],[c],[]),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({})],[_],[]),refresh_buyer_tokens:t.Func([Pt],[bt],[]),reset_timers:t.Func([t.Record({})],[t.Record({})],[])})};var Vt=({subaccount:t,amount_icp_e8s:e})=>({subaccount:t===void 0?[]:[t],amount_icp_e8s:e});var k=class extends Error{constructor(s){super();this.methodName=s}};var T=class extends Error{errorType;invalidUserAmount;existingTicket;constructor({errorType:e,invalidUserAmount:s,existingTicket:i}){super(),this.errorType=e,this.invalidUserAmount=s,this.existingTicket=i}},x=class extends Error{constructor(s){super();this.errorType=s}};import{nonNullish as zt}from"@dfinity/utils";var Ct=t=>{if(typeof t=="object"&&zt(t)&&"message"in t){let e=t.message;return e.includes("has no update method")||e.includes("has no query method")}return!1};var Bt=class t extends Et{static create(e){let{service:s,certifiedService:i,canisterId:n}=qt({options:e,idlFactory:vt,certifiedIdlFactory:Ft});return new t(n,s,i)}state=e=>this.caller(e).get_state({});notifyPaymentFailure=async()=>{let{ticket:e}=await this.caller({certified:!0}).notify_payment_failure({});return y(e)};notifyParticipation=async e=>await this.caller({certified:!0}).refresh_buyer_tokens(e);getUserCommitment=async e=>{let{buyer_state:s}=await this.caller({certified:e.certified}).get_buyer_state({principal_id:e.principal_id});return y(s)};getDerivedState=({certified:e})=>this.caller({certified:e}).get_derived_state({});getSaleParameters=({certified:e})=>this.caller({certified:e}).get_sale_parameters({});getOpenTicket=async e=>{let{result:s}=await this.caller({certified:e.certified}).get_open_ticket({}),i=S(s);if("Ok"in i)return y(i.Ok.ticket);let n=S(i?.Err?.error_type);throw new x(n)};newSaleTicket=async e=>{let s=Vt(e),{result:i}=await this.caller({certified:!0}).new_sale_ticket(s),n=S(i);if("Ok"in n)return S(n.Ok.ticket);let o=n.Err;throw new T({errorType:o.error_type,invalidUserAmount:y(o.invalid_user_amount??[]),existingTicket:y(o.existing_ticket??[])})};getLifecycle=e=>this.caller(e).get_lifecycle({});getFinalizationStatus=async e=>{try{return await this.caller(e).get_auto_finalization_status({})}catch(s){throw Ct(s)?new k("getFinalizationStatus"):s}}};export{k as a,T as b,x as c,Bt as d};
//# sourceMappingURL=chunk-IMCH2CXJ.js.map