UNPKG

@dfinity/sns

Version:

A library for interfacing with a Service Nervous System (SNS) project.

139 lines (138 loc) 6.24 kB
import { Canister, type QueryParams } from "@dfinity/utils"; import type { GetMetadataResponse, ListNervousSystemFunctionsResponse, ListProposalsResponse, ListTopicsResponse, ManageNeuron, ManageNeuronResponse, NervousSystemParameters, Neuron, NeuronId, ProposalData, _SERVICE as SnsGovernanceService } from "../candid/sns_governance"; import type { SnsCanisterOptions } from "./types/canister.options"; import type { SnsClaimNeuronParams, SnsDisburseNeuronParams, SnsGetNeuronParams, SnsGetProposalParams, SnsIncreaseDissolveDelayParams, SnsListNeuronsParams, SnsListProposalsParams, SnsListTopicsParams, SnsNeuronAutoStakeMaturityParams, SnsNeuronDisburseMaturityParams, SnsNeuronPermissionsParams, SnsNeuronStakeMaturityParams, SnsRegisterVoteParams, SnsSetDissolveTimestampParams, SnsSetFollowingParams, SnsSetTopicFollowees, SnsSplitNeuronParams } from "./types/governance.params"; export declare class SnsGovernanceCanister extends Canister<SnsGovernanceService> { /** * Instantiate a canister to interact with the governance of a Sns project. * * @param {SnsCanisterOptions} options Miscellaneous options to initialize the canister. Its ID being the only mandatory parammeter. */ static create(options: SnsCanisterOptions<SnsGovernanceService>): SnsGovernanceCanister; /** * List the neurons of the Sns */ listNeurons: (params: SnsListNeuronsParams) => Promise<Neuron[]>; /** * List the proposals of the Sns */ listProposals: (params: SnsListProposalsParams) => Promise<ListProposalsResponse>; /** * * List the topics of the Sns */ listTopics: (params: SnsListTopicsParams) => Promise<ListTopicsResponse>; /** * Get the proposal of the Sns */ getProposal: (params: SnsGetProposalParams) => Promise<ProposalData>; /** * List Nervous System Functions * Neurons can follow other neurons in specific Nervous System Functions. */ listNervousSystemFunctions: (params: QueryParams) => Promise<ListNervousSystemFunctionsResponse>; /** * Get the Sns metadata (title, description, etc.) */ metadata: (params: QueryParams) => Promise<GetMetadataResponse>; /** * Get the Sns nervous system parameters (default followees, max dissolve delay, max number of neurons, etc.) */ nervousSystemParameters: (params: QueryParams) => Promise<NervousSystemParameters>; /** * Get the neuron of the Sns */ getNeuron: (params: SnsGetNeuronParams) => Promise<Neuron>; /** * Same as `getNeuron` but returns undefined instead of raising error when not found. */ queryNeuron: (params: SnsGetNeuronParams) => Promise<Neuron | undefined>; /** * Manage neuron. For advanced users. */ manageNeuron: (request: ManageNeuron) => Promise<ManageNeuronResponse>; /** * Add permissions to a neuron for a specific principal */ addNeuronPermissions: (params: SnsNeuronPermissionsParams) => Promise<void>; /** * Remove permissions to a neuron for a specific principal */ removeNeuronPermissions: (params: SnsNeuronPermissionsParams) => Promise<void>; /** * Split neuron */ splitNeuron: (params: SnsSplitNeuronParams) => Promise<NeuronId | undefined>; /** * Disburse neuron on Account */ disburse: (params: SnsDisburseNeuronParams) => Promise<void>; /** * Start dissolving process of a neuron */ startDissolving: (neuronId: NeuronId) => Promise<void>; /** * Stop dissolving process of a neuron */ stopDissolving: (neuronId: NeuronId) => Promise<void>; /** * Stake the maturity of a neuron. * * @param {neuronId: NeuronId; percentageToStake: number;} params * @param {NeuronId} neuronId The id of the neuron for which to stake the maturity * @param {number} percentageToStake Optional. Percentage of the current maturity to stake. If not provided, all of the neuron's current maturity will be staked. */ stakeMaturity: ({ neuronId, percentageToStake, }: SnsNeuronStakeMaturityParams) => Promise<void>; /** * Disburse the maturity of a neuron. * * @param {neuronId: NeuronId; toAccount?: IcrcAccount; percentageToDisburse: number; } params * @param {IcrcAccount} toAccount. Account to disburse maturity. * @param {NeuronId} neuronId The id of the neuron for which to disburse the maturity * @param {number} percentageToDisburse What percentage of the available maturity to disburse. */ disburseMaturity: (params: SnsNeuronDisburseMaturityParams) => Promise<void>; /** * Changes auto-stake maturity for a Neuron. * * @param {neuronId: NeuronId; autoStake: boolean;} params * @param {NeuronId} neuronId The id of the neuron for which to request a change of the auto stake feature * @param {number} autoStake `true` to enable the auto-stake maturity for this neuron, `false` to turn it off */ autoStakeMaturity: (params: SnsNeuronAutoStakeMaturityParams) => Promise<void>; /** * Increase dissolve delay of a neuron */ setDissolveTimestamp: (params: SnsSetDissolveTimestampParams) => Promise<void>; /** * Increase dissolve delay of a neuron */ increaseDissolveDelay: (params: SnsIncreaseDissolveDelayParams) => Promise<void>; /** * Sets followees of a neuron for a specific Nervous System Function * @deprecated will be replaced by `setFollowing` in the future. */ setTopicFollowees: (params: SnsSetTopicFollowees) => Promise<void>; /** * Sets followees of a neuron for topics */ setFollowing: (params: SnsSetFollowingParams) => Promise<void>; /** * Registers vote for a proposal from the neuron passed. */ registerVote: (params: SnsRegisterVoteParams) => Promise<void>; /** * Refresh neuron */ refreshNeuron: (neuronId: NeuronId) => Promise<void>; /** * Claim neuron */ claimNeuron: ({ memo, controller, subaccount, }: SnsClaimNeuronParams) => Promise<NeuronId>; /** * * @param response ManageNeuronResponse * @throws SnsGovernanceError */ private assertManageNeuronError; }