@dfinity/sns 0.0.2 → 0.0.3-next-2022-08-08

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 (80) hide show
  1. package/dist/candid/{ledger.certified.idl.d.ts → icrc1_ledger.certified.idl.d.ts} +0 -0
  2. package/dist/candid/icrc1_ledger.certified.idl.js +104 -0
  3. package/dist/candid/icrc1_ledger.d.ts +64 -0
  4. package/dist/candid/icrc1_ledger.did +77 -0
  5. package/dist/candid/{ledger.idl.d.ts → icrc1_ledger.idl.d.ts} +0 -0
  6. package/dist/candid/icrc1_ledger.idl.js +108 -0
  7. package/dist/candid/sns_governance.certified.idl.js +21 -0
  8. package/dist/candid/sns_governance.d.ts +11 -0
  9. package/dist/candid/sns_governance.did +12 -1
  10. package/dist/candid/sns_governance.idl.js +25 -0
  11. package/dist/candid/sns_root.certified.idl.js +10 -4
  12. package/dist/candid/sns_root.d.ts +8 -4
  13. package/dist/candid/sns_root.did +9 -5
  14. package/dist/candid/sns_root.idl.js +10 -4
  15. package/dist/candid/sns_swap.certified.idl.js +43 -12
  16. package/dist/candid/sns_swap.d.ts +30 -5
  17. package/dist/candid/sns_swap.did +21 -5
  18. package/dist/candid/sns_swap.idl.js +43 -12
  19. package/dist/cjs/index.cjs.js +1 -852
  20. package/dist/cjs/index.cjs.js.map +3 -3
  21. package/dist/esm/chunk-BW5FNCFQ.js +2 -0
  22. package/dist/esm/chunk-BW5FNCFQ.js.map +7 -0
  23. package/dist/esm/chunk-C7NIDDRE.js +2 -0
  24. package/dist/esm/chunk-C7NIDDRE.js.map +7 -0
  25. package/dist/esm/chunk-ETZUMPBI.js +2 -0
  26. package/dist/esm/chunk-ETZUMPBI.js.map +7 -0
  27. package/dist/esm/chunk-OZ3QVZ6V.js +2 -0
  28. package/dist/esm/chunk-OZ3QVZ6V.js.map +7 -0
  29. package/dist/esm/chunk-UTRXOFS6.js +2 -0
  30. package/dist/esm/chunk-UTRXOFS6.js.map +7 -0
  31. package/dist/esm/chunk-WP45ZSPX.js +2 -0
  32. package/dist/esm/chunk-WP45ZSPX.js.map +7 -0
  33. package/dist/esm/chunk-YFZBYWX4.js +2 -0
  34. package/dist/esm/chunk-YFZBYWX4.js.map +7 -0
  35. package/dist/esm/governance.canister.js +1 -1
  36. package/dist/esm/index.js +1 -1
  37. package/dist/esm/index.js.map +3 -3
  38. package/dist/esm/ledger.canister.js +1 -1
  39. package/dist/esm/root.canister.js +1 -1
  40. package/dist/esm/sns.js +1 -1
  41. package/dist/esm/sns.wrapper.js +1 -1
  42. package/dist/esm/swap.canister.js +1 -1
  43. package/dist/types/converters/governance.converters.d.ts +4 -0
  44. package/dist/types/enums/governance.enums.d.ts +11 -0
  45. package/dist/types/errors/governance.errors.d.ts +2 -0
  46. package/dist/types/governance.canister.d.ts +32 -7
  47. package/dist/types/index.d.ts +11 -8
  48. package/dist/types/ledger.canister.d.ts +10 -4
  49. package/dist/types/root.canister.d.ts +4 -4
  50. package/dist/types/sns.d.ts +3 -3
  51. package/dist/types/sns.wrapper.d.ts +20 -13
  52. package/dist/types/swap.canister.d.ts +12 -4
  53. package/dist/types/types/canister.options.d.ts +2 -5
  54. package/dist/types/types/governance.params.d.ts +16 -1
  55. package/dist/types/types/ledger.responses.d.ts +11 -0
  56. package/package.json +6 -4
  57. package/dist/candid/ledger.certified.idl.js +0 -97
  58. package/dist/candid/ledger.d.ts +0 -106
  59. package/dist/candid/ledger.did +0 -250
  60. package/dist/candid/ledger.idl.js +0 -109
  61. package/dist/esm/chunk-5EFW5NLJ.js +0 -2
  62. package/dist/esm/chunk-5EFW5NLJ.js.map +0 -7
  63. package/dist/esm/chunk-A576P2ZR.js +0 -2
  64. package/dist/esm/chunk-A576P2ZR.js.map +0 -7
  65. package/dist/esm/chunk-NJ4DNYU7.js +0 -2
  66. package/dist/esm/chunk-NJ4DNYU7.js.map +0 -7
  67. package/dist/esm/chunk-QOHSQFP6.js +0 -2
  68. package/dist/esm/chunk-QOHSQFP6.js.map +0 -7
  69. package/dist/esm/chunk-S7OOQWQZ.js +0 -2
  70. package/dist/esm/chunk-S7OOQWQZ.js.map +0 -7
  71. package/dist/esm/chunk-TGR2FDNH.js +0 -2
  72. package/dist/esm/chunk-TGR2FDNH.js.map +0 -7
  73. package/dist/esm/chunk-VMVMYL6O.js +0 -840
  74. package/dist/esm/chunk-VMVMYL6O.js.map +0 -7
  75. package/dist/esm/chunk-Y5V5O772.js +0 -2
  76. package/dist/esm/chunk-Y5V5O772.js.map +0 -7
  77. package/dist/types/utils/actor.utils.d.ts +0 -14
  78. package/dist/types/utils/agent.utils.d.ts +0 -5
  79. package/dist/types/utils/asserts.utils.d.ts +0 -3
  80. package/dist/types/utils/did.utils.d.ts +0 -2
@@ -1,13 +1,38 @@
1
- import type { Neuron, _SERVICE as SnsGovernanceCanister } from "../candid/sns_governance";
1
+ import type { GetMetadataResponse, ManageNeuron, ManageNeuronResponse, Neuron, _SERVICE as SnsGovernanceService } from "../candid/sns_governance";
2
2
  import { Canister } from "./services/canister";
3
- import type { CanisterOptions } from "./types/canister.options";
4
- import type { ListNeuronsParams } from "./types/governance.params";
3
+ import type { SnsCanisterOptions } from "./types/canister.options";
4
+ import type { SnsGetNeuronParams, SnsListNeuronsParams, SnsNeuronPermissionsParams } from "./types/governance.params";
5
5
  import type { QueryParams } from "./types/query.params";
6
- export declare class GovernanceCanister extends Canister<SnsGovernanceCanister> {
7
- static create(options: CanisterOptions<SnsGovernanceCanister>): GovernanceCanister;
6
+ export declare class SnsGovernanceCanister extends Canister<SnsGovernanceService> {
7
+ static create(options: SnsCanisterOptions<SnsGovernanceService>): SnsGovernanceCanister;
8
8
  /**
9
9
  * List the neurons of the Sns
10
10
  */
11
- listNeurons: (params: ListNeuronsParams) => Promise<Neuron[]>;
12
- metadata: (params: QueryParams) => Promise<string>;
11
+ listNeurons: (params: SnsListNeuronsParams) => Promise<Neuron[]>;
12
+ /**
13
+ * Get the Sns metadata (title, description, etc.)
14
+ */
15
+ metadata: (params: QueryParams) => Promise<GetMetadataResponse>;
16
+ /**
17
+ * Get the neuron of the Sns
18
+ */
19
+ getNeuron: (params: SnsGetNeuronParams & QueryParams) => Promise<Neuron>;
20
+ /**
21
+ * Manage neuron. For advanced users.
22
+ */
23
+ manageNeuron: (request: ManageNeuron) => Promise<ManageNeuronResponse>;
24
+ /**
25
+ * Add permissions to a neuron for a specific principal
26
+ */
27
+ addNeuronPermissions: (params: SnsNeuronPermissionsParams) => Promise<void>;
28
+ /**
29
+ * Remove permissions to a neuron for a specific principal
30
+ */
31
+ removeNeuronPermissions: (params: SnsNeuronPermissionsParams) => Promise<void>;
32
+ /**
33
+ *
34
+ * @param response ManageNeuronResponse
35
+ * @throws SnsGovernanceError
36
+ */
37
+ private assertManageNeuronError;
13
38
  }
@@ -1,13 +1,16 @@
1
- export type { Neuron as SnsNeuron, NeuronId as SnsNeuronId, } from "../candid/sns_governance";
1
+ export type { GetMetadataResponse as SnsGetMetadataResponse, ManageNeuron as SnsManageNeuron, ManageNeuronResponse as SnsManageNeuronResponse, Neuron as SnsNeuron, NeuronId as SnsNeuronId, } from "../candid/sns_governance";
2
2
  export type { CanisterStatusResultV2 as SnsCanisterStatus } from "../candid/sns_root";
3
- export type { BuyerState as SnsSwapBuyerState, DerivedState as SnsSwapDerivedState, Init as SnsSwapInit, State as SnsSwapState, Swap as SnsSwap, TimeWindow as SnsSwapTimeWindow, } from "../candid/sns_swap";
3
+ export type { BuyerState as SnsSwapBuyerState, DerivedState as SnsSwapDerivedState, GetBuyerStateRequest as SnsGetBuyerStateRequest, GetBuyerStateResponse as SnsGetBuyerStateResponse, Init as SnsSwapInit, State as SnsSwapState, Swap as SnsSwap, TimeWindow as SnsSwapTimeWindow, } from "../candid/sns_swap";
4
+ export * from "./enums/governance.enums";
4
5
  export * from "./enums/swap.enums";
5
- export { GovernanceCanister } from "./governance.canister";
6
- export { LedgerCanister } from "./ledger.canister";
7
- export { RootCanister } from "./root.canister";
6
+ export * from "./errors/governance.errors";
7
+ export { SnsGovernanceCanister } from "./governance.canister";
8
+ export { SnsLedgerCanister } from "./ledger.canister";
9
+ export { SnsRootCanister } from "./root.canister";
8
10
  export * from "./sns";
9
11
  export * from "./sns.wrapper";
10
- export { SwapCanister } from "./swap.canister";
11
- export type { CanisterOptions } from "./types/canister.options";
12
- export type { ListNeuronsParams } from "./types/governance.params";
12
+ export { SnsSwapCanister } from "./swap.canister";
13
+ export type { SnsCanisterOptions } from "./types/canister.options";
14
+ export type { SnsGetNeuronParams, SnsListNeuronsParams, } from "./types/governance.params";
15
+ export * from "./types/ledger.responses";
13
16
  export type { QueryParams } from "./types/query.params";
@@ -1,6 +1,12 @@
1
- import type { _SERVICE as SnsLedgerCanister } from "../candid/ledger";
1
+ import type { _SERVICE as SnsLedgerService } from "../candid/icrc1_ledger";
2
2
  import { Canister } from "./services/canister";
3
- import type { CanisterOptions } from "./types/canister.options";
4
- export declare class LedgerCanister extends Canister<SnsLedgerCanister> {
5
- static create(options: CanisterOptions<SnsLedgerCanister>): LedgerCanister;
3
+ import type { SnsCanisterOptions } from "./types/canister.options";
4
+ import type { SnsTokenMetadataResponse } from "./types/ledger.responses";
5
+ import type { QueryParams } from "./types/query.params";
6
+ export declare class SnsLedgerCanister extends Canister<SnsLedgerService> {
7
+ static create(options: SnsCanisterOptions<SnsLedgerService>): SnsLedgerCanister;
8
+ /**
9
+ * The token metadata (name, symbol, etc.).
10
+ */
11
+ metadata: (params: QueryParams) => Promise<SnsTokenMetadataResponse>;
6
12
  }
@@ -1,8 +1,8 @@
1
- import type { ListSnsCanistersResponse, _SERVICE as SnsRootCanister } from "../candid/sns_root";
1
+ import type { ListSnsCanistersResponse, _SERVICE as SnsRootService } from "../candid/sns_root";
2
2
  import { Canister } from "./services/canister";
3
- import type { CanisterOptions } from "./types/canister.options";
4
- export declare class RootCanister extends Canister<SnsRootCanister> {
5
- static create(options: CanisterOptions<SnsRootCanister>): RootCanister;
3
+ import type { SnsCanisterOptions } from "./types/canister.options";
4
+ export declare class SnsRootCanister extends Canister<SnsRootService> {
5
+ static create(options: SnsCanisterOptions<SnsRootService>): SnsRootCanister;
6
6
  /**
7
7
  * List the canisters that are part of the Sns.
8
8
  *
@@ -1,7 +1,7 @@
1
1
  import type { Agent } from "@dfinity/agent";
2
- import type { _SERVICE as SnsRootCanister } from "../candid/sns_root";
2
+ import type { _SERVICE as SnsRootService } from "../candid/sns_root";
3
3
  import { SnsWrapper } from "./sns.wrapper";
4
- import type { CanisterOptions } from "./types/canister.options";
4
+ import type { SnsCanisterOptions } from "./types/canister.options";
5
5
  import type { QueryParams } from "./types/query.params";
6
6
  /**
7
7
  * Options to discover and initialize all canisters of a Sns.
@@ -10,7 +10,7 @@ export interface InitSnsCanistersOptions extends QueryParams {
10
10
  /** An agent that can be used to override the default agent. Useful to target another environment that mainnet. */
11
11
  agent?: Agent;
12
12
  /** The options that will be used to instantiate the actors of the root canister of the particular Sns. */
13
- rootOptions: Omit<CanisterOptions<SnsRootCanister>, "agent">;
13
+ rootOptions: Omit<SnsCanisterOptions<SnsRootService>, "agent">;
14
14
  }
15
15
  export interface InitSnsWrapper {
16
16
  (options: InitSnsCanistersOptions): Promise<SnsWrapper>;
@@ -1,21 +1,22 @@
1
1
  import type { Principal } from "@dfinity/principal";
2
- import type { Neuron } from "../candid/sns_governance";
3
- import type { GetStateResponse } from "../candid/sns_swap";
4
- import type { GovernanceCanister } from "./governance.canister";
5
- import type { LedgerCanister } from "./ledger.canister";
6
- import type { RootCanister } from "./root.canister";
7
- import type { SwapCanister } from "./swap.canister";
8
- import type { ListNeuronsParams } from "./types/governance.params";
2
+ import type { GetMetadataResponse, Neuron } from "../candid/sns_governance";
3
+ import type { BuyerState, GetBuyerStateRequest, GetStateResponse, RefreshBuyerTokensRequest } from "../candid/sns_swap";
4
+ import type { SnsGovernanceCanister } from "./governance.canister";
5
+ import type { SnsLedgerCanister } from "./ledger.canister";
6
+ import type { SnsRootCanister } from "./root.canister";
7
+ import type { SnsSwapCanister } from "./swap.canister";
8
+ import type { SnsGetNeuronParams, SnsListNeuronsParams, SnsNeuronPermissionsParams } from "./types/governance.params";
9
+ import type { SnsTokenMetadataResponse } from "./types/ledger.responses";
9
10
  import type { QueryParams } from "./types/query.params";
10
11
  interface SnsWrapperOptions {
11
12
  /** The wrapper for the "root" canister of the particular Sns */
12
- root: RootCanister;
13
+ root: SnsRootCanister;
13
14
  /** The wrapper for the "governance" canister of the particular Sns */
14
- governance: GovernanceCanister;
15
+ governance: SnsGovernanceCanister;
15
16
  /** The wrapper for the "ledger" canister of the particular Sns */
16
- ledger: LedgerCanister;
17
+ ledger: SnsLedgerCanister;
17
18
  /** The wrapper for the "swap" canister of the particular Sns */
18
- swap: SwapCanister;
19
+ swap: SnsSwapCanister;
19
20
  /** The wrapper has been instantiated and should perform query or update calls */
20
21
  certified: boolean;
21
22
  }
@@ -41,10 +42,16 @@ export declare class SnsWrapper {
41
42
  rootCanisterId: Principal;
42
43
  ledgerCanisterId: Principal;
43
44
  governanceCanisterId: Principal;
45
+ swapCanisterId: Principal;
44
46
  };
45
- listNeurons: (params: Omit<ListNeuronsParams, "certified">) => Promise<Neuron[]>;
46
- metadata: (params: Omit<QueryParams, "certified">) => Promise<string>;
47
+ listNeurons: (params: Omit<SnsListNeuronsParams, "certified">) => Promise<Neuron[]>;
48
+ metadata: (params: Omit<QueryParams, "certified">) => Promise<[GetMetadataResponse, SnsTokenMetadataResponse]>;
49
+ getNeuron: (params: Omit<SnsGetNeuronParams, "certified">) => Promise<Neuron>;
50
+ addNeuronPermissions: (params: SnsNeuronPermissionsParams) => Promise<void>;
51
+ removeNeuronPermissions: (params: SnsNeuronPermissionsParams) => Promise<void>;
47
52
  swapState: (params: Omit<QueryParams, "certified">) => Promise<GetStateResponse>;
53
+ notifyParticipation: (params: RefreshBuyerTokensRequest) => Promise<void>;
54
+ getUserCommitment: (params: GetBuyerStateRequest) => Promise<BuyerState | undefined>;
48
55
  private mergeParams;
49
56
  }
50
57
  export {};
@@ -1,11 +1,19 @@
1
- import type { GetStateResponse, _SERVICE as SnsSwapCanister } from "../candid/sns_swap";
1
+ import type { BuyerState, GetBuyerStateRequest, GetStateResponse, RefreshBuyerTokensRequest, _SERVICE as SnsSwapService } from "../candid/sns_swap";
2
2
  import { Canister } from "./services/canister";
3
- import type { CanisterOptions } from "./types/canister.options";
3
+ import type { SnsCanisterOptions } from "./types/canister.options";
4
4
  import type { QueryParams } from "./types/query.params";
5
- export declare class SwapCanister extends Canister<SnsSwapCanister> {
6
- static create(options: CanisterOptions<SnsSwapCanister>): SwapCanister;
5
+ export declare class SnsSwapCanister extends Canister<SnsSwapService> {
6
+ static create(options: SnsCanisterOptions<SnsSwapService>): SnsSwapCanister;
7
7
  /**
8
8
  * Get the state of the swap
9
9
  */
10
10
  state: (params: QueryParams) => Promise<GetStateResponse>;
11
+ /**
12
+ * Notify of the user participating in the swap
13
+ */
14
+ notifyParticipation: (params: RefreshBuyerTokensRequest) => Promise<void>;
15
+ /**
16
+ * Get user commitment
17
+ */
18
+ getUserCommitment: (params: GetBuyerStateRequest & QueryParams) => Promise<BuyerState | undefined>;
11
19
  }
@@ -1,8 +1,5 @@
1
- import type { ActorSubclass, Agent } from "@dfinity/agent";
2
1
  import type { Principal } from "@dfinity/principal";
3
- export interface CanisterOptions<T> {
4
- agent?: Agent;
2
+ import type { CanisterOptions } from "@dfinity/utils";
3
+ export interface SnsCanisterOptions<T> extends Omit<CanisterOptions<T>, "canisterId"> {
5
4
  canisterId: Principal;
6
- serviceOverride?: ActorSubclass<T>;
7
- certifiedServiceOverride?: ActorSubclass<T>;
8
5
  }
@@ -1,10 +1,11 @@
1
1
  import type { Principal } from "@dfinity/principal";
2
2
  import type { NeuronId } from "../../candid/sns_governance";
3
+ import type { SnsNeuronPermissionType } from "../enums/governance.enums";
3
4
  import type { QueryParams } from "./query.params";
4
5
  /**
5
6
  * The parameters available to list Sns neurons
6
7
  */
7
- export interface ListNeuronsParams extends QueryParams {
8
+ export interface SnsListNeuronsParams extends QueryParams {
8
9
  /** Scope the query to a particular principal */
9
10
  principal?: Principal | undefined;
10
11
  /** The maximum number of neurons returned by the method `list_neurons` */
@@ -12,3 +13,17 @@ export interface ListNeuronsParams extends QueryParams {
12
13
  /** Index the search to returns a list that starts after specified neuron id */
13
14
  beforeNeuronId?: NeuronId;
14
15
  }
16
+ /**
17
+ * The parameters to get an sns neuron
18
+ */
19
+ export interface SnsGetNeuronParams extends QueryParams {
20
+ neuronId: NeuronId;
21
+ }
22
+ /**
23
+ * Parametes to add permissions to a neuron
24
+ */
25
+ export interface SnsNeuronPermissionsParams {
26
+ principal: Principal;
27
+ neuronId: NeuronId;
28
+ permissions: SnsNeuronPermissionType[];
29
+ }
@@ -0,0 +1,11 @@
1
+ import type { Value } from "../../candid/icrc1_ledger";
2
+ export declare enum SnsMetadataResponseEntries {
3
+ SYMBOL = "icrc1:symbol",
4
+ NAME = "icrc1:name",
5
+ DECIMALS = "icrc1:decimals",
6
+ FEE = "icrc1:fee"
7
+ }
8
+ export declare type SnsTokenMetadataResponse = [
9
+ string | SnsMetadataResponseEntries,
10
+ Value
11
+ ][];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfinity/sns",
3
- "version": "0.0.2",
3
+ "version": "0.0.3-next-2022-08-08",
4
4
  "description": "A library for interfacing with a Service Nervous System (SNS) project.",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/cjs/index.cjs.js",
@@ -18,7 +18,6 @@
18
18
  "prepack": "npm run build",
19
19
  "test": "jest"
20
20
  },
21
- "dependencies": {},
22
21
  "devDependencies": {},
23
22
  "repository": {
24
23
  "type": "git",
@@ -36,5 +35,8 @@
36
35
  "service nervous system",
37
36
  "service-nervous-system",
38
37
  "sns"
39
- ]
40
- }
38
+ ],
39
+ "peerDependencies": {
40
+ "@dfinity/utils": "^0.0.1-next"
41
+ }
42
+ }
@@ -1,97 +0,0 @@
1
- /* Do not edit. Compiled with ./scripts/compile-idl-js from packages/sns/candid/ledger.did */
2
- export const idlFactory = ({ IDL }) => {
3
- const BlockIndex = IDL.Nat64;
4
- const GetBlocksArgs = IDL.Record({
5
- 'start' : BlockIndex,
6
- 'length' : IDL.Nat64,
7
- });
8
- const Memo = IDL.Nat64;
9
- const AccountIdentifier = IDL.Vec(IDL.Nat8);
10
- const Tokens = IDL.Record({ 'e8s' : IDL.Nat64 });
11
- const Operation = IDL.Variant({
12
- 'Burn' : IDL.Record({ 'from' : AccountIdentifier, 'amount' : Tokens }),
13
- 'Mint' : IDL.Record({ 'to' : AccountIdentifier, 'amount' : Tokens }),
14
- 'Transfer' : IDL.Record({
15
- 'to' : AccountIdentifier,
16
- 'fee' : Tokens,
17
- 'from' : AccountIdentifier,
18
- 'amount' : Tokens,
19
- }),
20
- });
21
- const TimeStamp = IDL.Record({ 'timestamp_nanos' : IDL.Nat64 });
22
- const Transaction = IDL.Record({
23
- 'memo' : Memo,
24
- 'operation' : IDL.Opt(Operation),
25
- 'created_at_time' : TimeStamp,
26
- });
27
- const Block = IDL.Record({
28
- 'transaction' : Transaction,
29
- 'timestamp' : TimeStamp,
30
- 'parent_hash' : IDL.Opt(IDL.Vec(IDL.Nat8)),
31
- });
32
- const BlockRange = IDL.Record({ 'blocks' : IDL.Vec(Block) });
33
- const QueryArchiveError = IDL.Variant({
34
- 'BadFirstBlockIndex' : IDL.Record({
35
- 'requested_index' : BlockIndex,
36
- 'first_valid_index' : BlockIndex,
37
- }),
38
- 'Other' : IDL.Record({
39
- 'error_message' : IDL.Text,
40
- 'error_code' : IDL.Nat64,
41
- }),
42
- });
43
- const QueryArchiveResult = IDL.Variant({
44
- 'Ok' : BlockRange,
45
- 'Err' : QueryArchiveError,
46
- });
47
- const QueryArchiveFn = IDL.Func([GetBlocksArgs], [QueryArchiveResult], []);
48
- const QueryBlocksResponse = IDL.Record({
49
- 'certificate' : IDL.Opt(IDL.Vec(IDL.Nat8)),
50
- 'blocks' : IDL.Vec(Block),
51
- 'chain_length' : IDL.Nat64,
52
- 'first_block_index' : BlockIndex,
53
- 'archived_blocks' : IDL.Vec(
54
- IDL.Record({
55
- 'callback' : QueryArchiveFn,
56
- 'start' : BlockIndex,
57
- 'length' : IDL.Nat64,
58
- })
59
- ),
60
- });
61
- const AccountBalanceArgs = IDL.Record({ 'account' : AccountIdentifier });
62
- const Archive = IDL.Record({ 'canister_id' : IDL.Principal });
63
- const Archives = IDL.Record({ 'archives' : IDL.Vec(Archive) });
64
- const SubAccount = IDL.Vec(IDL.Nat8);
65
- const TransferArgs = IDL.Record({
66
- 'to' : AccountIdentifier,
67
- 'fee' : Tokens,
68
- 'memo' : Memo,
69
- 'from_subaccount' : IDL.Opt(SubAccount),
70
- 'created_at_time' : IDL.Opt(TimeStamp),
71
- 'amount' : Tokens,
72
- });
73
- const TransferError = IDL.Variant({
74
- 'TxTooOld' : IDL.Record({ 'allowed_window_nanos' : IDL.Nat64 }),
75
- 'BadFee' : IDL.Record({ 'expected_fee' : Tokens }),
76
- 'TxDuplicate' : IDL.Record({ 'duplicate_of' : BlockIndex }),
77
- 'TxCreatedInFuture' : IDL.Null,
78
- 'InsufficientFunds' : IDL.Record({ 'balance' : Tokens }),
79
- });
80
- const TransferResult = IDL.Variant({
81
- 'Ok' : BlockIndex,
82
- 'Err' : TransferError,
83
- });
84
- const TransferFeeArg = IDL.Record({});
85
- const TransferFee = IDL.Record({ 'transfer_fee' : Tokens });
86
- return IDL.Service({
87
- '_blocks' : IDL.Func([GetBlocksArgs], [QueryBlocksResponse], []),
88
- 'account_balance' : IDL.Func([AccountBalanceArgs], [Tokens], []),
89
- 'archives' : IDL.Func([], [Archives], []),
90
- 'decimals' : IDL.Func([], [IDL.Record({ 'decimals' : IDL.Nat32 })], []),
91
- 'name' : IDL.Func([], [IDL.Record({ 'name' : IDL.Text })], []),
92
- 'symbol' : IDL.Func([], [IDL.Record({ 'symbol' : IDL.Text })], []),
93
- 'transfer' : IDL.Func([TransferArgs], [TransferResult], []),
94
- 'transfer_fee' : IDL.Func([TransferFeeArg], [TransferFee], []),
95
- });
96
- };
97
- export const init = ({ IDL }) => { return []; };
@@ -1,106 +0,0 @@
1
- import type { Principal } from "@dfinity/principal";
2
- export interface AccountBalanceArgs {
3
- account: AccountIdentifier;
4
- }
5
- export type AccountIdentifier = Array<number>;
6
- export interface Archive {
7
- canister_id: Principal;
8
- }
9
- export interface Archives {
10
- archives: Array<Archive>;
11
- }
12
- export interface Block {
13
- transaction: Transaction;
14
- timestamp: TimeStamp;
15
- parent_hash: [] | [Array<number>];
16
- }
17
- export type BlockIndex = bigint;
18
- export interface BlockRange {
19
- blocks: Array<Block>;
20
- }
21
- export interface GetBlocksArgs {
22
- start: BlockIndex;
23
- length: bigint;
24
- }
25
- export type Memo = bigint;
26
- export type Operation =
27
- | {
28
- Burn: { from: AccountIdentifier; amount: Tokens };
29
- }
30
- | { Mint: { to: AccountIdentifier; amount: Tokens } }
31
- | {
32
- Transfer: {
33
- to: AccountIdentifier;
34
- fee: Tokens;
35
- from: AccountIdentifier;
36
- amount: Tokens;
37
- };
38
- };
39
- export type QueryArchiveError =
40
- | {
41
- BadFirstBlockIndex: {
42
- requested_index: BlockIndex;
43
- first_valid_index: BlockIndex;
44
- };
45
- }
46
- | { Other: { error_message: string; error_code: bigint } };
47
- export type QueryArchiveFn = (
48
- arg_0: GetBlocksArgs
49
- ) => Promise<QueryArchiveResult>;
50
- export type QueryArchiveResult =
51
- | { Ok: BlockRange }
52
- | { Err: QueryArchiveError };
53
- export interface QueryBlocksResponse {
54
- certificate: [] | [Array<number>];
55
- blocks: Array<Block>;
56
- chain_length: bigint;
57
- first_block_index: BlockIndex;
58
- archived_blocks: Array<{
59
- callback: QueryArchiveFn;
60
- start: BlockIndex;
61
- length: bigint;
62
- }>;
63
- }
64
- export type SubAccount = Array<number>;
65
- export interface TimeStamp {
66
- timestamp_nanos: bigint;
67
- }
68
- export interface Tokens {
69
- e8s: bigint;
70
- }
71
- export interface Transaction {
72
- memo: Memo;
73
- operation: [] | [Operation];
74
- created_at_time: TimeStamp;
75
- }
76
- export interface TransferArgs {
77
- to: AccountIdentifier;
78
- fee: Tokens;
79
- memo: Memo;
80
- from_subaccount: [] | [SubAccount];
81
- created_at_time: [] | [TimeStamp];
82
- amount: Tokens;
83
- }
84
- export type TransferError =
85
- | {
86
- TxTooOld: { allowed_window_nanos: bigint };
87
- }
88
- | { BadFee: { expected_fee: Tokens } }
89
- | { TxDuplicate: { duplicate_of: BlockIndex } }
90
- | { TxCreatedInFuture: null }
91
- | { InsufficientFunds: { balance: Tokens } };
92
- export interface TransferFee {
93
- transfer_fee: Tokens;
94
- }
95
- export type TransferFeeArg = {};
96
- export type TransferResult = { Ok: BlockIndex } | { Err: TransferError };
97
- export interface _SERVICE {
98
- account_balance: (arg_0: AccountBalanceArgs) => Promise<Tokens>;
99
- archives: () => Promise<Archives>;
100
- decimals: () => Promise<{ decimals: number }>;
101
- name: () => Promise<{ name: string }>;
102
- query_blocks: (arg_0: GetBlocksArgs) => Promise<QueryBlocksResponse>;
103
- symbol: () => Promise<{ symbol: string }>;
104
- transfer: (arg_0: TransferArgs) => Promise<TransferResult>;
105
- transfer_fee: (arg_0: TransferFeeArg) => Promise<TransferFee>;
106
- }