@dfinity/nns 0.1.7 → 0.2.1
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/cjs/index.cjs.js +48 -48
- package/dist/cjs/index.cjs.js.map +3 -3
- package/dist/esm/account_identifier.js +1 -1
- package/dist/esm/chunk-4FZAJTYF.js +2 -0
- package/dist/esm/chunk-4FZAJTYF.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-NR65YN67.js → chunk-NYI672WX.js} +2 -2
- package/dist/esm/{chunk-NR65YN67.js.map → chunk-NYI672WX.js.map} +0 -0
- package/dist/esm/chunk-RPOIUQZO.js +2 -0
- package/dist/esm/chunk-RPOIUQZO.js.map +7 -0
- package/dist/esm/chunk-SO23SIWX.js +3 -0
- package/dist/esm/chunk-SO23SIWX.js.map +7 -0
- package/dist/esm/chunk-X2SHUWG3.js +2 -0
- package/dist/esm/chunk-X2SHUWG3.js.map +7 -0
- package/dist/esm/chunk-YL3F3CIN.js +4 -0
- package/dist/esm/chunk-YL3F3CIN.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/ledger.js +1 -1
- package/dist/types/account_identifier.d.ts +5 -2
- 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 +31 -16
- package/dist/types/icp.d.ts +2 -5
- package/dist/types/index.d.ts +6 -2
- package/dist/types/ledger.d.ts +11 -32
- 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.d.ts → proto.utils.d.ts} +0 -0
- package/package.json +17 -14
- package/dist/esm/chunk-AAXRCEPL.js +0 -2
- package/dist/esm/chunk-AAXRCEPL.js.map +0 -7
- package/dist/esm/chunk-AV2V5I5D.js +0 -10
- package/dist/esm/chunk-AV2V5I5D.js.map +0 -7
- package/dist/esm/chunk-QXLTRMTU.js +0 -832
- package/dist/esm/chunk-QXLTRMTU.js.map +0 -7
- package/dist/esm/chunk-RKZCM7KO.js +0 -4
- package/dist/esm/chunk-RKZCM7KO.js.map +0 -7
- package/dist/esm/chunk-UJYSTOZE.js +0 -2
- package/dist/esm/chunk-UJYSTOZE.js.map +0 -7
- package/dist/esm/chunk-XN3QHASA.js +0 -4
- package/dist/esm/chunk-XN3QHASA.js.map +0 -7
- package/dist/esm/chunk-YXM7FYC5.js +0 -2
- package/dist/esm/chunk-YXM7FYC5.js.map +0 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ledger.ts", "../../src/types/ledger.ts", "../../src/utils/proto.utils.ts"],
|
|
4
|
+
"sourcesContent": ["import { Agent } from \"@dfinity/agent\";\nimport { Principal } from \"@dfinity/principal\";\nimport {\n AccountBalanceRequest,\n BlockHeight as PbBlockHeight,\n ICPTs,\n Memo,\n Payment,\n SendRequest,\n} from \"../proto/ledger_pb\";\nimport { AccountIdentifier } from \"./account_identifier\";\nimport { MAINNET_LEDGER_CANISTER_ID } from \"./constants/canister_ids\";\nimport { ICP } from \"./icp\";\nimport { BlockHeight } from \"./types/common\";\nimport {\n Fetcher,\n InsufficientFunds,\n InvalidSender,\n LedgerCanisterOptions,\n TransferError,\n TxCreatedInFuture,\n TxDuplicate,\n TxTooOld,\n} from \"./types/ledger\";\nimport { defaultAgent } from \"./utils/agent.utils\";\nimport { queryCall, updateCall } from \"./utils/proto.utils\";\n\nexport class LedgerCanister {\n private constructor(\n private readonly agent: Agent,\n private readonly canisterId: Principal,\n private readonly updateFetcher: Fetcher,\n private readonly queryFetcher: Fetcher\n ) {}\n\n public static create(options: LedgerCanisterOptions = {}) {\n return new LedgerCanister(\n options.agent ?? defaultAgent(),\n options.canisterId ?? MAINNET_LEDGER_CANISTER_ID,\n options.updateCallOverride ?? updateCall,\n options.queryCallOverride ?? queryCall\n );\n }\n\n /**\n * Returns the balance of the specified account identifier.\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 accountBalance = async ({\n accountIdentifier,\n certified = true,\n }: {\n accountIdentifier: AccountIdentifier;\n certified?: boolean;\n }): Promise<ICP> => {\n const callMethod = certified ? this.updateFetcher : this.queryFetcher;\n\n const request = new AccountBalanceRequest();\n request.setAccount(accountIdentifier.toProto());\n const responseBytes = await callMethod(\n this.agent,\n this.canisterId,\n \"account_balance_pb\",\n request.serializeBinary()\n );\n\n if (responseBytes instanceof Error) {\n // An error is never expected from this endpoint.\n throw Error;\n }\n\n return ICP.fromE8s(\n BigInt(ICPTs.deserializeBinary(new Uint8Array(responseBytes)).getE8s())\n );\n };\n\n /**\n * Transfer ICP from the caller to the destination `accountIdentifier`.\n * Returns the index of the block containing the tx if it was successful.\n *\n * TODO: support remaining options (subaccounts, memos, etc.)\n */\n public transfer = async ({\n to,\n amount,\n memo,\n }: {\n to: AccountIdentifier;\n amount: ICP;\n memo?: bigint;\n }): Promise<BlockHeight | TransferError> => {\n const request = new SendRequest();\n request.setTo(to.toProto());\n\n const payment = new Payment();\n payment.setReceiverGets(amount.toProto());\n request.setPayment(payment);\n\n if (memo) {\n const memo = new Memo();\n memo.setMemo(memo.toString());\n request.setMemo(memo);\n }\n\n const responseBytes = await this.updateFetcher(\n this.agent,\n this.canisterId,\n \"send_pb\",\n request.serializeBinary()\n );\n\n if (responseBytes instanceof Error) {\n if (responseBytes.message.includes(\"Reject code: 5\")) {\n // Match against the different error types.\n // This string matching is fragile. It's a stop-gap solution until\n // we migrate to the candid interface.\n\n if (responseBytes.message.match(/Sending from (.*) is not allowed/)) {\n return new InvalidSender();\n }\n\n {\n const m = responseBytes.message.match(\n /transaction.*duplicate.* in block (\\d+)/\n );\n if (m && m.length > 1) {\n return new TxDuplicate(BigInt(m[1]));\n }\n }\n\n {\n const m = responseBytes.message.match(\n /debit account.*, current balance: (\\d*(\\.\\d*)?)/\n );\n if (m && m.length > 1) {\n const balance = ICP.fromString(m[1]);\n if (balance instanceof ICP) {\n return new InsufficientFunds(balance);\n }\n }\n }\n\n if (responseBytes.message.includes(\"is in future\")) {\n return new TxCreatedInFuture();\n }\n\n {\n const m = responseBytes.message.match(/older than (\\d+)/);\n if (m && m.length > 1) {\n return new TxTooOld(Number.parseInt(m[1]));\n }\n }\n }\n\n // Unknown error. Throw as-is.\n throw responseBytes;\n }\n\n // Successful tx. Return the block height.\n return BigInt(PbBlockHeight.deserializeBinary(responseBytes).getHeight());\n };\n}\n", "import { Agent } from \"@dfinity/agent\";\nimport { Principal } from \"@dfinity/principal\";\nimport { ICP } from \"../icp\";\n\nexport type BlockHeight = bigint;\n\nexport type TransferError =\n | InvalidSender\n | InsufficientFunds\n | TxTooOld\n | TxCreatedInFuture\n | TxDuplicate\n | BadFee;\n\nexport class InvalidSender {}\nexport class BadFee {}\nexport class InsufficientFunds {\n constructor(public readonly balance: ICP) {}\n}\nexport class TxTooOld {\n constructor(public readonly allowed_window_secs: number) {}\n}\nexport class TxCreatedInFuture {}\nexport class TxDuplicate {\n constructor(public readonly duplicateOf: BlockHeight) {}\n}\n\nexport type Fetcher = (\n agent: Agent,\n canisterId: Principal,\n methodName: string,\n arg: ArrayBuffer\n) => Promise<Uint8Array | Error>;\n\n// HttpAgent options that can be used at construction.\nexport interface LedgerCanisterOptions {\n // The agent to use when communicating with the ledger canister.\n agent?: Agent;\n // The ledger canister's ID.\n canisterId?: Principal;\n // The method to use for performing an update call. Primarily overridden\n // in test for mocking.\n updateCallOverride?: Fetcher;\n // The method to use for performing a query call. Primarily overridden\n // in test for mocking.\n queryCallOverride?: Fetcher;\n}\n", "import { Agent, polling } from \"@dfinity/agent\";\nimport { Principal } from \"@dfinity/principal\";\n\n/**\n * Submits an update call to the IC.\n * @returns The (binary) response if the request succeeded, an error otherwise.\n */\nexport const updateCall = async (\n agent: Agent,\n canisterId: Principal,\n methodName: string,\n arg: ArrayBuffer\n): Promise<Uint8Array | Error> => {\n const submitResponse = await agent.call(canisterId, {\n methodName,\n arg,\n effectiveCanisterId: canisterId,\n });\n\n if (!submitResponse.response.ok) {\n return Error(\n [\n \"Call failed:\",\n ` Method: ${methodName}`,\n ` Canister ID: ${canisterId}`,\n ` Request ID: ${submitResponse.requestId}`,\n ` HTTP status code: ${submitResponse.response.status}`,\n ` HTTP status text: ${submitResponse.response.statusText}`,\n ].join(\"\\n\")\n );\n }\n\n try {\n const blob = await polling.pollForResponse(\n agent,\n canisterId,\n submitResponse.requestId,\n polling.defaultStrategy()\n );\n return new Uint8Array(blob);\n } catch (err) {\n if (err instanceof Error) {\n // Return errors rather than throw them so that callers are forced to handle them.\n return err;\n }\n\n // Something very wrong happened, and we don't know how to deal with it. Throw as-is.\n throw err;\n }\n};\n\n/**\n * Submits a query call to the IC.\n * @returns The (binary) response if the request succeeded, an error otherwise.\n */\nexport const queryCall = async (\n agent: Agent,\n canisterId: Principal,\n methodName: string,\n arg: ArrayBuffer\n): Promise<Uint8Array | Error> => {\n const queryResponse = await agent.query(canisterId, {\n methodName,\n arg,\n });\n\n if (queryResponse.status == \"rejected\") {\n return new Error(\n [\n \"Call failed:\",\n ` Method: ${methodName}`,\n ` Canister ID: ${canisterId}`,\n ` HTTP status code: ${queryResponse.reject_code}`,\n ` HTTP status text: ${queryResponse.reject_message}`,\n ].join(\"\\n\")\n );\n }\n\n return new Uint8Array(queryResponse.reply.arg);\n};\n"],
|
|
5
|
+
"mappings": "8KAEA,MAOO,OCKA,WAAoB,GACpB,OAAa,GACb,OAAwB,CAC7B,YAA4B,EAAc,CAAd,iBAEvB,OAAe,CACpB,YAA4B,EAA6B,CAA7B,6BAEvB,OAAwB,GACxB,OAAkB,CACvB,YAA4B,EAA0B,CAA1B,qBCjBvB,GAAM,GAAa,MACxB,EACA,EACA,EACA,IACgC,CAChC,GAAM,GAAiB,KAAM,GAAM,KAAK,EAAY,CAClD,aACA,MACA,oBAAqB,IAGvB,GAAI,CAAC,EAAe,SAAS,GAC3B,MAAO,OACL,CACE,eACA,aAAa,IACb,kBAAkB,IAClB,iBAAiB,EAAe,YAChC,uBAAuB,EAAe,SAAS,SAC/C,uBAAuB,EAAe,SAAS,cAC/C,KAAK;AAAA,IAIX,GAAI,CACF,GAAM,GAAO,KAAM,GAAQ,gBACzB,EACA,EACA,EAAe,UACf,EAAQ,mBAEV,MAAO,IAAI,YAAW,SACf,EAAP,CACA,GAAI,YAAe,OAEjB,MAAO,GAIT,KAAM,KAQG,EAAY,MACvB,EACA,EACA,EACA,IACgC,CAChC,GAAM,GAAgB,KAAM,GAAM,MAAM,EAAY,CAClD,aACA,QAGF,MAAI,GAAc,QAAU,WACnB,GAAI,OACT,CACE,eACA,aAAa,IACb,kBAAkB,IAClB,uBAAuB,EAAc,cACrC,uBAAuB,EAAc,kBACrC,KAAK;AAAA,IAIJ,GAAI,YAAW,EAAc,MAAM,MFnDrC,WAAqB,CAClB,YACW,EACA,EACA,EACA,EACjB,CAJiB,aACA,kBACA,qBACA,0BAGL,QAAO,EAAiC,GAAI,CACxD,MAAO,IAAI,GACT,EAAQ,OAAS,IACjB,EAAQ,YAAc,EACtB,EAAQ,oBAAsB,EAC9B,EAAQ,mBAAqB,GAU1B,eAAiB,MAAO,CAC7B,oBACA,YAAY,MAIM,CAClB,GAAM,GAAa,EAAY,KAAK,cAAgB,KAAK,aAEnD,EAAU,GAAI,yBACpB,EAAQ,WAAW,EAAkB,WACrC,GAAM,GAAgB,KAAM,GAC1B,KAAK,MACL,KAAK,WACL,qBACA,EAAQ,mBAGV,GAAI,YAAyB,OAE3B,KAAM,OAGR,MAAO,GAAI,QACT,OAAO,QAAM,kBAAkB,GAAI,YAAW,IAAgB,YAU3D,SAAW,MAAO,CACvB,KACA,SACA,UAK0C,CAC1C,GAAM,GAAU,GAAI,eACpB,EAAQ,MAAM,EAAG,WAEjB,GAAM,GAAU,GAAI,WAIpB,GAHA,EAAQ,gBAAgB,EAAO,WAC/B,EAAQ,WAAW,GAEf,EAAM,CACR,GAAM,GAAO,GAAI,QACjB,EAAK,QAAQ,EAAK,YAClB,EAAQ,QAAQ,GAGlB,GAAM,GAAgB,KAAM,MAAK,cAC/B,KAAK,MACL,KAAK,WACL,UACA,EAAQ,mBAGV,GAAI,YAAyB,OAAO,CAClC,GAAI,EAAc,QAAQ,SAAS,kBAAmB,CAKpD,GAAI,EAAc,QAAQ,MAAM,oCAC9B,MAAO,IAAI,GAGb,CACE,GAAM,GAAI,EAAc,QAAQ,MAC9B,2CAEF,GAAI,GAAK,EAAE,OAAS,EAClB,MAAO,IAAI,GAAY,OAAO,EAAE,KAIpC,CACE,GAAM,GAAI,EAAc,QAAQ,MAC9B,mDAEF,GAAI,GAAK,EAAE,OAAS,EAAG,CACrB,GAAM,GAAU,EAAI,WAAW,EAAE,IACjC,GAAI,YAAmB,GACrB,MAAO,IAAI,GAAkB,IAKnC,GAAI,EAAc,QAAQ,SAAS,gBACjC,MAAO,IAAI,GAGb,CACE,GAAM,GAAI,EAAc,QAAQ,MAAM,oBACtC,GAAI,GAAK,EAAE,OAAS,EAClB,MAAO,IAAI,GAAS,OAAO,SAAS,EAAE,MAM5C,KAAM,GAIR,MAAO,QAAO,cAAc,kBAAkB,GAAe",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/governance.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{g as a}from"./chunk-RPOIUQZO.js";import"./chunk-LNMGZ6W7.js";import"./chunk-HMU24NWJ.js";import"./chunk-FVDRR6PO.js";import"./chunk-4FZAJTYF.js";export{a as GovernanceCanister};
|
|
2
2
|
//# sourceMappingURL=governance.js.map
|
package/dist/esm/icp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{b as a}from"./chunk-X2SHUWG3.js";import"./chunk-NYI672WX.js";import"./chunk-4FZAJTYF.js";export{a as ICP};
|
|
2
2
|
//# sourceMappingURL=icp.js.map
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as r,b as
|
|
1
|
+
import{a as r,b as o}from"./chunk-SO23SIWX.js";import{a as m,b as p,c as x,d as n,e as c,f as i,g as e}from"./chunk-RPOIUQZO.js";import"./chunk-LNMGZ6W7.js";import{a as u,b as C,c as d,d as s,e as A,f as I,g as f}from"./chunk-YL3F3CIN.js";import"./chunk-HMU24NWJ.js";import"./chunk-FVDRR6PO.js";import{a,b as t}from"./chunk-X2SHUWG3.js";import"./chunk-NYI672WX.js";import"./chunk-4FZAJTYF.js";export{r as AccountIdentifier,C as BadFee,a as FromICPStringError,e as GovernanceCanister,t as ICP,d as InsufficientFunds,u as InvalidSender,f as LedgerCanister,m as NeuronState,p as ProposalRewardStatus,x as ProposalStatus,o as SubAccount,c as Topic,A as TxCreatedInFuture,I as TxDuplicate,s as TxTooOld,i as UnsupportedValueError,n as Vote};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/ledger.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{g as a}from"./chunk-YL3F3CIN.js";import"./chunk-HMU24NWJ.js";import"./chunk-FVDRR6PO.js";import"./chunk-X2SHUWG3.js";import"./chunk-NYI672WX.js";import"./chunk-4FZAJTYF.js";export{a as LedgerCanister};
|
|
2
2
|
//# sourceMappingURL=ledger.js.map
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { AccountIdentifier as AccountIdentifierPb } from "../proto/ledger_pb";
|
|
2
1
|
import { Principal } from "@dfinity/principal";
|
|
2
|
+
import { AccountIdentifier as AccountIdentifierPb } from "../proto/ledger_pb";
|
|
3
3
|
export declare class AccountIdentifier {
|
|
4
4
|
private readonly bytes;
|
|
5
5
|
private constructor();
|
|
6
6
|
static fromHex(hex: string): AccountIdentifier;
|
|
7
|
-
static fromPrincipal(principal
|
|
7
|
+
static fromPrincipal({ principal, subAccount, }: {
|
|
8
|
+
principal: Principal;
|
|
9
|
+
subAccount?: SubAccount;
|
|
10
|
+
}): AccountIdentifier;
|
|
8
11
|
/**
|
|
9
12
|
* @returns An AccountIdentifier protobuf object.
|
|
10
13
|
*/
|
|
@@ -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
|
+
}
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
declare type NeuronId = bigint;
|
|
5
|
-
export declare type KnownNeuron = {
|
|
6
|
-
id: NeuronId;
|
|
7
|
-
name: string;
|
|
8
|
-
description: string | undefined;
|
|
9
|
-
};
|
|
10
|
-
export interface GovernanceCanisterOptions {
|
|
11
|
-
agent?: Agent;
|
|
12
|
-
canisterId?: Principal;
|
|
13
|
-
serviceOverride?: GovernanceService;
|
|
14
|
-
certifiedServiceOverride?: GovernanceService;
|
|
15
|
-
}
|
|
1
|
+
import { NeuronId } from "./types/common";
|
|
2
|
+
import { GovernanceCanisterOptions } from "./types/governance";
|
|
3
|
+
import { KnownNeuron, ListProposalsRequest, ListProposalsResponse, NeuronInfo } from "./types/governance_converters";
|
|
16
4
|
export declare class GovernanceCanister {
|
|
17
5
|
private readonly service;
|
|
18
6
|
private readonly certifiedService;
|
|
7
|
+
private readonly requestConverters;
|
|
8
|
+
private readonly responseConverters;
|
|
9
|
+
private readonly myPrincipal?;
|
|
19
10
|
private constructor();
|
|
20
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[]>;
|
|
21
26
|
/**
|
|
22
27
|
* Returns the list of neurons who have been approved by the community to
|
|
23
28
|
* appear as the default followee options.
|
|
@@ -26,5 +31,15 @@ export declare class GovernanceCanister {
|
|
|
26
31
|
* it is fetched using a query call.
|
|
27
32
|
*/
|
|
28
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>;
|
|
29
45
|
}
|
|
30
|
-
export {};
|
package/dist/types/icp.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ICPTs } from "../proto/ledger_pb";
|
|
2
|
+
import { FromICPStringError } from "./types/icp";
|
|
2
3
|
export declare class ICP {
|
|
3
4
|
private e8s;
|
|
4
5
|
private constructor();
|
|
@@ -10,11 +11,7 @@ export declare class ICP {
|
|
|
10
11
|
* 1'234'567.8901
|
|
11
12
|
* 1,234,567.8901
|
|
12
13
|
*/
|
|
13
|
-
static fromString(amount: string): ICP |
|
|
14
|
+
static fromString(amount: string): ICP | FromICPStringError;
|
|
14
15
|
toE8s(): bigint;
|
|
15
16
|
toProto(): ICPTs;
|
|
16
17
|
}
|
|
17
|
-
export declare enum FromStringError {
|
|
18
|
-
FRACTIONAL_MORE_THAN_8_DECIMALS = 0,
|
|
19
|
-
INVALID_FORMAT = 1
|
|
20
|
-
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export { GovernanceCanister } from "./governance";
|
|
2
|
-
export { LedgerCanister } from "./ledger";
|
|
3
1
|
export { AccountIdentifier, SubAccount } from "./account_identifier";
|
|
2
|
+
export { GovernanceCanister } from "./governance";
|
|
4
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";
|
package/dist/types/ledger.d.ts
CHANGED
|
@@ -1,34 +1,7 @@
|
|
|
1
|
-
import { Agent } from "@dfinity/agent";
|
|
2
|
-
import { Principal } from "@dfinity/principal";
|
|
3
1
|
import { AccountIdentifier } from "./account_identifier";
|
|
4
2
|
import { ICP } from "./icp";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare class InvalidSender {
|
|
8
|
-
}
|
|
9
|
-
export declare class BadFee {
|
|
10
|
-
}
|
|
11
|
-
export declare class InsufficientFunds {
|
|
12
|
-
readonly balance: ICP;
|
|
13
|
-
constructor(balance: ICP);
|
|
14
|
-
}
|
|
15
|
-
export declare class TxTooOld {
|
|
16
|
-
readonly allowed_window_secs: number;
|
|
17
|
-
constructor(allowed_window_secs: number);
|
|
18
|
-
}
|
|
19
|
-
export declare class TxCreatedInFuture {
|
|
20
|
-
}
|
|
21
|
-
export declare class TxDuplicate {
|
|
22
|
-
readonly duplicateOf: BlockHeight;
|
|
23
|
-
constructor(duplicateOf: BlockHeight);
|
|
24
|
-
}
|
|
25
|
-
declare type Fetcher = (agent: Agent, canisterId: Principal, methodName: string, arg: ArrayBuffer) => Promise<Uint8Array | Error>;
|
|
26
|
-
export interface LedgerCanisterOptions {
|
|
27
|
-
agent?: Agent;
|
|
28
|
-
canisterId?: Principal;
|
|
29
|
-
updateCallOverride?: Fetcher;
|
|
30
|
-
queryCallOverride?: Fetcher;
|
|
31
|
-
}
|
|
3
|
+
import { BlockHeight } from "./types/common";
|
|
4
|
+
import { LedgerCanisterOptions, TransferError } from "./types/ledger";
|
|
32
5
|
export declare class LedgerCanister {
|
|
33
6
|
private readonly agent;
|
|
34
7
|
private readonly canisterId;
|
|
@@ -42,13 +15,19 @@ export declare class LedgerCanister {
|
|
|
42
15
|
* If `certified` is true, the request is fetched as an update call, otherwise
|
|
43
16
|
* it is fetched using a query call.
|
|
44
17
|
*/
|
|
45
|
-
accountBalance: (accountIdentifier
|
|
18
|
+
accountBalance: ({ accountIdentifier, certified, }: {
|
|
19
|
+
accountIdentifier: AccountIdentifier;
|
|
20
|
+
certified?: boolean | undefined;
|
|
21
|
+
}) => Promise<ICP>;
|
|
46
22
|
/**
|
|
47
23
|
* Transfer ICP from the caller to the destination `accountIdentifier`.
|
|
48
24
|
* Returns the index of the block containing the tx if it was successful.
|
|
49
25
|
*
|
|
50
26
|
* TODO: support remaining options (subaccounts, memos, etc.)
|
|
51
27
|
*/
|
|
52
|
-
transfer: (to
|
|
28
|
+
transfer: ({ to, amount, memo, }: {
|
|
29
|
+
to: AccountIdentifier;
|
|
30
|
+
amount: ICP;
|
|
31
|
+
memo?: bigint | undefined;
|
|
32
|
+
}) => Promise<BlockHeight | TransferError>;
|
|
53
33
|
}
|
|
54
|
-
export {};
|
|
@@ -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
|
+
}
|