@dfinity/nns 11.1.4 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +4 -4
  2. package/dist/index.d.ts +10 -15
  3. package/dist/index.js +1 -7
  4. package/dist/index.js.map +4 -4
  5. package/dist/index.mjs +1 -7
  6. package/dist/index.mjs.map +4 -4
  7. package/package.json +3 -8
  8. package/dist/candid/genesis_token.certified.idl.d.ts +0 -2
  9. package/dist/candid/genesis_token.certified.idl.js +0 -49
  10. package/dist/candid/genesis_token.d.ts +0 -46
  11. package/dist/candid/genesis_token.did +0 -49
  12. package/dist/candid/genesis_token.idl.d.ts +0 -2
  13. package/dist/candid/genesis_token.idl.js +0 -49
  14. package/dist/candid/governance.certified.idl.d.ts +0 -2
  15. package/dist/candid/governance.certified.idl.js +0 -1788
  16. package/dist/candid/governance.d.ts +0 -1339
  17. package/dist/candid/governance.did +0 -1478
  18. package/dist/candid/governance.idl.d.ts +0 -2
  19. package/dist/candid/governance.idl.js +0 -1796
  20. package/dist/candid/governance_test.certified.idl.d.ts +0 -2
  21. package/dist/candid/governance_test.certified.idl.js +0 -1789
  22. package/dist/candid/governance_test.d.ts +0 -1343
  23. package/dist/candid/governance_test.did +0 -1481
  24. package/dist/candid/governance_test.idl.d.ts +0 -2
  25. package/dist/candid/governance_test.idl.js +0 -1797
  26. package/dist/candid/old_list_neurons_service.certified.idl.d.ts +0 -2
  27. package/dist/candid/old_list_neurons_service.certified.idl.js +0 -87
  28. package/dist/candid/sns_wasm.certified.idl.d.ts +0 -2
  29. package/dist/candid/sns_wasm.certified.idl.js +0 -331
  30. package/dist/candid/sns_wasm.d.ts +0 -315
  31. package/dist/candid/sns_wasm.did +0 -350
  32. package/dist/candid/sns_wasm.idl.d.ts +0 -2
  33. package/dist/candid/sns_wasm.idl.js +0 -331
  34. package/dist/canisters/governance/request.converters.d.ts +0 -108
  35. package/dist/canisters/governance/response.converters.d.ts +0 -26
  36. package/dist/canisters/governance/services.d.ts +0 -21
  37. package/dist/constants/canister_ids.d.ts +0 -5
  38. package/dist/constants/constants.d.ts +0 -1
  39. package/dist/enums/governance.enums.d.ts +0 -138
  40. package/dist/errors/governance.errors.d.ts +0 -21
  41. package/dist/genesis_token.canister.d.ts +0 -11
  42. package/dist/governance.canister.d.ts +0 -361
  43. package/dist/governance_test.canister.d.ts +0 -15
  44. package/dist/sns_wasm.canister.d.ts +0 -11
  45. package/dist/types/common.d.ts +0 -6
  46. package/dist/types/governance.options.d.ts +0 -7
  47. package/dist/types/governance_converters.d.ts +0 -821
  48. package/dist/types/sns_wasm.options.d.ts +0 -3
  49. package/dist/utils/account_identifier.utils.d.ts +0 -5
  50. package/dist/utils/neurons.utils.d.ts +0 -50
@@ -1,361 +0,0 @@
1
- import { type AccountIdentifierHex, type LedgerCanister } from "@dfinity/ledger-icp";
2
- import type { Principal } from "@icp-sdk/core/principal";
3
- import type { NeuronSubaccount, RewardEvent } from "./candid/governance";
4
- import type { NeuronVisibility, Vote } from "./enums/governance.enums";
5
- import type { E8s, NeuronId } from "./types/common";
6
- import type { GovernanceCanisterOptions } from "./types/governance.options";
7
- import type { Account, ClaimOrRefreshNeuronRequest, FollowRequest, FolloweesForTopic, GovernanceCachedMetrics, KnownNeuron, ListProposalsRequest, ListProposalsResponse, MakeProposalRequest, NetworkEconomics, NeuronInfo, ProposalId, ProposalInfo } from "./types/governance_converters";
8
- export declare class GovernanceCanister {
9
- private readonly canisterId;
10
- private readonly service;
11
- private readonly certifiedService;
12
- private readonly oldListNeuronsCertifiedService;
13
- private readonly agent;
14
- private constructor();
15
- static create(options?: GovernanceCanisterOptions): GovernanceCanister;
16
- /**
17
- * Returns the list of neurons controlled by the caller.
18
- *
19
- * If an array of neuron IDs is provided, precisely those neurons will be fetched.
20
- *
21
- * If `certified` is true, the request is fetched as an update call, otherwise
22
- * it is fetched using a query call.
23
- *
24
- * The backend treats `includeEmptyNeurons` as false if absent.
25
- *
26
- * The response from the canister might be paginated. In this case, all pages will be fetched in parallel and
27
- * combined into a single return value.
28
- */
29
- listNeurons: ({ certified, neuronIds, includeEmptyNeurons, includePublicNeurons, neuronSubaccounts, }: {
30
- certified: boolean;
31
- neuronIds?: NeuronId[];
32
- includeEmptyNeurons?: boolean;
33
- includePublicNeurons?: boolean;
34
- neuronSubaccounts?: NeuronSubaccount[];
35
- }) => Promise<NeuronInfo[]>;
36
- private fetchNeuronsWithOldMethodAndNoPagination;
37
- private fetchNeuronsPage;
38
- /**
39
- * Returns the list of neurons who have been approved by the community to
40
- * appear as the default followee options.
41
- *
42
- * If `certified` is true, the request is fetched as an update call, otherwise
43
- * it is fetched using a query call.
44
- */
45
- listKnownNeurons: (certified?: boolean) => Promise<KnownNeuron[]>;
46
- /**
47
- * Returns the latest reward event.
48
- *
49
- * If `certified` is true, the request is fetched as an update call, otherwise
50
- * it's fetched using a query call.
51
- *
52
- */
53
- getLatestRewardEvent: (certified?: boolean) => Promise<RewardEvent>;
54
- /**
55
- * Returns the list of proposals made for the community to vote on,
56
- * paginated and filtered by the request.
57
- *
58
- * If `certified` is true (default), the request is fetched as an update call, otherwise
59
- * it is fetched using a query call.
60
- *
61
- * @param request the options to list the proposals (limit number of results, topics to search for, etc.)
62
- * @param certified query or update calls
63
- */
64
- listProposals: ({ request, certified, }: {
65
- request: ListProposalsRequest;
66
- certified?: boolean;
67
- }) => Promise<ListProposalsResponse>;
68
- /**
69
- * @throws {@link InsufficientAmountError}
70
- * @throws {@link StakeNeuronTransferError}
71
- * @throws {@link CouldNotClaimNeuronError}
72
- * @throws {@link TransferError}
73
- */
74
- stakeNeuron: ({ stake, principal, fromSubAccount, ledgerCanister, createdAt, fee, }: {
75
- stake: bigint;
76
- principal: Principal;
77
- fromSubAccount?: number[];
78
- ledgerCanister: LedgerCanister;
79
- createdAt?: bigint;
80
- fee?: E8s;
81
- }) => Promise<NeuronId>;
82
- /**
83
- * Increases dissolve delay of a neuron
84
- *
85
- * @throws {@link GovernanceError}
86
- */
87
- increaseDissolveDelay: ({ neuronId, additionalDissolveDelaySeconds, }: {
88
- neuronId: NeuronId;
89
- additionalDissolveDelaySeconds: number;
90
- }) => Promise<void>;
91
- /**
92
- * Sets dissolve delay of a neuron.
93
- * The new date is now + dissolveDelaySeconds.
94
- *
95
- * @param {NeuronId} neuronId
96
- * @param {number} dissolveDelaySeconds
97
- * @throws {@link GovernanceError}
98
- */
99
- setDissolveDelay: ({ neuronId, dissolveDelaySeconds, }: {
100
- neuronId: NeuronId;
101
- dissolveDelaySeconds: number;
102
- }) => Promise<void>;
103
- /**
104
- * Start dissolving process of a neuron
105
- *
106
- * @throws {@link GovernanceError}
107
- */
108
- startDissolving: (neuronId: NeuronId) => Promise<void>;
109
- /**
110
- * Stop dissolving process of a neuron
111
- *
112
- * @throws {@link GovernanceError}
113
- */
114
- stopDissolving: (neuronId: NeuronId) => Promise<void>;
115
- /**
116
- * Neuron joins the community fund
117
- *
118
- * @throws {@link GovernanceError}
119
- */
120
- joinCommunityFund: (neuronId: NeuronId) => Promise<void>;
121
- /**
122
- * Changes auto-stake maturity for this Neuron. While on, auto-stake maturity will cause all the maturity generated by voting rewards to this neuron to be automatically staked and contribute to the voting power of the neuron.
123
- *
124
- * @param {neuronId: NeuronId; autoStake: boolean;} params
125
- * @param {NeuronId} neuronId The id of the neuron for which to request a change of the auto stake feature
126
- * @param {number} autoStake `true` to enable the auto-stake maturity for this neuron, `false` to turn it off
127
- *
128
- * @throws {@link GovernanceError}
129
- */
130
- autoStakeMaturity: (params: {
131
- neuronId: NeuronId;
132
- autoStake: boolean;
133
- }) => Promise<void>;
134
- /**
135
- * Neuron leaves the community fund
136
- *
137
- * @throws {@link GovernanceError}
138
- */
139
- leaveCommunityFund: (neuronId: NeuronId) => Promise<void>;
140
- /**
141
- * Set visibility of a neuron
142
- *
143
- * @throws {@link GovernanceError}
144
- */
145
- setVisibility: (neuronId: NeuronId, visibility: NeuronVisibility) => Promise<void>;
146
- /**
147
- * Sets node provider reward account.
148
- * Where the reward is paid to.
149
- *
150
- * @param {string} accountIdentifier
151
- * @throws {@link GovernanceError}
152
- * @throws {@link InvalidAccountIDError}
153
- */
154
- setNodeProviderAccount: (accountIdentifier: string) => Promise<void>;
155
- /**
156
- * Merge two neurons
157
- *
158
- * @throws {@link GovernanceError}
159
- */
160
- mergeNeurons: (request: {
161
- sourceNeuronId: NeuronId;
162
- targetNeuronId: NeuronId;
163
- }) => Promise<void>;
164
- /**
165
- * Simulate merging two neurons
166
- *
167
- * @throws {@link GovernanceError}
168
- */
169
- simulateMergeNeurons: (request: {
170
- sourceNeuronId: NeuronId;
171
- targetNeuronId: NeuronId;
172
- }) => Promise<NeuronInfo>;
173
- /**
174
- * Splits a neuron creating a new one
175
- *
176
- * @returns newNeuronId
177
- * @throws {@link GovernanceError}
178
- */
179
- splitNeuron: ({ neuronId, amount, memo, }: {
180
- neuronId: NeuronId;
181
- amount: bigint;
182
- memo?: bigint;
183
- }) => Promise<NeuronId>;
184
- /**
185
- * Returns single proposal info
186
- *
187
- * If `certified` is true (default), the request is fetched as an update call, otherwise
188
- * it is fetched using a query call.
189
- */
190
- getProposal: ({ proposalId, certified, }: {
191
- proposalId: bigint;
192
- certified?: boolean;
193
- }) => Promise<ProposalInfo | undefined>;
194
- /**
195
- * Create new proposal
196
- *
197
- * @returns The newly created proposal ID or undefined if the success response returned by the Governance canister does not provide such information.
198
- * @throws {@link GovernanceError}
199
- */
200
- makeProposal: (request: MakeProposalRequest) => Promise<NeuronId | undefined>;
201
- /**
202
- *
203
- * Registers vote for a proposal from the neuron passed.
204
- *
205
- * @throws {@link GovernanceError}
206
- */
207
- registerVote: ({ neuronId, vote, proposalId, }: {
208
- neuronId: NeuronId;
209
- vote: Vote;
210
- proposalId: ProposalId;
211
- }) => Promise<void>;
212
- /**
213
- * Edit neuron followees per topic
214
- *
215
- * @throws {@link GovernanceError}
216
- */
217
- setFollowees: (followRequest: FollowRequest) => Promise<void>;
218
- /**
219
- * Disburse neuron on Account
220
- *
221
- * @throws {@link GovernanceError}
222
- * @throws {@link InvalidAccountIDError}
223
- */
224
- disburse: ({ neuronId, toAccountId, amount, }: {
225
- neuronId: NeuronId;
226
- toAccountId?: string;
227
- amount?: E8s;
228
- }) => Promise<void>;
229
- /**
230
- * Refreshes voting power of a neuron
231
- * (Resets the `votingPowerRefreshedTimestampSeconds`
232
- * parameter of the neuron to the current time).
233
- *
234
- * @throws {@link GovernanceError}
235
- */
236
- refreshVotingPower: ({ neuronId, }: {
237
- neuronId: NeuronId;
238
- }) => Promise<void>;
239
- /**
240
- * Merge Maturity of a neuron
241
- *
242
- * @throws {@link GovernanceError}
243
- * @throws {@link InvalidPercentageError}
244
- *
245
- */
246
- mergeMaturity: ({ neuronId, percentageToMerge, }: {
247
- neuronId: NeuronId;
248
- percentageToMerge: number;
249
- }) => Promise<void>;
250
- /**
251
- * Stake the maturity of a neuron.
252
- *
253
- * @param {neuronId: NeuronId; percentageToStake: number;} params
254
- * @param {NeuronId} neuronId The id of the neuron for which to stake the maturity
255
- * @param {number} percentageToStake Optional. Percentage of the current maturity to stake. If not provided, all of the neuron's current maturity will be staked.
256
- *
257
- * @throws {@link GovernanceError}
258
- * @throws {@link InvalidPercentageError}
259
- *
260
- */
261
- stakeMaturity: ({ neuronId, percentageToStake, }: {
262
- neuronId: NeuronId;
263
- percentageToStake?: number;
264
- }) => Promise<void>;
265
- /**
266
- * Merge Maturity of a neuron
267
- *
268
- * @throws {@link GovernanceError}
269
- * @throws {@link InvalidPercentageError}
270
- *
271
- */
272
- spawnNeuron: ({ neuronId, percentageToSpawn, newController, nonce, }: {
273
- neuronId: NeuronId;
274
- percentageToSpawn?: number;
275
- newController?: Principal;
276
- nonce?: bigint;
277
- }) => Promise<bigint>;
278
- /**
279
- * Add hotkey to neuron
280
- *
281
- * @throws {@link GovernanceError}
282
- */
283
- addHotkey: ({ neuronId, principal, }: {
284
- neuronId: NeuronId;
285
- principal: Principal;
286
- }) => Promise<void>;
287
- /**
288
- * Remove hotkey to neuron
289
- *
290
- * @throws {@link GovernanceError}
291
- */
292
- removeHotkey: ({ neuronId, principal, }: {
293
- neuronId: NeuronId;
294
- principal: Principal;
295
- }) => Promise<void>;
296
- /**
297
- * Gets the NeuronID of a newly created neuron.
298
- */
299
- claimOrRefreshNeuronFromAccount: ({ memo, controller, }: {
300
- memo: bigint;
301
- controller?: Principal;
302
- }) => Promise<NeuronId | undefined>;
303
- /**
304
- * Refreshes neuron and returns neuronId when successful
305
- * Uses query call only.
306
- *
307
- * @throws {@link UnrecognizedTypeError}
308
- */
309
- claimOrRefreshNeuron: (request: ClaimOrRefreshNeuronRequest) => Promise<NeuronId | undefined>;
310
- private getGovernanceService;
311
- /**
312
- * Return the data of the neuron provided as id.
313
- */
314
- getNeuron: ({ certified, neuronId, }: {
315
- certified: boolean;
316
- neuronId: NeuronId;
317
- }) => Promise<NeuronInfo | undefined>;
318
- /**
319
- * Return the [Network Economics](https://github.com/dfinity/ic/blob/d90e934eb440c730d44d9d9b1ece2cc3f9505d05/rs/nns/governance/proto/ic_nns_governance/pb/v1/governance.proto#L1847).
320
- */
321
- getNetworkEconomicsParameters: ({ certified, }: {
322
- certified: boolean;
323
- }) => Promise<NetworkEconomics>;
324
- /**
325
- * Disburses a neuron's maturity (always certified).
326
- * Reference: https://github.com/dfinity/ic/blob/ca2be53acf413bb92478ee7694ac0fb92af07030/rs/sns/governance/src/governance.rs#L1614
327
- *
328
- * @preconditions
329
- * - The neuron exists
330
- * - The caller is authorized to perform this neuron operation (NeuronPermissionType::DisburseMaturity)
331
- * - The given percentage_to_merge is between 1 and 100 (inclusive)
332
- * - The neuron's id is not yet in the list of neurons with ongoing operations
333
- * - The e8s equivalent of the amount of maturity to disburse is more than the transaction fee.
334
- *
335
- * @param {Object} params
336
- * @param {NeuronId} params.neuronId The id of the neuron for which to disburse maturity
337
- * @param {number} params.percentageToDisburse The percentage of the neuron's maturity to disburse, between 1 and 100 (inclusive).
338
- * @param {AccountIdentifierHex} [params.toAccountIdentifier] Optional. The account identifier to which the maturity will be disbursed. If not provided, the maturity will be disbursed to the caller's Main account.
339
- * @param {Account} [params.toAccount] Optional. The ICRC account to which the maturity will be disbursed. If not provided, the maturity will be disbursed to the caller's Main account.
340
- */
341
- disburseMaturity: ({ neuronId, percentageToDisburse, toAccountIdentifier, toAccount, }: {
342
- neuronId: NeuronId;
343
- percentageToDisburse: number;
344
- toAccountIdentifier?: AccountIdentifierHex;
345
- toAccount?: Account;
346
- }) => Promise<void>;
347
- /**
348
- * Set the following topics for a neuron.
349
- *
350
- * @param {Object} params
351
- * @param {NeuronId} params.neuronId The id of the neuron for which to set the following topics
352
- * @param {Array<FolloweesForTopic>} params.topicFollowing The topics and the followees for each topic that the neuron should follow.
353
- */
354
- setFollowing: ({ neuronId, topicFollowing, }: {
355
- neuronId: NeuronId;
356
- topicFollowing: Array<FolloweesForTopic>;
357
- }) => Promise<void>;
358
- getMetrics: ({ certified, }: {
359
- certified: boolean;
360
- }) => Promise<GovernanceCachedMetrics>;
361
- }
@@ -1,15 +0,0 @@
1
- import { type CanisterOptions } from "@dfinity/utils";
2
- import type { _SERVICE as GovernanceService } from "./candid/governance_test";
3
- import type { Neuron } from "./types/governance_converters";
4
- export declare class GovernanceTestCanister {
5
- private readonly canisterId;
6
- private readonly certifiedService;
7
- private constructor();
8
- static create(options?: CanisterOptions<GovernanceService>): GovernanceTestCanister;
9
- /**
10
- * Test method to update fields of a neuron.
11
- *
12
- * Only available in the governance test canister.
13
- */
14
- updateNeuron(neuron: Neuron): Promise<[] | [import("./candid/governance_test").GovernanceError]>;
15
- }
@@ -1,11 +0,0 @@
1
- import { type CanisterOptions } from "@dfinity/utils";
2
- import type { DeployedSns, _SERVICE as SnsWasmService } from "./candid/sns_wasm";
3
- export declare class SnsWasmCanister {
4
- private readonly service;
5
- private readonly certifiedService;
6
- private constructor();
7
- static create(options?: CanisterOptions<SnsWasmService>): SnsWasmCanister;
8
- listSnses: ({ certified, }: {
9
- certified?: boolean;
10
- }) => Promise<DeployedSns[]>;
11
- }
@@ -1,6 +0,0 @@
1
- export type CanisterIdString = string;
2
- export type NeuronId = bigint;
3
- export type E8s = bigint;
4
- export type Memo = bigint;
5
- export type PrincipalString = string;
6
- export type Option<T> = T | undefined;
@@ -1,7 +0,0 @@
1
- import type { CanisterOptions } from "@dfinity/utils";
2
- import type { ActorSubclass } from "@icp-sdk/core/agent";
3
- import type { _SERVICE as GovernanceService } from "../candid/governance";
4
- export interface GovernanceCanisterOptions extends CanisterOptions<GovernanceService> {
5
- hardwareWallet?: boolean;
6
- oldListNeuronsServiceOverride?: ActorSubclass<GovernanceService>;
7
- }