@dfinity/nns 0.1.8 → 0.2.2
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 +10 -11
- package/dist/candid/governance.certified.idl.d.ts +2 -0
- package/dist/candid/governance.certified.idl.js +704 -0
- package/dist/candid/governance.did +338 -0
- package/dist/candid/governance.idl.d.ts +5 -0
- package/dist/candid/governance.idl.js +712 -0
- package/dist/candid/governanceTypes.d.ts +413 -0
- package/dist/candid/nns_dapp.certified.idl.js +206 -0
- package/dist/candid/nns_dapp.did +240 -0
- package/dist/candid/nns_dapp.idl.js +206 -0
- package/dist/candid/payloads.did +168 -0
- package/dist/candid/payloads.idl.d.ts +20 -0
- package/dist/candid/payloads.idl.js +163 -0
- package/dist/cjs/index.cjs.js +869 -0
- package/dist/cjs/index.cjs.js.map +7 -0
- package/dist/esm/account_identifier.js +2 -0
- package/dist/esm/account_identifier.js.map +7 -0
- package/dist/esm/chunk-2DZXLOEC.js +14 -0
- package/dist/esm/chunk-2DZXLOEC.js.map +7 -0
- package/dist/esm/chunk-4FZAJTYF.js +2 -0
- package/dist/esm/chunk-4FZAJTYF.js.map +7 -0
- package/dist/esm/chunk-D2W3ELRE.js +3 -0
- package/dist/esm/chunk-D2W3ELRE.js.map +7 -0
- package/dist/esm/chunk-FVDRR6PO.js +17 -0
- package/dist/esm/chunk-FVDRR6PO.js.map +7 -0
- package/dist/esm/chunk-HMU24NWJ.js +825 -0
- package/dist/esm/chunk-HMU24NWJ.js.map +7 -0
- package/dist/esm/chunk-LNMGZ6W7.js +3 -0
- package/dist/esm/chunk-LNMGZ6W7.js.map +7 -0
- package/dist/esm/chunk-QR4654XK.js +2 -0
- package/dist/esm/chunk-QR4654XK.js.map +7 -0
- package/dist/esm/chunk-RUFBUR7C.js +4 -0
- package/dist/esm/chunk-RUFBUR7C.js.map +7 -0
- package/dist/esm/chunk-ZWZRSVU4.js +2 -0
- package/dist/esm/chunk-ZWZRSVU4.js.map +7 -0
- package/dist/esm/governance.js +2 -0
- package/dist/esm/governance.js.map +7 -0
- package/dist/esm/icp.js +2 -0
- package/dist/esm/icp.js.map +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/ledger.js +2 -0
- package/dist/esm/ledger.js.map +7 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/proto/base_types.proto +60 -0
- package/dist/proto/base_types_pb.d.ts +144 -0
- package/dist/proto/base_types_pb.js +1071 -0
- package/dist/proto/ledger.proto +277 -0
- package/dist/proto/ledger_pb.d.ts +911 -0
- package/dist/proto/ledger_pb.js +6555 -0
- package/dist/types/account_identifier.d.ts +24 -0
- package/dist/types/canisters/governance/payloads.d.ts +3 -0
- package/dist/types/canisters/governance/request.converters.d.ts +27 -0
- package/dist/types/canisters/governance/response.converters.d.ts +35 -0
- package/dist/types/constants/canister_ids.d.ts +4 -0
- package/dist/types/constants/constants.d.ts +5 -0
- package/dist/types/governance.d.ts +49 -0
- package/dist/types/icp.d.ts +17 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/ledger.d.ts +33 -0
- package/dist/types/types/common.d.ts +8 -0
- package/dist/types/types/governance.d.ts +9 -0
- package/dist/types/types/governance_converters.d.ts +532 -0
- package/dist/types/types/icp.d.ts +4 -0
- package/dist/types/types/ledger.d.ts +30 -0
- package/dist/types/types/option.d.ts +1 -0
- package/dist/types/utils/agent.utils.d.ts +5 -0
- package/dist/types/utils/converter.utils.d.ts +18 -0
- package/dist/types/utils/proto.utils.d.ts +12 -0
- package/package.json +18 -15
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Principal } from "@dfinity/principal";
|
|
2
|
+
import { AccountIdentifier as AccountIdentifierPb } from "../proto/ledger_pb";
|
|
3
|
+
export declare class AccountIdentifier {
|
|
4
|
+
private readonly bytes;
|
|
5
|
+
private constructor();
|
|
6
|
+
static fromHex(hex: string): AccountIdentifier;
|
|
7
|
+
static fromPrincipal({ principal, subAccount, }: {
|
|
8
|
+
principal: Principal;
|
|
9
|
+
subAccount?: SubAccount;
|
|
10
|
+
}): AccountIdentifier;
|
|
11
|
+
/**
|
|
12
|
+
* @returns An AccountIdentifier protobuf object.
|
|
13
|
+
*/
|
|
14
|
+
toProto(): AccountIdentifierPb;
|
|
15
|
+
toHex(): string;
|
|
16
|
+
}
|
|
17
|
+
export declare class SubAccount {
|
|
18
|
+
private readonly bytes;
|
|
19
|
+
private constructor();
|
|
20
|
+
static fromBytes(bytes: Uint8Array): SubAccount | Error;
|
|
21
|
+
static fromPrincipal(principal: Principal): SubAccount;
|
|
22
|
+
static ZERO: SubAccount;
|
|
23
|
+
toUint8Array(): Uint8Array;
|
|
24
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ListNeurons as RawListNeurons, ListProposalInfo, ManageNeuron as RawManageNeuron } from "../../../candid/governanceTypes.d";
|
|
2
|
+
import { ClaimNeuronRequest, ClaimOrRefreshNeuronRequest, DisburseToNeuronRequest, ListProposalsRequest, MakeProposalRequest, ManageNeuron, SplitRequest } from "../../types/governance_converters";
|
|
3
|
+
export declare class RequestConverters {
|
|
4
|
+
private readonly principal?;
|
|
5
|
+
constructor();
|
|
6
|
+
fromListNeurons: (neuronIds?: bigint[] | undefined) => RawListNeurons;
|
|
7
|
+
fromManageNeuron: (manageNeuron: ManageNeuron) => RawManageNeuron;
|
|
8
|
+
fromClaimNeuronRequest: (request: ClaimNeuronRequest) => [Array<number>, bigint, bigint];
|
|
9
|
+
fromListProposalsRequest: (request: ListProposalsRequest) => ListProposalInfo;
|
|
10
|
+
fromClaimOrRefreshNeuronRequest: (request: ClaimOrRefreshNeuronRequest) => RawManageNeuron;
|
|
11
|
+
fromSplitRequest: (request: SplitRequest) => RawManageNeuron;
|
|
12
|
+
fromDisburseToNeuronRequest: (request: DisburseToNeuronRequest) => RawManageNeuron;
|
|
13
|
+
fromMakeProposalRequest: (request: MakeProposalRequest) => RawManageNeuron;
|
|
14
|
+
private fromFollowees;
|
|
15
|
+
private fromNeuronId;
|
|
16
|
+
private fromNeuronIdOrSubaccount;
|
|
17
|
+
private fromProposalId;
|
|
18
|
+
private fromAction;
|
|
19
|
+
private fromCommand;
|
|
20
|
+
private fromOperation;
|
|
21
|
+
private fromChange;
|
|
22
|
+
private fromNodeProvider;
|
|
23
|
+
private fromAmount;
|
|
24
|
+
private fromAccountIdentifier;
|
|
25
|
+
private fromRewardMode;
|
|
26
|
+
private fromClaimOrRefreshBy;
|
|
27
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Principal } from "@dfinity/principal";
|
|
2
|
+
import { KnownNeuron as RawKnownNeuron, ListNeuronsResponse as RawListNeuronsResponse, ListProposalInfoResponse as RawListProposalInfoResponse, ManageNeuronResponse as RawManageNeuronResponse, ProposalInfo as RawProposalInfo } from "../../../candid/governanceTypes.d";
|
|
3
|
+
import { NeuronId } from "../../types/common";
|
|
4
|
+
import { DisburseToNeuronResponse, KnownNeuron, ListProposalsResponse, MakeProposalResponse, NeuronInfo, ProposalInfo } from "../../types/governance_converters";
|
|
5
|
+
import { Option } from "../../types/option";
|
|
6
|
+
export declare class ResponseConverters {
|
|
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
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NeuronId } from "./types/common";
|
|
2
|
+
import { GovernanceCanisterOptions } from "./types/governance";
|
|
3
|
+
import { ClaimOrRefreshNeuronFromAccount, KnownNeuron, ListProposalsRequest, ListProposalsResponse, NeuronInfo } from "./types/governance_converters";
|
|
4
|
+
export declare class GovernanceCanister {
|
|
5
|
+
private readonly service;
|
|
6
|
+
private readonly certifiedService;
|
|
7
|
+
private readonly requestConverters;
|
|
8
|
+
private readonly responseConverters;
|
|
9
|
+
private readonly myPrincipal?;
|
|
10
|
+
private constructor();
|
|
11
|
+
static create(options?: GovernanceCanisterOptions): GovernanceCanister;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the list of neurons controlled by the caller.
|
|
14
|
+
*
|
|
15
|
+
* If an array of neuron IDs is provided, precisely those neurons will be fetched.
|
|
16
|
+
*
|
|
17
|
+
* If `certified` is true, the request is fetched as an update call, otherwise
|
|
18
|
+
* it is fetched using a query call.
|
|
19
|
+
*
|
|
20
|
+
* TODO: Decide: The library method is getNeurons but the raw method is list_neurons. Do we want this inconsistency?
|
|
21
|
+
*/
|
|
22
|
+
getNeurons: ({ certified, neuronIds, }: {
|
|
23
|
+
certified: boolean;
|
|
24
|
+
neuronIds?: bigint[] | undefined;
|
|
25
|
+
}) => Promise<NeuronInfo[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the list of neurons who have been approved by the community to
|
|
28
|
+
* appear as the default followee options.
|
|
29
|
+
*
|
|
30
|
+
* If `certified` is true, the request is fetched as an update call, otherwise
|
|
31
|
+
* it is fetched using a query call.
|
|
32
|
+
*/
|
|
33
|
+
listKnownNeurons: (certified?: boolean) => Promise<KnownNeuron[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the list of proposals made for the community to vote on,
|
|
36
|
+
* paginated and filtered by the request.
|
|
37
|
+
*
|
|
38
|
+
* If `certified` is true (default), the request is fetched as an update call, otherwise
|
|
39
|
+
* it is fetched using a query call.
|
|
40
|
+
*/
|
|
41
|
+
listProposals: ({ request, certified, }: {
|
|
42
|
+
request: ListProposalsRequest;
|
|
43
|
+
certified?: boolean | undefined;
|
|
44
|
+
}) => Promise<ListProposalsResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* Gets the NeuronID of a newly created neuron.
|
|
47
|
+
*/
|
|
48
|
+
claimOrRefreshNeuronFromAccount: (request: ClaimOrRefreshNeuronFromAccount) => Promise<NeuronId>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ICPTs } from "../proto/ledger_pb";
|
|
2
|
+
import { FromICPStringError } from "./types/icp";
|
|
3
|
+
export declare class ICP {
|
|
4
|
+
private e8s;
|
|
5
|
+
private constructor();
|
|
6
|
+
static fromE8s(amount: bigint): ICP;
|
|
7
|
+
/**
|
|
8
|
+
* Initialize from a string. Accepted formats:
|
|
9
|
+
*
|
|
10
|
+
* 1234567.8901
|
|
11
|
+
* 1'234'567.8901
|
|
12
|
+
* 1,234,567.8901
|
|
13
|
+
*/
|
|
14
|
+
static fromString(amount: string): ICP | FromICPStringError;
|
|
15
|
+
toE8s(): bigint;
|
|
16
|
+
toProto(): ICPTs;
|
|
17
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AccountIdentifier, SubAccount } from "./account_identifier";
|
|
2
|
+
export { GovernanceCanister } from "./governance";
|
|
3
|
+
export { ICP } from "./icp";
|
|
4
|
+
export { LedgerCanister } from "./ledger";
|
|
5
|
+
export * from "./types/governance";
|
|
6
|
+
export * from "./types/governance_converters";
|
|
7
|
+
export * from "./types/icp";
|
|
8
|
+
export * from "./types/ledger";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AccountIdentifier } from "./account_identifier";
|
|
2
|
+
import { ICP } from "./icp";
|
|
3
|
+
import { BlockHeight } from "./types/common";
|
|
4
|
+
import { LedgerCanisterOptions, TransferError } from "./types/ledger";
|
|
5
|
+
export declare class LedgerCanister {
|
|
6
|
+
private readonly agent;
|
|
7
|
+
private readonly canisterId;
|
|
8
|
+
private readonly updateFetcher;
|
|
9
|
+
private readonly queryFetcher;
|
|
10
|
+
private constructor();
|
|
11
|
+
static create(options?: LedgerCanisterOptions): LedgerCanister;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the balance of the specified account identifier.
|
|
14
|
+
*
|
|
15
|
+
* If `certified` is true, the request is fetched as an update call, otherwise
|
|
16
|
+
* it is fetched using a query call.
|
|
17
|
+
*/
|
|
18
|
+
accountBalance: ({ accountIdentifier, certified, }: {
|
|
19
|
+
accountIdentifier: AccountIdentifier;
|
|
20
|
+
certified?: boolean | undefined;
|
|
21
|
+
}) => Promise<ICP>;
|
|
22
|
+
/**
|
|
23
|
+
* Transfer ICP from the caller to the destination `accountIdentifier`.
|
|
24
|
+
* Returns the index of the block containing the tx if it was successful.
|
|
25
|
+
*
|
|
26
|
+
* TODO: support remaining options (subaccounts, memos, etc.)
|
|
27
|
+
*/
|
|
28
|
+
transfer: ({ to, amount, memo, }: {
|
|
29
|
+
to: AccountIdentifier;
|
|
30
|
+
amount: ICP;
|
|
31
|
+
memo?: bigint | undefined;
|
|
32
|
+
}) => Promise<BlockHeight | TransferError>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare type CanisterIdString = string;
|
|
2
|
+
export declare type NeuronId = bigint;
|
|
3
|
+
export declare type AccountIdentifier = string;
|
|
4
|
+
export declare type BlockHeight = bigint;
|
|
5
|
+
export declare type E8s = bigint;
|
|
6
|
+
export declare type Memo = bigint;
|
|
7
|
+
export declare type PrincipalString = string;
|
|
8
|
+
export declare type SubAccount = Uint8Array;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Agent } from "@dfinity/agent";
|
|
2
|
+
import { Principal } from "@dfinity/principal";
|
|
3
|
+
import { GovernanceService } from "../../candid/governance.idl";
|
|
4
|
+
export interface GovernanceCanisterOptions {
|
|
5
|
+
agent?: Agent;
|
|
6
|
+
canisterId?: Principal;
|
|
7
|
+
serviceOverride?: GovernanceService;
|
|
8
|
+
certifiedServiceOverride?: GovernanceService;
|
|
9
|
+
}
|