Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update sns Candid Files #847

Merged
merged 6 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# YYYY.MM.DD-HHMMZ

# Features

- Support `topic` and `list_topics` in @dfinity/sns`.

# 2025.02.19-1030Z

## Overview
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
{
"name": "@dfinity/sns",
"path": "./packages/sns/dist/index.js",
"limit": "18 kB",
"limit": "19 kB",
"gzip": true,
"ignore": [
"@dfinity/agent",
Expand Down
63 changes: 37 additions & 26 deletions packages/sns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,14 @@ Lookup for the canister ids of a Sns and initialize the wrapper to access its fe

### :factory: SnsGovernanceCanister

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L63)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L65)

#### Methods

- [create](#gear-create)
- [listNeurons](#gear-listneurons)
- [listProposals](#gear-listproposals)
- [listTopics](#gear-listtopics)
- [getProposal](#gear-getproposal)
- [listNervousSystemFunctions](#gear-listnervoussystemfunctions)
- [metadata](#gear-metadata)
Expand Down Expand Up @@ -142,7 +143,7 @@ Parameters:

- `options`: Miscellaneous options to initialize the canister. Its ID being the only mandatory parammeter.

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L69)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L71)

##### :gear: listNeurons

Expand All @@ -152,7 +153,7 @@ List the neurons of the Sns
| ------------- | ----------------------------------------------------- |
| `listNeurons` | `(params: SnsListNeuronsParams) => Promise<Neuron[]>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L83)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L85)

##### :gear: listProposals

Expand All @@ -162,7 +163,17 @@ List the proposals of the Sns
| --------------- | -------------------------------------------------------------------- |
| `listProposals` | `(params: SnsListProposalsParams) => Promise<ListProposalsResponse>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L97)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L99)

##### :gear: listTopics

List the topics of the Sns

| Method | Type |
| ------------ | -------------------------------------------------------------- |
| `listTopics` | `(params: SnsListTopicsParams) => Promise<ListTopicsResponse>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L114)

##### :gear: getProposal

Expand All @@ -172,7 +183,7 @@ Get the proposal of the Sns
| ------------- | --------------------------------------------------------- |
| `getProposal` | `(params: SnsGetProposalParams) => Promise<ProposalData>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L111)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L125)

##### :gear: listNervousSystemFunctions

Expand All @@ -183,7 +194,7 @@ Neurons can follow other neurons in specific Nervous System Functions.
| ---------------------------- | ---------------------------------------------------------------------- |
| `listNervousSystemFunctions` | `(params: QueryParams) => Promise<ListNervousSystemFunctionsResponse>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L130)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L144)

##### :gear: metadata

Expand All @@ -193,7 +204,7 @@ Get the Sns metadata (title, description, etc.)
| ---------- | ------------------------------------------------------- |
| `metadata` | `(params: QueryParams) => Promise<GetMetadataResponse>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L138)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L152)

##### :gear: nervousSystemParameters

Expand All @@ -203,7 +214,7 @@ Get the Sns nervous system parameters (default followees, max dissolve delay, ma
| ------------------------- | ----------------------------------------------------------- |
| `nervousSystemParameters` | `(params: QueryParams) => Promise<NervousSystemParameters>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L144)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L158)

##### :gear: getNeuron

Expand All @@ -213,7 +224,7 @@ Get the neuron of the Sns
| ----------- | ------------------------------------------------- |
| `getNeuron` | `(params: SnsGetNeuronParams) => Promise<Neuron>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L152)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L166)

##### :gear: queryNeuron

Expand All @@ -223,7 +234,7 @@ Same as `getNeuron` but returns undefined instead of raising error when not foun
| ------------- | -------------------------------------------------------------- |
| `queryNeuron` | `(params: SnsGetNeuronParams) => Promise<Neuron or undefined>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L170)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L184)

##### :gear: manageNeuron

Expand All @@ -233,7 +244,7 @@ Manage neuron. For advanced users.
| -------------- | ---------------------------------------------------------- |
| `manageNeuron` | `(request: ManageNeuron) => Promise<ManageNeuronResponse>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L190)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L204)

##### :gear: addNeuronPermissions

Expand All @@ -243,7 +254,7 @@ Add permissions to a neuron for a specific principal
| ---------------------- | ------------------------------------------------------- |
| `addNeuronPermissions` | `(params: SnsNeuronPermissionsParams) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L203)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L217)

##### :gear: removeNeuronPermissions

Expand All @@ -253,7 +264,7 @@ Remove permissions to a neuron for a specific principal
| ------------------------- | ------------------------------------------------------- |
| `removeNeuronPermissions` | `(params: SnsNeuronPermissionsParams) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L213)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L227)

##### :gear: splitNeuron

Expand All @@ -263,7 +274,7 @@ Split neuron
| ------------- | ------------------------------------------------------------------ |
| `splitNeuron` | `(params: SnsSplitNeuronParams) => Promise<NeuronId or undefined>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L223)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L237)

##### :gear: disburse

Expand All @@ -273,7 +284,7 @@ Disburse neuron on Account
| ---------- | ---------------------------------------------------- |
| `disburse` | `(params: SnsDisburseNeuronParams) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L254)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L268)

##### :gear: startDissolving

Expand All @@ -283,7 +294,7 @@ Start dissolving process of a neuron
| ----------------- | --------------------------------------- |
| `startDissolving` | `(neuronId: NeuronId) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L262)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L276)

##### :gear: stopDissolving

Expand All @@ -293,7 +304,7 @@ Stop dissolving process of a neuron
| ---------------- | --------------------------------------- |
| `stopDissolving` | `(neuronId: NeuronId) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L270)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L284)

##### :gear: stakeMaturity

Expand All @@ -308,7 +319,7 @@ Parameters:
- `neuronId`: The id of the neuron for which to stake the maturity
- `percentageToStake`: Optional. Percentage of the current maturity to stake. If not provided, all of the neuron's current maturity will be staked.

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L282)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L296)

##### :gear: disburseMaturity

Expand All @@ -324,7 +335,7 @@ Parameters:
- `neuronId`: The id of the neuron for which to disburse the maturity
- `percentageToDisburse`: What percentage of the available maturity to disburse.

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L303)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L317)

##### :gear: autoStakeMaturity

Expand All @@ -339,7 +350,7 @@ Parameters:
- `neuronId`: The id of the neuron for which to request a change of the auto stake feature
- `autoStake`: `true` to enable the auto-stake maturity for this neuron, `false` to turn it off

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L319)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L333)

##### :gear: setDissolveTimestamp

Expand All @@ -349,7 +360,7 @@ Increase dissolve delay of a neuron
| ---------------------- | ---------------------------------------------------------- |
| `setDissolveTimestamp` | `(params: SnsSetDissolveTimestampParams) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L329)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L343)

##### :gear: increaseDissolveDelay

Expand All @@ -359,7 +370,7 @@ Increase dissolve delay of a neuron
| ----------------------- | ----------------------------------------------------------- |
| `increaseDissolveDelay` | `(params: SnsIncreaseDissolveDelayParams) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L339)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L353)

##### :gear: setTopicFollowees

Expand All @@ -369,7 +380,7 @@ Sets followees of a neuron for a specific Nervous System Function (topic)
| ------------------- | ------------------------------------------------- |
| `setTopicFollowees` | `(params: SnsSetTopicFollowees) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L349)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L363)

##### :gear: registerVote

Expand All @@ -379,7 +390,7 @@ Registers vote for a proposal from the neuron passed.
| -------------- | -------------------------------------------------- |
| `registerVote` | `(params: SnsRegisterVoteParams) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L357)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L371)

##### :gear: refreshNeuron

Expand All @@ -389,7 +400,7 @@ Refresh neuron
| --------------- | --------------------------------------- |
| `refreshNeuron` | `(neuronId: NeuronId) => Promise<void>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L365)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L379)

##### :gear: claimNeuron

Expand All @@ -399,7 +410,7 @@ Claim neuron
| ------------- | -------------------------------------------------------------------------------- |
| `claimNeuron` | `({ memo, controller, subaccount, }: SnsClaimNeuronParams) => Promise<NeuronId>` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L375)
[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/sns/src/governance.canister.ts#L389)

### :factory: SnsRootCanister

Expand Down
34 changes: 34 additions & 0 deletions packages/sns/candid/sns_governance.certified.idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@ export const idlFactory = ({ IDL }) => {
'response_timestamp_seconds' : IDL.Opt(IDL.Nat64),
'requested_timestamp_seconds' : IDL.Opt(IDL.Nat64),
});
const Topic = IDL.Variant({
'DappCanisterManagement' : IDL.Null,
'DaoCommunitySettings' : IDL.Null,
'ApplicationBusinessLogic' : IDL.Null,
'CriticalDappOperations' : IDL.Null,
'TreasuryAssetManagement' : IDL.Null,
'Governance' : IDL.Null,
'SnsFrameworkManagement' : IDL.Null,
});
const GenericNervousSystemFunction = IDL.Record({
'topic' : IDL.Opt(Topic),
'validator_canister_id' : IDL.Opt(IDL.Principal),
'target_canister_id' : IDL.Opt(IDL.Principal),
'validator_method_name' : IDL.Opt(IDL.Text),
Expand Down Expand Up @@ -604,6 +614,19 @@ export const idlFactory = ({ IDL }) => {
'include_ballots_by_caller' : IDL.Opt(IDL.Bool),
'proposals' : IDL.Vec(ProposalData),
});
const ListTopicsRequest = IDL.Record({});
const TopicInfo = IDL.Record({
'native_functions' : IDL.Opt(IDL.Vec(NervousSystemFunction)),
'topic' : IDL.Opt(Topic),
'is_critical' : IDL.Opt(IDL.Bool),
'name' : IDL.Opt(IDL.Text),
'description' : IDL.Opt(IDL.Text),
'custom_functions' : IDL.Opt(IDL.Vec(NervousSystemFunction)),
});
const ListTopicsResponse = IDL.Record({
'uncategorized_functions' : IDL.Opt(IDL.Vec(NervousSystemFunction)),
'topics' : IDL.Opt(IDL.Vec(TopicInfo)),
});
const StakeMaturity = IDL.Record({
'percentage_to_stake' : IDL.Opt(IDL.Nat32),
});
Expand Down Expand Up @@ -714,6 +737,7 @@ export const idlFactory = ({ IDL }) => {
),
'list_neurons' : IDL.Func([ListNeurons], [ListNeuronsResponse], []),
'list_proposals' : IDL.Func([ListProposals], [ListProposalsResponse], []),
'list_topics' : IDL.Func([ListTopicsRequest], [ListTopicsResponse], []),
'manage_neuron' : IDL.Func([ManageNeuron], [ManageNeuronResponse], []),
'reset_timers' : IDL.Func([IDL.Record({})], [IDL.Record({})], []),
'set_mode' : IDL.Func([SetMode], [IDL.Record({})], []),
Expand All @@ -739,7 +763,17 @@ export const init = ({ IDL }) => {
'response_timestamp_seconds' : IDL.Opt(IDL.Nat64),
'requested_timestamp_seconds' : IDL.Opt(IDL.Nat64),
});
const Topic = IDL.Variant({
'DappCanisterManagement' : IDL.Null,
'DaoCommunitySettings' : IDL.Null,
'ApplicationBusinessLogic' : IDL.Null,
'CriticalDappOperations' : IDL.Null,
'TreasuryAssetManagement' : IDL.Null,
'Governance' : IDL.Null,
'SnsFrameworkManagement' : IDL.Null,
});
const GenericNervousSystemFunction = IDL.Record({
'topic' : IDL.Opt(Topic),
'validator_canister_id' : IDL.Opt(IDL.Principal),
'target_canister_id' : IDL.Opt(IDL.Principal),
'validator_method_name' : IDL.Opt(IDL.Text),
Expand Down
23 changes: 23 additions & 0 deletions packages/sns/candid/sns_governance.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export type FunctionType =
| { NativeNervousSystemFunction: {} }
| { GenericNervousSystemFunction: GenericNervousSystemFunction };
export interface GenericNervousSystemFunction {
topic: [] | [Topic];
validator_canister_id: [] | [Principal];
target_canister_id: [] | [Principal];
validator_method_name: [] | [string];
Expand Down Expand Up @@ -332,6 +333,11 @@ export interface ListProposalsResponse {
include_ballots_by_caller: [] | [boolean];
proposals: Array<ProposalData>;
}
export type ListTopicsRequest = {};
export interface ListTopicsResponse {
uncategorized_functions: [] | [Array<NervousSystemFunction>];
topics: [] | [Array<TopicInfo>];
}
export interface ManageDappCanisterSettings {
freezing_threshold: [] | [bigint];
wasm_memory_threshold: [] | [bigint];
Expand Down Expand Up @@ -617,6 +623,22 @@ export interface Timers {
export interface Tokens {
e8s: [] | [bigint];
}
export type Topic =
| { DappCanisterManagement: null }
| { DaoCommunitySettings: null }
| { ApplicationBusinessLogic: null }
| { CriticalDappOperations: null }
| { TreasuryAssetManagement: null }
| { Governance: null }
| { SnsFrameworkManagement: null };
export interface TopicInfo {
native_functions: [] | [Array<NervousSystemFunction>];
topic: [] | [Topic];
is_critical: [] | [boolean];
name: [] | [string];
description: [] | [string];
custom_functions: [] | [Array<NervousSystemFunction>];
}
export interface TransferSnsTreasuryFunds {
from_treasury: number;
to_principal: [] | [Principal];
Expand Down Expand Up @@ -743,6 +765,7 @@ export interface _SERVICE {
>;
list_neurons: ActorMethod<[ListNeurons], ListNeuronsResponse>;
list_proposals: ActorMethod<[ListProposals], ListProposalsResponse>;
list_topics: ActorMethod<[ListTopicsRequest], ListTopicsResponse>;
manage_neuron: ActorMethod<[ManageNeuron], ManageNeuronResponse>;
reset_timers: ActorMethod<[{}], {}>;
set_mode: ActorMethod<[SetMode], {}>;
Expand Down
Loading
Loading