koilib 2.7.0 → 3.1.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.
- package/README.md +75 -12
- package/dist/koinos.js +8556 -269
- package/dist/koinos.min.js +1 -1
- package/lib/Contract.d.ts +66 -18
- package/lib/Contract.js +103 -40
- package/lib/Contract.js.map +1 -1
- package/lib/Provider.d.ts +22 -7
- package/lib/Provider.js +60 -21
- package/lib/Provider.js.map +1 -1
- package/lib/Serializer.d.ts +9 -3
- package/lib/Serializer.js +111 -85
- package/lib/Serializer.js.map +1 -1
- package/lib/Signer.d.ts +58 -38
- package/lib/Signer.js +318 -97
- package/lib/Signer.js.map +1 -1
- package/lib/browser/Contract.d.ts +66 -18
- package/lib/browser/Contract.js +103 -40
- package/lib/browser/Contract.js.map +1 -1
- package/lib/browser/Provider.d.ts +22 -7
- package/lib/browser/Provider.js +60 -21
- package/lib/browser/Provider.js.map +1 -1
- package/lib/browser/Serializer.d.ts +9 -3
- package/lib/browser/Serializer.js +111 -85
- package/lib/browser/Serializer.js.map +1 -1
- package/lib/browser/Signer.d.ts +58 -38
- package/lib/browser/Signer.js +318 -97
- package/lib/browser/Signer.js.map +1 -1
- package/lib/browser/index.d.ts +1 -1
- package/lib/browser/index.js +1 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/indexUtils.d.ts +2 -0
- package/lib/browser/indexUtils.js +15 -0
- package/lib/browser/indexUtils.js.map +1 -0
- package/lib/browser/interface.d.ts +242 -46
- package/lib/browser/jsonDescriptors/chain-proto.json +676 -0
- package/lib/browser/jsonDescriptors/{krc20-proto.json → token-proto.json} +47 -4
- package/lib/browser/protoModules/protocol-proto.d.ts +2 -0
- package/lib/browser/protoModules/protocol-proto.js +6336 -0
- package/lib/browser/protoModules/protocol-proto.js.map +1 -0
- package/lib/browser/utils.d.ts +19 -255
- package/lib/browser/utils.js +170 -15
- package/lib/browser/utils.js.map +1 -1
- package/lib/browser/utilsNode.d.ts +1021 -0
- package/lib/browser/utilsNode.js +346 -0
- package/lib/browser/utilsNode.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/indexUtils.d.ts +2 -0
- package/lib/indexUtils.js +15 -0
- package/lib/indexUtils.js.map +1 -0
- package/lib/interface.d.ts +242 -46
- package/lib/jsonDescriptors/chain-proto.json +676 -0
- package/lib/jsonDescriptors/{krc20-proto.json → token-proto.json} +47 -4
- package/lib/protoModules/protocol-proto.d.ts +2 -0
- package/lib/protoModules/protocol-proto.js +6336 -0
- package/lib/protoModules/protocol-proto.js.map +1 -0
- package/lib/utils.d.ts +19 -255
- package/lib/utils.js +170 -15
- package/lib/utils.js.map +1 -1
- package/lib/utilsNode.d.ts +1021 -0
- package/lib/utilsNode.js +346 -0
- package/lib/utilsNode.js.map +1 -0
- package/package.json +1 -1
- package/lib/browser/jsonDescriptors/protocol-proto.json +0 -246
- package/lib/jsonDescriptors/protocol-proto.json +0 -246
package/lib/interface.d.ts
CHANGED
|
@@ -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
|
|
114
|
-
|
|
115
|
-
|
|
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
|
|
@@ -148,26 +251,56 @@ export interface RecoverPublicKeyOptions {
|
|
|
148
251
|
*
|
|
149
252
|
* When _byTransactionId_ is used it returns the block id.
|
|
150
253
|
*
|
|
151
|
-
* @param timeout - Timeout in milliseconds. By default it is
|
|
254
|
+
* @param timeout - Timeout in milliseconds. By default it is 60000
|
|
152
255
|
*/
|
|
153
256
|
export declare type WaitFunction = (type?: "byBlock" | "byTransactionId", timeout?: number) => Promise<string | number>;
|
|
154
|
-
export interface
|
|
155
|
-
|
|
156
|
-
|
|
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
|
|
159
|
-
|
|
160
|
-
bytecode?: string;
|
|
267
|
+
export interface GenesisDataEncoded {
|
|
268
|
+
entries?: GenesisDataEntryEncoded[];
|
|
161
269
|
}
|
|
162
|
-
export interface
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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>;
|
|
303
|
+
rule?: "repeated";
|
|
171
304
|
}
|
|
172
305
|
export interface ContractCallBundle {
|
|
173
306
|
contract_id: Uint8Array;
|
|
@@ -184,13 +317,51 @@ export interface ContractCallBundleNested {
|
|
|
184
317
|
system_call_bundle: ContractCallBundle;
|
|
185
318
|
}
|
|
186
319
|
export declare type SystemCallTarget = ThunkIdNested | ContractCallBundleNested;
|
|
320
|
+
export interface SystemCallTargetJson {
|
|
321
|
+
thunk_id?: number;
|
|
322
|
+
system_call_bundle?: ContractCallBundleJson;
|
|
323
|
+
}
|
|
324
|
+
export interface UploadContractOperation {
|
|
325
|
+
contract_id?: Uint8Array;
|
|
326
|
+
bytecode?: Uint8Array;
|
|
327
|
+
abi?: string;
|
|
328
|
+
authorizes_call_contract?: boolean;
|
|
329
|
+
authorizes_transaction_application?: boolean;
|
|
330
|
+
authorizes_upload_contract?: boolean;
|
|
331
|
+
}
|
|
332
|
+
export interface UploadContractOperationJson {
|
|
333
|
+
contract_id?: string;
|
|
334
|
+
bytecode?: string;
|
|
335
|
+
abi?: string;
|
|
336
|
+
authorizes_call_contract?: boolean;
|
|
337
|
+
authorizes_transaction_application?: boolean;
|
|
338
|
+
authorizes_upload_contract?: boolean;
|
|
339
|
+
}
|
|
340
|
+
export interface CallContractOperation {
|
|
341
|
+
contract_id: Uint8Array;
|
|
342
|
+
entry_point: number;
|
|
343
|
+
args: Uint8Array;
|
|
344
|
+
}
|
|
345
|
+
export interface CallContractOperationJson {
|
|
346
|
+
contract_id: string;
|
|
347
|
+
entry_point: number;
|
|
348
|
+
args: string;
|
|
349
|
+
}
|
|
187
350
|
export interface SetSystemCallOperation {
|
|
188
351
|
call_id: number;
|
|
189
352
|
target: SystemCallTarget;
|
|
190
353
|
}
|
|
191
354
|
export interface SetSystemCallOperationJson {
|
|
192
355
|
call_id: number;
|
|
193
|
-
target:
|
|
356
|
+
target: SystemCallTargetJson;
|
|
357
|
+
}
|
|
358
|
+
export interface SetSystemContractOperation {
|
|
359
|
+
contract_id: Uint8Array;
|
|
360
|
+
system_contract: boolean;
|
|
361
|
+
}
|
|
362
|
+
export interface SetSystemContractOperationJson {
|
|
363
|
+
contract_id: string;
|
|
364
|
+
system_contract: boolean;
|
|
194
365
|
}
|
|
195
366
|
export interface UploadContractOperationNested {
|
|
196
367
|
upload_contract: UploadContractOperation;
|
|
@@ -201,40 +372,41 @@ export interface CallContractOperationNested {
|
|
|
201
372
|
export interface SetSystemCallOperationNested {
|
|
202
373
|
set_system_call: SetSystemCallOperation;
|
|
203
374
|
}
|
|
204
|
-
export
|
|
375
|
+
export interface SetSystemContractOperationNested {
|
|
376
|
+
set_system_contract: SetSystemContractOperation;
|
|
377
|
+
}
|
|
378
|
+
export declare type Operation = UploadContractOperationNested | CallContractOperationNested | SetSystemCallOperationNested | SetSystemContractOperationNested;
|
|
205
379
|
export declare type OperationJson = {
|
|
206
380
|
upload_contract?: UploadContractOperationJson;
|
|
207
381
|
call_contract?: CallContractOperationJson;
|
|
208
382
|
set_system_call?: SetSystemCallOperationJson;
|
|
383
|
+
set_system_contract?: SetSystemContractOperationJson;
|
|
209
384
|
};
|
|
210
|
-
export interface
|
|
385
|
+
export interface TransactionHeaderJson {
|
|
386
|
+
/**
|
|
387
|
+
* ID of the chain
|
|
388
|
+
*/
|
|
389
|
+
chain_id?: string;
|
|
211
390
|
/**
|
|
212
391
|
* Resource credits limit
|
|
213
392
|
*/
|
|
214
|
-
rc_limit?: string
|
|
393
|
+
rc_limit?: string;
|
|
215
394
|
/**
|
|
216
395
|
* Account nonce
|
|
217
396
|
*/
|
|
218
|
-
nonce?: string
|
|
397
|
+
nonce?: string;
|
|
219
398
|
/**
|
|
220
|
-
*
|
|
399
|
+
* Merkle root of the serialized operations's SHA2-256 hashes
|
|
221
400
|
*/
|
|
222
|
-
|
|
223
|
-
[x: string]: unknown;
|
|
224
|
-
}
|
|
225
|
-
export interface ActiveTransactionDataJson {
|
|
401
|
+
operation_merkle_root?: string;
|
|
226
402
|
/**
|
|
227
|
-
*
|
|
403
|
+
* Transaction's payer
|
|
228
404
|
*/
|
|
229
|
-
|
|
405
|
+
payer?: string;
|
|
230
406
|
/**
|
|
231
|
-
*
|
|
407
|
+
* Transaction's payee
|
|
232
408
|
*/
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Array of operations
|
|
236
|
-
*/
|
|
237
|
-
operations?: OperationJson[];
|
|
409
|
+
payee?: string;
|
|
238
410
|
[x: string]: unknown;
|
|
239
411
|
}
|
|
240
412
|
/**
|
|
@@ -243,21 +415,21 @@ export interface ActiveTransactionDataJson {
|
|
|
243
415
|
export interface TransactionJson {
|
|
244
416
|
/**
|
|
245
417
|
* Transaction ID. It must be the sha2-256 of the
|
|
246
|
-
* serialized
|
|
418
|
+
* serialized header of the transaction
|
|
247
419
|
*/
|
|
248
420
|
id?: string;
|
|
249
421
|
/**
|
|
250
|
-
*
|
|
422
|
+
* Header of the transaction
|
|
251
423
|
*/
|
|
252
|
-
|
|
424
|
+
header?: TransactionHeaderJson;
|
|
253
425
|
/**
|
|
254
|
-
*
|
|
426
|
+
* Array of operations
|
|
255
427
|
*/
|
|
256
|
-
|
|
428
|
+
operations?: OperationJson[];
|
|
257
429
|
/**
|
|
258
|
-
*
|
|
430
|
+
* Signatures in compact format
|
|
259
431
|
*/
|
|
260
|
-
|
|
432
|
+
signatures?: string[];
|
|
261
433
|
}
|
|
262
434
|
export interface TransactionJsonWait extends TransactionJson {
|
|
263
435
|
wait: WaitFunction;
|
|
@@ -266,14 +438,38 @@ export interface BlockHeaderJson {
|
|
|
266
438
|
previous?: string;
|
|
267
439
|
height?: string;
|
|
268
440
|
timestamp?: string;
|
|
441
|
+
previous_state_merkle_root?: string;
|
|
442
|
+
transaction_merkle_root?: string;
|
|
443
|
+
signer?: string;
|
|
269
444
|
[x: string]: unknown;
|
|
270
445
|
}
|
|
271
446
|
export interface BlockJson {
|
|
272
447
|
id?: string;
|
|
273
448
|
header?: BlockHeaderJson;
|
|
274
|
-
active?: string;
|
|
275
|
-
passive?: string;
|
|
276
|
-
signature_data?: string;
|
|
277
449
|
transactions?: TransactionJson[];
|
|
450
|
+
signature?: string;
|
|
278
451
|
[x: string]: unknown;
|
|
279
452
|
}
|
|
453
|
+
export interface ValueType {
|
|
454
|
+
uint64_value?: string;
|
|
455
|
+
[x: string]: unknown;
|
|
456
|
+
}
|
|
457
|
+
export interface TransactionReceipt {
|
|
458
|
+
id: string;
|
|
459
|
+
payer: string;
|
|
460
|
+
max_payer_rc: string;
|
|
461
|
+
rc_limit: string;
|
|
462
|
+
rc_used: string;
|
|
463
|
+
disk_storage_used: string;
|
|
464
|
+
network_bandwidth_used: string;
|
|
465
|
+
compute_bandwidth_used: string;
|
|
466
|
+
reverted: boolean;
|
|
467
|
+
events: {
|
|
468
|
+
sequence: number;
|
|
469
|
+
source: string;
|
|
470
|
+
name: string;
|
|
471
|
+
data: string;
|
|
472
|
+
impacted: string[];
|
|
473
|
+
}[];
|
|
474
|
+
logs: string[];
|
|
475
|
+
}
|