koilib 2.8.0 → 3.0.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 (66) hide show
  1. package/README.md +61 -7
  2. package/dist/koinos.js +8404 -200
  3. package/dist/koinos.min.js +1 -1
  4. package/lib/Contract.d.ts +46 -7
  5. package/lib/Contract.js +89 -21
  6. package/lib/Contract.js.map +1 -1
  7. package/lib/Provider.d.ts +16 -3
  8. package/lib/Provider.js +36 -6
  9. package/lib/Provider.js.map +1 -1
  10. package/lib/Serializer.d.ts +2 -1
  11. package/lib/Serializer.js +50 -37
  12. package/lib/Serializer.js.map +1 -1
  13. package/lib/Signer.d.ts +42 -42
  14. package/lib/Signer.js +294 -112
  15. package/lib/Signer.js.map +1 -1
  16. package/lib/browser/Contract.d.ts +46 -7
  17. package/lib/browser/Contract.js +89 -21
  18. package/lib/browser/Contract.js.map +1 -1
  19. package/lib/browser/Provider.d.ts +16 -3
  20. package/lib/browser/Provider.js +36 -6
  21. package/lib/browser/Provider.js.map +1 -1
  22. package/lib/browser/Serializer.d.ts +2 -1
  23. package/lib/browser/Serializer.js +50 -37
  24. package/lib/browser/Serializer.js.map +1 -1
  25. package/lib/browser/Signer.d.ts +42 -42
  26. package/lib/browser/Signer.js +294 -112
  27. package/lib/browser/Signer.js.map +1 -1
  28. package/lib/browser/index.d.ts +1 -1
  29. package/lib/browser/index.js +1 -1
  30. package/lib/browser/index.js.map +1 -1
  31. package/lib/browser/indexUtils.d.ts +2 -0
  32. package/lib/browser/indexUtils.js +15 -0
  33. package/lib/browser/indexUtils.js.map +1 -0
  34. package/lib/browser/interface.d.ts +221 -45
  35. package/lib/browser/jsonDescriptors/chain-proto.json +676 -0
  36. package/lib/browser/jsonDescriptors/krc20-proto.json +47 -4
  37. package/lib/browser/protoModules/protocol-proto.d.ts +2 -0
  38. package/lib/browser/protoModules/protocol-proto.js +6336 -0
  39. package/lib/browser/protoModules/protocol-proto.js.map +1 -0
  40. package/lib/browser/utils.d.ts +18 -254
  41. package/lib/browser/utils.js +140 -12
  42. package/lib/browser/utils.js.map +1 -1
  43. package/lib/browser/utilsNode.d.ts +1021 -0
  44. package/lib/browser/utilsNode.js +346 -0
  45. package/lib/browser/utilsNode.js.map +1 -0
  46. package/lib/index.d.ts +1 -1
  47. package/lib/index.js +1 -1
  48. package/lib/index.js.map +1 -1
  49. package/lib/indexUtils.d.ts +2 -0
  50. package/lib/indexUtils.js +15 -0
  51. package/lib/indexUtils.js.map +1 -0
  52. package/lib/interface.d.ts +221 -45
  53. package/lib/jsonDescriptors/chain-proto.json +676 -0
  54. package/lib/jsonDescriptors/krc20-proto.json +47 -4
  55. package/lib/protoModules/protocol-proto.d.ts +2 -0
  56. package/lib/protoModules/protocol-proto.js +6336 -0
  57. package/lib/protoModules/protocol-proto.js.map +1 -0
  58. package/lib/utils.d.ts +18 -254
  59. package/lib/utils.js +140 -12
  60. package/lib/utils.js.map +1 -1
  61. package/lib/utilsNode.d.ts +1021 -0
  62. package/lib/utilsNode.js +346 -0
  63. package/lib/utilsNode.js.map +1 -0
  64. package/package.json +1 -1
  65. package/lib/browser/jsonDescriptors/protocol-proto.json +0 -246
  66. package/lib/jsonDescriptors/protocol-proto.json +0 -246
@@ -1,4 +1,5 @@
1
1
  import { INamespace } from "protobufjs/light";
2
+ import { Serializer } from "./Serializer";
2
3
  /**
3
4
  * Application Binary Interface (ABI)
4
5
  *
@@ -110,12 +111,114 @@ export interface DecodedOperationJson {
110
111
  /** Arguments decoded. See [[Abi]] */
111
112
  args?: Record<string, unknown>;
112
113
  }
113
- export interface TransactionOptions {
114
- rc_limit?: number | bigint | string;
115
- nonce?: number;
114
+ export interface BaseTransactionOptions {
115
+ /**
116
+ * Chain ID
117
+ *
118
+ * If this option is not set it will be taken
119
+ * by querying the blockchain
120
+ */
121
+ chainId?: string;
122
+ /**
123
+ * Resource Credits limit
124
+ *
125
+ * Max amount of mana to be spent. If this option
126
+ * is not set it will be taken by querying the
127
+ * actual mana of the payer
128
+ */
129
+ rcLimit?: string;
130
+ /**
131
+ * Transaction nonce
132
+ *
133
+ * It can be the nonce of the payee or the nonce of the
134
+ * payer. Use the payee's nonce when the payer's nonce changes
135
+ * continuosly without your control, for instance, when the
136
+ * payer is a dApp.
137
+ *
138
+ * The nonce is not required to be consecutive,
139
+ * only greater than the previous one.
140
+ *
141
+ * If this option is not set it will be taken
142
+ * from the blockchain depending on the payer/payee
143
+ * configuration.
144
+ */
145
+ nonce?: string;
146
+ /**
147
+ * Payer
148
+ *
149
+ * Address that will pay the resource credits (aka mana)
150
+ * consumed in the transaction.
151
+ *
152
+ * If this option is not set it will take the address
153
+ * of the signer as payer.
154
+ */
155
+ payer?: string;
156
+ /**
157
+ * Payee
158
+ *
159
+ * Address that increases the nonce. When this option is
160
+ * not set the blockchain will increase the payer's nonce.
161
+ */
162
+ payee?: string;
163
+ /**
164
+ * Sign transaction
165
+ *
166
+ * Boolean to define if the transaction should be signed.
167
+ * By default it is true.
168
+ */
169
+ signTransaction?: boolean;
170
+ /**
171
+ * Send transaction
172
+ *
173
+ * Boolean to define if the transaction should be signed
174
+ * ans broadcasted to the blockchain. By default it is
175
+ * true.
176
+ */
116
177
  sendTransaction?: boolean;
178
+ }
179
+ export interface TransactionOptions extends BaseTransactionOptions {
180
+ /**
181
+ * Send abis
182
+ *
183
+ * Boolean to define if the abis should be shared with
184
+ * the signer so it will be able to decode the operations.
185
+ * By default it is true.
186
+ */
117
187
  sendAbis?: boolean;
118
188
  }
189
+ export interface DeployOptions extends BaseTransactionOptions {
190
+ /**
191
+ * ABI
192
+ *
193
+ * ABI to be stored in the koinos-contract-meta-store.
194
+ * This option is optional.
195
+ */
196
+ abi?: string;
197
+ /**
198
+ * Authorizes call contract
199
+ *
200
+ * Set it true if the contract implements the "authorize"
201
+ * function and can authorize calling other contracts in
202
+ * its name.
203
+ */
204
+ authorizesCallContract?: boolean;
205
+ /**
206
+ * Authorizes transaction application
207
+ *
208
+ * Set it true if the contract implements the "authorize"
209
+ * function and can authorize paying the mana to apply
210
+ * transactions, or can authorize the use of its nonce
211
+ * to apply transactions.
212
+ */
213
+ authorizesTransactionApplication?: boolean;
214
+ /**
215
+ * Authorizes upload contract
216
+ *
217
+ * Set it true if the contract implements the "authorize"
218
+ * function and can authorize upgrades of the actual contract
219
+ */
220
+ authorizesUploadContract?: boolean;
221
+ }
119
222
  export interface RecoverPublicKeyOptions {
120
223
  /**
121
224
  * Boolean to define if the public key should
@@ -151,23 +254,52 @@ export interface RecoverPublicKeyOptions {
151
254
  * @param timeout - Timeout in milliseconds. By default it is 30000
152
255
  */
153
256
  export declare type WaitFunction = (type?: "byBlock" | "byTransactionId", timeout?: number) => Promise<string | number>;
154
- export interface UploadContractOperation {
155
- contract_id?: Uint8Array;
156
- bytecode?: Uint8Array;
257
+ export interface GenesisDataEntryEncoded {
258
+ space: {
259
+ system?: boolean;
260
+ zone?: string;
261
+ id?: number;
262
+ };
263
+ key?: string;
264
+ value: string;
265
+ error?: string;
157
266
  }
158
- export interface UploadContractOperationJson {
159
- contract_id?: string;
160
- bytecode?: string;
267
+ export interface GenesisDataEncoded {
268
+ entries?: GenesisDataEntryEncoded[];
161
269
  }
162
- export interface CallContractOperation {
163
- contract_id: Uint8Array;
164
- entry_point: number;
165
- args: Uint8Array;
270
+ export interface GenesisDataEntryDecoded {
271
+ space: {
272
+ system?: boolean;
273
+ zone?: string;
274
+ id?: number;
275
+ };
276
+ key?: string;
277
+ alias?: string;
278
+ value: string | Record<string, unknown>;
279
+ error?: string;
166
280
  }
167
- export interface CallContractOperationJson {
168
- contract_id: string;
169
- entry_point: number;
170
- args: string;
281
+ export interface GenesisDataDecoded {
282
+ entries?: GenesisDataEntryDecoded[];
283
+ }
284
+ export interface DictionaryGenesisData {
285
+ /** key name */
286
+ [x: string]: {
287
+ /** alternative name for the key name */
288
+ alias?: string;
289
+ /** boolean defining if it's an address */
290
+ isAddress?: boolean;
291
+ /** custom serializer */
292
+ serializer?: Serializer;
293
+ /** type name for serialization */
294
+ typeName?: string;
295
+ /** preformat bytes for base64url, base58 or hex string */
296
+ bytesConversion?: boolean;
297
+ };
298
+ }
299
+ export interface TypeField {
300
+ type: string;
301
+ btype?: string;
302
+ subtypes?: Record<string, TypeField>;
171
303
  }
172
304
  export interface ContractCallBundle {
173
305
  contract_id: Uint8Array;
@@ -184,13 +316,51 @@ export interface ContractCallBundleNested {
184
316
  system_call_bundle: ContractCallBundle;
185
317
  }
186
318
  export declare type SystemCallTarget = ThunkIdNested | ContractCallBundleNested;
319
+ export interface SystemCallTargetJson {
320
+ thunk_id?: number;
321
+ system_call_bundle?: ContractCallBundleJson;
322
+ }
323
+ export interface UploadContractOperation {
324
+ contract_id?: Uint8Array;
325
+ bytecode?: Uint8Array;
326
+ abi?: string;
327
+ authorizes_call_contract?: boolean;
328
+ authorizes_transaction_application?: boolean;
329
+ authorizes_upload_contract?: boolean;
330
+ }
331
+ export interface UploadContractOperationJson {
332
+ contract_id?: string;
333
+ bytecode?: string;
334
+ abi?: string;
335
+ authorizes_call_contract?: boolean;
336
+ authorizes_transaction_application?: boolean;
337
+ authorizes_upload_contract?: boolean;
338
+ }
339
+ export interface CallContractOperation {
340
+ contract_id: Uint8Array;
341
+ entry_point: number;
342
+ args: Uint8Array;
343
+ }
344
+ export interface CallContractOperationJson {
345
+ contract_id: string;
346
+ entry_point: number;
347
+ args: string;
348
+ }
187
349
  export interface SetSystemCallOperation {
188
350
  call_id: number;
189
351
  target: SystemCallTarget;
190
352
  }
191
353
  export interface SetSystemCallOperationJson {
192
354
  call_id: number;
193
- target: number | ContractCallBundleJson;
355
+ target: SystemCallTargetJson;
356
+ }
357
+ export interface SetSystemContractOperation {
358
+ contract_id: Uint8Array;
359
+ system_contract: boolean;
360
+ }
361
+ export interface SetSystemContractOperationJson {
362
+ contract_id: string;
363
+ system_contract: boolean;
194
364
  }
195
365
  export interface UploadContractOperationNested {
196
366
  upload_contract: UploadContractOperation;
@@ -201,40 +371,41 @@ export interface CallContractOperationNested {
201
371
  export interface SetSystemCallOperationNested {
202
372
  set_system_call: SetSystemCallOperation;
203
373
  }
204
- export declare type Operation = UploadContractOperationNested | CallContractOperationNested | SetSystemCallOperationNested;
374
+ export interface SetSystemContractOperationNested {
375
+ set_system_contract: SetSystemContractOperation;
376
+ }
377
+ export declare type Operation = UploadContractOperationNested | CallContractOperationNested | SetSystemCallOperationNested | SetSystemContractOperationNested;
205
378
  export declare type OperationJson = {
206
379
  upload_contract?: UploadContractOperationJson;
207
380
  call_contract?: CallContractOperationJson;
208
381
  set_system_call?: SetSystemCallOperationJson;
382
+ set_system_contract?: SetSystemContractOperationJson;
209
383
  };
210
- export interface ActiveTransactionData {
384
+ export interface TransactionHeaderJson {
385
+ /**
386
+ * ID of the chain
387
+ */
388
+ chain_id?: string;
211
389
  /**
212
390
  * Resource credits limit
213
391
  */
214
- rc_limit?: string | number | bigint;
392
+ rc_limit?: string;
215
393
  /**
216
394
  * Account nonce
217
395
  */
218
- nonce?: string | number | bigint;
396
+ nonce?: string;
219
397
  /**
220
- * Array of operations
398
+ * Merkle root of the serialized operations's SHA2-256 hashes
221
399
  */
222
- operations?: Operation[];
223
- [x: string]: unknown;
224
- }
225
- export interface ActiveTransactionDataJson {
400
+ operation_merkle_root?: string;
226
401
  /**
227
- * Resource credits limit
402
+ * Transaction's payer
228
403
  */
229
- rc_limit?: string | number | bigint;
404
+ payer?: string;
230
405
  /**
231
- * Account nonce
232
- */
233
- nonce?: string | number | bigint;
234
- /**
235
- * Array of operations
406
+ * Transaction's payee
236
407
  */
237
- operations?: OperationJson[];
408
+ payee?: string;
238
409
  [x: string]: unknown;
239
410
  }
240
411
  /**
@@ -243,21 +414,21 @@ export interface ActiveTransactionDataJson {
243
414
  export interface TransactionJson {
244
415
  /**
245
416
  * Transaction ID. It must be the sha2-256 of the
246
- * serialized data of active data, and encoded in multi base58
417
+ * serialized header of the transaction
247
418
  */
248
419
  id?: string;
249
420
  /**
250
- * Consensus data
421
+ * Header of the transaction
251
422
  */
252
- active?: string;
423
+ header?: TransactionHeaderJson;
253
424
  /**
254
- * Non-consensus data
425
+ * Array of operations
255
426
  */
256
- passive?: string;
427
+ operations?: OperationJson[];
257
428
  /**
258
- * Signature in compact format enconded in multi base64
429
+ * Signatures in compact format
259
430
  */
260
- signature_data?: string;
431
+ signatures?: string[];
261
432
  }
262
433
  export interface TransactionJsonWait extends TransactionJson {
263
434
  wait: WaitFunction;
@@ -266,14 +437,19 @@ export interface BlockHeaderJson {
266
437
  previous?: string;
267
438
  height?: string;
268
439
  timestamp?: string;
440
+ previous_state_merkle_root?: string;
441
+ transaction_merkle_root?: string;
442
+ signer?: string;
269
443
  [x: string]: unknown;
270
444
  }
271
445
  export interface BlockJson {
272
446
  id?: string;
273
447
  header?: BlockHeaderJson;
274
- active?: string;
275
- passive?: string;
276
- signature_data?: string;
277
448
  transactions?: TransactionJson[];
449
+ signature?: string;
450
+ [x: string]: unknown;
451
+ }
452
+ export interface ValueType {
453
+ uint64_value?: string;
278
454
  [x: string]: unknown;
279
455
  }