@dfinity/nns 0.1.9 → 0.2.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 (60) hide show
  1. package/README.md +10 -11
  2. package/dist/cjs/index.cjs.js +48 -48
  3. package/dist/cjs/index.cjs.js.map +3 -3
  4. package/dist/esm/account_identifier.js +1 -1
  5. package/dist/esm/chunk-4FZAJTYF.js +2 -0
  6. package/dist/esm/chunk-4FZAJTYF.js.map +7 -0
  7. package/dist/esm/chunk-AM5HOKAH.js +2 -0
  8. package/dist/esm/chunk-AM5HOKAH.js.map +7 -0
  9. package/dist/esm/chunk-FVDRR6PO.js +17 -0
  10. package/dist/esm/chunk-FVDRR6PO.js.map +7 -0
  11. package/dist/esm/chunk-HFWTAZD7.js +825 -0
  12. package/dist/esm/chunk-HFWTAZD7.js.map +7 -0
  13. package/dist/esm/chunk-IQ5S76MI.js +4 -0
  14. package/dist/esm/chunk-IQ5S76MI.js.map +7 -0
  15. package/dist/esm/chunk-LNMGZ6W7.js +3 -0
  16. package/dist/esm/chunk-LNMGZ6W7.js.map +7 -0
  17. package/dist/esm/{chunk-NR65YN67.js → chunk-NYI672WX.js} +2 -2
  18. package/dist/esm/{chunk-NR65YN67.js.map → chunk-NYI672WX.js.map} +0 -0
  19. package/dist/esm/chunk-SO23SIWX.js +3 -0
  20. package/dist/esm/chunk-SO23SIWX.js.map +7 -0
  21. package/dist/esm/chunk-X2SHUWG3.js +2 -0
  22. package/dist/esm/chunk-X2SHUWG3.js.map +7 -0
  23. package/dist/esm/governance.js +1 -1
  24. package/dist/esm/icp.js +1 -1
  25. package/dist/esm/index.js +1 -1
  26. package/dist/esm/ledger.js +1 -1
  27. package/dist/types/account_identifier.d.ts +5 -2
  28. package/dist/types/canisters/governance/payloads.d.ts +3 -0
  29. package/dist/types/canisters/governance/request.converters.d.ts +26 -0
  30. package/dist/types/canisters/governance/response.converters.d.ts +35 -0
  31. package/dist/types/constants/canister_ids.d.ts +4 -0
  32. package/dist/types/constants/constants.d.ts +5 -0
  33. package/dist/types/governance.d.ts +15 -16
  34. package/dist/types/icp.d.ts +2 -5
  35. package/dist/types/index.d.ts +6 -3
  36. package/dist/types/ledger.d.ts +11 -32
  37. package/dist/types/types/common.d.ts +8 -0
  38. package/dist/types/types/governance.d.ts +9 -0
  39. package/dist/types/types/governance_converters.d.ts +532 -0
  40. package/dist/types/types/icp.d.ts +4 -0
  41. package/dist/types/types/ledger.d.ts +30 -0
  42. package/dist/types/types/option.d.ts +1 -0
  43. package/dist/types/utils/agent.utils.d.ts +5 -0
  44. package/dist/types/utils/converter.utils.d.ts +18 -0
  45. package/dist/types/utils/{proto.d.ts → proto.utils.d.ts} +0 -0
  46. package/package.json +13 -11
  47. package/dist/esm/chunk-AAXRCEPL.js +0 -2
  48. package/dist/esm/chunk-AAXRCEPL.js.map +0 -7
  49. package/dist/esm/chunk-AV2V5I5D.js +0 -10
  50. package/dist/esm/chunk-AV2V5I5D.js.map +0 -7
  51. package/dist/esm/chunk-QXLTRMTU.js +0 -832
  52. package/dist/esm/chunk-QXLTRMTU.js.map +0 -7
  53. package/dist/esm/chunk-RKZCM7KO.js +0 -4
  54. package/dist/esm/chunk-RKZCM7KO.js.map +0 -7
  55. package/dist/esm/chunk-UJYSTOZE.js +0 -2
  56. package/dist/esm/chunk-UJYSTOZE.js.map +0 -7
  57. package/dist/esm/chunk-XN3QHASA.js +0 -4
  58. package/dist/esm/chunk-XN3QHASA.js.map +0 -7
  59. package/dist/esm/chunk-YXM7FYC5.js +0 -2
  60. package/dist/esm/chunk-YXM7FYC5.js.map +0 -7
@@ -0,0 +1,532 @@
1
+ import { DerEncodedPublicKey } from "@dfinity/agent";
2
+ import { Principal } from "@dfinity/principal";
3
+ import { AccountIdentifier, CanisterIdString, E8s, NeuronId, PrincipalString } from "./common";
4
+ import { Option } from "./option";
5
+ export declare type Action = {
6
+ RegisterKnownNeuron: KnownNeuron;
7
+ } | {
8
+ ExecuteNnsFunction: ExecuteNnsFunction;
9
+ } | {
10
+ ManageNeuron: ManageNeuron;
11
+ } | {
12
+ ApproveGenesisKyc: ApproveGenesisKyc;
13
+ } | {
14
+ ManageNetworkEconomics: NetworkEconomics;
15
+ } | {
16
+ RewardNodeProvider: RewardNodeProvider;
17
+ } | {
18
+ RewardNodeProviders: RewardNodeProviders;
19
+ } | {
20
+ AddOrRemoveNodeProvider: AddOrRemoveNodeProvider;
21
+ } | {
22
+ SetDefaultFollowees: SetDefaultFollowees;
23
+ } | {
24
+ Motion: Motion;
25
+ };
26
+ export interface AddHotKey {
27
+ newHotKey: Option<PrincipalString>;
28
+ }
29
+ export interface AddOrRemoveNodeProvider {
30
+ change: Option<Change>;
31
+ }
32
+ export interface ApproveGenesisKyc {
33
+ principals: Array<PrincipalString>;
34
+ }
35
+ export declare type AuthzChangeOp = {
36
+ Authorize: {
37
+ addSelf: boolean;
38
+ };
39
+ } | {
40
+ Deauthorize: null;
41
+ };
42
+ export interface Ballot {
43
+ neuronId: bigint;
44
+ vote: Vote;
45
+ votingPower: bigint;
46
+ }
47
+ export interface BallotInfo {
48
+ vote: Vote;
49
+ proposalId: Option<ProposalId>;
50
+ }
51
+ export declare type By = {
52
+ NeuronIdOrSubaccount: Record<string, never>;
53
+ } | {
54
+ MemoAndController: ClaimOrRefreshNeuronFromAccount;
55
+ } | {
56
+ Memo: bigint;
57
+ };
58
+ export interface CanisterAuthzInfo {
59
+ methodsAuthz: Array<MethodAuthzInfo>;
60
+ }
61
+ export declare type Change = {
62
+ ToRemove: NodeProvider;
63
+ } | {
64
+ ToAdd: NodeProvider;
65
+ };
66
+ export declare type ClaimOrRefresh = {
67
+ by: Option<By>;
68
+ };
69
+ export interface ClaimOrRefreshNeuronFromAccount {
70
+ controller: Option<Principal>;
71
+ memo: bigint;
72
+ }
73
+ export declare type ClaimOrRefreshNeuronRequest = {
74
+ neuronId: NeuronId;
75
+ by: Option<By>;
76
+ };
77
+ export declare type Command = {
78
+ Spawn: Spawn;
79
+ } | {
80
+ Split: Split;
81
+ } | {
82
+ Follow: Follow;
83
+ } | {
84
+ ClaimOrRefresh: ClaimOrRefresh;
85
+ } | {
86
+ Configure: Configure;
87
+ } | {
88
+ RegisterVote: RegisterVote;
89
+ } | {
90
+ Merge: Merge;
91
+ } | {
92
+ DisburseToNeuron: DisburseToNeuron;
93
+ } | {
94
+ MergeMaturity: MergeMaturity;
95
+ } | {
96
+ MakeProposal: Proposal;
97
+ } | {
98
+ Disburse: Disburse;
99
+ };
100
+ export interface Configure {
101
+ operation: Option<Operation>;
102
+ }
103
+ export interface Disburse {
104
+ toAccountId: Option<AccountIdentifier>;
105
+ amount: Option<E8s>;
106
+ }
107
+ export interface DisburseResponse {
108
+ transferBlockHeight: bigint;
109
+ }
110
+ export interface DisburseToNeuron {
111
+ dissolveDelaySeconds: bigint;
112
+ kycVerified: boolean;
113
+ amount: E8s;
114
+ newController: Option<PrincipalString>;
115
+ nonce: bigint;
116
+ }
117
+ export declare type DissolveState = {
118
+ DissolveDelaySeconds: bigint;
119
+ } | {
120
+ WhenDissolvedTimestampSeconds: bigint;
121
+ };
122
+ export interface ExecuteNnsFunction {
123
+ nnsFunctionId: number;
124
+ nnsFunctionName: Option<string>;
125
+ payload: Option<Record<string, unknown>>;
126
+ payloadBytes: ArrayBuffer;
127
+ }
128
+ export interface Follow {
129
+ topic: Topic;
130
+ followees: Array<NeuronId>;
131
+ }
132
+ export interface Followees {
133
+ topic: Topic;
134
+ followees: Array<NeuronId>;
135
+ }
136
+ export interface GovernanceError {
137
+ errorMessage: string;
138
+ errorType: number;
139
+ }
140
+ export interface IncreaseDissolveDelay {
141
+ additionalDissolveDelaySeconds: number;
142
+ }
143
+ export interface KnownNeuron {
144
+ id: NeuronId;
145
+ name: string;
146
+ description: Option<string>;
147
+ }
148
+ export interface SetDissolveTimestamp {
149
+ dissolveTimestampSeconds: bigint;
150
+ }
151
+ export interface ListProposalsRequest {
152
+ limit: number;
153
+ beforeProposal: Option<ProposalId>;
154
+ includeRewardStatus: Array<ProposalRewardStatus>;
155
+ excludeTopic: Array<Topic>;
156
+ includeStatus: Array<ProposalStatus>;
157
+ }
158
+ export interface ListProposalsResponse {
159
+ proposals: Array<ProposalInfo>;
160
+ }
161
+ export interface MakeProposalResponse {
162
+ proposalId: ProposalId;
163
+ }
164
+ export interface ManageNeuron {
165
+ id: Option<NeuronId>;
166
+ command: Option<Command>;
167
+ neuronIdOrSubaccount: Option<NeuronIdOrSubaccount>;
168
+ }
169
+ export interface Merge {
170
+ sourceNeuronId: Option<NeuronId>;
171
+ }
172
+ export interface MergeMaturity {
173
+ percentageToMerge: number;
174
+ }
175
+ export interface MergeMaturityRequest {
176
+ neuronId: NeuronId;
177
+ percentageToMerge: number;
178
+ }
179
+ export interface MergeMaturityResponse {
180
+ mergedMaturityE8s: bigint;
181
+ newStakeE8s: bigint;
182
+ }
183
+ export interface MethodAuthzChange {
184
+ principal: Option<PrincipalString>;
185
+ methodName: string;
186
+ canister: CanisterIdString;
187
+ operation: AuthzChangeOp;
188
+ }
189
+ export interface MethodAuthzInfo {
190
+ methodName: string;
191
+ principalIds: Array<ArrayBuffer>;
192
+ }
193
+ export interface Motion {
194
+ motionText: string;
195
+ }
196
+ export interface NetworkEconomics {
197
+ neuronMinimumStake: E8s;
198
+ maxProposalsToKeepPerTopic: number;
199
+ neuronManagementFeePerProposal: E8s;
200
+ rejectCost: E8s;
201
+ transactionFee: E8s;
202
+ neuronSpawnDissolveDelaySeconds: bigint;
203
+ minimumIcpXdrRate: bigint;
204
+ maximumNodeProviderRewards: bigint;
205
+ }
206
+ export interface Neuron {
207
+ id: Option<NeuronId>;
208
+ isCurrentUserController: Option<boolean>;
209
+ controller: Option<PrincipalString>;
210
+ recentBallots: Array<BallotInfo>;
211
+ kycVerified: boolean;
212
+ notForProfit: boolean;
213
+ cachedNeuronStake: E8s;
214
+ createdTimestampSeconds: bigint;
215
+ maturityE8sEquivalent: bigint;
216
+ agingSinceTimestampSeconds: bigint;
217
+ neuronFees: E8s;
218
+ hotKeys: Array<PrincipalString>;
219
+ accountIdentifier: AccountIdentifier;
220
+ joinedCommunityFundTimestampSeconds: Option<bigint>;
221
+ dissolveState: Option<DissolveState>;
222
+ followees: Array<Followees>;
223
+ }
224
+ export declare type NeuronIdOrSubaccount = {
225
+ Subaccount: Array<number>;
226
+ } | {
227
+ NeuronId: NeuronId;
228
+ };
229
+ export declare enum NeuronState {
230
+ UNSPECIFIED = 0,
231
+ LOCKED = 1,
232
+ DISSOLVING = 2,
233
+ DISSOLVED = 3
234
+ }
235
+ export interface NeuronInfo {
236
+ neuronId: NeuronId;
237
+ dissolveDelaySeconds: bigint;
238
+ recentBallots: Array<BallotInfo>;
239
+ createdTimestampSeconds: bigint;
240
+ state: NeuronState;
241
+ joinedCommunityFundTimestampSeconds: Option<bigint>;
242
+ retrievedAtTimestampSeconds: bigint;
243
+ votingPower: bigint;
244
+ ageSeconds: bigint;
245
+ fullNeuron: Option<Neuron>;
246
+ }
247
+ export interface NeuronInfoForHw {
248
+ id: string;
249
+ amount: string;
250
+ hotKeys: Array<PrincipalString>;
251
+ }
252
+ export interface NodeProvider {
253
+ id: Option<PrincipalString>;
254
+ rewardAccount: Option<AccountIdentifier>;
255
+ }
256
+ export declare type Operation = {
257
+ RemoveHotKey: RemoveHotKey;
258
+ } | {
259
+ AddHotKey: AddHotKey;
260
+ } | {
261
+ StopDissolving: Record<string, never>;
262
+ } | {
263
+ StartDissolving: Record<string, never>;
264
+ } | {
265
+ IncreaseDissolveDelay: IncreaseDissolveDelay;
266
+ } | {
267
+ JoinCommunityFund: Record<string, never>;
268
+ } | {
269
+ SetDissolveTimestamp: SetDissolveTimestamp;
270
+ };
271
+ export interface Proposal {
272
+ title: Option<string>;
273
+ url: string;
274
+ action: Option<Action>;
275
+ summary: string;
276
+ }
277
+ export declare type ProposalId = bigint;
278
+ export interface ProposalInfo {
279
+ id: Option<ProposalId>;
280
+ ballots: Array<Ballot>;
281
+ rejectCost: E8s;
282
+ proposalTimestampSeconds: bigint;
283
+ rewardEventRound: bigint;
284
+ failedTimestampSeconds: bigint;
285
+ decidedTimestampSeconds: bigint;
286
+ latestTally: Option<Tally>;
287
+ proposal: Option<Proposal>;
288
+ proposer: Option<NeuronId>;
289
+ executedTimestampSeconds: bigint;
290
+ topic: Topic;
291
+ status: ProposalStatus;
292
+ rewardStatus: ProposalRewardStatus;
293
+ }
294
+ export declare enum ProposalRewardStatus {
295
+ PROPOSAL_REWARD_STATUS_UNKNOWN = 0,
296
+ PROPOSAL_REWARD_STATUS_ACCEPT_VOTES = 1,
297
+ PROPOSAL_REWARD_STATUS_READY_TO_SETTLE = 2,
298
+ PROPOSAL_REWARD_STATUS_SETTLED = 3,
299
+ PROPOSAL_REWARD_STATUS_INELIGIBLE = 4
300
+ }
301
+ export declare enum ProposalStatus {
302
+ PROPOSAL_STATUS_UNKNOWN = 0,
303
+ PROPOSAL_STATUS_OPEN = 1,
304
+ PROPOSAL_STATUS_REJECTED = 2,
305
+ PROPOSAL_STATUS_ACCEPTED = 3,
306
+ PROPOSAL_STATUS_EXECUTED = 4,
307
+ PROPOSAL_STATUS_FAILED = 5
308
+ }
309
+ export declare enum Vote {
310
+ UNSPECIFIED = 0,
311
+ YES = 1,
312
+ NO = 2
313
+ }
314
+ export interface RegisterVote {
315
+ vote: Vote;
316
+ proposal: Option<ProposalId>;
317
+ }
318
+ export interface RemoveHotKey {
319
+ hotKeyToRemove: Option<PrincipalString>;
320
+ }
321
+ export declare type RewardMode = {
322
+ RewardToNeuron: RewardToNeuron;
323
+ } | {
324
+ RewardToAccount: RewardToAccount;
325
+ };
326
+ export declare type RewardNodeProviders = {
327
+ rewards: Array<RewardNodeProvider>;
328
+ };
329
+ export interface RewardToAccount {
330
+ toAccount: Option<AccountIdentifier>;
331
+ }
332
+ export interface RewardToNeuron {
333
+ dissolveDelaySeconds: bigint;
334
+ }
335
+ export declare type ClaimNeuronRequest = {
336
+ publicKey: DerEncodedPublicKey;
337
+ nonce: bigint;
338
+ dissolveDelayInSecs: bigint;
339
+ };
340
+ export declare type ClaimNeuronResponse = {
341
+ Ok: null;
342
+ } | {
343
+ Err: GovernanceError;
344
+ };
345
+ export declare type GetFullNeuronResponse = {
346
+ Ok: Neuron;
347
+ } | {
348
+ Err: GovernanceError;
349
+ };
350
+ export declare type GetNeuronInfoResponse = {
351
+ Ok: NeuronInfo;
352
+ } | {
353
+ Err: GovernanceError;
354
+ };
355
+ export interface RewardNodeProvider {
356
+ nodeProvider: Option<NodeProvider>;
357
+ rewardMode: Option<RewardMode>;
358
+ amountE8s: bigint;
359
+ }
360
+ export interface SetDefaultFollowees {
361
+ defaultFollowees: Array<Followees>;
362
+ }
363
+ export interface Spawn {
364
+ newController: Option<PrincipalString>;
365
+ }
366
+ export interface SpawnResponse {
367
+ createdNeuronId: NeuronId;
368
+ }
369
+ export interface Split {
370
+ amount: E8s;
371
+ }
372
+ export interface Tally {
373
+ no: bigint;
374
+ yes: bigint;
375
+ total: bigint;
376
+ timestampSeconds: bigint;
377
+ }
378
+ export declare enum Topic {
379
+ Unspecified = 0,
380
+ ManageNeuron = 1,
381
+ ExchangeRate = 2,
382
+ NetworkEconomics = 3,
383
+ Governance = 4,
384
+ NodeAdmin = 5,
385
+ ParticipantManagement = 6,
386
+ SubnetManagement = 7,
387
+ NetworkCanisterManagement = 8,
388
+ Kyc = 9,
389
+ NodeProviderRewards = 10
390
+ }
391
+ export interface AddHotKeyRequest {
392
+ neuronId: NeuronId;
393
+ principal: PrincipalString;
394
+ }
395
+ export interface RemoveHotKeyRequest {
396
+ neuronId: NeuronId;
397
+ principal: PrincipalString;
398
+ }
399
+ export interface StartDissolvingRequest {
400
+ neuronId: NeuronId;
401
+ }
402
+ export interface StopDissolvingRequest {
403
+ neuronId: NeuronId;
404
+ }
405
+ export interface IncreaseDissolveDelayRequest {
406
+ neuronId: NeuronId;
407
+ additionalDissolveDelaySeconds: number;
408
+ }
409
+ export interface FollowRequest {
410
+ neuronId: NeuronId;
411
+ topic: Topic;
412
+ followees: Array<NeuronId>;
413
+ }
414
+ export interface RegisterVoteRequest {
415
+ neuronId: NeuronId;
416
+ vote: Vote;
417
+ proposal: ProposalId;
418
+ }
419
+ export interface SpawnRequest {
420
+ neuronId: NeuronId;
421
+ newController: Option<PrincipalString>;
422
+ }
423
+ export interface SplitRequest {
424
+ neuronId: NeuronId;
425
+ amount: E8s;
426
+ }
427
+ export interface DisburseRequest {
428
+ neuronId: NeuronId;
429
+ toAccountId?: AccountIdentifier;
430
+ amount?: E8s;
431
+ }
432
+ export interface DisburseToNeuronRequest {
433
+ neuronId: NeuronId;
434
+ dissolveDelaySeconds: bigint;
435
+ kycVerified: boolean;
436
+ amount: E8s;
437
+ newController: Option<PrincipalString>;
438
+ nonce: bigint;
439
+ }
440
+ export interface JoinCommunityFundRequest {
441
+ neuronId: NeuronId;
442
+ }
443
+ export interface MakeProposalRequest {
444
+ neuronId: NeuronId;
445
+ title: Option<string>;
446
+ url: string;
447
+ summary: string;
448
+ action: Action;
449
+ }
450
+ export interface MakeMotionProposalRequest {
451
+ neuronId: NeuronId;
452
+ title: Option<string>;
453
+ url: string;
454
+ text: string;
455
+ summary: string;
456
+ }
457
+ export interface MakeNetworkEconomicsProposalRequest {
458
+ neuronId: NeuronId;
459
+ title: Option<string>;
460
+ summary: string;
461
+ url: string;
462
+ networkEconomics: NetworkEconomics;
463
+ }
464
+ export interface MakeRewardNodeProviderProposalRequest {
465
+ neuronId: NeuronId;
466
+ title: Option<string>;
467
+ summary: string;
468
+ url: string;
469
+ nodeProvider: PrincipalString;
470
+ amount: E8s;
471
+ rewardMode: Option<RewardMode>;
472
+ }
473
+ export interface MakeSetDefaultFolloweesProposalRequest {
474
+ neuronId: NeuronId;
475
+ title: Option<string>;
476
+ summary: string;
477
+ url: string;
478
+ followees: Array<Followees>;
479
+ }
480
+ export interface MakeExecuteNnsFunctionProposalRequest {
481
+ neuronId: NeuronId;
482
+ title: Option<string>;
483
+ summary: string;
484
+ url: string;
485
+ nnsFunction: number;
486
+ payload: ArrayBuffer;
487
+ }
488
+ export interface DisburseToNeuronResponse {
489
+ createdNeuronId: NeuronId;
490
+ }
491
+ export interface SpawnResponse {
492
+ createdNeuronId: NeuronId;
493
+ }
494
+ export declare type EmptyResponse = {
495
+ Ok: null;
496
+ } | {
497
+ Err: GovernanceError;
498
+ };
499
+ export default interface ServiceInterface {
500
+ getNeurons: (certified: boolean, neuronIds?: NeuronId[]) => Promise<Array<NeuronInfo>>;
501
+ getNeuronsForHW: () => Promise<Array<NeuronInfoForHw>>;
502
+ getPendingProposals: () => Promise<Array<ProposalInfo>>;
503
+ getProposalInfo: (proposalId: bigint) => Promise<Option<ProposalInfo>>;
504
+ listKnownNeurons: (certified: boolean) => Promise<Array<KnownNeuron>>;
505
+ listProposals: (request: ListProposalsRequest) => Promise<ListProposalsResponse>;
506
+ addHotKey: (request: AddHotKeyRequest) => Promise<EmptyResponse>;
507
+ removeHotKey: (request: RemoveHotKeyRequest) => Promise<EmptyResponse>;
508
+ startDissolving: (request: StartDissolvingRequest) => Promise<EmptyResponse>;
509
+ stopDissolving: (request: StopDissolvingRequest) => Promise<EmptyResponse>;
510
+ increaseDissolveDelay: (request: IncreaseDissolveDelayRequest) => Promise<EmptyResponse>;
511
+ joinCommunityFund: (request: JoinCommunityFundRequest) => Promise<EmptyResponse>;
512
+ follow: (request: FollowRequest) => Promise<EmptyResponse>;
513
+ mergeMaturity: (request: MergeMaturityRequest) => Promise<MergeMaturityResponse>;
514
+ registerVote: (request: RegisterVoteRequest) => Promise<EmptyResponse>;
515
+ spawn: (request: SpawnRequest) => Promise<SpawnResponse>;
516
+ split: (request: SplitRequest) => Promise<NeuronId>;
517
+ disburse: (request: DisburseRequest) => Promise<DisburseResponse>;
518
+ disburseToNeuron: (request: DisburseToNeuronRequest) => Promise<DisburseToNeuronResponse>;
519
+ makeMotionProposal: (request: MakeMotionProposalRequest) => Promise<MakeProposalResponse>;
520
+ makeNetworkEconomicsProposal: (request: MakeNetworkEconomicsProposalRequest) => Promise<MakeProposalResponse>;
521
+ makeRewardNodeProviderProposal: (request: MakeRewardNodeProviderProposalRequest) => Promise<MakeProposalResponse>;
522
+ makeSetDefaultFolloweesProposal: (request: MakeSetDefaultFolloweesProposalRequest) => Promise<MakeProposalResponse>;
523
+ makeExecuteNnsFunctionProposal: (request: MakeExecuteNnsFunctionProposalRequest) => Promise<MakeProposalResponse>;
524
+ claimOrRefreshNeuron: (request: ClaimOrRefreshNeuronRequest) => Promise<Option<NeuronId>>;
525
+ claimOrRefreshNeuronFromAccount: (request: ClaimOrRefreshNeuronFromAccount) => Promise<NeuronId>;
526
+ }
527
+ /**
528
+ * An error used to ensure at compile-time that it's never reached.
529
+ */
530
+ export declare class UnsupportedValueError extends Error {
531
+ constructor(value: never);
532
+ }
@@ -0,0 +1,4 @@
1
+ export declare enum FromICPStringError {
2
+ FRACTIONAL_MORE_THAN_8_DECIMALS = 0,
3
+ INVALID_FORMAT = 1
4
+ }
@@ -0,0 +1,30 @@
1
+ import { Agent } from "@dfinity/agent";
2
+ import { Principal } from "@dfinity/principal";
3
+ import { ICP } from "../icp";
4
+ export declare type BlockHeight = bigint;
5
+ export declare type TransferError = InvalidSender | InsufficientFunds | TxTooOld | TxCreatedInFuture | TxDuplicate | BadFee;
6
+ export declare class InvalidSender {
7
+ }
8
+ export declare class BadFee {
9
+ }
10
+ export declare class InsufficientFunds {
11
+ readonly balance: ICP;
12
+ constructor(balance: ICP);
13
+ }
14
+ export declare class TxTooOld {
15
+ readonly allowed_window_secs: number;
16
+ constructor(allowed_window_secs: number);
17
+ }
18
+ export declare class TxCreatedInFuture {
19
+ }
20
+ export declare class TxDuplicate {
21
+ readonly duplicateOf: BlockHeight;
22
+ constructor(duplicateOf: BlockHeight);
23
+ }
24
+ export declare type Fetcher = (agent: Agent, canisterId: Principal, methodName: string, arg: ArrayBuffer) => Promise<Uint8Array | Error>;
25
+ export interface LedgerCanisterOptions {
26
+ agent?: Agent;
27
+ canisterId?: Principal;
28
+ updateCallOverride?: Fetcher;
29
+ queryCallOverride?: Fetcher;
30
+ }
@@ -0,0 +1 @@
1
+ export declare type Option<T> = T | undefined;
@@ -0,0 +1,5 @@
1
+ import { Agent } from "@dfinity/agent";
2
+ /**
3
+ * @returns The default agent to use. An agent that connects to mainnet with the anonymous identity.
4
+ */
5
+ export declare const defaultAgent: () => Agent;
@@ -0,0 +1,18 @@
1
+ import { Principal } from "@dfinity/principal";
2
+ import { AccountIdentifier, SubAccount } from "../types/common";
3
+ export declare const uint8ArrayToBigInt: (array: Uint8Array) => bigint;
4
+ export declare const bigIntToUint8Array: (value: bigint) => Uint8Array;
5
+ export declare const arrayBufferToArrayOfNumber: (buffer: ArrayBuffer) => Array<number>;
6
+ export declare const arrayOfNumberToUint8Array: (numbers: Array<number>) => Uint8Array;
7
+ export declare const arrayOfNumberToArrayBuffer: (numbers: Array<number>) => ArrayBuffer;
8
+ export declare const arrayBufferToNumber: (buffer: ArrayBuffer) => number;
9
+ export declare const numberToArrayBuffer: (value: number, byteLength: number) => ArrayBuffer;
10
+ export declare const asciiStringToByteArray: (text: string) => Array<number>;
11
+ export declare const toSubAccountId: (subAccount: Array<number>) => number;
12
+ export declare const fromSubAccountId: (subAccountId: number) => Array<number>;
13
+ export declare const accountIdentifierToBytes: (accountIdentifier: AccountIdentifier) => Uint8Array;
14
+ export declare const accountIdentifierFromBytes: (accountIdentifier: Uint8Array) => AccountIdentifier;
15
+ export declare const principalToAccountIdentifier: (principal: Principal, subAccount?: Uint8Array | undefined) => string;
16
+ export declare const principalToSubAccount: (principal: Principal) => SubAccount;
17
+ export declare const toHexString: (bytes: Uint8Array) => string;
18
+ export declare const calculateCrc32: (bytes: Uint8Array) => Uint8Array;
package/package.json CHANGED
@@ -1,17 +1,20 @@
1
1
  {
2
2
  "name": "@dfinity/nns",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "A library for interfacing with the Internet Computer's Network Nervous System.",
5
+ "license": "Apache-2.0",
5
6
  "main": "dist/cjs/index.cjs.js",
6
7
  "module": "dist/esm/index.js",
7
8
  "types": "dist/types/index.d.ts",
8
9
  "files": [
9
10
  "dist",
10
- "README.md"
11
+ "README.md",
12
+ "LICENSE"
11
13
  ],
12
14
  "scripts": {
13
15
  "rmdir": "node ./scripts/rmdir.mjs",
14
16
  "ts-declaration": "tsc --emitDeclarationOnly --outDir dist/types",
17
+ "did": "scripts/compile-idl-js",
15
18
  "build": "npm run rmdir && node esbuild.mjs && npm run ts-declaration",
16
19
  "test": "jest",
17
20
  "doc": "typedoc ./src/index.ts",
@@ -23,18 +26,16 @@
23
26
  "@dfinity/agent": "^0.10.2",
24
27
  "@dfinity/candid": "^0.10.2",
25
28
  "@dfinity/principal": "^0.10.2",
29
+ "crc": "^3.8.0",
26
30
  "crc-32": "^1.2.0",
27
31
  "google-protobuf": "^3.19.1",
28
32
  "js-sha256": "^0.9.0"
29
33
  },
30
34
  "devDependencies": {
31
- "@babel/preset-env": "^7.16.11",
32
35
  "@types/google-protobuf": "^3.15.5",
33
36
  "@types/jest": "^27.0.3",
34
37
  "@types/text-encoding": "^0.0.36",
35
38
  "@typescript-eslint/eslint-plugin": "^5.4.0",
36
- "babel-jest": "^27.4.6",
37
- "babelify": "^10.0.0",
38
39
  "esbuild": "^0.14.14",
39
40
  "eslint": "^7.29.0",
40
41
  "eslint-config-standard": "^16.0.3",
@@ -44,6 +45,7 @@
44
45
  "jest": "^27.3.1",
45
46
  "jest-mock-extended": "^2.0.4",
46
47
  "prettier": "^2.5.0",
48
+ "prettier-plugin-organize-imports": "^2.3.4",
47
49
  "text-encoding": "^0.7.0",
48
50
  "ts-jest": "^27.0.7",
49
51
  "ts-protoc-gen": "^0.15.0",
@@ -51,12 +53,12 @@
51
53
  "typescript": "^4.5.2",
52
54
  "whatwg-fetch": "^3.6.2"
53
55
  },
54
- "browserify": {
55
- "transform": [
56
- [
57
- "babelify"
58
- ]
59
- ]
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "git+https://github.com/dfinity/nns-js.git"
59
+ },
60
+ "bugs": {
61
+ "url": "https://github.com/dfinity/nns-js"
60
62
  },
61
63
  "keywords": [
62
64
  "internet computer",
@@ -1,2 +0,0 @@
1
- import{a,b as s,c as d,e as i}from"./chunk-QXLTRMTU.js";var u=({IDL:e})=>{let n=e.Record({id:e.Nat64}),t=e.Record({name:e.Text,description:e.Opt(e.Text)}),o=e.Record({id:e.Opt(n),known_neuron_data:e.Opt(t)}),r=e.Record({known_neurons:e.Vec(o)});return e.Service({list_known_neurons:e.Func([],[r],["query"])})};var p=({IDL:e})=>{let n=e.Record({id:e.Nat64}),t=e.Record({name:e.Text,description:e.Opt(e.Text)}),o=e.Record({id:e.Opt(n),known_neuron_data:e.Opt(t)}),r=e.Record({known_neurons:e.Vec(o)});return e.Service({list_known_neurons:e.Func([],[r],[])})};var w=a.fromText("rrkah-fqaaa-aaaaa-aaaaq-cai"),c=class{constructor(n,t){this.service=n;this.certifiedService=t}static create(n={}){let t=n.agent??N(),o=n.canisterId??w,r=n.serviceOverride??i.createActor(u,{agent:t,canisterId:o}),v=n.certifiedServiceOverride??i.createActor(p,{agent:t,canisterId:o});return new c(r,v)}listKnownNeurons=async(n=!0)=>(await(n?this.certifiedService:this.service).list_known_neurons()).known_neurons.map(r=>({id:r.id[0]?.id??BigInt(0),name:r.known_neuron_data[0]?.name??"",description:r.known_neuron_data[0]?.description[0]}))};function N(){return new d({host:"https://ic0.app",identity:new s})}export{c as a};
2
- //# sourceMappingURL=chunk-AAXRCEPL.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../candid/governance.idl.js", "../../candid/governance.certified.idl.js", "../../src/governance.ts"],
4
- "sourcesContent": ["export const idlFactory = ({ IDL }) => {\n const NeuronId = IDL.Record({ 'id' : IDL.Nat64 });\n const KnownNeuronData = IDL.Record({\n 'name' : IDL.Text,\n 'description' : IDL.Opt(IDL.Text),\n });\n const KnownNeuron = IDL.Record({\n 'id' : IDL.Opt(NeuronId),\n 'known_neuron_data' : IDL.Opt(KnownNeuronData),\n });\n const ListKnownNeuronsResponse = IDL.Record({\n 'known_neurons' : IDL.Vec(KnownNeuron),\n });\n return IDL.Service({\n 'list_known_neurons' : IDL.Func([], [ListKnownNeuronsResponse], ['query']),\n });\n};\nexport const init = ({ IDL }) => { return []; };\n", "export const idlFactory = ({ IDL }) => {\n const NeuronId = IDL.Record({ 'id' : IDL.Nat64 });\n const KnownNeuronData = IDL.Record({\n 'name' : IDL.Text,\n 'description' : IDL.Opt(IDL.Text),\n });\n const KnownNeuron = IDL.Record({\n 'id' : IDL.Opt(NeuronId),\n 'known_neuron_data' : IDL.Opt(KnownNeuronData),\n });\n const ListKnownNeuronsResponse = IDL.Record({\n 'known_neurons' : IDL.Vec(KnownNeuron),\n });\n return IDL.Service({\n 'list_known_neurons' : IDL.Func([], [ListKnownNeuronsResponse], []),\n });\n};\nexport const init = ({ IDL }) => { return []; };\n", "import { Actor, Agent, AnonymousIdentity, HttpAgent } from \"@dfinity/agent\";\nimport { Principal } from \"@dfinity/principal\";\nimport { GovernanceService, idlFactory } from \"../candid/governance.idl\";\nimport { idlFactory as certifiedIdlFactory } from \"../candid/governance.certified.idl\";\n\nconst MAINNET_GOVERNANCE_CANISTER_ID = Principal.fromText(\n \"rrkah-fqaaa-aaaaa-aaaaq-cai\"\n);\n\ntype NeuronId = bigint;\n\nexport type KnownNeuron = {\n id: NeuronId,\n name: string,\n description: string | undefined\n};\n\n// HttpAgent options that can be used at construction.\nexport interface GovernanceCanisterOptions {\n // The agent to use when communicating with the governance canister.\n agent?: Agent;\n // The governance canister's ID.\n canisterId?: Principal;\n // The default service to use when calling into the IC. Primarily overridden\n // in test for mocking.\n serviceOverride?: GovernanceService;\n // The service to use when making 'certified' calls into the IC (as in, using\n // update calls in place of queries). Primarily overridden in test for\n // mocking.\n certifiedServiceOverride?: GovernanceService;\n}\n\nexport class GovernanceCanister {\n private constructor(\n private readonly service: GovernanceService,\n private readonly certifiedService: GovernanceService\n ) {}\n\n public static create(options: GovernanceCanisterOptions = {}) {\n const agent = options.agent ?? defaultAgent();\n const canisterId = options.canisterId ?? MAINNET_GOVERNANCE_CANISTER_ID;\n\n const service = options.serviceOverride ??\n Actor.createActor<GovernanceService>(idlFactory, {\n agent,\n canisterId,\n });\n\n const certifiedService = options.certifiedServiceOverride ??\n Actor.createActor<GovernanceService>(certifiedIdlFactory, {\n agent,\n canisterId,\n });\n\n return new GovernanceCanister(service, certifiedService);\n }\n\n /**\n * Returns the list of neurons who have been approved by the community to\n * appear as the default followee options.\n *\n * If `certified` is true, the request is fetched as an update call, otherwise\n * it is fetched using a query call.\n */\n public listKnownNeurons = async (\n certified = true\n ): Promise<KnownNeuron[]> => {\n const service = certified ? this.certifiedService : this.service;\n const response = await service.list_known_neurons();\n\n return response.known_neurons.map(n => ({\n id: n.id[0]?.id ?? BigInt(0),\n name: n.known_neuron_data[0]?.name ?? \"\",\n description: n.known_neuron_data[0]?.description[0]\n }));\n };\n}\n\n/**\n * @returns The default agent to use. An agent that connects to mainnet with the anonymous identity.\n */\nfunction defaultAgent(): Agent {\n return new HttpAgent({\n host: \"https://ic0.app\",\n identity: new AnonymousIdentity(),\n });\n}\n"],
5
- "mappings": "wDAAO,GAAM,GAAa,CAAC,CAAE,SAAU,CACrC,GAAM,GAAW,EAAI,OAAO,CAAE,GAAO,EAAI,QACnC,EAAkB,EAAI,OAAO,CACjC,KAAS,EAAI,KACb,YAAgB,EAAI,IAAI,EAAI,QAExB,EAAc,EAAI,OAAO,CAC7B,GAAO,EAAI,IAAI,GACf,kBAAsB,EAAI,IAAI,KAE1B,EAA2B,EAAI,OAAO,CAC1C,cAAkB,EAAI,IAAI,KAE5B,MAAO,GAAI,QAAQ,CACjB,mBAAuB,EAAI,KAAK,GAAI,CAAC,GAA2B,CAAC,aCd9D,GAAM,GAAa,CAAC,CAAE,SAAU,CACrC,GAAM,GAAW,EAAI,OAAO,CAAE,GAAO,EAAI,QACnC,EAAkB,EAAI,OAAO,CACjC,KAAS,EAAI,KACb,YAAgB,EAAI,IAAI,EAAI,QAExB,EAAc,EAAI,OAAO,CAC7B,GAAO,EAAI,IAAI,GACf,kBAAsB,EAAI,IAAI,KAE1B,EAA2B,EAAI,OAAO,CAC1C,cAAkB,EAAI,IAAI,KAE5B,MAAO,GAAI,QAAQ,CACjB,mBAAuB,EAAI,KAAK,GAAI,CAAC,GAA2B,OCTpE,GAAM,GAAiC,EAAU,SAC/C,+BA0BK,OAAyB,CACtB,YACW,EACA,EACjB,CAFiB,eACA,8BAGL,QAAO,EAAqC,GAAI,CAC5D,GAAM,GAAQ,EAAQ,OAAS,IACzB,EAAa,EAAQ,YAAc,EAEnC,EAAU,EAAQ,iBACtB,EAAM,YAA+B,EAAY,CAC/C,QACA,eAGE,EAAmB,EAAQ,0BAC/B,EAAM,YAA+B,EAAqB,CACxD,QACA,eAGJ,MAAO,IAAI,GAAmB,EAAS,GAUlC,iBAAmB,MACxB,EAAY,KAKL,AAFU,MAAM,AADP,GAAY,KAAK,iBAAmB,KAAK,SAC1B,sBAEf,cAAc,IAAI,GAAM,EACtC,GAAI,EAAE,GAAG,IAAI,IAAM,OAAO,GAC1B,KAAM,EAAE,kBAAkB,IAAI,MAAQ,GACtC,YAAa,EAAE,kBAAkB,IAAI,YAAY,OAQvD,YAA+B,CAC7B,MAAO,IAAI,GAAU,CACnB,KAAM,kBACN,SAAU,GAAI",
6
- "names": []
7
- }