@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,3 @@
1
+ import{d as l,h as p,i as y}from"./chunk-LNMGZ6W7.js";import{a as h}from"./chunk-FVDRR6PO.js";import{a as U}from"./chunk-NYI672WX.js";import{c as s,d as u}from"./chunk-4FZAJTYF.js";var b=s(h()),A=s(U());var e=class{constructor(t){this.bytes=t}static fromHex(t){return new e(Uint8Array.from(Buffer.from(t,"hex")))}static fromPrincipal({principal:t,subAccount:n=o.ZERO}){let i=l(`
2
+ account-id`),r=b.sha224.create();r.update([...i,...t.toUint8Array(),...n.toUint8Array()]);let a=new Uint8Array(r.array()),f=y(a),m=new Uint8Array([...f,...a]);return new e(m)}toProto(){let t=new A.AccountIdentifier;return t.setHash(this.bytes),t}toHex(){return p(this.bytes)}},c=class{constructor(t){this.bytes=t}static fromBytes(t){return t.length!=32?Error("Subaccount length must be 32-bytes"):new c(t)}static fromPrincipal(t){let n=new Uint8Array(32).fill(0),i=t.toUint8Array();n[0]=i.length;for(let r=0;r<i.length;r++)n[1+r]=i[r];return new c(n)}toUint8Array(){return this.bytes}},o=c;u(o,"ZERO",new c(new Uint8Array(32).fill(0)));export{e as a,o as b};
3
+ //# sourceMappingURL=chunk-SO23SIWX.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/account_identifier.ts"],
4
+ "sourcesContent": ["import { Principal } from \"@dfinity/principal\";\nimport { sha224 } from \"js-sha256\";\nimport { AccountIdentifier as AccountIdentifierPb } from \"../proto/ledger_pb\";\nimport {\n asciiStringToByteArray,\n calculateCrc32,\n toHexString,\n} from \"./utils/converter.utils\";\n\nexport class AccountIdentifier {\n private constructor(private readonly bytes: Uint8Array) {}\n\n public static fromHex(hex: string): AccountIdentifier {\n return new AccountIdentifier(Uint8Array.from(Buffer.from(hex, \"hex\")));\n }\n\n public static fromPrincipal({\n principal,\n subAccount = SubAccount.ZERO,\n }: {\n principal: Principal;\n subAccount?: SubAccount;\n }): AccountIdentifier {\n // Hash (sha224) the principal, the subAccount and some padding\n const padding = asciiStringToByteArray(\"\\x0Aaccount-id\");\n\n const shaObj = sha224.create();\n shaObj.update([\n ...padding,\n ...principal.toUint8Array(),\n ...subAccount.toUint8Array(),\n ]);\n const hash = new Uint8Array(shaObj.array());\n\n // Prepend the checksum of the hash and convert to a hex string\n const checksum = calculateCrc32(hash);\n const bytes = new Uint8Array([...checksum, ...hash]);\n return new AccountIdentifier(bytes);\n }\n\n /**\n * @returns An AccountIdentifier protobuf object.\n */\n public toProto(): AccountIdentifierPb {\n const accountIdentifier = new AccountIdentifierPb();\n accountIdentifier.setHash(this.bytes);\n return accountIdentifier;\n }\n\n public toHex(): string {\n return toHexString(this.bytes);\n }\n}\n\nexport class SubAccount {\n private constructor(private readonly bytes: Uint8Array) {}\n\n public static fromBytes(bytes: Uint8Array): SubAccount | Error {\n if (bytes.length != 32) {\n return Error(\"Subaccount length must be 32-bytes\");\n }\n\n return new SubAccount(bytes);\n }\n\n public static fromPrincipal(principal: Principal): SubAccount {\n const bytes = new Uint8Array(32).fill(0);\n\n const principalBytes = principal.toUint8Array();\n bytes[0] = principalBytes.length;\n\n for (let i = 0; i < principalBytes.length; i++) {\n bytes[1 + i] = principalBytes[i];\n }\n\n return new SubAccount(bytes);\n }\n\n public static ZERO: SubAccount = new SubAccount(new Uint8Array(32).fill(0));\n\n public toUint8Array(): Uint8Array {\n return this.bytes;\n }\n}\n"],
5
+ "mappings": "qLACA,MAAuB,OACvB,EAAyD,OAOlD,WAAwB,CACrB,YAA6B,EAAmB,CAAnB,mBAEvB,SAAQ,EAAgC,CACpD,MAAO,IAAI,GAAkB,WAAW,KAAK,OAAO,KAAK,EAAK,eAGlD,eAAc,CAC1B,YACA,aAAa,EAAW,MAIJ,CAEpB,GAAM,GAAU,EAAuB;AAAA,aAEjC,EAAS,SAAO,SACtB,EAAO,OAAO,CACZ,GAAG,EACH,GAAG,EAAU,eACb,GAAG,EAAW,iBAEhB,GAAM,GAAO,GAAI,YAAW,EAAO,SAG7B,EAAW,EAAe,GAC1B,EAAQ,GAAI,YAAW,CAAC,GAAG,EAAU,GAAG,IAC9C,MAAO,IAAI,GAAkB,GAMxB,SAA+B,CACpC,GAAM,GAAoB,GAAI,qBAC9B,SAAkB,QAAQ,KAAK,OACxB,EAGF,OAAgB,CACrB,MAAO,GAAY,KAAK,SAIrB,OAAiB,CACd,YAA6B,EAAmB,CAAnB,mBAEvB,WAAU,EAAuC,CAC7D,MAAI,GAAM,QAAU,GACX,MAAM,sCAGR,GAAI,GAAW,SAGV,eAAc,EAAkC,CAC5D,GAAM,GAAQ,GAAI,YAAW,IAAI,KAAK,GAEhC,EAAiB,EAAU,eACjC,EAAM,GAAK,EAAe,OAE1B,OAAS,GAAI,EAAG,EAAI,EAAe,OAAQ,IACzC,EAAM,EAAI,GAAK,EAAe,GAGhC,MAAO,IAAI,GAAW,GAKjB,cAA2B,CAChC,MAAO,MAAK,QA3BT,IAwBS,EAxBT,EAwBS,OAAmB,GAAI,GAAW,GAAI,YAAW,IAAI,KAAK",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import{a as p}from"./chunk-NYI672WX.js";import{c as o,e as c}from"./chunk-4FZAJTYF.js";var I=o(p());var A=(r=>(r[r.FRACTIONAL_MORE_THAN_8_DECIMALS=0]="FRACTIONAL_MORE_THAN_8_DECIMALS",r[r.INVALID_FORMAT=1]="INVALID_FORMAT",r))(A||{});var i=class{constructor(t){this.e8s=t}static fromE8s(t){return new i(t)}static fromString(t){t=t.trim().replace(/[,']/g,"");let r=t.match(/\d*(\.\d*)?/);if(!r||r[0]!==t)return 1;let[s,e]=t.split("."),n=BigInt(0);if(s)try{n+=BigInt(s)*c}catch{return 1}if(e){if(e.length>8)return 0;try{n+=BigInt(e.padEnd(8,"0"))}catch{return 1}}return new i(n)}toE8s(){return this.e8s}toProto(){let t=new I.ICPTs;return t.setE8s(this.e8s.toString()),t}};export{A as a,i as b};
2
+ //# sourceMappingURL=chunk-X2SHUWG3.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/icp.ts", "../../src/types/icp.ts"],
4
+ "sourcesContent": ["import { ICPTs } from \"../proto/ledger_pb\";\nimport { E8S_PER_ICP } from \"./constants/constants\";\nimport { FromICPStringError } from \"./types/icp\";\n\nexport class ICP {\n private constructor(private e8s: bigint) {}\n\n public static fromE8s(amount: bigint): ICP {\n return new ICP(amount);\n }\n\n /**\n * Initialize from a string. Accepted formats:\n *\n * 1234567.8901\n * 1'234'567.8901\n * 1,234,567.8901\n */\n public static fromString(amount: string): ICP | FromICPStringError {\n // Remove all instances of \",\" and \"'\".\n amount = amount.trim().replace(/[,']/g, \"\");\n\n // Verify that the string is of the format 1234.5678\n const regexMatch = amount.match(/\\d*(\\.\\d*)?/);\n if (!regexMatch || regexMatch[0] !== amount) {\n return FromICPStringError.INVALID_FORMAT;\n }\n\n const [integral, fractional] = amount.split(\".\");\n\n let e8s = BigInt(0);\n\n if (integral) {\n try {\n e8s += BigInt(integral) * E8S_PER_ICP;\n } catch {\n return FromICPStringError.INVALID_FORMAT;\n }\n }\n\n if (fractional) {\n if (fractional.length > 8) {\n return FromICPStringError.FRACTIONAL_MORE_THAN_8_DECIMALS;\n }\n try {\n e8s += BigInt(fractional.padEnd(8, \"0\"));\n } catch {\n return FromICPStringError.INVALID_FORMAT;\n }\n }\n\n return new ICP(e8s);\n }\n\n public toE8s(): bigint {\n return this.e8s;\n }\n\n public toProto(): ICPTs {\n const proto = new ICPTs();\n proto.setE8s(this.e8s.toString());\n return proto;\n }\n}\n", "export enum FromICPStringError {\n FRACTIONAL_MORE_THAN_8_DECIMALS,\n INVALID_FORMAT,\n}\n"],
5
+ "mappings": "uFAAA,MAAsB,OCAf,GAAK,GAAL,CAAK,GACV,0EACA,uCAFU,WDIL,WAAU,CACP,YAAoB,EAAa,CAAb,iBAEd,SAAQ,EAAqB,CACzC,MAAO,IAAI,GAAI,SAUH,YAAW,EAA0C,CAEjE,EAAS,EAAO,OAAO,QAAQ,QAAS,IAGxC,GAAM,GAAa,EAAO,MAAM,eAChC,GAAI,CAAC,GAAc,EAAW,KAAO,EACnC,MAAO,GAGT,GAAM,CAAC,EAAU,GAAc,EAAO,MAAM,KAExC,EAAM,OAAO,GAEjB,GAAI,EACF,GAAI,CACF,GAAO,OAAO,GAAY,OAC1B,CACA,MAAO,GAIX,GAAI,EAAY,CACd,GAAI,EAAW,OAAS,EACtB,MAAO,GAET,GAAI,CACF,GAAO,OAAO,EAAW,OAAO,EAAG,WACnC,CACA,MAAO,IAIX,MAAO,IAAI,GAAI,GAGV,OAAgB,CACrB,MAAO,MAAK,IAGP,SAAiB,CACtB,GAAM,GAAQ,GAAI,SAClB,SAAM,OAAO,KAAK,IAAI,YACf",
6
+ "names": []
7
+ }
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-AAXRCEPL.js";import"./chunk-QXLTRMTU.js";import"./chunk-AV2V5I5D.js";import"./chunk-UJYSTOZE.js";export{a as GovernanceCanister};
1
+ import{g as a}from"./chunk-AM5HOKAH.js";import"./chunk-LNMGZ6W7.js";import"./chunk-HFWTAZD7.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,b}from"./chunk-YXM7FYC5.js";import"./chunk-NR65YN67.js";import"./chunk-UJYSTOZE.js";export{b as FromStringError,a as ICP};
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 e,b as r}from"./chunk-XN3QHASA.js";import{a as o}from"./chunk-AAXRCEPL.js";import{g as t}from"./chunk-RKZCM7KO.js";import"./chunk-QXLTRMTU.js";import"./chunk-AV2V5I5D.js";import{a as n}from"./chunk-YXM7FYC5.js";import"./chunk-NR65YN67.js";import"./chunk-UJYSTOZE.js";export{e as AccountIdentifier,o as GovernanceCanister,n as ICP,t as LedgerCanister,r as SubAccount};
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-AM5HOKAH.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-IQ5S76MI.js";import"./chunk-HFWTAZD7.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
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f,g}from"./chunk-RKZCM7KO.js";import"./chunk-QXLTRMTU.js";import"./chunk-AV2V5I5D.js";import"./chunk-YXM7FYC5.js";import"./chunk-NR65YN67.js";import"./chunk-UJYSTOZE.js";export{b as BadFee,c as InsufficientFunds,a as InvalidSender,g as LedgerCanister,e as TxCreatedInFuture,f as TxDuplicate,d as TxTooOld};
1
+ import{g as a}from"./chunk-IQ5S76MI.js";import"./chunk-HFWTAZD7.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: Principal, subAccount?: SubAccount): AccountIdentifier;
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,3 @@
1
+ import { Option } from "../../types/option";
2
+ export declare const getNnsFunctionName: (nnsFunction: number) => string;
3
+ export declare const convertNnsFunctionPayload: (nnsFunction: number, payload: ArrayBuffer) => Option<Record<string, unknown>>;
@@ -0,0 +1,26 @@
1
+ import { 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
+ fromManageNeuron: (manageNeuron: ManageNeuron) => RawManageNeuron;
7
+ fromClaimNeuronRequest: (request: ClaimNeuronRequest) => [Array<number>, bigint, bigint];
8
+ fromListProposalsRequest: (request: ListProposalsRequest) => ListProposalInfo;
9
+ fromClaimOrRefreshNeuronRequest: (request: ClaimOrRefreshNeuronRequest) => RawManageNeuron;
10
+ fromSplitRequest: (request: SplitRequest) => RawManageNeuron;
11
+ fromDisburseToNeuronRequest: (request: DisburseToNeuronRequest) => RawManageNeuron;
12
+ fromMakeProposalRequest: (request: MakeProposalRequest) => RawManageNeuron;
13
+ private fromFollowees;
14
+ private fromNeuronId;
15
+ private fromNeuronIdOrSubaccount;
16
+ private fromProposalId;
17
+ private fromAction;
18
+ private fromCommand;
19
+ private fromOperation;
20
+ private fromChange;
21
+ private fromNodeProvider;
22
+ private fromAmount;
23
+ private fromAccountIdentifier;
24
+ private fromRewardMode;
25
+ private fromClaimOrRefreshBy;
26
+ }
@@ -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,4 @@
1
+ import { Principal } from "@dfinity/principal";
2
+ export declare const GOVERNANCE_CANISTER_ID: Principal;
3
+ export declare const MAINNET_GOVERNANCE_CANISTER_ID: Principal;
4
+ export declare const MAINNET_LEDGER_CANISTER_ID: Principal;
@@ -0,0 +1,5 @@
1
+ export declare const SUB_ACCOUNT_BYTE_LENGTH = 32;
2
+ export declare const CREATE_CANISTER_MEMO: bigint;
3
+ export declare const TOP_UP_CANISTER_MEMO: bigint;
4
+ export declare const TRANSACTION_FEE: bigint;
5
+ export declare const E8S_PER_ICP: bigint;
@@ -1,21 +1,10 @@
1
- import { Agent } from "@dfinity/agent";
2
- import { Principal } from "@dfinity/principal";
3
- import { GovernanceService } from "../candid/governance.idl";
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 { GovernanceCanisterOptions } from "./types/governance";
2
+ import { KnownNeuron, ListProposalsRequest, ListProposalsResponse } from "./types/governance_converters";
16
3
  export declare class GovernanceCanister {
17
4
  private readonly service;
18
5
  private readonly certifiedService;
6
+ private readonly requestConverters;
7
+ private readonly responseConverters;
19
8
  private constructor();
20
9
  static create(options?: GovernanceCanisterOptions): GovernanceCanister;
21
10
  /**
@@ -26,5 +15,15 @@ export declare class GovernanceCanister {
26
15
  * it is fetched using a query call.
27
16
  */
28
17
  listKnownNeurons: (certified?: boolean) => Promise<KnownNeuron[]>;
18
+ /**
19
+ * Returns the list of proposals made for the community to vote on,
20
+ * paginated and filtered by the request.
21
+ *
22
+ * If `certified` is true (default), the request is fetched as an update call, otherwise
23
+ * it is fetched using a query call.
24
+ */
25
+ listProposals: ({ request, certified, }: {
26
+ request: ListProposalsRequest;
27
+ certified?: boolean | undefined;
28
+ }) => Promise<ListProposalsResponse>;
29
29
  }
30
- export {};
@@ -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 | FromStringError;
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
- }
@@ -1,5 +1,8 @@
1
- export { GovernanceCanister } from "./governance";
2
- export type { KnownNeuron } from "./governance";
3
- export { LedgerCanister } from "./ledger";
4
1
  export { AccountIdentifier, SubAccount } from "./account_identifier";
2
+ export { GovernanceCanister } from "./governance";
5
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";
@@ -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
- declare type BlockHeight = bigint;
6
- export declare type TransferError = InvalidSender | InsufficientFunds | TxTooOld | TxCreatedInFuture | TxDuplicate | BadFee;
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: AccountIdentifier, certified?: boolean) => Promise<ICP>;
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: AccountIdentifier, amount: ICP, memo?: bigint | undefined) => Promise<BlockHeight | TransferError>;
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
+ }