@dfinity/nns 0.2.2 → 0.3.0-nightly-2022-04-10
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.
- package/README.md +1 -6
- package/dist/candid/governanceTypes.d.ts +13 -9
- package/dist/cjs/index.cjs.js +36 -36
- package/dist/cjs/index.cjs.js.map +3 -3
- package/dist/esm/account_identifier.js +1 -1
- package/dist/esm/{chunk-2DZXLOEC.js → chunk-27LBXZJR.js} +3 -3
- package/dist/esm/{chunk-2DZXLOEC.js.map → chunk-27LBXZJR.js.map} +2 -2
- package/dist/esm/{chunk-HMU24NWJ.js → chunk-7AFR3LOO.js} +2 -2
- package/dist/esm/{chunk-HMU24NWJ.js.map → chunk-7AFR3LOO.js.map} +0 -0
- package/dist/esm/chunk-EXEYDII6.js +18 -0
- package/dist/esm/{chunk-FVDRR6PO.js.map → chunk-EXEYDII6.js.map} +3 -3
- package/dist/esm/chunk-F6ES4H7R.js +2 -0
- package/dist/esm/{chunk-QR4654XK.js.map → chunk-F6ES4H7R.js.map} +3 -3
- package/dist/esm/chunk-FY5QONEL.js +4 -0
- package/dist/esm/chunk-FY5QONEL.js.map +7 -0
- package/dist/esm/{chunk-D2W3ELRE.js → chunk-HQLGGFMH.js} +2 -2
- package/dist/esm/{chunk-D2W3ELRE.js.map → chunk-HQLGGFMH.js.map} +1 -1
- package/dist/esm/chunk-LSSEKDUC.js +3 -0
- package/dist/esm/chunk-LSSEKDUC.js.map +7 -0
- package/dist/esm/governance.js +1 -1
- package/dist/esm/icp.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/ledger.js +1 -1
- package/dist/proto/base_types_pb.js +217 -140
- package/dist/proto/ledger_pb.js +1571 -969
- package/dist/types/canisters/governance/payloads.d.ts +1 -1
- package/dist/types/canisters/governance/request.converters.d.ts +24 -26
- package/dist/types/canisters/governance/response.converters.d.ts +6 -35
- package/dist/types/canisters/governance/services.d.ts +9 -0
- package/dist/types/errors/governance.errors.d.ts +22 -0
- package/dist/types/errors/ledger.errors.d.ts +21 -0
- package/dist/types/governance.d.ts +95 -7
- package/dist/types/index.d.ts +4 -0
- package/dist/types/ledger.d.ts +9 -3
- package/dist/types/types/common.d.ts +4 -0
- package/dist/types/types/governance_converters.d.ts +1 -70
- package/dist/types/types/ledger.d.ts +3 -24
- package/dist/types/utils/converter.utils.d.ts +1 -6
- package/dist/types/utils/neurons.utils.d.ts +13 -0
- package/package.json +6 -4
- package/dist/candid/nns_dapp.certified.idl.js +0 -206
- package/dist/candid/nns_dapp.did +0 -240
- package/dist/candid/nns_dapp.idl.js +0 -206
- package/dist/esm/chunk-4FZAJTYF.js +0 -2
- package/dist/esm/chunk-4FZAJTYF.js.map +0 -7
- package/dist/esm/chunk-FVDRR6PO.js +0 -17
- package/dist/esm/chunk-LNMGZ6W7.js +0 -3
- package/dist/esm/chunk-LNMGZ6W7.js.map +0 -7
- package/dist/esm/chunk-QR4654XK.js +0 -2
- package/dist/esm/chunk-RUFBUR7C.js +0 -4
- package/dist/esm/chunk-RUFBUR7C.js.map +0 -7
- package/dist/esm/chunk-ZWZRSVU4.js +0 -2
- package/dist/esm/chunk-ZWZRSVU4.js.map +0 -7
- package/dist/types/types/option.d.ts +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Option } from "../../types/
|
|
1
|
+
import { Option } from "../../types/common";
|
|
2
2
|
export declare const getNnsFunctionName: (nnsFunction: number) => string;
|
|
3
3
|
export declare const convertNnsFunctionPayload: (nnsFunction: number, payload: ArrayBuffer) => Option<Record<string, unknown>>;
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { ListNeurons as RawListNeurons, ListProposalInfo, ManageNeuron as RawManageNeuron } from "../../../candid/governanceTypes.d";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
private fromClaimOrRefreshBy;
|
|
27
|
-
}
|
|
2
|
+
import { NeuronId } from "../../types/common";
|
|
3
|
+
import { ClaimNeuronRequest, ClaimOrRefreshNeuronRequest, DisburseToNeuronRequest, FollowRequest, ListProposalsRequest, MakeProposalRequest, ManageNeuron, ProposalId, SplitRequest, Vote } from "../../types/governance_converters";
|
|
4
|
+
export declare const fromListNeurons: (neuronIds?: bigint[] | undefined) => RawListNeurons;
|
|
5
|
+
export declare const fromManageNeuron: ({ id, command, neuronIdOrSubaccount, }: ManageNeuron) => RawManageNeuron;
|
|
6
|
+
export declare const fromClaimNeuronRequest: ({ publicKey, nonce, dissolveDelayInSecs, }: ClaimNeuronRequest) => [Array<number>, bigint, bigint];
|
|
7
|
+
export declare const fromListProposalsRequest: ({ includeRewardStatus, beforeProposal, excludeTopic, includeStatus, limit, }: ListProposalsRequest) => ListProposalInfo;
|
|
8
|
+
export declare const fromClaimOrRefreshNeuronRequest: (request: ClaimOrRefreshNeuronRequest) => RawManageNeuron;
|
|
9
|
+
export declare const fromSplitRequest: (request: SplitRequest) => RawManageNeuron;
|
|
10
|
+
export declare const fromDisburseToNeuronRequest: (request: DisburseToNeuronRequest) => RawManageNeuron;
|
|
11
|
+
export declare const fromMakeProposalRequest: (request: MakeProposalRequest) => RawManageNeuron;
|
|
12
|
+
export declare const toRegisterVoteRequest: ({ neuronId, vote, proposalId, }: {
|
|
13
|
+
neuronId: NeuronId;
|
|
14
|
+
vote: Vote;
|
|
15
|
+
proposalId: ProposalId;
|
|
16
|
+
}) => RawManageNeuron;
|
|
17
|
+
export declare const toMakeProposalRawRequest: (request: MakeProposalRequest) => RawManageNeuron;
|
|
18
|
+
export declare const toManageNeuronsFollowRequest: ({ neuronId, topic, followees, }: FollowRequest) => RawManageNeuron;
|
|
19
|
+
export declare const toIncreaseDissolveDelayRequest: ({ neuronId, additionalDissolveDelaySeconds, }: {
|
|
20
|
+
neuronId: NeuronId;
|
|
21
|
+
additionalDissolveDelaySeconds: number;
|
|
22
|
+
}) => RawManageNeuron;
|
|
23
|
+
export declare const toJoinCommunityFundRequest: (neuronId: NeuronId) => RawManageNeuron;
|
|
24
|
+
export declare const toStartDissolvingRequest: (neuronId: NeuronId) => RawManageNeuron;
|
|
25
|
+
export declare const toStopDissolvingRequest: (neuronId: NeuronId) => RawManageNeuron;
|
|
@@ -1,35 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { KnownNeuron
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare
|
|
7
|
-
toProposalInfo: (proposalInfo: RawProposalInfo) => ProposalInfo;
|
|
8
|
-
toArrayOfNeuronInfo: (response: RawListNeuronsResponse, principal: Principal) => Array<NeuronInfo>;
|
|
9
|
-
private toNeuronInfo;
|
|
10
|
-
toListProposalsResponse: (response: RawListProposalInfoResponse) => ListProposalsResponse;
|
|
11
|
-
toKnownNeuron: (response: RawKnownNeuron) => KnownNeuron;
|
|
12
|
-
toSplitResponse: (response: RawManageNeuronResponse) => NeuronId;
|
|
13
|
-
toDisburseToNeuronResult: (response: RawManageNeuronResponse) => DisburseToNeuronResponse;
|
|
14
|
-
toClaimOrRefreshNeuronResponse: (response: RawManageNeuronResponse) => Option<NeuronId>;
|
|
15
|
-
toMakeProposalResponse: (response: RawManageNeuronResponse) => MakeProposalResponse;
|
|
16
|
-
private toNeuron;
|
|
17
|
-
private toBallotInfo;
|
|
18
|
-
private toDissolveState;
|
|
19
|
-
private toFollowees;
|
|
20
|
-
private toNeuronId;
|
|
21
|
-
private toNeuronIdOrSubaccount;
|
|
22
|
-
private toBallot;
|
|
23
|
-
private toProposal;
|
|
24
|
-
private toAction;
|
|
25
|
-
private toTally;
|
|
26
|
-
private toCommand;
|
|
27
|
-
private toOperation;
|
|
28
|
-
private toChange;
|
|
29
|
-
private toNodeProvider;
|
|
30
|
-
private toAmount;
|
|
31
|
-
private toAccountIdentifier;
|
|
32
|
-
private toRewardMode;
|
|
33
|
-
private toClaimOrRefreshBy;
|
|
34
|
-
private throwUnrecognisedTypeError;
|
|
35
|
-
}
|
|
1
|
+
import { KnownNeuron as RawKnownNeuron, ListNeuronsResponse as RawListNeuronsResponse, ListProposalInfoResponse as RawListProposalInfoResponse, ProposalInfo as RawProposalInfo } from "../../../candid/governanceTypes.d";
|
|
2
|
+
import { KnownNeuron, ListProposalsResponse, NeuronInfo, ProposalInfo } from "../../types/governance_converters";
|
|
3
|
+
export declare const toProposalInfo: (proposalInfo: RawProposalInfo) => ProposalInfo;
|
|
4
|
+
export declare const toArrayOfNeuronInfo: ({ neuron_infos, full_neurons, }: RawListNeuronsResponse) => Array<NeuronInfo>;
|
|
5
|
+
export declare const toListProposalsResponse: ({ proposal_info, }: RawListProposalInfoResponse) => ListProposalsResponse;
|
|
6
|
+
export declare const toKnownNeuron: ({ id, known_neuron_data, }: RawKnownNeuron) => KnownNeuron;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GovernanceService } from "../../../candid/governance.idl";
|
|
2
|
+
import { ManageNeuron } from "../../../candid/governanceTypes";
|
|
3
|
+
/**
|
|
4
|
+
* @throws {@link GovernanceError}
|
|
5
|
+
*/
|
|
6
|
+
export declare const manageNeuron: ({ request, service, }: {
|
|
7
|
+
request: ManageNeuron;
|
|
8
|
+
service: GovernanceService;
|
|
9
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GovernanceErrorDetail } from "../../candid/governanceTypes";
|
|
2
|
+
import { ICP } from "../icp";
|
|
3
|
+
export declare abstract class StakeNeuronError extends Error {
|
|
4
|
+
}
|
|
5
|
+
export declare class CouldNotClaimNeuronError extends StakeNeuronError {
|
|
6
|
+
}
|
|
7
|
+
export declare class InsufficientAmountError extends StakeNeuronError {
|
|
8
|
+
readonly minimumAmount: ICP;
|
|
9
|
+
constructor(minimumAmount: ICP);
|
|
10
|
+
}
|
|
11
|
+
export declare class UnrecognizedTypeError extends Error {
|
|
12
|
+
}
|
|
13
|
+
export declare class GovernanceError extends Error {
|
|
14
|
+
readonly detail: GovernanceErrorDetail;
|
|
15
|
+
constructor(detail: GovernanceErrorDetail);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* An error used to ensure at compile-time that it's never reached.
|
|
19
|
+
*/
|
|
20
|
+
export declare class UnsupportedValueError extends Error {
|
|
21
|
+
constructor(value: never);
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ICP } from "../icp";
|
|
2
|
+
import { BlockHeight } from "../types/common";
|
|
3
|
+
export declare abstract class TransferError extends Error {
|
|
4
|
+
}
|
|
5
|
+
export declare class InvalidSenderError extends TransferError {
|
|
6
|
+
}
|
|
7
|
+
export declare class InsufficientFundsError extends TransferError {
|
|
8
|
+
readonly balance: ICP;
|
|
9
|
+
constructor(balance: ICP);
|
|
10
|
+
}
|
|
11
|
+
export declare class TxTooOldError extends TransferError {
|
|
12
|
+
readonly allowed_window_secs: number;
|
|
13
|
+
constructor(allowed_window_secs: number);
|
|
14
|
+
}
|
|
15
|
+
export declare class TxCreatedInFutureError extends TransferError {
|
|
16
|
+
}
|
|
17
|
+
export declare class TxDuplicateError extends TransferError {
|
|
18
|
+
readonly duplicateOf: BlockHeight;
|
|
19
|
+
constructor(duplicateOf: BlockHeight);
|
|
20
|
+
}
|
|
21
|
+
export declare const mapTransferError: (responseBytes: Error) => TransferError;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { Principal } from "@dfinity/principal";
|
|
2
|
+
import { ICP } from "./icp";
|
|
3
|
+
import { LedgerCanister } from "./ledger";
|
|
1
4
|
import { NeuronId } from "./types/common";
|
|
2
5
|
import { GovernanceCanisterOptions } from "./types/governance";
|
|
3
|
-
import { ClaimOrRefreshNeuronFromAccount, KnownNeuron, ListProposalsRequest, ListProposalsResponse, NeuronInfo } from "./types/governance_converters";
|
|
6
|
+
import { ClaimOrRefreshNeuronFromAccount, ClaimOrRefreshNeuronRequest, FollowRequest, KnownNeuron, ListProposalsRequest, ListProposalsResponse, MakeProposalRequest, NeuronInfo, ProposalId, ProposalInfo, Vote } from "./types/governance_converters";
|
|
4
7
|
export declare class GovernanceCanister {
|
|
8
|
+
private readonly canisterId;
|
|
5
9
|
private readonly service;
|
|
6
10
|
private readonly certifiedService;
|
|
7
|
-
private readonly requestConverters;
|
|
8
|
-
private readonly responseConverters;
|
|
9
|
-
private readonly myPrincipal?;
|
|
10
11
|
private constructor();
|
|
11
12
|
static create(options?: GovernanceCanisterOptions): GovernanceCanister;
|
|
12
13
|
/**
|
|
@@ -17,9 +18,8 @@ export declare class GovernanceCanister {
|
|
|
17
18
|
* If `certified` is true, the request is fetched as an update call, otherwise
|
|
18
19
|
* it is fetched using a query call.
|
|
19
20
|
*
|
|
20
|
-
* TODO: Decide: The library method is getNeurons but the raw method is list_neurons. Do we want this inconsistency?
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
listNeurons: ({ certified, neuronIds, }: {
|
|
23
23
|
certified: boolean;
|
|
24
24
|
neuronIds?: bigint[] | undefined;
|
|
25
25
|
}) => Promise<NeuronInfo[]>;
|
|
@@ -42,8 +42,96 @@ export declare class GovernanceCanister {
|
|
|
42
42
|
request: ListProposalsRequest;
|
|
43
43
|
certified?: boolean | undefined;
|
|
44
44
|
}) => Promise<ListProposalsResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* @throws {@link InsufficientAmountError}
|
|
47
|
+
* @throws {@link StakeNeuronTransferError}
|
|
48
|
+
* @throws {@link CouldNotClaimNeuronError}
|
|
49
|
+
* @throws {@link TransferError}
|
|
50
|
+
*/
|
|
51
|
+
stakeNeuron: ({ stake, principal, fromSubAccountId, ledgerCanister, }: {
|
|
52
|
+
stake: ICP;
|
|
53
|
+
principal: Principal;
|
|
54
|
+
fromSubAccountId?: number | undefined;
|
|
55
|
+
ledgerCanister: LedgerCanister;
|
|
56
|
+
}) => Promise<NeuronId>;
|
|
57
|
+
/**
|
|
58
|
+
* Increases dissolve delay of a neuron
|
|
59
|
+
*
|
|
60
|
+
* @throws {@link GovernanceError}
|
|
61
|
+
*/
|
|
62
|
+
increaseDissolveDelay: ({ neuronId, additionalDissolveDelaySeconds, }: {
|
|
63
|
+
neuronId: NeuronId;
|
|
64
|
+
additionalDissolveDelaySeconds: number;
|
|
65
|
+
}) => Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Start dissolving process of a neuron
|
|
68
|
+
*
|
|
69
|
+
* @throws {@link GovernanceError}
|
|
70
|
+
*/
|
|
71
|
+
startDissolving: (neuronId: NeuronId) => Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Stop dissolving process of a neuron
|
|
74
|
+
*
|
|
75
|
+
* @throws {@link GovernanceError}
|
|
76
|
+
*/
|
|
77
|
+
stopDissolving: (neuronId: NeuronId) => Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Neuron joins the community fund
|
|
80
|
+
*
|
|
81
|
+
* @throws {@link GovernanceError}
|
|
82
|
+
*/
|
|
83
|
+
joinCommunityFund: (neuronId: NeuronId) => Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Returns single proposal info
|
|
86
|
+
*
|
|
87
|
+
* If `certified` is true (default), the request is fetched as an update call, otherwise
|
|
88
|
+
* it is fetched using a query call.
|
|
89
|
+
*/
|
|
90
|
+
getProposal: ({ proposalId, certified, }: {
|
|
91
|
+
proposalId: bigint;
|
|
92
|
+
certified?: boolean | undefined;
|
|
93
|
+
}) => Promise<ProposalInfo | undefined>;
|
|
94
|
+
/**
|
|
95
|
+
* Create new proposal
|
|
96
|
+
*
|
|
97
|
+
* @throws {@link GovernanceError}
|
|
98
|
+
*/
|
|
99
|
+
makeProposal: (request: MakeProposalRequest) => Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* Registers vote for a proposal from the neuron passed.
|
|
103
|
+
*
|
|
104
|
+
* @throws {@link GovernanceError}
|
|
105
|
+
*/
|
|
106
|
+
registerVote: ({ neuronId, vote, proposalId, }: {
|
|
107
|
+
neuronId: NeuronId;
|
|
108
|
+
vote: Vote;
|
|
109
|
+
proposalId: ProposalId;
|
|
110
|
+
}) => Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Edit neuron followees per topic
|
|
113
|
+
*
|
|
114
|
+
* @throws {@link GovernanceError}
|
|
115
|
+
*/
|
|
116
|
+
setFollowees: (followRequest: FollowRequest) => Promise<void>;
|
|
45
117
|
/**
|
|
46
118
|
* Gets the NeuronID of a newly created neuron.
|
|
47
119
|
*/
|
|
48
|
-
claimOrRefreshNeuronFromAccount: (request: ClaimOrRefreshNeuronFromAccount) => Promise<NeuronId>;
|
|
120
|
+
claimOrRefreshNeuronFromAccount: (request: ClaimOrRefreshNeuronFromAccount) => Promise<NeuronId | undefined>;
|
|
121
|
+
/**
|
|
122
|
+
* Refreshes neuron and returns neuronId when successful
|
|
123
|
+
* Uses query call only.
|
|
124
|
+
*
|
|
125
|
+
* @throws {@link UnrecognizedTypeError}
|
|
126
|
+
*/
|
|
127
|
+
claimOrRefreshNeuron: (request: ClaimOrRefreshNeuronRequest) => Promise<NeuronId | undefined>;
|
|
128
|
+
private buildNeuronStakeSubAccount;
|
|
129
|
+
private getGovernanceService;
|
|
130
|
+
/**
|
|
131
|
+
* Return the data of the neuron provided as id.
|
|
132
|
+
*/
|
|
133
|
+
getNeuron: ({ certified, neuronId, }: {
|
|
134
|
+
certified: boolean;
|
|
135
|
+
neuronId: NeuronId;
|
|
136
|
+
}) => Promise<NeuronInfo | undefined>;
|
|
49
137
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export { AccountIdentifier, SubAccount } from "./account_identifier";
|
|
2
|
+
export * from "./errors/governance.errors";
|
|
3
|
+
export * from "./errors/ledger.errors";
|
|
2
4
|
export { GovernanceCanister } from "./governance";
|
|
3
5
|
export { ICP } from "./icp";
|
|
4
6
|
export { LedgerCanister } from "./ledger";
|
|
7
|
+
export * from "./types/common";
|
|
5
8
|
export * from "./types/governance";
|
|
6
9
|
export * from "./types/governance_converters";
|
|
7
10
|
export * from "./types/icp";
|
|
8
11
|
export * from "./types/ledger";
|
|
12
|
+
export * from "./utils/neurons.utils";
|
package/dist/types/ledger.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccountIdentifier } from "./account_identifier";
|
|
2
2
|
import { ICP } from "./icp";
|
|
3
3
|
import { BlockHeight } from "./types/common";
|
|
4
|
-
import { LedgerCanisterOptions
|
|
4
|
+
import { LedgerCanisterOptions } from "./types/ledger";
|
|
5
5
|
export declare class LedgerCanister {
|
|
6
6
|
private readonly agent;
|
|
7
7
|
private readonly canisterId;
|
|
@@ -14,6 +14,8 @@ export declare class LedgerCanister {
|
|
|
14
14
|
*
|
|
15
15
|
* If `certified` is true, the request is fetched as an update call, otherwise
|
|
16
16
|
* it is fetched using a query call.
|
|
17
|
+
*
|
|
18
|
+
* @throws {@link Error}
|
|
17
19
|
*/
|
|
18
20
|
accountBalance: ({ accountIdentifier, certified, }: {
|
|
19
21
|
accountIdentifier: AccountIdentifier;
|
|
@@ -24,10 +26,14 @@ export declare class LedgerCanister {
|
|
|
24
26
|
* Returns the index of the block containing the tx if it was successful.
|
|
25
27
|
*
|
|
26
28
|
* TODO: support remaining options (subaccounts, memos, etc.)
|
|
29
|
+
*
|
|
30
|
+
* @throws {@link TransferError}
|
|
27
31
|
*/
|
|
28
|
-
transfer: ({ to, amount, memo, }: {
|
|
32
|
+
transfer: ({ to, amount, memo, fromSubAccountId, }: {
|
|
29
33
|
to: AccountIdentifier;
|
|
30
34
|
amount: ICP;
|
|
31
35
|
memo?: bigint | undefined;
|
|
32
|
-
|
|
36
|
+
fromSubAccountId?: number | undefined;
|
|
37
|
+
}) => Promise<BlockHeight>;
|
|
38
|
+
private subAccountIdToSubaccount;
|
|
33
39
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Agent } from "@dfinity/agent";
|
|
2
|
+
import { Principal } from "@dfinity/principal";
|
|
1
3
|
export declare type CanisterIdString = string;
|
|
2
4
|
export declare type NeuronId = bigint;
|
|
3
5
|
export declare type AccountIdentifier = string;
|
|
@@ -6,3 +8,5 @@ export declare type E8s = bigint;
|
|
|
6
8
|
export declare type Memo = bigint;
|
|
7
9
|
export declare type PrincipalString = string;
|
|
8
10
|
export declare type SubAccount = Uint8Array;
|
|
11
|
+
export declare type CanisterCall = (agent: Agent, canisterId: Principal, methodName: string, arg: ArrayBuffer) => Promise<Uint8Array | Error>;
|
|
12
|
+
export declare type Option<T> = T | undefined;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DerEncodedPublicKey } from "@dfinity/agent";
|
|
2
2
|
import { Principal } from "@dfinity/principal";
|
|
3
|
-
import { AccountIdentifier, CanisterIdString, E8s, NeuronId, PrincipalString } from "./common";
|
|
4
|
-
import { Option } from "./option";
|
|
3
|
+
import { AccountIdentifier, CanisterIdString, E8s, NeuronId, Option, PrincipalString } from "./common";
|
|
5
4
|
export declare type Action = {
|
|
6
5
|
RegisterKnownNeuron: KnownNeuron;
|
|
7
6
|
} | {
|
|
@@ -133,10 +132,6 @@ export interface Followees {
|
|
|
133
132
|
topic: Topic;
|
|
134
133
|
followees: Array<NeuronId>;
|
|
135
134
|
}
|
|
136
|
-
export interface GovernanceError {
|
|
137
|
-
errorMessage: string;
|
|
138
|
-
errorType: number;
|
|
139
|
-
}
|
|
140
135
|
export interface IncreaseDissolveDelay {
|
|
141
136
|
additionalDissolveDelaySeconds: number;
|
|
142
137
|
}
|
|
@@ -205,7 +200,6 @@ export interface NetworkEconomics {
|
|
|
205
200
|
}
|
|
206
201
|
export interface Neuron {
|
|
207
202
|
id: Option<NeuronId>;
|
|
208
|
-
isCurrentUserController: Option<boolean>;
|
|
209
203
|
controller: Option<PrincipalString>;
|
|
210
204
|
recentBallots: Array<BallotInfo>;
|
|
211
205
|
kycVerified: boolean;
|
|
@@ -337,21 +331,6 @@ export declare type ClaimNeuronRequest = {
|
|
|
337
331
|
nonce: bigint;
|
|
338
332
|
dissolveDelayInSecs: bigint;
|
|
339
333
|
};
|
|
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
334
|
export interface RewardNodeProvider {
|
|
356
335
|
nodeProvider: Option<NodeProvider>;
|
|
357
336
|
rewardMode: Option<RewardMode>;
|
|
@@ -363,9 +342,6 @@ export interface SetDefaultFollowees {
|
|
|
363
342
|
export interface Spawn {
|
|
364
343
|
newController: Option<PrincipalString>;
|
|
365
344
|
}
|
|
366
|
-
export interface SpawnResponse {
|
|
367
|
-
createdNeuronId: NeuronId;
|
|
368
|
-
}
|
|
369
345
|
export interface Split {
|
|
370
346
|
amount: E8s;
|
|
371
347
|
}
|
|
@@ -485,48 +461,3 @@ export interface MakeExecuteNnsFunctionProposalRequest {
|
|
|
485
461
|
nnsFunction: number;
|
|
486
462
|
payload: ArrayBuffer;
|
|
487
463
|
}
|
|
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
|
-
}
|
|
@@ -1,30 +1,9 @@
|
|
|
1
1
|
import { Agent } from "@dfinity/agent";
|
|
2
2
|
import { Principal } from "@dfinity/principal";
|
|
3
|
-
import {
|
|
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>;
|
|
3
|
+
import { CanisterCall } from "./common";
|
|
25
4
|
export interface LedgerCanisterOptions {
|
|
26
5
|
agent?: Agent;
|
|
27
6
|
canisterId?: Principal;
|
|
28
|
-
updateCallOverride?:
|
|
29
|
-
queryCallOverride?:
|
|
7
|
+
updateCallOverride?: CanisterCall;
|
|
8
|
+
queryCallOverride?: CanisterCall;
|
|
30
9
|
}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { Principal } from "@dfinity/principal";
|
|
2
|
-
import { AccountIdentifier
|
|
2
|
+
import { AccountIdentifier } from "../types/common";
|
|
3
3
|
export declare const uint8ArrayToBigInt: (array: Uint8Array) => bigint;
|
|
4
|
-
export declare const bigIntToUint8Array: (value: bigint) => Uint8Array;
|
|
5
4
|
export declare const arrayBufferToArrayOfNumber: (buffer: ArrayBuffer) => Array<number>;
|
|
6
5
|
export declare const arrayOfNumberToUint8Array: (numbers: Array<number>) => Uint8Array;
|
|
7
6
|
export declare const arrayOfNumberToArrayBuffer: (numbers: Array<number>) => ArrayBuffer;
|
|
8
|
-
export declare const arrayBufferToNumber: (buffer: ArrayBuffer) => number;
|
|
9
7
|
export declare const numberToArrayBuffer: (value: number, byteLength: number) => ArrayBuffer;
|
|
10
8
|
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
9
|
export declare const accountIdentifierToBytes: (accountIdentifier: AccountIdentifier) => Uint8Array;
|
|
14
10
|
export declare const accountIdentifierFromBytes: (accountIdentifier: Uint8Array) => AccountIdentifier;
|
|
15
11
|
export declare const principalToAccountIdentifier: (principal: Principal, subAccount?: Uint8Array | undefined) => string;
|
|
16
|
-
export declare const principalToSubAccount: (principal: Principal) => SubAccount;
|
|
17
12
|
export declare const toHexString: (bytes: Uint8Array) => string;
|
|
18
13
|
export declare const calculateCrc32: (bytes: Uint8Array) => Uint8Array;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NeuronInfo, ProposalInfo } from "../types/governance_converters";
|
|
2
|
+
export declare const ineligibleNeurons: ({ neurons, proposal, }: {
|
|
3
|
+
neurons: NeuronInfo[];
|
|
4
|
+
proposal: ProposalInfo;
|
|
5
|
+
}) => NeuronInfo[];
|
|
6
|
+
export declare const notVotedNeurons: ({ neurons, proposal, }: {
|
|
7
|
+
neurons: NeuronInfo[];
|
|
8
|
+
proposal: ProposalInfo;
|
|
9
|
+
}) => NeuronInfo[];
|
|
10
|
+
export declare const votedNeurons: ({ neurons, proposal, }: {
|
|
11
|
+
neurons: NeuronInfo[];
|
|
12
|
+
proposal: ProposalInfo;
|
|
13
|
+
}) => NeuronInfo[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dfinity/nns",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-nightly-2022-04-10",
|
|
4
4
|
"description": "A library for interfacing with the Internet Computer's Network Nervous System.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/cjs/index.cjs.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"lint": "eslint --max-warnings 0 .",
|
|
22
22
|
"format": "prettier --write .",
|
|
23
23
|
"prepare": "npm run build",
|
|
24
|
-
"
|
|
24
|
+
"protoc": "bash ./scripts/update_proto.sh"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@dfinity/agent": "^0.10.3",
|
|
@@ -30,11 +30,13 @@
|
|
|
30
30
|
"crc": "^3.8.0",
|
|
31
31
|
"crc-32": "^1.2.0",
|
|
32
32
|
"google-protobuf": "^3.19.1",
|
|
33
|
-
"js-sha256": "^0.9.0"
|
|
33
|
+
"js-sha256": "^0.9.0",
|
|
34
|
+
"randombytes": "^2.1.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@types/google-protobuf": "^3.15.5",
|
|
37
38
|
"@types/jest": "^27.0.3",
|
|
39
|
+
"@types/randombytes": "^2.0.0",
|
|
38
40
|
"@types/text-encoding": "^0.0.36",
|
|
39
41
|
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
|
40
42
|
"esbuild": "^0.14.14",
|
|
@@ -78,4 +80,4 @@
|
|
|
78
80
|
"network nervous system",
|
|
79
81
|
"network-nervous-system"
|
|
80
82
|
]
|
|
81
|
-
}
|
|
83
|
+
}
|