@keetanetwork/keetanet-client 0.10.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.
Files changed (71) hide show
  1. package/._version.d.ts +0 -0
  2. package/LICENSE +35 -0
  3. package/api/index.d.ts +181 -0
  4. package/api/node.d.ts +216 -0
  5. package/api/vote.d.ts +25 -0
  6. package/client/builder.d.ts +129 -0
  7. package/client/client_common_tests.d.ts +72 -0
  8. package/client/index-browser.d.ts +243 -0
  9. package/client/index-browser.js +141899 -0
  10. package/client/index.d.ts +243 -0
  11. package/client/index.js +89118 -0
  12. package/config/index.d.ts +62 -0
  13. package/lib/account.d.ts +544 -0
  14. package/lib/block/index.d.ts +181 -0
  15. package/lib/block/operations.d.ts +407 -0
  16. package/lib/bootstrap.d.ts +27 -0
  17. package/lib/error/account.d.ts +9 -0
  18. package/lib/error/block.d.ts +9 -0
  19. package/lib/error/client.d.ts +9 -0
  20. package/lib/error/index.d.ts +20 -0
  21. package/lib/error/kv.d.ts +9 -0
  22. package/lib/error/ledger.d.ts +12 -0
  23. package/lib/error/permissions.d.ts +9 -0
  24. package/lib/error/vote.d.ts +9 -0
  25. package/lib/index.d.ts +39 -0
  26. package/lib/kv/index.d.ts +22 -0
  27. package/lib/kv/index.test.data.d.ts +9 -0
  28. package/lib/kv/kv_dynamodb.d.ts +20 -0
  29. package/lib/kv/kv_memory.d.ts +17 -0
  30. package/lib/kv/kv_redis.d.ts +22 -0
  31. package/lib/kv/providers.d.ts +9 -0
  32. package/lib/ledger/cache.d.ts +14 -0
  33. package/lib/ledger/common.d.ts +115 -0
  34. package/lib/ledger/db_dynamodb.d.ts +129 -0
  35. package/lib/ledger/db_memory.d.ts +6 -0
  36. package/lib/ledger/db_postgres.d.ts +70 -0
  37. package/lib/ledger/db_spanner.d.ts +116 -0
  38. package/lib/ledger/db_spanner_helper.d.ts +487 -0
  39. package/lib/ledger/db_sqlite.d.ts +64 -0
  40. package/lib/ledger/drivers.d.ts +7 -0
  41. package/lib/ledger/effects.d.ts +78 -0
  42. package/lib/ledger/index.d.ts +312 -0
  43. package/lib/ledger/types.d.ts +49 -0
  44. package/lib/node/index.d.ts +114 -0
  45. package/lib/node/local.d.ts +30 -0
  46. package/lib/node/timing.d.ts +12 -0
  47. package/lib/node/utils.d.ts +4 -0
  48. package/lib/p2p.d.ts +300 -0
  49. package/lib/permissions.d.ts +121 -0
  50. package/lib/pubsub/index.d.ts +7 -0
  51. package/lib/pubsub/providers.d.ts +7 -0
  52. package/lib/pubsub/ps_memory.d.ts +9 -0
  53. package/lib/pubsub/ps_redis.d.ts +10 -0
  54. package/lib/stats.d.ts +51 -0
  55. package/lib/utils/asn1.d.ts +205 -0
  56. package/lib/utils/bitfield.d.ts +13 -0
  57. package/lib/utils/bloom.d.ts +6 -0
  58. package/lib/utils/buffer.d.ts +27 -0
  59. package/lib/utils/certificate.d.ts +340 -0
  60. package/lib/utils/conversion.d.ts +46 -0
  61. package/lib/utils/dynamodb.d.ts +17 -0
  62. package/lib/utils/ed2curve.d.ts +7 -0
  63. package/lib/utils/hash.d.ts +17 -0
  64. package/lib/utils/helper.d.ts +67 -0
  65. package/lib/utils/helper_testing.d.ts +37 -0
  66. package/lib/utils/initial.d.ts +32 -0
  67. package/lib/utils/never.d.ts +7 -0
  68. package/lib/utils/redis.d.ts +11 -0
  69. package/lib/vote.d.ts +273 -0
  70. package/package.json +35 -0
  71. package/version.d.ts +2 -0
@@ -0,0 +1,181 @@
1
+ import type { GenericAccount } from '../account';
2
+ import Account from '../account';
3
+ import BufferStorage from '../utils/buffer';
4
+ import * as ASN1 from '../utils/asn1';
5
+ import type { JSONSupported, ToJSONSerializableOptions } from '../utils/conversion';
6
+ import * as Operations from './operations';
7
+ export declare enum AdjustMethod {
8
+ ADD = 0,
9
+ SUBTRACT = 1,
10
+ SET = 2
11
+ }
12
+ export declare function assertAdjustMethod(value: any, bigintOkay?: boolean): AdjustMethod;
13
+ /**
14
+ * Block hash
15
+ */
16
+ export declare class BlockHash extends BufferStorage {
17
+ static isInstance: (obj: any, strict?: boolean) => obj is BlockHash;
18
+ static Set: import("../utils/helper").InstanceSetConstructor<BlockHash, string>;
19
+ static getAccountOpeningHash(account: GenericAccount): BlockHash;
20
+ fromData(data: Buffer): BlockHash;
21
+ get hashFunctionName(): string;
22
+ constructor(blockhash: ConstructorParameters<typeof BufferStorage>[0]);
23
+ static toJSONSerializablePrefix: string;
24
+ static toJSONSerializable(value: BlockHash, _ignore_opts: ToJSONSerializableOptions): string;
25
+ }
26
+ /**
27
+ * Network ID
28
+ */
29
+ type NetworkID = bigint;
30
+ /**
31
+ * Subnet ID
32
+ */
33
+ type SubnetID = bigint;
34
+ /**
35
+ * Block signature
36
+ */
37
+ type BlockSignature = Buffer;
38
+ /**
39
+ * Representation of the block
40
+ */
41
+ export interface BlockJSON {
42
+ version: number;
43
+ date: string | Date;
44
+ previous: string | BlockHash;
45
+ network: string | NetworkID;
46
+ subnet?: string | SubnetID;
47
+ account: string | GenericAccount;
48
+ signer: string | Account;
49
+ signature: string | BlockSignature;
50
+ operations: Operations.BlockJSONOperations[] | Operations.BlockOperations[];
51
+ }
52
+ export type BlockJSONIncomplete = Partial<BlockJSON>;
53
+ /**
54
+ * Output of block suitable to JSON serialization
55
+ */
56
+ export interface BlockJSONOutput extends JSONSupported<Omit<BlockJSON, 'operations'>> {
57
+ operations: JSONSupported<Operations.BlockJSONOperations>[];
58
+ $hash: string;
59
+ $opening: boolean;
60
+ }
61
+ export type BlockJSONOutputIncomplete = Partial<BlockJSONOutput>;
62
+ /**
63
+ * Map input to our values
64
+ */
65
+ interface BlockUnsignedCanonical {
66
+ version: number;
67
+ date: Date;
68
+ previous: BlockHash;
69
+ account: GenericAccount;
70
+ signer: Account;
71
+ operations: Operations.BlockOperations[];
72
+ network: NetworkID;
73
+ subnet: SubnetID | undefined;
74
+ signature: never;
75
+ }
76
+ interface BlockCanonical extends Omit<BlockUnsignedCanonical, 'signature'> {
77
+ signature: BlockSignature;
78
+ }
79
+ type BlockASN1WithoutSignature = ASN1.ValidateASN1.SchemaMap<[typeof BlockASN1Schema[0], typeof BlockASN1Schema[1], typeof BlockASN1Schema[2], typeof BlockASN1Schema[3], typeof BlockASN1Schema[4], typeof BlockASN1Schema[5], typeof BlockASN1Schema[6], typeof BlockASN1Schema[7]]>;
80
+ /**
81
+ * Block: An item which contains a number of operations (transactions) which
82
+ * originated from an account at a particular instant
83
+ */
84
+ export declare class Block implements BlockCanonical {
85
+ #private;
86
+ static isInstance: (obj: any, strict?: boolean) => obj is Block;
87
+ static Hash: typeof BlockHash;
88
+ static OperationType: typeof Operations.OperationType;
89
+ static Operation: {
90
+ SEND: typeof Operations.BlockOperationSEND;
91
+ SET_REP: typeof Operations.BlockOperationSET_REP;
92
+ SET_INFO: typeof Operations.BlockOperationSET_INFO;
93
+ MODIFY_PERMISSIONS: typeof Operations.BlockOperationMODIFY_PERMISSIONS;
94
+ CREATE_IDENTIFIER: typeof Operations.BlockOperationCREATE_IDENTIFIER;
95
+ TOKEN_ADMIN_SUPPLY: typeof Operations.BlockOperationTOKEN_ADMIN_SUPPLY;
96
+ TOKEN_ADMIN_MODIFY_BALANCE: typeof Operations.BlockOperationTOKEN_ADMIN_MODIFY_BALANCE;
97
+ RECEIVE: typeof Operations.BlockOperationRECEIVE;
98
+ };
99
+ static NO_PREVIOUS: string;
100
+ static AdjustMethod: typeof AdjustMethod;
101
+ static Builder: typeof BlockBuilder;
102
+ readonly version: number;
103
+ readonly date: Date;
104
+ readonly previous: BlockHash;
105
+ readonly account: GenericAccount;
106
+ readonly signer: Account;
107
+ readonly operations: BlockCanonical['operations'];
108
+ readonly network: NetworkID;
109
+ readonly subnet: SubnetID | undefined;
110
+ readonly signature: BlockSignature;
111
+ readonly $signatureValid: boolean;
112
+ readonly $opening: boolean;
113
+ static fromUnsignedJSON(input: BlockUnsignedCanonical): Promise<Block>;
114
+ static isValidJSON(block: BlockJSON | BlockJSONOutput | BlockJSONIncomplete): block is BlockJSON;
115
+ constructor(input: Buffer | ArrayBuffer | BlockJSON | BlockJSONOutput | Block | string);
116
+ static getAccountOpeningHash(account: GenericAccount): BlockHash;
117
+ toBytes(includeSignature?: boolean): ArrayBuffer;
118
+ protected static getASN1ContainerWithoutSignature(input: BlockUnsignedCanonical | BlockCanonical): BlockASN1WithoutSignature;
119
+ toJSON(): BlockJSONOutput;
120
+ /**
121
+ * Hash of the block minus the signature
122
+ *
123
+ * XXX:TODO: Should the hash of the block normally include the
124
+ * signature ? One reason against is that it would
125
+ * allow for identical blocks that only differ by
126
+ * signature (which isn't signed)
127
+ */
128
+ get hash(): BlockHash;
129
+ static toJSONSerializablePrefix: string;
130
+ static toJSONSerializable(value: Block, opts: ToJSONSerializableOptions): {
131
+ [x: string]: any;
132
+ operations: JSONSupported<Operations.BlockJSONOperations>[];
133
+ $hash: string;
134
+ $opening: boolean;
135
+ };
136
+ }
137
+ export declare class BlockBuilder implements BlockJSONIncomplete {
138
+ #private;
139
+ static isInstance: (obj: any, strict?: boolean) => obj is BlockBuilder;
140
+ static OperationType: typeof Operations.OperationType;
141
+ static AdjustMethod: typeof AdjustMethod;
142
+ static Operation: {
143
+ SEND: typeof Operations.BlockOperationSEND;
144
+ SET_REP: typeof Operations.BlockOperationSET_REP;
145
+ SET_INFO: typeof Operations.BlockOperationSET_INFO;
146
+ MODIFY_PERMISSIONS: typeof Operations.BlockOperationMODIFY_PERMISSIONS;
147
+ CREATE_IDENTIFIER: typeof Operations.BlockOperationCREATE_IDENTIFIER;
148
+ TOKEN_ADMIN_SUPPLY: typeof Operations.BlockOperationTOKEN_ADMIN_SUPPLY;
149
+ TOKEN_ADMIN_MODIFY_BALANCE: typeof Operations.BlockOperationTOKEN_ADMIN_MODIFY_BALANCE;
150
+ RECEIVE: typeof Operations.BlockOperationRECEIVE;
151
+ };
152
+ static NO_PREVIOUS: string;
153
+ constructor(block?: BlockJSONIncomplete | BlockJSON | Block | ArrayBuffer | string);
154
+ protected get currentBlock(): Block | BlockJSONIncomplete;
155
+ protected get currentWIP(): BlockJSONIncomplete;
156
+ protected get currentBlockSealed(): Block;
157
+ toJSON(): BlockJSONOutput | BlockJSONOutputIncomplete;
158
+ seal(): Promise<Block>;
159
+ unseal(): BlockJSONIncomplete;
160
+ get sealed(): boolean;
161
+ get block(): Block | undefined;
162
+ get hash(): BlockHash | undefined;
163
+ set signer(signer: string | Account | undefined);
164
+ get signer(): Account | undefined;
165
+ set account(account: string | GenericAccount | undefined);
166
+ get account(): GenericAccount | undefined;
167
+ set previous(blockhash: string | BlockHash | undefined);
168
+ get previous(): BlockHash | undefined;
169
+ get $opening(): boolean | undefined;
170
+ set date(date: Date | string | undefined);
171
+ get date(): Date | undefined;
172
+ set version(version: number | undefined);
173
+ get version(): number | undefined;
174
+ set network(network: NetworkID | string | undefined);
175
+ get network(): NetworkID | undefined;
176
+ set subnet(subnet: SubnetID | string | undefined);
177
+ get subnet(): SubnetID | undefined;
178
+ addOperation(operation: Operations.BlockJSONOperations): void;
179
+ get operations(): Operations.BlockOperations[] | undefined;
180
+ }
181
+ export default Block;
@@ -0,0 +1,407 @@
1
+ import { ValidateASN1 } from '../utils/asn1';
2
+ import type { DeepMutable } from '../utils/helper';
3
+ import type { GenericAccount, IdentifierAddress, TokenAddress, TokenPublicKeyString } from '../account';
4
+ import Account from '../account';
5
+ import type { AcceptedPermissionTypes } from '../permissions';
6
+ import Permissions from '../permissions';
7
+ import type { JSONSupported } from '../utils/conversion';
8
+ import Block, { AdjustMethod } from '.';
9
+ /**
10
+ * All supported operations
11
+ */
12
+ export declare enum OperationType {
13
+ SEND = 0,
14
+ SET_REP = 1,
15
+ SET_INFO = 2,
16
+ MODIFY_PERMISSIONS = 3,
17
+ CREATE_IDENTIFIER = 4,
18
+ TOKEN_ADMIN_SUPPLY = 5,
19
+ TOKEN_ADMIN_MODIFY_BALANCE = 6,
20
+ RECEIVE = 7
21
+ }
22
+ export type BlockOperationTypes = keyof typeof OperationType;
23
+ /**
24
+ * Schema for each operation as well as names of each field within the block operations
25
+ */
26
+ declare const BlockOperationASN1SchemaBase: {
27
+ readonly SEND: [{
28
+ readonly name: "to";
29
+ readonly schema: typeof ValidateASN1.IsOctetString;
30
+ }, {
31
+ readonly name: "amount";
32
+ readonly schema: typeof ValidateASN1.IsInteger;
33
+ }, {
34
+ readonly name: "token";
35
+ readonly schema: typeof ValidateASN1.IsOctetString;
36
+ }, {
37
+ readonly name: "external";
38
+ readonly schema: {
39
+ readonly optional: {
40
+ readonly type: "string";
41
+ readonly kind: "utf8";
42
+ };
43
+ };
44
+ }];
45
+ readonly RECEIVE: [{
46
+ readonly name: "amount";
47
+ readonly schema: typeof ValidateASN1.IsInteger;
48
+ }, {
49
+ readonly name: "token";
50
+ readonly schema: typeof ValidateASN1.IsOctetString;
51
+ }, {
52
+ readonly name: "from";
53
+ readonly schema: typeof ValidateASN1.IsOctetString;
54
+ }, {
55
+ readonly name: "exact";
56
+ readonly schema: typeof ValidateASN1.IsBoolean;
57
+ }, {
58
+ readonly name: "forward";
59
+ readonly schema: {
60
+ readonly optional: typeof ValidateASN1.IsOctetString;
61
+ };
62
+ }];
63
+ readonly SET_REP: [{
64
+ readonly name: "to";
65
+ readonly schema: typeof ValidateASN1.IsOctetString;
66
+ }];
67
+ readonly SET_INFO: [{
68
+ readonly name: "name";
69
+ readonly schema: {
70
+ readonly type: "string";
71
+ readonly kind: "utf8";
72
+ };
73
+ }, {
74
+ readonly name: "description";
75
+ readonly schema: {
76
+ readonly type: "string";
77
+ readonly kind: "utf8";
78
+ };
79
+ }, {
80
+ readonly name: "metadata";
81
+ readonly schema: {
82
+ readonly type: "string";
83
+ readonly kind: "utf8";
84
+ };
85
+ }, {
86
+ readonly name: "defaultPermission";
87
+ readonly schema: {
88
+ readonly optional: readonly [typeof ValidateASN1.IsInteger, typeof ValidateASN1.IsInteger];
89
+ };
90
+ }];
91
+ readonly MODIFY_PERMISSIONS: [{
92
+ readonly name: "principal";
93
+ readonly schema: typeof ValidateASN1.IsOctetString;
94
+ }, {
95
+ readonly name: "method";
96
+ readonly schema: typeof ValidateASN1.IsInteger;
97
+ }, {
98
+ readonly name: "permissions";
99
+ readonly schema: {
100
+ readonly choice: [typeof ValidateASN1.IsNull, readonly [typeof ValidateASN1.IsInteger, typeof ValidateASN1.IsInteger]];
101
+ };
102
+ }, {
103
+ readonly name: "target";
104
+ readonly schema: {
105
+ readonly optional: typeof ValidateASN1.IsOctetString;
106
+ };
107
+ }];
108
+ readonly CREATE_IDENTIFIER: [{
109
+ readonly name: "identifier";
110
+ readonly schema: typeof ValidateASN1.IsOctetString;
111
+ }];
112
+ readonly TOKEN_ADMIN_SUPPLY: [{
113
+ readonly name: "amount";
114
+ readonly schema: typeof ValidateASN1.IsInteger;
115
+ }, {
116
+ readonly name: "method";
117
+ readonly schema: typeof ValidateASN1.IsInteger;
118
+ }];
119
+ readonly TOKEN_ADMIN_MODIFY_BALANCE: [{
120
+ readonly name: "token";
121
+ readonly schema: typeof ValidateASN1.IsOctetString;
122
+ }, {
123
+ readonly name: "amount";
124
+ readonly schema: typeof ValidateASN1.IsInteger;
125
+ }, {
126
+ readonly name: "method";
127
+ readonly schema: typeof ValidateASN1.IsInteger;
128
+ }];
129
+ };
130
+ type ExtractSchemaFromBase<T extends {
131
+ name: string;
132
+ schema: ValidateASN1.Schema;
133
+ }[]> = {
134
+ [K in keyof T]: T[K]['schema'];
135
+ };
136
+ /**
137
+ * Schema for each operation
138
+ */
139
+ export declare const BlockOperationASN1Schema: { [T in BlockOperationTypes]: {
140
+ type: "context";
141
+ kind: "explicit";
142
+ value: (typeof OperationType)[T];
143
+ contains: DeepMutable<ExtractSchemaFromBase<(typeof BlockOperationASN1SchemaBase)[T]>>;
144
+ }; };
145
+ /**
146
+ * Keys of the operations which we will serialize/deserialize
147
+ */
148
+ export declare const BlockOperationKeys: BlockOperationKeysType;
149
+ export type BlockOperationASN1SchemaType<T extends BlockOperationTypes = BlockOperationTypes> = typeof BlockOperationASN1Schema[T];
150
+ type BlockOperationKeysType = {
151
+ [Property in BlockOperationTypes as `${Property}`]: string[];
152
+ };
153
+ interface BlockJSONOperation {
154
+ type: OperationType;
155
+ }
156
+ interface BlockOperationValidateContext {
157
+ block: Block;
158
+ operationIndex: number;
159
+ }
160
+ declare class BlockOperation {
161
+ static isInstance: (obj: any, strict?: boolean) => obj is BlockOperation;
162
+ validate(_ignored_context: BlockOperationValidateContext): void;
163
+ protected computeTo(to: string | GenericAccount, isIdentifier: false): Account;
164
+ protected computeTo(to: string | GenericAccount, isIdentifier: true): IdentifierAddress;
165
+ protected computeTo(to: string | GenericAccount, isIdentifier?: undefined): GenericAccount;
166
+ protected computeAmount(amount: string | bigint): bigint;
167
+ }
168
+ interface BlockJSONOperationSEND extends BlockJSONOperation {
169
+ type: OperationType.SEND;
170
+ to: string | GenericAccount;
171
+ amount: string | bigint;
172
+ token: TokenPublicKeyString | TokenAddress;
173
+ external?: string;
174
+ }
175
+ declare class BlockOperationSEND extends BlockOperation implements BlockJSONOperationSEND {
176
+ #private;
177
+ static isInstance: (obj: any, strict?: boolean) => obj is BlockOperationSEND;
178
+ type: OperationType.SEND;
179
+ external: string | undefined;
180
+ constructor(input: BlockJSONOperationSEND);
181
+ set to(to: string | GenericAccount);
182
+ get to(): GenericAccount;
183
+ set token(token: TokenPublicKeyString | TokenAddress);
184
+ get token(): TokenAddress;
185
+ set amount(amount: string | bigint);
186
+ get amount(): bigint;
187
+ validate(context: BlockOperationValidateContext): void;
188
+ toJSON(): JSONSupported<BlockJSONOperationSEND>;
189
+ }
190
+ interface BlockJSONOperationRECEIVE extends BlockJSONOperation {
191
+ type: OperationType.RECEIVE;
192
+ amount: string | bigint;
193
+ token: TokenPublicKeyString | TokenAddress;
194
+ from: string | GenericAccount;
195
+ forward?: string | GenericAccount;
196
+ exact?: boolean;
197
+ }
198
+ declare class BlockOperationRECEIVE extends BlockOperation implements BlockJSONOperationRECEIVE {
199
+ #private;
200
+ static isInstance: (obj: any, strict?: boolean) => obj is BlockOperationRECEIVE;
201
+ type: OperationType.RECEIVE;
202
+ constructor(input: BlockJSONOperationRECEIVE);
203
+ set from(from: string | GenericAccount);
204
+ get from(): GenericAccount;
205
+ set forward(forward: undefined | string | GenericAccount);
206
+ get forward(): GenericAccount | undefined;
207
+ set exact(exact: boolean | undefined);
208
+ get exact(): boolean;
209
+ set token(token: TokenPublicKeyString | TokenAddress);
210
+ get token(): TokenAddress;
211
+ set amount(amount: string | bigint);
212
+ get amount(): bigint;
213
+ validate(context: BlockOperationValidateContext): void;
214
+ toJSON(): JSONSupported<BlockJSONOperationSEND>;
215
+ }
216
+ interface BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE extends BlockJSONOperation {
217
+ type: OperationType.TOKEN_ADMIN_MODIFY_BALANCE;
218
+ token: TokenPublicKeyString | TokenAddress;
219
+ amount: string | bigint;
220
+ method: AdjustMethod;
221
+ }
222
+ declare class BlockOperationTOKEN_ADMIN_MODIFY_BALANCE extends BlockOperation implements BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE {
223
+ #private;
224
+ static isInstance: (obj: any, strict?: boolean) => obj is BlockOperationTOKEN_ADMIN_MODIFY_BALANCE;
225
+ type: OperationType.TOKEN_ADMIN_MODIFY_BALANCE;
226
+ constructor(input: BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE);
227
+ set token(token: TokenPublicKeyString | TokenAddress);
228
+ get token(): TokenAddress;
229
+ set method(newMethod: AdjustMethod);
230
+ get method(): AdjustMethod;
231
+ set amount(amount: string | bigint);
232
+ get amount(): bigint;
233
+ validate(context: BlockOperationValidateContext): void;
234
+ toJSON(): JSONSupported<BlockJSONOperationTOKEN_ADMIN_MODIFY_BALANCE>;
235
+ }
236
+ /**
237
+ * SetRep operation
238
+ */
239
+ interface BlockJSONOperationSET_REP extends BlockJSONOperation {
240
+ type: OperationType.SET_REP;
241
+ to: string | GenericAccount;
242
+ }
243
+ declare class BlockOperationSET_REP extends BlockOperation implements BlockJSONOperationSET_REP {
244
+ #private;
245
+ static isInstance: (obj: any, strict?: boolean) => obj is BlockOperationSET_REP;
246
+ type: OperationType.SET_REP;
247
+ constructor(input: BlockJSONOperationSET_REP);
248
+ set to(to: string | Account);
249
+ get to(): Account;
250
+ validate(context: BlockOperationValidateContext): void;
251
+ toJSON(): JSONSupported<BlockJSONOperationSET_REP>;
252
+ }
253
+ /**
254
+ * TokenCreate Operation
255
+ */
256
+ interface BlockJSONOperationCREATE_IDENTIFIER extends BlockJSONOperation {
257
+ type: OperationType.CREATE_IDENTIFIER;
258
+ identifier: IdentifierAddress | string;
259
+ }
260
+ declare class BlockOperationCREATE_IDENTIFIER extends BlockOperation implements BlockJSONOperationCREATE_IDENTIFIER {
261
+ #private;
262
+ static isInstance: (obj: any, strict?: boolean) => obj is BlockOperationCREATE_IDENTIFIER;
263
+ type: OperationType.CREATE_IDENTIFIER;
264
+ constructor(input: BlockJSONOperationCREATE_IDENTIFIER);
265
+ set identifier(identifier: string | IdentifierAddress);
266
+ get identifier(): IdentifierAddress;
267
+ validate(context: BlockOperationValidateContext): void;
268
+ toJSON(): JSONSupported<BlockJSONOperationCREATE_IDENTIFIER>;
269
+ }
270
+ /**
271
+ * SetInfo operation
272
+ */
273
+ interface BlockJSONOperationSET_INFO extends BlockJSONOperation {
274
+ type: OperationType.SET_INFO;
275
+ name: string;
276
+ description: string;
277
+ metadata: string;
278
+ defaultPermission?: AcceptedPermissionTypes;
279
+ }
280
+ declare class BlockOperationSET_INFO extends BlockOperation implements BlockJSONOperationSET_INFO {
281
+ #private;
282
+ static isInstance: (obj: any, strict?: boolean) => obj is BlockOperationSET_INFO;
283
+ type: OperationType.SET_INFO;
284
+ constructor(input: BlockJSONOperationSET_INFO);
285
+ set name(name: string);
286
+ get name(): string;
287
+ set description(description: string);
288
+ get description(): string;
289
+ set metadata(metadata: string);
290
+ get metadata(): string;
291
+ set defaultPermission(newPerms: Permissions | undefined);
292
+ get defaultPermission(): Permissions | undefined;
293
+ validate(context: BlockOperationValidateContext): void;
294
+ toJSON(): JSONSupported<BlockJSONOperationSET_INFO>;
295
+ }
296
+ /**
297
+ * Set Permissions Operation
298
+ */
299
+ interface BlockJSONOperationMODIFY_PERMISSIONS extends BlockJSONOperation {
300
+ type: OperationType.MODIFY_PERMISSIONS;
301
+ principal: string | GenericAccount;
302
+ method: AdjustMethod;
303
+ permissions: AcceptedPermissionTypes | null;
304
+ target?: string | GenericAccount;
305
+ }
306
+ declare class BlockOperationMODIFY_PERMISSIONS extends BlockOperation implements BlockJSONOperationMODIFY_PERMISSIONS {
307
+ #private;
308
+ static isInstance: (obj: any, strict?: boolean) => obj is BlockOperationMODIFY_PERMISSIONS;
309
+ type: OperationType.MODIFY_PERMISSIONS;
310
+ constructor(input: BlockJSONOperationMODIFY_PERMISSIONS);
311
+ set principal(principal: string | GenericAccount);
312
+ get principal(): GenericAccount;
313
+ set permissions(newPerms: Permissions | null);
314
+ get permissions(): Permissions | null;
315
+ set target(token: string | GenericAccount | undefined);
316
+ get target(): GenericAccount | undefined;
317
+ set method(method: AdjustMethod);
318
+ get method(): AdjustMethod;
319
+ validate(context: BlockOperationValidateContext): void;
320
+ toJSON(): JSONSupported<BlockOperationMODIFY_PERMISSIONS>;
321
+ }
322
+ /**
323
+ * Token Supply operation
324
+ */
325
+ interface BlockJSONOperationTOKEN_ADMIN_SUPPLY extends BlockJSONOperation {
326
+ type: OperationType.TOKEN_ADMIN_SUPPLY;
327
+ amount: bigint | string;
328
+ method: Omit<AdjustMethod, AdjustMethod.SET>;
329
+ }
330
+ declare class BlockOperationTOKEN_ADMIN_SUPPLY extends BlockOperation implements BlockJSONOperationTOKEN_ADMIN_SUPPLY {
331
+ #private;
332
+ static isInstance: (obj: any, strict?: boolean) => obj is BlockOperationTOKEN_ADMIN_SUPPLY;
333
+ type: OperationType.TOKEN_ADMIN_SUPPLY;
334
+ constructor(input: BlockJSONOperationTOKEN_ADMIN_SUPPLY);
335
+ set amount(amount: string | bigint);
336
+ get amount(): bigint;
337
+ set method(shouldAdd: AdjustMethod);
338
+ get method(): AdjustMethod;
339
+ validate(context: BlockOperationValidateContext): void;
340
+ toJSON(): JSONSupported<BlockJSONOperationTOKEN_ADMIN_SUPPLY>;
341
+ }
342
+ /**
343
+ * Aggregate set of operations
344
+ */
345
+ export declare const Operation: {
346
+ SEND: typeof BlockOperationSEND;
347
+ SET_REP: typeof BlockOperationSET_REP;
348
+ SET_INFO: typeof BlockOperationSET_INFO;
349
+ MODIFY_PERMISSIONS: typeof BlockOperationMODIFY_PERMISSIONS;
350
+ CREATE_IDENTIFIER: typeof BlockOperationCREATE_IDENTIFIER;
351
+ TOKEN_ADMIN_SUPPLY: typeof BlockOperationTOKEN_ADMIN_SUPPLY;
352
+ TOKEN_ADMIN_MODIFY_BALANCE: typeof BlockOperationTOKEN_ADMIN_MODIFY_BALANCE;
353
+ RECEIVE: typeof BlockOperationRECEIVE;
354
+ };
355
+ export type { BlockOperationSEND, BlockOperationSET_REP, BlockOperationSET_INFO, BlockOperationMODIFY_PERMISSIONS, BlockOperationCREATE_IDENTIFIER, BlockOperationTOKEN_ADMIN_SUPPLY, BlockOperationTOKEN_ADMIN_MODIFY_BALANCE, BlockOperationRECEIVE };
356
+ export type BlockOperations = InstanceType<typeof Operation[keyof typeof OperationType]>;
357
+ export type BlockJSONOperations = ConstructorParameters<typeof Operation[keyof typeof OperationType]>[0];
358
+ export declare function createBlockOperation(input: BlockJSONOperations): BlockOperationSEND | BlockOperationRECEIVE | BlockOperationTOKEN_ADMIN_MODIFY_BALANCE | BlockOperationSET_REP | BlockOperationSET_INFO | BlockOperationMODIFY_PERMISSIONS | BlockOperationCREATE_IDENTIFIER | BlockOperationTOKEN_ADMIN_SUPPLY;
359
+ export declare function isBlockOperation(input: any): input is BlockOperations;
360
+ /**
361
+ * Export the "operations" mapping as something compatible with being
362
+ * serialized to JSON
363
+ */
364
+ export declare function ExportOperationsJSON(operations: BlockOperations[]): JSONSupported<BlockJSONOperations>[];
365
+ export declare function ImportOperationsJSON(operations: BlockOperations[] | BlockJSONOperations[]): BlockOperations[];
366
+ export declare function ExportBlockOperations(operations: BlockOperations[]): ((Omit<import("../utils/asn1").ASN1ContextTag, "kind" | "value" | "contains"> & {
367
+ contains: [bigint, bigint];
368
+ value: OperationType.TOKEN_ADMIN_SUPPLY;
369
+ kind: "explicit";
370
+ }) | (Omit<import("../utils/asn1").ASN1ContextTag, "kind" | "value" | "contains"> & {
371
+ contains: [Buffer, bigint, bigint];
372
+ value: OperationType.TOKEN_ADMIN_MODIFY_BALANCE;
373
+ kind: "explicit";
374
+ }) | (Omit<import("../utils/asn1").ASN1ContextTag, "kind" | "value" | "contains"> & {
375
+ contains: [Buffer, bigint, Buffer, (Omit<import("../utils/asn1").ASN1String, "kind"> & {
376
+ kind: "utf8";
377
+ }) | undefined];
378
+ value: OperationType.SEND;
379
+ kind: "explicit";
380
+ }) | (Omit<import("../utils/asn1").ASN1ContextTag, "kind" | "value" | "contains"> & {
381
+ contains: [Buffer];
382
+ value: OperationType.SET_REP;
383
+ kind: "explicit";
384
+ }) | (Omit<import("../utils/asn1").ASN1ContextTag, "kind" | "value" | "contains"> & {
385
+ contains: [Omit<import("../utils/asn1").ASN1String, "kind"> & {
386
+ kind: "utf8";
387
+ }, Omit<import("../utils/asn1").ASN1String, "kind"> & {
388
+ kind: "utf8";
389
+ }, Omit<import("../utils/asn1").ASN1String, "kind"> & {
390
+ kind: "utf8";
391
+ }, [bigint, bigint] | undefined];
392
+ value: OperationType.SET_INFO;
393
+ kind: "explicit";
394
+ }) | (Omit<import("../utils/asn1").ASN1ContextTag, "kind" | "value" | "contains"> & {
395
+ contains: [Buffer, bigint, [bigint, bigint] | null, Buffer | undefined];
396
+ value: OperationType.MODIFY_PERMISSIONS;
397
+ kind: "explicit";
398
+ }) | (Omit<import("../utils/asn1").ASN1ContextTag, "kind" | "value" | "contains"> & {
399
+ contains: [Buffer];
400
+ value: OperationType.CREATE_IDENTIFIER;
401
+ kind: "explicit";
402
+ }) | (Omit<import("../utils/asn1").ASN1ContextTag, "kind" | "value" | "contains"> & {
403
+ contains: [bigint, Buffer, Buffer, boolean, Buffer | undefined];
404
+ value: OperationType.RECEIVE;
405
+ kind: "explicit";
406
+ }))[];
407
+ export declare function ImportOperationsASN1(input: unknown[], network: bigint): BlockOperations[];
@@ -0,0 +1,27 @@
1
+ import type Node from './node';
2
+ import type { KVStorageProvider } from './kv';
3
+ import type { VoteStaple } from './vote';
4
+ interface BootstrapFullConfig {
5
+ period: number;
6
+ timeout?: number;
7
+ kv: KVStorageProvider | null;
8
+ callback?: (voteStaple: VoteStaple) => Promise<void>;
9
+ }
10
+ export type BootstrapConfig = Partial<BootstrapFullConfig>;
11
+ type NodeLike = Pick<Node, 'log' | 'config' | 'ledger'> & Partial<Pick<Node, 'switch'>>;
12
+ export declare class BootstrapClient {
13
+ #private;
14
+ timeout: number;
15
+ static isInstance: (obj: any, strict?: boolean) => obj is BootstrapClient;
16
+ constructor(node: NodeLike, config?: BootstrapConfig);
17
+ resetKV(): Promise<void>;
18
+ stats(): Promise<{
19
+ lastUpdate: Date | undefined;
20
+ completeCount: number;
21
+ }>;
22
+ update(limit?: number): Promise<{
23
+ complete: boolean;
24
+ }>;
25
+ stop(): Promise<void>;
26
+ }
27
+ export default BootstrapClient;
@@ -0,0 +1,9 @@
1
+ import KeetaNetError from '.';
2
+ declare const AccountErrorType: "ACCOUNT";
3
+ declare const AccountErrorCodes: readonly ["INVALID_PREFIX", "INVALID_KEYTYPE", "INVALID_KEYTYPE_EXTERNAL", "PASSPHRASE_WEAK", "INVALID_CONSTRUCTION", "NO_IDENTIFIER_SIGN", "NO_IDENTIFIER_VERIFY", "INVALID_IDENTIFIER_CONSTRUCTION", "SEED_INDEX_UNDEFINED", "SEED_INDEX_NEGATIVE", "SEED_INDEX_NOT_INT", "SEED_INDEX_TOO_LARGE", "ENCRYPTION_NOT_SUPPORTED"];
4
+ export type AccountErrorCode = `${typeof AccountErrorType}_${typeof AccountErrorCodes[number]}`;
5
+ export default class KeetaNetAccountError extends KeetaNetError {
6
+ static isInstance: (obj: any, strict?: boolean) => obj is KeetaNetAccountError;
7
+ constructor(code: AccountErrorCode, message: string);
8
+ }
9
+ export {};
@@ -0,0 +1,9 @@
1
+ import KeetaNetError from '.';
2
+ declare const BlockErrorType: "BLOCK";
3
+ declare const BlockErrorCodes: readonly ["INVALID_TYPE", "NO_MULTIPLE_SET_REP", "IDENTIFIER_NEED_DEFAULT_PERMISSIONS", "CANNOT_SEND_NON_TOKEN", "TOKEN_RECEIVE_DIFFERS", "ONLY_TOKEN_OP", "ONLY_IDENTIFIER_OP", "NO_TOKEN_OP", "NO_IDENTIFIER_OP", "IDENTIFIER_INVALID", "GENERAL_FIELD_INVALID", "PERMISSIONS_INVALID_DEFAULT", "PERMISSIONS_INVALID_ENTITY", "PERMISSIONS_INVALID_PRINCIPAL", "PERMISSIONS_INVALID_TARGET", "INVALID_ACCOUNT_TYPE", "NO_ADMIN_ON_TARGET", "PREVIOUS_SELF", "NO_DELEGATE_ADMIN", "NO_MODIFY_PERMISSION_DUPE", "CANNOT_FORWARD_TO_SELF", "EXACT_TRUE_WHEN_FORWARDING", "EXTERNAL_TOO_LONG", "EXTERNAL_INVALID", "EXTERNAL_MISSING"];
4
+ export type BlockErrorCode = `${typeof BlockErrorType}_${typeof BlockErrorCodes[number]}`;
5
+ export default class KeetaNetBlockError extends KeetaNetError {
6
+ static isInstance: (obj: any, strict?: boolean) => obj is KeetaNetBlockError;
7
+ constructor(code: BlockErrorCode, message: string);
8
+ }
9
+ export {};
@@ -0,0 +1,9 @@
1
+ import KeetaNetError from '.';
2
+ declare const ClientErrorType: "CLIENT";
3
+ declare const ClientErrorCodes: readonly ["BUILDER_CANNOT_READ_BEFORE_RENDER", "BUILDER_REQUIRES_PRIVATE_KEY", "BUILDER_AMOUNT_IS_ZERO"];
4
+ export type ClientErrorCode = `${typeof ClientErrorType}_${typeof ClientErrorCodes[number]}`;
5
+ export default class KeetaNetClientError extends KeetaNetError {
6
+ static isInstance: (obj: any, strict?: boolean) => obj is KeetaNetClientError;
7
+ constructor(code: ClientErrorCode, message: string);
8
+ }
9
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { AccountErrorCode } from './account';
2
+ import type { BlockErrorCode } from './block';
3
+ import type { ClientErrorCode } from './client';
4
+ import type { LedgerErrorCode } from './ledger';
5
+ import type { VoteErrorCode } from './vote';
6
+ import type { KVErrorCode } from './kv';
7
+ import type { PermissionsErrorCode } from './permissions';
8
+ export type ErrorCode = BlockErrorCode | LedgerErrorCode | AccountErrorCode | ClientErrorCode | VoteErrorCode | PermissionsErrorCode | KVErrorCode;
9
+ export declare function ExpectErrorCode(code: ErrorCode, test: () => any): Promise<void>;
10
+ interface ValidationOptions {
11
+ type: string;
12
+ codes: string[] | Readonly<string[]>;
13
+ }
14
+ export default class KeetaNetError extends Error {
15
+ static isInstance: (obj: any, strict?: boolean) => obj is KeetaNetError;
16
+ type: string;
17
+ code: ErrorCode;
18
+ constructor(code: ErrorCode, message: string, validation?: ValidationOptions);
19
+ }
20
+ export {};
@@ -0,0 +1,9 @@
1
+ import KeetaNetError from '.';
2
+ declare const KVErrorType: "KV";
3
+ declare const KVErrorCodes: readonly ["TTL_NOT_SUPPORTED"];
4
+ export type KVErrorCode = `${typeof KVErrorType}_${typeof KVErrorCodes[number]}`;
5
+ export default class KeetaNetKVError extends KeetaNetError {
6
+ static isInstance: (obj: any, strict?: boolean) => obj is KeetaNetKVError;
7
+ constructor(code: KVErrorCode, message: string);
8
+ }
9
+ export {};