koilib 2.6.1 → 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.
- package/README.md +66 -12
- package/dist/koinos.js +8533 -274
- package/dist/koinos.min.js +1 -1
- package/lib/Contract.d.ts +53 -16
- package/lib/Contract.js +99 -31
- package/lib/Contract.js.map +1 -1
- package/lib/Provider.d.ts +39 -19
- package/lib/Provider.js +119 -87
- package/lib/Provider.js.map +1 -1
- package/lib/Serializer.d.ts +8 -3
- package/lib/Serializer.js +60 -41
- package/lib/Serializer.js.map +1 -1
- package/lib/Signer.d.ts +53 -39
- package/lib/Signer.js +320 -91
- package/lib/Signer.js.map +1 -1
- package/lib/browser/Contract.d.ts +53 -16
- package/lib/browser/Contract.js +99 -31
- package/lib/browser/Contract.js.map +1 -1
- package/lib/browser/Provider.d.ts +39 -19
- package/lib/browser/Provider.js +119 -87
- package/lib/browser/Provider.js.map +1 -1
- package/lib/browser/Serializer.d.ts +8 -3
- package/lib/browser/Serializer.js +60 -41
- package/lib/browser/Serializer.js.map +1 -1
- package/lib/browser/Signer.d.ts +53 -39
- package/lib/browser/Signer.js +320 -91
- 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 -65
- package/lib/browser/jsonDescriptors/chain-proto.json +676 -0
- package/lib/browser/jsonDescriptors/krc20-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 +18 -254
- package/lib/browser/utils.js +140 -12
- 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 -65
- package/lib/jsonDescriptors/chain-proto.json +676 -0
- package/lib/jsonDescriptors/krc20-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 +18 -254
- package/lib/utils.js +140 -12
- 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
|
@@ -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
|
|
@@ -132,44 +235,71 @@ export interface RecoverPublicKeyOptions {
|
|
|
132
235
|
*/
|
|
133
236
|
transformSignature?: (signatureData: string) => Promise<string>;
|
|
134
237
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
238
|
+
/**
|
|
239
|
+
* Function to wait for a transaction to be mined.
|
|
240
|
+
* This function comes as a response after sending a transaction.
|
|
241
|
+
* See [[Provider.sendTransaction]]
|
|
242
|
+
*
|
|
243
|
+
* @param type - Type must be "byBlock" (default) or "byTransactionId".
|
|
244
|
+
* _byBlock_ will query the blockchain to get blocks and search for the
|
|
245
|
+
* transaction there. _byTransactionId_ will query the "transaction store"
|
|
246
|
+
* microservice to search the transaction by its id. If non of them is
|
|
247
|
+
* specified the function will use "byBlock" (as "byTransactionId"
|
|
248
|
+
* requires the transaction store, which is an optional microservice).
|
|
249
|
+
*
|
|
250
|
+
* When _byBlock_ is used it returns the block number.
|
|
251
|
+
*
|
|
252
|
+
* When _byTransactionId_ is used it returns the block id.
|
|
253
|
+
*
|
|
254
|
+
* @param timeout - Timeout in milliseconds. By default it is 30000
|
|
255
|
+
*/
|
|
256
|
+
export declare type WaitFunction = (type?: "byBlock" | "byTransactionId", timeout?: number) => Promise<string | number>;
|
|
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;
|
|
155
266
|
}
|
|
156
|
-
export interface
|
|
157
|
-
|
|
158
|
-
bytecode?: Uint8Array;
|
|
267
|
+
export interface GenesisDataEncoded {
|
|
268
|
+
entries?: GenesisDataEntryEncoded[];
|
|
159
269
|
}
|
|
160
|
-
export interface
|
|
161
|
-
|
|
162
|
-
|
|
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;
|
|
163
280
|
}
|
|
164
|
-
export interface
|
|
165
|
-
|
|
166
|
-
entry_point: number;
|
|
167
|
-
args: Uint8Array;
|
|
281
|
+
export interface GenesisDataDecoded {
|
|
282
|
+
entries?: GenesisDataEntryDecoded[];
|
|
168
283
|
}
|
|
169
|
-
export interface
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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>;
|
|
173
303
|
}
|
|
174
304
|
export interface ContractCallBundle {
|
|
175
305
|
contract_id: Uint8Array;
|
|
@@ -186,13 +316,51 @@ export interface ContractCallBundleNested {
|
|
|
186
316
|
system_call_bundle: ContractCallBundle;
|
|
187
317
|
}
|
|
188
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
|
+
}
|
|
189
349
|
export interface SetSystemCallOperation {
|
|
190
350
|
call_id: number;
|
|
191
351
|
target: SystemCallTarget;
|
|
192
352
|
}
|
|
193
353
|
export interface SetSystemCallOperationJson {
|
|
194
354
|
call_id: number;
|
|
195
|
-
target:
|
|
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;
|
|
196
364
|
}
|
|
197
365
|
export interface UploadContractOperationNested {
|
|
198
366
|
upload_contract: UploadContractOperation;
|
|
@@ -203,40 +371,41 @@ export interface CallContractOperationNested {
|
|
|
203
371
|
export interface SetSystemCallOperationNested {
|
|
204
372
|
set_system_call: SetSystemCallOperation;
|
|
205
373
|
}
|
|
206
|
-
export
|
|
374
|
+
export interface SetSystemContractOperationNested {
|
|
375
|
+
set_system_contract: SetSystemContractOperation;
|
|
376
|
+
}
|
|
377
|
+
export declare type Operation = UploadContractOperationNested | CallContractOperationNested | SetSystemCallOperationNested | SetSystemContractOperationNested;
|
|
207
378
|
export declare type OperationJson = {
|
|
208
379
|
upload_contract?: UploadContractOperationJson;
|
|
209
380
|
call_contract?: CallContractOperationJson;
|
|
210
381
|
set_system_call?: SetSystemCallOperationJson;
|
|
382
|
+
set_system_contract?: SetSystemContractOperationJson;
|
|
211
383
|
};
|
|
212
|
-
export interface
|
|
384
|
+
export interface TransactionHeaderJson {
|
|
213
385
|
/**
|
|
214
|
-
*
|
|
386
|
+
* ID of the chain
|
|
215
387
|
*/
|
|
216
|
-
|
|
388
|
+
chain_id?: string;
|
|
217
389
|
/**
|
|
218
|
-
*
|
|
390
|
+
* Resource credits limit
|
|
219
391
|
*/
|
|
220
|
-
|
|
392
|
+
rc_limit?: string;
|
|
221
393
|
/**
|
|
222
|
-
*
|
|
394
|
+
* Account nonce
|
|
223
395
|
*/
|
|
224
|
-
|
|
225
|
-
[x: string]: unknown;
|
|
226
|
-
}
|
|
227
|
-
export interface ActiveTransactionDataJson {
|
|
396
|
+
nonce?: string;
|
|
228
397
|
/**
|
|
229
|
-
*
|
|
398
|
+
* Merkle root of the serialized operations's SHA2-256 hashes
|
|
230
399
|
*/
|
|
231
|
-
|
|
400
|
+
operation_merkle_root?: string;
|
|
232
401
|
/**
|
|
233
|
-
*
|
|
402
|
+
* Transaction's payer
|
|
234
403
|
*/
|
|
235
|
-
|
|
404
|
+
payer?: string;
|
|
236
405
|
/**
|
|
237
|
-
*
|
|
406
|
+
* Transaction's payee
|
|
238
407
|
*/
|
|
239
|
-
|
|
408
|
+
payee?: string;
|
|
240
409
|
[x: string]: unknown;
|
|
241
410
|
}
|
|
242
411
|
/**
|
|
@@ -245,34 +414,42 @@ export interface ActiveTransactionDataJson {
|
|
|
245
414
|
export interface TransactionJson {
|
|
246
415
|
/**
|
|
247
416
|
* Transaction ID. It must be the sha2-256 of the
|
|
248
|
-
* serialized
|
|
417
|
+
* serialized header of the transaction
|
|
249
418
|
*/
|
|
250
419
|
id?: string;
|
|
251
420
|
/**
|
|
252
|
-
*
|
|
421
|
+
* Header of the transaction
|
|
253
422
|
*/
|
|
254
|
-
|
|
423
|
+
header?: TransactionHeaderJson;
|
|
255
424
|
/**
|
|
256
|
-
*
|
|
425
|
+
* Array of operations
|
|
257
426
|
*/
|
|
258
|
-
|
|
427
|
+
operations?: OperationJson[];
|
|
259
428
|
/**
|
|
260
|
-
*
|
|
429
|
+
* Signatures in compact format
|
|
261
430
|
*/
|
|
262
|
-
|
|
431
|
+
signatures?: string[];
|
|
432
|
+
}
|
|
433
|
+
export interface TransactionJsonWait extends TransactionJson {
|
|
434
|
+
wait: WaitFunction;
|
|
263
435
|
}
|
|
264
436
|
export interface BlockHeaderJson {
|
|
265
437
|
previous?: string;
|
|
266
438
|
height?: string;
|
|
267
439
|
timestamp?: string;
|
|
440
|
+
previous_state_merkle_root?: string;
|
|
441
|
+
transaction_merkle_root?: string;
|
|
442
|
+
signer?: string;
|
|
268
443
|
[x: string]: unknown;
|
|
269
444
|
}
|
|
270
445
|
export interface BlockJson {
|
|
271
446
|
id?: string;
|
|
272
447
|
header?: BlockHeaderJson;
|
|
273
|
-
active?: string;
|
|
274
|
-
passive?: string;
|
|
275
|
-
signature_data?: string;
|
|
276
448
|
transactions?: TransactionJson[];
|
|
449
|
+
signature?: string;
|
|
450
|
+
[x: string]: unknown;
|
|
451
|
+
}
|
|
452
|
+
export interface ValueType {
|
|
453
|
+
uint64_value?: string;
|
|
277
454
|
[x: string]: unknown;
|
|
278
455
|
}
|