@keetanetwork/keetanet-client 0.10.2 → 0.10.3

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/api/node.d.ts CHANGED
@@ -11,6 +11,7 @@ interface GetPeersAPIResponse {
11
11
  kind: NodeKind;
12
12
  key?: string;
13
13
  endpoint?: string;
14
+ signature?: string;
14
15
  }
15
16
  interface GetAccountChainAPIResponse {
16
17
  account: string;
@@ -32,6 +33,7 @@ interface AccountStateError {
32
33
  }
33
34
  interface GetAllRepresentativesAPIResponse {
34
35
  representative: string;
36
+ weight: bigint;
35
37
  endpoints: Endpoints;
36
38
  }
37
39
  interface GetRepresentativeAPIResponse {
@@ -1,8 +1,9 @@
1
1
  import * as KeetaNet from '.';
2
2
  import type LocalNode from '../lib/node/local';
3
3
  import type { Networks } from '../config';
4
+ import { AccountKeyAlgorithm } from '../lib/account';
4
5
  import type Account from '../lib/account';
5
- import type { UserClient } from '.';
6
+ import { UserClient } from '.';
6
7
  import { toJSONSerializable } from '../lib/utils/conversion';
7
8
  import KeetaError from '../lib/error';
8
9
  export type ClientParams = {
@@ -22,9 +23,9 @@ export type NodeCreationOptions = {
22
23
  count?: number;
23
24
  };
24
25
  export declare function setup(options?: NodeCreationOptions): Promise<{
25
- trustedKey: Account<import("../lib/account").AccountKeyAlgorithm.ECDSA_SECP256K1>;
26
- repKeys: Account<import("../lib/account").AccountKeyAlgorithm.ECDSA_SECP256K1 | import("../lib/account").AccountKeyAlgorithm.ED25519 | import("../lib/account").AccountKeyAlgorithm.ECDSA_SECP256R1>[];
27
- accounts: Account<import("../lib/account").AccountKeyAlgorithm.ECDSA_SECP256K1>[];
26
+ trustedKey: Account<AccountKeyAlgorithm.ECDSA_SECP256K1>;
27
+ repKeys: Account<AccountKeyAlgorithm.ECDSA_SECP256K1 | AccountKeyAlgorithm.ED25519 | AccountKeyAlgorithm.ECDSA_SECP256R1>[];
28
+ accounts: Account<AccountKeyAlgorithm.ECDSA_SECP256K1>[];
28
29
  nodes: LocalNode[];
29
30
  trustedClients: KeetaNet.UserClient[];
30
31
  userClients: KeetaNet.UserClient[];
@@ -11,6 +11,7 @@ import KeetaNetError from '../lib/error';
11
11
  import type { AccountInfo, GetAllBalancesResponse, ACLRow, LedgerStatistics } from '../lib/ledger/types';
12
12
  import type { LedgerSelector, LedgerStorage } from '../lib/ledger';
13
13
  import type { AcceptedPermissionTypes } from '../lib/permissions';
14
+ import { type BlockOperations } from '../lib/block/operations';
14
15
  type Vote = InstanceType<typeof KeetaNet['Vote']>;
15
16
  type VoteStaple = InstanceType<typeof KeetaNet['Vote']['Staple']>;
16
17
  type VoteBlocksHash = Vote['blocksHash'];
@@ -50,6 +51,9 @@ interface UserClientConfig extends UserClientOptions {
50
51
  network: bigint;
51
52
  networkAlias: Config.Networks;
52
53
  }
54
+ type ClientRepresentative = Config.Representative & {
55
+ weight?: bigint;
56
+ };
53
57
  export declare class Client {
54
58
  #private;
55
59
  static readonly Builder: typeof UserClientBuilder;
@@ -64,13 +68,13 @@ export declare class Client {
64
68
  };
65
69
  static fromNetwork(network: Config.Networks): Client;
66
70
  static isInstance: (obj: any, strict?: boolean) => obj is Client;
67
- constructor(reps: Config.Representative[]);
71
+ constructor(reps: ClientRepresentative[]);
68
72
  destroy(): Promise<void>;
69
73
  makeBuilder(options: BuilderOptions): UserClientBuilder;
70
74
  computeBuilderBlocks(network: bigint, builder: UserClientBuilder): Promise<import("./builder").ComputeBlocksResponse>;
71
75
  transmit(blocks: Block[]): ReturnType<Client['transmitStaple']>;
72
76
  transmit(blocks: UserClientBuilder, network: bigint): ReturnType<Client['transmitStaple']>;
73
- transmitStaple(votesAndBlocks: VoteStaple, reps?: Config.Representative[]): Promise<any>;
77
+ transmitStaple(votesAndBlocks: VoteStaple, reps?: ClientRepresentative[]): Promise<any>;
74
78
  getNodeStats(): Promise<{
75
79
  ledger: LedgerStatistics;
76
80
  switch: P2PSwitchStatistics;
@@ -87,7 +91,7 @@ export declare class Client {
87
91
  getAllBalances(account: GenericAccount | string): Promise<GetAllBalancesResponse>;
88
92
  getHeadBlock(account: GenericAccount | string): Promise<Block | null>;
89
93
  getBlock(blockhash: BlockHash | string): Promise<Block | null>;
90
- getBlock(blockhash: BlockHash | string, side?: LedgerSelector, rep?: Config.Representative | 'ANY'): Promise<Block | null>;
94
+ getBlock(blockhash: BlockHash | string, side?: LedgerSelector, rep?: ClientRepresentative | 'ANY'): Promise<Block | null>;
91
95
  getVoteStaple(blockhash: BlockHash | string): Promise<VoteStaple | null>;
92
96
  getVoteStaple(blockhash: BlockHash | string, side?: LedgerStorage): Promise<VoteStaple | null>;
93
97
  getChain(account: GenericAccount | string, options?: {
@@ -103,17 +107,17 @@ export declare class Client {
103
107
  getSingleRepresentativeInfo(rep?: Account | string): Promise<RepresentativeInfo>;
104
108
  getPeers(): Promise<GetPeersAPIResponse>;
105
109
  getAllRepresentativeInfo(): Promise<RepresentativeInfo[]>;
106
- get representatives(): Config.Representative[];
110
+ get representatives(): ClientRepresentative[];
107
111
  /**
108
112
  * Get the network status of all representatives
109
113
  *
110
114
  * @param timeout Maximum time to wait for a response from a representative in milliseconds
111
115
  */
112
116
  getNetworkStatus(timeout?: number): Promise<({
113
- rep: Config.Representative;
117
+ rep: ClientRepresentative;
114
118
  online: false;
115
119
  } | {
116
- rep: Config.Representative;
120
+ rep: ClientRepresentative;
117
121
  online: true;
118
122
  ledger: {
119
123
  moment: string;
@@ -131,7 +135,7 @@ export declare class Client {
131
135
  outgoingMessagesPeerFailureUngreeted: number;
132
136
  };
133
137
  })[]>;
134
- updateReps(): Promise<void>;
138
+ updateReps(addNewReps?: boolean): Promise<void>;
135
139
  getVoteStaplesAfter(moment: Date, limit?: number, bloomFilter?: string): Promise<VoteStaple[]>;
136
140
  getPendingBlock(account: GenericAccount): Promise<Block | null>;
137
141
  /**
@@ -141,12 +145,12 @@ export declare class Client {
141
145
  * @param publish Publish the recovered staple to the network (default is true)
142
146
  */
143
147
  recoverAccount(account: GenericAccount, publish?: boolean): Promise<VoteStaple | null>;
144
- getLedgerChecksum(rep?: Config.Representative | 'ANY'): Promise<{
148
+ getLedgerChecksum(rep?: ClientRepresentative | 'ANY'): Promise<{
145
149
  moment: string;
146
150
  momentRange: number;
147
151
  checksum: string;
148
152
  }>;
149
- getVersion(rep?: Config.Representative | 'ANY'): Promise<{
153
+ getVersion(rep?: ClientRepresentative | 'ANY'): Promise<{
150
154
  node: string;
151
155
  }>;
152
156
  }
@@ -163,6 +167,12 @@ export declare class UserClient {
163
167
  static getConfigFromNetwork(network: Config.Networks, options?: UserClientOptions): Omit<UserClientConfig, 'signer'>;
164
168
  static fromNetwork(network: Config.Networks, signer: Account | null, options?: UserClientOptions): UserClient;
165
169
  static isInstance: (obj: any, strict?: boolean) => obj is UserClient;
170
+ static filterStapleOperations(voteStaples: VoteStaple[], account: GenericAccount): {
171
+ [stapleHash: string]: {
172
+ block: Block;
173
+ filteredOperations: BlockOperations[];
174
+ }[];
175
+ };
166
176
  constructor(config: UserClientConfig);
167
177
  initializeChain(initOpts: {
168
178
  addSupplyAmount: bigint;
@@ -186,6 +196,12 @@ export declare class UserClient {
186
196
  voteStaple: import("../lib/vote").VoteStaple;
187
197
  effects: import("../lib/ledger/effects").ComputedEffectOfBlocks;
188
198
  }[]>;
199
+ filterStapleOperations(voteStaples: VoteStaple[], options?: UserClientOptions): {
200
+ [stapleHash: string]: {
201
+ block: Block;
202
+ filteredOperations: BlockOperations[];
203
+ }[];
204
+ };
189
205
  state(options?: UserClientOptions): ReturnType<Client['getAccountInfo']>;
190
206
  listACLsByPrincipal(entity?: (GenericAccount | string)[], options?: UserClientOptions): ReturnType<Client['listACLsByPrincipal']>;
191
207
  listACLsByEntity(options?: UserClientOptions): ReturnType<Client['listACLsByEntity']>;