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.
- package/README.md +61 -7
- package/dist/koinos.js +8404 -200
- package/dist/koinos.min.js +1 -1
- package/lib/Contract.d.ts +46 -7
- package/lib/Contract.js +89 -21
- package/lib/Contract.js.map +1 -1
- package/lib/Provider.d.ts +16 -3
- package/lib/Provider.js +36 -6
- package/lib/Provider.js.map +1 -1
- package/lib/Serializer.d.ts +2 -1
- package/lib/Serializer.js +50 -37
- package/lib/Serializer.js.map +1 -1
- package/lib/Signer.d.ts +42 -42
- package/lib/Signer.js +294 -112
- package/lib/Signer.js.map +1 -1
- package/lib/browser/Contract.d.ts +46 -7
- package/lib/browser/Contract.js +89 -21
- package/lib/browser/Contract.js.map +1 -1
- package/lib/browser/Provider.d.ts +16 -3
- package/lib/browser/Provider.js +36 -6
- package/lib/browser/Provider.js.map +1 -1
- package/lib/browser/Serializer.d.ts +2 -1
- package/lib/browser/Serializer.js +50 -37
- package/lib/browser/Serializer.js.map +1 -1
- package/lib/browser/Signer.d.ts +42 -42
- package/lib/browser/Signer.js +294 -112
- 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 +221 -45
- 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 +221 -45
- 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
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
|
|
@@ -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
|
|
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>;
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
392
|
+
rc_limit?: string;
|
|
215
393
|
/**
|
|
216
394
|
* Account nonce
|
|
217
395
|
*/
|
|
218
|
-
nonce?: string
|
|
396
|
+
nonce?: string;
|
|
219
397
|
/**
|
|
220
|
-
*
|
|
398
|
+
* Merkle root of the serialized operations's SHA2-256 hashes
|
|
221
399
|
*/
|
|
222
|
-
|
|
223
|
-
[x: string]: unknown;
|
|
224
|
-
}
|
|
225
|
-
export interface ActiveTransactionDataJson {
|
|
400
|
+
operation_merkle_root?: string;
|
|
226
401
|
/**
|
|
227
|
-
*
|
|
402
|
+
* Transaction's payer
|
|
228
403
|
*/
|
|
229
|
-
|
|
404
|
+
payer?: string;
|
|
230
405
|
/**
|
|
231
|
-
*
|
|
232
|
-
*/
|
|
233
|
-
nonce?: string | number | bigint;
|
|
234
|
-
/**
|
|
235
|
-
* Array of operations
|
|
406
|
+
* Transaction's payee
|
|
236
407
|
*/
|
|
237
|
-
|
|
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
|
|
417
|
+
* serialized header of the transaction
|
|
247
418
|
*/
|
|
248
419
|
id?: string;
|
|
249
420
|
/**
|
|
250
|
-
*
|
|
421
|
+
* Header of the transaction
|
|
251
422
|
*/
|
|
252
|
-
|
|
423
|
+
header?: TransactionHeaderJson;
|
|
253
424
|
/**
|
|
254
|
-
*
|
|
425
|
+
* Array of operations
|
|
255
426
|
*/
|
|
256
|
-
|
|
427
|
+
operations?: OperationJson[];
|
|
257
428
|
/**
|
|
258
|
-
*
|
|
429
|
+
* Signatures in compact format
|
|
259
430
|
*/
|
|
260
|
-
|
|
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
|
}
|