@taquito/local-forging 23.0.2 → 23.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/dist/lib/taquito-local-forging.js +7 -29
- package/dist/lib/version.js +2 -2
- package/dist/taquito-local-forging.es6.js +315 -1736
- package/dist/taquito-local-forging.es6.js.map +1 -1
- package/dist/taquito-local-forging.umd.js +389 -1810
- package/dist/taquito-local-forging.umd.js.map +1 -1
- package/dist/types/taquito-local-forging.d.ts +2 -3
- package/package.json +8 -7
- package/dist/lib/codec-proto022.js +0 -563
- package/dist/lib/constants-proto022.js +0 -286
- package/dist/lib/decoder-proto022.js +0 -63
- package/dist/lib/encoder-proto022.js +0 -62
- package/dist/lib/michelson/codec-proto022.js +0 -283
- package/dist/lib/schema/operation-proto022.js +0 -238
- package/dist/lib/validator-proto022.js +0 -56
- package/dist/types/codec-proto022.d.ts +0 -79
- package/dist/types/constants-proto022.d.ts +0 -74
- package/dist/types/decoder-proto022.d.ts +0 -5
- package/dist/types/encoder-proto022.d.ts +0 -4
- package/dist/types/michelson/codec-proto022.d.ts +0 -49
- package/dist/types/schema/operation-proto022.d.ts +0 -188
- package/dist/types/validator-proto022.d.ts +0 -13
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'fast-text-encoding';
|
|
2
|
-
import { PrefixV2, b58DecodeAndCheckPrefix, buf2hex, payloadLength, b58Encode, b58DecodePublicKeyHash, b58DecodePublicKey, InvalidPublicKeyError, b58DecodeAddress, ValidationResult, signaturePrefixes,
|
|
2
|
+
import { PrefixV2, b58DecodeAndCheckPrefix, buf2hex, payloadLength, b58Encode, b58DecodePublicKeyHash, b58DecodePublicKey, InvalidPublicKeyError, b58DecodeAddress, ValidationResult, signaturePrefixes, validateBlock } from '@taquito/utils';
|
|
3
3
|
import { ParameterValidationError, InvalidHexStringError, InvalidKeyHashError, InvalidAddressError, InvalidContractAddressError, ProhibitedActionError, InvalidSignatureError, InvalidOperationKindError, InvalidBlockHashError } from '@taquito/core';
|
|
4
4
|
import BigNumber$1, { BigNumber } from 'bignumber.js';
|
|
5
5
|
|
|
@@ -13,8 +13,8 @@ const pad = (num, paddingLen = 8) => {
|
|
|
13
13
|
* Copyright (c) 2018 Andrew Kishino
|
|
14
14
|
*/
|
|
15
15
|
// See: https://tezos.gitlab.io/protocols/005_babylon.html#transactions-now-have-an-entrypoint
|
|
16
|
-
const ENTRYPOINT_MAX_LENGTH
|
|
17
|
-
var CODEC
|
|
16
|
+
const ENTRYPOINT_MAX_LENGTH = 31;
|
|
17
|
+
var CODEC;
|
|
18
18
|
(function (CODEC) {
|
|
19
19
|
CODEC["SECRET"] = "secret";
|
|
20
20
|
CODEC["RAW"] = "raw";
|
|
@@ -70,9 +70,9 @@ var CODEC$1;
|
|
|
70
70
|
CODEC["OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE"] = "smart_rollup_execute_outbox_message";
|
|
71
71
|
CODEC["OP_DAL_PUBLISH_COMMITMENT"] = "dal_publish_commitment";
|
|
72
72
|
CODEC["SLOT_HEADER"] = "slot_header";
|
|
73
|
-
})(CODEC
|
|
73
|
+
})(CODEC || (CODEC = {}));
|
|
74
74
|
// See https://tezos.gitlab.io/shell/p2p_api.html#alpha-michelson-v1-primitives-enumeration-unsigned-8-bit-integer
|
|
75
|
-
const opMapping
|
|
75
|
+
const opMapping = {
|
|
76
76
|
'00': 'parameter',
|
|
77
77
|
'01': 'storage',
|
|
78
78
|
'02': 'code',
|
|
@@ -233,15 +233,15 @@ const opMapping$1 = {
|
|
|
233
233
|
'9d': 'Ticket',
|
|
234
234
|
'9e': 'IS_IMPLICIT_ACCOUNT',
|
|
235
235
|
};
|
|
236
|
-
const opMappingReverse
|
|
236
|
+
const opMappingReverse = (() => {
|
|
237
237
|
const result = {};
|
|
238
|
-
Object.keys(opMapping
|
|
239
|
-
result[opMapping
|
|
238
|
+
Object.keys(opMapping).forEach((key) => {
|
|
239
|
+
result[opMapping[key]] = key;
|
|
240
240
|
});
|
|
241
241
|
return result;
|
|
242
242
|
})();
|
|
243
243
|
// See https://tezos.gitlab.io/shell/p2p_api.html
|
|
244
|
-
const kindMapping
|
|
244
|
+
const kindMapping = {
|
|
245
245
|
0x04: 'activate_account',
|
|
246
246
|
0x6b: 'reveal',
|
|
247
247
|
0x6e: 'delegation',
|
|
@@ -265,16 +265,16 @@ const kindMapping$1 = {
|
|
|
265
265
|
0xe6: 'dal_publish_commitment',
|
|
266
266
|
0x11: 'failing_noop',
|
|
267
267
|
};
|
|
268
|
-
const kindMappingReverse
|
|
268
|
+
const kindMappingReverse = (() => {
|
|
269
269
|
const result = {};
|
|
270
|
-
Object.keys(kindMapping
|
|
270
|
+
Object.keys(kindMapping).forEach((key) => {
|
|
271
271
|
const keyNum = typeof key === 'string' ? parseInt(key, 10) : key;
|
|
272
|
-
result[kindMapping
|
|
272
|
+
result[kindMapping[keyNum]] = pad(keyNum, 2);
|
|
273
273
|
});
|
|
274
274
|
return result;
|
|
275
275
|
})();
|
|
276
276
|
// See https://tezos.gitlab.io/protocols/005_babylon.html#transactions-now-have-an-entrypoint
|
|
277
|
-
const entrypointMapping
|
|
277
|
+
const entrypointMapping = {
|
|
278
278
|
'00': 'default',
|
|
279
279
|
'01': 'root',
|
|
280
280
|
'02': 'do',
|
|
@@ -286,10 +286,10 @@ const entrypointMapping$1 = {
|
|
|
286
286
|
'08': 'finalize_unstake',
|
|
287
287
|
'09': 'set_delegate_parameters',
|
|
288
288
|
};
|
|
289
|
-
const entrypointMappingReverse
|
|
289
|
+
const entrypointMappingReverse = (() => {
|
|
290
290
|
const result = {};
|
|
291
|
-
Object.keys(entrypointMapping
|
|
292
|
-
result[entrypointMapping
|
|
291
|
+
Object.keys(entrypointMapping).forEach((key) => {
|
|
292
|
+
result[entrypointMapping[key]] = key;
|
|
293
293
|
});
|
|
294
294
|
return result;
|
|
295
295
|
})();
|
|
@@ -316,1481 +316,176 @@ class OversizedEntryPointError extends ParameterValidationError {
|
|
|
316
316
|
super();
|
|
317
317
|
this.entrypoint = entrypoint;
|
|
318
318
|
this.name = 'OversizedEntryPointError';
|
|
319
|
-
this.message = `Invalid entrypoint length "${entrypoint.length}", maximum length is "${ENTRYPOINT_MAX_LENGTH
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* @category Error
|
|
324
|
-
* @description Error that indicates an invalid ballot value being used
|
|
325
|
-
*/
|
|
326
|
-
class InvalidBallotValueError extends ParameterValidationError {
|
|
327
|
-
constructor(ballotValue) {
|
|
328
|
-
super();
|
|
329
|
-
this.ballotValue = ballotValue;
|
|
330
|
-
this.name = 'InvalidBallotValueError';
|
|
331
|
-
this.message = `Invalid ballot value "${ballotValue}" expecting one of the following: "yay", "nay", "pass".`;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* @category Error
|
|
336
|
-
* @description Error that indicates a failure when trying to decode ballot value
|
|
337
|
-
*/
|
|
338
|
-
class DecodeBallotValueError extends ParameterValidationError {
|
|
339
|
-
constructor(ballotValue) {
|
|
340
|
-
super();
|
|
341
|
-
this.ballotValue = ballotValue;
|
|
342
|
-
this.name = 'DecodeBallotValueError';
|
|
343
|
-
this.message = `Invalid ballot value "${ballotValue}", cannot be decoded.`;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* @category Error
|
|
348
|
-
* @description Error that indicates unexpected Michelson Value being passed or used
|
|
349
|
-
*/
|
|
350
|
-
class UnexpectedMichelsonValueError extends ParameterValidationError {
|
|
351
|
-
constructor(value) {
|
|
352
|
-
super();
|
|
353
|
-
this.value = value;
|
|
354
|
-
this.name = 'UnexpectedMichelsonValueError';
|
|
355
|
-
this.message = `Invalid Michelson value "${value}", unalbe to encode.`;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* @category Error
|
|
360
|
-
* @description Error that indicates a failure when trying to decode an operation
|
|
361
|
-
*/
|
|
362
|
-
class OperationDecodingError extends ParameterValidationError {
|
|
363
|
-
constructor(message) {
|
|
364
|
-
super();
|
|
365
|
-
this.message = message;
|
|
366
|
-
this.name = 'OperationDecodingError';
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* @category Error
|
|
371
|
-
* @description Error that indicates a failure when trying to encode an operation
|
|
372
|
-
*/
|
|
373
|
-
class OperationEncodingError extends ParameterValidationError {
|
|
374
|
-
constructor(message) {
|
|
375
|
-
super();
|
|
376
|
-
this.message = message;
|
|
377
|
-
this.name = 'OperationEncodingError';
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* @category Error
|
|
382
|
-
* @description Error that indicates an unsupported operation being passed or used
|
|
383
|
-
*/
|
|
384
|
-
class UnsupportedOperationError extends ParameterValidationError {
|
|
385
|
-
constructor(op) {
|
|
386
|
-
super();
|
|
387
|
-
this.op = op;
|
|
388
|
-
this.name = 'UnsupportedOperationError';
|
|
389
|
-
this.message = `Unsupported operation "${op}", can submit an issue on our github for feature request.`;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* @cateogry Error
|
|
394
|
-
* @description Error that indicates an unsupported pvm being passed or used
|
|
395
|
-
*/
|
|
396
|
-
class UnsupportedPvmKindError extends ParameterValidationError {
|
|
397
|
-
constructor(pvm) {
|
|
398
|
-
super();
|
|
399
|
-
this.pvm = pvm;
|
|
400
|
-
this.name = 'UnsupportedPvmKindError';
|
|
401
|
-
this.message = `Invalid Pvm kind "${pvm}" expecting either "arith" or "wasm_2_0_0".`;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* @category Error
|
|
406
|
-
* @description Error that indicates an unsupported pvm to decode
|
|
407
|
-
*/
|
|
408
|
-
class DecodePvmKindError extends ParameterValidationError {
|
|
409
|
-
constructor(pvm) {
|
|
410
|
-
super();
|
|
411
|
-
this.pvm = pvm;
|
|
412
|
-
this.name = 'DecodePvmKindError';
|
|
413
|
-
this.message = `Invalid Pvm kind "${pvm}", cannot be decoded.`;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* @category Error
|
|
418
|
-
* @description Error that indicates an invalid Smart Rollup Address (sr1)
|
|
419
|
-
*/
|
|
420
|
-
class InvalidSmartRollupAddressError extends ParameterValidationError {
|
|
421
|
-
constructor(address, errorDetail) {
|
|
422
|
-
super();
|
|
423
|
-
this.address = address;
|
|
424
|
-
this.errorDetail = errorDetail;
|
|
425
|
-
this.name = 'InvalidSmartRollupAddress';
|
|
426
|
-
this.message = `Invalid smart rollup address "${address}"`;
|
|
427
|
-
errorDetail ? (this.message += ` ${errorDetail}.`) : '';
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* @category Error
|
|
432
|
-
* @description Error that indicates an invalid Smart Rollup commitment hash (src1)
|
|
433
|
-
*/
|
|
434
|
-
class InvalidSmartRollupCommitmentHashError extends ParameterValidationError {
|
|
435
|
-
constructor(hash, errorDetail) {
|
|
436
|
-
super();
|
|
437
|
-
this.hash = hash;
|
|
438
|
-
this.errorDetail = errorDetail;
|
|
439
|
-
this.name = 'InvalidSmartRollupCommitmentHashError';
|
|
440
|
-
this.message = `Invalid smart rollup commitment hash "${hash}"`;
|
|
441
|
-
errorDetail ? (this.message += ` ${errorDetail}.`) : '';
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* @category Error
|
|
446
|
-
* @description Error that indicates an invalid dal commitment (sh)
|
|
447
|
-
*/
|
|
448
|
-
class InvalidDalCommitmentError extends ParameterValidationError {
|
|
449
|
-
constructor(commitment, errorDetail) {
|
|
450
|
-
super();
|
|
451
|
-
this.commitment = commitment;
|
|
452
|
-
this.errorDetail = errorDetail;
|
|
453
|
-
this.name = 'InvalidDalCommitmentError';
|
|
454
|
-
this.message = `Invalid dal commitment "${commitment}"`;
|
|
455
|
-
errorDetail ? (this.message += ` ${errorDetail}.`) : '';
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
class Uint8ArrayConsumer {
|
|
460
|
-
static fromHexString(hex) {
|
|
461
|
-
const lowHex = hex.toLowerCase();
|
|
462
|
-
if (/^(([a-f]|\d){2})*$/.test(lowHex)) {
|
|
463
|
-
const arr = new Uint8Array((lowHex.match(/([a-z]|\d){2}/g) || []).map((byte) => parseInt(byte, 16)));
|
|
464
|
-
return new Uint8ArrayConsumer(arr);
|
|
465
|
-
}
|
|
466
|
-
else {
|
|
467
|
-
throw new InvalidHexStringError(lowHex);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
constructor(arr, offset = 0) {
|
|
471
|
-
this.arr = arr;
|
|
472
|
-
this.offset = offset;
|
|
473
|
-
}
|
|
474
|
-
consume(count) {
|
|
475
|
-
const subArr = this.arr.subarray(this.offset, this.offset + count);
|
|
476
|
-
this.offset += count;
|
|
477
|
-
return subArr;
|
|
478
|
-
}
|
|
479
|
-
get(idx) {
|
|
480
|
-
return this.arr[this.offset + idx];
|
|
481
|
-
}
|
|
482
|
-
length() {
|
|
483
|
-
return this.arr.length - this.offset;
|
|
484
|
-
}
|
|
485
|
-
slice(start, end) {
|
|
486
|
-
return new Uint8ArrayConsumer(this.arr.slice(start, end));
|
|
319
|
+
this.message = `Invalid entrypoint length "${entrypoint.length}", maximum length is "${ENTRYPOINT_MAX_LENGTH}".`;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* @category Error
|
|
324
|
+
* @description Error that indicates an invalid ballot value being used
|
|
325
|
+
*/
|
|
326
|
+
class InvalidBallotValueError extends ParameterValidationError {
|
|
327
|
+
constructor(ballotValue) {
|
|
328
|
+
super();
|
|
329
|
+
this.ballotValue = ballotValue;
|
|
330
|
+
this.name = 'InvalidBallotValueError';
|
|
331
|
+
this.message = `Invalid ballot value "${ballotValue}" expecting one of the following: "yay", "nay", "pass".`;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* @category Error
|
|
336
|
+
* @description Error that indicates a failure when trying to decode ballot value
|
|
337
|
+
*/
|
|
338
|
+
class DecodeBallotValueError extends ParameterValidationError {
|
|
339
|
+
constructor(ballotValue) {
|
|
340
|
+
super();
|
|
341
|
+
this.ballotValue = ballotValue;
|
|
342
|
+
this.name = 'DecodeBallotValueError';
|
|
343
|
+
this.message = `Invalid ballot value "${ballotValue}", cannot be decoded.`;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* @category Error
|
|
348
|
+
* @description Error that indicates unexpected Michelson Value being passed or used
|
|
349
|
+
*/
|
|
350
|
+
class UnexpectedMichelsonValueError extends ParameterValidationError {
|
|
351
|
+
constructor(value) {
|
|
352
|
+
super();
|
|
353
|
+
this.value = value;
|
|
354
|
+
this.name = 'UnexpectedMichelsonValueError';
|
|
355
|
+
this.message = `Invalid Michelson value "${value}", unalbe to encode.`;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* @category Error
|
|
360
|
+
* @description Error that indicates a failure when trying to decode an operation
|
|
361
|
+
*/
|
|
362
|
+
class OperationDecodingError extends ParameterValidationError {
|
|
363
|
+
constructor(message) {
|
|
364
|
+
super();
|
|
365
|
+
this.message = message;
|
|
366
|
+
this.name = 'OperationDecodingError';
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* @category Error
|
|
371
|
+
* @description Error that indicates a failure when trying to encode an operation
|
|
372
|
+
*/
|
|
373
|
+
class OperationEncodingError extends ParameterValidationError {
|
|
374
|
+
constructor(message) {
|
|
375
|
+
super();
|
|
376
|
+
this.message = message;
|
|
377
|
+
this.name = 'OperationEncodingError';
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* @category Error
|
|
382
|
+
* @description Error that indicates an unsupported operation being passed or used
|
|
383
|
+
*/
|
|
384
|
+
class UnsupportedOperationError extends ParameterValidationError {
|
|
385
|
+
constructor(op) {
|
|
386
|
+
super();
|
|
387
|
+
this.op = op;
|
|
388
|
+
this.name = 'UnsupportedOperationError';
|
|
389
|
+
this.message = `Unsupported operation "${op}", can submit an issue on our github for feature request.`;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* @cateogry Error
|
|
394
|
+
* @description Error that indicates an unsupported pvm being passed or used
|
|
395
|
+
*/
|
|
396
|
+
class UnsupportedPvmKindError extends ParameterValidationError {
|
|
397
|
+
constructor(pvm) {
|
|
398
|
+
super();
|
|
399
|
+
this.pvm = pvm;
|
|
400
|
+
this.name = 'UnsupportedPvmKindError';
|
|
401
|
+
this.message = `Invalid Pvm kind "${pvm}" expecting either "arith" or "wasm_2_0_0".`;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* @category Error
|
|
406
|
+
* @description Error that indicates an unsupported pvm to decode
|
|
407
|
+
*/
|
|
408
|
+
class DecodePvmKindError extends ParameterValidationError {
|
|
409
|
+
constructor(pvm) {
|
|
410
|
+
super();
|
|
411
|
+
this.pvm = pvm;
|
|
412
|
+
this.name = 'DecodePvmKindError';
|
|
413
|
+
this.message = `Invalid Pvm kind "${pvm}", cannot be decoded.`;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* @category Error
|
|
418
|
+
* @description Error that indicates an invalid Smart Rollup Address (sr1)
|
|
419
|
+
*/
|
|
420
|
+
class InvalidSmartRollupAddressError extends ParameterValidationError {
|
|
421
|
+
constructor(address, errorDetail) {
|
|
422
|
+
super();
|
|
423
|
+
this.address = address;
|
|
424
|
+
this.errorDetail = errorDetail;
|
|
425
|
+
this.name = 'InvalidSmartRollupAddress';
|
|
426
|
+
this.message = `Invalid smart rollup address "${address}"`;
|
|
427
|
+
errorDetail ? (this.message += ` ${errorDetail}.`) : '';
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* @category Error
|
|
432
|
+
* @description Error that indicates an invalid Smart Rollup commitment hash (src1)
|
|
433
|
+
*/
|
|
434
|
+
class InvalidSmartRollupCommitmentHashError extends ParameterValidationError {
|
|
435
|
+
constructor(hash, errorDetail) {
|
|
436
|
+
super();
|
|
437
|
+
this.hash = hash;
|
|
438
|
+
this.errorDetail = errorDetail;
|
|
439
|
+
this.name = 'InvalidSmartRollupCommitmentHashError';
|
|
440
|
+
this.message = `Invalid smart rollup commitment hash "${hash}"`;
|
|
441
|
+
errorDetail ? (this.message += ` ${errorDetail}.`) : '';
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* @category Error
|
|
446
|
+
* @description Error that indicates an invalid dal commitment (sh)
|
|
447
|
+
*/
|
|
448
|
+
class InvalidDalCommitmentError extends ParameterValidationError {
|
|
449
|
+
constructor(commitment, errorDetail) {
|
|
450
|
+
super();
|
|
451
|
+
this.commitment = commitment;
|
|
452
|
+
this.errorDetail = errorDetail;
|
|
453
|
+
this.name = 'InvalidDalCommitmentError';
|
|
454
|
+
this.message = `Invalid dal commitment "${commitment}"`;
|
|
455
|
+
errorDetail ? (this.message += ` ${errorDetail}.`) : '';
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
class Uint8ArrayConsumer {
|
|
460
|
+
static fromHexString(hex) {
|
|
461
|
+
const lowHex = hex.toLowerCase();
|
|
462
|
+
if (/^(([a-f]|\d){2})*$/.test(lowHex)) {
|
|
463
|
+
const arr = new Uint8Array((lowHex.match(/([a-z]|\d){2}/g) || []).map((byte) => parseInt(byte, 16)));
|
|
464
|
+
return new Uint8ArrayConsumer(arr);
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
throw new InvalidHexStringError(lowHex);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
constructor(arr, offset = 0) {
|
|
471
|
+
this.arr = arr;
|
|
472
|
+
this.offset = offset;
|
|
473
|
+
}
|
|
474
|
+
consume(count) {
|
|
475
|
+
const subArr = this.arr.subarray(this.offset, this.offset + count);
|
|
476
|
+
this.offset += count;
|
|
477
|
+
return subArr;
|
|
478
|
+
}
|
|
479
|
+
get(idx) {
|
|
480
|
+
return this.arr[this.offset + idx];
|
|
481
|
+
}
|
|
482
|
+
length() {
|
|
483
|
+
return this.arr.length - this.offset;
|
|
484
|
+
}
|
|
485
|
+
slice(start, end) {
|
|
486
|
+
return new Uint8ArrayConsumer(this.arr.slice(start, end));
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
|
-
|
|
490
|
-
const isPrim$1 = (value) => {
|
|
491
|
-
return 'prim' in value;
|
|
492
|
-
};
|
|
493
|
-
const isBytes$1 = (value) => {
|
|
494
|
-
return 'bytes' in value && typeof value.bytes === 'string';
|
|
495
|
-
};
|
|
496
|
-
const isString$1 = (value) => {
|
|
497
|
-
return 'string' in value && typeof value.string === 'string';
|
|
498
|
-
};
|
|
499
|
-
const isInt$1 = (value) => {
|
|
500
|
-
return 'int' in value && typeof value.int === 'string';
|
|
501
|
-
};
|
|
502
|
-
const scriptEncoder$1 = (script) => {
|
|
503
|
-
const code = valueEncoder$1(script.code);
|
|
504
|
-
const storage = valueEncoder$1(script.storage);
|
|
505
|
-
return `${pad(code.length / 2, 8)}${code}${pad(storage.length / 2, 8)}${storage}`;
|
|
506
|
-
};
|
|
507
|
-
const scriptDecoder$1 = (value) => {
|
|
508
|
-
const code = extractRequiredLen$1(value);
|
|
509
|
-
const storage = extractRequiredLen$1(value);
|
|
510
|
-
return {
|
|
511
|
-
code: valueDecoder$1(new Uint8ArrayConsumer(code)),
|
|
512
|
-
storage: valueDecoder$1(new Uint8ArrayConsumer(storage)),
|
|
513
|
-
};
|
|
514
|
-
};
|
|
515
|
-
const valueEncoder$1 = (value) => {
|
|
516
|
-
if (Array.isArray(value)) {
|
|
517
|
-
const encoded = value.map((x) => valueEncoder$1(x)).join('');
|
|
518
|
-
const len = encoded.length / 2;
|
|
519
|
-
return `02${pad(len)}${encoded}`;
|
|
520
|
-
}
|
|
521
|
-
else if (isPrim$1(value)) {
|
|
522
|
-
return primEncoder$1(value);
|
|
523
|
-
}
|
|
524
|
-
else if (isBytes$1(value)) {
|
|
525
|
-
return bytesEncoder$1(value);
|
|
526
|
-
}
|
|
527
|
-
else if (isString$1(value)) {
|
|
528
|
-
return stringEncoder$1(value);
|
|
529
|
-
}
|
|
530
|
-
else if (isInt$1(value)) {
|
|
531
|
-
return intEncoder$1(value);
|
|
532
|
-
}
|
|
533
|
-
throw new UnexpectedMichelsonValueError(JSON.stringify(value));
|
|
534
|
-
};
|
|
535
|
-
const valueDecoder$1 = (value) => {
|
|
536
|
-
const preamble = value.consume(1);
|
|
537
|
-
switch (preamble[0]) {
|
|
538
|
-
case 0x0a:
|
|
539
|
-
return bytesDecoder$1(value);
|
|
540
|
-
case 0x01:
|
|
541
|
-
return stringDecoder$1(value);
|
|
542
|
-
case 0x00:
|
|
543
|
-
return intDecoder$1(value);
|
|
544
|
-
case 0x02: {
|
|
545
|
-
const val = new Uint8ArrayConsumer(extractRequiredLen$1(value));
|
|
546
|
-
const results = [];
|
|
547
|
-
while (val.length() > 0) {
|
|
548
|
-
results.push(valueDecoder$1(val));
|
|
549
|
-
}
|
|
550
|
-
return results;
|
|
551
|
-
}
|
|
552
|
-
default:
|
|
553
|
-
return primDecoder$1(value, preamble);
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
const extractRequiredLen$1 = (value, bytesLength = 4) => {
|
|
557
|
-
const len = value.consume(bytesLength);
|
|
558
|
-
const valueLen = parseInt(Buffer.from(len).toString('hex'), 16);
|
|
559
|
-
return value.consume(valueLen);
|
|
560
|
-
};
|
|
561
|
-
/**
|
|
562
|
-
* @description parse bytes into multiple items of an array
|
|
563
|
-
* @param value Uint8ArrayConsumer class of forged segment to parse
|
|
564
|
-
* @param bytesLength default 4 bytes for length of variable bytes
|
|
565
|
-
* @returns array of Uint8Array values for each array item
|
|
566
|
-
*/
|
|
567
|
-
const stripLengthPrefixFromBytes$1 = (value, bytesLength = 4) => {
|
|
568
|
-
const ret = [];
|
|
569
|
-
let values = value;
|
|
570
|
-
while (values.length()) {
|
|
571
|
-
const len = values.consume(bytesLength);
|
|
572
|
-
const valueLen = parseInt(Buffer.from(len).toString('hex'), 16);
|
|
573
|
-
ret.push(values.consume(valueLen));
|
|
574
|
-
values = values.slice(valueLen + bytesLength);
|
|
575
|
-
}
|
|
576
|
-
return ret;
|
|
577
|
-
};
|
|
578
|
-
const bytesEncoder$1 = (value) => {
|
|
579
|
-
if (!/^([A-Fa-f0-9]{2})*$/.test(value.bytes)) {
|
|
580
|
-
throw new InvalidHexStringError(value.bytes);
|
|
581
|
-
}
|
|
582
|
-
const len = value.bytes.length / 2;
|
|
583
|
-
return `0a${pad(len)}${value.bytes}`;
|
|
584
|
-
};
|
|
585
|
-
const bytesDecoder$1 = (value) => {
|
|
586
|
-
const bytes = extractRequiredLen$1(value);
|
|
587
|
-
return {
|
|
588
|
-
bytes: Buffer.from(bytes).toString('hex'),
|
|
589
|
-
};
|
|
590
|
-
};
|
|
591
|
-
const stringEncoder$1 = (value) => {
|
|
592
|
-
const str = Buffer.from(value.string, 'utf8').toString('hex');
|
|
593
|
-
const hexLength = str.length / 2;
|
|
594
|
-
return `01${pad(hexLength)}${str}`;
|
|
595
|
-
};
|
|
596
|
-
const stringDecoder$1 = (value) => {
|
|
597
|
-
const str = extractRequiredLen$1(value);
|
|
598
|
-
return {
|
|
599
|
-
string: Buffer.from(str).toString('utf8'),
|
|
600
|
-
};
|
|
601
|
-
};
|
|
602
|
-
const intEncoder$1 = ({ int }) => {
|
|
603
|
-
const num = new BigNumber(int, 10);
|
|
604
|
-
const positiveMark = num.toString(2)[0] === '-' ? '1' : '0';
|
|
605
|
-
const binary = num.toString(2).replace(/-/g, '');
|
|
606
|
-
const pad = binary.length <= 6
|
|
607
|
-
? 6
|
|
608
|
-
: (binary.length - 6) % 7
|
|
609
|
-
? binary.length + 7 - ((binary.length - 6) % 7)
|
|
610
|
-
: binary.length;
|
|
611
|
-
const splitted = binary.padStart(pad, '0').match(/\d{6,7}/g);
|
|
612
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
613
|
-
const reversed = splitted.reverse();
|
|
614
|
-
reversed[0] = positiveMark + reversed[0];
|
|
615
|
-
const numHex = reversed.map((x, i) =>
|
|
616
|
-
// Add one to the last chunk
|
|
617
|
-
parseInt((i === reversed.length - 1 ? '0' : '1') + x, 2)
|
|
618
|
-
.toString(16)
|
|
619
|
-
.padStart(2, '0'));
|
|
620
|
-
return `00${numHex.join('')}`;
|
|
621
|
-
};
|
|
622
|
-
const intDecoder$1 = (value) => {
|
|
623
|
-
let c = value.consume(1)[0];
|
|
624
|
-
const hexNumber = [];
|
|
625
|
-
const isNotLastChunkMask = 1 << 7;
|
|
626
|
-
while (c & isNotLastChunkMask) {
|
|
627
|
-
hexNumber.push(c);
|
|
628
|
-
c = value.consume(1)[0];
|
|
629
|
-
}
|
|
630
|
-
hexNumber.push(c);
|
|
631
|
-
const isNegative = !!((1 << 6) & hexNumber[0]);
|
|
632
|
-
hexNumber[0] = hexNumber[0] & 0b1111111;
|
|
633
|
-
const numBin = hexNumber
|
|
634
|
-
.map((x, i) => x
|
|
635
|
-
.toString(2)
|
|
636
|
-
.slice(i === 0 ? -6 : -7)
|
|
637
|
-
.padStart(i === 0 ? 6 : 7, '0'))
|
|
638
|
-
.reverse();
|
|
639
|
-
let num = new BigNumber(numBin.join(''), 2);
|
|
640
|
-
if (isNegative) {
|
|
641
|
-
num = num.times(-1);
|
|
642
|
-
}
|
|
643
|
-
return {
|
|
644
|
-
int: num.toFixed(),
|
|
645
|
-
};
|
|
646
|
-
};
|
|
647
|
-
const primEncoder$1 = (value) => {
|
|
648
|
-
const hasAnnot = +Array.isArray(value.annots);
|
|
649
|
-
const argsCount = Array.isArray(value.args) ? value.args.length : 0;
|
|
650
|
-
// Specify the number of args max is 3 without annotation
|
|
651
|
-
const preamble = pad(Math.min(2 * argsCount + hasAnnot + 0x03, 9), 2);
|
|
652
|
-
const op = opMappingReverse$1[value.prim];
|
|
653
|
-
let encodedArgs = (value.args || []).map((arg) => valueEncoder$1(arg)).join('');
|
|
654
|
-
const encodedAnnots = Array.isArray(value.annots) ? encodeAnnots$1(value.annots) : '';
|
|
655
|
-
if ((value.prim === 'LAMBDA' || value.prim === 'LAMBDA_REC') && argsCount) {
|
|
656
|
-
encodedArgs = pad(encodedArgs.length / 2) + encodedArgs + pad(0);
|
|
657
|
-
}
|
|
658
|
-
if ((value.prim === 'pair' || value.prim === 'Pair') && argsCount > 2) {
|
|
659
|
-
encodedArgs =
|
|
660
|
-
encodedAnnots === ''
|
|
661
|
-
? pad(encodedArgs.length / 2) + encodedArgs + pad(0)
|
|
662
|
-
: pad(encodedArgs.length / 2) + encodedArgs;
|
|
663
|
-
}
|
|
664
|
-
if (value.prim === 'view' && value.args) {
|
|
665
|
-
encodedArgs = pad(encodedArgs.length / 2) + encodedArgs + pad(0);
|
|
666
|
-
}
|
|
667
|
-
return `${preamble}${op}${encodedArgs}${encodedAnnots}`;
|
|
668
|
-
};
|
|
669
|
-
const primDecoder$1 = (value, preamble) => {
|
|
670
|
-
const hasAnnot = (preamble[0] - 0x03) % 2 === 1;
|
|
671
|
-
let argsCount = Math.floor((preamble[0] - 0x03) / 2);
|
|
672
|
-
const op = value.consume(1)[0].toString(16).padStart(2, '0');
|
|
673
|
-
const result = {
|
|
674
|
-
prim: opMapping$1[op],
|
|
675
|
-
};
|
|
676
|
-
if (opMapping$1[op] === 'LAMBDA' || opMapping$1[op] === 'LAMBDA_REC') {
|
|
677
|
-
value.consume(4);
|
|
678
|
-
}
|
|
679
|
-
if (opMapping$1[op] === 'view') {
|
|
680
|
-
if (argsCount != 0) {
|
|
681
|
-
return primViewDecoder$1(value, result);
|
|
682
|
-
}
|
|
683
|
-
else {
|
|
684
|
-
return result;
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
let combPairArgs;
|
|
688
|
-
let combPairAnnots;
|
|
689
|
-
if ((opMapping$1[op] === 'pair' || opMapping$1[op] === 'Pair') && argsCount > 2) {
|
|
690
|
-
combPairArgs = decodeCombPair$1(value);
|
|
691
|
-
argsCount = 0;
|
|
692
|
-
combPairAnnots = decodeAnnots$1(value);
|
|
693
|
-
}
|
|
694
|
-
const args = new Array(argsCount).fill(0).map(() => valueDecoder$1(value));
|
|
695
|
-
if (opMapping$1[op] === 'LAMBDA' || opMapping$1[op] === 'LAMBDA_REC') {
|
|
696
|
-
value.consume(4);
|
|
697
|
-
}
|
|
698
|
-
if (combPairArgs) {
|
|
699
|
-
result['args'] = combPairArgs;
|
|
700
|
-
}
|
|
701
|
-
else if (args.length) {
|
|
702
|
-
result['args'] = args;
|
|
703
|
-
}
|
|
704
|
-
if (combPairAnnots && combPairAnnots[0] !== '') {
|
|
705
|
-
result['annots'] = combPairAnnots;
|
|
706
|
-
}
|
|
707
|
-
else if (hasAnnot) {
|
|
708
|
-
result['annots'] = decodeAnnots$1(value);
|
|
709
|
-
}
|
|
710
|
-
return result;
|
|
711
|
-
};
|
|
712
|
-
const primViewDecoder$1 = (value, result) => {
|
|
713
|
-
value.consume(4);
|
|
714
|
-
result['args'] = new Array(4).fill(0).map(() => valueDecoder$1(value));
|
|
715
|
-
value.consume(4);
|
|
716
|
-
return result;
|
|
717
|
-
};
|
|
718
|
-
const decodeCombPair$1 = (val) => {
|
|
719
|
-
const array = new Uint8ArrayConsumer(extractRequiredLen$1(val));
|
|
720
|
-
const args = [];
|
|
721
|
-
while (array.length() > 0) {
|
|
722
|
-
args.push(valueDecoder$1(array));
|
|
723
|
-
}
|
|
724
|
-
return args;
|
|
725
|
-
};
|
|
726
|
-
const encodeAnnots$1 = (value) => {
|
|
727
|
-
const mergedAnnot = value
|
|
728
|
-
.map((x) => {
|
|
729
|
-
return Buffer.from(x, 'utf8').toString('hex');
|
|
730
|
-
})
|
|
731
|
-
.join('20');
|
|
732
|
-
const len = mergedAnnot.length / 2;
|
|
733
|
-
return `${pad(len)}${mergedAnnot}`;
|
|
734
|
-
};
|
|
735
|
-
const decodeAnnots$1 = (val) => {
|
|
736
|
-
const len = val.consume(4);
|
|
737
|
-
const annotLen = parseInt(Buffer.from(len).toString('hex'), 16);
|
|
738
|
-
const restOfAnnot = val.consume(annotLen);
|
|
739
|
-
const restOfAnnotHex = Buffer.from(restOfAnnot).toString('hex');
|
|
740
|
-
return restOfAnnotHex.split('20').map((x) => Buffer.from(x, 'hex').toString('utf8'));
|
|
741
|
-
};
|
|
742
|
-
|
|
743
|
-
// https://tezos.gitlab.io/shell/p2p_api.html specifies data types and structure for forging
|
|
744
|
-
const prefixEncoder$1 = (prefix) => (str) => {
|
|
745
|
-
const [pl] = b58DecodeAndCheckPrefix(str, [prefix]);
|
|
746
|
-
return buf2hex(pl);
|
|
747
|
-
};
|
|
748
|
-
const prefixDecoder$1 = (pre) => (str) => {
|
|
749
|
-
const val = str.consume(payloadLength[pre]);
|
|
750
|
-
return b58Encode(val, pre);
|
|
751
|
-
};
|
|
752
|
-
const tz1Decoder$1 = prefixDecoder$1(PrefixV2.Ed25519PublicKeyHash);
|
|
753
|
-
const branchDecoder$1 = prefixDecoder$1(PrefixV2.BlockHash);
|
|
754
|
-
const publicKeyHashDecoder$1 = (val) => {
|
|
755
|
-
const prefix = val.consume(1);
|
|
756
|
-
if (prefix[0] === 0x00) {
|
|
757
|
-
return prefixDecoder$1(PrefixV2.Ed25519PublicKeyHash)(val);
|
|
758
|
-
}
|
|
759
|
-
else if (prefix[0] === 0x01) {
|
|
760
|
-
return prefixDecoder$1(PrefixV2.Secp256k1PublicKeyHash)(val);
|
|
761
|
-
}
|
|
762
|
-
else if (prefix[0] === 0x02) {
|
|
763
|
-
return prefixDecoder$1(PrefixV2.P256PublicKeyHash)(val);
|
|
764
|
-
}
|
|
765
|
-
else if (prefix[0] === 0x03) {
|
|
766
|
-
return prefixDecoder$1(PrefixV2.BLS12_381PublicKeyHash)(val);
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
const publicKeyHashesDecoder$1 = (val) => {
|
|
770
|
-
if (!boolDecoder$1(val)) {
|
|
771
|
-
return;
|
|
772
|
-
}
|
|
773
|
-
const publicKeyHashes = [];
|
|
774
|
-
val.consume(4);
|
|
775
|
-
while (val.length() > 0) {
|
|
776
|
-
publicKeyHashes.push(publicKeyHashDecoder$1(val));
|
|
777
|
-
}
|
|
778
|
-
return publicKeyHashes;
|
|
779
|
-
};
|
|
780
|
-
const branchEncoder$1 = prefixEncoder$1(PrefixV2.BlockHash);
|
|
781
|
-
const tz1Encoder$1 = prefixEncoder$1(PrefixV2.Ed25519PublicKeyHash);
|
|
782
|
-
const boolEncoder$1 = (bool) => (bool ? 'ff' : '00');
|
|
783
|
-
const proposalEncoder$1 = (proposal) => {
|
|
784
|
-
return prefixEncoder$1(PrefixV2.ProtocolHash)(proposal);
|
|
785
|
-
};
|
|
786
|
-
const proposalDecoder$1 = (proposal) => {
|
|
787
|
-
return prefixDecoder$1(PrefixV2.ProtocolHash)(proposal);
|
|
788
|
-
};
|
|
789
|
-
const proposalsDecoder$1 = (proposal) => {
|
|
790
|
-
const proposals = [];
|
|
791
|
-
proposal.consume(4);
|
|
792
|
-
while (proposal.length() > 0) {
|
|
793
|
-
proposals.push(proposalDecoder$1(proposal));
|
|
794
|
-
}
|
|
795
|
-
return proposals;
|
|
796
|
-
};
|
|
797
|
-
const proposalsEncoder$1 = (proposals) => {
|
|
798
|
-
return pad(32 * proposals.length) + proposals.map((x) => proposalEncoder$1(x)).join('');
|
|
799
|
-
};
|
|
800
|
-
const ballotEncoder$1 = (ballot) => {
|
|
801
|
-
switch (ballot) {
|
|
802
|
-
case 'yay':
|
|
803
|
-
return '00';
|
|
804
|
-
case 'nay':
|
|
805
|
-
return '01';
|
|
806
|
-
case 'pass':
|
|
807
|
-
return '02';
|
|
808
|
-
default:
|
|
809
|
-
throw new InvalidBallotValueError(ballot);
|
|
810
|
-
}
|
|
811
|
-
};
|
|
812
|
-
const ballotDecoder$1 = (ballot) => {
|
|
813
|
-
const value = ballot.consume(1);
|
|
814
|
-
switch (value[0]) {
|
|
815
|
-
case 0x00:
|
|
816
|
-
return 'yay';
|
|
817
|
-
case 0x01:
|
|
818
|
-
return 'nay';
|
|
819
|
-
case 0x02:
|
|
820
|
-
return 'pass';
|
|
821
|
-
default:
|
|
822
|
-
throw new DecodeBallotValueError(value[0].toString());
|
|
823
|
-
}
|
|
824
|
-
};
|
|
825
|
-
const pvmKindEncoder$1 = (pvm) => {
|
|
826
|
-
switch (pvm) {
|
|
827
|
-
case 'arith':
|
|
828
|
-
return '00';
|
|
829
|
-
case 'wasm_2_0_0':
|
|
830
|
-
return '01';
|
|
831
|
-
case 'riscv':
|
|
832
|
-
return '02';
|
|
833
|
-
default:
|
|
834
|
-
throw new UnsupportedPvmKindError(pvm);
|
|
835
|
-
}
|
|
836
|
-
};
|
|
837
|
-
const pvmKindDecoder$1 = (pvm) => {
|
|
838
|
-
const value = pvm.consume(1);
|
|
839
|
-
switch (value[0]) {
|
|
840
|
-
case 0x00:
|
|
841
|
-
return 'arith';
|
|
842
|
-
case 0x01:
|
|
843
|
-
return 'wasm_2_0_0';
|
|
844
|
-
case 0x02:
|
|
845
|
-
return 'riscv';
|
|
846
|
-
default:
|
|
847
|
-
throw new DecodePvmKindError(value[0].toString());
|
|
848
|
-
}
|
|
849
|
-
};
|
|
850
|
-
const delegateEncoder$1 = (val) => {
|
|
851
|
-
if (val) {
|
|
852
|
-
return boolEncoder$1(true) + publicKeyHashEncoder$1(val);
|
|
853
|
-
}
|
|
854
|
-
else {
|
|
855
|
-
return boolEncoder$1(false);
|
|
856
|
-
}
|
|
857
|
-
};
|
|
858
|
-
const int32Encoder$1 = (val) => {
|
|
859
|
-
const num = parseInt(String(val), 10);
|
|
860
|
-
const byte = [];
|
|
861
|
-
for (let i = 0; i < 4; i++) {
|
|
862
|
-
const shiftBy = (4 - (i + 1)) * 8;
|
|
863
|
-
byte.push((num & (0xff << shiftBy)) >> shiftBy);
|
|
864
|
-
}
|
|
865
|
-
return Buffer.from(byte).toString('hex');
|
|
866
|
-
};
|
|
867
|
-
const int32Decoder$1 = (val) => {
|
|
868
|
-
const num = val.consume(4);
|
|
869
|
-
let finalNum = 0;
|
|
870
|
-
for (let i = 0; i < num.length; i++) {
|
|
871
|
-
finalNum = finalNum | (num[i] << ((num.length - (i + 1)) * 8));
|
|
872
|
-
}
|
|
873
|
-
return finalNum;
|
|
874
|
-
};
|
|
875
|
-
const int16Encoder$1 = (val) => {
|
|
876
|
-
const num = parseInt(String(val), 10);
|
|
877
|
-
const byte = [];
|
|
878
|
-
for (let i = 0; i < 2; i++) {
|
|
879
|
-
const shiftBy = (2 - (i + 1)) * 8;
|
|
880
|
-
byte.push((num & (0xff << shiftBy)) >> shiftBy);
|
|
881
|
-
}
|
|
882
|
-
return Buffer.from(byte).toString('hex');
|
|
883
|
-
};
|
|
884
|
-
const int16Decoder$1 = (val) => {
|
|
885
|
-
const num = val.consume(2);
|
|
886
|
-
let finalNum = 0;
|
|
887
|
-
for (let i = 0; i < num.length; i++) {
|
|
888
|
-
finalNum = finalNum | (num[i] << ((num.length - (i + 1)) * 8));
|
|
889
|
-
}
|
|
890
|
-
return finalNum;
|
|
891
|
-
};
|
|
892
|
-
const boolDecoder$1 = (val) => {
|
|
893
|
-
const bool = val.consume(1);
|
|
894
|
-
return bool[0] === 0xff;
|
|
895
|
-
};
|
|
896
|
-
const delegateDecoder$1 = (val) => {
|
|
897
|
-
const hasDelegate = boolDecoder$1(val);
|
|
898
|
-
if (hasDelegate) {
|
|
899
|
-
return publicKeyHashDecoder$1(val);
|
|
900
|
-
}
|
|
901
|
-
};
|
|
902
|
-
const publicKeyHashEncoder$1 = (val) => {
|
|
903
|
-
try {
|
|
904
|
-
return b58DecodePublicKeyHash(val);
|
|
905
|
-
}
|
|
906
|
-
catch (err) {
|
|
907
|
-
throw new InvalidKeyHashError(val, err instanceof ParameterValidationError ? err.result : undefined);
|
|
908
|
-
}
|
|
909
|
-
};
|
|
910
|
-
const publicKeyHashesEncoder$1 = (val) => {
|
|
911
|
-
if (!val) {
|
|
912
|
-
return boolEncoder$1(false);
|
|
913
|
-
}
|
|
914
|
-
if (val.length === 0) {
|
|
915
|
-
return boolEncoder$1(true) + pad(0);
|
|
916
|
-
}
|
|
917
|
-
const publicKeyHashes = val.reduce((prev, curr) => {
|
|
918
|
-
return prev + publicKeyHashEncoder$1(curr);
|
|
919
|
-
}, '');
|
|
920
|
-
return boolEncoder$1(true) + pad(publicKeyHashes.length / 2) + publicKeyHashes;
|
|
921
|
-
};
|
|
922
|
-
const publicKeyEncoder$1 = (val) => {
|
|
923
|
-
try {
|
|
924
|
-
return b58DecodePublicKey(val);
|
|
925
|
-
}
|
|
926
|
-
catch (err) {
|
|
927
|
-
throw new InvalidPublicKeyError(val, err instanceof ParameterValidationError ? err.result : undefined);
|
|
928
|
-
}
|
|
929
|
-
};
|
|
930
|
-
const addressEncoder$1 = (val) => {
|
|
931
|
-
return b58DecodeAddress(val);
|
|
932
|
-
};
|
|
933
|
-
const smartRollupAddressEncoder$1 = (val) => {
|
|
934
|
-
try {
|
|
935
|
-
return prefixEncoder$1(PrefixV2.SmartRollupHash)(val);
|
|
936
|
-
}
|
|
937
|
-
catch (err) {
|
|
938
|
-
if (err instanceof ParameterValidationError) {
|
|
939
|
-
throw new InvalidSmartRollupAddressError(val);
|
|
940
|
-
}
|
|
941
|
-
else {
|
|
942
|
-
throw err;
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
};
|
|
946
|
-
const smartContractAddressEncoder$1 = (val) => b58DecodeAddress(val);
|
|
947
|
-
const publicKeyDecoder$1 = (val) => {
|
|
948
|
-
const preamble = val.consume(1);
|
|
949
|
-
switch (preamble[0]) {
|
|
950
|
-
case 0x00:
|
|
951
|
-
return prefixDecoder$1(PrefixV2.Ed25519PublicKey)(val);
|
|
952
|
-
case 0x01:
|
|
953
|
-
return prefixDecoder$1(PrefixV2.Secp256k1PublicKey)(val);
|
|
954
|
-
case 0x02:
|
|
955
|
-
return prefixDecoder$1(PrefixV2.P256PublicKey)(val);
|
|
956
|
-
case 0x03:
|
|
957
|
-
return prefixDecoder$1(PrefixV2.BLS12_381PublicKey)(val);
|
|
958
|
-
default:
|
|
959
|
-
throw new InvalidPublicKeyError(undefined, ValidationResult.NO_PREFIX_MATCHED);
|
|
960
|
-
}
|
|
961
|
-
};
|
|
962
|
-
const smartRollupCommitmentHashEncoder$1 = (val) => {
|
|
963
|
-
try {
|
|
964
|
-
return prefixEncoder$1(PrefixV2.SmartRollupCommitmentHash)(val);
|
|
965
|
-
}
|
|
966
|
-
catch (err) {
|
|
967
|
-
if (err instanceof ParameterValidationError) {
|
|
968
|
-
throw new InvalidSmartRollupCommitmentHashError(val);
|
|
969
|
-
}
|
|
970
|
-
else {
|
|
971
|
-
throw err;
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
};
|
|
975
|
-
const addressDecoder$1 = (val) => {
|
|
976
|
-
const preamble = val.consume(1);
|
|
977
|
-
switch (preamble[0]) {
|
|
978
|
-
case 0x00:
|
|
979
|
-
return publicKeyHashDecoder$1(val);
|
|
980
|
-
case 0x01: {
|
|
981
|
-
const address = prefixDecoder$1(PrefixV2.ContractHash)(val);
|
|
982
|
-
val.consume(1);
|
|
983
|
-
return address;
|
|
984
|
-
}
|
|
985
|
-
default:
|
|
986
|
-
throw new InvalidAddressError(val.toString(), ': Unable to decode.');
|
|
987
|
-
}
|
|
988
|
-
};
|
|
989
|
-
const smartRollupAddressDecoder$1 = (val) => {
|
|
990
|
-
return prefixDecoder$1(PrefixV2.SmartRollupHash)(val);
|
|
991
|
-
};
|
|
992
|
-
const smartContractAddressDecoder$1 = (val) => {
|
|
993
|
-
const preamble = val.consume(1);
|
|
994
|
-
if (preamble[0] === 0x01) {
|
|
995
|
-
const scAddress = prefixDecoder$1(PrefixV2.ContractHash)(val);
|
|
996
|
-
val.consume(1);
|
|
997
|
-
return scAddress;
|
|
998
|
-
}
|
|
999
|
-
throw new InvalidContractAddressError(val.toString(), ValidationResult.NO_PREFIX_MATCHED);
|
|
1000
|
-
};
|
|
1001
|
-
const smartRollupCommitmentHashDecoder$1 = (val) => {
|
|
1002
|
-
return prefixDecoder$1(PrefixV2.SmartRollupCommitmentHash)(val);
|
|
1003
|
-
};
|
|
1004
|
-
const zarithEncoder$1 = (n) => {
|
|
1005
|
-
const fn = [];
|
|
1006
|
-
let nn = new BigNumber$1(n, 10);
|
|
1007
|
-
if (nn.isNaN()) {
|
|
1008
|
-
throw new TypeError(`Invalid zarith number ${n}`);
|
|
1009
|
-
}
|
|
1010
|
-
// eslint-disable-next-line no-constant-condition
|
|
1011
|
-
while (true) {
|
|
1012
|
-
if (nn.lt(128)) {
|
|
1013
|
-
if (nn.lt(16))
|
|
1014
|
-
fn.push('0');
|
|
1015
|
-
fn.push(nn.toString(16));
|
|
1016
|
-
break;
|
|
1017
|
-
}
|
|
1018
|
-
else {
|
|
1019
|
-
let b = nn.mod(128);
|
|
1020
|
-
nn = nn.minus(b);
|
|
1021
|
-
nn = nn.dividedBy(128);
|
|
1022
|
-
b = b.plus(128);
|
|
1023
|
-
fn.push(b.toString(16));
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
return fn.join('');
|
|
1027
|
-
};
|
|
1028
|
-
const zarithDecoder$1 = (n) => {
|
|
1029
|
-
let mostSignificantByte = 0;
|
|
1030
|
-
while (mostSignificantByte < n.length() && (n.get(mostSignificantByte) & 128) !== 0) {
|
|
1031
|
-
mostSignificantByte += 1;
|
|
1032
|
-
}
|
|
1033
|
-
let num = new BigNumber$1(0);
|
|
1034
|
-
for (let i = mostSignificantByte; i >= 0; i -= 1) {
|
|
1035
|
-
const tmp = n.get(i) & 0x7f;
|
|
1036
|
-
num = num.multipliedBy(128);
|
|
1037
|
-
num = num.plus(tmp);
|
|
1038
|
-
}
|
|
1039
|
-
n.consume(mostSignificantByte + 1);
|
|
1040
|
-
return new BigNumber$1(num).toString();
|
|
1041
|
-
};
|
|
1042
|
-
const entrypointDecoder$1 = (value) => {
|
|
1043
|
-
const preamble = pad(value.consume(1)[0], 2);
|
|
1044
|
-
if (preamble in entrypointMapping$1) {
|
|
1045
|
-
return entrypointMapping$1[preamble];
|
|
1046
|
-
}
|
|
1047
|
-
else {
|
|
1048
|
-
const entry = extractRequiredLen$1(value, 1);
|
|
1049
|
-
const entrypoint = Buffer.from(entry).toString('utf8');
|
|
1050
|
-
if (entrypoint.length > ENTRYPOINT_MAX_LENGTH$1) {
|
|
1051
|
-
throw new OversizedEntryPointError(entrypoint);
|
|
1052
|
-
}
|
|
1053
|
-
return entrypoint;
|
|
1054
|
-
}
|
|
1055
|
-
};
|
|
1056
|
-
const parametersDecoder$1 = (val) => {
|
|
1057
|
-
const preamble = val.consume(1);
|
|
1058
|
-
if (preamble[0] === 0x00) {
|
|
1059
|
-
return;
|
|
1060
|
-
}
|
|
1061
|
-
else {
|
|
1062
|
-
const encodedEntrypoint = entrypointDecoder$1(val);
|
|
1063
|
-
const params = extractRequiredLen$1(val);
|
|
1064
|
-
const parameters = valueDecoder$1(new Uint8ArrayConsumer(params));
|
|
1065
|
-
return {
|
|
1066
|
-
entrypoint: encodedEntrypoint,
|
|
1067
|
-
value: parameters,
|
|
1068
|
-
};
|
|
1069
|
-
}
|
|
1070
|
-
};
|
|
1071
|
-
const entrypointEncoder$1 = (entrypoint) => {
|
|
1072
|
-
if (entrypoint in entrypointMappingReverse$1) {
|
|
1073
|
-
return `${entrypointMappingReverse$1[entrypoint]}`;
|
|
1074
|
-
}
|
|
1075
|
-
else {
|
|
1076
|
-
if (entrypoint.length > ENTRYPOINT_MAX_LENGTH$1) {
|
|
1077
|
-
throw new OversizedEntryPointError(entrypoint);
|
|
1078
|
-
}
|
|
1079
|
-
const value = { string: entrypoint };
|
|
1080
|
-
return `ff${valueEncoder$1(value).slice(8)}`;
|
|
1081
|
-
}
|
|
1082
|
-
};
|
|
1083
|
-
const parametersEncoder$1 = (val) => {
|
|
1084
|
-
if (!val || (val.entrypoint === 'default' && 'prim' in val.value && val.value.prim === 'Unit')) {
|
|
1085
|
-
return '00';
|
|
1086
|
-
}
|
|
1087
|
-
const encodedEntrypoint = entrypointEncoder$1(val.entrypoint);
|
|
1088
|
-
const parameters = valueEncoder$1(val.value);
|
|
1089
|
-
const length = pad(parameters.length / 2);
|
|
1090
|
-
return `ff${encodedEntrypoint}${length}${parameters}`;
|
|
1091
|
-
};
|
|
1092
|
-
const valueParameterEncoder$1 = (value) => {
|
|
1093
|
-
const valueEncoded = valueEncoder$1(value);
|
|
1094
|
-
return `${pad(valueEncoded.length / 2)}${valueEncoded}`;
|
|
1095
|
-
};
|
|
1096
|
-
const valueParameterDecoder$1 = (val) => {
|
|
1097
|
-
const value = extractRequiredLen$1(val);
|
|
1098
|
-
return valueDecoder$1(new Uint8ArrayConsumer(value));
|
|
1099
|
-
};
|
|
1100
|
-
const blockPayloadHashEncoder$1 = prefixEncoder$1(PrefixV2.ValueHash);
|
|
1101
|
-
const blockPayloadHashDecoder$1 = prefixDecoder$1(PrefixV2.ValueHash);
|
|
1102
|
-
const entrypointNameEncoder$1 = (entrypoint) => {
|
|
1103
|
-
const value = { string: entrypoint };
|
|
1104
|
-
return `${valueEncoder$1(value).slice(2)}`;
|
|
1105
|
-
};
|
|
1106
|
-
const entrypointNameDecoder$1 = (val) => {
|
|
1107
|
-
const entry = extractRequiredLen$1(val);
|
|
1108
|
-
return Buffer.from(entry).toString('utf8');
|
|
1109
|
-
};
|
|
1110
|
-
const burnLimitEncoder$1 = (val) => {
|
|
1111
|
-
return !val ? '00' : `ff${zarithEncoder$1(val)}`;
|
|
1112
|
-
};
|
|
1113
|
-
const burnLimitDecoder$1 = (value) => {
|
|
1114
|
-
const prefix = value.consume(1);
|
|
1115
|
-
if (Buffer.from(prefix).toString('hex') !== '00') {
|
|
1116
|
-
return zarithDecoder$1(value);
|
|
1117
|
-
}
|
|
1118
|
-
};
|
|
1119
|
-
const depositsLimitEncoder$1 = (val) => {
|
|
1120
|
-
return !val ? '00' : `ff${zarithEncoder$1(val)}`;
|
|
1121
|
-
};
|
|
1122
|
-
const depositsLimitDecoder$1 = (value) => {
|
|
1123
|
-
const prefix = value.consume(1);
|
|
1124
|
-
if (Buffer.from(prefix).toString('hex') !== '00') {
|
|
1125
|
-
return zarithDecoder$1(value);
|
|
1126
|
-
}
|
|
1127
|
-
};
|
|
1128
|
-
const signatureV1Encoder$1 = (val) => {
|
|
1129
|
-
try {
|
|
1130
|
-
const [data, pre] = b58DecodeAndCheckPrefix(val, signaturePrefixes);
|
|
1131
|
-
if (pre === PrefixV2.BLS12_381Signature) {
|
|
1132
|
-
return paddedBytesEncoder$1(buf2hex(data));
|
|
1133
|
-
}
|
|
1134
|
-
else {
|
|
1135
|
-
throw new ProhibitedActionError('we only support encoding of BLSIG signatures from protocol Seoul');
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
catch (err) {
|
|
1139
|
-
if (err instanceof ParameterValidationError) {
|
|
1140
|
-
throw new InvalidSignatureError(val, err.result);
|
|
1141
|
-
}
|
|
1142
|
-
else {
|
|
1143
|
-
throw err;
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
};
|
|
1147
|
-
const signatureV1Decoder$1 = (val) => {
|
|
1148
|
-
val.consume(4);
|
|
1149
|
-
if (val.length().toString() === '96') {
|
|
1150
|
-
return prefixDecoder$1(PrefixV2.BLS12_381Signature)(val);
|
|
1151
|
-
}
|
|
1152
|
-
else {
|
|
1153
|
-
throw new ProhibitedActionError('we only support decoding of BLSIG signatures');
|
|
1154
|
-
}
|
|
1155
|
-
};
|
|
1156
|
-
const signatureProofEncoder$1 = (val) => {
|
|
1157
|
-
if (val) {
|
|
1158
|
-
return boolEncoder$1(true) + signatureV1Encoder$1(val);
|
|
1159
|
-
}
|
|
1160
|
-
else {
|
|
1161
|
-
return boolEncoder$1(false);
|
|
1162
|
-
}
|
|
1163
|
-
};
|
|
1164
|
-
const signatureProofDecoder$1 = (value) => {
|
|
1165
|
-
const hasProof = boolDecoder$1(value);
|
|
1166
|
-
if (hasProof) {
|
|
1167
|
-
return signatureV1Decoder$1(value);
|
|
1168
|
-
}
|
|
1169
|
-
};
|
|
1170
|
-
const paddedBytesEncoder$1 = (val, paddingLength = 8) => {
|
|
1171
|
-
return `${pad(val.length / 2, paddingLength)}${val}`;
|
|
1172
|
-
};
|
|
1173
|
-
const paddedBytesDecoder$1 = (val) => {
|
|
1174
|
-
const value = extractRequiredLen$1(val);
|
|
1175
|
-
return Buffer.from(value).toString('hex');
|
|
1176
|
-
};
|
|
1177
|
-
const smartRollupMessageEncoder$1 = (val) => {
|
|
1178
|
-
const message = val.reduce((prev, curr) => {
|
|
1179
|
-
return prev + `${pad(curr.length / 2)}${curr}`;
|
|
1180
|
-
}, '');
|
|
1181
|
-
return `${pad(message.length / 2)}${message}`;
|
|
1182
|
-
};
|
|
1183
|
-
const smartRollupMessageDecoder$1 = (val) => {
|
|
1184
|
-
const valueArray = extractRequiredLen$1(val);
|
|
1185
|
-
const ret = stripLengthPrefixFromBytes$1(new Uint8ArrayConsumer(valueArray));
|
|
1186
|
-
return ret.map((value) => Buffer.from(value).toString('hex'));
|
|
1187
|
-
};
|
|
1188
|
-
const dalCommitmentEncoder$1 = (val) => {
|
|
1189
|
-
try {
|
|
1190
|
-
return prefixEncoder$1(PrefixV2.SlotHeader)(val);
|
|
1191
|
-
}
|
|
1192
|
-
catch (err) {
|
|
1193
|
-
if (err instanceof ParameterValidationError) {
|
|
1194
|
-
throw new InvalidDalCommitmentError(val);
|
|
1195
|
-
}
|
|
1196
|
-
else {
|
|
1197
|
-
throw err;
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
};
|
|
1201
|
-
const dalCommitmentDecoder$1 = (val) => {
|
|
1202
|
-
return prefixDecoder$1(PrefixV2.SlotHeader)(val);
|
|
1203
|
-
};
|
|
1204
|
-
const slotHeaderEncoder$1 = (val) => {
|
|
1205
|
-
return pad(val.slot_index, 2) + dalCommitmentEncoder$1(val.commitment) + val.commitment_proof;
|
|
1206
|
-
};
|
|
1207
|
-
const slotHeaderDecoder$1 = (val) => {
|
|
1208
|
-
const preamble = val.consume(1);
|
|
1209
|
-
return {
|
|
1210
|
-
slot_index: Number(preamble[0].toString(10)),
|
|
1211
|
-
commitment: dalCommitmentDecoder$1(val),
|
|
1212
|
-
commitment_proof: toHexString(val.consume(96)), // rpcForger expect commitment_proof bytes to be len 96
|
|
1213
|
-
};
|
|
1214
|
-
};
|
|
1215
|
-
|
|
1216
|
-
const ManagerOperationSchema$1 = {
|
|
1217
|
-
branch: CODEC$1.BRANCH,
|
|
1218
|
-
contents: [CODEC$1.OPERATION],
|
|
1219
|
-
};
|
|
1220
|
-
const ActivationSchema$1 = {
|
|
1221
|
-
pkh: CODEC$1.TZ1,
|
|
1222
|
-
secret: CODEC$1.SECRET,
|
|
1223
|
-
};
|
|
1224
|
-
const RevealSchema$1 = {
|
|
1225
|
-
source: CODEC$1.PKH,
|
|
1226
|
-
fee: CODEC$1.ZARITH,
|
|
1227
|
-
counter: CODEC$1.ZARITH,
|
|
1228
|
-
gas_limit: CODEC$1.ZARITH,
|
|
1229
|
-
storage_limit: CODEC$1.ZARITH,
|
|
1230
|
-
public_key: CODEC$1.PUBLIC_KEY,
|
|
1231
|
-
proof: CODEC$1.SIGNATURE_PROOF,
|
|
1232
|
-
};
|
|
1233
|
-
const DelegationSchema$1 = {
|
|
1234
|
-
source: CODEC$1.PKH,
|
|
1235
|
-
fee: CODEC$1.ZARITH,
|
|
1236
|
-
counter: CODEC$1.ZARITH,
|
|
1237
|
-
gas_limit: CODEC$1.ZARITH,
|
|
1238
|
-
storage_limit: CODEC$1.ZARITH,
|
|
1239
|
-
delegate: CODEC$1.DELEGATE,
|
|
1240
|
-
};
|
|
1241
|
-
const TransactionSchema$1 = {
|
|
1242
|
-
source: CODEC$1.PKH,
|
|
1243
|
-
fee: CODEC$1.ZARITH,
|
|
1244
|
-
counter: CODEC$1.ZARITH,
|
|
1245
|
-
gas_limit: CODEC$1.ZARITH,
|
|
1246
|
-
storage_limit: CODEC$1.ZARITH,
|
|
1247
|
-
amount: CODEC$1.ZARITH,
|
|
1248
|
-
destination: CODEC$1.ADDRESS,
|
|
1249
|
-
parameters: CODEC$1.PARAMETERS,
|
|
1250
|
-
};
|
|
1251
|
-
const OriginationSchema$1 = {
|
|
1252
|
-
source: CODEC$1.PKH,
|
|
1253
|
-
fee: CODEC$1.ZARITH,
|
|
1254
|
-
counter: CODEC$1.ZARITH,
|
|
1255
|
-
gas_limit: CODEC$1.ZARITH,
|
|
1256
|
-
storage_limit: CODEC$1.ZARITH,
|
|
1257
|
-
balance: CODEC$1.ZARITH,
|
|
1258
|
-
delegate: CODEC$1.DELEGATE,
|
|
1259
|
-
script: CODEC$1.SCRIPT,
|
|
1260
|
-
};
|
|
1261
|
-
const BallotSchema$1 = {
|
|
1262
|
-
source: CODEC$1.PKH,
|
|
1263
|
-
period: CODEC$1.INT32,
|
|
1264
|
-
proposal: CODEC$1.PROPOSAL,
|
|
1265
|
-
ballot: CODEC$1.BALLOT_STATEMENT,
|
|
1266
|
-
};
|
|
1267
|
-
const AttestationSchema$1 = {
|
|
1268
|
-
slot: CODEC$1.INT16,
|
|
1269
|
-
level: CODEC$1.INT32,
|
|
1270
|
-
round: CODEC$1.INT32,
|
|
1271
|
-
block_payload_hash: CODEC$1.BLOCK_PAYLOAD_HASH,
|
|
1272
|
-
};
|
|
1273
|
-
const AttestationWithDalSchema$1 = {
|
|
1274
|
-
slot: CODEC$1.INT16,
|
|
1275
|
-
level: CODEC$1.INT32,
|
|
1276
|
-
round: CODEC$1.INT32,
|
|
1277
|
-
block_payload_hash: CODEC$1.BLOCK_PAYLOAD_HASH,
|
|
1278
|
-
dal_attestation: CODEC$1.ZARITH,
|
|
1279
|
-
};
|
|
1280
|
-
const SeedNonceRevelationSchema$1 = {
|
|
1281
|
-
level: CODEC$1.INT32,
|
|
1282
|
-
nonce: CODEC$1.RAW,
|
|
1283
|
-
};
|
|
1284
|
-
const ProposalsSchema$1 = {
|
|
1285
|
-
source: CODEC$1.PKH,
|
|
1286
|
-
period: CODEC$1.INT32,
|
|
1287
|
-
proposals: CODEC$1.PROPOSAL_ARR,
|
|
1288
|
-
};
|
|
1289
|
-
const RegisterGlobalConstantSchema$1 = {
|
|
1290
|
-
source: CODEC$1.PKH,
|
|
1291
|
-
fee: CODEC$1.ZARITH,
|
|
1292
|
-
counter: CODEC$1.ZARITH,
|
|
1293
|
-
gas_limit: CODEC$1.ZARITH,
|
|
1294
|
-
storage_limit: CODEC$1.ZARITH,
|
|
1295
|
-
value: CODEC$1.VALUE,
|
|
1296
|
-
};
|
|
1297
|
-
const TransferTicketSchema$1 = {
|
|
1298
|
-
source: CODEC$1.PKH,
|
|
1299
|
-
fee: CODEC$1.ZARITH,
|
|
1300
|
-
counter: CODEC$1.ZARITH,
|
|
1301
|
-
gas_limit: CODEC$1.ZARITH,
|
|
1302
|
-
storage_limit: CODEC$1.ZARITH,
|
|
1303
|
-
ticket_contents: CODEC$1.VALUE,
|
|
1304
|
-
ticket_ty: CODEC$1.VALUE,
|
|
1305
|
-
ticket_ticketer: CODEC$1.ADDRESS,
|
|
1306
|
-
ticket_amount: CODEC$1.ZARITH,
|
|
1307
|
-
destination: CODEC$1.ADDRESS,
|
|
1308
|
-
entrypoint: CODEC$1.ENTRYPOINT,
|
|
1309
|
-
};
|
|
1310
|
-
const IncreasePaidStorageSchema$1 = {
|
|
1311
|
-
source: CODEC$1.PKH,
|
|
1312
|
-
fee: CODEC$1.ZARITH,
|
|
1313
|
-
counter: CODEC$1.ZARITH,
|
|
1314
|
-
gas_limit: CODEC$1.ZARITH,
|
|
1315
|
-
storage_limit: CODEC$1.ZARITH,
|
|
1316
|
-
amount: CODEC$1.ZARITH,
|
|
1317
|
-
destination: CODEC$1.SMART_CONTRACT_ADDRESS,
|
|
1318
|
-
};
|
|
1319
|
-
const UpdateConsensusKeySchema$1 = {
|
|
1320
|
-
source: CODEC$1.PKH,
|
|
1321
|
-
fee: CODEC$1.ZARITH,
|
|
1322
|
-
counter: CODEC$1.ZARITH,
|
|
1323
|
-
gas_limit: CODEC$1.ZARITH,
|
|
1324
|
-
storage_limit: CODEC$1.ZARITH,
|
|
1325
|
-
pk: CODEC$1.PUBLIC_KEY,
|
|
1326
|
-
proof: CODEC$1.SIGNATURE_PROOF,
|
|
1327
|
-
};
|
|
1328
|
-
const UpdateCompanionKeySchema = {
|
|
1329
|
-
source: CODEC$1.PKH,
|
|
1330
|
-
fee: CODEC$1.ZARITH,
|
|
1331
|
-
counter: CODEC$1.ZARITH,
|
|
1332
|
-
gas_limit: CODEC$1.ZARITH,
|
|
1333
|
-
storage_limit: CODEC$1.ZARITH,
|
|
1334
|
-
pk: CODEC$1.PUBLIC_KEY,
|
|
1335
|
-
proof: CODEC$1.SIGNATURE_PROOF,
|
|
1336
|
-
};
|
|
1337
|
-
const DrainDelegateSchema$1 = {
|
|
1338
|
-
consensus_key: CODEC$1.PKH,
|
|
1339
|
-
delegate: CODEC$1.PKH,
|
|
1340
|
-
destination: CODEC$1.PKH,
|
|
1341
|
-
};
|
|
1342
|
-
const SetDepositsLimitSchema$1 = {
|
|
1343
|
-
source: CODEC$1.PKH,
|
|
1344
|
-
fee: CODEC$1.ZARITH,
|
|
1345
|
-
counter: CODEC$1.ZARITH,
|
|
1346
|
-
gas_limit: CODEC$1.ZARITH,
|
|
1347
|
-
storage_limit: CODEC$1.ZARITH,
|
|
1348
|
-
limit: CODEC$1.DEPOSITS_LIMIT,
|
|
1349
|
-
};
|
|
1350
|
-
const SmartRollupOriginateSchema$1 = {
|
|
1351
|
-
source: CODEC$1.PKH,
|
|
1352
|
-
fee: CODEC$1.ZARITH,
|
|
1353
|
-
counter: CODEC$1.ZARITH,
|
|
1354
|
-
gas_limit: CODEC$1.ZARITH,
|
|
1355
|
-
storage_limit: CODEC$1.ZARITH,
|
|
1356
|
-
pvm_kind: CODEC$1.PVM_KIND,
|
|
1357
|
-
kernel: CODEC$1.PADDED_BYTES,
|
|
1358
|
-
parameters_ty: CODEC$1.VALUE,
|
|
1359
|
-
whitelist: CODEC$1.PKH_ARR,
|
|
1360
|
-
};
|
|
1361
|
-
const SmartRollupAddMessagesSchema$1 = {
|
|
1362
|
-
source: CODEC$1.PKH,
|
|
1363
|
-
fee: CODEC$1.ZARITH,
|
|
1364
|
-
counter: CODEC$1.ZARITH,
|
|
1365
|
-
gas_limit: CODEC$1.ZARITH,
|
|
1366
|
-
storage_limit: CODEC$1.ZARITH,
|
|
1367
|
-
message: CODEC$1.SMART_ROLLUP_MESSAGE,
|
|
1368
|
-
};
|
|
1369
|
-
const SmartRollupExecuteOutboxMessageSchema$1 = {
|
|
1370
|
-
source: CODEC$1.PKH,
|
|
1371
|
-
fee: CODEC$1.ZARITH,
|
|
1372
|
-
counter: CODEC$1.ZARITH,
|
|
1373
|
-
gas_limit: CODEC$1.ZARITH,
|
|
1374
|
-
storage_limit: CODEC$1.ZARITH,
|
|
1375
|
-
rollup: CODEC$1.SMART_ROLLUP_ADDRESS,
|
|
1376
|
-
cemented_commitment: CODEC$1.SMART_ROLLUP_COMMITMENT_HASH,
|
|
1377
|
-
output_proof: CODEC$1.PADDED_BYTES,
|
|
1378
|
-
};
|
|
1379
|
-
const DalPublishCommitmentSchema$1 = {
|
|
1380
|
-
source: CODEC$1.PKH,
|
|
1381
|
-
fee: CODEC$1.ZARITH,
|
|
1382
|
-
counter: CODEC$1.ZARITH,
|
|
1383
|
-
gas_limit: CODEC$1.ZARITH,
|
|
1384
|
-
storage_limit: CODEC$1.ZARITH,
|
|
1385
|
-
slot_header: CODEC$1.SLOT_HEADER,
|
|
1386
|
-
};
|
|
1387
|
-
const FailingNoopSchema$1 = {
|
|
1388
|
-
arbitrary: CODEC$1.PADDED_BYTES,
|
|
1389
|
-
};
|
|
1390
|
-
const operationEncoder$1 = (encoders) => (operation) => {
|
|
1391
|
-
if (!(operation.kind in encoders) || !(operation.kind in kindMappingReverse$1)) {
|
|
1392
|
-
throw new InvalidOperationKindError(operation.kind);
|
|
1393
|
-
}
|
|
1394
|
-
return kindMappingReverse$1[operation.kind] + encoders[operation.kind](operation);
|
|
1395
|
-
};
|
|
1396
|
-
const operationDecoder$1 = (decoders) => (value) => {
|
|
1397
|
-
const op = value.consume(1);
|
|
1398
|
-
const operationName = kindMapping$1[op[0]];
|
|
1399
|
-
if (operationName === undefined) {
|
|
1400
|
-
throw new UnsupportedOperationError(op[0].toString());
|
|
1401
|
-
}
|
|
1402
|
-
const decodedObj = decoders[operationName](value);
|
|
1403
|
-
if (typeof decodedObj !== 'object') {
|
|
1404
|
-
throw new OperationDecodingError('Invalid operation, cannot be decoded.');
|
|
1405
|
-
}
|
|
1406
|
-
return Object.assign({ kind: operationName }, decodedObj);
|
|
1407
|
-
};
|
|
1408
|
-
const schemaEncoder$1 = (encoders) => (schema) => (value) => {
|
|
1409
|
-
const keys = Object.keys(schema);
|
|
1410
|
-
return keys.reduce((prev, key) => {
|
|
1411
|
-
const valueToEncode = schema[key];
|
|
1412
|
-
if (value && Array.isArray(valueToEncode)) {
|
|
1413
|
-
const encoder = encoders[valueToEncode[0]];
|
|
1414
|
-
const values = value[key];
|
|
1415
|
-
if (!Array.isArray(values)) {
|
|
1416
|
-
throw new OperationEncodingError(`Invalid operation value "${JSON.stringify(values)}" of key "${key}, expected value to be Array.`);
|
|
1417
|
-
}
|
|
1418
|
-
return (prev + values.reduce((prevBytes, current) => prevBytes + encoder(current), ''));
|
|
1419
|
-
}
|
|
1420
|
-
else {
|
|
1421
|
-
const encoder = encoders[valueToEncode];
|
|
1422
|
-
return prev + encoder(value[key]);
|
|
1423
|
-
}
|
|
1424
|
-
}, '');
|
|
1425
|
-
};
|
|
1426
|
-
const schemaDecoder$1 = (decoders) => (schema) => (value) => {
|
|
1427
|
-
const keys = Object.keys(schema);
|
|
1428
|
-
return keys.reduce((prev, key) => {
|
|
1429
|
-
const valueToEncode = schema[key];
|
|
1430
|
-
if (Array.isArray(valueToEncode)) {
|
|
1431
|
-
const decoder = decoders[valueToEncode[0]];
|
|
1432
|
-
const decoded = [];
|
|
1433
|
-
const lastLength = value.length();
|
|
1434
|
-
while (value.length() > 0) {
|
|
1435
|
-
decoded.push(decoder(value));
|
|
1436
|
-
if (lastLength === value.length()) {
|
|
1437
|
-
throw new OperationDecodingError('Unable to decode value');
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
return Object.assign(Object.assign({}, prev), { [key]: decoded });
|
|
1441
|
-
}
|
|
1442
|
-
else {
|
|
1443
|
-
const decoder = decoders[valueToEncode];
|
|
1444
|
-
const result = decoder(value);
|
|
1445
|
-
if (typeof result !== 'undefined') {
|
|
1446
|
-
return Object.assign(Object.assign({}, prev), { [key]: result });
|
|
1447
|
-
}
|
|
1448
|
-
else {
|
|
1449
|
-
return Object.assign({}, prev);
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
}, {});
|
|
1453
|
-
};
|
|
1454
|
-
|
|
1455
|
-
const decoders$1 = {
|
|
1456
|
-
[CODEC$1.SECRET]: (val) => toHexString(val.consume(20)),
|
|
1457
|
-
[CODEC$1.RAW]: (val) => toHexString(val.consume(32)),
|
|
1458
|
-
[CODEC$1.TZ1]: tz1Decoder$1,
|
|
1459
|
-
[CODEC$1.BRANCH]: branchDecoder$1,
|
|
1460
|
-
[CODEC$1.ZARITH]: zarithDecoder$1,
|
|
1461
|
-
[CODEC$1.PUBLIC_KEY]: publicKeyDecoder$1,
|
|
1462
|
-
[CODEC$1.PKH]: publicKeyHashDecoder$1,
|
|
1463
|
-
[CODEC$1.PKH_ARR]: publicKeyHashesDecoder$1,
|
|
1464
|
-
[CODEC$1.DELEGATE]: delegateDecoder$1,
|
|
1465
|
-
[CODEC$1.INT32]: int32Decoder$1,
|
|
1466
|
-
[CODEC$1.SCRIPT]: scriptDecoder$1,
|
|
1467
|
-
[CODEC$1.BALLOT_STATEMENT]: ballotDecoder$1,
|
|
1468
|
-
[CODEC$1.PROPOSAL]: proposalDecoder$1,
|
|
1469
|
-
[CODEC$1.PROPOSAL_ARR]: proposalsDecoder$1,
|
|
1470
|
-
[CODEC$1.PARAMETERS]: parametersDecoder$1,
|
|
1471
|
-
[CODEC$1.ADDRESS]: addressDecoder$1,
|
|
1472
|
-
[CODEC$1.SMART_ROLLUP_ADDRESS]: smartRollupAddressDecoder$1,
|
|
1473
|
-
[CODEC$1.SMART_CONTRACT_ADDRESS]: smartContractAddressDecoder$1,
|
|
1474
|
-
[CODEC$1.SMART_ROLLUP_COMMITMENT_HASH]: smartRollupCommitmentHashDecoder$1,
|
|
1475
|
-
[CODEC$1.VALUE]: valueParameterDecoder$1,
|
|
1476
|
-
[CODEC$1.INT16]: int16Decoder$1,
|
|
1477
|
-
[CODEC$1.BLOCK_PAYLOAD_HASH]: blockPayloadHashDecoder$1,
|
|
1478
|
-
[CODEC$1.ENTRYPOINT]: entrypointNameDecoder$1,
|
|
1479
|
-
[CODEC$1.BURN_LIMIT]: burnLimitDecoder$1,
|
|
1480
|
-
[CODEC$1.DEPOSITS_LIMIT]: depositsLimitDecoder$1,
|
|
1481
|
-
[CODEC$1.SIGNATURE_PROOF]: signatureProofDecoder$1,
|
|
1482
|
-
[CODEC$1.PVM_KIND]: pvmKindDecoder$1,
|
|
1483
|
-
[CODEC$1.PADDED_BYTES]: paddedBytesDecoder$1,
|
|
1484
|
-
[CODEC$1.SMART_ROLLUP_MESSAGE]: smartRollupMessageDecoder$1,
|
|
1485
|
-
[CODEC$1.SLOT_HEADER]: slotHeaderDecoder$1,
|
|
1486
|
-
};
|
|
1487
|
-
decoders$1[CODEC$1.OPERATION] = operationDecoder$1(decoders$1);
|
|
1488
|
-
decoders$1[CODEC$1.OP_ACTIVATE_ACCOUNT] = (val) => schemaDecoder$1(decoders$1)(ActivationSchema$1)(val);
|
|
1489
|
-
decoders$1[CODEC$1.OP_FAILING_NOOP] = (val) => schemaDecoder$1(decoders$1)(FailingNoopSchema$1)(val);
|
|
1490
|
-
decoders$1[CODEC$1.OP_DELEGATION] = (val) => schemaDecoder$1(decoders$1)(DelegationSchema$1)(val);
|
|
1491
|
-
decoders$1[CODEC$1.OP_TRANSACTION] = (val) => schemaDecoder$1(decoders$1)(TransactionSchema$1)(val);
|
|
1492
|
-
decoders$1[CODEC$1.OP_ORIGINATION] = (val) => schemaDecoder$1(decoders$1)(OriginationSchema$1)(val);
|
|
1493
|
-
decoders$1[CODEC$1.OP_BALLOT] = (val) => schemaDecoder$1(decoders$1)(BallotSchema$1)(val);
|
|
1494
|
-
decoders$1[CODEC$1.OP_ATTESTATION] = (val) => schemaDecoder$1(decoders$1)(AttestationSchema$1)(val);
|
|
1495
|
-
decoders$1[CODEC$1.OP_ATTESTATION_WITH_DAL] = (val) => schemaDecoder$1(decoders$1)(AttestationWithDalSchema$1)(val);
|
|
1496
|
-
decoders$1[CODEC$1.OP_SEED_NONCE_REVELATION] = (val) => schemaDecoder$1(decoders$1)(SeedNonceRevelationSchema$1)(val);
|
|
1497
|
-
decoders$1[CODEC$1.OP_PROPOSALS] = (val) => schemaDecoder$1(decoders$1)(ProposalsSchema$1)(val);
|
|
1498
|
-
decoders$1[CODEC$1.OP_REVEAL] = (val) => schemaDecoder$1(decoders$1)(RevealSchema$1)(val);
|
|
1499
|
-
decoders$1[CODEC$1.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaDecoder$1(decoders$1)(RegisterGlobalConstantSchema$1)(val);
|
|
1500
|
-
decoders$1[CODEC$1.OP_TRANSFER_TICKET] = (val) => schemaDecoder$1(decoders$1)(TransferTicketSchema$1)(val);
|
|
1501
|
-
decoders$1[CODEC$1.OP_INCREASE_PAID_STORAGE] = (val) => schemaDecoder$1(decoders$1)(IncreasePaidStorageSchema$1)(val);
|
|
1502
|
-
decoders$1[CODEC$1.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaDecoder$1(decoders$1)(UpdateConsensusKeySchema$1)(val);
|
|
1503
|
-
decoders$1[CODEC$1.OP_UPDATE_COMPANION_KEY] = (val) => schemaDecoder$1(decoders$1)(UpdateCompanionKeySchema)(val);
|
|
1504
|
-
decoders$1[CODEC$1.OP_DRAIN_DELEGATE] = (val) => schemaDecoder$1(decoders$1)(DrainDelegateSchema$1)(val);
|
|
1505
|
-
decoders$1[CODEC$1.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaDecoder$1(decoders$1)(SmartRollupOriginateSchema$1)(val);
|
|
1506
|
-
decoders$1[CODEC$1.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaDecoder$1(decoders$1)(SmartRollupAddMessagesSchema$1)(val);
|
|
1507
|
-
decoders$1[CODEC$1.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaDecoder$1(decoders$1)(SmartRollupExecuteOutboxMessageSchema$1)(val);
|
|
1508
|
-
decoders$1[CODEC$1.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaDecoder$1(decoders$1)(DalPublishCommitmentSchema$1)(val);
|
|
1509
|
-
decoders$1[CODEC$1.MANAGER] = schemaDecoder$1(decoders$1)(ManagerOperationSchema$1);
|
|
1510
|
-
decoders$1[CODEC$1.OP_SET_DEPOSITS_LIMIT] = (val) => schemaDecoder$1(decoders$1)(SetDepositsLimitSchema$1)(val);
|
|
1511
|
-
|
|
1512
|
-
/*
|
|
1513
|
-
* Some code in this file is originally from sotez
|
|
1514
|
-
* Copyright (c) 2018 Andrew Kishino
|
|
1515
|
-
*/
|
|
1516
|
-
// See: https://tezos.gitlab.io/protocols/005_babylon.html#transactions-now-have-an-entrypoint
|
|
1517
|
-
const ENTRYPOINT_MAX_LENGTH = 31;
|
|
1518
|
-
var CODEC;
|
|
1519
|
-
(function (CODEC) {
|
|
1520
|
-
CODEC["SECRET"] = "secret";
|
|
1521
|
-
CODEC["RAW"] = "raw";
|
|
1522
|
-
CODEC["TZ1"] = "tz1";
|
|
1523
|
-
CODEC["BRANCH"] = "branch";
|
|
1524
|
-
CODEC["ZARITH"] = "zarith";
|
|
1525
|
-
CODEC["PUBLIC_KEY"] = "public_key";
|
|
1526
|
-
CODEC["PKH"] = "pkh";
|
|
1527
|
-
CODEC["PKH_ARR"] = "pkhArr";
|
|
1528
|
-
CODEC["DELEGATE"] = "delegate";
|
|
1529
|
-
CODEC["SCRIPT"] = "script";
|
|
1530
|
-
CODEC["BALLOT_STATEMENT"] = "ballotStmt";
|
|
1531
|
-
CODEC["PROPOSAL"] = "proposal";
|
|
1532
|
-
CODEC["PROPOSAL_ARR"] = "proposalArr";
|
|
1533
|
-
CODEC["INT32"] = "int32";
|
|
1534
|
-
CODEC["INT16"] = "int16";
|
|
1535
|
-
CODEC["PARAMETERS"] = "parameters";
|
|
1536
|
-
CODEC["ADDRESS"] = "address";
|
|
1537
|
-
CODEC["SMART_CONTRACT_ADDRESS"] = "smart_contract_address";
|
|
1538
|
-
CODEC["SMART_ROLLUP_ADDRESS"] = "smart_rollup_address";
|
|
1539
|
-
CODEC["SMART_ROLLUP_COMMITMENT_HASH"] = "smart_rollup_commitment_hash";
|
|
1540
|
-
CODEC["VALUE"] = "value";
|
|
1541
|
-
CODEC["PADDED_BYTES"] = "padded_bytes";
|
|
1542
|
-
CODEC["SMART_ROLLUP_MESSAGE"] = "smart_rollup_message";
|
|
1543
|
-
CODEC["MANAGER"] = "manager";
|
|
1544
|
-
CODEC["BLOCK_PAYLOAD_HASH"] = "blockPayloadHash";
|
|
1545
|
-
CODEC["ENTRYPOINT"] = "entrypoint";
|
|
1546
|
-
CODEC["OPERATION"] = "operation";
|
|
1547
|
-
CODEC["OP_ACTIVATE_ACCOUNT"] = "activate_account";
|
|
1548
|
-
CODEC["OP_DELEGATION"] = "delegation";
|
|
1549
|
-
CODEC["OP_TRANSACTION"] = "transaction";
|
|
1550
|
-
CODEC["OP_ORIGINATION"] = "origination";
|
|
1551
|
-
CODEC["OP_BALLOT"] = "ballot";
|
|
1552
|
-
CODEC["OP_FAILING_NOOP"] = "failing_noop";
|
|
1553
|
-
CODEC["OP_ATTESTATION"] = "attestation";
|
|
1554
|
-
CODEC["OP_ATTESTATION_WITH_DAL"] = "attestation_with_dal";
|
|
1555
|
-
CODEC["OP_SEED_NONCE_REVELATION"] = "seed_nonce_revelation";
|
|
1556
|
-
CODEC["OP_REVEAL"] = "reveal";
|
|
1557
|
-
CODEC["OP_PROPOSALS"] = "proposals";
|
|
1558
|
-
CODEC["OP_REGISTER_GLOBAL_CONSTANT"] = "register_global_constant";
|
|
1559
|
-
CODEC["OP_TRANSFER_TICKET"] = "transfer_ticket";
|
|
1560
|
-
CODEC["BURN_LIMIT"] = "burn_limit";
|
|
1561
|
-
CODEC["OP_INCREASE_PAID_STORAGE"] = "increase_paid_storage";
|
|
1562
|
-
CODEC["OP_UPDATE_CONSENSUS_KEY"] = "update_consensus_key";
|
|
1563
|
-
CODEC["SIGNATURE_PROOF"] = "signature_proof";
|
|
1564
|
-
CODEC["OP_DRAIN_DELEGATE"] = "drain_delegate";
|
|
1565
|
-
CODEC["DEPOSITS_LIMIT"] = "deposits_limit";
|
|
1566
|
-
CODEC["OP_SET_DEPOSITS_LIMIT"] = "set_deposits_limit";
|
|
1567
|
-
CODEC["OP_SMART_ROLLUP_ORIGINATE"] = "smart_rollup_originate";
|
|
1568
|
-
CODEC["PVM_KIND"] = "pvm_kind";
|
|
1569
|
-
CODEC["OP_SMART_ROLLUP_ADD_MESSAGES"] = "smart_rollup_add_messages";
|
|
1570
|
-
CODEC["OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE"] = "smart_rollup_execute_outbox_message";
|
|
1571
|
-
CODEC["OP_DAL_PUBLISH_COMMITMENT"] = "dal_publish_commitment";
|
|
1572
|
-
CODEC["SLOT_HEADER"] = "slot_header";
|
|
1573
|
-
})(CODEC || (CODEC = {}));
|
|
1574
|
-
// See https://tezos.gitlab.io/shell/p2p_api.html#alpha-michelson-v1-primitives-enumeration-unsigned-8-bit-integer
|
|
1575
|
-
const opMapping = {
|
|
1576
|
-
'00': 'parameter',
|
|
1577
|
-
'01': 'storage',
|
|
1578
|
-
'02': 'code',
|
|
1579
|
-
'03': 'False',
|
|
1580
|
-
'04': 'Elt',
|
|
1581
|
-
'05': 'Left',
|
|
1582
|
-
'06': 'None',
|
|
1583
|
-
'07': 'Pair',
|
|
1584
|
-
'08': 'Right',
|
|
1585
|
-
'09': 'Some',
|
|
1586
|
-
'0a': 'True',
|
|
1587
|
-
'0b': 'Unit',
|
|
1588
|
-
'0c': 'PACK',
|
|
1589
|
-
'0d': 'UNPACK',
|
|
1590
|
-
'0e': 'BLAKE2B',
|
|
1591
|
-
'0f': 'SHA256',
|
|
1592
|
-
'10': 'SHA512',
|
|
1593
|
-
'11': 'ABS',
|
|
1594
|
-
'12': 'ADD',
|
|
1595
|
-
'13': 'AMOUNT',
|
|
1596
|
-
'14': 'AND',
|
|
1597
|
-
'15': 'BALANCE',
|
|
1598
|
-
'16': 'CAR',
|
|
1599
|
-
'17': 'CDR',
|
|
1600
|
-
'18': 'CHECK_SIGNATURE',
|
|
1601
|
-
'19': 'COMPARE',
|
|
1602
|
-
'1a': 'CONCAT',
|
|
1603
|
-
'1b': 'CONS',
|
|
1604
|
-
'1c': 'CREATE_ACCOUNT', // Removed in Edo
|
|
1605
|
-
'1d': 'CREATE_CONTRACT', // Removed in Edo
|
|
1606
|
-
'1e': 'IMPLICIT_ACCOUNT',
|
|
1607
|
-
'1f': 'DIP',
|
|
1608
|
-
'20': 'DROP',
|
|
1609
|
-
'21': 'DUP',
|
|
1610
|
-
'22': 'EDIV',
|
|
1611
|
-
'23': 'EMPTY_MAP',
|
|
1612
|
-
'24': 'EMPTY_SET',
|
|
1613
|
-
'25': 'EQ',
|
|
1614
|
-
'26': 'EXEC',
|
|
1615
|
-
'27': 'FAILWITH',
|
|
1616
|
-
'28': 'GE',
|
|
1617
|
-
'29': 'GET',
|
|
1618
|
-
'2a': 'GT',
|
|
1619
|
-
'2b': 'HASH_KEY',
|
|
1620
|
-
'2c': 'IF',
|
|
1621
|
-
'2d': 'IF_CONS',
|
|
1622
|
-
'2e': 'IF_LEFT',
|
|
1623
|
-
'2f': 'IF_NONE',
|
|
1624
|
-
'30': 'INT',
|
|
1625
|
-
'31': 'LAMBDA',
|
|
1626
|
-
'32': 'LE',
|
|
1627
|
-
'33': 'LEFT',
|
|
1628
|
-
'34': 'LOOP',
|
|
1629
|
-
'35': 'LSL',
|
|
1630
|
-
'36': 'LSR',
|
|
1631
|
-
'37': 'LT',
|
|
1632
|
-
'38': 'MAP',
|
|
1633
|
-
'39': 'MEM',
|
|
1634
|
-
'3a': 'MUL',
|
|
1635
|
-
'3b': 'NEG',
|
|
1636
|
-
'3c': 'NEQ',
|
|
1637
|
-
'3d': 'NIL',
|
|
1638
|
-
'3e': 'NONE',
|
|
1639
|
-
'3f': 'NOT',
|
|
1640
|
-
'40': 'NOW',
|
|
1641
|
-
'41': 'OR',
|
|
1642
|
-
'42': 'PAIR',
|
|
1643
|
-
'43': 'PUSH',
|
|
1644
|
-
'44': 'RIGHT',
|
|
1645
|
-
'45': 'SIZE',
|
|
1646
|
-
'46': 'SOME',
|
|
1647
|
-
'47': 'SOURCE',
|
|
1648
|
-
'48': 'SENDER',
|
|
1649
|
-
'49': 'SELF',
|
|
1650
|
-
'4a': 'STEPS_TO_QUOTA', // Removed in Edo
|
|
1651
|
-
'4b': 'SUB',
|
|
1652
|
-
'4c': 'SWAP',
|
|
1653
|
-
'4d': 'TRANSFER_TOKENS',
|
|
1654
|
-
'4e': 'SET_DELEGATE',
|
|
1655
|
-
'4f': 'UNIT',
|
|
1656
|
-
'50': 'UPDATE',
|
|
1657
|
-
'51': 'XOR',
|
|
1658
|
-
'52': 'ITER',
|
|
1659
|
-
'53': 'LOOP_LEFT',
|
|
1660
|
-
'54': 'ADDRESS',
|
|
1661
|
-
'55': 'CONTRACT',
|
|
1662
|
-
'56': 'ISNAT',
|
|
1663
|
-
'57': 'CAST',
|
|
1664
|
-
'58': 'RENAME',
|
|
1665
|
-
'59': 'bool',
|
|
1666
|
-
'5a': 'contract',
|
|
1667
|
-
'5b': 'int',
|
|
1668
|
-
'5c': 'key',
|
|
1669
|
-
'5d': 'key_hash',
|
|
1670
|
-
'5e': 'lambda',
|
|
1671
|
-
'5f': 'list',
|
|
1672
|
-
'60': 'map',
|
|
1673
|
-
'61': 'big_map',
|
|
1674
|
-
'62': 'nat',
|
|
1675
|
-
'63': 'option',
|
|
1676
|
-
'64': 'or',
|
|
1677
|
-
'65': 'pair',
|
|
1678
|
-
'66': 'set',
|
|
1679
|
-
'67': 'signature',
|
|
1680
|
-
'68': 'string',
|
|
1681
|
-
'69': 'bytes',
|
|
1682
|
-
'6a': 'mutez',
|
|
1683
|
-
'6b': 'timestamp',
|
|
1684
|
-
'6c': 'unit',
|
|
1685
|
-
'6d': 'operation',
|
|
1686
|
-
'6e': 'address',
|
|
1687
|
-
'6f': 'SLICE',
|
|
1688
|
-
'70': 'DIG',
|
|
1689
|
-
'71': 'DUG',
|
|
1690
|
-
'72': 'EMPTY_BIG_MAP',
|
|
1691
|
-
'73': 'APPLY',
|
|
1692
|
-
'74': 'chain_id',
|
|
1693
|
-
'75': 'CHAIN_ID',
|
|
1694
|
-
'76': 'LEVEL',
|
|
1695
|
-
'77': 'SELF_ADDRESS',
|
|
1696
|
-
'78': 'never',
|
|
1697
|
-
'79': 'NEVER',
|
|
1698
|
-
'7a': 'UNPAIR',
|
|
1699
|
-
'7b': 'VOTING_POWER',
|
|
1700
|
-
'7c': 'TOTAL_VOTING_POWER',
|
|
1701
|
-
'7d': 'KECCAK',
|
|
1702
|
-
'7e': 'SHA3',
|
|
1703
|
-
'7f': 'PAIRING_CHECK',
|
|
1704
|
-
'80': 'bls12_381_g1',
|
|
1705
|
-
'81': 'bls12_381_g2',
|
|
1706
|
-
'82': 'bls12_381_fr',
|
|
1707
|
-
'83': 'sapling_state',
|
|
1708
|
-
'84': 'sapling_transaction_deprecated',
|
|
1709
|
-
'85': 'SAPLING_EMPTY_STATE',
|
|
1710
|
-
'86': 'SAPLING_VERIFY_UPDATE',
|
|
1711
|
-
'87': 'ticket',
|
|
1712
|
-
'88': 'TICKET_DEPRECATED',
|
|
1713
|
-
'89': 'READ_TICKET',
|
|
1714
|
-
'8a': 'SPLIT_TICKET',
|
|
1715
|
-
'8b': 'JOIN_TICKETS',
|
|
1716
|
-
'8c': 'GET_AND_UPDATE',
|
|
1717
|
-
'8d': 'chest',
|
|
1718
|
-
'8e': 'chest_key',
|
|
1719
|
-
'8f': 'OPEN_CHEST',
|
|
1720
|
-
'90': 'VIEW',
|
|
1721
|
-
'91': 'view',
|
|
1722
|
-
'92': 'constant',
|
|
1723
|
-
'93': 'SUB_MUTEZ',
|
|
1724
|
-
'94': 'tx_rollup_l2_address',
|
|
1725
|
-
'95': 'MIN_BLOCK_TIME',
|
|
1726
|
-
'96': 'sapling_transaction',
|
|
1727
|
-
'97': 'EMIT',
|
|
1728
|
-
'98': 'Lambda_rec',
|
|
1729
|
-
'99': 'LAMBDA_REC',
|
|
1730
|
-
'9a': 'TICKET',
|
|
1731
|
-
'9b': 'BYTES',
|
|
1732
|
-
'9c': 'NAT',
|
|
1733
|
-
'9d': 'Ticket',
|
|
1734
|
-
};
|
|
1735
|
-
const opMappingReverse = (() => {
|
|
1736
|
-
const result = {};
|
|
1737
|
-
Object.keys(opMapping).forEach((key) => {
|
|
1738
|
-
result[opMapping[key]] = key;
|
|
1739
|
-
});
|
|
1740
|
-
return result;
|
|
1741
|
-
})();
|
|
1742
|
-
// See https://tezos.gitlab.io/shell/p2p_api.html
|
|
1743
|
-
const kindMapping = {
|
|
1744
|
-
0x04: 'activate_account',
|
|
1745
|
-
0x6b: 'reveal',
|
|
1746
|
-
0x6e: 'delegation',
|
|
1747
|
-
0x6c: 'transaction',
|
|
1748
|
-
0x6d: 'origination',
|
|
1749
|
-
0x06: 'ballot',
|
|
1750
|
-
0x15: 'attestation',
|
|
1751
|
-
0x17: 'attestation_with_dal',
|
|
1752
|
-
0x01: 'seed_nonce_revelation',
|
|
1753
|
-
0x05: 'proposals',
|
|
1754
|
-
0x6f: 'register_global_constant',
|
|
1755
|
-
0x9e: 'transfer_ticket',
|
|
1756
|
-
0x70: 'set_deposits_limit',
|
|
1757
|
-
0x71: 'increase_paid_storage',
|
|
1758
|
-
0x72: 'update_consensus_key',
|
|
1759
|
-
0x09: 'drain_delegate',
|
|
1760
|
-
0xc8: 'smart_rollup_originate',
|
|
1761
|
-
0xc9: 'smart_rollup_add_messages',
|
|
1762
|
-
0xce: 'smart_rollup_execute_outbox_message',
|
|
1763
|
-
0xe6: 'dal_publish_commitment',
|
|
1764
|
-
0x11: 'failing_noop',
|
|
1765
|
-
};
|
|
1766
|
-
const kindMappingReverse = (() => {
|
|
1767
|
-
const result = {};
|
|
1768
|
-
Object.keys(kindMapping).forEach((key) => {
|
|
1769
|
-
const keyNum = typeof key === 'string' ? parseInt(key, 10) : key;
|
|
1770
|
-
result[kindMapping[keyNum]] = pad(keyNum, 2);
|
|
1771
|
-
});
|
|
1772
|
-
return result;
|
|
1773
|
-
})();
|
|
1774
|
-
// See https://tezos.gitlab.io/protocols/005_babylon.html#transactions-now-have-an-entrypoint
|
|
1775
|
-
const entrypointMapping = {
|
|
1776
|
-
'00': 'default',
|
|
1777
|
-
'01': 'root',
|
|
1778
|
-
'02': 'do',
|
|
1779
|
-
'03': 'set_delegate',
|
|
1780
|
-
'04': 'remove_delegate',
|
|
1781
|
-
'05': 'deposit',
|
|
1782
|
-
'06': 'stake',
|
|
1783
|
-
'07': 'unstake',
|
|
1784
|
-
'08': 'finalize_unstake',
|
|
1785
|
-
'09': 'set_delegate_parameters',
|
|
1786
|
-
};
|
|
1787
|
-
const entrypointMappingReverse = (() => {
|
|
1788
|
-
const result = {};
|
|
1789
|
-
Object.keys(entrypointMapping).forEach((key) => {
|
|
1790
|
-
result[entrypointMapping[key]] = key;
|
|
1791
|
-
});
|
|
1792
|
-
return result;
|
|
1793
|
-
})();
|
|
1794
489
|
|
|
1795
490
|
const isPrim = (value) => {
|
|
1796
491
|
return 'prim' in value;
|
|
@@ -2046,28 +741,29 @@ const decodeAnnots = (val) => {
|
|
|
2046
741
|
};
|
|
2047
742
|
|
|
2048
743
|
// https://tezos.gitlab.io/shell/p2p_api.html specifies data types and structure for forging
|
|
2049
|
-
const prefixEncoder = (prefix
|
|
2050
|
-
|
|
744
|
+
const prefixEncoder = (prefix) => (str) => {
|
|
745
|
+
const [pl] = b58DecodeAndCheckPrefix(str, [prefix]);
|
|
746
|
+
return buf2hex(pl);
|
|
2051
747
|
};
|
|
2052
748
|
const prefixDecoder = (pre) => (str) => {
|
|
2053
|
-
const val = str.consume(
|
|
2054
|
-
return
|
|
749
|
+
const val = str.consume(payloadLength[pre]);
|
|
750
|
+
return b58Encode(val, pre);
|
|
2055
751
|
};
|
|
2056
|
-
const tz1Decoder = prefixDecoder(
|
|
2057
|
-
const branchDecoder = prefixDecoder(
|
|
752
|
+
const tz1Decoder = prefixDecoder(PrefixV2.Ed25519PublicKeyHash);
|
|
753
|
+
const branchDecoder = prefixDecoder(PrefixV2.BlockHash);
|
|
2058
754
|
const publicKeyHashDecoder = (val) => {
|
|
2059
755
|
const prefix = val.consume(1);
|
|
2060
756
|
if (prefix[0] === 0x00) {
|
|
2061
|
-
return prefixDecoder(
|
|
757
|
+
return prefixDecoder(PrefixV2.Ed25519PublicKeyHash)(val);
|
|
2062
758
|
}
|
|
2063
759
|
else if (prefix[0] === 0x01) {
|
|
2064
|
-
return prefixDecoder(
|
|
760
|
+
return prefixDecoder(PrefixV2.Secp256k1PublicKeyHash)(val);
|
|
2065
761
|
}
|
|
2066
762
|
else if (prefix[0] === 0x02) {
|
|
2067
|
-
return prefixDecoder(
|
|
763
|
+
return prefixDecoder(PrefixV2.P256PublicKeyHash)(val);
|
|
2068
764
|
}
|
|
2069
765
|
else if (prefix[0] === 0x03) {
|
|
2070
|
-
return prefixDecoder(
|
|
766
|
+
return prefixDecoder(PrefixV2.BLS12_381PublicKeyHash)(val);
|
|
2071
767
|
}
|
|
2072
768
|
};
|
|
2073
769
|
const publicKeyHashesDecoder = (val) => {
|
|
@@ -2081,14 +777,14 @@ const publicKeyHashesDecoder = (val) => {
|
|
|
2081
777
|
}
|
|
2082
778
|
return publicKeyHashes;
|
|
2083
779
|
};
|
|
2084
|
-
const branchEncoder = prefixEncoder(
|
|
2085
|
-
const tz1Encoder = prefixEncoder(
|
|
780
|
+
const branchEncoder = prefixEncoder(PrefixV2.BlockHash);
|
|
781
|
+
const tz1Encoder = prefixEncoder(PrefixV2.Ed25519PublicKeyHash);
|
|
2086
782
|
const boolEncoder = (bool) => (bool ? 'ff' : '00');
|
|
2087
783
|
const proposalEncoder = (proposal) => {
|
|
2088
|
-
return prefixEncoder(
|
|
784
|
+
return prefixEncoder(PrefixV2.ProtocolHash)(proposal);
|
|
2089
785
|
};
|
|
2090
786
|
const proposalDecoder = (proposal) => {
|
|
2091
|
-
return prefixDecoder(
|
|
787
|
+
return prefixDecoder(PrefixV2.ProtocolHash)(proposal);
|
|
2092
788
|
};
|
|
2093
789
|
const proposalsDecoder = (proposal) => {
|
|
2094
790
|
const proposals = [];
|
|
@@ -2204,19 +900,11 @@ const delegateDecoder = (val) => {
|
|
|
2204
900
|
}
|
|
2205
901
|
};
|
|
2206
902
|
const publicKeyHashEncoder = (val) => {
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
return '01' + prefixEncoder(Prefix.TZ2)(val);
|
|
2213
|
-
case Prefix.TZ3:
|
|
2214
|
-
return '02' + prefixEncoder(Prefix.TZ3)(val);
|
|
2215
|
-
case Prefix.TZ4:
|
|
2216
|
-
return '03' + prefixEncoder(Prefix.TZ4)(val);
|
|
2217
|
-
default:
|
|
2218
|
-
throw new InvalidKeyHashError$1(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
2219
|
-
` expecting one for the following "${Prefix.TZ1}", "${Prefix.TZ2}", "${Prefix.TZ3}" or "${Prefix.TZ4}".`);
|
|
903
|
+
try {
|
|
904
|
+
return b58DecodePublicKeyHash(val);
|
|
905
|
+
}
|
|
906
|
+
catch (err) {
|
|
907
|
+
throw new InvalidKeyHashError(val, err instanceof ParameterValidationError ? err.result : undefined);
|
|
2220
908
|
}
|
|
2221
909
|
};
|
|
2222
910
|
const publicKeyHashesEncoder = (val) => {
|
|
@@ -2232,70 +920,57 @@ const publicKeyHashesEncoder = (val) => {
|
|
|
2232
920
|
return boolEncoder(true) + pad(publicKeyHashes.length / 2) + publicKeyHashes;
|
|
2233
921
|
};
|
|
2234
922
|
const publicKeyEncoder = (val) => {
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
return '01' + prefixEncoder(Prefix.SPPK)(val);
|
|
2241
|
-
case Prefix.P2PK:
|
|
2242
|
-
return '02' + prefixEncoder(Prefix.P2PK)(val);
|
|
2243
|
-
case Prefix.BLPK:
|
|
2244
|
-
return '03' + prefixEncoder(Prefix.BLPK)(val);
|
|
2245
|
-
default:
|
|
2246
|
-
throw new InvalidPublicKeyError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
2247
|
-
` expecting one of the following '${Prefix.EDPK}', '${Prefix.SPPK}', '${Prefix.P2PK}' or '${Prefix.BLPK}'.`);
|
|
923
|
+
try {
|
|
924
|
+
return b58DecodePublicKey(val);
|
|
925
|
+
}
|
|
926
|
+
catch (err) {
|
|
927
|
+
throw new InvalidPublicKeyError(val, err instanceof ParameterValidationError ? err.result : undefined);
|
|
2248
928
|
}
|
|
2249
929
|
};
|
|
2250
930
|
const addressEncoder = (val) => {
|
|
2251
|
-
|
|
2252
|
-
switch (pubkeyPrefix) {
|
|
2253
|
-
case Prefix.TZ1:
|
|
2254
|
-
case Prefix.TZ2:
|
|
2255
|
-
case Prefix.TZ3:
|
|
2256
|
-
case Prefix.TZ4:
|
|
2257
|
-
return '00' + publicKeyHashEncoder(val);
|
|
2258
|
-
case Prefix.KT1:
|
|
2259
|
-
return '01' + prefixEncoder(Prefix.KT1)(val) + '00';
|
|
2260
|
-
default:
|
|
2261
|
-
throw new InvalidAddressError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
2262
|
-
` expecting one of the following prefix '${Prefix.TZ1}', ${Prefix.TZ2}', '${Prefix.TZ3}', '${Prefix.TZ4}' or '${Prefix.KT1}'.`);
|
|
2263
|
-
}
|
|
931
|
+
return b58DecodeAddress(val);
|
|
2264
932
|
};
|
|
2265
933
|
const smartRollupAddressEncoder = (val) => {
|
|
2266
|
-
|
|
2267
|
-
|
|
934
|
+
try {
|
|
935
|
+
return prefixEncoder(PrefixV2.SmartRollupHash)(val);
|
|
2268
936
|
}
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
937
|
+
catch (err) {
|
|
938
|
+
if (err instanceof ParameterValidationError) {
|
|
939
|
+
throw new InvalidSmartRollupAddressError(val);
|
|
940
|
+
}
|
|
941
|
+
else {
|
|
942
|
+
throw err;
|
|
943
|
+
}
|
|
2275
944
|
}
|
|
2276
|
-
throw new InvalidContractAddressError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.KT1}'.`);
|
|
2277
945
|
};
|
|
946
|
+
const smartContractAddressEncoder = (val) => b58DecodeAddress(val);
|
|
2278
947
|
const publicKeyDecoder = (val) => {
|
|
2279
948
|
const preamble = val.consume(1);
|
|
2280
949
|
switch (preamble[0]) {
|
|
2281
950
|
case 0x00:
|
|
2282
|
-
return prefixDecoder(
|
|
951
|
+
return prefixDecoder(PrefixV2.Ed25519PublicKey)(val);
|
|
2283
952
|
case 0x01:
|
|
2284
|
-
return prefixDecoder(
|
|
953
|
+
return prefixDecoder(PrefixV2.Secp256k1PublicKey)(val);
|
|
2285
954
|
case 0x02:
|
|
2286
|
-
return prefixDecoder(
|
|
955
|
+
return prefixDecoder(PrefixV2.P256PublicKey)(val);
|
|
2287
956
|
case 0x03:
|
|
2288
|
-
return prefixDecoder(
|
|
957
|
+
return prefixDecoder(PrefixV2.BLS12_381PublicKey)(val);
|
|
2289
958
|
default:
|
|
2290
|
-
throw new InvalidPublicKeyError(
|
|
959
|
+
throw new InvalidPublicKeyError(undefined, ValidationResult.NO_PREFIX_MATCHED);
|
|
2291
960
|
}
|
|
2292
961
|
};
|
|
2293
962
|
const smartRollupCommitmentHashEncoder = (val) => {
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
963
|
+
try {
|
|
964
|
+
return prefixEncoder(PrefixV2.SmartRollupCommitmentHash)(val);
|
|
965
|
+
}
|
|
966
|
+
catch (err) {
|
|
967
|
+
if (err instanceof ParameterValidationError) {
|
|
968
|
+
throw new InvalidSmartRollupCommitmentHashError(val);
|
|
969
|
+
}
|
|
970
|
+
else {
|
|
971
|
+
throw err;
|
|
972
|
+
}
|
|
2297
973
|
}
|
|
2298
|
-
throw new InvalidSmartRollupCommitmentHashError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SRC1}'`);
|
|
2299
974
|
};
|
|
2300
975
|
const addressDecoder = (val) => {
|
|
2301
976
|
const preamble = val.consume(1);
|
|
@@ -2303,7 +978,7 @@ const addressDecoder = (val) => {
|
|
|
2303
978
|
case 0x00:
|
|
2304
979
|
return publicKeyHashDecoder(val);
|
|
2305
980
|
case 0x01: {
|
|
2306
|
-
const address = prefixDecoder(
|
|
981
|
+
const address = prefixDecoder(PrefixV2.ContractHash)(val);
|
|
2307
982
|
val.consume(1);
|
|
2308
983
|
return address;
|
|
2309
984
|
}
|
|
@@ -2312,27 +987,19 @@ const addressDecoder = (val) => {
|
|
|
2312
987
|
}
|
|
2313
988
|
};
|
|
2314
989
|
const smartRollupAddressDecoder = (val) => {
|
|
2315
|
-
|
|
2316
|
-
if (address.substring(0, 3) !== Prefix.SR1) {
|
|
2317
|
-
throw new InvalidSmartRollupAddressError(address, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SR1}'.`);
|
|
2318
|
-
}
|
|
2319
|
-
return address;
|
|
990
|
+
return prefixDecoder(PrefixV2.SmartRollupHash)(val);
|
|
2320
991
|
};
|
|
2321
992
|
const smartContractAddressDecoder = (val) => {
|
|
2322
993
|
const preamble = val.consume(1);
|
|
2323
994
|
if (preamble[0] === 0x01) {
|
|
2324
|
-
const scAddress = prefixDecoder(
|
|
995
|
+
const scAddress = prefixDecoder(PrefixV2.ContractHash)(val);
|
|
2325
996
|
val.consume(1);
|
|
2326
997
|
return scAddress;
|
|
2327
998
|
}
|
|
2328
|
-
throw new InvalidContractAddressError(val.toString(),
|
|
999
|
+
throw new InvalidContractAddressError(val.toString(), ValidationResult.NO_PREFIX_MATCHED);
|
|
2329
1000
|
};
|
|
2330
1001
|
const smartRollupCommitmentHashDecoder = (val) => {
|
|
2331
|
-
|
|
2332
|
-
if (address.substring(0, 4) !== Prefix.SRC1) {
|
|
2333
|
-
throw new InvalidSmartRollupCommitmentHashError(address, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SRC1}'`);
|
|
2334
|
-
}
|
|
2335
|
-
return address;
|
|
1002
|
+
return prefixDecoder(PrefixV2.SmartRollupCommitmentHash)(val);
|
|
2336
1003
|
};
|
|
2337
1004
|
const zarithEncoder = (n) => {
|
|
2338
1005
|
const fn = [];
|
|
@@ -2430,8 +1097,8 @@ const valueParameterDecoder = (val) => {
|
|
|
2430
1097
|
const value = extractRequiredLen(val);
|
|
2431
1098
|
return valueDecoder(new Uint8ArrayConsumer(value));
|
|
2432
1099
|
};
|
|
2433
|
-
const blockPayloadHashEncoder = prefixEncoder(
|
|
2434
|
-
const blockPayloadHashDecoder = prefixDecoder(
|
|
1100
|
+
const blockPayloadHashEncoder = prefixEncoder(PrefixV2.ValueHash);
|
|
1101
|
+
const blockPayloadHashDecoder = prefixDecoder(PrefixV2.ValueHash);
|
|
2435
1102
|
const entrypointNameEncoder = (entrypoint) => {
|
|
2436
1103
|
const value = { string: entrypoint };
|
|
2437
1104
|
return `${valueEncoder(value).slice(2)}`;
|
|
@@ -2459,28 +1126,31 @@ const depositsLimitDecoder = (value) => {
|
|
|
2459
1126
|
}
|
|
2460
1127
|
};
|
|
2461
1128
|
const signatureV1Encoder = (val) => {
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
return paddedBytesEncoder(
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
throw new InvalidSignatureError(val,
|
|
2474
|
-
|
|
1129
|
+
try {
|
|
1130
|
+
const [data, pre] = b58DecodeAndCheckPrefix(val, signaturePrefixes);
|
|
1131
|
+
if (pre === PrefixV2.BLS12_381Signature) {
|
|
1132
|
+
return paddedBytesEncoder(buf2hex(data));
|
|
1133
|
+
}
|
|
1134
|
+
else {
|
|
1135
|
+
throw new ProhibitedActionError('we only support encoding of BLSIG signatures from protocol Seoul');
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
catch (err) {
|
|
1139
|
+
if (err instanceof ParameterValidationError) {
|
|
1140
|
+
throw new InvalidSignatureError(val, err.result);
|
|
1141
|
+
}
|
|
1142
|
+
else {
|
|
1143
|
+
throw err;
|
|
1144
|
+
}
|
|
2475
1145
|
}
|
|
2476
1146
|
};
|
|
2477
1147
|
const signatureV1Decoder = (val) => {
|
|
2478
1148
|
val.consume(4);
|
|
2479
1149
|
if (val.length().toString() === '96') {
|
|
2480
|
-
return prefixDecoder(
|
|
1150
|
+
return prefixDecoder(PrefixV2.BLS12_381Signature)(val);
|
|
2481
1151
|
}
|
|
2482
1152
|
else {
|
|
2483
|
-
throw new ProhibitedActionError('
|
|
1153
|
+
throw new ProhibitedActionError('we only support decoding of BLSIG signatures');
|
|
2484
1154
|
}
|
|
2485
1155
|
};
|
|
2486
1156
|
const signatureProofEncoder = (val) => {
|
|
@@ -2516,18 +1186,20 @@ const smartRollupMessageDecoder = (val) => {
|
|
|
2516
1186
|
return ret.map((value) => Buffer.from(value).toString('hex'));
|
|
2517
1187
|
};
|
|
2518
1188
|
const dalCommitmentEncoder = (val) => {
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
1189
|
+
try {
|
|
1190
|
+
return prefixEncoder(PrefixV2.SlotHeader)(val);
|
|
1191
|
+
}
|
|
1192
|
+
catch (err) {
|
|
1193
|
+
if (err instanceof ParameterValidationError) {
|
|
1194
|
+
throw new InvalidDalCommitmentError(val);
|
|
1195
|
+
}
|
|
1196
|
+
else {
|
|
1197
|
+
throw err;
|
|
1198
|
+
}
|
|
2522
1199
|
}
|
|
2523
|
-
throw new InvalidDalCommitmentError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SH}'`);
|
|
2524
1200
|
};
|
|
2525
1201
|
const dalCommitmentDecoder = (val) => {
|
|
2526
|
-
|
|
2527
|
-
if (commitment.substring(0, 2) !== Prefix.SH) {
|
|
2528
|
-
throw new InvalidDalCommitmentError(commitment, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SH}'`);
|
|
2529
|
-
}
|
|
2530
|
-
return commitment;
|
|
1202
|
+
return prefixDecoder(PrefixV2.SlotHeader)(val);
|
|
2531
1203
|
};
|
|
2532
1204
|
const slotHeaderEncoder = (val) => {
|
|
2533
1205
|
return pad(val.slot_index, 2) + dalCommitmentEncoder(val.commitment) + val.commitment_proof;
|
|
@@ -2556,6 +1228,7 @@ const RevealSchema = {
|
|
|
2556
1228
|
gas_limit: CODEC.ZARITH,
|
|
2557
1229
|
storage_limit: CODEC.ZARITH,
|
|
2558
1230
|
public_key: CODEC.PUBLIC_KEY,
|
|
1231
|
+
proof: CODEC.SIGNATURE_PROOF,
|
|
2559
1232
|
};
|
|
2560
1233
|
const DelegationSchema = {
|
|
2561
1234
|
source: CODEC.PKH,
|
|
@@ -2652,6 +1325,15 @@ const UpdateConsensusKeySchema = {
|
|
|
2652
1325
|
pk: CODEC.PUBLIC_KEY,
|
|
2653
1326
|
proof: CODEC.SIGNATURE_PROOF,
|
|
2654
1327
|
};
|
|
1328
|
+
const UpdateCompanionKeySchema = {
|
|
1329
|
+
source: CODEC.PKH,
|
|
1330
|
+
fee: CODEC.ZARITH,
|
|
1331
|
+
counter: CODEC.ZARITH,
|
|
1332
|
+
gas_limit: CODEC.ZARITH,
|
|
1333
|
+
storage_limit: CODEC.ZARITH,
|
|
1334
|
+
pk: CODEC.PUBLIC_KEY,
|
|
1335
|
+
proof: CODEC.SIGNATURE_PROOF,
|
|
1336
|
+
};
|
|
2655
1337
|
const DrainDelegateSchema = {
|
|
2656
1338
|
consensus_key: CODEC.PKH,
|
|
2657
1339
|
delegate: CODEC.PKH,
|
|
@@ -2818,6 +1500,7 @@ decoders[CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaDecoder(decoders)(R
|
|
|
2818
1500
|
decoders[CODEC.OP_TRANSFER_TICKET] = (val) => schemaDecoder(decoders)(TransferTicketSchema)(val);
|
|
2819
1501
|
decoders[CODEC.OP_INCREASE_PAID_STORAGE] = (val) => schemaDecoder(decoders)(IncreasePaidStorageSchema)(val);
|
|
2820
1502
|
decoders[CODEC.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaDecoder(decoders)(UpdateConsensusKeySchema)(val);
|
|
1503
|
+
decoders[CODEC.OP_UPDATE_COMPANION_KEY] = (val) => schemaDecoder(decoders)(UpdateCompanionKeySchema)(val);
|
|
2821
1504
|
decoders[CODEC.OP_DRAIN_DELEGATE] = (val) => schemaDecoder(decoders)(DrainDelegateSchema)(val);
|
|
2822
1505
|
decoders[CODEC.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaDecoder(decoders)(SmartRollupOriginateSchema)(val);
|
|
2823
1506
|
decoders[CODEC.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaDecoder(decoders)(SmartRollupAddMessagesSchema)(val);
|
|
@@ -2826,63 +1509,6 @@ decoders[CODEC.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaDecoder(decoders)(Dal
|
|
|
2826
1509
|
decoders[CODEC.MANAGER] = schemaDecoder(decoders)(ManagerOperationSchema);
|
|
2827
1510
|
decoders[CODEC.OP_SET_DEPOSITS_LIMIT] = (val) => schemaDecoder(decoders)(SetDepositsLimitSchema)(val);
|
|
2828
1511
|
|
|
2829
|
-
const encoders$1 = {
|
|
2830
|
-
[CODEC$1.SECRET]: (val) => val,
|
|
2831
|
-
[CODEC$1.RAW]: (val) => val,
|
|
2832
|
-
[CODEC$1.TZ1]: tz1Encoder$1,
|
|
2833
|
-
[CODEC$1.BRANCH]: branchEncoder$1,
|
|
2834
|
-
[CODEC$1.ZARITH]: zarithEncoder$1,
|
|
2835
|
-
[CODEC$1.PUBLIC_KEY]: publicKeyEncoder$1,
|
|
2836
|
-
[CODEC$1.PKH]: publicKeyHashEncoder$1,
|
|
2837
|
-
[CODEC$1.PKH_ARR]: publicKeyHashesEncoder$1,
|
|
2838
|
-
[CODEC$1.DELEGATE]: delegateEncoder$1,
|
|
2839
|
-
[CODEC$1.SCRIPT]: scriptEncoder$1,
|
|
2840
|
-
[CODEC$1.BALLOT_STATEMENT]: ballotEncoder$1,
|
|
2841
|
-
[CODEC$1.PROPOSAL]: proposalEncoder$1,
|
|
2842
|
-
[CODEC$1.PROPOSAL_ARR]: proposalsEncoder$1,
|
|
2843
|
-
[CODEC$1.INT32]: int32Encoder$1,
|
|
2844
|
-
[CODEC$1.PARAMETERS]: parametersEncoder$1,
|
|
2845
|
-
[CODEC$1.ADDRESS]: addressEncoder$1,
|
|
2846
|
-
[CODEC$1.SMART_ROLLUP_ADDRESS]: smartRollupAddressEncoder$1,
|
|
2847
|
-
[CODEC$1.SMART_CONTRACT_ADDRESS]: smartContractAddressEncoder$1,
|
|
2848
|
-
[CODEC$1.SMART_ROLLUP_COMMITMENT_HASH]: smartRollupCommitmentHashEncoder$1,
|
|
2849
|
-
[CODEC$1.VALUE]: valueParameterEncoder$1,
|
|
2850
|
-
[CODEC$1.INT16]: int16Encoder$1,
|
|
2851
|
-
[CODEC$1.BLOCK_PAYLOAD_HASH]: blockPayloadHashEncoder$1,
|
|
2852
|
-
[CODEC$1.ENTRYPOINT]: entrypointNameEncoder$1,
|
|
2853
|
-
[CODEC$1.BURN_LIMIT]: burnLimitEncoder$1,
|
|
2854
|
-
[CODEC$1.DEPOSITS_LIMIT]: depositsLimitEncoder$1,
|
|
2855
|
-
[CODEC$1.SIGNATURE_PROOF]: signatureProofEncoder$1,
|
|
2856
|
-
[CODEC$1.PVM_KIND]: pvmKindEncoder$1,
|
|
2857
|
-
[CODEC$1.PADDED_BYTES]: paddedBytesEncoder$1,
|
|
2858
|
-
[CODEC$1.SMART_ROLLUP_MESSAGE]: smartRollupMessageEncoder$1,
|
|
2859
|
-
[CODEC$1.SLOT_HEADER]: slotHeaderEncoder$1,
|
|
2860
|
-
};
|
|
2861
|
-
encoders$1[CODEC$1.OPERATION] = operationEncoder$1(encoders$1);
|
|
2862
|
-
encoders$1[CODEC$1.OP_ACTIVATE_ACCOUNT] = (val) => schemaEncoder$1(encoders$1)(ActivationSchema$1)(val);
|
|
2863
|
-
encoders$1[CODEC$1.OP_DELEGATION] = (val) => schemaEncoder$1(encoders$1)(DelegationSchema$1)(val);
|
|
2864
|
-
encoders$1[CODEC$1.OP_TRANSACTION] = (val) => schemaEncoder$1(encoders$1)(TransactionSchema$1)(val);
|
|
2865
|
-
encoders$1[CODEC$1.OP_ORIGINATION] = (val) => schemaEncoder$1(encoders$1)(OriginationSchema$1)(val);
|
|
2866
|
-
encoders$1[CODEC$1.OP_BALLOT] = (val) => schemaEncoder$1(encoders$1)(BallotSchema$1)(val);
|
|
2867
|
-
encoders$1[CODEC$1.OP_ATTESTATION] = (val) => schemaEncoder$1(encoders$1)(AttestationSchema$1)(val);
|
|
2868
|
-
encoders$1[CODEC$1.OP_ATTESTATION_WITH_DAL] = (val) => schemaEncoder$1(encoders$1)(AttestationWithDalSchema$1)(val);
|
|
2869
|
-
encoders$1[CODEC$1.OP_SEED_NONCE_REVELATION] = (val) => schemaEncoder$1(encoders$1)(SeedNonceRevelationSchema$1)(val);
|
|
2870
|
-
encoders$1[CODEC$1.OP_PROPOSALS] = (val) => schemaEncoder$1(encoders$1)(ProposalsSchema$1)(val);
|
|
2871
|
-
encoders$1[CODEC$1.OP_REVEAL] = (val) => schemaEncoder$1(encoders$1)(RevealSchema$1)(val);
|
|
2872
|
-
encoders$1[CODEC$1.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaEncoder$1(encoders$1)(RegisterGlobalConstantSchema$1)(val);
|
|
2873
|
-
encoders$1[CODEC$1.OP_TRANSFER_TICKET] = (val) => schemaEncoder$1(encoders$1)(TransferTicketSchema$1)(val);
|
|
2874
|
-
encoders$1[CODEC$1.OP_INCREASE_PAID_STORAGE] = (val) => schemaEncoder$1(encoders$1)(IncreasePaidStorageSchema$1)(val);
|
|
2875
|
-
encoders$1[CODEC$1.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaEncoder$1(encoders$1)(UpdateConsensusKeySchema$1)(val);
|
|
2876
|
-
encoders$1[CODEC$1.OP_UPDATE_COMPANION_KEY] = (val) => schemaEncoder$1(encoders$1)(UpdateCompanionKeySchema)(val);
|
|
2877
|
-
encoders$1[CODEC$1.OP_DRAIN_DELEGATE] = (val) => schemaEncoder$1(encoders$1)(DrainDelegateSchema$1)(val);
|
|
2878
|
-
encoders$1[CODEC$1.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaEncoder$1(encoders$1)(SmartRollupOriginateSchema$1)(val);
|
|
2879
|
-
encoders$1[CODEC$1.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaEncoder$1(encoders$1)(SmartRollupAddMessagesSchema$1)(val);
|
|
2880
|
-
encoders$1[CODEC$1.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaEncoder$1(encoders$1)(SmartRollupExecuteOutboxMessageSchema$1)(val);
|
|
2881
|
-
encoders$1[CODEC$1.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaEncoder$1(encoders$1)(DalPublishCommitmentSchema$1)(val);
|
|
2882
|
-
encoders$1[CODEC$1.MANAGER] = schemaEncoder$1(encoders$1)(ManagerOperationSchema$1);
|
|
2883
|
-
encoders$1[CODEC$1.OP_SET_DEPOSITS_LIMIT] = (val) => schemaEncoder$1(encoders$1)(SetDepositsLimitSchema$1)(val);
|
|
2884
|
-
encoders$1[CODEC$1.OP_FAILING_NOOP] = (val) => schemaEncoder$1(encoders$1)(FailingNoopSchema$1)(val);
|
|
2885
|
-
|
|
2886
1512
|
const encoders = {
|
|
2887
1513
|
[CODEC.SECRET]: (val) => val,
|
|
2888
1514
|
[CODEC.RAW]: (val) => val,
|
|
@@ -2930,6 +1556,7 @@ encoders[CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaEncoder(encoders)(R
|
|
|
2930
1556
|
encoders[CODEC.OP_TRANSFER_TICKET] = (val) => schemaEncoder(encoders)(TransferTicketSchema)(val);
|
|
2931
1557
|
encoders[CODEC.OP_INCREASE_PAID_STORAGE] = (val) => schemaEncoder(encoders)(IncreasePaidStorageSchema)(val);
|
|
2932
1558
|
encoders[CODEC.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaEncoder(encoders)(UpdateConsensusKeySchema)(val);
|
|
1559
|
+
encoders[CODEC.OP_UPDATE_COMPANION_KEY] = (val) => schemaEncoder(encoders)(UpdateCompanionKeySchema)(val);
|
|
2933
1560
|
encoders[CODEC.OP_DRAIN_DELEGATE] = (val) => schemaEncoder(encoders)(DrainDelegateSchema)(val);
|
|
2934
1561
|
encoders[CODEC.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaEncoder(encoders)(SmartRollupOriginateSchema)(val);
|
|
2935
1562
|
encoders[CODEC.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaEncoder(encoders)(SmartRollupAddMessagesSchema)(val);
|
|
@@ -2940,28 +1567,28 @@ encoders[CODEC.OP_SET_DEPOSITS_LIMIT] = (val) => schemaEncoder(encoders)(SetDepo
|
|
|
2940
1567
|
encoders[CODEC.OP_FAILING_NOOP] = (val) => schemaEncoder(encoders)(FailingNoopSchema)(val);
|
|
2941
1568
|
|
|
2942
1569
|
const OperationKindMapping = {
|
|
2943
|
-
activate_account: ActivationSchema
|
|
2944
|
-
reveal: RevealSchema
|
|
2945
|
-
delegation: DelegationSchema
|
|
2946
|
-
transaction: TransactionSchema
|
|
2947
|
-
origination: OriginationSchema
|
|
2948
|
-
ballot: BallotSchema
|
|
2949
|
-
attestation: AttestationSchema
|
|
2950
|
-
attestation_with_dal: AttestationWithDalSchema
|
|
2951
|
-
seed_nonce_revelation: SeedNonceRevelationSchema
|
|
2952
|
-
proposals: ProposalsSchema
|
|
2953
|
-
register_global_constant: RegisterGlobalConstantSchema
|
|
2954
|
-
transfer_ticket: TransferTicketSchema
|
|
2955
|
-
increase_paid_storage: IncreasePaidStorageSchema
|
|
2956
|
-
update_consensus_key: UpdateConsensusKeySchema
|
|
1570
|
+
activate_account: ActivationSchema,
|
|
1571
|
+
reveal: RevealSchema,
|
|
1572
|
+
delegation: DelegationSchema,
|
|
1573
|
+
transaction: TransactionSchema,
|
|
1574
|
+
origination: OriginationSchema,
|
|
1575
|
+
ballot: BallotSchema,
|
|
1576
|
+
attestation: AttestationSchema,
|
|
1577
|
+
attestation_with_dal: AttestationWithDalSchema,
|
|
1578
|
+
seed_nonce_revelation: SeedNonceRevelationSchema,
|
|
1579
|
+
proposals: ProposalsSchema,
|
|
1580
|
+
register_global_constant: RegisterGlobalConstantSchema,
|
|
1581
|
+
transfer_ticket: TransferTicketSchema,
|
|
1582
|
+
increase_paid_storage: IncreasePaidStorageSchema,
|
|
1583
|
+
update_consensus_key: UpdateConsensusKeySchema,
|
|
2957
1584
|
update_companion_key: UpdateCompanionKeySchema,
|
|
2958
|
-
drain_delegate: DrainDelegateSchema
|
|
2959
|
-
set_deposits_limit: SetDepositsLimitSchema
|
|
2960
|
-
smart_rollup_originate: SmartRollupOriginateSchema
|
|
2961
|
-
smart_rollup_add_messages: SmartRollupAddMessagesSchema
|
|
2962
|
-
smart_rollup_execute_outbox_message: SmartRollupExecuteOutboxMessageSchema
|
|
2963
|
-
dal_publish_commitment: DalPublishCommitmentSchema
|
|
2964
|
-
failing_noop: FailingNoopSchema
|
|
1585
|
+
drain_delegate: DrainDelegateSchema,
|
|
1586
|
+
set_deposits_limit: SetDepositsLimitSchema,
|
|
1587
|
+
smart_rollup_originate: SmartRollupOriginateSchema,
|
|
1588
|
+
smart_rollup_add_messages: SmartRollupAddMessagesSchema,
|
|
1589
|
+
smart_rollup_execute_outbox_message: SmartRollupExecuteOutboxMessageSchema,
|
|
1590
|
+
dal_publish_commitment: DalPublishCommitmentSchema,
|
|
1591
|
+
failing_noop: FailingNoopSchema,
|
|
2965
1592
|
};
|
|
2966
1593
|
// Asymmetric difference: only account for things in arr2 that are not present in arr1, not vice versa
|
|
2967
1594
|
const getArrayDifference = (arr1, arr2) => {
|
|
@@ -3017,39 +1644,11 @@ var ProtocolsHash;
|
|
|
3017
1644
|
ProtocolsHash["PtSeouLou"] = "PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh";
|
|
3018
1645
|
ProtocolsHash["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
|
|
3019
1646
|
})(ProtocolsHash || (ProtocolsHash = {}));
|
|
3020
|
-
const protoLevel = {
|
|
3021
|
-
Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd: 4,
|
|
3022
|
-
PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU: 5,
|
|
3023
|
-
PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS: 5,
|
|
3024
|
-
PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb: 6,
|
|
3025
|
-
PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo: 7,
|
|
3026
|
-
PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA: 8,
|
|
3027
|
-
PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i: 9,
|
|
3028
|
-
PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV: 10,
|
|
3029
|
-
PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx: 11,
|
|
3030
|
-
Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A: 12,
|
|
3031
|
-
PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY: 13,
|
|
3032
|
-
PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg: 14,
|
|
3033
|
-
PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW: 15,
|
|
3034
|
-
PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc: 16,
|
|
3035
|
-
PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1: 16,
|
|
3036
|
-
PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf: 17,
|
|
3037
|
-
ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH: 19,
|
|
3038
|
-
PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ: 20,
|
|
3039
|
-
PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi: 20,
|
|
3040
|
-
PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg: 21,
|
|
3041
|
-
PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7: 22,
|
|
3042
|
-
PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh: 23,
|
|
3043
|
-
ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK: 23,
|
|
3044
|
-
};
|
|
3045
|
-
function ProtoInferiorTo(a, b) {
|
|
3046
|
-
return protoLevel[a] < protoLevel[b];
|
|
3047
|
-
}
|
|
3048
1647
|
|
|
3049
1648
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
3050
1649
|
const VERSION = {
|
|
3051
|
-
"commitHash": "
|
|
3052
|
-
"version": "23.0
|
|
1650
|
+
"commitHash": "c77fe4b0989665d8b5cfd15a7cc977499021f6fd",
|
|
1651
|
+
"version": "23.1.0"
|
|
3053
1652
|
};
|
|
3054
1653
|
|
|
3055
1654
|
/**
|
|
@@ -3064,38 +1663,18 @@ if (typeof globalThis.TextDecoder === 'undefined') {
|
|
|
3064
1663
|
}
|
|
3065
1664
|
const PROTOCOL_CURRENT = ProtocolsHash.PtSeouLou;
|
|
3066
1665
|
function getCodec(codec, _proto) {
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
},
|
|
3075
|
-
};
|
|
3076
|
-
}
|
|
3077
|
-
else {
|
|
3078
|
-
return {
|
|
3079
|
-
encoder: encoders$1[codec],
|
|
3080
|
-
decoder: (hex) => {
|
|
3081
|
-
const consumer = Uint8ArrayConsumer.fromHexString(hex);
|
|
3082
|
-
return decoders$1[codec](consumer);
|
|
3083
|
-
},
|
|
3084
|
-
};
|
|
3085
|
-
}
|
|
3086
|
-
// TODO: Remove above if else once mainnet migrated into rio protocol and uncommon the return block below
|
|
3087
|
-
// return {
|
|
3088
|
-
// encoder: encoders[codec],
|
|
3089
|
-
// decoder: (hex: string) => {
|
|
3090
|
-
// const consumer = Uint8ArrayConsumer.fromHexString(hex);
|
|
3091
|
-
// return decoders[codec](consumer) as any;
|
|
3092
|
-
// },
|
|
3093
|
-
// };
|
|
1666
|
+
return {
|
|
1667
|
+
encoder: encoders[codec],
|
|
1668
|
+
decoder: (hex) => {
|
|
1669
|
+
const consumer = Uint8ArrayConsumer.fromHexString(hex);
|
|
1670
|
+
return decoders[codec](consumer);
|
|
1671
|
+
},
|
|
1672
|
+
};
|
|
3094
1673
|
}
|
|
3095
1674
|
class LocalForger {
|
|
3096
1675
|
constructor(protocolHash = PROTOCOL_CURRENT) {
|
|
3097
1676
|
this.protocolHash = protocolHash;
|
|
3098
|
-
this.codec = getCodec(CODEC
|
|
1677
|
+
this.codec = getCodec(CODEC.MANAGER, this.protocolHash);
|
|
3099
1678
|
}
|
|
3100
1679
|
forge(params) {
|
|
3101
1680
|
const branchValidation = validateBlock(params.branch);
|
|
@@ -3149,5 +1728,5 @@ class LocalForger {
|
|
|
3149
1728
|
}
|
|
3150
1729
|
const localForger = new LocalForger();
|
|
3151
1730
|
|
|
3152
|
-
export { CODEC
|
|
1731
|
+
export { CODEC, LocalForger, ProtocolsHash, Uint8ArrayConsumer, VERSION, decoders, encoders, getCodec, localForger, opMapping, opMappingReverse };
|
|
3153
1732
|
//# sourceMappingURL=taquito-local-forging.es6.js.map
|