@taquito/local-forging 22.0.0 → 23.0.0-RC.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/{codec-proto021.js → codec-proto022.js} +71 -23
- package/dist/lib/codec.js +87 -110
- package/dist/lib/{constants-proto021.js → constants-proto022.js} +1 -0
- package/dist/lib/constants.js +3 -0
- package/dist/lib/decoder-proto022.js +63 -0
- package/dist/lib/decoder.js +1 -0
- package/dist/lib/encoder-proto022.js +62 -0
- package/dist/lib/encoder.js +1 -0
- package/dist/lib/michelson/codec-proto022.js +283 -0
- package/dist/lib/protocols.js +2 -0
- package/dist/lib/schema/operation-proto022.js +238 -0
- package/dist/lib/schema/operation.js +11 -1
- package/dist/lib/taquito-local-forging.js +14 -8
- package/dist/lib/validator-proto022.js +56 -0
- package/dist/lib/validator.js +1 -0
- package/dist/lib/version.js +2 -2
- package/dist/taquito-local-forging.es6.js +606 -302
- package/dist/taquito-local-forging.es6.js.map +1 -1
- package/dist/taquito-local-forging.umd.js +604 -300
- package/dist/taquito-local-forging.umd.js.map +1 -1
- package/dist/types/{codec-proto021.d.ts → codec-proto022.d.ts} +3 -1
- package/dist/types/codec.d.ts +3 -3
- package/dist/types/{constants-proto021.d.ts → constants-proto022.d.ts} +1 -0
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/{decoder-proto021.d.ts → decoder-proto022.d.ts} +1 -1
- package/dist/types/{encoder-proto021.d.ts → encoder-proto022.d.ts} +1 -1
- package/dist/types/michelson/codec-proto022.d.ts +49 -0
- package/dist/types/michelson/codec.d.ts +1 -1
- package/dist/types/protocols.d.ts +1 -0
- package/dist/types/schema/{operation-proto021.d.ts → operation-proto022.d.ts} +3 -2
- package/dist/types/schema/operation.d.ts +10 -0
- package/dist/types/taquito-local-forging.d.ts +3 -3
- package/dist/types/validator-proto022.d.ts +13 -0
- package/package.json +5 -5
- package/dist/lib/decoder-proto021.js +0 -62
- package/dist/lib/encoder-proto021.js +0 -61
- package/dist/lib/schema/operation-proto021.js +0 -237
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ParameterValidationError, InvalidHexStringError, InvalidAddressError, InvalidContractAddressError,
|
|
1
|
+
import { PrefixV2, b58DecodeAndCheckPrefix, buf2hex, payloadLength, b58Encode, b58DecodePublicKeyHash, b58DecodePublicKey, InvalidPublicKeyError, b58DecodeAddress, ValidationResult, signaturePrefixes, Prefix, b58cdecode, prefix, prefixLength, b58cencode, InvalidKeyHashError as InvalidKeyHashError$1, invalidDetail, validateBlock } from '@taquito/utils';
|
|
2
|
+
import { ParameterValidationError, InvalidHexStringError, InvalidKeyHashError, InvalidAddressError, InvalidContractAddressError, ProhibitedActionError, InvalidSignatureError, InvalidOperationKindError, InvalidBlockHashError } from '@taquito/core';
|
|
3
3
|
import BigNumber$1, { BigNumber } from 'bignumber.js';
|
|
4
4
|
|
|
5
5
|
const toHexString = (bytes) => bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
|
|
@@ -58,6 +58,7 @@ var CODEC$1;
|
|
|
58
58
|
CODEC["BURN_LIMIT"] = "burn_limit";
|
|
59
59
|
CODEC["OP_INCREASE_PAID_STORAGE"] = "increase_paid_storage";
|
|
60
60
|
CODEC["OP_UPDATE_CONSENSUS_KEY"] = "update_consensus_key";
|
|
61
|
+
CODEC["OP_UPDATE_COMPANION_KEY"] = "update_companion_key";
|
|
61
62
|
CODEC["SIGNATURE_PROOF"] = "signature_proof";
|
|
62
63
|
CODEC["OP_DRAIN_DELEGATE"] = "drain_delegate";
|
|
63
64
|
CODEC["DEPOSITS_LIMIT"] = "deposits_limit";
|
|
@@ -229,8 +230,9 @@ const opMapping$1 = {
|
|
|
229
230
|
'9b': 'BYTES',
|
|
230
231
|
'9c': 'NAT',
|
|
231
232
|
'9d': 'Ticket',
|
|
233
|
+
'9e': 'IS_IMPLICIT_ACCOUNT',
|
|
232
234
|
};
|
|
233
|
-
const opMappingReverse = (() => {
|
|
235
|
+
const opMappingReverse$1 = (() => {
|
|
234
236
|
const result = {};
|
|
235
237
|
Object.keys(opMapping$1).forEach((key) => {
|
|
236
238
|
result[opMapping$1[key]] = key;
|
|
@@ -254,6 +256,7 @@ const kindMapping$1 = {
|
|
|
254
256
|
0x70: 'set_deposits_limit',
|
|
255
257
|
0x71: 'increase_paid_storage',
|
|
256
258
|
0x72: 'update_consensus_key',
|
|
259
|
+
0x73: 'update_companion_key',
|
|
257
260
|
0x09: 'drain_delegate',
|
|
258
261
|
0xc8: 'smart_rollup_originate',
|
|
259
262
|
0xc9: 'smart_rollup_add_messages',
|
|
@@ -483,73 +486,73 @@ class Uint8ArrayConsumer {
|
|
|
483
486
|
}
|
|
484
487
|
}
|
|
485
488
|
|
|
486
|
-
const isPrim = (value) => {
|
|
489
|
+
const isPrim$1 = (value) => {
|
|
487
490
|
return 'prim' in value;
|
|
488
491
|
};
|
|
489
|
-
const isBytes = (value) => {
|
|
492
|
+
const isBytes$1 = (value) => {
|
|
490
493
|
return 'bytes' in value && typeof value.bytes === 'string';
|
|
491
494
|
};
|
|
492
|
-
const isString = (value) => {
|
|
495
|
+
const isString$1 = (value) => {
|
|
493
496
|
return 'string' in value && typeof value.string === 'string';
|
|
494
497
|
};
|
|
495
|
-
const isInt = (value) => {
|
|
498
|
+
const isInt$1 = (value) => {
|
|
496
499
|
return 'int' in value && typeof value.int === 'string';
|
|
497
500
|
};
|
|
498
|
-
const scriptEncoder = (script) => {
|
|
499
|
-
const code = valueEncoder(script.code);
|
|
500
|
-
const storage = valueEncoder(script.storage);
|
|
501
|
+
const scriptEncoder$1 = (script) => {
|
|
502
|
+
const code = valueEncoder$1(script.code);
|
|
503
|
+
const storage = valueEncoder$1(script.storage);
|
|
501
504
|
return `${pad(code.length / 2, 8)}${code}${pad(storage.length / 2, 8)}${storage}`;
|
|
502
505
|
};
|
|
503
|
-
const scriptDecoder = (value) => {
|
|
504
|
-
const code = extractRequiredLen(value);
|
|
505
|
-
const storage = extractRequiredLen(value);
|
|
506
|
+
const scriptDecoder$1 = (value) => {
|
|
507
|
+
const code = extractRequiredLen$1(value);
|
|
508
|
+
const storage = extractRequiredLen$1(value);
|
|
506
509
|
return {
|
|
507
|
-
code: valueDecoder(new Uint8ArrayConsumer(code)),
|
|
508
|
-
storage: valueDecoder(new Uint8ArrayConsumer(storage)),
|
|
510
|
+
code: valueDecoder$1(new Uint8ArrayConsumer(code)),
|
|
511
|
+
storage: valueDecoder$1(new Uint8ArrayConsumer(storage)),
|
|
509
512
|
};
|
|
510
513
|
};
|
|
511
|
-
const valueEncoder = (value) => {
|
|
514
|
+
const valueEncoder$1 = (value) => {
|
|
512
515
|
if (Array.isArray(value)) {
|
|
513
|
-
const encoded = value.map((x) => valueEncoder(x)).join('');
|
|
516
|
+
const encoded = value.map((x) => valueEncoder$1(x)).join('');
|
|
514
517
|
const len = encoded.length / 2;
|
|
515
518
|
return `02${pad(len)}${encoded}`;
|
|
516
519
|
}
|
|
517
|
-
else if (isPrim(value)) {
|
|
518
|
-
return primEncoder(value);
|
|
520
|
+
else if (isPrim$1(value)) {
|
|
521
|
+
return primEncoder$1(value);
|
|
519
522
|
}
|
|
520
|
-
else if (isBytes(value)) {
|
|
521
|
-
return bytesEncoder(value);
|
|
523
|
+
else if (isBytes$1(value)) {
|
|
524
|
+
return bytesEncoder$1(value);
|
|
522
525
|
}
|
|
523
|
-
else if (isString(value)) {
|
|
524
|
-
return stringEncoder(value);
|
|
526
|
+
else if (isString$1(value)) {
|
|
527
|
+
return stringEncoder$1(value);
|
|
525
528
|
}
|
|
526
|
-
else if (isInt(value)) {
|
|
527
|
-
return intEncoder(value);
|
|
529
|
+
else if (isInt$1(value)) {
|
|
530
|
+
return intEncoder$1(value);
|
|
528
531
|
}
|
|
529
532
|
throw new UnexpectedMichelsonValueError(JSON.stringify(value));
|
|
530
533
|
};
|
|
531
|
-
const valueDecoder = (value) => {
|
|
534
|
+
const valueDecoder$1 = (value) => {
|
|
532
535
|
const preamble = value.consume(1);
|
|
533
536
|
switch (preamble[0]) {
|
|
534
537
|
case 0x0a:
|
|
535
|
-
return bytesDecoder(value);
|
|
538
|
+
return bytesDecoder$1(value);
|
|
536
539
|
case 0x01:
|
|
537
|
-
return stringDecoder(value);
|
|
540
|
+
return stringDecoder$1(value);
|
|
538
541
|
case 0x00:
|
|
539
|
-
return intDecoder(value);
|
|
542
|
+
return intDecoder$1(value);
|
|
540
543
|
case 0x02: {
|
|
541
|
-
const val = new Uint8ArrayConsumer(extractRequiredLen(value));
|
|
544
|
+
const val = new Uint8ArrayConsumer(extractRequiredLen$1(value));
|
|
542
545
|
const results = [];
|
|
543
546
|
while (val.length() > 0) {
|
|
544
|
-
results.push(valueDecoder(val));
|
|
547
|
+
results.push(valueDecoder$1(val));
|
|
545
548
|
}
|
|
546
549
|
return results;
|
|
547
550
|
}
|
|
548
551
|
default:
|
|
549
|
-
return primDecoder(value, preamble);
|
|
552
|
+
return primDecoder$1(value, preamble);
|
|
550
553
|
}
|
|
551
554
|
};
|
|
552
|
-
const extractRequiredLen = (value, bytesLength = 4) => {
|
|
555
|
+
const extractRequiredLen$1 = (value, bytesLength = 4) => {
|
|
553
556
|
const len = value.consume(bytesLength);
|
|
554
557
|
const valueLen = parseInt(Buffer.from(len).toString('hex'), 16);
|
|
555
558
|
return value.consume(valueLen);
|
|
@@ -560,7 +563,7 @@ const extractRequiredLen = (value, bytesLength = 4) => {
|
|
|
560
563
|
* @param bytesLength default 4 bytes for length of variable bytes
|
|
561
564
|
* @returns array of Uint8Array values for each array item
|
|
562
565
|
*/
|
|
563
|
-
const stripLengthPrefixFromBytes = (value, bytesLength = 4) => {
|
|
566
|
+
const stripLengthPrefixFromBytes$1 = (value, bytesLength = 4) => {
|
|
564
567
|
const ret = [];
|
|
565
568
|
let values = value;
|
|
566
569
|
while (values.length()) {
|
|
@@ -571,31 +574,31 @@ const stripLengthPrefixFromBytes = (value, bytesLength = 4) => {
|
|
|
571
574
|
}
|
|
572
575
|
return ret;
|
|
573
576
|
};
|
|
574
|
-
const bytesEncoder = (value) => {
|
|
577
|
+
const bytesEncoder$1 = (value) => {
|
|
575
578
|
if (!/^([A-Fa-f0-9]{2})*$/.test(value.bytes)) {
|
|
576
579
|
throw new InvalidHexStringError(value.bytes);
|
|
577
580
|
}
|
|
578
581
|
const len = value.bytes.length / 2;
|
|
579
582
|
return `0a${pad(len)}${value.bytes}`;
|
|
580
583
|
};
|
|
581
|
-
const bytesDecoder = (value) => {
|
|
582
|
-
const bytes = extractRequiredLen(value);
|
|
584
|
+
const bytesDecoder$1 = (value) => {
|
|
585
|
+
const bytes = extractRequiredLen$1(value);
|
|
583
586
|
return {
|
|
584
587
|
bytes: Buffer.from(bytes).toString('hex'),
|
|
585
588
|
};
|
|
586
589
|
};
|
|
587
|
-
const stringEncoder = (value) => {
|
|
590
|
+
const stringEncoder$1 = (value) => {
|
|
588
591
|
const str = Buffer.from(value.string, 'utf8').toString('hex');
|
|
589
592
|
const hexLength = str.length / 2;
|
|
590
593
|
return `01${pad(hexLength)}${str}`;
|
|
591
594
|
};
|
|
592
|
-
const stringDecoder = (value) => {
|
|
593
|
-
const str = extractRequiredLen(value);
|
|
595
|
+
const stringDecoder$1 = (value) => {
|
|
596
|
+
const str = extractRequiredLen$1(value);
|
|
594
597
|
return {
|
|
595
598
|
string: Buffer.from(str).toString('utf8'),
|
|
596
599
|
};
|
|
597
600
|
};
|
|
598
|
-
const intEncoder = ({ int }) => {
|
|
601
|
+
const intEncoder$1 = ({ int }) => {
|
|
599
602
|
const num = new BigNumber(int, 10);
|
|
600
603
|
const positiveMark = num.toString(2)[0] === '-' ? '1' : '0';
|
|
601
604
|
const binary = num.toString(2).replace(/-/g, '');
|
|
@@ -615,7 +618,7 @@ const intEncoder = ({ int }) => {
|
|
|
615
618
|
.padStart(2, '0'));
|
|
616
619
|
return `00${numHex.join('')}`;
|
|
617
620
|
};
|
|
618
|
-
const intDecoder = (value) => {
|
|
621
|
+
const intDecoder$1 = (value) => {
|
|
619
622
|
let c = value.consume(1)[0];
|
|
620
623
|
const hexNumber = [];
|
|
621
624
|
const isNotLastChunkMask = 1 << 7;
|
|
@@ -640,14 +643,14 @@ const intDecoder = (value) => {
|
|
|
640
643
|
int: num.toFixed(),
|
|
641
644
|
};
|
|
642
645
|
};
|
|
643
|
-
const primEncoder = (value) => {
|
|
646
|
+
const primEncoder$1 = (value) => {
|
|
644
647
|
const hasAnnot = +Array.isArray(value.annots);
|
|
645
648
|
const argsCount = Array.isArray(value.args) ? value.args.length : 0;
|
|
646
649
|
// Specify the number of args max is 3 without annotation
|
|
647
650
|
const preamble = pad(Math.min(2 * argsCount + hasAnnot + 0x03, 9), 2);
|
|
648
|
-
const op = opMappingReverse[value.prim];
|
|
649
|
-
let encodedArgs = (value.args || []).map((arg) => valueEncoder(arg)).join('');
|
|
650
|
-
const encodedAnnots = Array.isArray(value.annots) ? encodeAnnots(value.annots) : '';
|
|
651
|
+
const op = opMappingReverse$1[value.prim];
|
|
652
|
+
let encodedArgs = (value.args || []).map((arg) => valueEncoder$1(arg)).join('');
|
|
653
|
+
const encodedAnnots = Array.isArray(value.annots) ? encodeAnnots$1(value.annots) : '';
|
|
651
654
|
if ((value.prim === 'LAMBDA' || value.prim === 'LAMBDA_REC') && argsCount) {
|
|
652
655
|
encodedArgs = pad(encodedArgs.length / 2) + encodedArgs + pad(0);
|
|
653
656
|
}
|
|
@@ -662,7 +665,7 @@ const primEncoder = (value) => {
|
|
|
662
665
|
}
|
|
663
666
|
return `${preamble}${op}${encodedArgs}${encodedAnnots}`;
|
|
664
667
|
};
|
|
665
|
-
const primDecoder = (value, preamble) => {
|
|
668
|
+
const primDecoder$1 = (value, preamble) => {
|
|
666
669
|
const hasAnnot = (preamble[0] - 0x03) % 2 === 1;
|
|
667
670
|
let argsCount = Math.floor((preamble[0] - 0x03) / 2);
|
|
668
671
|
const op = value.consume(1)[0].toString(16).padStart(2, '0');
|
|
@@ -674,7 +677,7 @@ const primDecoder = (value, preamble) => {
|
|
|
674
677
|
}
|
|
675
678
|
if (opMapping$1[op] === 'view') {
|
|
676
679
|
if (argsCount != 0) {
|
|
677
|
-
return primViewDecoder(value, result);
|
|
680
|
+
return primViewDecoder$1(value, result);
|
|
678
681
|
}
|
|
679
682
|
else {
|
|
680
683
|
return result;
|
|
@@ -683,11 +686,11 @@ const primDecoder = (value, preamble) => {
|
|
|
683
686
|
let combPairArgs;
|
|
684
687
|
let combPairAnnots;
|
|
685
688
|
if ((opMapping$1[op] === 'pair' || opMapping$1[op] === 'Pair') && argsCount > 2) {
|
|
686
|
-
combPairArgs = decodeCombPair(value);
|
|
689
|
+
combPairArgs = decodeCombPair$1(value);
|
|
687
690
|
argsCount = 0;
|
|
688
|
-
combPairAnnots = decodeAnnots(value);
|
|
691
|
+
combPairAnnots = decodeAnnots$1(value);
|
|
689
692
|
}
|
|
690
|
-
const args = new Array(argsCount).fill(0).map(() => valueDecoder(value));
|
|
693
|
+
const args = new Array(argsCount).fill(0).map(() => valueDecoder$1(value));
|
|
691
694
|
if (opMapping$1[op] === 'LAMBDA' || opMapping$1[op] === 'LAMBDA_REC') {
|
|
692
695
|
value.consume(4);
|
|
693
696
|
}
|
|
@@ -701,25 +704,25 @@ const primDecoder = (value, preamble) => {
|
|
|
701
704
|
result['annots'] = combPairAnnots;
|
|
702
705
|
}
|
|
703
706
|
else if (hasAnnot) {
|
|
704
|
-
result['annots'] = decodeAnnots(value);
|
|
707
|
+
result['annots'] = decodeAnnots$1(value);
|
|
705
708
|
}
|
|
706
709
|
return result;
|
|
707
710
|
};
|
|
708
|
-
const primViewDecoder = (value, result) => {
|
|
711
|
+
const primViewDecoder$1 = (value, result) => {
|
|
709
712
|
value.consume(4);
|
|
710
|
-
result['args'] = new Array(4).fill(0).map(() => valueDecoder(value));
|
|
713
|
+
result['args'] = new Array(4).fill(0).map(() => valueDecoder$1(value));
|
|
711
714
|
value.consume(4);
|
|
712
715
|
return result;
|
|
713
716
|
};
|
|
714
|
-
const decodeCombPair = (val) => {
|
|
715
|
-
const array = new Uint8ArrayConsumer(extractRequiredLen(val));
|
|
717
|
+
const decodeCombPair$1 = (val) => {
|
|
718
|
+
const array = new Uint8ArrayConsumer(extractRequiredLen$1(val));
|
|
716
719
|
const args = [];
|
|
717
720
|
while (array.length() > 0) {
|
|
718
|
-
args.push(valueDecoder(array));
|
|
721
|
+
args.push(valueDecoder$1(array));
|
|
719
722
|
}
|
|
720
723
|
return args;
|
|
721
724
|
};
|
|
722
|
-
const encodeAnnots = (value) => {
|
|
725
|
+
const encodeAnnots$1 = (value) => {
|
|
723
726
|
const mergedAnnot = value
|
|
724
727
|
.map((x) => {
|
|
725
728
|
return Buffer.from(x, 'utf8').toString('hex');
|
|
@@ -728,7 +731,7 @@ const encodeAnnots = (value) => {
|
|
|
728
731
|
const len = mergedAnnot.length / 2;
|
|
729
732
|
return `${pad(len)}${mergedAnnot}`;
|
|
730
733
|
};
|
|
731
|
-
const decodeAnnots = (val) => {
|
|
734
|
+
const decodeAnnots$1 = (val) => {
|
|
732
735
|
const len = val.consume(4);
|
|
733
736
|
const annotLen = parseInt(Buffer.from(len).toString('hex'), 16);
|
|
734
737
|
const restOfAnnot = val.consume(annotLen);
|
|
@@ -737,28 +740,29 @@ const decodeAnnots = (val) => {
|
|
|
737
740
|
};
|
|
738
741
|
|
|
739
742
|
// https://tezos.gitlab.io/shell/p2p_api.html specifies data types and structure for forging
|
|
740
|
-
const prefixEncoder$1 = (prefix
|
|
741
|
-
|
|
743
|
+
const prefixEncoder$1 = (prefix) => (str) => {
|
|
744
|
+
const [pl] = b58DecodeAndCheckPrefix(str, [prefix]);
|
|
745
|
+
return buf2hex(pl);
|
|
742
746
|
};
|
|
743
747
|
const prefixDecoder$1 = (pre) => (str) => {
|
|
744
|
-
const val = str.consume(
|
|
745
|
-
return
|
|
748
|
+
const val = str.consume(payloadLength[pre]);
|
|
749
|
+
return b58Encode(val, pre);
|
|
746
750
|
};
|
|
747
|
-
const tz1Decoder$1 = prefixDecoder$1(
|
|
748
|
-
const branchDecoder$1 = prefixDecoder$1(
|
|
751
|
+
const tz1Decoder$1 = prefixDecoder$1(PrefixV2.Ed25519PublicKeyHash);
|
|
752
|
+
const branchDecoder$1 = prefixDecoder$1(PrefixV2.BlockHash);
|
|
749
753
|
const publicKeyHashDecoder$1 = (val) => {
|
|
750
754
|
const prefix = val.consume(1);
|
|
751
755
|
if (prefix[0] === 0x00) {
|
|
752
|
-
return prefixDecoder$1(
|
|
756
|
+
return prefixDecoder$1(PrefixV2.Ed25519PublicKeyHash)(val);
|
|
753
757
|
}
|
|
754
758
|
else if (prefix[0] === 0x01) {
|
|
755
|
-
return prefixDecoder$1(
|
|
759
|
+
return prefixDecoder$1(PrefixV2.Secp256k1PublicKeyHash)(val);
|
|
756
760
|
}
|
|
757
761
|
else if (prefix[0] === 0x02) {
|
|
758
|
-
return prefixDecoder$1(
|
|
762
|
+
return prefixDecoder$1(PrefixV2.P256PublicKeyHash)(val);
|
|
759
763
|
}
|
|
760
764
|
else if (prefix[0] === 0x03) {
|
|
761
|
-
return prefixDecoder$1(
|
|
765
|
+
return prefixDecoder$1(PrefixV2.BLS12_381PublicKeyHash)(val);
|
|
762
766
|
}
|
|
763
767
|
};
|
|
764
768
|
const publicKeyHashesDecoder$1 = (val) => {
|
|
@@ -772,14 +776,14 @@ const publicKeyHashesDecoder$1 = (val) => {
|
|
|
772
776
|
}
|
|
773
777
|
return publicKeyHashes;
|
|
774
778
|
};
|
|
775
|
-
const branchEncoder$1 = prefixEncoder$1(
|
|
776
|
-
const tz1Encoder$1 = prefixEncoder$1(
|
|
779
|
+
const branchEncoder$1 = prefixEncoder$1(PrefixV2.BlockHash);
|
|
780
|
+
const tz1Encoder$1 = prefixEncoder$1(PrefixV2.Ed25519PublicKeyHash);
|
|
777
781
|
const boolEncoder$1 = (bool) => (bool ? 'ff' : '00');
|
|
778
782
|
const proposalEncoder$1 = (proposal) => {
|
|
779
|
-
return prefixEncoder$1(
|
|
783
|
+
return prefixEncoder$1(PrefixV2.ProtocolHash)(proposal);
|
|
780
784
|
};
|
|
781
785
|
const proposalDecoder$1 = (proposal) => {
|
|
782
|
-
return prefixDecoder$1(
|
|
786
|
+
return prefixDecoder$1(PrefixV2.ProtocolHash)(proposal);
|
|
783
787
|
};
|
|
784
788
|
const proposalsDecoder$1 = (proposal) => {
|
|
785
789
|
const proposals = [];
|
|
@@ -895,19 +899,11 @@ const delegateDecoder$1 = (val) => {
|
|
|
895
899
|
}
|
|
896
900
|
};
|
|
897
901
|
const publicKeyHashEncoder$1 = (val) => {
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
return '01' + prefixEncoder$1(Prefix.TZ2)(val);
|
|
904
|
-
case Prefix.TZ3:
|
|
905
|
-
return '02' + prefixEncoder$1(Prefix.TZ3)(val);
|
|
906
|
-
case Prefix.TZ4:
|
|
907
|
-
return '03' + prefixEncoder$1(Prefix.TZ4)(val);
|
|
908
|
-
default:
|
|
909
|
-
throw new InvalidKeyHashError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
910
|
-
` expecting one for the following "${Prefix.TZ1}", "${Prefix.TZ2}", "${Prefix.TZ3}" or "${Prefix.TZ4}".`);
|
|
902
|
+
try {
|
|
903
|
+
return b58DecodePublicKeyHash(val);
|
|
904
|
+
}
|
|
905
|
+
catch (err) {
|
|
906
|
+
throw new InvalidKeyHashError(val, err instanceof ParameterValidationError ? err.result : undefined);
|
|
911
907
|
}
|
|
912
908
|
};
|
|
913
909
|
const publicKeyHashesEncoder$1 = (val) => {
|
|
@@ -923,70 +919,57 @@ const publicKeyHashesEncoder$1 = (val) => {
|
|
|
923
919
|
return boolEncoder$1(true) + pad(publicKeyHashes.length / 2) + publicKeyHashes;
|
|
924
920
|
};
|
|
925
921
|
const publicKeyEncoder$1 = (val) => {
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
return '01' + prefixEncoder$1(Prefix.SPPK)(val);
|
|
932
|
-
case Prefix.P2PK:
|
|
933
|
-
return '02' + prefixEncoder$1(Prefix.P2PK)(val);
|
|
934
|
-
case Prefix.BLPK:
|
|
935
|
-
return '03' + prefixEncoder$1(Prefix.BLPK)(val);
|
|
936
|
-
default:
|
|
937
|
-
throw new InvalidPublicKeyError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
938
|
-
` expecting one of the following '${Prefix.EDPK}', '${Prefix.SPPK}', '${Prefix.P2PK}' or '${Prefix.BLPK}'.`);
|
|
922
|
+
try {
|
|
923
|
+
return b58DecodePublicKey(val);
|
|
924
|
+
}
|
|
925
|
+
catch (err) {
|
|
926
|
+
throw new InvalidPublicKeyError(val, err instanceof ParameterValidationError ? err.result : undefined);
|
|
939
927
|
}
|
|
940
928
|
};
|
|
941
929
|
const addressEncoder$1 = (val) => {
|
|
942
|
-
|
|
943
|
-
switch (pubkeyPrefix) {
|
|
944
|
-
case Prefix.TZ1:
|
|
945
|
-
case Prefix.TZ2:
|
|
946
|
-
case Prefix.TZ3:
|
|
947
|
-
case Prefix.TZ4:
|
|
948
|
-
return '00' + publicKeyHashEncoder$1(val);
|
|
949
|
-
case Prefix.KT1:
|
|
950
|
-
return '01' + prefixEncoder$1(Prefix.KT1)(val) + '00';
|
|
951
|
-
default:
|
|
952
|
-
throw new InvalidAddressError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
953
|
-
` expecting one of the following prefix '${Prefix.TZ1}', ${Prefix.TZ2}', '${Prefix.TZ3}', '${Prefix.TZ4}' or '${Prefix.KT1}'.`);
|
|
954
|
-
}
|
|
930
|
+
return b58DecodeAddress(val);
|
|
955
931
|
};
|
|
956
932
|
const smartRollupAddressEncoder$1 = (val) => {
|
|
957
|
-
|
|
958
|
-
|
|
933
|
+
try {
|
|
934
|
+
return prefixEncoder$1(PrefixV2.SmartRollupHash)(val);
|
|
959
935
|
}
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
936
|
+
catch (err) {
|
|
937
|
+
if (err instanceof ParameterValidationError) {
|
|
938
|
+
throw new InvalidSmartRollupAddressError(val);
|
|
939
|
+
}
|
|
940
|
+
else {
|
|
941
|
+
throw err;
|
|
942
|
+
}
|
|
966
943
|
}
|
|
967
|
-
throw new InvalidContractAddressError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.KT1}'.`);
|
|
968
944
|
};
|
|
945
|
+
const smartContractAddressEncoder$1 = (val) => b58DecodeAddress(val);
|
|
969
946
|
const publicKeyDecoder$1 = (val) => {
|
|
970
947
|
const preamble = val.consume(1);
|
|
971
948
|
switch (preamble[0]) {
|
|
972
949
|
case 0x00:
|
|
973
|
-
return prefixDecoder$1(
|
|
950
|
+
return prefixDecoder$1(PrefixV2.Ed25519PublicKey)(val);
|
|
974
951
|
case 0x01:
|
|
975
|
-
return prefixDecoder$1(
|
|
952
|
+
return prefixDecoder$1(PrefixV2.Secp256k1PublicKey)(val);
|
|
976
953
|
case 0x02:
|
|
977
|
-
return prefixDecoder$1(
|
|
954
|
+
return prefixDecoder$1(PrefixV2.P256PublicKey)(val);
|
|
978
955
|
case 0x03:
|
|
979
|
-
return prefixDecoder$1(
|
|
956
|
+
return prefixDecoder$1(PrefixV2.BLS12_381PublicKey)(val);
|
|
980
957
|
default:
|
|
981
|
-
throw new InvalidPublicKeyError(
|
|
958
|
+
throw new InvalidPublicKeyError(undefined, ValidationResult.NO_PREFIX_MATCHED);
|
|
982
959
|
}
|
|
983
960
|
};
|
|
984
961
|
const smartRollupCommitmentHashEncoder$1 = (val) => {
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
962
|
+
try {
|
|
963
|
+
return prefixEncoder$1(PrefixV2.SmartRollupCommitmentHash)(val);
|
|
964
|
+
}
|
|
965
|
+
catch (err) {
|
|
966
|
+
if (err instanceof ParameterValidationError) {
|
|
967
|
+
throw new InvalidSmartRollupCommitmentHashError(val);
|
|
968
|
+
}
|
|
969
|
+
else {
|
|
970
|
+
throw err;
|
|
971
|
+
}
|
|
988
972
|
}
|
|
989
|
-
throw new InvalidSmartRollupCommitmentHashError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SRC1}'`);
|
|
990
973
|
};
|
|
991
974
|
const addressDecoder$1 = (val) => {
|
|
992
975
|
const preamble = val.consume(1);
|
|
@@ -994,7 +977,7 @@ const addressDecoder$1 = (val) => {
|
|
|
994
977
|
case 0x00:
|
|
995
978
|
return publicKeyHashDecoder$1(val);
|
|
996
979
|
case 0x01: {
|
|
997
|
-
const address = prefixDecoder$1(
|
|
980
|
+
const address = prefixDecoder$1(PrefixV2.ContractHash)(val);
|
|
998
981
|
val.consume(1);
|
|
999
982
|
return address;
|
|
1000
983
|
}
|
|
@@ -1003,27 +986,19 @@ const addressDecoder$1 = (val) => {
|
|
|
1003
986
|
}
|
|
1004
987
|
};
|
|
1005
988
|
const smartRollupAddressDecoder$1 = (val) => {
|
|
1006
|
-
|
|
1007
|
-
if (address.substring(0, 3) !== Prefix.SR1) {
|
|
1008
|
-
throw new InvalidSmartRollupAddressError(address, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SR1}'.`);
|
|
1009
|
-
}
|
|
1010
|
-
return address;
|
|
989
|
+
return prefixDecoder$1(PrefixV2.SmartRollupHash)(val);
|
|
1011
990
|
};
|
|
1012
991
|
const smartContractAddressDecoder$1 = (val) => {
|
|
1013
992
|
const preamble = val.consume(1);
|
|
1014
993
|
if (preamble[0] === 0x01) {
|
|
1015
|
-
const scAddress = prefixDecoder$1(
|
|
994
|
+
const scAddress = prefixDecoder$1(PrefixV2.ContractHash)(val);
|
|
1016
995
|
val.consume(1);
|
|
1017
996
|
return scAddress;
|
|
1018
997
|
}
|
|
1019
|
-
throw new InvalidContractAddressError(val.toString(),
|
|
998
|
+
throw new InvalidContractAddressError(val.toString(), ValidationResult.NO_PREFIX_MATCHED);
|
|
1020
999
|
};
|
|
1021
1000
|
const smartRollupCommitmentHashDecoder$1 = (val) => {
|
|
1022
|
-
|
|
1023
|
-
if (address.substring(0, 4) !== Prefix.SRC1) {
|
|
1024
|
-
throw new InvalidSmartRollupCommitmentHashError(address, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SRC1}'`);
|
|
1025
|
-
}
|
|
1026
|
-
return address;
|
|
1001
|
+
return prefixDecoder$1(PrefixV2.SmartRollupCommitmentHash)(val);
|
|
1027
1002
|
};
|
|
1028
1003
|
const zarithEncoder$1 = (n) => {
|
|
1029
1004
|
const fn = [];
|
|
@@ -1069,7 +1044,7 @@ const entrypointDecoder$1 = (value) => {
|
|
|
1069
1044
|
return entrypointMapping$1[preamble];
|
|
1070
1045
|
}
|
|
1071
1046
|
else {
|
|
1072
|
-
const entry = extractRequiredLen(value, 1);
|
|
1047
|
+
const entry = extractRequiredLen$1(value, 1);
|
|
1073
1048
|
const entrypoint = Buffer.from(entry).toString('utf8');
|
|
1074
1049
|
if (entrypoint.length > ENTRYPOINT_MAX_LENGTH$1) {
|
|
1075
1050
|
throw new OversizedEntryPointError(entrypoint);
|
|
@@ -1084,8 +1059,8 @@ const parametersDecoder$1 = (val) => {
|
|
|
1084
1059
|
}
|
|
1085
1060
|
else {
|
|
1086
1061
|
const encodedEntrypoint = entrypointDecoder$1(val);
|
|
1087
|
-
const params = extractRequiredLen(val);
|
|
1088
|
-
const parameters = valueDecoder(new Uint8ArrayConsumer(params));
|
|
1062
|
+
const params = extractRequiredLen$1(val);
|
|
1063
|
+
const parameters = valueDecoder$1(new Uint8ArrayConsumer(params));
|
|
1089
1064
|
return {
|
|
1090
1065
|
entrypoint: encodedEntrypoint,
|
|
1091
1066
|
value: parameters,
|
|
@@ -1101,7 +1076,7 @@ const entrypointEncoder$1 = (entrypoint) => {
|
|
|
1101
1076
|
throw new OversizedEntryPointError(entrypoint);
|
|
1102
1077
|
}
|
|
1103
1078
|
const value = { string: entrypoint };
|
|
1104
|
-
return `ff${valueEncoder(value).slice(8)}`;
|
|
1079
|
+
return `ff${valueEncoder$1(value).slice(8)}`;
|
|
1105
1080
|
}
|
|
1106
1081
|
};
|
|
1107
1082
|
const parametersEncoder$1 = (val) => {
|
|
@@ -1109,26 +1084,26 @@ const parametersEncoder$1 = (val) => {
|
|
|
1109
1084
|
return '00';
|
|
1110
1085
|
}
|
|
1111
1086
|
const encodedEntrypoint = entrypointEncoder$1(val.entrypoint);
|
|
1112
|
-
const parameters = valueEncoder(val.value);
|
|
1087
|
+
const parameters = valueEncoder$1(val.value);
|
|
1113
1088
|
const length = pad(parameters.length / 2);
|
|
1114
1089
|
return `ff${encodedEntrypoint}${length}${parameters}`;
|
|
1115
1090
|
};
|
|
1116
1091
|
const valueParameterEncoder$1 = (value) => {
|
|
1117
|
-
const valueEncoded = valueEncoder(value);
|
|
1092
|
+
const valueEncoded = valueEncoder$1(value);
|
|
1118
1093
|
return `${pad(valueEncoded.length / 2)}${valueEncoded}`;
|
|
1119
1094
|
};
|
|
1120
1095
|
const valueParameterDecoder$1 = (val) => {
|
|
1121
|
-
const value = extractRequiredLen(val);
|
|
1122
|
-
return valueDecoder(new Uint8ArrayConsumer(value));
|
|
1096
|
+
const value = extractRequiredLen$1(val);
|
|
1097
|
+
return valueDecoder$1(new Uint8ArrayConsumer(value));
|
|
1123
1098
|
};
|
|
1124
|
-
const blockPayloadHashEncoder$1 = prefixEncoder$1(
|
|
1125
|
-
const blockPayloadHashDecoder$1 = prefixDecoder$1(
|
|
1099
|
+
const blockPayloadHashEncoder$1 = prefixEncoder$1(PrefixV2.ValueHash);
|
|
1100
|
+
const blockPayloadHashDecoder$1 = prefixDecoder$1(PrefixV2.ValueHash);
|
|
1126
1101
|
const entrypointNameEncoder$1 = (entrypoint) => {
|
|
1127
1102
|
const value = { string: entrypoint };
|
|
1128
|
-
return `${valueEncoder(value).slice(2)}`;
|
|
1103
|
+
return `${valueEncoder$1(value).slice(2)}`;
|
|
1129
1104
|
};
|
|
1130
1105
|
const entrypointNameDecoder$1 = (val) => {
|
|
1131
|
-
const entry = extractRequiredLen(val);
|
|
1106
|
+
const entry = extractRequiredLen$1(val);
|
|
1132
1107
|
return Buffer.from(entry).toString('utf8');
|
|
1133
1108
|
};
|
|
1134
1109
|
const burnLimitEncoder$1 = (val) => {
|
|
@@ -1149,50 +1124,53 @@ const depositsLimitDecoder$1 = (value) => {
|
|
|
1149
1124
|
return zarithDecoder$1(value);
|
|
1150
1125
|
}
|
|
1151
1126
|
};
|
|
1152
|
-
const signatureV1Encoder = (val) => {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
return paddedBytesEncoder$1(
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
throw new InvalidSignatureError(val,
|
|
1165
|
-
|
|
1127
|
+
const signatureV1Encoder$1 = (val) => {
|
|
1128
|
+
try {
|
|
1129
|
+
const [data, pre] = b58DecodeAndCheckPrefix(val, signaturePrefixes);
|
|
1130
|
+
if (pre === PrefixV2.BLS12_381Signature) {
|
|
1131
|
+
return paddedBytesEncoder$1(buf2hex(data));
|
|
1132
|
+
}
|
|
1133
|
+
else {
|
|
1134
|
+
throw new ProhibitedActionError('we only support encoding of BLSIG signatures from protocol Seoul');
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
catch (err) {
|
|
1138
|
+
if (err instanceof ParameterValidationError) {
|
|
1139
|
+
throw new InvalidSignatureError(val, err.result);
|
|
1140
|
+
}
|
|
1141
|
+
else {
|
|
1142
|
+
throw err;
|
|
1143
|
+
}
|
|
1166
1144
|
}
|
|
1167
1145
|
};
|
|
1168
|
-
const signatureV1Decoder = (val) => {
|
|
1146
|
+
const signatureV1Decoder$1 = (val) => {
|
|
1169
1147
|
val.consume(4);
|
|
1170
1148
|
if (val.length().toString() === '96') {
|
|
1171
|
-
return prefixDecoder$1(
|
|
1149
|
+
return prefixDecoder$1(PrefixV2.BLS12_381Signature)(val);
|
|
1172
1150
|
}
|
|
1173
1151
|
else {
|
|
1174
|
-
throw new ProhibitedActionError('
|
|
1152
|
+
throw new ProhibitedActionError('we only support decoding of BLSIG signatures');
|
|
1175
1153
|
}
|
|
1176
1154
|
};
|
|
1177
|
-
const signatureProofEncoder = (val) => {
|
|
1155
|
+
const signatureProofEncoder$1 = (val) => {
|
|
1178
1156
|
if (val) {
|
|
1179
|
-
return boolEncoder$1(true) + signatureV1Encoder(val);
|
|
1157
|
+
return boolEncoder$1(true) + signatureV1Encoder$1(val);
|
|
1180
1158
|
}
|
|
1181
1159
|
else {
|
|
1182
1160
|
return boolEncoder$1(false);
|
|
1183
1161
|
}
|
|
1184
1162
|
};
|
|
1185
|
-
const signatureProofDecoder = (value) => {
|
|
1163
|
+
const signatureProofDecoder$1 = (value) => {
|
|
1186
1164
|
const hasProof = boolDecoder$1(value);
|
|
1187
1165
|
if (hasProof) {
|
|
1188
|
-
return signatureV1Decoder(value);
|
|
1166
|
+
return signatureV1Decoder$1(value);
|
|
1189
1167
|
}
|
|
1190
1168
|
};
|
|
1191
1169
|
const paddedBytesEncoder$1 = (val, paddingLength = 8) => {
|
|
1192
1170
|
return `${pad(val.length / 2, paddingLength)}${val}`;
|
|
1193
1171
|
};
|
|
1194
1172
|
const paddedBytesDecoder$1 = (val) => {
|
|
1195
|
-
const value = extractRequiredLen(val);
|
|
1173
|
+
const value = extractRequiredLen$1(val);
|
|
1196
1174
|
return Buffer.from(value).toString('hex');
|
|
1197
1175
|
};
|
|
1198
1176
|
const smartRollupMessageEncoder$1 = (val) => {
|
|
@@ -1202,23 +1180,25 @@ const smartRollupMessageEncoder$1 = (val) => {
|
|
|
1202
1180
|
return `${pad(message.length / 2)}${message}`;
|
|
1203
1181
|
};
|
|
1204
1182
|
const smartRollupMessageDecoder$1 = (val) => {
|
|
1205
|
-
const valueArray = extractRequiredLen(val);
|
|
1206
|
-
const ret = stripLengthPrefixFromBytes(new Uint8ArrayConsumer(valueArray));
|
|
1183
|
+
const valueArray = extractRequiredLen$1(val);
|
|
1184
|
+
const ret = stripLengthPrefixFromBytes$1(new Uint8ArrayConsumer(valueArray));
|
|
1207
1185
|
return ret.map((value) => Buffer.from(value).toString('hex'));
|
|
1208
1186
|
};
|
|
1209
1187
|
const dalCommitmentEncoder$1 = (val) => {
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1188
|
+
try {
|
|
1189
|
+
return prefixEncoder$1(PrefixV2.SlotHeader)(val);
|
|
1190
|
+
}
|
|
1191
|
+
catch (err) {
|
|
1192
|
+
if (err instanceof ParameterValidationError) {
|
|
1193
|
+
throw new InvalidDalCommitmentError(val);
|
|
1194
|
+
}
|
|
1195
|
+
else {
|
|
1196
|
+
throw err;
|
|
1197
|
+
}
|
|
1213
1198
|
}
|
|
1214
|
-
throw new InvalidDalCommitmentError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SH}'`);
|
|
1215
1199
|
};
|
|
1216
1200
|
const dalCommitmentDecoder$1 = (val) => {
|
|
1217
|
-
|
|
1218
|
-
if (commitment.substring(0, 2) !== Prefix.SH) {
|
|
1219
|
-
throw new InvalidDalCommitmentError(commitment, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${Prefix.SH}'`);
|
|
1220
|
-
}
|
|
1221
|
-
return commitment;
|
|
1201
|
+
return prefixDecoder$1(PrefixV2.SlotHeader)(val);
|
|
1222
1202
|
};
|
|
1223
1203
|
const slotHeaderEncoder$1 = (val) => {
|
|
1224
1204
|
return pad(val.slot_index, 2) + dalCommitmentEncoder$1(val.commitment) + val.commitment_proof;
|
|
@@ -1247,6 +1227,7 @@ const RevealSchema$1 = {
|
|
|
1247
1227
|
gas_limit: CODEC$1.ZARITH,
|
|
1248
1228
|
storage_limit: CODEC$1.ZARITH,
|
|
1249
1229
|
public_key: CODEC$1.PUBLIC_KEY,
|
|
1230
|
+
proof: CODEC$1.SIGNATURE_PROOF,
|
|
1250
1231
|
};
|
|
1251
1232
|
const DelegationSchema$1 = {
|
|
1252
1233
|
source: CODEC$1.PKH,
|
|
@@ -1343,6 +1324,15 @@ const UpdateConsensusKeySchema$1 = {
|
|
|
1343
1324
|
pk: CODEC$1.PUBLIC_KEY,
|
|
1344
1325
|
proof: CODEC$1.SIGNATURE_PROOF,
|
|
1345
1326
|
};
|
|
1327
|
+
const UpdateCompanionKeySchema = {
|
|
1328
|
+
source: CODEC$1.PKH,
|
|
1329
|
+
fee: CODEC$1.ZARITH,
|
|
1330
|
+
counter: CODEC$1.ZARITH,
|
|
1331
|
+
gas_limit: CODEC$1.ZARITH,
|
|
1332
|
+
storage_limit: CODEC$1.ZARITH,
|
|
1333
|
+
pk: CODEC$1.PUBLIC_KEY,
|
|
1334
|
+
proof: CODEC$1.SIGNATURE_PROOF,
|
|
1335
|
+
};
|
|
1346
1336
|
const DrainDelegateSchema$1 = {
|
|
1347
1337
|
consensus_key: CODEC$1.PKH,
|
|
1348
1338
|
delegate: CODEC$1.PKH,
|
|
@@ -1461,7 +1451,7 @@ const schemaDecoder$1 = (decoders) => (schema) => (value) => {
|
|
|
1461
1451
|
}, {});
|
|
1462
1452
|
};
|
|
1463
1453
|
|
|
1464
|
-
const decoders = {
|
|
1454
|
+
const decoders$1 = {
|
|
1465
1455
|
[CODEC$1.SECRET]: (val) => toHexString(val.consume(20)),
|
|
1466
1456
|
[CODEC$1.RAW]: (val) => toHexString(val.consume(32)),
|
|
1467
1457
|
[CODEC$1.TZ1]: tz1Decoder$1,
|
|
@@ -1472,7 +1462,7 @@ const decoders = {
|
|
|
1472
1462
|
[CODEC$1.PKH_ARR]: publicKeyHashesDecoder$1,
|
|
1473
1463
|
[CODEC$1.DELEGATE]: delegateDecoder$1,
|
|
1474
1464
|
[CODEC$1.INT32]: int32Decoder$1,
|
|
1475
|
-
[CODEC$1.SCRIPT]: scriptDecoder,
|
|
1465
|
+
[CODEC$1.SCRIPT]: scriptDecoder$1,
|
|
1476
1466
|
[CODEC$1.BALLOT_STATEMENT]: ballotDecoder$1,
|
|
1477
1467
|
[CODEC$1.PROPOSAL]: proposalDecoder$1,
|
|
1478
1468
|
[CODEC$1.PROPOSAL_ARR]: proposalsDecoder$1,
|
|
@@ -1487,35 +1477,36 @@ const decoders = {
|
|
|
1487
1477
|
[CODEC$1.ENTRYPOINT]: entrypointNameDecoder$1,
|
|
1488
1478
|
[CODEC$1.BURN_LIMIT]: burnLimitDecoder$1,
|
|
1489
1479
|
[CODEC$1.DEPOSITS_LIMIT]: depositsLimitDecoder$1,
|
|
1490
|
-
[CODEC$1.SIGNATURE_PROOF]: signatureProofDecoder,
|
|
1480
|
+
[CODEC$1.SIGNATURE_PROOF]: signatureProofDecoder$1,
|
|
1491
1481
|
[CODEC$1.PVM_KIND]: pvmKindDecoder$1,
|
|
1492
1482
|
[CODEC$1.PADDED_BYTES]: paddedBytesDecoder$1,
|
|
1493
1483
|
[CODEC$1.SMART_ROLLUP_MESSAGE]: smartRollupMessageDecoder$1,
|
|
1494
1484
|
[CODEC$1.SLOT_HEADER]: slotHeaderDecoder$1,
|
|
1495
1485
|
};
|
|
1496
|
-
decoders[CODEC$1.OPERATION] = operationDecoder$1(decoders);
|
|
1497
|
-
decoders[CODEC$1.OP_ACTIVATE_ACCOUNT] = (val) => schemaDecoder$1(decoders)(ActivationSchema$1)(val);
|
|
1498
|
-
decoders[CODEC$1.OP_FAILING_NOOP] = (val) => schemaDecoder$1(decoders)(FailingNoopSchema$1)(val);
|
|
1499
|
-
decoders[CODEC$1.OP_DELEGATION] = (val) => schemaDecoder$1(decoders)(DelegationSchema$1)(val);
|
|
1500
|
-
decoders[CODEC$1.OP_TRANSACTION] = (val) => schemaDecoder$1(decoders)(TransactionSchema$1)(val);
|
|
1501
|
-
decoders[CODEC$1.OP_ORIGINATION] = (val) => schemaDecoder$1(decoders)(OriginationSchema$1)(val);
|
|
1502
|
-
decoders[CODEC$1.OP_BALLOT] = (val) => schemaDecoder$1(decoders)(BallotSchema$1)(val);
|
|
1503
|
-
decoders[CODEC$1.OP_ATTESTATION] = (val) => schemaDecoder$1(decoders)(AttestationSchema$1)(val);
|
|
1504
|
-
decoders[CODEC$1.OP_ATTESTATION_WITH_DAL] = (val) => schemaDecoder$1(decoders)(AttestationWithDalSchema$1)(val);
|
|
1505
|
-
decoders[CODEC$1.OP_SEED_NONCE_REVELATION] = (val) => schemaDecoder$1(decoders)(SeedNonceRevelationSchema$1)(val);
|
|
1506
|
-
decoders[CODEC$1.OP_PROPOSALS] = (val) => schemaDecoder$1(decoders)(ProposalsSchema$1)(val);
|
|
1507
|
-
decoders[CODEC$1.OP_REVEAL] = (val) => schemaDecoder$1(decoders)(RevealSchema$1)(val);
|
|
1508
|
-
decoders[CODEC$1.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaDecoder$1(decoders)(RegisterGlobalConstantSchema$1)(val);
|
|
1509
|
-
decoders[CODEC$1.OP_TRANSFER_TICKET] = (val) => schemaDecoder$1(decoders)(TransferTicketSchema$1)(val);
|
|
1510
|
-
decoders[CODEC$1.OP_INCREASE_PAID_STORAGE] = (val) => schemaDecoder$1(decoders)(IncreasePaidStorageSchema$1)(val);
|
|
1511
|
-
decoders[CODEC$1.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaDecoder$1(decoders)(UpdateConsensusKeySchema$1)(val);
|
|
1512
|
-
decoders[CODEC$1.
|
|
1513
|
-
decoders[CODEC$1.
|
|
1514
|
-
decoders[CODEC$1.
|
|
1515
|
-
decoders[CODEC$1.
|
|
1516
|
-
decoders[CODEC$1.
|
|
1517
|
-
decoders[CODEC$1.
|
|
1518
|
-
decoders[CODEC$1.
|
|
1486
|
+
decoders$1[CODEC$1.OPERATION] = operationDecoder$1(decoders$1);
|
|
1487
|
+
decoders$1[CODEC$1.OP_ACTIVATE_ACCOUNT] = (val) => schemaDecoder$1(decoders$1)(ActivationSchema$1)(val);
|
|
1488
|
+
decoders$1[CODEC$1.OP_FAILING_NOOP] = (val) => schemaDecoder$1(decoders$1)(FailingNoopSchema$1)(val);
|
|
1489
|
+
decoders$1[CODEC$1.OP_DELEGATION] = (val) => schemaDecoder$1(decoders$1)(DelegationSchema$1)(val);
|
|
1490
|
+
decoders$1[CODEC$1.OP_TRANSACTION] = (val) => schemaDecoder$1(decoders$1)(TransactionSchema$1)(val);
|
|
1491
|
+
decoders$1[CODEC$1.OP_ORIGINATION] = (val) => schemaDecoder$1(decoders$1)(OriginationSchema$1)(val);
|
|
1492
|
+
decoders$1[CODEC$1.OP_BALLOT] = (val) => schemaDecoder$1(decoders$1)(BallotSchema$1)(val);
|
|
1493
|
+
decoders$1[CODEC$1.OP_ATTESTATION] = (val) => schemaDecoder$1(decoders$1)(AttestationSchema$1)(val);
|
|
1494
|
+
decoders$1[CODEC$1.OP_ATTESTATION_WITH_DAL] = (val) => schemaDecoder$1(decoders$1)(AttestationWithDalSchema$1)(val);
|
|
1495
|
+
decoders$1[CODEC$1.OP_SEED_NONCE_REVELATION] = (val) => schemaDecoder$1(decoders$1)(SeedNonceRevelationSchema$1)(val);
|
|
1496
|
+
decoders$1[CODEC$1.OP_PROPOSALS] = (val) => schemaDecoder$1(decoders$1)(ProposalsSchema$1)(val);
|
|
1497
|
+
decoders$1[CODEC$1.OP_REVEAL] = (val) => schemaDecoder$1(decoders$1)(RevealSchema$1)(val);
|
|
1498
|
+
decoders$1[CODEC$1.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaDecoder$1(decoders$1)(RegisterGlobalConstantSchema$1)(val);
|
|
1499
|
+
decoders$1[CODEC$1.OP_TRANSFER_TICKET] = (val) => schemaDecoder$1(decoders$1)(TransferTicketSchema$1)(val);
|
|
1500
|
+
decoders$1[CODEC$1.OP_INCREASE_PAID_STORAGE] = (val) => schemaDecoder$1(decoders$1)(IncreasePaidStorageSchema$1)(val);
|
|
1501
|
+
decoders$1[CODEC$1.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaDecoder$1(decoders$1)(UpdateConsensusKeySchema$1)(val);
|
|
1502
|
+
decoders$1[CODEC$1.OP_UPDATE_COMPANION_KEY] = (val) => schemaDecoder$1(decoders$1)(UpdateCompanionKeySchema)(val);
|
|
1503
|
+
decoders$1[CODEC$1.OP_DRAIN_DELEGATE] = (val) => schemaDecoder$1(decoders$1)(DrainDelegateSchema$1)(val);
|
|
1504
|
+
decoders$1[CODEC$1.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaDecoder$1(decoders$1)(SmartRollupOriginateSchema$1)(val);
|
|
1505
|
+
decoders$1[CODEC$1.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaDecoder$1(decoders$1)(SmartRollupAddMessagesSchema$1)(val);
|
|
1506
|
+
decoders$1[CODEC$1.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaDecoder$1(decoders$1)(SmartRollupExecuteOutboxMessageSchema$1)(val);
|
|
1507
|
+
decoders$1[CODEC$1.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaDecoder$1(decoders$1)(DalPublishCommitmentSchema$1)(val);
|
|
1508
|
+
decoders$1[CODEC$1.MANAGER] = schemaDecoder$1(decoders$1)(ManagerOperationSchema$1);
|
|
1509
|
+
decoders$1[CODEC$1.OP_SET_DEPOSITS_LIMIT] = (val) => schemaDecoder$1(decoders$1)(SetDepositsLimitSchema$1)(val);
|
|
1519
1510
|
|
|
1520
1511
|
/*
|
|
1521
1512
|
* Some code in this file is originally from sotez
|
|
@@ -1568,6 +1559,7 @@ var CODEC;
|
|
|
1568
1559
|
CODEC["BURN_LIMIT"] = "burn_limit";
|
|
1569
1560
|
CODEC["OP_INCREASE_PAID_STORAGE"] = "increase_paid_storage";
|
|
1570
1561
|
CODEC["OP_UPDATE_CONSENSUS_KEY"] = "update_consensus_key";
|
|
1562
|
+
CODEC["SIGNATURE_PROOF"] = "signature_proof";
|
|
1571
1563
|
CODEC["OP_DRAIN_DELEGATE"] = "drain_delegate";
|
|
1572
1564
|
CODEC["DEPOSITS_LIMIT"] = "deposits_limit";
|
|
1573
1565
|
CODEC["OP_SET_DEPOSITS_LIMIT"] = "set_deposits_limit";
|
|
@@ -1739,7 +1731,7 @@ const opMapping = {
|
|
|
1739
1731
|
'9c': 'NAT',
|
|
1740
1732
|
'9d': 'Ticket',
|
|
1741
1733
|
};
|
|
1742
|
-
(() => {
|
|
1734
|
+
const opMappingReverse = (() => {
|
|
1743
1735
|
const result = {};
|
|
1744
1736
|
Object.keys(opMapping).forEach((key) => {
|
|
1745
1737
|
result[opMapping[key]] = key;
|
|
@@ -1799,6 +1791,259 @@ const entrypointMappingReverse = (() => {
|
|
|
1799
1791
|
return result;
|
|
1800
1792
|
})();
|
|
1801
1793
|
|
|
1794
|
+
const isPrim = (value) => {
|
|
1795
|
+
return 'prim' in value;
|
|
1796
|
+
};
|
|
1797
|
+
const isBytes = (value) => {
|
|
1798
|
+
return 'bytes' in value && typeof value.bytes === 'string';
|
|
1799
|
+
};
|
|
1800
|
+
const isString = (value) => {
|
|
1801
|
+
return 'string' in value && typeof value.string === 'string';
|
|
1802
|
+
};
|
|
1803
|
+
const isInt = (value) => {
|
|
1804
|
+
return 'int' in value && typeof value.int === 'string';
|
|
1805
|
+
};
|
|
1806
|
+
const scriptEncoder = (script) => {
|
|
1807
|
+
const code = valueEncoder(script.code);
|
|
1808
|
+
const storage = valueEncoder(script.storage);
|
|
1809
|
+
return `${pad(code.length / 2, 8)}${code}${pad(storage.length / 2, 8)}${storage}`;
|
|
1810
|
+
};
|
|
1811
|
+
const scriptDecoder = (value) => {
|
|
1812
|
+
const code = extractRequiredLen(value);
|
|
1813
|
+
const storage = extractRequiredLen(value);
|
|
1814
|
+
return {
|
|
1815
|
+
code: valueDecoder(new Uint8ArrayConsumer(code)),
|
|
1816
|
+
storage: valueDecoder(new Uint8ArrayConsumer(storage)),
|
|
1817
|
+
};
|
|
1818
|
+
};
|
|
1819
|
+
const valueEncoder = (value) => {
|
|
1820
|
+
if (Array.isArray(value)) {
|
|
1821
|
+
const encoded = value.map((x) => valueEncoder(x)).join('');
|
|
1822
|
+
const len = encoded.length / 2;
|
|
1823
|
+
return `02${pad(len)}${encoded}`;
|
|
1824
|
+
}
|
|
1825
|
+
else if (isPrim(value)) {
|
|
1826
|
+
return primEncoder(value);
|
|
1827
|
+
}
|
|
1828
|
+
else if (isBytes(value)) {
|
|
1829
|
+
return bytesEncoder(value);
|
|
1830
|
+
}
|
|
1831
|
+
else if (isString(value)) {
|
|
1832
|
+
return stringEncoder(value);
|
|
1833
|
+
}
|
|
1834
|
+
else if (isInt(value)) {
|
|
1835
|
+
return intEncoder(value);
|
|
1836
|
+
}
|
|
1837
|
+
throw new UnexpectedMichelsonValueError(JSON.stringify(value));
|
|
1838
|
+
};
|
|
1839
|
+
const valueDecoder = (value) => {
|
|
1840
|
+
const preamble = value.consume(1);
|
|
1841
|
+
switch (preamble[0]) {
|
|
1842
|
+
case 0x0a:
|
|
1843
|
+
return bytesDecoder(value);
|
|
1844
|
+
case 0x01:
|
|
1845
|
+
return stringDecoder(value);
|
|
1846
|
+
case 0x00:
|
|
1847
|
+
return intDecoder(value);
|
|
1848
|
+
case 0x02: {
|
|
1849
|
+
const val = new Uint8ArrayConsumer(extractRequiredLen(value));
|
|
1850
|
+
const results = [];
|
|
1851
|
+
while (val.length() > 0) {
|
|
1852
|
+
results.push(valueDecoder(val));
|
|
1853
|
+
}
|
|
1854
|
+
return results;
|
|
1855
|
+
}
|
|
1856
|
+
default:
|
|
1857
|
+
return primDecoder(value, preamble);
|
|
1858
|
+
}
|
|
1859
|
+
};
|
|
1860
|
+
const extractRequiredLen = (value, bytesLength = 4) => {
|
|
1861
|
+
const len = value.consume(bytesLength);
|
|
1862
|
+
const valueLen = parseInt(Buffer.from(len).toString('hex'), 16);
|
|
1863
|
+
return value.consume(valueLen);
|
|
1864
|
+
};
|
|
1865
|
+
/**
|
|
1866
|
+
* @description parse bytes into multiple items of an array
|
|
1867
|
+
* @param value Uint8ArrayConsumer class of forged segment to parse
|
|
1868
|
+
* @param bytesLength default 4 bytes for length of variable bytes
|
|
1869
|
+
* @returns array of Uint8Array values for each array item
|
|
1870
|
+
*/
|
|
1871
|
+
const stripLengthPrefixFromBytes = (value, bytesLength = 4) => {
|
|
1872
|
+
const ret = [];
|
|
1873
|
+
let values = value;
|
|
1874
|
+
while (values.length()) {
|
|
1875
|
+
const len = values.consume(bytesLength);
|
|
1876
|
+
const valueLen = parseInt(Buffer.from(len).toString('hex'), 16);
|
|
1877
|
+
ret.push(values.consume(valueLen));
|
|
1878
|
+
values = values.slice(valueLen + bytesLength);
|
|
1879
|
+
}
|
|
1880
|
+
return ret;
|
|
1881
|
+
};
|
|
1882
|
+
const bytesEncoder = (value) => {
|
|
1883
|
+
if (!/^([A-Fa-f0-9]{2})*$/.test(value.bytes)) {
|
|
1884
|
+
throw new InvalidHexStringError(value.bytes);
|
|
1885
|
+
}
|
|
1886
|
+
const len = value.bytes.length / 2;
|
|
1887
|
+
return `0a${pad(len)}${value.bytes}`;
|
|
1888
|
+
};
|
|
1889
|
+
const bytesDecoder = (value) => {
|
|
1890
|
+
const bytes = extractRequiredLen(value);
|
|
1891
|
+
return {
|
|
1892
|
+
bytes: Buffer.from(bytes).toString('hex'),
|
|
1893
|
+
};
|
|
1894
|
+
};
|
|
1895
|
+
const stringEncoder = (value) => {
|
|
1896
|
+
const str = Buffer.from(value.string, 'utf8').toString('hex');
|
|
1897
|
+
const hexLength = str.length / 2;
|
|
1898
|
+
return `01${pad(hexLength)}${str}`;
|
|
1899
|
+
};
|
|
1900
|
+
const stringDecoder = (value) => {
|
|
1901
|
+
const str = extractRequiredLen(value);
|
|
1902
|
+
return {
|
|
1903
|
+
string: Buffer.from(str).toString('utf8'),
|
|
1904
|
+
};
|
|
1905
|
+
};
|
|
1906
|
+
const intEncoder = ({ int }) => {
|
|
1907
|
+
const num = new BigNumber(int, 10);
|
|
1908
|
+
const positiveMark = num.toString(2)[0] === '-' ? '1' : '0';
|
|
1909
|
+
const binary = num.toString(2).replace(/-/g, '');
|
|
1910
|
+
const pad = binary.length <= 6
|
|
1911
|
+
? 6
|
|
1912
|
+
: (binary.length - 6) % 7
|
|
1913
|
+
? binary.length + 7 - ((binary.length - 6) % 7)
|
|
1914
|
+
: binary.length;
|
|
1915
|
+
const splitted = binary.padStart(pad, '0').match(/\d{6,7}/g);
|
|
1916
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1917
|
+
const reversed = splitted.reverse();
|
|
1918
|
+
reversed[0] = positiveMark + reversed[0];
|
|
1919
|
+
const numHex = reversed.map((x, i) =>
|
|
1920
|
+
// Add one to the last chunk
|
|
1921
|
+
parseInt((i === reversed.length - 1 ? '0' : '1') + x, 2)
|
|
1922
|
+
.toString(16)
|
|
1923
|
+
.padStart(2, '0'));
|
|
1924
|
+
return `00${numHex.join('')}`;
|
|
1925
|
+
};
|
|
1926
|
+
const intDecoder = (value) => {
|
|
1927
|
+
let c = value.consume(1)[0];
|
|
1928
|
+
const hexNumber = [];
|
|
1929
|
+
const isNotLastChunkMask = 1 << 7;
|
|
1930
|
+
while (c & isNotLastChunkMask) {
|
|
1931
|
+
hexNumber.push(c);
|
|
1932
|
+
c = value.consume(1)[0];
|
|
1933
|
+
}
|
|
1934
|
+
hexNumber.push(c);
|
|
1935
|
+
const isNegative = !!((1 << 6) & hexNumber[0]);
|
|
1936
|
+
hexNumber[0] = hexNumber[0] & 0b1111111;
|
|
1937
|
+
const numBin = hexNumber
|
|
1938
|
+
.map((x, i) => x
|
|
1939
|
+
.toString(2)
|
|
1940
|
+
.slice(i === 0 ? -6 : -7)
|
|
1941
|
+
.padStart(i === 0 ? 6 : 7, '0'))
|
|
1942
|
+
.reverse();
|
|
1943
|
+
let num = new BigNumber(numBin.join(''), 2);
|
|
1944
|
+
if (isNegative) {
|
|
1945
|
+
num = num.times(-1);
|
|
1946
|
+
}
|
|
1947
|
+
return {
|
|
1948
|
+
int: num.toFixed(),
|
|
1949
|
+
};
|
|
1950
|
+
};
|
|
1951
|
+
const primEncoder = (value) => {
|
|
1952
|
+
const hasAnnot = +Array.isArray(value.annots);
|
|
1953
|
+
const argsCount = Array.isArray(value.args) ? value.args.length : 0;
|
|
1954
|
+
// Specify the number of args max is 3 without annotation
|
|
1955
|
+
const preamble = pad(Math.min(2 * argsCount + hasAnnot + 0x03, 9), 2);
|
|
1956
|
+
const op = opMappingReverse[value.prim];
|
|
1957
|
+
let encodedArgs = (value.args || []).map((arg) => valueEncoder(arg)).join('');
|
|
1958
|
+
const encodedAnnots = Array.isArray(value.annots) ? encodeAnnots(value.annots) : '';
|
|
1959
|
+
if ((value.prim === 'LAMBDA' || value.prim === 'LAMBDA_REC') && argsCount) {
|
|
1960
|
+
encodedArgs = pad(encodedArgs.length / 2) + encodedArgs + pad(0);
|
|
1961
|
+
}
|
|
1962
|
+
if ((value.prim === 'pair' || value.prim === 'Pair') && argsCount > 2) {
|
|
1963
|
+
encodedArgs =
|
|
1964
|
+
encodedAnnots === ''
|
|
1965
|
+
? pad(encodedArgs.length / 2) + encodedArgs + pad(0)
|
|
1966
|
+
: pad(encodedArgs.length / 2) + encodedArgs;
|
|
1967
|
+
}
|
|
1968
|
+
if (value.prim === 'view' && value.args) {
|
|
1969
|
+
encodedArgs = pad(encodedArgs.length / 2) + encodedArgs + pad(0);
|
|
1970
|
+
}
|
|
1971
|
+
return `${preamble}${op}${encodedArgs}${encodedAnnots}`;
|
|
1972
|
+
};
|
|
1973
|
+
const primDecoder = (value, preamble) => {
|
|
1974
|
+
const hasAnnot = (preamble[0] - 0x03) % 2 === 1;
|
|
1975
|
+
let argsCount = Math.floor((preamble[0] - 0x03) / 2);
|
|
1976
|
+
const op = value.consume(1)[0].toString(16).padStart(2, '0');
|
|
1977
|
+
const result = {
|
|
1978
|
+
prim: opMapping[op],
|
|
1979
|
+
};
|
|
1980
|
+
if (opMapping[op] === 'LAMBDA' || opMapping[op] === 'LAMBDA_REC') {
|
|
1981
|
+
value.consume(4);
|
|
1982
|
+
}
|
|
1983
|
+
if (opMapping[op] === 'view') {
|
|
1984
|
+
if (argsCount != 0) {
|
|
1985
|
+
return primViewDecoder(value, result);
|
|
1986
|
+
}
|
|
1987
|
+
else {
|
|
1988
|
+
return result;
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
let combPairArgs;
|
|
1992
|
+
let combPairAnnots;
|
|
1993
|
+
if ((opMapping[op] === 'pair' || opMapping[op] === 'Pair') && argsCount > 2) {
|
|
1994
|
+
combPairArgs = decodeCombPair(value);
|
|
1995
|
+
argsCount = 0;
|
|
1996
|
+
combPairAnnots = decodeAnnots(value);
|
|
1997
|
+
}
|
|
1998
|
+
const args = new Array(argsCount).fill(0).map(() => valueDecoder(value));
|
|
1999
|
+
if (opMapping[op] === 'LAMBDA' || opMapping[op] === 'LAMBDA_REC') {
|
|
2000
|
+
value.consume(4);
|
|
2001
|
+
}
|
|
2002
|
+
if (combPairArgs) {
|
|
2003
|
+
result['args'] = combPairArgs;
|
|
2004
|
+
}
|
|
2005
|
+
else if (args.length) {
|
|
2006
|
+
result['args'] = args;
|
|
2007
|
+
}
|
|
2008
|
+
if (combPairAnnots && combPairAnnots[0] !== '') {
|
|
2009
|
+
result['annots'] = combPairAnnots;
|
|
2010
|
+
}
|
|
2011
|
+
else if (hasAnnot) {
|
|
2012
|
+
result['annots'] = decodeAnnots(value);
|
|
2013
|
+
}
|
|
2014
|
+
return result;
|
|
2015
|
+
};
|
|
2016
|
+
const primViewDecoder = (value, result) => {
|
|
2017
|
+
value.consume(4);
|
|
2018
|
+
result['args'] = new Array(4).fill(0).map(() => valueDecoder(value));
|
|
2019
|
+
value.consume(4);
|
|
2020
|
+
return result;
|
|
2021
|
+
};
|
|
2022
|
+
const decodeCombPair = (val) => {
|
|
2023
|
+
const array = new Uint8ArrayConsumer(extractRequiredLen(val));
|
|
2024
|
+
const args = [];
|
|
2025
|
+
while (array.length() > 0) {
|
|
2026
|
+
args.push(valueDecoder(array));
|
|
2027
|
+
}
|
|
2028
|
+
return args;
|
|
2029
|
+
};
|
|
2030
|
+
const encodeAnnots = (value) => {
|
|
2031
|
+
const mergedAnnot = value
|
|
2032
|
+
.map((x) => {
|
|
2033
|
+
return Buffer.from(x, 'utf8').toString('hex');
|
|
2034
|
+
})
|
|
2035
|
+
.join('20');
|
|
2036
|
+
const len = mergedAnnot.length / 2;
|
|
2037
|
+
return `${pad(len)}${mergedAnnot}`;
|
|
2038
|
+
};
|
|
2039
|
+
const decodeAnnots = (val) => {
|
|
2040
|
+
const len = val.consume(4);
|
|
2041
|
+
const annotLen = parseInt(Buffer.from(len).toString('hex'), 16);
|
|
2042
|
+
const restOfAnnot = val.consume(annotLen);
|
|
2043
|
+
const restOfAnnotHex = Buffer.from(restOfAnnot).toString('hex');
|
|
2044
|
+
return restOfAnnotHex.split('20').map((x) => Buffer.from(x, 'hex').toString('utf8'));
|
|
2045
|
+
};
|
|
2046
|
+
|
|
1802
2047
|
// https://tezos.gitlab.io/shell/p2p_api.html specifies data types and structure for forging
|
|
1803
2048
|
const prefixEncoder = (prefix$1) => (str) => {
|
|
1804
2049
|
return buf2hex(Buffer.from(b58cdecode(str, prefix[prefix$1])));
|
|
@@ -1820,10 +2065,13 @@ const publicKeyHashDecoder = (val) => {
|
|
|
1820
2065
|
else if (prefix[0] === 0x02) {
|
|
1821
2066
|
return prefixDecoder(Prefix.TZ3)(val);
|
|
1822
2067
|
}
|
|
2068
|
+
else if (prefix[0] === 0x03) {
|
|
2069
|
+
return prefixDecoder(Prefix.TZ4)(val);
|
|
2070
|
+
}
|
|
1823
2071
|
};
|
|
1824
2072
|
const publicKeyHashesDecoder = (val) => {
|
|
1825
2073
|
if (!boolDecoder(val)) {
|
|
1826
|
-
return
|
|
2074
|
+
return;
|
|
1827
2075
|
}
|
|
1828
2076
|
const publicKeyHashes = [];
|
|
1829
2077
|
val.consume(4);
|
|
@@ -1966,7 +2214,7 @@ const publicKeyHashEncoder = (val) => {
|
|
|
1966
2214
|
case Prefix.TZ4:
|
|
1967
2215
|
return '03' + prefixEncoder(Prefix.TZ4)(val);
|
|
1968
2216
|
default:
|
|
1969
|
-
throw new InvalidKeyHashError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
2217
|
+
throw new InvalidKeyHashError$1(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
1970
2218
|
` expecting one for the following "${Prefix.TZ1}", "${Prefix.TZ2}", "${Prefix.TZ3}" or "${Prefix.TZ4}".`);
|
|
1971
2219
|
}
|
|
1972
2220
|
};
|
|
@@ -1991,6 +2239,8 @@ const publicKeyEncoder = (val) => {
|
|
|
1991
2239
|
return '01' + prefixEncoder(Prefix.SPPK)(val);
|
|
1992
2240
|
case Prefix.P2PK:
|
|
1993
2241
|
return '02' + prefixEncoder(Prefix.P2PK)(val);
|
|
2242
|
+
case Prefix.BLPK:
|
|
2243
|
+
return '03' + prefixEncoder(Prefix.BLPK)(val);
|
|
1994
2244
|
default:
|
|
1995
2245
|
throw new InvalidPublicKeyError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
1996
2246
|
` expecting one of the following '${Prefix.EDPK}', '${Prefix.SPPK}', '${Prefix.P2PK}' or '${Prefix.BLPK}'.`);
|
|
@@ -2033,6 +2283,8 @@ const publicKeyDecoder = (val) => {
|
|
|
2033
2283
|
return prefixDecoder(Prefix.SPPK)(val);
|
|
2034
2284
|
case 0x02:
|
|
2035
2285
|
return prefixDecoder(Prefix.P2PK)(val);
|
|
2286
|
+
case 0x03:
|
|
2287
|
+
return prefixDecoder(Prefix.BLPK)(val);
|
|
2036
2288
|
default:
|
|
2037
2289
|
throw new InvalidPublicKeyError(val.toString(), invalidDetail(ValidationResult.NO_PREFIX_MATCHED));
|
|
2038
2290
|
}
|
|
@@ -2205,6 +2457,45 @@ const depositsLimitDecoder = (value) => {
|
|
|
2205
2457
|
return zarithDecoder(value);
|
|
2206
2458
|
}
|
|
2207
2459
|
};
|
|
2460
|
+
const signatureV1Encoder = (val) => {
|
|
2461
|
+
const signaturePrefix = val.substring(0, 5);
|
|
2462
|
+
switch (signaturePrefix) {
|
|
2463
|
+
case Prefix.EDSIG:
|
|
2464
|
+
return paddedBytesEncoder(prefixEncoder(Prefix.EDSIG)(val));
|
|
2465
|
+
case Prefix.SPSIG:
|
|
2466
|
+
return paddedBytesEncoder(prefixEncoder(Prefix.SPSIG)(val));
|
|
2467
|
+
case Prefix.P2SIG:
|
|
2468
|
+
return paddedBytesEncoder(prefixEncoder(Prefix.P2SIG)(val));
|
|
2469
|
+
case Prefix.BLSIG:
|
|
2470
|
+
return paddedBytesEncoder(prefixEncoder(Prefix.BLSIG)(val));
|
|
2471
|
+
default:
|
|
2472
|
+
throw new InvalidSignatureError(val, invalidDetail(ValidationResult.NO_PREFIX_MATCHED) +
|
|
2473
|
+
` expecting one of the following '${Prefix.EDSIG}', '${Prefix.SPSIG}', '${Prefix.P2SIG}' or '${Prefix.BLSIG}'.`);
|
|
2474
|
+
}
|
|
2475
|
+
};
|
|
2476
|
+
const signatureV1Decoder = (val) => {
|
|
2477
|
+
val.consume(4);
|
|
2478
|
+
if (val.length().toString() === '96') {
|
|
2479
|
+
return prefixDecoder(Prefix.BLSIG)(val);
|
|
2480
|
+
}
|
|
2481
|
+
else {
|
|
2482
|
+
throw new ProhibitedActionError('currently we only support decoding of BLSIG signatures');
|
|
2483
|
+
}
|
|
2484
|
+
};
|
|
2485
|
+
const signatureProofEncoder = (val) => {
|
|
2486
|
+
if (val) {
|
|
2487
|
+
return boolEncoder(true) + signatureV1Encoder(val);
|
|
2488
|
+
}
|
|
2489
|
+
else {
|
|
2490
|
+
return boolEncoder(false);
|
|
2491
|
+
}
|
|
2492
|
+
};
|
|
2493
|
+
const signatureProofDecoder = (value) => {
|
|
2494
|
+
const hasProof = boolDecoder(value);
|
|
2495
|
+
if (hasProof) {
|
|
2496
|
+
return signatureV1Decoder(value);
|
|
2497
|
+
}
|
|
2498
|
+
};
|
|
2208
2499
|
const paddedBytesEncoder = (val, paddingLength = 8) => {
|
|
2209
2500
|
return `${pad(val.length / 2, paddingLength)}${val}`;
|
|
2210
2501
|
};
|
|
@@ -2358,6 +2649,7 @@ const UpdateConsensusKeySchema = {
|
|
|
2358
2649
|
gas_limit: CODEC.ZARITH,
|
|
2359
2650
|
storage_limit: CODEC.ZARITH,
|
|
2360
2651
|
pk: CODEC.PUBLIC_KEY,
|
|
2652
|
+
proof: CODEC.SIGNATURE_PROOF,
|
|
2361
2653
|
};
|
|
2362
2654
|
const DrainDelegateSchema = {
|
|
2363
2655
|
consensus_key: CODEC.PKH,
|
|
@@ -2477,7 +2769,7 @@ const schemaDecoder = (decoders) => (schema) => (value) => {
|
|
|
2477
2769
|
}, {});
|
|
2478
2770
|
};
|
|
2479
2771
|
|
|
2480
|
-
const
|
|
2772
|
+
const decoders = {
|
|
2481
2773
|
[CODEC.SECRET]: (val) => toHexString(val.consume(20)),
|
|
2482
2774
|
[CODEC.RAW]: (val) => toHexString(val.consume(32)),
|
|
2483
2775
|
[CODEC.TZ1]: tz1Decoder,
|
|
@@ -2503,36 +2795,37 @@ const decodersProto021 = {
|
|
|
2503
2795
|
[CODEC.ENTRYPOINT]: entrypointNameDecoder,
|
|
2504
2796
|
[CODEC.BURN_LIMIT]: burnLimitDecoder,
|
|
2505
2797
|
[CODEC.DEPOSITS_LIMIT]: depositsLimitDecoder,
|
|
2798
|
+
[CODEC.SIGNATURE_PROOF]: signatureProofDecoder,
|
|
2506
2799
|
[CODEC.PVM_KIND]: pvmKindDecoder,
|
|
2507
2800
|
[CODEC.PADDED_BYTES]: paddedBytesDecoder,
|
|
2508
2801
|
[CODEC.SMART_ROLLUP_MESSAGE]: smartRollupMessageDecoder,
|
|
2509
2802
|
[CODEC.SLOT_HEADER]: slotHeaderDecoder,
|
|
2510
2803
|
};
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2804
|
+
decoders[CODEC.OPERATION] = operationDecoder(decoders);
|
|
2805
|
+
decoders[CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaDecoder(decoders)(ActivationSchema)(val);
|
|
2806
|
+
decoders[CODEC.OP_FAILING_NOOP] = (val) => schemaDecoder(decoders)(FailingNoopSchema)(val);
|
|
2807
|
+
decoders[CODEC.OP_DELEGATION] = (val) => schemaDecoder(decoders)(DelegationSchema)(val);
|
|
2808
|
+
decoders[CODEC.OP_TRANSACTION] = (val) => schemaDecoder(decoders)(TransactionSchema)(val);
|
|
2809
|
+
decoders[CODEC.OP_ORIGINATION] = (val) => schemaDecoder(decoders)(OriginationSchema)(val);
|
|
2810
|
+
decoders[CODEC.OP_BALLOT] = (val) => schemaDecoder(decoders)(BallotSchema)(val);
|
|
2811
|
+
decoders[CODEC.OP_ATTESTATION] = (val) => schemaDecoder(decoders)(AttestationSchema)(val);
|
|
2812
|
+
decoders[CODEC.OP_ATTESTATION_WITH_DAL] = (val) => schemaDecoder(decoders)(AttestationWithDalSchema)(val);
|
|
2813
|
+
decoders[CODEC.OP_SEED_NONCE_REVELATION] = (val) => schemaDecoder(decoders)(SeedNonceRevelationSchema)(val);
|
|
2814
|
+
decoders[CODEC.OP_PROPOSALS] = (val) => schemaDecoder(decoders)(ProposalsSchema)(val);
|
|
2815
|
+
decoders[CODEC.OP_REVEAL] = (val) => schemaDecoder(decoders)(RevealSchema)(val);
|
|
2816
|
+
decoders[CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaDecoder(decoders)(RegisterGlobalConstantSchema)(val);
|
|
2817
|
+
decoders[CODEC.OP_TRANSFER_TICKET] = (val) => schemaDecoder(decoders)(TransferTicketSchema)(val);
|
|
2818
|
+
decoders[CODEC.OP_INCREASE_PAID_STORAGE] = (val) => schemaDecoder(decoders)(IncreasePaidStorageSchema)(val);
|
|
2819
|
+
decoders[CODEC.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaDecoder(decoders)(UpdateConsensusKeySchema)(val);
|
|
2820
|
+
decoders[CODEC.OP_DRAIN_DELEGATE] = (val) => schemaDecoder(decoders)(DrainDelegateSchema)(val);
|
|
2821
|
+
decoders[CODEC.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaDecoder(decoders)(SmartRollupOriginateSchema)(val);
|
|
2822
|
+
decoders[CODEC.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaDecoder(decoders)(SmartRollupAddMessagesSchema)(val);
|
|
2823
|
+
decoders[CODEC.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaDecoder(decoders)(SmartRollupExecuteOutboxMessageSchema)(val);
|
|
2824
|
+
decoders[CODEC.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaDecoder(decoders)(DalPublishCommitmentSchema)(val);
|
|
2825
|
+
decoders[CODEC.MANAGER] = schemaDecoder(decoders)(ManagerOperationSchema);
|
|
2826
|
+
decoders[CODEC.OP_SET_DEPOSITS_LIMIT] = (val) => schemaDecoder(decoders)(SetDepositsLimitSchema)(val);
|
|
2534
2827
|
|
|
2535
|
-
const encoders = {
|
|
2828
|
+
const encoders$1 = {
|
|
2536
2829
|
[CODEC$1.SECRET]: (val) => val,
|
|
2537
2830
|
[CODEC$1.RAW]: (val) => val,
|
|
2538
2831
|
[CODEC$1.TZ1]: tz1Encoder$1,
|
|
@@ -2542,7 +2835,7 @@ const encoders = {
|
|
|
2542
2835
|
[CODEC$1.PKH]: publicKeyHashEncoder$1,
|
|
2543
2836
|
[CODEC$1.PKH_ARR]: publicKeyHashesEncoder$1,
|
|
2544
2837
|
[CODEC$1.DELEGATE]: delegateEncoder$1,
|
|
2545
|
-
[CODEC$1.SCRIPT]: scriptEncoder,
|
|
2838
|
+
[CODEC$1.SCRIPT]: scriptEncoder$1,
|
|
2546
2839
|
[CODEC$1.BALLOT_STATEMENT]: ballotEncoder$1,
|
|
2547
2840
|
[CODEC$1.PROPOSAL]: proposalEncoder$1,
|
|
2548
2841
|
[CODEC$1.PROPOSAL_ARR]: proposalsEncoder$1,
|
|
@@ -2558,37 +2851,38 @@ const encoders = {
|
|
|
2558
2851
|
[CODEC$1.ENTRYPOINT]: entrypointNameEncoder$1,
|
|
2559
2852
|
[CODEC$1.BURN_LIMIT]: burnLimitEncoder$1,
|
|
2560
2853
|
[CODEC$1.DEPOSITS_LIMIT]: depositsLimitEncoder$1,
|
|
2561
|
-
[CODEC$1.SIGNATURE_PROOF]: signatureProofEncoder,
|
|
2854
|
+
[CODEC$1.SIGNATURE_PROOF]: signatureProofEncoder$1,
|
|
2562
2855
|
[CODEC$1.PVM_KIND]: pvmKindEncoder$1,
|
|
2563
2856
|
[CODEC$1.PADDED_BYTES]: paddedBytesEncoder$1,
|
|
2564
2857
|
[CODEC$1.SMART_ROLLUP_MESSAGE]: smartRollupMessageEncoder$1,
|
|
2565
2858
|
[CODEC$1.SLOT_HEADER]: slotHeaderEncoder$1,
|
|
2566
2859
|
};
|
|
2567
|
-
encoders[CODEC$1.OPERATION] = operationEncoder$1(encoders);
|
|
2568
|
-
encoders[CODEC$1.OP_ACTIVATE_ACCOUNT] = (val) => schemaEncoder$1(encoders)(ActivationSchema$1)(val);
|
|
2569
|
-
encoders[CODEC$1.OP_DELEGATION] = (val) => schemaEncoder$1(encoders)(DelegationSchema$1)(val);
|
|
2570
|
-
encoders[CODEC$1.OP_TRANSACTION] = (val) => schemaEncoder$1(encoders)(TransactionSchema$1)(val);
|
|
2571
|
-
encoders[CODEC$1.OP_ORIGINATION] = (val) => schemaEncoder$1(encoders)(OriginationSchema$1)(val);
|
|
2572
|
-
encoders[CODEC$1.OP_BALLOT] = (val) => schemaEncoder$1(encoders)(BallotSchema$1)(val);
|
|
2573
|
-
encoders[CODEC$1.OP_ATTESTATION] = (val) => schemaEncoder$1(encoders)(AttestationSchema$1)(val);
|
|
2574
|
-
encoders[CODEC$1.OP_ATTESTATION_WITH_DAL] = (val) => schemaEncoder$1(encoders)(AttestationWithDalSchema$1)(val);
|
|
2575
|
-
encoders[CODEC$1.OP_SEED_NONCE_REVELATION] = (val) => schemaEncoder$1(encoders)(SeedNonceRevelationSchema$1)(val);
|
|
2576
|
-
encoders[CODEC$1.OP_PROPOSALS] = (val) => schemaEncoder$1(encoders)(ProposalsSchema$1)(val);
|
|
2577
|
-
encoders[CODEC$1.OP_REVEAL] = (val) => schemaEncoder$1(encoders)(RevealSchema$1)(val);
|
|
2578
|
-
encoders[CODEC$1.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaEncoder$1(encoders)(RegisterGlobalConstantSchema$1)(val);
|
|
2579
|
-
encoders[CODEC$1.OP_TRANSFER_TICKET] = (val) => schemaEncoder$1(encoders)(TransferTicketSchema$1)(val);
|
|
2580
|
-
encoders[CODEC$1.OP_INCREASE_PAID_STORAGE] = (val) => schemaEncoder$1(encoders)(IncreasePaidStorageSchema$1)(val);
|
|
2581
|
-
encoders[CODEC$1.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaEncoder$1(encoders)(UpdateConsensusKeySchema$1)(val);
|
|
2582
|
-
encoders[CODEC$1.
|
|
2583
|
-
encoders[CODEC$1.
|
|
2584
|
-
encoders[CODEC$1.
|
|
2585
|
-
encoders[CODEC$1.
|
|
2586
|
-
encoders[CODEC$1.
|
|
2587
|
-
encoders[CODEC$1.
|
|
2588
|
-
encoders[CODEC$1.
|
|
2589
|
-
encoders[CODEC$1.
|
|
2860
|
+
encoders$1[CODEC$1.OPERATION] = operationEncoder$1(encoders$1);
|
|
2861
|
+
encoders$1[CODEC$1.OP_ACTIVATE_ACCOUNT] = (val) => schemaEncoder$1(encoders$1)(ActivationSchema$1)(val);
|
|
2862
|
+
encoders$1[CODEC$1.OP_DELEGATION] = (val) => schemaEncoder$1(encoders$1)(DelegationSchema$1)(val);
|
|
2863
|
+
encoders$1[CODEC$1.OP_TRANSACTION] = (val) => schemaEncoder$1(encoders$1)(TransactionSchema$1)(val);
|
|
2864
|
+
encoders$1[CODEC$1.OP_ORIGINATION] = (val) => schemaEncoder$1(encoders$1)(OriginationSchema$1)(val);
|
|
2865
|
+
encoders$1[CODEC$1.OP_BALLOT] = (val) => schemaEncoder$1(encoders$1)(BallotSchema$1)(val);
|
|
2866
|
+
encoders$1[CODEC$1.OP_ATTESTATION] = (val) => schemaEncoder$1(encoders$1)(AttestationSchema$1)(val);
|
|
2867
|
+
encoders$1[CODEC$1.OP_ATTESTATION_WITH_DAL] = (val) => schemaEncoder$1(encoders$1)(AttestationWithDalSchema$1)(val);
|
|
2868
|
+
encoders$1[CODEC$1.OP_SEED_NONCE_REVELATION] = (val) => schemaEncoder$1(encoders$1)(SeedNonceRevelationSchema$1)(val);
|
|
2869
|
+
encoders$1[CODEC$1.OP_PROPOSALS] = (val) => schemaEncoder$1(encoders$1)(ProposalsSchema$1)(val);
|
|
2870
|
+
encoders$1[CODEC$1.OP_REVEAL] = (val) => schemaEncoder$1(encoders$1)(RevealSchema$1)(val);
|
|
2871
|
+
encoders$1[CODEC$1.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaEncoder$1(encoders$1)(RegisterGlobalConstantSchema$1)(val);
|
|
2872
|
+
encoders$1[CODEC$1.OP_TRANSFER_TICKET] = (val) => schemaEncoder$1(encoders$1)(TransferTicketSchema$1)(val);
|
|
2873
|
+
encoders$1[CODEC$1.OP_INCREASE_PAID_STORAGE] = (val) => schemaEncoder$1(encoders$1)(IncreasePaidStorageSchema$1)(val);
|
|
2874
|
+
encoders$1[CODEC$1.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaEncoder$1(encoders$1)(UpdateConsensusKeySchema$1)(val);
|
|
2875
|
+
encoders$1[CODEC$1.OP_UPDATE_COMPANION_KEY] = (val) => schemaEncoder$1(encoders$1)(UpdateCompanionKeySchema)(val);
|
|
2876
|
+
encoders$1[CODEC$1.OP_DRAIN_DELEGATE] = (val) => schemaEncoder$1(encoders$1)(DrainDelegateSchema$1)(val);
|
|
2877
|
+
encoders$1[CODEC$1.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaEncoder$1(encoders$1)(SmartRollupOriginateSchema$1)(val);
|
|
2878
|
+
encoders$1[CODEC$1.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaEncoder$1(encoders$1)(SmartRollupAddMessagesSchema$1)(val);
|
|
2879
|
+
encoders$1[CODEC$1.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaEncoder$1(encoders$1)(SmartRollupExecuteOutboxMessageSchema$1)(val);
|
|
2880
|
+
encoders$1[CODEC$1.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaEncoder$1(encoders$1)(DalPublishCommitmentSchema$1)(val);
|
|
2881
|
+
encoders$1[CODEC$1.MANAGER] = schemaEncoder$1(encoders$1)(ManagerOperationSchema$1);
|
|
2882
|
+
encoders$1[CODEC$1.OP_SET_DEPOSITS_LIMIT] = (val) => schemaEncoder$1(encoders$1)(SetDepositsLimitSchema$1)(val);
|
|
2883
|
+
encoders$1[CODEC$1.OP_FAILING_NOOP] = (val) => schemaEncoder$1(encoders$1)(FailingNoopSchema$1)(val);
|
|
2590
2884
|
|
|
2591
|
-
const
|
|
2885
|
+
const encoders = {
|
|
2592
2886
|
[CODEC.SECRET]: (val) => val,
|
|
2593
2887
|
[CODEC.RAW]: (val) => val,
|
|
2594
2888
|
[CODEC.TZ1]: tz1Encoder,
|
|
@@ -2614,34 +2908,35 @@ const encodersProto021 = {
|
|
|
2614
2908
|
[CODEC.ENTRYPOINT]: entrypointNameEncoder,
|
|
2615
2909
|
[CODEC.BURN_LIMIT]: burnLimitEncoder,
|
|
2616
2910
|
[CODEC.DEPOSITS_LIMIT]: depositsLimitEncoder,
|
|
2911
|
+
[CODEC.SIGNATURE_PROOF]: signatureProofEncoder,
|
|
2617
2912
|
[CODEC.PVM_KIND]: pvmKindEncoder,
|
|
2618
2913
|
[CODEC.PADDED_BYTES]: paddedBytesEncoder,
|
|
2619
2914
|
[CODEC.SMART_ROLLUP_MESSAGE]: smartRollupMessageEncoder,
|
|
2620
2915
|
[CODEC.SLOT_HEADER]: slotHeaderEncoder,
|
|
2621
2916
|
};
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2917
|
+
encoders[CODEC.OPERATION] = operationEncoder(encoders);
|
|
2918
|
+
encoders[CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaEncoder(encoders)(ActivationSchema)(val);
|
|
2919
|
+
encoders[CODEC.OP_DELEGATION] = (val) => schemaEncoder(encoders)(DelegationSchema)(val);
|
|
2920
|
+
encoders[CODEC.OP_TRANSACTION] = (val) => schemaEncoder(encoders)(TransactionSchema)(val);
|
|
2921
|
+
encoders[CODEC.OP_ORIGINATION] = (val) => schemaEncoder(encoders)(OriginationSchema)(val);
|
|
2922
|
+
encoders[CODEC.OP_BALLOT] = (val) => schemaEncoder(encoders)(BallotSchema)(val);
|
|
2923
|
+
encoders[CODEC.OP_ATTESTATION] = (val) => schemaEncoder(encoders)(AttestationSchema)(val);
|
|
2924
|
+
encoders[CODEC.OP_ATTESTATION_WITH_DAL] = (val) => schemaEncoder(encoders)(AttestationWithDalSchema)(val);
|
|
2925
|
+
encoders[CODEC.OP_SEED_NONCE_REVELATION] = (val) => schemaEncoder(encoders)(SeedNonceRevelationSchema)(val);
|
|
2926
|
+
encoders[CODEC.OP_PROPOSALS] = (val) => schemaEncoder(encoders)(ProposalsSchema)(val);
|
|
2927
|
+
encoders[CODEC.OP_REVEAL] = (val) => schemaEncoder(encoders)(RevealSchema)(val);
|
|
2928
|
+
encoders[CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaEncoder(encoders)(RegisterGlobalConstantSchema)(val);
|
|
2929
|
+
encoders[CODEC.OP_TRANSFER_TICKET] = (val) => schemaEncoder(encoders)(TransferTicketSchema)(val);
|
|
2930
|
+
encoders[CODEC.OP_INCREASE_PAID_STORAGE] = (val) => schemaEncoder(encoders)(IncreasePaidStorageSchema)(val);
|
|
2931
|
+
encoders[CODEC.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaEncoder(encoders)(UpdateConsensusKeySchema)(val);
|
|
2932
|
+
encoders[CODEC.OP_DRAIN_DELEGATE] = (val) => schemaEncoder(encoders)(DrainDelegateSchema)(val);
|
|
2933
|
+
encoders[CODEC.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaEncoder(encoders)(SmartRollupOriginateSchema)(val);
|
|
2934
|
+
encoders[CODEC.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaEncoder(encoders)(SmartRollupAddMessagesSchema)(val);
|
|
2935
|
+
encoders[CODEC.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaEncoder(encoders)(SmartRollupExecuteOutboxMessageSchema)(val);
|
|
2936
|
+
encoders[CODEC.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaEncoder(encoders)(DalPublishCommitmentSchema)(val);
|
|
2937
|
+
encoders[CODEC.MANAGER] = schemaEncoder(encoders)(ManagerOperationSchema);
|
|
2938
|
+
encoders[CODEC.OP_SET_DEPOSITS_LIMIT] = (val) => schemaEncoder(encoders)(SetDepositsLimitSchema)(val);
|
|
2939
|
+
encoders[CODEC.OP_FAILING_NOOP] = (val) => schemaEncoder(encoders)(FailingNoopSchema)(val);
|
|
2645
2940
|
|
|
2646
2941
|
const OperationKindMapping = {
|
|
2647
2942
|
activate_account: ActivationSchema$1,
|
|
@@ -2658,6 +2953,7 @@ const OperationKindMapping = {
|
|
|
2658
2953
|
transfer_ticket: TransferTicketSchema$1,
|
|
2659
2954
|
increase_paid_storage: IncreasePaidStorageSchema$1,
|
|
2660
2955
|
update_consensus_key: UpdateConsensusKeySchema$1,
|
|
2956
|
+
update_companion_key: UpdateCompanionKeySchema,
|
|
2661
2957
|
drain_delegate: DrainDelegateSchema$1,
|
|
2662
2958
|
set_deposits_limit: SetDepositsLimitSchema$1,
|
|
2663
2959
|
smart_rollup_originate: SmartRollupOriginateSchema$1,
|
|
@@ -2717,6 +3013,7 @@ var ProtocolsHash;
|
|
|
2717
3013
|
ProtocolsHash["PsParisCZ"] = "PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi";
|
|
2718
3014
|
ProtocolsHash["PsQuebecn"] = "PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg";
|
|
2719
3015
|
ProtocolsHash["PsRiotuma"] = "PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7";
|
|
3016
|
+
ProtocolsHash["PtSeouLou"] = "PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh";
|
|
2720
3017
|
ProtocolsHash["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
|
|
2721
3018
|
})(ProtocolsHash || (ProtocolsHash = {}));
|
|
2722
3019
|
const protoLevel = {
|
|
@@ -2741,6 +3038,7 @@ const protoLevel = {
|
|
|
2741
3038
|
PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi: 20,
|
|
2742
3039
|
PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg: 21,
|
|
2743
3040
|
PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7: 22,
|
|
3041
|
+
PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh: 23,
|
|
2744
3042
|
ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK: 23,
|
|
2745
3043
|
};
|
|
2746
3044
|
function ProtoInferiorTo(a, b) {
|
|
@@ -2749,32 +3047,32 @@ function ProtoInferiorTo(a, b) {
|
|
|
2749
3047
|
|
|
2750
3048
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
2751
3049
|
const VERSION = {
|
|
2752
|
-
"commitHash": "
|
|
2753
|
-
"version": "
|
|
3050
|
+
"commitHash": "13639ef56845fbb7e93bcbd37d3f6d0457b0872b",
|
|
3051
|
+
"version": "23.0.0-RC.0"
|
|
2754
3052
|
};
|
|
2755
3053
|
|
|
2756
3054
|
/**
|
|
2757
3055
|
* @packageDocumentation
|
|
2758
3056
|
* @module @taquito/local-forging
|
|
2759
3057
|
*/
|
|
2760
|
-
const PROTOCOL_CURRENT = ProtocolsHash.
|
|
3058
|
+
const PROTOCOL_CURRENT = ProtocolsHash.PtSeouLou;
|
|
2761
3059
|
function getCodec(codec, _proto) {
|
|
2762
|
-
// use
|
|
2763
|
-
if (_proto === ProtocolsHash.
|
|
3060
|
+
// use encodersProto022 & decodersProto022 if it's rio or prior
|
|
3061
|
+
if (_proto === ProtocolsHash.PsRiotuma || ProtoInferiorTo(_proto, ProtocolsHash.PsRiotuma)) {
|
|
2764
3062
|
return {
|
|
2765
|
-
encoder:
|
|
3063
|
+
encoder: encoders[codec],
|
|
2766
3064
|
decoder: (hex) => {
|
|
2767
3065
|
const consumer = Uint8ArrayConsumer.fromHexString(hex);
|
|
2768
|
-
return
|
|
3066
|
+
return decoders[codec](consumer);
|
|
2769
3067
|
},
|
|
2770
3068
|
};
|
|
2771
3069
|
}
|
|
2772
3070
|
else {
|
|
2773
3071
|
return {
|
|
2774
|
-
encoder: encoders[codec],
|
|
3072
|
+
encoder: encoders$1[codec],
|
|
2775
3073
|
decoder: (hex) => {
|
|
2776
3074
|
const consumer = Uint8ArrayConsumer.fromHexString(hex);
|
|
2777
|
-
return decoders[codec](consumer);
|
|
3075
|
+
return decoders$1[codec](consumer);
|
|
2778
3076
|
},
|
|
2779
3077
|
};
|
|
2780
3078
|
}
|
|
@@ -2795,7 +3093,7 @@ class LocalForger {
|
|
|
2795
3093
|
forge(params) {
|
|
2796
3094
|
const branchValidation = validateBlock(params.branch);
|
|
2797
3095
|
if (branchValidation !== ValidationResult.VALID) {
|
|
2798
|
-
throw new InvalidBlockHashError(params.branch,
|
|
3096
|
+
throw new InvalidBlockHashError(params.branch, branchValidation);
|
|
2799
3097
|
}
|
|
2800
3098
|
for (const content of params.contents) {
|
|
2801
3099
|
if (!validateOperationKind(content.kind)) {
|
|
@@ -2821,6 +3119,12 @@ class LocalForger {
|
|
|
2821
3119
|
else if (content.kind === 'update_consensus_key' && diff[0] === 'proof') {
|
|
2822
3120
|
continue;
|
|
2823
3121
|
}
|
|
3122
|
+
else if (content.kind === 'update_companion_key' && diff[0] === 'proof') {
|
|
3123
|
+
continue;
|
|
3124
|
+
}
|
|
3125
|
+
else if (content.kind === 'reveal' && diff[0] === 'proof') {
|
|
3126
|
+
continue;
|
|
3127
|
+
}
|
|
2824
3128
|
else {
|
|
2825
3129
|
throw new InvalidOperationSchemaError(content, `missing properties "${diff.join(', ')}"`);
|
|
2826
3130
|
}
|
|
@@ -2838,5 +3142,5 @@ class LocalForger {
|
|
|
2838
3142
|
}
|
|
2839
3143
|
const localForger = new LocalForger();
|
|
2840
3144
|
|
|
2841
|
-
export { CODEC$1 as CODEC, LocalForger, ProtocolsHash, Uint8ArrayConsumer, VERSION, decoders, encoders, getCodec, localForger, opMapping$1 as opMapping, opMappingReverse };
|
|
3145
|
+
export { CODEC$1 as CODEC, LocalForger, ProtocolsHash, Uint8ArrayConsumer, VERSION, decoders$1 as decoders, encoders$1 as encoders, getCodec, localForger, opMapping$1 as opMapping, opMappingReverse$1 as opMappingReverse };
|
|
2842
3146
|
//# sourceMappingURL=taquito-local-forging.es6.js.map
|