diff --git a/Makefile b/Makefile index f5ce2c6..ca19f4d 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ gen: gen-ic: go run ic/testdata/gen.go + go run ic/sns/testdata/gen.go fmt: go mod tidy diff --git a/gen/templates/agent.gotmpl b/gen/templates/agent.gotmpl index c3c81d7..e26e54b 100644 --- a/gen/templates/agent.gotmpl +++ b/gen/templates/agent.gotmpl @@ -13,13 +13,13 @@ import ( type {{ .Name }} {{ if .Eq }}= {{end}}{{ .Type }} {{- end }} -// Agent is a client for the "{{ .CanisterName }}" canister. +// {{ .AgentName }}Agent is a client for the "{{ .CanisterName }}" canister. type {{ .AgentName }}Agent struct { a *agent.Agent canisterId principal.Principal } -// NewAgent creates a new agent for the "{{ .CanisterName }}" canister. +// New{{ .AgentName }}Agent creates a new agent for the "{{ .CanisterName }}" canister. func New{{ .AgentName }}Agent(canisterId principal.Principal, config agent.Config) (*{{ .AgentName }}Agent, error) { a, err := agent.New(config) if err != nil { diff --git a/ic/sns/agent.go b/ic/sns/agent.go new file mode 100755 index 0000000..5520ad4 --- /dev/null +++ b/ic/sns/agent.go @@ -0,0 +1,558 @@ +// Package sns provides a client for the "sns" canister. +// Do NOT edit this file. It was automatically generated by https://github.com/aviate-labs/agent-go. +package sns + +import ( + "github.com/aviate-labs/agent-go" + "github.com/aviate-labs/agent-go/candid/idl" + "github.com/aviate-labs/agent-go/principal" +) + +type AddWasmRequest struct { + Hash []byte `ic:"hash" json:"hash"` + Wasm *SnsWasm `ic:"wasm,omitempty" json:"wasm,omitempty"` +} + +type AddWasmResponse struct { + Result *Result `ic:"result,omitempty" json:"result,omitempty"` +} + +// Agent is a client for the "sns" canister. +type Agent struct { + a *agent.Agent + canisterId principal.Principal +} + +// NewAgent creates a new agent for the "sns" canister. +func NewAgent(canisterId principal.Principal, config agent.Config) (*Agent, error) { + a, err := agent.New(config) + if err != nil { + return nil, err + } + return &Agent{ + a: a, + canisterId: canisterId, + }, nil +} + +// AddWasm calls the "add_wasm" method on the "sns" canister. +func (a Agent) AddWasm(arg0 AddWasmRequest) (*AddWasmResponse, error) { + var r0 AddWasmResponse + if err := a.a.Call( + a.canisterId, + "add_wasm", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// DeployNewSns calls the "deploy_new_sns" method on the "sns" canister. +func (a Agent) DeployNewSns(arg0 DeployNewSnsRequest) (*DeployNewSnsResponse, error) { + var r0 DeployNewSnsResponse + if err := a.a.Call( + a.canisterId, + "deploy_new_sns", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetAllowedPrincipals calls the "get_allowed_principals" method on the "sns" canister. +func (a Agent) GetAllowedPrincipals(arg0 struct { +}) (*GetAllowedPrincipalsResponse, error) { + var r0 GetAllowedPrincipalsResponse + if err := a.a.Query( + a.canisterId, + "get_allowed_principals", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetDeployedSnsByProposalId calls the "get_deployed_sns_by_proposal_id" method on the "sns" canister. +func (a Agent) GetDeployedSnsByProposalId(arg0 GetDeployedSnsByProposalIdRequest) (*GetDeployedSnsByProposalIdResponse, error) { + var r0 GetDeployedSnsByProposalIdResponse + if err := a.a.Query( + a.canisterId, + "get_deployed_sns_by_proposal_id", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetLatestSnsVersionPretty calls the "get_latest_sns_version_pretty" method on the "sns" canister. +func (a Agent) GetLatestSnsVersionPretty(arg0 idl.Null) (*[]struct { + Field0 string `ic:"0" json:"0"` + Field1 string `ic:"1" json:"1"` +}, error) { + var r0 []struct { + Field0 string `ic:"0" json:"0"` + Field1 string `ic:"1" json:"1"` + } + if err := a.a.Query( + a.canisterId, + "get_latest_sns_version_pretty", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetNextSnsVersion calls the "get_next_sns_version" method on the "sns" canister. +func (a Agent) GetNextSnsVersion(arg0 GetNextSnsVersionRequest) (*GetNextSnsVersionResponse, error) { + var r0 GetNextSnsVersionResponse + if err := a.a.Query( + a.canisterId, + "get_next_sns_version", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetSnsSubnetIds calls the "get_sns_subnet_ids" method on the "sns" canister. +func (a Agent) GetSnsSubnetIds(arg0 struct { +}) (*GetSnsSubnetIdsResponse, error) { + var r0 GetSnsSubnetIdsResponse + if err := a.a.Query( + a.canisterId, + "get_sns_subnet_ids", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetWasm calls the "get_wasm" method on the "sns" canister. +func (a Agent) GetWasm(arg0 GetWasmRequest) (*GetWasmResponse, error) { + var r0 GetWasmResponse + if err := a.a.Query( + a.canisterId, + "get_wasm", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetWasmMetadata calls the "get_wasm_metadata" method on the "sns" canister. +func (a Agent) GetWasmMetadata(arg0 GetWasmMetadataRequest) (*GetWasmMetadataResponse, error) { + var r0 GetWasmMetadataResponse + if err := a.a.Query( + a.canisterId, + "get_wasm_metadata", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// InsertUpgradePathEntries calls the "insert_upgrade_path_entries" method on the "sns" canister. +func (a Agent) InsertUpgradePathEntries(arg0 InsertUpgradePathEntriesRequest) (*InsertUpgradePathEntriesResponse, error) { + var r0 InsertUpgradePathEntriesResponse + if err := a.a.Call( + a.canisterId, + "insert_upgrade_path_entries", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ListDeployedSnses calls the "list_deployed_snses" method on the "sns" canister. +func (a Agent) ListDeployedSnses(arg0 struct { +}) (*ListDeployedSnsesResponse, error) { + var r0 ListDeployedSnsesResponse + if err := a.a.Query( + a.canisterId, + "list_deployed_snses", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ListUpgradeSteps calls the "list_upgrade_steps" method on the "sns" canister. +func (a Agent) ListUpgradeSteps(arg0 ListUpgradeStepsRequest) (*ListUpgradeStepsResponse, error) { + var r0 ListUpgradeStepsResponse + if err := a.a.Query( + a.canisterId, + "list_upgrade_steps", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// UpdateAllowedPrincipals calls the "update_allowed_principals" method on the "sns" canister. +func (a Agent) UpdateAllowedPrincipals(arg0 UpdateAllowedPrincipalsRequest) (*UpdateAllowedPrincipalsResponse, error) { + var r0 UpdateAllowedPrincipalsResponse + if err := a.a.Call( + a.canisterId, + "update_allowed_principals", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// UpdateSnsSubnetList calls the "update_sns_subnet_list" method on the "sns" canister. +func (a Agent) UpdateSnsSubnetList(arg0 UpdateSnsSubnetListRequest) (*UpdateSnsSubnetListResponse, error) { + var r0 UpdateSnsSubnetListResponse + if err := a.a.Call( + a.canisterId, + "update_sns_subnet_list", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +type AirdropDistribution struct { + AirdropNeurons []NeuronDistribution `ic:"airdrop_neurons" json:"airdrop_neurons"` +} + +type Canister struct { + Id *principal.Principal `ic:"id,omitempty" json:"id,omitempty"` +} + +type CfNeuron struct { + HasCreatedNeuronRecipes *bool `ic:"has_created_neuron_recipes,omitempty" json:"has_created_neuron_recipes,omitempty"` + NnsNeuronId uint64 `ic:"nns_neuron_id" json:"nns_neuron_id"` + AmountIcpE8s uint64 `ic:"amount_icp_e8s" json:"amount_icp_e8s"` +} + +type CfParticipant struct { + HotkeyPrincipal string `ic:"hotkey_principal" json:"hotkey_principal"` + CfNeurons []CfNeuron `ic:"cf_neurons" json:"cf_neurons"` +} + +type Countries struct { + IsoCodes []string `ic:"iso_codes" json:"iso_codes"` +} + +type DappCanisters struct { + Canisters []Canister `ic:"canisters" json:"canisters"` +} + +type DappCanistersTransferResult struct { + RestoredDappCanisters []Canister `ic:"restored_dapp_canisters" json:"restored_dapp_canisters"` + NnsControlledDappCanisters []Canister `ic:"nns_controlled_dapp_canisters" json:"nns_controlled_dapp_canisters"` + SnsControlledDappCanisters []Canister `ic:"sns_controlled_dapp_canisters" json:"sns_controlled_dapp_canisters"` +} + +type DeployNewSnsRequest struct { + SnsInitPayload *SnsInitPayload `ic:"sns_init_payload,omitempty" json:"sns_init_payload,omitempty"` +} + +type DeployNewSnsResponse struct { + DappCanistersTransferResult *DappCanistersTransferResult `ic:"dapp_canisters_transfer_result,omitempty" json:"dapp_canisters_transfer_result,omitempty"` + SubnetId *principal.Principal `ic:"subnet_id,omitempty" json:"subnet_id,omitempty"` + Error *SnsWasmError `ic:"error,omitempty" json:"error,omitempty"` + Canisters *SnsCanisterIds `ic:"canisters,omitempty" json:"canisters,omitempty"` +} + +type DeployedSns struct { + RootCanisterId *principal.Principal `ic:"root_canister_id,omitempty" json:"root_canister_id,omitempty"` + GovernanceCanisterId *principal.Principal `ic:"governance_canister_id,omitempty" json:"governance_canister_id,omitempty"` + IndexCanisterId *principal.Principal `ic:"index_canister_id,omitempty" json:"index_canister_id,omitempty"` + SwapCanisterId *principal.Principal `ic:"swap_canister_id,omitempty" json:"swap_canister_id,omitempty"` + LedgerCanisterId *principal.Principal `ic:"ledger_canister_id,omitempty" json:"ledger_canister_id,omitempty"` +} + +type DeveloperDistribution struct { + DeveloperNeurons []NeuronDistribution `ic:"developer_neurons" json:"developer_neurons"` +} + +type FractionalDeveloperVotingPower struct { + TreasuryDistribution *TreasuryDistribution `ic:"treasury_distribution,omitempty" json:"treasury_distribution,omitempty"` + DeveloperDistribution *DeveloperDistribution `ic:"developer_distribution,omitempty" json:"developer_distribution,omitempty"` + AirdropDistribution *AirdropDistribution `ic:"airdrop_distribution,omitempty" json:"airdrop_distribution,omitempty"` + SwapDistribution *SwapDistribution `ic:"swap_distribution,omitempty" json:"swap_distribution,omitempty"` +} + +type GetAllowedPrincipalsResponse struct { + AllowedPrincipals []principal.Principal `ic:"allowed_principals" json:"allowed_principals"` +} + +type GetDeployedSnsByProposalIdRequest struct { + ProposalId uint64 `ic:"proposal_id" json:"proposal_id"` +} + +type GetDeployedSnsByProposalIdResponse struct { + GetDeployedSnsByProposalIdResult *GetDeployedSnsByProposalIdResult `ic:"get_deployed_sns_by_proposal_id_result,omitempty" json:"get_deployed_sns_by_proposal_id_result,omitempty"` +} + +type GetDeployedSnsByProposalIdResult struct { + Error *SnsWasmError `ic:"Error,variant"` + DeployedSns *DeployedSns `ic:"DeployedSns,variant"` +} + +type GetNextSnsVersionRequest struct { + GovernanceCanisterId *principal.Principal `ic:"governance_canister_id,omitempty" json:"governance_canister_id,omitempty"` + CurrentVersion *SnsVersion `ic:"current_version,omitempty" json:"current_version,omitempty"` +} + +type GetNextSnsVersionResponse struct { + NextVersion *SnsVersion `ic:"next_version,omitempty" json:"next_version,omitempty"` +} + +type GetSnsSubnetIdsResponse struct { + SnsSubnetIds []principal.Principal `ic:"sns_subnet_ids" json:"sns_subnet_ids"` +} + +type GetWasmMetadataRequest struct { + Hash *[]byte `ic:"hash,omitempty" json:"hash,omitempty"` +} + +type GetWasmMetadataResponse struct { + Result *Result1 `ic:"result,omitempty" json:"result,omitempty"` +} + +type GetWasmRequest struct { + Hash []byte `ic:"hash" json:"hash"` +} + +type GetWasmResponse struct { + Wasm *SnsWasm `ic:"wasm,omitempty" json:"wasm,omitempty"` +} + +type IdealMatchedParticipationFunction struct { + SerializedRepresentation *string `ic:"serialized_representation,omitempty" json:"serialized_representation,omitempty"` +} + +type InitialTokenDistribution struct { + FractionalDeveloperVotingPower *FractionalDeveloperVotingPower `ic:"FractionalDeveloperVotingPower,variant"` +} + +type InsertUpgradePathEntriesRequest struct { + UpgradePath []SnsUpgrade `ic:"upgrade_path" json:"upgrade_path"` + SnsGovernanceCanisterId *principal.Principal `ic:"sns_governance_canister_id,omitempty" json:"sns_governance_canister_id,omitempty"` +} + +type InsertUpgradePathEntriesResponse struct { + Error *SnsWasmError `ic:"error,omitempty" json:"error,omitempty"` +} + +type LinearScalingCoefficient struct { + SlopeNumerator *uint64 `ic:"slope_numerator,omitempty" json:"slope_numerator,omitempty"` + InterceptIcpE8s *uint64 `ic:"intercept_icp_e8s,omitempty" json:"intercept_icp_e8s,omitempty"` + FromDirectParticipationIcpE8s *uint64 `ic:"from_direct_participation_icp_e8s,omitempty" json:"from_direct_participation_icp_e8s,omitempty"` + SlopeDenominator *uint64 `ic:"slope_denominator,omitempty" json:"slope_denominator,omitempty"` + ToDirectParticipationIcpE8s *uint64 `ic:"to_direct_participation_icp_e8s,omitempty" json:"to_direct_participation_icp_e8s,omitempty"` +} + +type ListDeployedSnsesResponse struct { + Instances []DeployedSns `ic:"instances" json:"instances"` +} + +type ListUpgradeStep struct { + PrettyVersion *PrettySnsVersion `ic:"pretty_version,omitempty" json:"pretty_version,omitempty"` + Version *SnsVersion `ic:"version,omitempty" json:"version,omitempty"` +} + +type ListUpgradeStepsRequest struct { + Limit uint32 `ic:"limit" json:"limit"` + StartingAt *SnsVersion `ic:"starting_at,omitempty" json:"starting_at,omitempty"` + SnsGovernanceCanisterId *principal.Principal `ic:"sns_governance_canister_id,omitempty" json:"sns_governance_canister_id,omitempty"` +} + +type ListUpgradeStepsResponse struct { + Steps []ListUpgradeStep `ic:"steps" json:"steps"` +} + +type MetadataSection struct { + Contents *[]byte `ic:"contents,omitempty" json:"contents,omitempty"` + Name *string `ic:"name,omitempty" json:"name,omitempty"` + Visibility *string `ic:"visibility,omitempty" json:"visibility,omitempty"` +} + +type NeuronBasketConstructionParameters struct { + DissolveDelayIntervalSeconds uint64 `ic:"dissolve_delay_interval_seconds" json:"dissolve_delay_interval_seconds"` + Count uint64 `ic:"count" json:"count"` +} + +type NeuronDistribution struct { + Controller *principal.Principal `ic:"controller,omitempty" json:"controller,omitempty"` + DissolveDelaySeconds uint64 `ic:"dissolve_delay_seconds" json:"dissolve_delay_seconds"` + Memo uint64 `ic:"memo" json:"memo"` + StakeE8s uint64 `ic:"stake_e8s" json:"stake_e8s"` + VestingPeriodSeconds *uint64 `ic:"vesting_period_seconds,omitempty" json:"vesting_period_seconds,omitempty"` +} + +type NeuronsFundParticipants struct { + Participants []CfParticipant `ic:"participants" json:"participants"` +} + +type NeuronsFundParticipationConstraints struct { + CoefficientIntervals []LinearScalingCoefficient `ic:"coefficient_intervals" json:"coefficient_intervals"` + MaxNeuronsFundParticipationIcpE8s *uint64 `ic:"max_neurons_fund_participation_icp_e8s,omitempty" json:"max_neurons_fund_participation_icp_e8s,omitempty"` + MinDirectParticipationThresholdIcpE8s *uint64 `ic:"min_direct_participation_threshold_icp_e8s,omitempty" json:"min_direct_participation_threshold_icp_e8s,omitempty"` + IdealMatchedParticipationFunction *IdealMatchedParticipationFunction `ic:"ideal_matched_participation_function,omitempty" json:"ideal_matched_participation_function,omitempty"` +} + +type Ok struct { + Sections []MetadataSection `ic:"sections" json:"sections"` +} + +type PrettySnsVersion struct { + ArchiveWasmHash string `ic:"archive_wasm_hash" json:"archive_wasm_hash"` + RootWasmHash string `ic:"root_wasm_hash" json:"root_wasm_hash"` + SwapWasmHash string `ic:"swap_wasm_hash" json:"swap_wasm_hash"` + LedgerWasmHash string `ic:"ledger_wasm_hash" json:"ledger_wasm_hash"` + GovernanceWasmHash string `ic:"governance_wasm_hash" json:"governance_wasm_hash"` + IndexWasmHash string `ic:"index_wasm_hash" json:"index_wasm_hash"` +} + +type Result struct { + Error *SnsWasmError `ic:"Error,variant"` + Hash *[]byte `ic:"Hash,variant"` +} + +type Result1 struct { + Ok *Ok `ic:"Ok,variant"` + Error *SnsWasmError `ic:"Error,variant"` +} + +type SnsCanisterIds struct { + Root *principal.Principal `ic:"root,omitempty" json:"root,omitempty"` + Swap *principal.Principal `ic:"swap,omitempty" json:"swap,omitempty"` + Ledger *principal.Principal `ic:"ledger,omitempty" json:"ledger,omitempty"` + Index *principal.Principal `ic:"index,omitempty" json:"index,omitempty"` + Governance *principal.Principal `ic:"governance,omitempty" json:"governance,omitempty"` +} + +type SnsInitPayload struct { + Url *string `ic:"url,omitempty" json:"url,omitempty"` + MaxDissolveDelaySeconds *uint64 `ic:"max_dissolve_delay_seconds,omitempty" json:"max_dissolve_delay_seconds,omitempty"` + MaxDissolveDelayBonusPercentage *uint64 `ic:"max_dissolve_delay_bonus_percentage,omitempty" json:"max_dissolve_delay_bonus_percentage,omitempty"` + NnsProposalId *uint64 `ic:"nns_proposal_id,omitempty" json:"nns_proposal_id,omitempty"` + NeuronsFundParticipation *bool `ic:"neurons_fund_participation,omitempty" json:"neurons_fund_participation,omitempty"` + MinParticipantIcpE8s *uint64 `ic:"min_participant_icp_e8s,omitempty" json:"min_participant_icp_e8s,omitempty"` + NeuronBasketConstructionParameters *NeuronBasketConstructionParameters `ic:"neuron_basket_construction_parameters,omitempty" json:"neuron_basket_construction_parameters,omitempty"` + FallbackControllerPrincipalIds []string `ic:"fallback_controller_principal_ids" json:"fallback_controller_principal_ids"` + TokenSymbol *string `ic:"token_symbol,omitempty" json:"token_symbol,omitempty"` + FinalRewardRateBasisPoints *uint64 `ic:"final_reward_rate_basis_points,omitempty" json:"final_reward_rate_basis_points,omitempty"` + MaxIcpE8s *uint64 `ic:"max_icp_e8s,omitempty" json:"max_icp_e8s,omitempty"` + NeuronMinimumStakeE8s *uint64 `ic:"neuron_minimum_stake_e8s,omitempty" json:"neuron_minimum_stake_e8s,omitempty"` + ConfirmationText *string `ic:"confirmation_text,omitempty" json:"confirmation_text,omitempty"` + Logo *string `ic:"logo,omitempty" json:"logo,omitempty"` + Name *string `ic:"name,omitempty" json:"name,omitempty"` + SwapStartTimestampSeconds *uint64 `ic:"swap_start_timestamp_seconds,omitempty" json:"swap_start_timestamp_seconds,omitempty"` + SwapDueTimestampSeconds *uint64 `ic:"swap_due_timestamp_seconds,omitempty" json:"swap_due_timestamp_seconds,omitempty"` + InitialVotingPeriodSeconds *uint64 `ic:"initial_voting_period_seconds,omitempty" json:"initial_voting_period_seconds,omitempty"` + NeuronMinimumDissolveDelayToVoteSeconds *uint64 `ic:"neuron_minimum_dissolve_delay_to_vote_seconds,omitempty" json:"neuron_minimum_dissolve_delay_to_vote_seconds,omitempty"` + Description *string `ic:"description,omitempty" json:"description,omitempty"` + MaxNeuronAgeSecondsForAgeBonus *uint64 `ic:"max_neuron_age_seconds_for_age_bonus,omitempty" json:"max_neuron_age_seconds_for_age_bonus,omitempty"` + MinParticipants *uint64 `ic:"min_participants,omitempty" json:"min_participants,omitempty"` + InitialRewardRateBasisPoints *uint64 `ic:"initial_reward_rate_basis_points,omitempty" json:"initial_reward_rate_basis_points,omitempty"` + WaitForQuietDeadlineIncreaseSeconds *uint64 `ic:"wait_for_quiet_deadline_increase_seconds,omitempty" json:"wait_for_quiet_deadline_increase_seconds,omitempty"` + TransactionFeeE8s *uint64 `ic:"transaction_fee_e8s,omitempty" json:"transaction_fee_e8s,omitempty"` + DappCanisters *DappCanisters `ic:"dapp_canisters,omitempty" json:"dapp_canisters,omitempty"` + NeuronsFundParticipationConstraints *NeuronsFundParticipationConstraints `ic:"neurons_fund_participation_constraints,omitempty" json:"neurons_fund_participation_constraints,omitempty"` + NeuronsFundParticipants *NeuronsFundParticipants `ic:"neurons_fund_participants,omitempty" json:"neurons_fund_participants,omitempty"` + MaxAgeBonusPercentage *uint64 `ic:"max_age_bonus_percentage,omitempty" json:"max_age_bonus_percentage,omitempty"` + InitialTokenDistribution *InitialTokenDistribution `ic:"initial_token_distribution,omitempty" json:"initial_token_distribution,omitempty"` + RewardRateTransitionDurationSeconds *uint64 `ic:"reward_rate_transition_duration_seconds,omitempty" json:"reward_rate_transition_duration_seconds,omitempty"` + TokenLogo *string `ic:"token_logo,omitempty" json:"token_logo,omitempty"` + TokenName *string `ic:"token_name,omitempty" json:"token_name,omitempty"` + MaxParticipantIcpE8s *uint64 `ic:"max_participant_icp_e8s,omitempty" json:"max_participant_icp_e8s,omitempty"` + MinDirectParticipationIcpE8s *uint64 `ic:"min_direct_participation_icp_e8s,omitempty" json:"min_direct_participation_icp_e8s,omitempty"` + ProposalRejectCostE8s *uint64 `ic:"proposal_reject_cost_e8s,omitempty" json:"proposal_reject_cost_e8s,omitempty"` + RestrictedCountries *Countries `ic:"restricted_countries,omitempty" json:"restricted_countries,omitempty"` + MinIcpE8s *uint64 `ic:"min_icp_e8s,omitempty" json:"min_icp_e8s,omitempty"` + MaxDirectParticipationIcpE8s *uint64 `ic:"max_direct_participation_icp_e8s,omitempty" json:"max_direct_participation_icp_e8s,omitempty"` +} + +type SnsUpgrade struct { + NextVersion *SnsVersion `ic:"next_version,omitempty" json:"next_version,omitempty"` + CurrentVersion *SnsVersion `ic:"current_version,omitempty" json:"current_version,omitempty"` +} + +type SnsVersion struct { + ArchiveWasmHash []byte `ic:"archive_wasm_hash" json:"archive_wasm_hash"` + RootWasmHash []byte `ic:"root_wasm_hash" json:"root_wasm_hash"` + SwapWasmHash []byte `ic:"swap_wasm_hash" json:"swap_wasm_hash"` + LedgerWasmHash []byte `ic:"ledger_wasm_hash" json:"ledger_wasm_hash"` + GovernanceWasmHash []byte `ic:"governance_wasm_hash" json:"governance_wasm_hash"` + IndexWasmHash []byte `ic:"index_wasm_hash" json:"index_wasm_hash"` +} + +type SnsWasm struct { + Wasm []byte `ic:"wasm" json:"wasm"` + CanisterType int32 `ic:"canister_type" json:"canister_type"` +} + +type SnsWasmCanisterInitPayload struct { + AllowedPrincipals []principal.Principal `ic:"allowed_principals" json:"allowed_principals"` + AccessControlsEnabled bool `ic:"access_controls_enabled" json:"access_controls_enabled"` + SnsSubnetIds []principal.Principal `ic:"sns_subnet_ids" json:"sns_subnet_ids"` +} + +type SnsWasmError struct { + Message string `ic:"message" json:"message"` +} + +type SwapDistribution struct { + TotalE8s uint64 `ic:"total_e8s" json:"total_e8s"` + InitialSwapAmountE8s uint64 `ic:"initial_swap_amount_e8s" json:"initial_swap_amount_e8s"` +} + +type TreasuryDistribution struct { + TotalE8s uint64 `ic:"total_e8s" json:"total_e8s"` +} + +type UpdateAllowedPrincipalsRequest struct { + AddedPrincipals []principal.Principal `ic:"added_principals" json:"added_principals"` + RemovedPrincipals []principal.Principal `ic:"removed_principals" json:"removed_principals"` +} + +type UpdateAllowedPrincipalsResponse struct { + UpdateAllowedPrincipalsResult *UpdateAllowedPrincipalsResult `ic:"update_allowed_principals_result,omitempty" json:"update_allowed_principals_result,omitempty"` +} + +type UpdateAllowedPrincipalsResult struct { + Error *SnsWasmError `ic:"Error,variant"` + AllowedPrincipals *GetAllowedPrincipalsResponse `ic:"AllowedPrincipals,variant"` +} + +type UpdateSnsSubnetListRequest struct { + SnsSubnetIdsToAdd []principal.Principal `ic:"sns_subnet_ids_to_add" json:"sns_subnet_ids_to_add"` + SnsSubnetIdsToRemove []principal.Principal `ic:"sns_subnet_ids_to_remove" json:"sns_subnet_ids_to_remove"` +} + +type UpdateSnsSubnetListResponse struct { + Error *SnsWasmError `ic:"error,omitempty" json:"error,omitempty"` +} diff --git a/ic/sns/governance/agent.go b/ic/sns/governance/agent.go new file mode 100755 index 0000000..4d1796b --- /dev/null +++ b/ic/sns/governance/agent.go @@ -0,0 +1,759 @@ +// Package governance provides a client for the "governance" canister. +// Do NOT edit this file. It was automatically generated by https://github.com/aviate-labs/agent-go. +package governance + +import ( + "github.com/aviate-labs/agent-go" + "github.com/aviate-labs/agent-go/candid/idl" + "github.com/aviate-labs/agent-go/principal" +) + +// Agent is a client for the "governance" canister. +type Agent struct { + a *agent.Agent + canisterId principal.Principal +} + +// NewAgent creates a new agent for the "governance" canister. +func NewAgent(canisterId principal.Principal, config agent.Config) (*Agent, error) { + a, err := agent.New(config) + if err != nil { + return nil, err + } + return &Agent{ + a: a, + canisterId: canisterId, + }, nil +} + +// ApiVersion calls the "api_version" method on the "governance" canister. +func (a Agent) ApiVersion() (*uint16, error) { + var r0 uint16 + if err := a.a.Query( + a.canisterId, + "api_version", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Authorize calls the "authorize" method on the "governance" canister. +func (a Agent) Authorize(arg0 principal.Principal) error { + if err := a.a.Call( + a.canisterId, + "authorize", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// CertifiedTree calls the "certified_tree" method on the "governance" canister. +func (a Agent) CertifiedTree(arg0 struct { +}) (*struct { + Certificate []byte `ic:"certificate" json:"certificate"` + Tree []byte `ic:"tree" json:"tree"` +}, error) { + var r0 struct { + Certificate []byte `ic:"certificate" json:"certificate"` + Tree []byte `ic:"tree" json:"tree"` + } + if err := a.a.Query( + a.canisterId, + "certified_tree", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Clear calls the "clear" method on the "governance" canister. +func (a Agent) Clear(arg0 ClearArguments) error { + if err := a.a.Call( + a.canisterId, + "clear", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// CommitBatch calls the "commit_batch" method on the "governance" canister. +func (a Agent) CommitBatch(arg0 CommitBatchArguments) error { + if err := a.a.Call( + a.canisterId, + "commit_batch", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// CommitProposedBatch calls the "commit_proposed_batch" method on the "governance" canister. +func (a Agent) CommitProposedBatch(arg0 CommitProposedBatchArguments) error { + if err := a.a.Call( + a.canisterId, + "commit_proposed_batch", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// ComputeEvidence calls the "compute_evidence" method on the "governance" canister. +func (a Agent) ComputeEvidence(arg0 ComputeEvidenceArguments) (**[]byte, error) { + var r0 *[]byte + if err := a.a.Call( + a.canisterId, + "compute_evidence", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Configure calls the "configure" method on the "governance" canister. +func (a Agent) Configure(arg0 ConfigureArguments) error { + if err := a.a.Call( + a.canisterId, + "configure", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// CreateAsset calls the "create_asset" method on the "governance" canister. +func (a Agent) CreateAsset(arg0 CreateAssetArguments) error { + if err := a.a.Call( + a.canisterId, + "create_asset", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// CreateBatch calls the "create_batch" method on the "governance" canister. +func (a Agent) CreateBatch(arg0 struct { +}) (*struct { + BatchId BatchId `ic:"batch_id" json:"batch_id"` +}, error) { + var r0 struct { + BatchId BatchId `ic:"batch_id" json:"batch_id"` + } + if err := a.a.Call( + a.canisterId, + "create_batch", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// CreateChunk calls the "create_chunk" method on the "governance" canister. +func (a Agent) CreateChunk(arg0 struct { + BatchId BatchId `ic:"batch_id" json:"batch_id"` + Content []byte `ic:"content" json:"content"` +}) (*struct { + ChunkId ChunkId `ic:"chunk_id" json:"chunk_id"` +}, error) { + var r0 struct { + ChunkId ChunkId `ic:"chunk_id" json:"chunk_id"` + } + if err := a.a.Call( + a.canisterId, + "create_chunk", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Deauthorize calls the "deauthorize" method on the "governance" canister. +func (a Agent) Deauthorize(arg0 principal.Principal) error { + if err := a.a.Call( + a.canisterId, + "deauthorize", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// DeleteAsset calls the "delete_asset" method on the "governance" canister. +func (a Agent) DeleteAsset(arg0 DeleteAssetArguments) error { + if err := a.a.Call( + a.canisterId, + "delete_asset", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// DeleteBatch calls the "delete_batch" method on the "governance" canister. +func (a Agent) DeleteBatch(arg0 DeleteBatchArguments) error { + if err := a.a.Call( + a.canisterId, + "delete_batch", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// Get calls the "get" method on the "governance" canister. +func (a Agent) Get(arg0 struct { + Key Key `ic:"key" json:"key"` + AcceptEncodings []string `ic:"accept_encodings" json:"accept_encodings"` +}) (*struct { + Content []byte `ic:"content" json:"content"` + ContentType string `ic:"content_type" json:"content_type"` + ContentEncoding string `ic:"content_encoding" json:"content_encoding"` + Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` + TotalLength idl.Nat `ic:"total_length" json:"total_length"` +}, error) { + var r0 struct { + Content []byte `ic:"content" json:"content"` + ContentType string `ic:"content_type" json:"content_type"` + ContentEncoding string `ic:"content_encoding" json:"content_encoding"` + Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` + TotalLength idl.Nat `ic:"total_length" json:"total_length"` + } + if err := a.a.Query( + a.canisterId, + "get", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetAssetProperties calls the "get_asset_properties" method on the "governance" canister. +func (a Agent) GetAssetProperties(key Key) (*struct { + MaxAge *uint64 `ic:"max_age,omitempty" json:"max_age,omitempty"` + Headers *[]HeaderField `ic:"headers,omitempty" json:"headers,omitempty"` + AllowRawAccess *bool `ic:"allow_raw_access,omitempty" json:"allow_raw_access,omitempty"` + IsAliased *bool `ic:"is_aliased,omitempty" json:"is_aliased,omitempty"` +}, error) { + var r0 struct { + MaxAge *uint64 `ic:"max_age,omitempty" json:"max_age,omitempty"` + Headers *[]HeaderField `ic:"headers,omitempty" json:"headers,omitempty"` + AllowRawAccess *bool `ic:"allow_raw_access,omitempty" json:"allow_raw_access,omitempty"` + IsAliased *bool `ic:"is_aliased,omitempty" json:"is_aliased,omitempty"` + } + if err := a.a.Query( + a.canisterId, + "get_asset_properties", + []any{key}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetChunk calls the "get_chunk" method on the "governance" canister. +func (a Agent) GetChunk(arg0 struct { + Key Key `ic:"key" json:"key"` + ContentEncoding string `ic:"content_encoding" json:"content_encoding"` + Index idl.Nat `ic:"index" json:"index"` + Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` +}) (*struct { + Content []byte `ic:"content" json:"content"` +}, error) { + var r0 struct { + Content []byte `ic:"content" json:"content"` + } + if err := a.a.Query( + a.canisterId, + "get_chunk", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetConfiguration calls the "get_configuration" method on the "governance" canister. +func (a Agent) GetConfiguration() (*ConfigurationResponse, error) { + var r0 ConfigurationResponse + if err := a.a.Call( + a.canisterId, + "get_configuration", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GrantPermission calls the "grant_permission" method on the "governance" canister. +func (a Agent) GrantPermission(arg0 GrantPermission) error { + if err := a.a.Call( + a.canisterId, + "grant_permission", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// HttpRequest calls the "http_request" method on the "governance" canister. +func (a Agent) HttpRequest(request HttpRequest) (*HttpResponse, error) { + var r0 HttpResponse + if err := a.a.Query( + a.canisterId, + "http_request", + []any{request}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// HttpRequestStreamingCallback calls the "http_request_streaming_callback" method on the "governance" canister. +func (a Agent) HttpRequestStreamingCallback(token StreamingCallbackToken) (**StreamingCallbackHttpResponse, error) { + var r0 *StreamingCallbackHttpResponse + if err := a.a.Query( + a.canisterId, + "http_request_streaming_callback", + []any{token}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// List calls the "list" method on the "governance" canister. +func (a Agent) List(arg0 struct { +}) (*[]struct { + Key Key `ic:"key" json:"key"` + ContentType string `ic:"content_type" json:"content_type"` + Encodings []struct { + ContentEncoding string `ic:"content_encoding" json:"content_encoding"` + Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` + Length idl.Nat `ic:"length" json:"length"` + Modified Time `ic:"modified" json:"modified"` + } `ic:"encodings" json:"encodings"` +}, error) { + var r0 []struct { + Key Key `ic:"key" json:"key"` + ContentType string `ic:"content_type" json:"content_type"` + Encodings []struct { + ContentEncoding string `ic:"content_encoding" json:"content_encoding"` + Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` + Length idl.Nat `ic:"length" json:"length"` + Modified Time `ic:"modified" json:"modified"` + } `ic:"encodings" json:"encodings"` + } + if err := a.a.Query( + a.canisterId, + "list", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ListAuthorized calls the "list_authorized" method on the "governance" canister. +func (a Agent) ListAuthorized() (*[]principal.Principal, error) { + var r0 []principal.Principal + if err := a.a.Call( + a.canisterId, + "list_authorized", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ListPermitted calls the "list_permitted" method on the "governance" canister. +func (a Agent) ListPermitted(arg0 ListPermitted) (*[]principal.Principal, error) { + var r0 []principal.Principal + if err := a.a.Call( + a.canisterId, + "list_permitted", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ProposeCommitBatch calls the "propose_commit_batch" method on the "governance" canister. +func (a Agent) ProposeCommitBatch(arg0 CommitBatchArguments) error { + if err := a.a.Call( + a.canisterId, + "propose_commit_batch", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// RevokePermission calls the "revoke_permission" method on the "governance" canister. +func (a Agent) RevokePermission(arg0 RevokePermission) error { + if err := a.a.Call( + a.canisterId, + "revoke_permission", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// SetAssetContent calls the "set_asset_content" method on the "governance" canister. +func (a Agent) SetAssetContent(arg0 SetAssetContentArguments) error { + if err := a.a.Call( + a.canisterId, + "set_asset_content", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// SetAssetProperties calls the "set_asset_properties" method on the "governance" canister. +func (a Agent) SetAssetProperties(arg0 SetAssetPropertiesArguments) error { + if err := a.a.Call( + a.canisterId, + "set_asset_properties", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// Store calls the "store" method on the "governance" canister. +func (a Agent) Store(arg0 struct { + Key Key `ic:"key" json:"key"` + ContentType string `ic:"content_type" json:"content_type"` + ContentEncoding string `ic:"content_encoding" json:"content_encoding"` + Content []byte `ic:"content" json:"content"` + Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` +}) error { + if err := a.a.Call( + a.canisterId, + "store", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// TakeOwnership calls the "take_ownership" method on the "governance" canister. +func (a Agent) TakeOwnership() error { + if err := a.a.Call( + a.canisterId, + "take_ownership", + []any{}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// UnsetAssetContent calls the "unset_asset_content" method on the "governance" canister. +func (a Agent) UnsetAssetContent(arg0 UnsetAssetContentArguments) error { + if err := a.a.Call( + a.canisterId, + "unset_asset_content", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// ValidateCommitProposedBatch calls the "validate_commit_proposed_batch" method on the "governance" canister. +func (a Agent) ValidateCommitProposedBatch(arg0 CommitProposedBatchArguments) (*ValidationResult, error) { + var r0 ValidationResult + if err := a.a.Call( + a.canisterId, + "validate_commit_proposed_batch", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ValidateConfigure calls the "validate_configure" method on the "governance" canister. +func (a Agent) ValidateConfigure(arg0 ConfigureArguments) (*ValidationResult, error) { + var r0 ValidationResult + if err := a.a.Call( + a.canisterId, + "validate_configure", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ValidateGrantPermission calls the "validate_grant_permission" method on the "governance" canister. +func (a Agent) ValidateGrantPermission(arg0 GrantPermission) (*ValidationResult, error) { + var r0 ValidationResult + if err := a.a.Call( + a.canisterId, + "validate_grant_permission", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ValidateRevokePermission calls the "validate_revoke_permission" method on the "governance" canister. +func (a Agent) ValidateRevokePermission(arg0 RevokePermission) (*ValidationResult, error) { + var r0 ValidationResult + if err := a.a.Call( + a.canisterId, + "validate_revoke_permission", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ValidateTakeOwnership calls the "validate_take_ownership" method on the "governance" canister. +func (a Agent) ValidateTakeOwnership() (*ValidationResult, error) { + var r0 ValidationResult + if err := a.a.Call( + a.canisterId, + "validate_take_ownership", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +type AssetCanisterArgs struct { + Init *InitArgs `ic:"Init,variant"` + Upgrade *UpgradeArgs `ic:"Upgrade,variant"` +} + +type BatchId = idl.Nat + +type BatchOperationKind struct { + CreateAsset *CreateAssetArguments `ic:"CreateAsset,variant"` + SetAssetContent *SetAssetContentArguments `ic:"SetAssetContent,variant"` + SetAssetProperties *SetAssetPropertiesArguments `ic:"SetAssetProperties,variant"` + UnsetAssetContent *UnsetAssetContentArguments `ic:"UnsetAssetContent,variant"` + DeleteAsset *DeleteAssetArguments `ic:"DeleteAsset,variant"` + Clear *ClearArguments `ic:"Clear,variant"` +} + +type ChunkId = idl.Nat + +type ClearArguments struct { +} + +type CommitBatchArguments struct { + BatchId BatchId `ic:"batch_id" json:"batch_id"` + Operations []BatchOperationKind `ic:"operations" json:"operations"` +} + +type CommitProposedBatchArguments struct { + BatchId BatchId `ic:"batch_id" json:"batch_id"` + Evidence []byte `ic:"evidence" json:"evidence"` +} + +type ComputeEvidenceArguments struct { + BatchId BatchId `ic:"batch_id" json:"batch_id"` + MaxIterations *uint16 `ic:"max_iterations,omitempty" json:"max_iterations,omitempty"` +} + +type ConfigurationResponse struct { + MaxBatches *uint64 `ic:"max_batches,omitempty" json:"max_batches,omitempty"` + MaxChunks *uint64 `ic:"max_chunks,omitempty" json:"max_chunks,omitempty"` + MaxBytes *uint64 `ic:"max_bytes,omitempty" json:"max_bytes,omitempty"` +} + +type ConfigureArguments struct { + MaxBatches **uint64 `ic:"max_batches,omitempty" json:"max_batches,omitempty"` + MaxChunks **uint64 `ic:"max_chunks,omitempty" json:"max_chunks,omitempty"` + MaxBytes **uint64 `ic:"max_bytes,omitempty" json:"max_bytes,omitempty"` +} + +type CreateAssetArguments struct { + Key Key `ic:"key" json:"key"` + ContentType string `ic:"content_type" json:"content_type"` + MaxAge *uint64 `ic:"max_age,omitempty" json:"max_age,omitempty"` + Headers *[]HeaderField `ic:"headers,omitempty" json:"headers,omitempty"` + EnableAliasing *bool `ic:"enable_aliasing,omitempty" json:"enable_aliasing,omitempty"` + AllowRawAccess *bool `ic:"allow_raw_access,omitempty" json:"allow_raw_access,omitempty"` +} + +type DeleteAssetArguments struct { + Key Key `ic:"key" json:"key"` +} + +type DeleteBatchArguments struct { + BatchId BatchId `ic:"batch_id" json:"batch_id"` +} + +type GrantPermission struct { + ToPrincipal principal.Principal `ic:"to_principal" json:"to_principal"` + Permission Permission `ic:"permission" json:"permission"` +} + +type HeaderField struct { + Field0 string `ic:"0" json:"0"` + Field1 string `ic:"1" json:"1"` +} + +type HttpRequest struct { + Method string `ic:"method" json:"method"` + Url string `ic:"url" json:"url"` + Headers []HeaderField `ic:"headers" json:"headers"` + Body []byte `ic:"body" json:"body"` + CertificateVersion *uint16 `ic:"certificate_version,omitempty" json:"certificate_version,omitempty"` +} + +type HttpResponse struct { + StatusCode uint16 `ic:"status_code" json:"status_code"` + Headers []HeaderField `ic:"headers" json:"headers"` + Body []byte `ic:"body" json:"body"` + StreamingStrategy *StreamingStrategy `ic:"streaming_strategy,omitempty" json:"streaming_strategy,omitempty"` +} + +type InitArgs struct { +} + +type Key = string + +type ListPermitted struct { + Permission Permission `ic:"permission" json:"permission"` +} + +type Permission struct { + Commit *idl.Null `ic:"Commit,variant"` + ManagePermissions *idl.Null `ic:"ManagePermissions,variant"` + Prepare *idl.Null `ic:"Prepare,variant"` +} + +type RevokePermission struct { + OfPrincipal principal.Principal `ic:"of_principal" json:"of_principal"` + Permission Permission `ic:"permission" json:"permission"` +} + +type SetAssetContentArguments struct { + Key Key `ic:"key" json:"key"` + ContentEncoding string `ic:"content_encoding" json:"content_encoding"` + ChunkIds []ChunkId `ic:"chunk_ids" json:"chunk_ids"` + Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` +} + +type SetAssetPropertiesArguments struct { + Key Key `ic:"key" json:"key"` + MaxAge **uint64 `ic:"max_age,omitempty" json:"max_age,omitempty"` + Headers **[]HeaderField `ic:"headers,omitempty" json:"headers,omitempty"` + AllowRawAccess **bool `ic:"allow_raw_access,omitempty" json:"allow_raw_access,omitempty"` + IsAliased **bool `ic:"is_aliased,omitempty" json:"is_aliased,omitempty"` +} + +type SetPermissions struct { + Prepare []principal.Principal `ic:"prepare" json:"prepare"` + Commit []principal.Principal `ic:"commit" json:"commit"` + ManagePermissions []principal.Principal `ic:"manage_permissions" json:"manage_permissions"` +} + +type StreamingCallbackHttpResponse struct { + Body []byte `ic:"body" json:"body"` + Token *StreamingCallbackToken `ic:"token,omitempty" json:"token,omitempty"` +} + +type StreamingCallbackToken struct { + Key Key `ic:"key" json:"key"` + ContentEncoding string `ic:"content_encoding" json:"content_encoding"` + Index idl.Nat `ic:"index" json:"index"` + Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` +} + +type StreamingStrategy struct { + Callback *struct { + Callback struct { /* NOT SUPPORTED */ + } `ic:"callback" json:"callback"` + Token StreamingCallbackToken `ic:"token" json:"token"` + } `ic:"Callback,variant"` +} + +type Time = idl.Int + +type UnsetAssetContentArguments struct { + Key Key `ic:"key" json:"key"` + ContentEncoding string `ic:"content_encoding" json:"content_encoding"` +} + +type UpgradeArgs struct { + SetPermissions *SetPermissions `ic:"set_permissions,omitempty" json:"set_permissions,omitempty"` +} + +type ValidationResult struct { + Ok *string `ic:"Ok,variant"` + Err *string `ic:"Err,variant"` +} diff --git a/ic/sns/index/agent.go b/ic/sns/index/agent.go new file mode 100755 index 0000000..1b793e6 --- /dev/null +++ b/ic/sns/index/agent.go @@ -0,0 +1,157 @@ +// Package index provides a client for the "index" canister. +// Do NOT edit this file. It was automatically generated by https://github.com/aviate-labs/agent-go. +package index + +import ( + "github.com/aviate-labs/agent-go" + "github.com/aviate-labs/agent-go/candid/idl" + "github.com/aviate-labs/agent-go/principal" +) + +type Account struct { + Owner principal.Principal `ic:"owner" json:"owner"` + Subaccount *[]byte `ic:"subaccount,omitempty" json:"subaccount,omitempty"` +} + +// Agent is a client for the "index" canister. +type Agent struct { + a *agent.Agent + canisterId principal.Principal +} + +// NewAgent creates a new agent for the "index" canister. +func NewAgent(canisterId principal.Principal, config agent.Config) (*Agent, error) { + a, err := agent.New(config) + if err != nil { + return nil, err + } + return &Agent{ + a: a, + canisterId: canisterId, + }, nil +} + +// GetAccountTransactions calls the "get_account_transactions" method on the "index" canister. +func (a Agent) GetAccountTransactions(arg0 GetAccountTransactionsArgs) (*GetTransactionsResult, error) { + var r0 GetTransactionsResult + if err := a.a.Call( + a.canisterId, + "get_account_transactions", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// LedgerId calls the "ledger_id" method on the "index" canister. +func (a Agent) LedgerId() (*principal.Principal, error) { + var r0 principal.Principal + if err := a.a.Query( + a.canisterId, + "ledger_id", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ListSubaccounts calls the "list_subaccounts" method on the "index" canister. +func (a Agent) ListSubaccounts(arg0 ListSubaccountsArgs) (*[]SubAccount, error) { + var r0 []SubAccount + if err := a.a.Query( + a.canisterId, + "list_subaccounts", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +type Approve struct { + Fee *idl.Nat `ic:"fee,omitempty" json:"fee,omitempty"` + From Account `ic:"from" json:"from"` + Memo *[]uint8 `ic:"memo,omitempty" json:"memo,omitempty"` + CreatedAtTime *uint64 `ic:"created_at_time,omitempty" json:"created_at_time,omitempty"` + Amount idl.Nat `ic:"amount" json:"amount"` + ExpectedAllowance *idl.Nat `ic:"expected_allowance,omitempty" json:"expected_allowance,omitempty"` + ExpiresAt *uint64 `ic:"expires_at,omitempty" json:"expires_at,omitempty"` + Spender Account `ic:"spender" json:"spender"` +} + +type Burn struct { + From Account `ic:"from" json:"from"` + Memo *[]uint8 `ic:"memo,omitempty" json:"memo,omitempty"` + CreatedAtTime *uint64 `ic:"created_at_time,omitempty" json:"created_at_time,omitempty"` + Amount idl.Nat `ic:"amount" json:"amount"` + Spender *Account `ic:"spender,omitempty" json:"spender,omitempty"` +} + +type GetAccountTransactionsArgs struct { + Account Account `ic:"account" json:"account"` + Start *TxId `ic:"start,omitempty" json:"start,omitempty"` + MaxResults idl.Nat `ic:"max_results" json:"max_results"` +} + +type GetTransactions struct { + Transactions []TransactionWithId `ic:"transactions" json:"transactions"` + OldestTxId *TxId `ic:"oldest_tx_id,omitempty" json:"oldest_tx_id,omitempty"` +} + +type GetTransactionsErr struct { + Message string `ic:"message" json:"message"` +} + +type GetTransactionsResult struct { + Ok *GetTransactions `ic:"Ok,variant"` + Err *GetTransactionsErr `ic:"Err,variant"` +} + +type InitArgs struct { + LedgerId principal.Principal `ic:"ledger_id" json:"ledger_id"` +} + +type ListSubaccountsArgs struct { + Owner principal.Principal `ic:"owner" json:"owner"` + Start *SubAccount `ic:"start,omitempty" json:"start,omitempty"` +} + +type Mint struct { + To Account `ic:"to" json:"to"` + Memo *[]uint8 `ic:"memo,omitempty" json:"memo,omitempty"` + CreatedAtTime *uint64 `ic:"created_at_time,omitempty" json:"created_at_time,omitempty"` + Amount idl.Nat `ic:"amount" json:"amount"` +} + +type SubAccount = []byte + +type Transaction struct { + Burn *Burn `ic:"burn,omitempty" json:"burn,omitempty"` + Kind string `ic:"kind" json:"kind"` + Mint *Mint `ic:"mint,omitempty" json:"mint,omitempty"` + Approve *Approve `ic:"approve,omitempty" json:"approve,omitempty"` + Timestamp uint64 `ic:"timestamp" json:"timestamp"` + Transfer *Transfer `ic:"transfer,omitempty" json:"transfer,omitempty"` +} + +type TransactionWithId struct { + Id TxId `ic:"id" json:"id"` + Transaction Transaction `ic:"transaction" json:"transaction"` +} + +type Transfer struct { + To Account `ic:"to" json:"to"` + Fee *idl.Nat `ic:"fee,omitempty" json:"fee,omitempty"` + From Account `ic:"from" json:"from"` + Memo *[]uint8 `ic:"memo,omitempty" json:"memo,omitempty"` + CreatedAtTime *uint64 `ic:"created_at_time,omitempty" json:"created_at_time,omitempty"` + Amount idl.Nat `ic:"amount" json:"amount"` + Spender *Account `ic:"spender,omitempty" json:"spender,omitempty"` +} + +type TxId = idl.Nat diff --git a/ic/sns/ledger/agent.go b/ic/sns/ledger/agent.go new file mode 100755 index 0000000..771d2d1 --- /dev/null +++ b/ic/sns/ledger/agent.go @@ -0,0 +1,695 @@ +// Package ledger provides a client for the "ledger" canister. +// Do NOT edit this file. It was automatically generated by https://github.com/aviate-labs/agent-go. +package ledger + +import ( + "github.com/aviate-labs/agent-go" + "github.com/aviate-labs/agent-go/candid/idl" + "github.com/aviate-labs/agent-go/principal" +) + +type Account struct { + Owner principal.Principal `ic:"owner" json:"owner"` + Subaccount *Subaccount `ic:"subaccount,omitempty" json:"subaccount,omitempty"` +} + +// Agent is a client for the "ledger" canister. +type Agent struct { + a *agent.Agent + canisterId principal.Principal +} + +// NewAgent creates a new agent for the "ledger" canister. +func NewAgent(canisterId principal.Principal, config agent.Config) (*Agent, error) { + a, err := agent.New(config) + if err != nil { + return nil, err + } + return &Agent{ + a: a, + canisterId: canisterId, + }, nil +} + +// Archives calls the "archives" method on the "ledger" canister. +func (a Agent) Archives() (*[]ArchiveInfo, error) { + var r0 []ArchiveInfo + if err := a.a.Query( + a.canisterId, + "archives", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetBlocks calls the "get_blocks" method on the "ledger" canister. +func (a Agent) GetBlocks(arg0 GetBlocksArgs) (*GetBlocksResponse, error) { + var r0 GetBlocksResponse + if err := a.a.Query( + a.canisterId, + "get_blocks", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetDataCertificate calls the "get_data_certificate" method on the "ledger" canister. +func (a Agent) GetDataCertificate() (*DataCertificate, error) { + var r0 DataCertificate + if err := a.a.Query( + a.canisterId, + "get_data_certificate", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetTransactions calls the "get_transactions" method on the "ledger" canister. +func (a Agent) GetTransactions(arg0 GetTransactionsRequest) (*GetTransactionsResponse, error) { + var r0 GetTransactionsResponse + if err := a.a.Query( + a.canisterId, + "get_transactions", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1BalanceOf calls the "icrc1_balance_of" method on the "ledger" canister. +func (a Agent) Icrc1BalanceOf(arg0 Account) (*Tokens, error) { + var r0 Tokens + if err := a.a.Query( + a.canisterId, + "icrc1_balance_of", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1Decimals calls the "icrc1_decimals" method on the "ledger" canister. +func (a Agent) Icrc1Decimals() (*uint8, error) { + var r0 uint8 + if err := a.a.Query( + a.canisterId, + "icrc1_decimals", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1Fee calls the "icrc1_fee" method on the "ledger" canister. +func (a Agent) Icrc1Fee() (*Tokens, error) { + var r0 Tokens + if err := a.a.Query( + a.canisterId, + "icrc1_fee", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1Metadata calls the "icrc1_metadata" method on the "ledger" canister. +func (a Agent) Icrc1Metadata() (*[]struct { + Field0 string `ic:"0" json:"0"` + Field1 MetadataValue `ic:"1" json:"1"` +}, error) { + var r0 []struct { + Field0 string `ic:"0" json:"0"` + Field1 MetadataValue `ic:"1" json:"1"` + } + if err := a.a.Query( + a.canisterId, + "icrc1_metadata", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1MintingAccount calls the "icrc1_minting_account" method on the "ledger" canister. +func (a Agent) Icrc1MintingAccount() (**Account, error) { + var r0 *Account + if err := a.a.Query( + a.canisterId, + "icrc1_minting_account", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1Name calls the "icrc1_name" method on the "ledger" canister. +func (a Agent) Icrc1Name() (*string, error) { + var r0 string + if err := a.a.Query( + a.canisterId, + "icrc1_name", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1SupportedStandards calls the "icrc1_supported_standards" method on the "ledger" canister. +func (a Agent) Icrc1SupportedStandards() (*[]StandardRecord, error) { + var r0 []StandardRecord + if err := a.a.Query( + a.canisterId, + "icrc1_supported_standards", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1Symbol calls the "icrc1_symbol" method on the "ledger" canister. +func (a Agent) Icrc1Symbol() (*string, error) { + var r0 string + if err := a.a.Query( + a.canisterId, + "icrc1_symbol", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1TotalSupply calls the "icrc1_total_supply" method on the "ledger" canister. +func (a Agent) Icrc1TotalSupply() (*Tokens, error) { + var r0 Tokens + if err := a.a.Query( + a.canisterId, + "icrc1_total_supply", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1Transfer calls the "icrc1_transfer" method on the "ledger" canister. +func (a Agent) Icrc1Transfer(arg0 TransferArg) (*TransferResult, error) { + var r0 TransferResult + if err := a.a.Call( + a.canisterId, + "icrc1_transfer", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc2Allowance calls the "icrc2_allowance" method on the "ledger" canister. +func (a Agent) Icrc2Allowance(arg0 AllowanceArgs) (*Allowance, error) { + var r0 Allowance + if err := a.a.Query( + a.canisterId, + "icrc2_allowance", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc2Approve calls the "icrc2_approve" method on the "ledger" canister. +func (a Agent) Icrc2Approve(arg0 ApproveArgs) (*ApproveResult, error) { + var r0 ApproveResult + if err := a.a.Call( + a.canisterId, + "icrc2_approve", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc2TransferFrom calls the "icrc2_transfer_from" method on the "ledger" canister. +func (a Agent) Icrc2TransferFrom(arg0 TransferFromArgs) (*TransferFromResult, error) { + var r0 TransferFromResult + if err := a.a.Call( + a.canisterId, + "icrc2_transfer_from", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc3GetArchives calls the "icrc3_get_archives" method on the "ledger" canister. +func (a Agent) Icrc3GetArchives(arg0 GetArchivesArgs) (*GetArchivesResult, error) { + var r0 GetArchivesResult + if err := a.a.Query( + a.canisterId, + "icrc3_get_archives", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc3GetTipCertificate calls the "icrc3_get_tip_certificate" method on the "ledger" canister. +func (a Agent) Icrc3GetTipCertificate() (**ICRC3DataCertificate, error) { + var r0 *ICRC3DataCertificate + if err := a.a.Query( + a.canisterId, + "icrc3_get_tip_certificate", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc3SupportedBlockTypes calls the "icrc3_supported_block_types" method on the "ledger" canister. +func (a Agent) Icrc3SupportedBlockTypes() (*[]struct { + BlockType string `ic:"block_type" json:"block_type"` + Url string `ic:"url" json:"url"` +}, error) { + var r0 []struct { + BlockType string `ic:"block_type" json:"block_type"` + Url string `ic:"url" json:"url"` + } + if err := a.a.Query( + a.canisterId, + "icrc3_supported_block_types", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +type Allowance struct { + Allowance idl.Nat `ic:"allowance" json:"allowance"` + ExpiresAt *Timestamp `ic:"expires_at,omitempty" json:"expires_at,omitempty"` +} + +type AllowanceArgs struct { + Account Account `ic:"account" json:"account"` + Spender Account `ic:"spender" json:"spender"` +} + +type Approve struct { + Fee *idl.Nat `ic:"fee,omitempty" json:"fee,omitempty"` + From Account `ic:"from" json:"from"` + Memo *[]byte `ic:"memo,omitempty" json:"memo,omitempty"` + CreatedAtTime *Timestamp `ic:"created_at_time,omitempty" json:"created_at_time,omitempty"` + Amount idl.Nat `ic:"amount" json:"amount"` + ExpectedAllowance *idl.Nat `ic:"expected_allowance,omitempty" json:"expected_allowance,omitempty"` + ExpiresAt *Timestamp `ic:"expires_at,omitempty" json:"expires_at,omitempty"` + Spender Account `ic:"spender" json:"spender"` +} + +type ApproveArgs struct { + Fee *idl.Nat `ic:"fee,omitempty" json:"fee,omitempty"` + Memo *[]byte `ic:"memo,omitempty" json:"memo,omitempty"` + FromSubaccount *[]byte `ic:"from_subaccount,omitempty" json:"from_subaccount,omitempty"` + CreatedAtTime *Timestamp `ic:"created_at_time,omitempty" json:"created_at_time,omitempty"` + Amount idl.Nat `ic:"amount" json:"amount"` + ExpectedAllowance *idl.Nat `ic:"expected_allowance,omitempty" json:"expected_allowance,omitempty"` + ExpiresAt *Timestamp `ic:"expires_at,omitempty" json:"expires_at,omitempty"` + Spender Account `ic:"spender" json:"spender"` +} + +type ApproveError struct { + GenericError *struct { + Message string `ic:"message" json:"message"` + ErrorCode idl.Nat `ic:"error_code" json:"error_code"` + } `ic:"GenericError,variant"` + TemporarilyUnavailable *idl.Null `ic:"TemporarilyUnavailable,variant"` + Duplicate *struct { + DuplicateOf BlockIndex `ic:"duplicate_of" json:"duplicate_of"` + } `ic:"Duplicate,variant"` + BadFee *struct { + ExpectedFee idl.Nat `ic:"expected_fee" json:"expected_fee"` + } `ic:"BadFee,variant"` + AllowanceChanged *struct { + CurrentAllowance idl.Nat `ic:"current_allowance" json:"current_allowance"` + } `ic:"AllowanceChanged,variant"` + CreatedInFuture *struct { + LedgerTime Timestamp `ic:"ledger_time" json:"ledger_time"` + } `ic:"CreatedInFuture,variant"` + TooOld *idl.Null `ic:"TooOld,variant"` + Expired *struct { + LedgerTime Timestamp `ic:"ledger_time" json:"ledger_time"` + } `ic:"Expired,variant"` + InsufficientFunds *struct { + Balance idl.Nat `ic:"balance" json:"balance"` + } `ic:"InsufficientFunds,variant"` +} + +type ApproveResult struct { + Ok *BlockIndex `ic:"Ok,variant"` + Err *ApproveError `ic:"Err,variant"` +} + +type ArchiveInfo struct { + CanisterId principal.Principal `ic:"canister_id" json:"canister_id"` + BlockRangeStart BlockIndex `ic:"block_range_start" json:"block_range_start"` + BlockRangeEnd BlockIndex `ic:"block_range_end" json:"block_range_end"` +} + +type Block = Value + +type BlockIndex = idl.Nat + +type BlockRange struct { + Blocks []Block `ic:"blocks" json:"blocks"` +} + +type Burn struct { + From Account `ic:"from" json:"from"` + Memo *[]byte `ic:"memo,omitempty" json:"memo,omitempty"` + CreatedAtTime *Timestamp `ic:"created_at_time,omitempty" json:"created_at_time,omitempty"` + Amount idl.Nat `ic:"amount" json:"amount"` + Spender *Account `ic:"spender,omitempty" json:"spender,omitempty"` +} + +type ChangeFeeCollector struct { + Unset *idl.Null `ic:"Unset,variant"` + SetTo *Account `ic:"SetTo,variant"` +} + +type DataCertificate struct { + Certificate *[]byte `ic:"certificate,omitempty" json:"certificate,omitempty"` + HashTree []byte `ic:"hash_tree" json:"hash_tree"` +} + +type Duration = uint64 + +type FeatureFlags struct { + Icrc2 bool `ic:"icrc2" json:"icrc2"` +} + +type GetArchivesArgs struct { + From *principal.Principal `ic:"from,omitempty" json:"from,omitempty"` +} + +type GetArchivesResult = []struct { + CanisterId principal.Principal `ic:"canister_id" json:"canister_id"` + Start idl.Nat `ic:"start" json:"start"` + End idl.Nat `ic:"end" json:"end"` +} + +type GetBlocksArgs struct { + Start BlockIndex `ic:"start" json:"start"` + Length idl.Nat `ic:"length" json:"length"` +} + +type GetBlocksResponse struct { + FirstIndex BlockIndex `ic:"first_index" json:"first_index"` + ChainLength uint64 `ic:"chain_length" json:"chain_length"` + Certificate *[]byte `ic:"certificate,omitempty" json:"certificate,omitempty"` + Blocks []Block `ic:"blocks" json:"blocks"` + ArchivedBlocks []struct { + Start BlockIndex `ic:"start" json:"start"` + Length idl.Nat `ic:"length" json:"length"` + Callback QueryBlockArchiveFn `ic:"callback" json:"callback"` + } `ic:"archived_blocks" json:"archived_blocks"` +} + +type GetTransactionsRequest struct { + Start TxIndex `ic:"start" json:"start"` + Length idl.Nat `ic:"length" json:"length"` +} + +type GetTransactionsResponse struct { + LogLength idl.Nat `ic:"log_length" json:"log_length"` + Transactions []Transaction `ic:"transactions" json:"transactions"` + FirstIndex TxIndex `ic:"first_index" json:"first_index"` + ArchivedTransactions []struct { + Start TxIndex `ic:"start" json:"start"` + Length idl.Nat `ic:"length" json:"length"` + Callback QueryArchiveFn `ic:"callback" json:"callback"` + } `ic:"archived_transactions" json:"archived_transactions"` +} + +type HttpRequest struct { + Url string `ic:"url" json:"url"` + Method string `ic:"method" json:"method"` + Body []byte `ic:"body" json:"body"` + Headers []struct { + Field0 string `ic:"0" json:"0"` + Field1 string `ic:"1" json:"1"` + } `ic:"headers" json:"headers"` +} + +type HttpResponse struct { + Body []byte `ic:"body" json:"body"` + Headers []struct { + Field0 string `ic:"0" json:"0"` + Field1 string `ic:"1" json:"1"` + } `ic:"headers" json:"headers"` + StatusCode uint16 `ic:"status_code" json:"status_code"` +} + +type ICRC3DataCertificate struct { + Certificate []byte `ic:"certificate" json:"certificate"` + HashTree []byte `ic:"hash_tree" json:"hash_tree"` +} + +type InitArgs struct { + MintingAccount Account `ic:"minting_account" json:"minting_account"` + FeeCollectorAccount *Account `ic:"fee_collector_account,omitempty" json:"fee_collector_account,omitempty"` + TransferFee idl.Nat `ic:"transfer_fee" json:"transfer_fee"` + Decimals *uint8 `ic:"decimals,omitempty" json:"decimals,omitempty"` + MaxMemoLength *uint16 `ic:"max_memo_length,omitempty" json:"max_memo_length,omitempty"` + TokenSymbol string `ic:"token_symbol" json:"token_symbol"` + TokenName string `ic:"token_name" json:"token_name"` + Metadata []struct { + Field0 string `ic:"0" json:"0"` + Field1 MetadataValue `ic:"1" json:"1"` + } `ic:"metadata" json:"metadata"` + InitialBalances []struct { + Field0 Account `ic:"0" json:"0"` + Field1 idl.Nat `ic:"1" json:"1"` + } `ic:"initial_balances" json:"initial_balances"` + FeatureFlags *FeatureFlags `ic:"feature_flags,omitempty" json:"feature_flags,omitempty"` + MaximumNumberOfAccounts *uint64 `ic:"maximum_number_of_accounts,omitempty" json:"maximum_number_of_accounts,omitempty"` + AccountsOverflowTrimQuantity *uint64 `ic:"accounts_overflow_trim_quantity,omitempty" json:"accounts_overflow_trim_quantity,omitempty"` + ArchiveOptions struct { + NumBlocksToArchive uint64 `ic:"num_blocks_to_archive" json:"num_blocks_to_archive"` + MaxTransactionsPerResponse *uint64 `ic:"max_transactions_per_response,omitempty" json:"max_transactions_per_response,omitempty"` + TriggerThreshold uint64 `ic:"trigger_threshold" json:"trigger_threshold"` + MaxMessageSizeBytes *uint64 `ic:"max_message_size_bytes,omitempty" json:"max_message_size_bytes,omitempty"` + CyclesForArchiveCreation *uint64 `ic:"cycles_for_archive_creation,omitempty" json:"cycles_for_archive_creation,omitempty"` + NodeMaxMemorySizeBytes *uint64 `ic:"node_max_memory_size_bytes,omitempty" json:"node_max_memory_size_bytes,omitempty"` + ControllerId principal.Principal `ic:"controller_id" json:"controller_id"` + MoreControllerIds *[]principal.Principal `ic:"more_controller_ids,omitempty" json:"more_controller_ids,omitempty"` + } `ic:"archive_options" json:"archive_options"` +} + +type LedgerArg struct { + Init *InitArgs `ic:"Init,variant"` + Upgrade **UpgradeArgs `ic:"Upgrade,variant"` +} + +type Map = []struct { + Field0 string `ic:"0" json:"0"` + Field1 Value `ic:"1" json:"1"` +} + +type MetadataValue struct { + Nat *idl.Nat `ic:"Nat,variant"` + Int *idl.Int `ic:"Int,variant"` + Text *string `ic:"Text,variant"` + Blob *[]byte `ic:"Blob,variant"` +} + +type Mint struct { + To Account `ic:"to" json:"to"` + Memo *[]byte `ic:"memo,omitempty" json:"memo,omitempty"` + CreatedAtTime *Timestamp `ic:"created_at_time,omitempty" json:"created_at_time,omitempty"` + Amount idl.Nat `ic:"amount" json:"amount"` +} + +type QueryArchiveFn struct { /* NOT SUPPORTED */ +} + +type QueryBlockArchiveFn struct { /* NOT SUPPORTED */ +} + +type StandardRecord struct { + Url string `ic:"url" json:"url"` + Name string `ic:"name" json:"name"` +} + +type Subaccount = []byte + +type Timestamp = uint64 + +type Tokens = idl.Nat + +type Transaction struct { + Burn *Burn `ic:"burn,omitempty" json:"burn,omitempty"` + Kind string `ic:"kind" json:"kind"` + Mint *Mint `ic:"mint,omitempty" json:"mint,omitempty"` + Approve *Approve `ic:"approve,omitempty" json:"approve,omitempty"` + Timestamp Timestamp `ic:"timestamp" json:"timestamp"` + Transfer *Transfer `ic:"transfer,omitempty" json:"transfer,omitempty"` +} + +type TransactionRange struct { + Transactions []Transaction `ic:"transactions" json:"transactions"` +} + +type Transfer struct { + To Account `ic:"to" json:"to"` + Fee *idl.Nat `ic:"fee,omitempty" json:"fee,omitempty"` + From Account `ic:"from" json:"from"` + Memo *[]byte `ic:"memo,omitempty" json:"memo,omitempty"` + CreatedAtTime *Timestamp `ic:"created_at_time,omitempty" json:"created_at_time,omitempty"` + Amount idl.Nat `ic:"amount" json:"amount"` + Spender *Account `ic:"spender,omitempty" json:"spender,omitempty"` +} + +type TransferArg struct { + FromSubaccount *Subaccount `ic:"from_subaccount,omitempty" json:"from_subaccount,omitempty"` + To Account `ic:"to" json:"to"` + Amount Tokens `ic:"amount" json:"amount"` + Fee *Tokens `ic:"fee,omitempty" json:"fee,omitempty"` + Memo *[]byte `ic:"memo,omitempty" json:"memo,omitempty"` + CreatedAtTime *Timestamp `ic:"created_at_time,omitempty" json:"created_at_time,omitempty"` +} + +type TransferError struct { + BadFee *struct { + ExpectedFee Tokens `ic:"expected_fee" json:"expected_fee"` + } `ic:"BadFee,variant"` + BadBurn *struct { + MinBurnAmount Tokens `ic:"min_burn_amount" json:"min_burn_amount"` + } `ic:"BadBurn,variant"` + InsufficientFunds *struct { + Balance Tokens `ic:"balance" json:"balance"` + } `ic:"InsufficientFunds,variant"` + TooOld *idl.Null `ic:"TooOld,variant"` + CreatedInFuture *struct { + LedgerTime Timestamp `ic:"ledger_time" json:"ledger_time"` + } `ic:"CreatedInFuture,variant"` + TemporarilyUnavailable *idl.Null `ic:"TemporarilyUnavailable,variant"` + Duplicate *struct { + DuplicateOf BlockIndex `ic:"duplicate_of" json:"duplicate_of"` + } `ic:"Duplicate,variant"` + GenericError *struct { + ErrorCode idl.Nat `ic:"error_code" json:"error_code"` + Message string `ic:"message" json:"message"` + } `ic:"GenericError,variant"` +} + +type TransferFromArgs struct { + SpenderSubaccount *Subaccount `ic:"spender_subaccount,omitempty" json:"spender_subaccount,omitempty"` + From Account `ic:"from" json:"from"` + To Account `ic:"to" json:"to"` + Amount Tokens `ic:"amount" json:"amount"` + Fee *Tokens `ic:"fee,omitempty" json:"fee,omitempty"` + Memo *[]byte `ic:"memo,omitempty" json:"memo,omitempty"` + CreatedAtTime *Timestamp `ic:"created_at_time,omitempty" json:"created_at_time,omitempty"` +} + +type TransferFromError struct { + BadFee *struct { + ExpectedFee Tokens `ic:"expected_fee" json:"expected_fee"` + } `ic:"BadFee,variant"` + BadBurn *struct { + MinBurnAmount Tokens `ic:"min_burn_amount" json:"min_burn_amount"` + } `ic:"BadBurn,variant"` + InsufficientFunds *struct { + Balance Tokens `ic:"balance" json:"balance"` + } `ic:"InsufficientFunds,variant"` + InsufficientAllowance *struct { + Allowance Tokens `ic:"allowance" json:"allowance"` + } `ic:"InsufficientAllowance,variant"` + TooOld *idl.Null `ic:"TooOld,variant"` + CreatedInFuture *struct { + LedgerTime Timestamp `ic:"ledger_time" json:"ledger_time"` + } `ic:"CreatedInFuture,variant"` + Duplicate *struct { + DuplicateOf BlockIndex `ic:"duplicate_of" json:"duplicate_of"` + } `ic:"Duplicate,variant"` + TemporarilyUnavailable *idl.Null `ic:"TemporarilyUnavailable,variant"` + GenericError *struct { + ErrorCode idl.Nat `ic:"error_code" json:"error_code"` + Message string `ic:"message" json:"message"` + } `ic:"GenericError,variant"` +} + +type TransferFromResult struct { + Ok *BlockIndex `ic:"Ok,variant"` + Err *TransferFromError `ic:"Err,variant"` +} + +type TransferResult struct { + Ok *BlockIndex `ic:"Ok,variant"` + Err *TransferError `ic:"Err,variant"` +} + +type TxIndex = idl.Nat + +type UpgradeArgs struct { + Metadata *[]struct { + Field0 string `ic:"0" json:"0"` + Field1 MetadataValue `ic:"1" json:"1"` + } `ic:"metadata,omitempty" json:"metadata,omitempty"` + TokenSymbol *string `ic:"token_symbol,omitempty" json:"token_symbol,omitempty"` + TokenName *string `ic:"token_name,omitempty" json:"token_name,omitempty"` + TransferFee *idl.Nat `ic:"transfer_fee,omitempty" json:"transfer_fee,omitempty"` + ChangeFeeCollector *ChangeFeeCollector `ic:"change_fee_collector,omitempty" json:"change_fee_collector,omitempty"` + MaxMemoLength *uint16 `ic:"max_memo_length,omitempty" json:"max_memo_length,omitempty"` + FeatureFlags *FeatureFlags `ic:"feature_flags,omitempty" json:"feature_flags,omitempty"` + MaximumNumberOfAccounts *uint64 `ic:"maximum_number_of_accounts,omitempty" json:"maximum_number_of_accounts,omitempty"` + AccountsOverflowTrimQuantity *uint64 `ic:"accounts_overflow_trim_quantity,omitempty" json:"accounts_overflow_trim_quantity,omitempty"` +} + +type Value struct { + Blob *[]byte `ic:"Blob,variant"` + Text *string `ic:"Text,variant"` + Nat *idl.Nat `ic:"Nat,variant"` + Nat64 *uint64 `ic:"Nat64,variant"` + Int *idl.Int `ic:"Int,variant"` + Array *[]Value `ic:"Array,variant"` + Map *Map `ic:"Map,variant"` +} diff --git a/ic/sns/root/agent.go b/ic/sns/root/agent.go new file mode 100755 index 0000000..2a936a0 --- /dev/null +++ b/ic/sns/root/agent.go @@ -0,0 +1,297 @@ +// Package root provides a client for the "root" canister. +// Do NOT edit this file. It was automatically generated by https://github.com/aviate-labs/agent-go. +package root + +import ( + "github.com/aviate-labs/agent-go" + "github.com/aviate-labs/agent-go/candid/idl" + "github.com/aviate-labs/agent-go/principal" +) + +// Agent is a client for the "root" canister. +type Agent struct { + a *agent.Agent + canisterId principal.Principal +} + +// NewAgent creates a new agent for the "root" canister. +func NewAgent(canisterId principal.Principal, config agent.Config) (*Agent, error) { + a, err := agent.New(config) + if err != nil { + return nil, err + } + return &Agent{ + a: a, + canisterId: canisterId, + }, nil +} + +// CanisterStatus calls the "canister_status" method on the "root" canister. +func (a Agent) CanisterStatus(arg0 CanisterIdRecord) (*CanisterStatusResult, error) { + var r0 CanisterStatusResult + if err := a.a.Call( + a.canisterId, + "canister_status", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ChangeCanister calls the "change_canister" method on the "root" canister. +func (a Agent) ChangeCanister(arg0 ChangeCanisterRequest) error { + if err := a.a.Call( + a.canisterId, + "change_canister", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// GetBuildMetadata calls the "get_build_metadata" method on the "root" canister. +func (a Agent) GetBuildMetadata() (*string, error) { + var r0 string + if err := a.a.Query( + a.canisterId, + "get_build_metadata", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetSnsCanistersSummary calls the "get_sns_canisters_summary" method on the "root" canister. +func (a Agent) GetSnsCanistersSummary(arg0 GetSnsCanistersSummaryRequest) (*GetSnsCanistersSummaryResponse, error) { + var r0 GetSnsCanistersSummaryResponse + if err := a.a.Call( + a.canisterId, + "get_sns_canisters_summary", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ListSnsCanisters calls the "list_sns_canisters" method on the "root" canister. +func (a Agent) ListSnsCanisters(arg0 struct { +}) (*ListSnsCanistersResponse, error) { + var r0 ListSnsCanistersResponse + if err := a.a.Query( + a.canisterId, + "list_sns_canisters", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ManageDappCanisterSettings calls the "manage_dapp_canister_settings" method on the "root" canister. +func (a Agent) ManageDappCanisterSettings(arg0 ManageDappCanisterSettingsRequest) (*ManageDappCanisterSettingsResponse, error) { + var r0 ManageDappCanisterSettingsResponse + if err := a.a.Call( + a.canisterId, + "manage_dapp_canister_settings", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// RegisterDappCanister calls the "register_dapp_canister" method on the "root" canister. +func (a Agent) RegisterDappCanister(arg0 RegisterDappCanisterRequest) (*struct { +}, error) { + var r0 struct { + } + if err := a.a.Call( + a.canisterId, + "register_dapp_canister", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// RegisterDappCanisters calls the "register_dapp_canisters" method on the "root" canister. +func (a Agent) RegisterDappCanisters(arg0 RegisterDappCanistersRequest) (*struct { +}, error) { + var r0 struct { + } + if err := a.a.Call( + a.canisterId, + "register_dapp_canisters", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// SetDappControllers calls the "set_dapp_controllers" method on the "root" canister. +func (a Agent) SetDappControllers(arg0 SetDappControllersRequest) (*SetDappControllersResponse, error) { + var r0 SetDappControllersResponse + if err := a.a.Call( + a.canisterId, + "set_dapp_controllers", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +type CanisterCallError struct { + Code *int32 `ic:"code,omitempty" json:"code,omitempty"` + Description string `ic:"description" json:"description"` +} + +type CanisterIdRecord struct { + CanisterId principal.Principal `ic:"canister_id" json:"canister_id"` +} + +type CanisterInstallMode struct { + Reinstall *idl.Null `ic:"reinstall,variant"` + Upgrade *idl.Null `ic:"upgrade,variant"` + Install *idl.Null `ic:"install,variant"` +} + +type CanisterStatusResult struct { + Status CanisterStatusType `ic:"status" json:"status"` + MemorySize idl.Nat `ic:"memory_size" json:"memory_size"` + Cycles idl.Nat `ic:"cycles" json:"cycles"` + Settings DefiniteCanisterSettings `ic:"settings" json:"settings"` + IdleCyclesBurnedPerDay *idl.Nat `ic:"idle_cycles_burned_per_day,omitempty" json:"idle_cycles_burned_per_day,omitempty"` + ModuleHash *[]byte `ic:"module_hash,omitempty" json:"module_hash,omitempty"` + ReservedCycles *idl.Nat `ic:"reserved_cycles,omitempty" json:"reserved_cycles,omitempty"` +} + +type CanisterStatusResultV2 struct { + Status CanisterStatusType `ic:"status" json:"status"` + MemorySize idl.Nat `ic:"memory_size" json:"memory_size"` + Cycles idl.Nat `ic:"cycles" json:"cycles"` + Settings DefiniteCanisterSettingsArgs `ic:"settings" json:"settings"` + IdleCyclesBurnedPerDay idl.Nat `ic:"idle_cycles_burned_per_day" json:"idle_cycles_burned_per_day"` + ModuleHash *[]byte `ic:"module_hash,omitempty" json:"module_hash,omitempty"` +} + +type CanisterStatusType struct { + Stopped *idl.Null `ic:"stopped,variant"` + Stopping *idl.Null `ic:"stopping,variant"` + Running *idl.Null `ic:"running,variant"` +} + +type CanisterSummary struct { + Status *CanisterStatusResultV2 `ic:"status,omitempty" json:"status,omitempty"` + CanisterId *principal.Principal `ic:"canister_id,omitempty" json:"canister_id,omitempty"` +} + +type ChangeCanisterRequest struct { + Arg []byte `ic:"arg" json:"arg"` + WasmModule []byte `ic:"wasm_module" json:"wasm_module"` + StopBeforeInstalling bool `ic:"stop_before_installing" json:"stop_before_installing"` + Mode CanisterInstallMode `ic:"mode" json:"mode"` + CanisterId principal.Principal `ic:"canister_id" json:"canister_id"` + MemoryAllocation *idl.Nat `ic:"memory_allocation,omitempty" json:"memory_allocation,omitempty"` + ComputeAllocation *idl.Nat `ic:"compute_allocation,omitempty" json:"compute_allocation,omitempty"` +} + +type DefiniteCanisterSettings struct { + FreezingThreshold *idl.Nat `ic:"freezing_threshold,omitempty" json:"freezing_threshold,omitempty"` + Controllers []principal.Principal `ic:"controllers" json:"controllers"` + ReservedCyclesLimit *idl.Nat `ic:"reserved_cycles_limit,omitempty" json:"reserved_cycles_limit,omitempty"` + MemoryAllocation *idl.Nat `ic:"memory_allocation,omitempty" json:"memory_allocation,omitempty"` + ComputeAllocation *idl.Nat `ic:"compute_allocation,omitempty" json:"compute_allocation,omitempty"` +} + +type DefiniteCanisterSettingsArgs struct { + FreezingThreshold idl.Nat `ic:"freezing_threshold" json:"freezing_threshold"` + Controllers []principal.Principal `ic:"controllers" json:"controllers"` + MemoryAllocation idl.Nat `ic:"memory_allocation" json:"memory_allocation"` + ComputeAllocation idl.Nat `ic:"compute_allocation" json:"compute_allocation"` +} + +type FailedUpdate struct { + Err *CanisterCallError `ic:"err,omitempty" json:"err,omitempty"` + DappCanisterId *principal.Principal `ic:"dapp_canister_id,omitempty" json:"dapp_canister_id,omitempty"` +} + +type GetSnsCanistersSummaryRequest struct { + UpdateCanisterList *bool `ic:"update_canister_list,omitempty" json:"update_canister_list,omitempty"` +} + +type GetSnsCanistersSummaryResponse struct { + Root *CanisterSummary `ic:"root,omitempty" json:"root,omitempty"` + Swap *CanisterSummary `ic:"swap,omitempty" json:"swap,omitempty"` + Ledger *CanisterSummary `ic:"ledger,omitempty" json:"ledger,omitempty"` + Index *CanisterSummary `ic:"index,omitempty" json:"index,omitempty"` + Governance *CanisterSummary `ic:"governance,omitempty" json:"governance,omitempty"` + Dapps []CanisterSummary `ic:"dapps" json:"dapps"` + Archives []CanisterSummary `ic:"archives" json:"archives"` +} + +type ListSnsCanistersResponse struct { + Root *principal.Principal `ic:"root,omitempty" json:"root,omitempty"` + Swap *principal.Principal `ic:"swap,omitempty" json:"swap,omitempty"` + Ledger *principal.Principal `ic:"ledger,omitempty" json:"ledger,omitempty"` + Index *principal.Principal `ic:"index,omitempty" json:"index,omitempty"` + Governance *principal.Principal `ic:"governance,omitempty" json:"governance,omitempty"` + Dapps []principal.Principal `ic:"dapps" json:"dapps"` + Archives []principal.Principal `ic:"archives" json:"archives"` +} + +type ManageDappCanisterSettingsRequest struct { + FreezingThreshold *uint64 `ic:"freezing_threshold,omitempty" json:"freezing_threshold,omitempty"` + CanisterIds []principal.Principal `ic:"canister_ids" json:"canister_ids"` + ReservedCyclesLimit *uint64 `ic:"reserved_cycles_limit,omitempty" json:"reserved_cycles_limit,omitempty"` + LogVisibility *int32 `ic:"log_visibility,omitempty" json:"log_visibility,omitempty"` + MemoryAllocation *uint64 `ic:"memory_allocation,omitempty" json:"memory_allocation,omitempty"` + ComputeAllocation *uint64 `ic:"compute_allocation,omitempty" json:"compute_allocation,omitempty"` +} + +type ManageDappCanisterSettingsResponse struct { + FailureReason *string `ic:"failure_reason,omitempty" json:"failure_reason,omitempty"` +} + +type RegisterDappCanisterRequest struct { + CanisterId *principal.Principal `ic:"canister_id,omitempty" json:"canister_id,omitempty"` +} + +type RegisterDappCanistersRequest struct { + CanisterIds []principal.Principal `ic:"canister_ids" json:"canister_ids"` +} + +type SetDappControllersRequest struct { + CanisterIds *RegisterDappCanistersRequest `ic:"canister_ids,omitempty" json:"canister_ids,omitempty"` + ControllerPrincipalIds []principal.Principal `ic:"controller_principal_ids" json:"controller_principal_ids"` +} + +type SetDappControllersResponse struct { + FailedUpdates []FailedUpdate `ic:"failed_updates" json:"failed_updates"` +} + +type SnsRootCanister struct { + DappCanisterIds []principal.Principal `ic:"dapp_canister_ids" json:"dapp_canister_ids"` + Testflight bool `ic:"testflight" json:"testflight"` + LatestLedgerArchivePollTimestampSeconds *uint64 `ic:"latest_ledger_archive_poll_timestamp_seconds,omitempty" json:"latest_ledger_archive_poll_timestamp_seconds,omitempty"` + ArchiveCanisterIds []principal.Principal `ic:"archive_canister_ids" json:"archive_canister_ids"` + GovernanceCanisterId *principal.Principal `ic:"governance_canister_id,omitempty" json:"governance_canister_id,omitempty"` + IndexCanisterId *principal.Principal `ic:"index_canister_id,omitempty" json:"index_canister_id,omitempty"` + SwapCanisterId *principal.Principal `ic:"swap_canister_id,omitempty" json:"swap_canister_id,omitempty"` + LedgerCanisterId *principal.Principal `ic:"ledger_canister_id,omitempty" json:"ledger_canister_id,omitempty"` +} diff --git a/ic/sns/sns_test.go b/ic/sns/sns_test.go new file mode 100644 index 0000000..60d811e --- /dev/null +++ b/ic/sns/sns_test.go @@ -0,0 +1,34 @@ +package sns + +import ( + "bytes" + "github.com/aviate-labs/agent-go" + "github.com/aviate-labs/agent-go/ic" + "github.com/aviate-labs/agent-go/ic/sns/root" + "testing" +) + +func TestSNS(t *testing.T) { + snsAgent, err := NewAgent(ic.SNS_WASM_PRINCIPAL, agent.DefaultConfig) + if err != nil { + t.Fatal(err) + } + snsList, err := snsAgent.ListDeployedSnses(struct{}{}) + if err != nil { + t.Fatal(err) + } + sns1Instances := snsList.Instances[0] + rootAgent, err := root.NewAgent(*sns1Instances.RootCanisterId, agent.DefaultConfig) + if err != nil { + t.Fatal(err) + } + canisterStatus, err := rootAgent.CanisterStatus(root.CanisterIdRecord{ + CanisterId: *sns1Instances.RootCanisterId, + }) + if err != nil { + t.Fatal(err) + } + if len(canisterStatus.Settings.Controllers) != 1 || !bytes.Equal(canisterStatus.Settings.Controllers[0].Raw, sns1Instances.GovernanceCanisterId.Raw) { + t.Fatalf("unexpected controllers: %v", canisterStatus.Settings.Controllers) + } +} diff --git a/ic/sns/swap/agent.go b/ic/sns/swap/agent.go new file mode 100755 index 0000000..0f24812 --- /dev/null +++ b/ic/sns/swap/agent.go @@ -0,0 +1,762 @@ +// Package swap provides a client for the "swap" canister. +// Do NOT edit this file. It was automatically generated by https://github.com/aviate-labs/agent-go. +package swap + +import ( + "github.com/aviate-labs/agent-go" + "github.com/aviate-labs/agent-go/candid/idl" + "github.com/aviate-labs/agent-go/principal" +) + +// Agent is a client for the "swap" canister. +type Agent struct { + a *agent.Agent + canisterId principal.Principal +} + +// NewAgent creates a new agent for the "swap" canister. +func NewAgent(canisterId principal.Principal, config agent.Config) (*Agent, error) { + a, err := agent.New(config) + if err != nil { + return nil, err + } + return &Agent{ + a: a, + canisterId: canisterId, + }, nil +} + +// ErrorRefundIcp calls the "error_refund_icp" method on the "swap" canister. +func (a Agent) ErrorRefundIcp(arg0 ErrorRefundIcpRequest) (*ErrorRefundIcpResponse, error) { + var r0 ErrorRefundIcpResponse + if err := a.a.Call( + a.canisterId, + "error_refund_icp", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// FinalizeSwap calls the "finalize_swap" method on the "swap" canister. +func (a Agent) FinalizeSwap(arg0 struct { +}) (*FinalizeSwapResponse, error) { + var r0 FinalizeSwapResponse + if err := a.a.Call( + a.canisterId, + "finalize_swap", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetAutoFinalizationStatus calls the "get_auto_finalization_status" method on the "swap" canister. +func (a Agent) GetAutoFinalizationStatus(arg0 struct { +}) (*GetAutoFinalizationStatusResponse, error) { + var r0 GetAutoFinalizationStatusResponse + if err := a.a.Query( + a.canisterId, + "get_auto_finalization_status", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetBuyerState calls the "get_buyer_state" method on the "swap" canister. +func (a Agent) GetBuyerState(arg0 GetBuyerStateRequest) (*GetBuyerStateResponse, error) { + var r0 GetBuyerStateResponse + if err := a.a.Query( + a.canisterId, + "get_buyer_state", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetBuyersTotal calls the "get_buyers_total" method on the "swap" canister. +func (a Agent) GetBuyersTotal(arg0 struct { +}) (*GetBuyersTotalResponse, error) { + var r0 GetBuyersTotalResponse + if err := a.a.Call( + a.canisterId, + "get_buyers_total", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetCanisterStatus calls the "get_canister_status" method on the "swap" canister. +func (a Agent) GetCanisterStatus(arg0 struct { +}) (*CanisterStatusResultV2, error) { + var r0 CanisterStatusResultV2 + if err := a.a.Call( + a.canisterId, + "get_canister_status", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetDerivedState calls the "get_derived_state" method on the "swap" canister. +func (a Agent) GetDerivedState(arg0 struct { +}) (*GetDerivedStateResponse, error) { + var r0 GetDerivedStateResponse + if err := a.a.Query( + a.canisterId, + "get_derived_state", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetInit calls the "get_init" method on the "swap" canister. +func (a Agent) GetInit(arg0 struct { +}) (*GetInitResponse, error) { + var r0 GetInitResponse + if err := a.a.Query( + a.canisterId, + "get_init", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetLifecycle calls the "get_lifecycle" method on the "swap" canister. +func (a Agent) GetLifecycle(arg0 struct { +}) (*GetLifecycleResponse, error) { + var r0 GetLifecycleResponse + if err := a.a.Query( + a.canisterId, + "get_lifecycle", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetOpenTicket calls the "get_open_ticket" method on the "swap" canister. +func (a Agent) GetOpenTicket(arg0 struct { +}) (*GetOpenTicketResponse, error) { + var r0 GetOpenTicketResponse + if err := a.a.Query( + a.canisterId, + "get_open_ticket", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetSaleParameters calls the "get_sale_parameters" method on the "swap" canister. +func (a Agent) GetSaleParameters(arg0 struct { +}) (*GetSaleParametersResponse, error) { + var r0 GetSaleParametersResponse + if err := a.a.Query( + a.canisterId, + "get_sale_parameters", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetState calls the "get_state" method on the "swap" canister. +func (a Agent) GetState(arg0 struct { +}) (*GetStateResponse, error) { + var r0 GetStateResponse + if err := a.a.Query( + a.canisterId, + "get_state", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ListCommunityFundParticipants calls the "list_community_fund_participants" method on the "swap" canister. +func (a Agent) ListCommunityFundParticipants(arg0 ListCommunityFundParticipantsRequest) (*NeuronsFundParticipants, error) { + var r0 NeuronsFundParticipants + if err := a.a.Query( + a.canisterId, + "list_community_fund_participants", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ListDirectParticipants calls the "list_direct_participants" method on the "swap" canister. +func (a Agent) ListDirectParticipants(arg0 ListDirectParticipantsRequest) (*ListDirectParticipantsResponse, error) { + var r0 ListDirectParticipantsResponse + if err := a.a.Query( + a.canisterId, + "list_direct_participants", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ListSnsNeuronRecipes calls the "list_sns_neuron_recipes" method on the "swap" canister. +func (a Agent) ListSnsNeuronRecipes(arg0 ListSnsNeuronRecipesRequest) (*ListSnsNeuronRecipesResponse, error) { + var r0 ListSnsNeuronRecipesResponse + if err := a.a.Query( + a.canisterId, + "list_sns_neuron_recipes", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// NewSaleTicket calls the "new_sale_ticket" method on the "swap" canister. +func (a Agent) NewSaleTicket(arg0 NewSaleTicketRequest) (*NewSaleTicketResponse, error) { + var r0 NewSaleTicketResponse + if err := a.a.Call( + a.canisterId, + "new_sale_ticket", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// NotifyPaymentFailure calls the "notify_payment_failure" method on the "swap" canister. +func (a Agent) NotifyPaymentFailure(arg0 struct { +}) (*Ok2, error) { + var r0 Ok2 + if err := a.a.Call( + a.canisterId, + "notify_payment_failure", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Open calls the "open" method on the "swap" canister. +func (a Agent) Open(arg0 OpenRequest) (*struct { +}, error) { + var r0 struct { + } + if err := a.a.Call( + a.canisterId, + "open", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// RefreshBuyerTokens calls the "refresh_buyer_tokens" method on the "swap" canister. +func (a Agent) RefreshBuyerTokens(arg0 RefreshBuyerTokensRequest) (*RefreshBuyerTokensResponse, error) { + var r0 RefreshBuyerTokensResponse + if err := a.a.Call( + a.canisterId, + "refresh_buyer_tokens", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// RestoreDappControllers calls the "restore_dapp_controllers" method on the "swap" canister. +func (a Agent) RestoreDappControllers(arg0 struct { +}) (*SetDappControllersCallResult, error) { + var r0 SetDappControllersCallResult + if err := a.a.Call( + a.canisterId, + "restore_dapp_controllers", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +type BuyerState struct { + Icp *TransferableAmount `ic:"icp,omitempty" json:"icp,omitempty"` + HasCreatedNeuronRecipes *bool `ic:"has_created_neuron_recipes,omitempty" json:"has_created_neuron_recipes,omitempty"` +} + +type CanisterCallError struct { + Code *int32 `ic:"code,omitempty" json:"code,omitempty"` + Description string `ic:"description" json:"description"` +} + +type CanisterStatusResultV2 struct { + Status CanisterStatusType `ic:"status" json:"status"` + MemorySize idl.Nat `ic:"memory_size" json:"memory_size"` + Cycles idl.Nat `ic:"cycles" json:"cycles"` + Settings DefiniteCanisterSettingsArgs `ic:"settings" json:"settings"` + IdleCyclesBurnedPerDay idl.Nat `ic:"idle_cycles_burned_per_day" json:"idle_cycles_burned_per_day"` + ModuleHash *[]byte `ic:"module_hash,omitempty" json:"module_hash,omitempty"` +} + +type CanisterStatusType struct { + Stopped *idl.Null `ic:"stopped,variant"` + Stopping *idl.Null `ic:"stopping,variant"` + Running *idl.Null `ic:"running,variant"` +} + +type CfInvestment struct { + HotkeyPrincipal string `ic:"hotkey_principal" json:"hotkey_principal"` + NnsNeuronId uint64 `ic:"nns_neuron_id" json:"nns_neuron_id"` +} + +type CfNeuron struct { + HasCreatedNeuronRecipes *bool `ic:"has_created_neuron_recipes,omitempty" json:"has_created_neuron_recipes,omitempty"` + NnsNeuronId uint64 `ic:"nns_neuron_id" json:"nns_neuron_id"` + AmountIcpE8s uint64 `ic:"amount_icp_e8s" json:"amount_icp_e8s"` +} + +type CfParticipant struct { + HotkeyPrincipal string `ic:"hotkey_principal" json:"hotkey_principal"` + CfNeurons []CfNeuron `ic:"cf_neurons" json:"cf_neurons"` +} + +type Countries struct { + IsoCodes []string `ic:"iso_codes" json:"iso_codes"` +} + +type DefiniteCanisterSettingsArgs struct { + FreezingThreshold idl.Nat `ic:"freezing_threshold" json:"freezing_threshold"` + Controllers []principal.Principal `ic:"controllers" json:"controllers"` + MemoryAllocation idl.Nat `ic:"memory_allocation" json:"memory_allocation"` + ComputeAllocation idl.Nat `ic:"compute_allocation" json:"compute_allocation"` +} + +type DerivedState struct { + SnsTokensPerIcp float32 `ic:"sns_tokens_per_icp" json:"sns_tokens_per_icp"` + BuyerTotalIcpE8s uint64 `ic:"buyer_total_icp_e8s" json:"buyer_total_icp_e8s"` + CfParticipantCount *uint64 `ic:"cf_participant_count,omitempty" json:"cf_participant_count,omitempty"` + NeuronsFundParticipationIcpE8s *uint64 `ic:"neurons_fund_participation_icp_e8s,omitempty" json:"neurons_fund_participation_icp_e8s,omitempty"` + DirectParticipationIcpE8s *uint64 `ic:"direct_participation_icp_e8s,omitempty" json:"direct_participation_icp_e8s,omitempty"` + DirectParticipantCount *uint64 `ic:"direct_participant_count,omitempty" json:"direct_participant_count,omitempty"` + CfNeuronCount *uint64 `ic:"cf_neuron_count,omitempty" json:"cf_neuron_count,omitempty"` +} + +type DirectInvestment struct { + BuyerPrincipal string `ic:"buyer_principal" json:"buyer_principal"` +} + +type Err struct { + Description *string `ic:"description,omitempty" json:"description,omitempty"` + ErrorType *int32 `ic:"error_type,omitempty" json:"error_type,omitempty"` +} + +type Err1 struct { + ErrorType *int32 `ic:"error_type,omitempty" json:"error_type,omitempty"` +} + +type Err2 struct { + InvalidUserAmount *InvalidUserAmount `ic:"invalid_user_amount,omitempty" json:"invalid_user_amount,omitempty"` + ExistingTicket *Ticket `ic:"existing_ticket,omitempty" json:"existing_ticket,omitempty"` + ErrorType int32 `ic:"error_type" json:"error_type"` +} + +type Error struct { + Message *string `ic:"message,omitempty" json:"message,omitempty"` +} + +type ErrorRefundIcpRequest struct { + SourcePrincipalId *principal.Principal `ic:"source_principal_id,omitempty" json:"source_principal_id,omitempty"` +} + +type ErrorRefundIcpResponse struct { + Result *Result `ic:"result,omitempty" json:"result,omitempty"` +} + +type FailedUpdate struct { + Err *CanisterCallError `ic:"err,omitempty" json:"err,omitempty"` + DappCanisterId *principal.Principal `ic:"dapp_canister_id,omitempty" json:"dapp_canister_id,omitempty"` +} + +type FinalizeSwapResponse struct { + SetDappControllersCallResult *SetDappControllersCallResult `ic:"set_dapp_controllers_call_result,omitempty" json:"set_dapp_controllers_call_result,omitempty"` + CreateSnsNeuronRecipesResult *SweepResult `ic:"create_sns_neuron_recipes_result,omitempty" json:"create_sns_neuron_recipes_result,omitempty"` + SettleCommunityFundParticipationResult *SettleCommunityFundParticipationResult `ic:"settle_community_fund_participation_result,omitempty" json:"settle_community_fund_participation_result,omitempty"` + ErrorMessage *string `ic:"error_message,omitempty" json:"error_message,omitempty"` + SettleNeuronsFundParticipationResult *SettleNeuronsFundParticipationResult `ic:"settle_neurons_fund_participation_result,omitempty" json:"settle_neurons_fund_participation_result,omitempty"` + SetModeCallResult *SetModeCallResult `ic:"set_mode_call_result,omitempty" json:"set_mode_call_result,omitempty"` + SweepIcpResult *SweepResult `ic:"sweep_icp_result,omitempty" json:"sweep_icp_result,omitempty"` + ClaimNeuronResult *SweepResult `ic:"claim_neuron_result,omitempty" json:"claim_neuron_result,omitempty"` + SweepSnsResult *SweepResult `ic:"sweep_sns_result,omitempty" json:"sweep_sns_result,omitempty"` +} + +type GetAutoFinalizationStatusResponse struct { + AutoFinalizeSwapResponse *FinalizeSwapResponse `ic:"auto_finalize_swap_response,omitempty" json:"auto_finalize_swap_response,omitempty"` + HasAutoFinalizeBeenAttempted *bool `ic:"has_auto_finalize_been_attempted,omitempty" json:"has_auto_finalize_been_attempted,omitempty"` + IsAutoFinalizeEnabled *bool `ic:"is_auto_finalize_enabled,omitempty" json:"is_auto_finalize_enabled,omitempty"` +} + +type GetBuyerStateRequest struct { + PrincipalId *principal.Principal `ic:"principal_id,omitempty" json:"principal_id,omitempty"` +} + +type GetBuyerStateResponse struct { + BuyerState *BuyerState `ic:"buyer_state,omitempty" json:"buyer_state,omitempty"` +} + +type GetBuyersTotalResponse struct { + BuyersTotal uint64 `ic:"buyers_total" json:"buyers_total"` +} + +type GetDerivedStateResponse struct { + SnsTokensPerIcp *float64 `ic:"sns_tokens_per_icp,omitempty" json:"sns_tokens_per_icp,omitempty"` + BuyerTotalIcpE8s *uint64 `ic:"buyer_total_icp_e8s,omitempty" json:"buyer_total_icp_e8s,omitempty"` + CfParticipantCount *uint64 `ic:"cf_participant_count,omitempty" json:"cf_participant_count,omitempty"` + NeuronsFundParticipationIcpE8s *uint64 `ic:"neurons_fund_participation_icp_e8s,omitempty" json:"neurons_fund_participation_icp_e8s,omitempty"` + DirectParticipationIcpE8s *uint64 `ic:"direct_participation_icp_e8s,omitempty" json:"direct_participation_icp_e8s,omitempty"` + DirectParticipantCount *uint64 `ic:"direct_participant_count,omitempty" json:"direct_participant_count,omitempty"` + CfNeuronCount *uint64 `ic:"cf_neuron_count,omitempty" json:"cf_neuron_count,omitempty"` +} + +type GetInitResponse struct { + Init *Init `ic:"init,omitempty" json:"init,omitempty"` +} + +type GetLifecycleResponse struct { + DecentralizationSaleOpenTimestampSeconds *uint64 `ic:"decentralization_sale_open_timestamp_seconds,omitempty" json:"decentralization_sale_open_timestamp_seconds,omitempty"` + Lifecycle *int32 `ic:"lifecycle,omitempty" json:"lifecycle,omitempty"` + DecentralizationSwapTerminationTimestampSeconds *uint64 `ic:"decentralization_swap_termination_timestamp_seconds,omitempty" json:"decentralization_swap_termination_timestamp_seconds,omitempty"` +} + +type GetOpenTicketResponse struct { + Result *Result1 `ic:"result,omitempty" json:"result,omitempty"` +} + +type GetSaleParametersResponse struct { + Params *Params `ic:"params,omitempty" json:"params,omitempty"` +} + +type GetStateResponse struct { + Swap *Swap `ic:"swap,omitempty" json:"swap,omitempty"` + Derived *DerivedState `ic:"derived,omitempty" json:"derived,omitempty"` +} + +type GovernanceError struct { + ErrorMessage string `ic:"error_message" json:"error_message"` + ErrorType int32 `ic:"error_type" json:"error_type"` +} + +type Icrc1Account struct { + Owner *principal.Principal `ic:"owner,omitempty" json:"owner,omitempty"` + Subaccount *[]byte `ic:"subaccount,omitempty" json:"subaccount,omitempty"` +} + +type IdealMatchedParticipationFunction struct { + SerializedRepresentation *string `ic:"serialized_representation,omitempty" json:"serialized_representation,omitempty"` +} + +type Init struct { + NnsProposalId *uint64 `ic:"nns_proposal_id,omitempty" json:"nns_proposal_id,omitempty"` + SnsRootCanisterId string `ic:"sns_root_canister_id" json:"sns_root_canister_id"` + NeuronsFundParticipation *bool `ic:"neurons_fund_participation,omitempty" json:"neurons_fund_participation,omitempty"` + MinParticipantIcpE8s *uint64 `ic:"min_participant_icp_e8s,omitempty" json:"min_participant_icp_e8s,omitempty"` + NeuronBasketConstructionParameters *NeuronBasketConstructionParameters `ic:"neuron_basket_construction_parameters,omitempty" json:"neuron_basket_construction_parameters,omitempty"` + FallbackControllerPrincipalIds []string `ic:"fallback_controller_principal_ids" json:"fallback_controller_principal_ids"` + MaxIcpE8s *uint64 `ic:"max_icp_e8s,omitempty" json:"max_icp_e8s,omitempty"` + NeuronMinimumStakeE8s *uint64 `ic:"neuron_minimum_stake_e8s,omitempty" json:"neuron_minimum_stake_e8s,omitempty"` + ConfirmationText *string `ic:"confirmation_text,omitempty" json:"confirmation_text,omitempty"` + SwapStartTimestampSeconds *uint64 `ic:"swap_start_timestamp_seconds,omitempty" json:"swap_start_timestamp_seconds,omitempty"` + SwapDueTimestampSeconds *uint64 `ic:"swap_due_timestamp_seconds,omitempty" json:"swap_due_timestamp_seconds,omitempty"` + MinParticipants *uint32 `ic:"min_participants,omitempty" json:"min_participants,omitempty"` + SnsTokenE8s *uint64 `ic:"sns_token_e8s,omitempty" json:"sns_token_e8s,omitempty"` + NnsGovernanceCanisterId string `ic:"nns_governance_canister_id" json:"nns_governance_canister_id"` + TransactionFeeE8s *uint64 `ic:"transaction_fee_e8s,omitempty" json:"transaction_fee_e8s,omitempty"` + IcpLedgerCanisterId string `ic:"icp_ledger_canister_id" json:"icp_ledger_canister_id"` + SnsLedgerCanisterId string `ic:"sns_ledger_canister_id" json:"sns_ledger_canister_id"` + NeuronsFundParticipationConstraints *NeuronsFundParticipationConstraints `ic:"neurons_fund_participation_constraints,omitempty" json:"neurons_fund_participation_constraints,omitempty"` + NeuronsFundParticipants *NeuronsFundParticipants `ic:"neurons_fund_participants,omitempty" json:"neurons_fund_participants,omitempty"` + ShouldAutoFinalize *bool `ic:"should_auto_finalize,omitempty" json:"should_auto_finalize,omitempty"` + MaxParticipantIcpE8s *uint64 `ic:"max_participant_icp_e8s,omitempty" json:"max_participant_icp_e8s,omitempty"` + SnsGovernanceCanisterId string `ic:"sns_governance_canister_id" json:"sns_governance_canister_id"` + MinDirectParticipationIcpE8s *uint64 `ic:"min_direct_participation_icp_e8s,omitempty" json:"min_direct_participation_icp_e8s,omitempty"` + RestrictedCountries *Countries `ic:"restricted_countries,omitempty" json:"restricted_countries,omitempty"` + MinIcpE8s *uint64 `ic:"min_icp_e8s,omitempty" json:"min_icp_e8s,omitempty"` + MaxDirectParticipationIcpE8s *uint64 `ic:"max_direct_participation_icp_e8s,omitempty" json:"max_direct_participation_icp_e8s,omitempty"` +} + +type InvalidUserAmount struct { + MinAmountIcpE8sIncluded uint64 `ic:"min_amount_icp_e8s_included" json:"min_amount_icp_e8s_included"` + MaxAmountIcpE8sIncluded uint64 `ic:"max_amount_icp_e8s_included" json:"max_amount_icp_e8s_included"` +} + +type Investor struct { + CommunityFund *CfInvestment `ic:"CommunityFund,variant"` + Direct *DirectInvestment `ic:"Direct,variant"` +} + +type LinearScalingCoefficient struct { + SlopeNumerator *uint64 `ic:"slope_numerator,omitempty" json:"slope_numerator,omitempty"` + InterceptIcpE8s *uint64 `ic:"intercept_icp_e8s,omitempty" json:"intercept_icp_e8s,omitempty"` + FromDirectParticipationIcpE8s *uint64 `ic:"from_direct_participation_icp_e8s,omitempty" json:"from_direct_participation_icp_e8s,omitempty"` + SlopeDenominator *uint64 `ic:"slope_denominator,omitempty" json:"slope_denominator,omitempty"` + ToDirectParticipationIcpE8s *uint64 `ic:"to_direct_participation_icp_e8s,omitempty" json:"to_direct_participation_icp_e8s,omitempty"` +} + +type ListCommunityFundParticipantsRequest struct { + Offset *uint64 `ic:"offset,omitempty" json:"offset,omitempty"` + Limit *uint32 `ic:"limit,omitempty" json:"limit,omitempty"` +} + +type ListDirectParticipantsRequest struct { + Offset *uint32 `ic:"offset,omitempty" json:"offset,omitempty"` + Limit *uint32 `ic:"limit,omitempty" json:"limit,omitempty"` +} + +type ListDirectParticipantsResponse struct { + Participants []Participant `ic:"participants" json:"participants"` +} + +type ListSnsNeuronRecipesRequest struct { + Offset *uint64 `ic:"offset,omitempty" json:"offset,omitempty"` + Limit *uint32 `ic:"limit,omitempty" json:"limit,omitempty"` +} + +type ListSnsNeuronRecipesResponse struct { + SnsNeuronRecipes []SnsNeuronRecipe `ic:"sns_neuron_recipes" json:"sns_neuron_recipes"` +} + +type NeuronAttributes struct { + DissolveDelaySeconds uint64 `ic:"dissolve_delay_seconds" json:"dissolve_delay_seconds"` + Memo uint64 `ic:"memo" json:"memo"` + Followees []NeuronId `ic:"followees" json:"followees"` +} + +type NeuronBasketConstructionParameters struct { + DissolveDelayIntervalSeconds uint64 `ic:"dissolve_delay_interval_seconds" json:"dissolve_delay_interval_seconds"` + Count uint64 `ic:"count" json:"count"` +} + +type NeuronId struct { + Id []byte `ic:"id" json:"id"` +} + +type NeuronsFundParticipants struct { + CfParticipants []CfParticipant `ic:"cf_participants" json:"cf_participants"` +} + +type NeuronsFundParticipationConstraints struct { + CoefficientIntervals []LinearScalingCoefficient `ic:"coefficient_intervals" json:"coefficient_intervals"` + MaxNeuronsFundParticipationIcpE8s *uint64 `ic:"max_neurons_fund_participation_icp_e8s,omitempty" json:"max_neurons_fund_participation_icp_e8s,omitempty"` + MinDirectParticipationThresholdIcpE8s *uint64 `ic:"min_direct_participation_threshold_icp_e8s,omitempty" json:"min_direct_participation_threshold_icp_e8s,omitempty"` + IdealMatchedParticipationFunction *IdealMatchedParticipationFunction `ic:"ideal_matched_participation_function,omitempty" json:"ideal_matched_participation_function,omitempty"` +} + +type NewSaleTicketRequest struct { + Subaccount *[]byte `ic:"subaccount,omitempty" json:"subaccount,omitempty"` + AmountIcpE8s uint64 `ic:"amount_icp_e8s" json:"amount_icp_e8s"` +} + +type NewSaleTicketResponse struct { + Result *Result2 `ic:"result,omitempty" json:"result,omitempty"` +} + +type Ok struct { + BlockHeight *uint64 `ic:"block_height,omitempty" json:"block_height,omitempty"` +} + +type Ok1 struct { + NeuronsFundParticipationIcpE8s *uint64 `ic:"neurons_fund_participation_icp_e8s,omitempty" json:"neurons_fund_participation_icp_e8s,omitempty"` + NeuronsFundNeuronsCount *uint64 `ic:"neurons_fund_neurons_count,omitempty" json:"neurons_fund_neurons_count,omitempty"` +} + +type Ok2 struct { + Ticket *Ticket `ic:"ticket,omitempty" json:"ticket,omitempty"` +} + +type OpenRequest struct { + CfParticipants []CfParticipant `ic:"cf_participants" json:"cf_participants"` + Params *Params `ic:"params,omitempty" json:"params,omitempty"` + OpenSnsTokenSwapProposalId *uint64 `ic:"open_sns_token_swap_proposal_id,omitempty" json:"open_sns_token_swap_proposal_id,omitempty"` +} + +type Params struct { + MinParticipantIcpE8s uint64 `ic:"min_participant_icp_e8s" json:"min_participant_icp_e8s"` + NeuronBasketConstructionParameters *NeuronBasketConstructionParameters `ic:"neuron_basket_construction_parameters,omitempty" json:"neuron_basket_construction_parameters,omitempty"` + MaxIcpE8s uint64 `ic:"max_icp_e8s" json:"max_icp_e8s"` + SwapDueTimestampSeconds uint64 `ic:"swap_due_timestamp_seconds" json:"swap_due_timestamp_seconds"` + MinParticipants uint32 `ic:"min_participants" json:"min_participants"` + SnsTokenE8s uint64 `ic:"sns_token_e8s" json:"sns_token_e8s"` + SaleDelaySeconds *uint64 `ic:"sale_delay_seconds,omitempty" json:"sale_delay_seconds,omitempty"` + MaxParticipantIcpE8s uint64 `ic:"max_participant_icp_e8s" json:"max_participant_icp_e8s"` + MinDirectParticipationIcpE8s *uint64 `ic:"min_direct_participation_icp_e8s,omitempty" json:"min_direct_participation_icp_e8s,omitempty"` + MinIcpE8s uint64 `ic:"min_icp_e8s" json:"min_icp_e8s"` + MaxDirectParticipationIcpE8s *uint64 `ic:"max_direct_participation_icp_e8s,omitempty" json:"max_direct_participation_icp_e8s,omitempty"` +} + +type Participant struct { + Participation *BuyerState `ic:"participation,omitempty" json:"participation,omitempty"` + ParticipantId *principal.Principal `ic:"participant_id,omitempty" json:"participant_id,omitempty"` +} + +type Possibility struct { + Ok *SetDappControllersResponse `ic:"Ok,variant"` + Err *CanisterCallError `ic:"Err,variant"` +} + +type Possibility1 struct { + Ok *Response `ic:"Ok,variant"` + Err *CanisterCallError `ic:"Err,variant"` +} + +type Possibility2 struct { + Ok *Ok1 `ic:"Ok,variant"` + Err *Error `ic:"Err,variant"` +} + +type Possibility3 struct { + Ok *struct { + } `ic:"Ok,variant"` + Err *CanisterCallError `ic:"Err,variant"` +} + +type RefreshBuyerTokensRequest struct { + ConfirmationText *string `ic:"confirmation_text,omitempty" json:"confirmation_text,omitempty"` + Buyer string `ic:"buyer" json:"buyer"` +} + +type RefreshBuyerTokensResponse struct { + IcpAcceptedParticipationE8s uint64 `ic:"icp_accepted_participation_e8s" json:"icp_accepted_participation_e8s"` + IcpLedgerAccountBalanceE8s uint64 `ic:"icp_ledger_account_balance_e8s" json:"icp_ledger_account_balance_e8s"` +} + +type Response struct { + GovernanceError *GovernanceError `ic:"governance_error,omitempty" json:"governance_error,omitempty"` +} + +type Result struct { + Ok *Ok `ic:"Ok,variant"` + Err *Err `ic:"Err,variant"` +} + +type Result1 struct { + Ok *Ok2 `ic:"Ok,variant"` + Err *Err1 `ic:"Err,variant"` +} + +type Result2 struct { + Ok *Ok2 `ic:"Ok,variant"` + Err *Err2 `ic:"Err,variant"` +} + +type SetDappControllersCallResult struct { + Possibility *Possibility `ic:"possibility,omitempty" json:"possibility,omitempty"` +} + +type SetDappControllersResponse struct { + FailedUpdates []FailedUpdate `ic:"failed_updates" json:"failed_updates"` +} + +type SetModeCallResult struct { + Possibility *Possibility3 `ic:"possibility,omitempty" json:"possibility,omitempty"` +} + +type SettleCommunityFundParticipationResult struct { + Possibility *Possibility1 `ic:"possibility,omitempty" json:"possibility,omitempty"` +} + +type SettleNeuronsFundParticipationResult struct { + Possibility *Possibility2 `ic:"possibility,omitempty" json:"possibility,omitempty"` +} + +type SnsNeuronRecipe struct { + Sns *TransferableAmount `ic:"sns,omitempty" json:"sns,omitempty"` + ClaimedStatus *int32 `ic:"claimed_status,omitempty" json:"claimed_status,omitempty"` + NeuronAttributes *NeuronAttributes `ic:"neuron_attributes,omitempty" json:"neuron_attributes,omitempty"` + Investor *Investor `ic:"investor,omitempty" json:"investor,omitempty"` +} + +type Swap struct { + AutoFinalizeSwapResponse *FinalizeSwapResponse `ic:"auto_finalize_swap_response,omitempty" json:"auto_finalize_swap_response,omitempty"` + NeuronRecipes []SnsNeuronRecipe `ic:"neuron_recipes" json:"neuron_recipes"` + NextTicketId *uint64 `ic:"next_ticket_id,omitempty" json:"next_ticket_id,omitempty"` + DecentralizationSaleOpenTimestampSeconds *uint64 `ic:"decentralization_sale_open_timestamp_seconds,omitempty" json:"decentralization_sale_open_timestamp_seconds,omitempty"` + FinalizeSwapInProgress *bool `ic:"finalize_swap_in_progress,omitempty" json:"finalize_swap_in_progress,omitempty"` + CfParticipants []CfParticipant `ic:"cf_participants" json:"cf_participants"` + Init *Init `ic:"init,omitempty" json:"init,omitempty"` + AlreadyTriedToAutoFinalize *bool `ic:"already_tried_to_auto_finalize,omitempty" json:"already_tried_to_auto_finalize,omitempty"` + NeuronsFundParticipationIcpE8s *uint64 `ic:"neurons_fund_participation_icp_e8s,omitempty" json:"neurons_fund_participation_icp_e8s,omitempty"` + PurgeOldTicketsLastCompletionTimestampNanoseconds *uint64 `ic:"purge_old_tickets_last_completion_timestamp_nanoseconds,omitempty" json:"purge_old_tickets_last_completion_timestamp_nanoseconds,omitempty"` + DirectParticipationIcpE8s *uint64 `ic:"direct_participation_icp_e8s,omitempty" json:"direct_participation_icp_e8s,omitempty"` + Lifecycle int32 `ic:"lifecycle" json:"lifecycle"` + PurgeOldTicketsNextPrincipal *[]byte `ic:"purge_old_tickets_next_principal,omitempty" json:"purge_old_tickets_next_principal,omitempty"` + DecentralizationSwapTerminationTimestampSeconds *uint64 `ic:"decentralization_swap_termination_timestamp_seconds,omitempty" json:"decentralization_swap_termination_timestamp_seconds,omitempty"` + Buyers []struct { + Field0 string `ic:"0" json:"0"` + Field1 BuyerState `ic:"1" json:"1"` + } `ic:"buyers" json:"buyers"` + Params *Params `ic:"params,omitempty" json:"params,omitempty"` + OpenSnsTokenSwapProposalId *uint64 `ic:"open_sns_token_swap_proposal_id,omitempty" json:"open_sns_token_swap_proposal_id,omitempty"` +} + +type SweepResult struct { + Failure uint32 `ic:"failure" json:"failure"` + Skipped uint32 `ic:"skipped" json:"skipped"` + Invalid uint32 `ic:"invalid" json:"invalid"` + Success uint32 `ic:"success" json:"success"` + GlobalFailures uint32 `ic:"global_failures" json:"global_failures"` +} + +type Ticket struct { + CreationTime uint64 `ic:"creation_time" json:"creation_time"` + TicketId uint64 `ic:"ticket_id" json:"ticket_id"` + Account *Icrc1Account `ic:"account,omitempty" json:"account,omitempty"` + AmountIcpE8s uint64 `ic:"amount_icp_e8s" json:"amount_icp_e8s"` +} + +type TransferableAmount struct { + TransferFeePaidE8s *uint64 `ic:"transfer_fee_paid_e8s,omitempty" json:"transfer_fee_paid_e8s,omitempty"` + TransferStartTimestampSeconds uint64 `ic:"transfer_start_timestamp_seconds" json:"transfer_start_timestamp_seconds"` + AmountE8s uint64 `ic:"amount_e8s" json:"amount_e8s"` + AmountTransferredE8s *uint64 `ic:"amount_transferred_e8s,omitempty" json:"amount_transferred_e8s,omitempty"` + TransferSuccessTimestampSeconds uint64 `ic:"transfer_success_timestamp_seconds" json:"transfer_success_timestamp_seconds"` +} diff --git a/ic/sns/testdata/did/governance.did b/ic/sns/testdata/did/governance.did new file mode 100644 index 0000000..51bb1a2 --- /dev/null +++ b/ic/sns/testdata/did/governance.did @@ -0,0 +1,262 @@ +type BatchId = nat; +type ChunkId = nat; +type Key = text; +type Time = int; + +type CreateAssetArguments = record { + key: Key; + content_type: text; + max_age: opt nat64; + headers: opt vec HeaderField; + enable_aliasing: opt bool; + allow_raw_access: opt bool; +}; + +// Add or change content for an asset, by content encoding +type SetAssetContentArguments = record { + key: Key; + content_encoding: text; + chunk_ids: vec ChunkId; + sha256: opt blob; +}; + +// Remove content for an asset, by content encoding +type UnsetAssetContentArguments = record { + key: Key; + content_encoding: text; +}; + +// Delete an asset +type DeleteAssetArguments = record { + key: Key; +}; + +// Reset everything +type ClearArguments = record {}; + +type BatchOperationKind = variant { + CreateAsset: CreateAssetArguments; + SetAssetContent: SetAssetContentArguments; + + SetAssetProperties: SetAssetPropertiesArguments; + + UnsetAssetContent: UnsetAssetContentArguments; + DeleteAsset: DeleteAssetArguments; + + Clear: ClearArguments; +}; + +type CommitBatchArguments = record { + batch_id: BatchId; + operations: vec BatchOperationKind +}; + +type CommitProposedBatchArguments = record { + batch_id: BatchId; + evidence: blob; +}; + +type ComputeEvidenceArguments = record { + batch_id: BatchId; + max_iterations: opt nat16 +}; + +type DeleteBatchArguments = record { + batch_id: BatchId; +}; + +type HeaderField = record { text; text; }; + +type HttpRequest = record { + method: text; + url: text; + headers: vec HeaderField; + body: blob; + certificate_version: opt nat16; +}; + +type HttpResponse = record { + status_code: nat16; + headers: vec HeaderField; + body: blob; + streaming_strategy: opt StreamingStrategy; +}; + +type StreamingCallbackHttpResponse = record { + body: blob; + token: opt StreamingCallbackToken; +}; + +type StreamingCallbackToken = record { + key: Key; + content_encoding: text; + index: nat; + sha256: opt blob; +}; + +type StreamingStrategy = variant { + Callback: record { + callback: func (StreamingCallbackToken) -> (opt StreamingCallbackHttpResponse) query; + token: StreamingCallbackToken; + }; +}; + +type SetAssetPropertiesArguments = record { + key: Key; + max_age: opt opt nat64; + headers: opt opt vec HeaderField; + allow_raw_access: opt opt bool; + is_aliased: opt opt bool; +}; + +type ConfigurationResponse = record { + max_batches: opt nat64; + max_chunks: opt nat64; + max_bytes: opt nat64; +}; + +type ConfigureArguments = record { + max_batches: opt opt nat64; + max_chunks: opt opt nat64; + max_bytes: opt opt nat64; +}; + +type Permission = variant { + Commit; + ManagePermissions; + Prepare; +}; + +type GrantPermission = record { + to_principal: principal; + permission: Permission; +}; +type RevokePermission = record { + of_principal: principal; + permission: Permission; +}; +type ListPermitted = record { permission: Permission }; + +type ValidationResult = variant { Ok : text; Err : text }; + +type AssetCanisterArgs = variant { + Init: InitArgs; + Upgrade: UpgradeArgs; +}; + +type InitArgs = record {}; + +type UpgradeArgs = record { + set_permissions: opt SetPermissions; +}; + +/// Sets the list of principals granted each permission. +type SetPermissions = record { + prepare: vec principal; + commit: vec principal; + manage_permissions: vec principal; +}; + +service: (asset_canister_args: opt AssetCanisterArgs) -> { + api_version: () -> (nat16) query; + + get: (record { + key: Key; + accept_encodings: vec text; + }) -> (record { + content: blob; // may be the entirety of the content, or just chunk index 0 + content_type: text; + content_encoding: text; + sha256: opt blob; // sha256 of entire asset encoding, calculated by dfx and passed in SetAssetContentArguments + total_length: nat; // all chunks except last have size == content.size() + }) query; + + // if get() returned chunks > 1, call this to retrieve them. + // chunks may or may not be split up at the same boundaries as presented to create_chunk(). + get_chunk: (record { + key: Key; + content_encoding: text; + index: nat; + sha256: opt blob; // sha256 of entire asset encoding, calculated by dfx and passed in SetAssetContentArguments + }) -> (record { content: blob }) query; + + list : (record {}) -> (vec record { + key: Key; + content_type: text; + encodings: vec record { + content_encoding: text; + sha256: opt blob; // sha256 of entire asset encoding, calculated by dfx and passed in SetAssetContentArguments + length: nat; // Size of this encoding's blob. Calculated when uploading assets. + modified: Time; + }; + }) query; + + certified_tree : (record {}) -> (record { + certificate: blob; + tree: blob; + }) query; + + create_batch : (record {}) -> (record { batch_id: BatchId }); + + create_chunk: (record { batch_id: BatchId; content: blob }) -> (record { chunk_id: ChunkId }); + + // Perform all operations successfully, or reject + commit_batch: (CommitBatchArguments) -> (); + + // Save the batch operations for later commit + propose_commit_batch: (CommitBatchArguments) -> (); + + // Given a batch already proposed, perform all operations successfully, or reject + commit_proposed_batch: (CommitProposedBatchArguments) -> (); + + // Compute a hash over the CommitBatchArguments. Call until it returns Some(evidence). + compute_evidence: (ComputeEvidenceArguments) -> (opt blob); + + // Delete a batch that has been created, or proposed for commit, but not yet committed + delete_batch: (DeleteBatchArguments) -> (); + + create_asset: (CreateAssetArguments) -> (); + set_asset_content: (SetAssetContentArguments) -> (); + unset_asset_content: (UnsetAssetContentArguments) -> (); + + delete_asset: (DeleteAssetArguments) -> (); + + clear: (ClearArguments) -> (); + + // Single call to create an asset with content for a single content encoding that + // fits within the message ingress limit. + store: (record { + key: Key; + content_type: text; + content_encoding: text; + content: blob; + sha256: opt blob + }) -> (); + + http_request: (request: HttpRequest) -> (HttpResponse) query; + http_request_streaming_callback: (token: StreamingCallbackToken) -> (opt StreamingCallbackHttpResponse) query; + + authorize: (principal) -> (); + deauthorize: (principal) -> (); + list_authorized: () -> (vec principal); + grant_permission: (GrantPermission) -> (); + revoke_permission: (RevokePermission) -> (); + list_permitted: (ListPermitted) -> (vec principal); + take_ownership: () -> (); + + get_asset_properties : (key: Key) -> (record { + max_age: opt nat64; + headers: opt vec HeaderField; + allow_raw_access: opt bool; + is_aliased: opt bool; } ) query; + set_asset_properties: (SetAssetPropertiesArguments) -> (); + + get_configuration: () -> (ConfigurationResponse); + configure: (ConfigureArguments) -> (); + + validate_grant_permission: (GrantPermission) -> (ValidationResult); + validate_revoke_permission: (RevokePermission) -> (ValidationResult); + validate_take_ownership: () -> (ValidationResult); + validate_commit_proposed_batch: (CommitProposedBatchArguments) -> (ValidationResult); + validate_configure: (ConfigureArguments) -> (ValidationResult); +} diff --git a/ic/sns/testdata/did/index.did b/ic/sns/testdata/did/index.did new file mode 100644 index 0000000..a6b35d0 --- /dev/null +++ b/ic/sns/testdata/did/index.did @@ -0,0 +1,96 @@ +type TxId = nat; + +type Account = record { owner : principal; subaccount : opt blob }; + +type SubAccount = blob; + +type Transaction = record { + burn : opt Burn; + kind : text; + mint : opt Mint; + approve : opt Approve; + timestamp : nat64; + transfer : opt Transfer; +}; + +type Approve = record { + fee : opt nat; + from : Account; + memo : opt vec nat8; + created_at_time : opt nat64; + amount : nat; + expected_allowance : opt nat; + expires_at : opt nat64; + spender : Account; +}; + +type Burn = record { + from : Account; + memo : opt vec nat8; + created_at_time : opt nat64; + amount : nat; + spender : opt Account; +}; + +type Mint = record { + to : Account; + memo : opt vec nat8; + created_at_time : opt nat64; + amount : nat; +}; + +type Transfer = record { + to : Account; + fee : opt nat; + from : Account; + memo : opt vec nat8; + created_at_time : opt nat64; + amount : nat; + spender : opt Account; +}; + +type GetAccountTransactionsArgs = record { + account : Account; + // The txid of the last transaction seen by the client. + // If None then the results will start from the most recent + // txid. + start : opt TxId; + // Maximum number of transactions to fetch. + max_results : nat; +}; + +type TransactionWithId = record { + id : TxId; + transaction : Transaction; +}; + +type GetTransactions = record { + transactions : vec TransactionWithId; + // The txid of the oldest transaction the account has + oldest_tx_id : opt TxId; +}; + +type GetTransactionsErr = record { + message : text; +}; + +type GetTransactionsResult = variant { + Ok : GetTransactions; + Err : GetTransactionsErr; +}; + +type ListSubaccountsArgs = record { + owner: principal; + start: opt SubAccount; +}; + +// The initialization parameters of the Index canister. +type InitArgs = record { + ledger_id : principal; +}; + +service : (InitArgs) -> { + get_account_transactions : (GetAccountTransactionsArgs) -> (GetTransactionsResult); + ledger_id : () -> (principal) query; + list_subaccounts : (ListSubaccountsArgs) -> (vec SubAccount) query; +} diff --git a/ic/sns/testdata/did/ledger.did b/ic/sns/testdata/did/ledger.did new file mode 100644 index 0000000..c8cc56b --- /dev/null +++ b/ic/sns/testdata/did/ledger.did @@ -0,0 +1,418 @@ +type BlockIndex = nat; +type Subaccount = blob; +// Number of nanoseconds since the UNIX epoch in UTC timezone. +type Timestamp = nat64; +// Number of nanoseconds between two [Timestamp]s. +type Duration = nat64; +type Tokens = nat; +type TxIndex = nat; +type Allowance = record { allowance : nat; expires_at : opt Timestamp }; +type AllowanceArgs = record { account : Account; spender : Account }; +type Approve = record { + fee : opt nat; + from : Account; + memo : opt blob; + created_at_time : opt Timestamp; + amount : nat; + expected_allowance : opt nat; + expires_at : opt Timestamp; + spender : Account; +}; +type ApproveArgs = record { + fee : opt nat; + memo : opt blob; + from_subaccount : opt blob; + created_at_time : opt Timestamp; + amount : nat; + expected_allowance : opt nat; + expires_at : opt Timestamp; + spender : Account; +}; +type ApproveError = variant { + GenericError : record { message : text; error_code : nat }; + TemporarilyUnavailable; + Duplicate : record { duplicate_of : BlockIndex }; + BadFee : record { expected_fee : nat }; + AllowanceChanged : record { current_allowance : nat }; + CreatedInFuture : record { ledger_time : Timestamp }; + TooOld; + Expired : record { ledger_time : Timestamp }; + InsufficientFunds : record { balance : nat }; +}; +type ApproveResult = variant { Ok : BlockIndex; Err : ApproveError }; + +type HttpRequest = record { + url : text; + method : text; + body : blob; + headers : vec record { text; text }; +}; +type HttpResponse = record { + body : blob; + headers : vec record { text; text }; + status_code : nat16; +}; + +type Account = record { + owner : principal; + subaccount : opt Subaccount; +}; + +type TransferArg = record { + from_subaccount : opt Subaccount; + to : Account; + amount : Tokens; + fee : opt Tokens; + memo : opt blob; + created_at_time: opt Timestamp; +}; + +type TransferError = variant { + BadFee : record { expected_fee : Tokens }; + BadBurn : record { min_burn_amount : Tokens }; + InsufficientFunds : record { balance : Tokens }; + TooOld; + CreatedInFuture : record { ledger_time : Timestamp }; + TemporarilyUnavailable; + Duplicate : record { duplicate_of : BlockIndex }; + GenericError : record { error_code : nat; message : text }; +}; + +type TransferResult = variant { + Ok : BlockIndex; + Err : TransferError; +}; + +// The value returned from the [icrc1_metadata] endpoint. +type MetadataValue = variant { + Nat : nat; + Int : int; + Text : text; + Blob : blob; +}; + +type FeatureFlags = record { + icrc2 : bool; +}; + +// The initialization parameters of the Ledger +type InitArgs = record { + minting_account : Account; + fee_collector_account : opt Account; + transfer_fee : nat; + decimals : opt nat8; + max_memo_length : opt nat16; + token_symbol : text; + token_name : text; + metadata : vec record { text; MetadataValue }; + initial_balances : vec record { Account; nat }; + feature_flags : opt FeatureFlags; + maximum_number_of_accounts : opt nat64; + accounts_overflow_trim_quantity : opt nat64; + archive_options : record { + num_blocks_to_archive : nat64; + max_transactions_per_response : opt nat64; + trigger_threshold : nat64; + max_message_size_bytes : opt nat64; + cycles_for_archive_creation : opt nat64; + node_max_memory_size_bytes : opt nat64; + controller_id : principal; + more_controller_ids : opt vec principal; + }; +}; + +type ChangeFeeCollector = variant { + Unset; SetTo: Account; +}; + +type UpgradeArgs = record { + metadata : opt vec record { text; MetadataValue }; + token_symbol : opt text; + token_name : opt text; + transfer_fee : opt nat; + change_fee_collector : opt ChangeFeeCollector; + max_memo_length : opt nat16; + feature_flags : opt FeatureFlags; + maximum_number_of_accounts: opt nat64; + accounts_overflow_trim_quantity: opt nat64; +}; + +type LedgerArg = variant { + Init: InitArgs; + Upgrade: opt UpgradeArgs; +}; + +type GetTransactionsRequest = record { + // The index of the first tx to fetch. + start : TxIndex; + // The number of transactions to fetch. + length : nat; +}; + +type GetTransactionsResponse = record { + // The total number of transactions in the log. + log_length : nat; + + // List of transaction that were available in the ledger when it processed the call. + // + // The transactions form a contiguous range, with the first transaction having index + // [first_index] (see below), and the last transaction having index + // [first_index] + len(transactions) - 1. + // + // The transaction range can be an arbitrary sub-range of the originally requested range. + transactions : vec Transaction; + + // The index of the first transaction in [transactions]. + // If the transaction vector is empty, the exact value of this field is not specified. + first_index : TxIndex; + + // Encoding of instructions for fetching archived transactions whose indices fall into the + // requested range. + // + // For each entry `e` in [archived_transactions], `[e.from, e.from + len)` is a sub-range + // of the originally requested transaction range. + archived_transactions : vec record { + // The index of the first archived transaction you can fetch using the [callback]. + start : TxIndex; + + // The number of transactions you can fetch using the callback. + length : nat; + + // The function you should call to fetch the archived transactions. + // The range of the transaction accessible using this function is given by [from] + // and [len] fields above. + callback : QueryArchiveFn; + }; +}; + + +// A prefix of the transaction range specified in the [GetTransactionsRequest] request. +type TransactionRange = record { + // A prefix of the requested transaction range. + // The index of the first transaction is equal to [GetTransactionsRequest.from]. + // + // Note that the number of transactions might be less than the requested + // [GetTransactionsRequest.length] for various reasons, for example: + // + // 1. The query might have hit the replica with an outdated state + // that doesn't have the whole range yet. + // 2. The requested range is too large to fit into a single reply. + // + // NOTE: the list of transactions can be empty if: + // + // 1. [GetTransactionsRequest.length] was zero. + // 2. [GetTransactionsRequest.from] was larger than the last transaction known to + // the canister. + transactions : vec Transaction; +}; + +// A function for fetching archived transaction. +type QueryArchiveFn = func (GetTransactionsRequest) -> (TransactionRange) query; + +type Transaction = record { + burn : opt Burn; + kind : text; + mint : opt Mint; + approve : opt Approve; + timestamp : Timestamp; + transfer : opt Transfer; +}; + +type Burn = record { + from : Account; + memo : opt blob; + created_at_time : opt Timestamp; + amount : nat; + spender : opt Account; +}; + +type Mint = record { + to : Account; + memo : opt blob; + created_at_time : opt Timestamp; + amount : nat; +}; + +type Transfer = record { + to : Account; + fee : opt nat; + from : Account; + memo : opt blob; + created_at_time : opt Timestamp; + amount : nat; + spender : opt Account; +}; + +type Value = variant { + Blob : blob; + Text : text; + Nat : nat; + Nat64: nat64; + Int : int; + Array : vec Value; + Map : Map; +}; + +type Map = vec record { text; Value }; + +type Block = Value; + +type GetBlocksArgs = record { + // The index of the first block to fetch. + start : BlockIndex; + // Max number of blocks to fetch. + length : nat; +}; + +// A prefix of the block range specified in the [GetBlocksArgs] request. +type BlockRange = record { + // A prefix of the requested block range. + // The index of the first block is equal to [GetBlocksArgs.start]. + // + // Note that the number of blocks might be less than the requested + // [GetBlocksArgs.length] for various reasons, for example: + // + // 1. The query might have hit the replica with an outdated state + // that doesn't have the whole range yet. + // 2. The requested range is too large to fit into a single reply. + // + // NOTE: the list of blocks can be empty if: + // + // 1. [GetBlocksArgs.length] was zero. + // 2. [GetBlocksArgs.start] was larger than the last block known to + // the canister. + blocks : vec Block; +}; + +// A function for fetching archived blocks. +type QueryBlockArchiveFn = func (GetBlocksArgs) -> (BlockRange) query; + +// The result of a "get_blocks" call. +type GetBlocksResponse = record { + // The index of the first block in "blocks". + // If the blocks vector is empty, the exact value of this field is not specified. + first_index : BlockIndex; + + // The total number of blocks in the chain. + // If the chain length is positive, the index of the last block is `chain_len - 1`. + chain_length : nat64; + + // System certificate for the hash of the latest block in the chain. + // Only present if `get_blocks` is called in a non-replicated query context. + certificate : opt blob; + + // List of blocks that were available in the ledger when it processed the call. + // + // The blocks form a contiguous range, with the first block having index + // [first_block_index] (see below), and the last block having index + // [first_block_index] + len(blocks) - 1. + // + // The block range can be an arbitrary sub-range of the originally requested range. + blocks : vec Block; + + // Encoding of instructions for fetching archived blocks. + archived_blocks : vec record { + // The index of the first archived block. + start : BlockIndex; + + // The number of blocks that can be fetched. + length : nat; + + // Callback to fetch the archived blocks. + callback : QueryBlockArchiveFn; + }; +}; + +// Certificate for the block at `block_index`. +type DataCertificate = record { + certificate : opt blob; + hash_tree : blob; +}; + +type StandardRecord = record { url : text; name : text }; + +type TransferFromArgs = record { + spender_subaccount : opt Subaccount; + from : Account; + to : Account; + amount : Tokens; + fee : opt Tokens; + memo : opt blob; + created_at_time: opt Timestamp; +}; + +type TransferFromResult = variant { + Ok : BlockIndex; + Err : TransferFromError; +}; + +type TransferFromError = variant { + BadFee : record { expected_fee : Tokens }; + BadBurn : record { min_burn_amount : Tokens }; + InsufficientFunds : record { balance : Tokens }; + InsufficientAllowance : record { allowance : Tokens }; + TooOld; + CreatedInFuture : record { ledger_time : Timestamp }; + Duplicate : record { duplicate_of : BlockIndex }; + TemporarilyUnavailable; + GenericError : record { error_code : nat; message : text }; +}; + +type ArchiveInfo = record { + canister_id: principal; + block_range_start: BlockIndex; + block_range_end: BlockIndex; +}; + +type GetArchivesArgs = record { + // The last archive seen by the client. + // The Ledger will return archives coming + // after this one if set, otherwise it + // will return the first archives. + from : opt principal; +}; + +type GetArchivesResult = vec record { + // The id of the archive + canister_id : principal; + + // The first block in the archive + start : nat; + + // The last block in the archive + end : nat; +}; + +type ICRC3DataCertificate = record { + // See https://internetcomputer.org/docs/current/references/ic-interface-spec#certification + certificate : blob; + + // CBOR encoded hash_tree + hash_tree : blob; +}; + +service : (ledger_arg : LedgerArg) -> { + archives : () -> (vec ArchiveInfo) query; + get_transactions : (GetTransactionsRequest) -> (GetTransactionsResponse) query; + get_blocks : (GetBlocksArgs) -> (GetBlocksResponse) query; + get_data_certificate : () -> (DataCertificate) query; + + icrc1_name : () -> (text) query; + icrc1_symbol : () -> (text) query; + icrc1_decimals : () -> (nat8) query; + icrc1_metadata : () -> (vec record { text; MetadataValue }) query; + icrc1_total_supply : () -> (Tokens) query; + icrc1_fee : () -> (Tokens) query; + icrc1_minting_account : () -> (opt Account) query; + icrc1_balance_of : (Account) -> (Tokens) query; + icrc1_transfer : (TransferArg) -> (TransferResult); + icrc1_supported_standards : () -> (vec StandardRecord) query; + + icrc2_approve : (ApproveArgs) -> (ApproveResult); + icrc2_allowance : (AllowanceArgs) -> (Allowance) query; + icrc2_transfer_from : (TransferFromArgs) -> (TransferFromResult); + + icrc3_get_archives : (GetArchivesArgs) -> (GetArchivesResult) query; + icrc3_get_tip_certificate : () -> (opt ICRC3DataCertificate) query; + icrc3_supported_block_types : () -> (vec record { block_type : text; url : text }) query; +} diff --git a/ic/sns/testdata/did/root.did b/ic/sns/testdata/did/root.did new file mode 100644 index 0000000..da738d6 --- /dev/null +++ b/ic/sns/testdata/did/root.did @@ -0,0 +1,113 @@ +type CanisterCallError = record { code : opt int32; description : text }; +type CanisterIdRecord = record { canister_id : principal }; +type CanisterInstallMode = variant { reinstall; upgrade; install }; +type CanisterStatusResult = record { + status : CanisterStatusType; + memory_size : nat; + cycles : nat; + settings : DefiniteCanisterSettings; + idle_cycles_burned_per_day : opt nat; + module_hash : opt blob; + reserved_cycles : opt nat; +}; +type CanisterStatusResultV2 = record { + status : CanisterStatusType; + memory_size : nat; + cycles : nat; + settings : DefiniteCanisterSettingsArgs; + idle_cycles_burned_per_day : nat; + module_hash : opt blob; +}; +type CanisterStatusType = variant { stopped; stopping; running }; +type CanisterSummary = record { + status : opt CanisterStatusResultV2; + canister_id : opt principal; +}; +type ChangeCanisterRequest = record { + arg : blob; + wasm_module : blob; + stop_before_installing : bool; + mode : CanisterInstallMode; + canister_id : principal; + memory_allocation : opt nat; + compute_allocation : opt nat; +}; +type DefiniteCanisterSettings = record { + freezing_threshold : opt nat; + controllers : vec principal; + reserved_cycles_limit : opt nat; + memory_allocation : opt nat; + compute_allocation : opt nat; +}; +type DefiniteCanisterSettingsArgs = record { + freezing_threshold : nat; + controllers : vec principal; + memory_allocation : nat; + compute_allocation : nat; +}; +type FailedUpdate = record { + err : opt CanisterCallError; + dapp_canister_id : opt principal; +}; +type GetSnsCanistersSummaryRequest = record { update_canister_list : opt bool }; +type GetSnsCanistersSummaryResponse = record { + root : opt CanisterSummary; + swap : opt CanisterSummary; + ledger : opt CanisterSummary; + index : opt CanisterSummary; + governance : opt CanisterSummary; + dapps : vec CanisterSummary; + archives : vec CanisterSummary; +}; +type ListSnsCanistersResponse = record { + root : opt principal; + swap : opt principal; + ledger : opt principal; + index : opt principal; + governance : opt principal; + dapps : vec principal; + archives : vec principal; +}; +type ManageDappCanisterSettingsRequest = record { + freezing_threshold : opt nat64; + canister_ids : vec principal; + reserved_cycles_limit : opt nat64; + log_visibility : opt int32; + memory_allocation : opt nat64; + compute_allocation : opt nat64; +}; +type ManageDappCanisterSettingsResponse = record { failure_reason : opt text }; +type RegisterDappCanisterRequest = record { canister_id : opt principal }; +type RegisterDappCanistersRequest = record { canister_ids : vec principal }; +type SetDappControllersRequest = record { + canister_ids : opt RegisterDappCanistersRequest; + controller_principal_ids : vec principal; +}; +type SetDappControllersResponse = record { failed_updates : vec FailedUpdate }; +type SnsRootCanister = record { + dapp_canister_ids : vec principal; + testflight : bool; + latest_ledger_archive_poll_timestamp_seconds : opt nat64; + archive_canister_ids : vec principal; + governance_canister_id : opt principal; + index_canister_id : opt principal; + swap_canister_id : opt principal; + ledger_canister_id : opt principal; +}; +service : (SnsRootCanister) -> { + canister_status : (CanisterIdRecord) -> (CanisterStatusResult); + change_canister : (ChangeCanisterRequest) -> (); + get_build_metadata : () -> (text) query; + get_sns_canisters_summary : (GetSnsCanistersSummaryRequest) -> ( + GetSnsCanistersSummaryResponse, + ); + list_sns_canisters : (record {}) -> (ListSnsCanistersResponse) query; + manage_dapp_canister_settings : (ManageDappCanisterSettingsRequest) -> ( + ManageDappCanisterSettingsResponse, + ); + register_dapp_canister : (RegisterDappCanisterRequest) -> (record {}); + register_dapp_canisters : (RegisterDappCanistersRequest) -> (record {}); + set_dapp_controllers : (SetDappControllersRequest) -> ( + SetDappControllersResponse, + ); +} \ No newline at end of file diff --git a/ic/sns/testdata/did/sns.did b/ic/sns/testdata/did/sns.did new file mode 100644 index 0000000..ecd9b1b --- /dev/null +++ b/ic/sns/testdata/did/sns.did @@ -0,0 +1,245 @@ +type AddWasmRequest = record { hash : blob; wasm : opt SnsWasm }; +type AddWasmResponse = record { result : opt Result }; +type AirdropDistribution = record { airdrop_neurons : vec NeuronDistribution }; +type Canister = record { id : opt principal }; +type CfNeuron = record { + has_created_neuron_recipes : opt bool; + nns_neuron_id : nat64; + amount_icp_e8s : nat64; +}; +type CfParticipant = record { + hotkey_principal : text; + cf_neurons : vec CfNeuron; +}; +type Countries = record { iso_codes : vec text }; +type DappCanisters = record { canisters : vec Canister }; +type DappCanistersTransferResult = record { + restored_dapp_canisters : vec Canister; + nns_controlled_dapp_canisters : vec Canister; + sns_controlled_dapp_canisters : vec Canister; +}; +type DeployNewSnsRequest = record { sns_init_payload : opt SnsInitPayload }; +type DeployNewSnsResponse = record { + dapp_canisters_transfer_result : opt DappCanistersTransferResult; + subnet_id : opt principal; + error : opt SnsWasmError; + canisters : opt SnsCanisterIds; +}; +type DeployedSns = record { + root_canister_id : opt principal; + governance_canister_id : opt principal; + index_canister_id : opt principal; + swap_canister_id : opt principal; + ledger_canister_id : opt principal; +}; +type DeveloperDistribution = record { + developer_neurons : vec NeuronDistribution; +}; +type FractionalDeveloperVotingPower = record { + treasury_distribution : opt TreasuryDistribution; + developer_distribution : opt DeveloperDistribution; + airdrop_distribution : opt AirdropDistribution; + swap_distribution : opt SwapDistribution; +}; +type GetAllowedPrincipalsResponse = record { + allowed_principals : vec principal; +}; +type GetDeployedSnsByProposalIdRequest = record { proposal_id : nat64 }; +type GetDeployedSnsByProposalIdResponse = record { + get_deployed_sns_by_proposal_id_result : opt GetDeployedSnsByProposalIdResult; +}; +type GetDeployedSnsByProposalIdResult = variant { + Error : SnsWasmError; + DeployedSns : DeployedSns; +}; +type GetNextSnsVersionRequest = record { + governance_canister_id : opt principal; + current_version : opt SnsVersion; +}; +type GetNextSnsVersionResponse = record { next_version : opt SnsVersion }; +type GetSnsSubnetIdsResponse = record { sns_subnet_ids : vec principal }; +type GetWasmMetadataRequest = record { hash : opt blob }; +type GetWasmMetadataResponse = record { result : opt Result_1 }; +type GetWasmRequest = record { hash : blob }; +type GetWasmResponse = record { wasm : opt SnsWasm }; +type IdealMatchedParticipationFunction = record { + serialized_representation : opt text; +}; +type InitialTokenDistribution = variant { + FractionalDeveloperVotingPower : FractionalDeveloperVotingPower; +}; +type InsertUpgradePathEntriesRequest = record { + upgrade_path : vec SnsUpgrade; + sns_governance_canister_id : opt principal; +}; +type InsertUpgradePathEntriesResponse = record { error : opt SnsWasmError }; +type LinearScalingCoefficient = record { + slope_numerator : opt nat64; + intercept_icp_e8s : opt nat64; + from_direct_participation_icp_e8s : opt nat64; + slope_denominator : opt nat64; + to_direct_participation_icp_e8s : opt nat64; +}; +type ListDeployedSnsesResponse = record { instances : vec DeployedSns }; +type ListUpgradeStep = record { + pretty_version : opt PrettySnsVersion; + version : opt SnsVersion; +}; +type ListUpgradeStepsRequest = record { + limit : nat32; + starting_at : opt SnsVersion; + sns_governance_canister_id : opt principal; +}; +type ListUpgradeStepsResponse = record { steps : vec ListUpgradeStep }; +type MetadataSection = record { + contents : opt blob; + name : opt text; + visibility : opt text; +}; +type NeuronBasketConstructionParameters = record { + dissolve_delay_interval_seconds : nat64; + count : nat64; +}; +type NeuronDistribution = record { + controller : opt principal; + dissolve_delay_seconds : nat64; + memo : nat64; + stake_e8s : nat64; + vesting_period_seconds : opt nat64; +}; +type NeuronsFundParticipants = record { participants : vec CfParticipant }; +type NeuronsFundParticipationConstraints = record { + coefficient_intervals : vec LinearScalingCoefficient; + max_neurons_fund_participation_icp_e8s : opt nat64; + min_direct_participation_threshold_icp_e8s : opt nat64; + ideal_matched_participation_function : opt IdealMatchedParticipationFunction; +}; +type Ok = record { sections : vec MetadataSection }; +type PrettySnsVersion = record { + archive_wasm_hash : text; + root_wasm_hash : text; + swap_wasm_hash : text; + ledger_wasm_hash : text; + governance_wasm_hash : text; + index_wasm_hash : text; +}; +type Result = variant { Error : SnsWasmError; Hash : blob }; +type Result_1 = variant { Ok : Ok; Error : SnsWasmError }; +type SnsCanisterIds = record { + root : opt principal; + swap : opt principal; + ledger : opt principal; + index : opt principal; + governance : opt principal; +}; +type SnsInitPayload = record { + url : opt text; + max_dissolve_delay_seconds : opt nat64; + max_dissolve_delay_bonus_percentage : opt nat64; + nns_proposal_id : opt nat64; + neurons_fund_participation : opt bool; + min_participant_icp_e8s : opt nat64; + neuron_basket_construction_parameters : opt NeuronBasketConstructionParameters; + fallback_controller_principal_ids : vec text; + token_symbol : opt text; + final_reward_rate_basis_points : opt nat64; + max_icp_e8s : opt nat64; + neuron_minimum_stake_e8s : opt nat64; + confirmation_text : opt text; + logo : opt text; + name : opt text; + swap_start_timestamp_seconds : opt nat64; + swap_due_timestamp_seconds : opt nat64; + initial_voting_period_seconds : opt nat64; + neuron_minimum_dissolve_delay_to_vote_seconds : opt nat64; + description : opt text; + max_neuron_age_seconds_for_age_bonus : opt nat64; + min_participants : opt nat64; + initial_reward_rate_basis_points : opt nat64; + wait_for_quiet_deadline_increase_seconds : opt nat64; + transaction_fee_e8s : opt nat64; + dapp_canisters : opt DappCanisters; + neurons_fund_participation_constraints : opt NeuronsFundParticipationConstraints; + neurons_fund_participants : opt NeuronsFundParticipants; + max_age_bonus_percentage : opt nat64; + initial_token_distribution : opt InitialTokenDistribution; + reward_rate_transition_duration_seconds : opt nat64; + token_logo : opt text; + token_name : opt text; + max_participant_icp_e8s : opt nat64; + min_direct_participation_icp_e8s : opt nat64; + proposal_reject_cost_e8s : opt nat64; + restricted_countries : opt Countries; + min_icp_e8s : opt nat64; + max_direct_participation_icp_e8s : opt nat64; +}; +type SnsUpgrade = record { + next_version : opt SnsVersion; + current_version : opt SnsVersion; +}; +type SnsVersion = record { + archive_wasm_hash : blob; + root_wasm_hash : blob; + swap_wasm_hash : blob; + ledger_wasm_hash : blob; + governance_wasm_hash : blob; + index_wasm_hash : blob; +}; +type SnsWasm = record { wasm : blob; canister_type : int32 }; +type SnsWasmCanisterInitPayload = record { + allowed_principals : vec principal; + access_controls_enabled : bool; + sns_subnet_ids : vec principal; +}; +type SnsWasmError = record { message : text }; +type SwapDistribution = record { + total_e8s : nat64; + initial_swap_amount_e8s : nat64; +}; +type TreasuryDistribution = record { total_e8s : nat64 }; +type UpdateAllowedPrincipalsRequest = record { + added_principals : vec principal; + removed_principals : vec principal; +}; +type UpdateAllowedPrincipalsResponse = record { + update_allowed_principals_result : opt UpdateAllowedPrincipalsResult; +}; +type UpdateAllowedPrincipalsResult = variant { + Error : SnsWasmError; + AllowedPrincipals : GetAllowedPrincipalsResponse; +}; +type UpdateSnsSubnetListRequest = record { + sns_subnet_ids_to_add : vec principal; + sns_subnet_ids_to_remove : vec principal; +}; +type UpdateSnsSubnetListResponse = record { error : opt SnsWasmError }; +service : (SnsWasmCanisterInitPayload) -> { + add_wasm : (AddWasmRequest) -> (AddWasmResponse); + deploy_new_sns : (DeployNewSnsRequest) -> (DeployNewSnsResponse); + get_allowed_principals : (record {}) -> (GetAllowedPrincipalsResponse) query; + get_deployed_sns_by_proposal_id : (GetDeployedSnsByProposalIdRequest) -> ( + GetDeployedSnsByProposalIdResponse, + ) query; + get_latest_sns_version_pretty : (null) -> (vec record { text; text }) query; + get_next_sns_version : (GetNextSnsVersionRequest) -> ( + GetNextSnsVersionResponse, + ) query; + get_sns_subnet_ids : (record {}) -> (GetSnsSubnetIdsResponse) query; + get_wasm : (GetWasmRequest) -> (GetWasmResponse) query; + get_wasm_metadata : (GetWasmMetadataRequest) -> ( + GetWasmMetadataResponse, + ) query; + insert_upgrade_path_entries : (InsertUpgradePathEntriesRequest) -> ( + InsertUpgradePathEntriesResponse, + ); + list_deployed_snses : (record {}) -> (ListDeployedSnsesResponse) query; + list_upgrade_steps : (ListUpgradeStepsRequest) -> ( + ListUpgradeStepsResponse, + ) query; + update_allowed_principals : (UpdateAllowedPrincipalsRequest) -> ( + UpdateAllowedPrincipalsResponse, + ); + update_sns_subnet_list : (UpdateSnsSubnetListRequest) -> ( + UpdateSnsSubnetListResponse, + ); +} \ No newline at end of file diff --git a/ic/sns/testdata/did/swap.did b/ic/sns/testdata/did/swap.did new file mode 100644 index 0000000..8b5ca1b --- /dev/null +++ b/ic/sns/testdata/did/swap.did @@ -0,0 +1,311 @@ +type BuyerState = record { + icp : opt TransferableAmount; + has_created_neuron_recipes : opt bool; +}; +type CanisterCallError = record { code : opt int32; description : text }; +type CanisterStatusResultV2 = record { + status : CanisterStatusType; + memory_size : nat; + cycles : nat; + settings : DefiniteCanisterSettingsArgs; + idle_cycles_burned_per_day : nat; + module_hash : opt blob; +}; +type CanisterStatusType = variant { stopped; stopping; running }; +type CfInvestment = record { hotkey_principal : text; nns_neuron_id : nat64 }; +type CfNeuron = record { + has_created_neuron_recipes : opt bool; + nns_neuron_id : nat64; + amount_icp_e8s : nat64; +}; +type CfParticipant = record { + hotkey_principal : text; + cf_neurons : vec CfNeuron; +}; +type Countries = record { iso_codes : vec text }; +type DefiniteCanisterSettingsArgs = record { + freezing_threshold : nat; + controllers : vec principal; + memory_allocation : nat; + compute_allocation : nat; +}; +type DerivedState = record { + sns_tokens_per_icp : float32; + buyer_total_icp_e8s : nat64; + cf_participant_count : opt nat64; + neurons_fund_participation_icp_e8s : opt nat64; + direct_participation_icp_e8s : opt nat64; + direct_participant_count : opt nat64; + cf_neuron_count : opt nat64; +}; +type DirectInvestment = record { buyer_principal : text }; +type Err = record { description : opt text; error_type : opt int32 }; +type Err_1 = record { error_type : opt int32 }; +type Err_2 = record { + invalid_user_amount : opt InvalidUserAmount; + existing_ticket : opt Ticket; + error_type : int32; +}; +type Error = record { message : opt text }; +type ErrorRefundIcpRequest = record { source_principal_id : opt principal }; +type ErrorRefundIcpResponse = record { result : opt Result }; +type FailedUpdate = record { + err : opt CanisterCallError; + dapp_canister_id : opt principal; +}; +type FinalizeSwapResponse = record { + set_dapp_controllers_call_result : opt SetDappControllersCallResult; + create_sns_neuron_recipes_result : opt SweepResult; + settle_community_fund_participation_result : opt SettleCommunityFundParticipationResult; + error_message : opt text; + settle_neurons_fund_participation_result : opt SettleNeuronsFundParticipationResult; + set_mode_call_result : opt SetModeCallResult; + sweep_icp_result : opt SweepResult; + claim_neuron_result : opt SweepResult; + sweep_sns_result : opt SweepResult; +}; +type GetAutoFinalizationStatusResponse = record { + auto_finalize_swap_response : opt FinalizeSwapResponse; + has_auto_finalize_been_attempted : opt bool; + is_auto_finalize_enabled : opt bool; +}; +type GetBuyerStateRequest = record { principal_id : opt principal }; +type GetBuyerStateResponse = record { buyer_state : opt BuyerState }; +type GetBuyersTotalResponse = record { buyers_total : nat64 }; +type GetDerivedStateResponse = record { + sns_tokens_per_icp : opt float64; + buyer_total_icp_e8s : opt nat64; + cf_participant_count : opt nat64; + neurons_fund_participation_icp_e8s : opt nat64; + direct_participation_icp_e8s : opt nat64; + direct_participant_count : opt nat64; + cf_neuron_count : opt nat64; +}; +type GetInitResponse = record { init : opt Init }; +type GetLifecycleResponse = record { + decentralization_sale_open_timestamp_seconds : opt nat64; + lifecycle : opt int32; + decentralization_swap_termination_timestamp_seconds : opt nat64; +}; +type GetOpenTicketResponse = record { result : opt Result_1 }; +type GetSaleParametersResponse = record { params : opt Params }; +type GetStateResponse = record { swap : opt Swap; derived : opt DerivedState }; +type GovernanceError = record { error_message : text; error_type : int32 }; +type Icrc1Account = record { owner : opt principal; subaccount : opt blob }; +type IdealMatchedParticipationFunction = record { + serialized_representation : opt text; +}; +type Init = record { + nns_proposal_id : opt nat64; + sns_root_canister_id : text; + neurons_fund_participation : opt bool; + min_participant_icp_e8s : opt nat64; + neuron_basket_construction_parameters : opt NeuronBasketConstructionParameters; + fallback_controller_principal_ids : vec text; + max_icp_e8s : opt nat64; + neuron_minimum_stake_e8s : opt nat64; + confirmation_text : opt text; + swap_start_timestamp_seconds : opt nat64; + swap_due_timestamp_seconds : opt nat64; + min_participants : opt nat32; + sns_token_e8s : opt nat64; + nns_governance_canister_id : text; + transaction_fee_e8s : opt nat64; + icp_ledger_canister_id : text; + sns_ledger_canister_id : text; + neurons_fund_participation_constraints : opt NeuronsFundParticipationConstraints; + neurons_fund_participants : opt NeuronsFundParticipants; + should_auto_finalize : opt bool; + max_participant_icp_e8s : opt nat64; + sns_governance_canister_id : text; + min_direct_participation_icp_e8s : opt nat64; + restricted_countries : opt Countries; + min_icp_e8s : opt nat64; + max_direct_participation_icp_e8s : opt nat64; +}; +type InvalidUserAmount = record { + min_amount_icp_e8s_included : nat64; + max_amount_icp_e8s_included : nat64; +}; +type Investor = variant { + CommunityFund : CfInvestment; + Direct : DirectInvestment; +}; +type LinearScalingCoefficient = record { + slope_numerator : opt nat64; + intercept_icp_e8s : opt nat64; + from_direct_participation_icp_e8s : opt nat64; + slope_denominator : opt nat64; + to_direct_participation_icp_e8s : opt nat64; +}; +type ListCommunityFundParticipantsRequest = record { + offset : opt nat64; + limit : opt nat32; +}; +type ListDirectParticipantsRequest = record { + offset : opt nat32; + limit : opt nat32; +}; +type ListDirectParticipantsResponse = record { participants : vec Participant }; +type ListSnsNeuronRecipesRequest = record { + offset : opt nat64; + limit : opt nat32; +}; +type ListSnsNeuronRecipesResponse = record { + sns_neuron_recipes : vec SnsNeuronRecipe; +}; +type NeuronAttributes = record { + dissolve_delay_seconds : nat64; + memo : nat64; + followees : vec NeuronId; +}; +type NeuronBasketConstructionParameters = record { + dissolve_delay_interval_seconds : nat64; + count : nat64; +}; +type NeuronId = record { id : blob }; +type NeuronsFundParticipants = record { cf_participants : vec CfParticipant }; +type NeuronsFundParticipationConstraints = record { + coefficient_intervals : vec LinearScalingCoefficient; + max_neurons_fund_participation_icp_e8s : opt nat64; + min_direct_participation_threshold_icp_e8s : opt nat64; + ideal_matched_participation_function : opt IdealMatchedParticipationFunction; +}; +type NewSaleTicketRequest = record { + subaccount : opt blob; + amount_icp_e8s : nat64; +}; +type NewSaleTicketResponse = record { result : opt Result_2 }; +type Ok = record { block_height : opt nat64 }; +type Ok_1 = record { + neurons_fund_participation_icp_e8s : opt nat64; + neurons_fund_neurons_count : opt nat64; +}; +type Ok_2 = record { ticket : opt Ticket }; +type OpenRequest = record { + cf_participants : vec CfParticipant; + params : opt Params; + open_sns_token_swap_proposal_id : opt nat64; +}; +type Params = record { + min_participant_icp_e8s : nat64; + neuron_basket_construction_parameters : opt NeuronBasketConstructionParameters; + max_icp_e8s : nat64; + swap_due_timestamp_seconds : nat64; + min_participants : nat32; + sns_token_e8s : nat64; + sale_delay_seconds : opt nat64; + max_participant_icp_e8s : nat64; + min_direct_participation_icp_e8s : opt nat64; + min_icp_e8s : nat64; + max_direct_participation_icp_e8s : opt nat64; +}; +type Participant = record { + participation : opt BuyerState; + participant_id : opt principal; +}; +type Possibility = variant { + Ok : SetDappControllersResponse; + Err : CanisterCallError; +}; +type Possibility_1 = variant { Ok : Response; Err : CanisterCallError }; +type Possibility_2 = variant { Ok : Ok_1; Err : Error }; +type Possibility_3 = variant { Ok : record {}; Err : CanisterCallError }; +type RefreshBuyerTokensRequest = record { + confirmation_text : opt text; + buyer : text; +}; +type RefreshBuyerTokensResponse = record { + icp_accepted_participation_e8s : nat64; + icp_ledger_account_balance_e8s : nat64; +}; +type Response = record { governance_error : opt GovernanceError }; +type Result = variant { Ok : Ok; Err : Err }; +type Result_1 = variant { Ok : Ok_2; Err : Err_1 }; +type Result_2 = variant { Ok : Ok_2; Err : Err_2 }; +type SetDappControllersCallResult = record { possibility : opt Possibility }; +type SetDappControllersResponse = record { failed_updates : vec FailedUpdate }; +type SetModeCallResult = record { possibility : opt Possibility_3 }; +type SettleCommunityFundParticipationResult = record { + possibility : opt Possibility_1; +}; +type SettleNeuronsFundParticipationResult = record { + possibility : opt Possibility_2; +}; +type SnsNeuronRecipe = record { + sns : opt TransferableAmount; + claimed_status : opt int32; + neuron_attributes : opt NeuronAttributes; + investor : opt Investor; +}; +type Swap = record { + auto_finalize_swap_response : opt FinalizeSwapResponse; + neuron_recipes : vec SnsNeuronRecipe; + next_ticket_id : opt nat64; + decentralization_sale_open_timestamp_seconds : opt nat64; + finalize_swap_in_progress : opt bool; + cf_participants : vec CfParticipant; + init : opt Init; + already_tried_to_auto_finalize : opt bool; + neurons_fund_participation_icp_e8s : opt nat64; + purge_old_tickets_last_completion_timestamp_nanoseconds : opt nat64; + direct_participation_icp_e8s : opt nat64; + lifecycle : int32; + purge_old_tickets_next_principal : opt blob; + decentralization_swap_termination_timestamp_seconds : opt nat64; + buyers : vec record { text; BuyerState }; + params : opt Params; + open_sns_token_swap_proposal_id : opt nat64; +}; +type SweepResult = record { + failure : nat32; + skipped : nat32; + invalid : nat32; + success : nat32; + global_failures : nat32; +}; +type Ticket = record { + creation_time : nat64; + ticket_id : nat64; + account : opt Icrc1Account; + amount_icp_e8s : nat64; +}; +type TransferableAmount = record { + transfer_fee_paid_e8s : opt nat64; + transfer_start_timestamp_seconds : nat64; + amount_e8s : nat64; + amount_transferred_e8s : opt nat64; + transfer_success_timestamp_seconds : nat64; +}; +service : (Init) -> { + error_refund_icp : (ErrorRefundIcpRequest) -> (ErrorRefundIcpResponse); + finalize_swap : (record {}) -> (FinalizeSwapResponse); + get_auto_finalization_status : (record {}) -> ( + GetAutoFinalizationStatusResponse, + ) query; + get_buyer_state : (GetBuyerStateRequest) -> (GetBuyerStateResponse) query; + get_buyers_total : (record {}) -> (GetBuyersTotalResponse); + get_canister_status : (record {}) -> (CanisterStatusResultV2); + get_derived_state : (record {}) -> (GetDerivedStateResponse) query; + get_init : (record {}) -> (GetInitResponse) query; + get_lifecycle : (record {}) -> (GetLifecycleResponse) query; + get_open_ticket : (record {}) -> (GetOpenTicketResponse) query; + get_sale_parameters : (record {}) -> (GetSaleParametersResponse) query; + get_state : (record {}) -> (GetStateResponse) query; + list_community_fund_participants : (ListCommunityFundParticipantsRequest) -> ( + NeuronsFundParticipants, + ) query; + list_direct_participants : (ListDirectParticipantsRequest) -> ( + ListDirectParticipantsResponse, + ) query; + list_sns_neuron_recipes : (ListSnsNeuronRecipesRequest) -> ( + ListSnsNeuronRecipesResponse, + ) query; + new_sale_ticket : (NewSaleTicketRequest) -> (NewSaleTicketResponse); + notify_payment_failure : (record {}) -> (Ok_2); + open : (OpenRequest) -> (record {}); + refresh_buyer_tokens : (RefreshBuyerTokensRequest) -> ( + RefreshBuyerTokensResponse, + ); + restore_dapp_controllers : (record {}) -> (SetDappControllersCallResult); +} \ No newline at end of file diff --git a/ic/sns/testdata/gen.go b/ic/sns/testdata/gen.go new file mode 100644 index 0000000..42230b1 --- /dev/null +++ b/ic/sns/testdata/gen.go @@ -0,0 +1,114 @@ +package main + +import ( + "bytes" + "embed" + "fmt" + "github.com/aviate-labs/agent-go/gen" + "io" + "log" + "net/http" + "os" + "strings" + "unicode" +) + +var ( + //go:embed did + dids embed.FS +) + +func checkLatest() error { + for _, f := range []struct { + filepath string + remote string + }{ + { + filepath: "ic/sns/testdata/did/sns.did", + remote: "https://raw.githubusercontent.com/dfinity/ic/master/rs/nns/sns-wasm/canister/sns-wasm.did", + }, + { + filepath: "ic/sns/testdata/did/governance.did", + remote: "https://raw.githubusercontent.com/dfinity/sdk/master/src/distributed/assetstorage.did", + }, + { + filepath: "ic/sns/testdata/did/root.did", + remote: "https://raw.githubusercontent.com/dfinity/ic/master/rs/sns/root/canister/root.did", + }, + { + filepath: "ic/sns/testdata/did/swap.did", + remote: "https://raw.githubusercontent.com/dfinity/ic/master/rs/sns/swap/canister/swap.did", + }, + { + filepath: "ic/sns/testdata/did/ledger.did", + remote: "https://raw.githubusercontent.com/dfinity/ic/master/rs/rosetta-api/icrc1/ledger/ledger.did", + }, + { + filepath: "ic/sns/testdata/did/index.did", + remote: "https://raw.githubusercontent.com/dfinity/ic/master/rs/rosetta-api/icrc1/index/index.did", + }, + } { + raw, err := http.Get(f.remote) + if err != nil { + return err + } + remoteDID, err := io.ReadAll(raw.Body) + if err != nil { + return err + } + localDID, err := os.ReadFile(f.filepath) + if err != nil { + return err + } + if bytes.Compare(remoteDID, localDID) != 0 { + if err := os.WriteFile(f.filepath, remoteDID, os.ModePerm); err != nil { + return err + } + } + } + return nil +} + +func main() { + if err := checkLatest(); err != nil { + log.Panic(err) + } + + entries, _ := dids.ReadDir("did") + for _, entry := range entries { + name := strings.TrimSuffix(entry.Name(), ".did") + fmt.Printf("Generating %q...\n", name) + did, _ := dids.ReadFile(fmt.Sprintf("did/%s", entry.Name())) + dir := fmt.Sprintf("ic/sns/%s", name) + if name == "sns" { + dir = "ic/sns" + } + if _, err := os.Stat(dir); os.IsNotExist(err) { + _ = os.Mkdir(dir, os.ModePerm) + } + + { + g, err := gen.NewGenerator("", name, name, did) + if err != nil { + log.Panic(err) + } + raw, err := g.Generate() + if err != nil { + log.Panic(err) + } + _ = os.WriteFile(fmt.Sprintf("%s/agent.go", dir), raw, os.ModePerm) + } + } +} + +func title(s string) string { + var title []rune + for i, c := range s { + if i == 0 { + title = append(title, unicode.ToUpper(c)) + } else { + title = append(title, c) + } + } + return string(title) +}