@taquito/local-forging 23.0.3 → 24.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.
@@ -14,7 +14,7 @@
14
14
  * Copyright (c) 2018 Andrew Kishino
15
15
  */
16
16
  // See: https://tezos.gitlab.io/protocols/005_babylon.html#transactions-now-have-an-entrypoint
17
- const ENTRYPOINT_MAX_LENGTH$1 = 31;
17
+ const ENTRYPOINT_MAX_LENGTH = 31;
18
18
  exports.CODEC = void 0;
19
19
  (function (CODEC) {
20
20
  CODEC["SECRET"] = "secret";
@@ -73,7 +73,7 @@
73
73
  CODEC["SLOT_HEADER"] = "slot_header";
74
74
  })(exports.CODEC || (exports.CODEC = {}));
75
75
  // See https://tezos.gitlab.io/shell/p2p_api.html#alpha-michelson-v1-primitives-enumeration-unsigned-8-bit-integer
76
- const opMapping$1 = {
76
+ const opMapping = {
77
77
  '00': 'parameter',
78
78
  '01': 'storage',
79
79
  '02': 'code',
@@ -233,16 +233,18 @@
233
233
  '9c': 'NAT',
234
234
  '9d': 'Ticket',
235
235
  '9e': 'IS_IMPLICIT_ACCOUNT',
236
+ '9f': 'INDEX_ADDRESS',
237
+ 'a0': 'GET_ADDRESS_INDEX',
236
238
  };
237
- const opMappingReverse$1 = (() => {
239
+ const opMappingReverse = (() => {
238
240
  const result = {};
239
- Object.keys(opMapping$1).forEach((key) => {
240
- result[opMapping$1[key]] = key;
241
+ Object.keys(opMapping).forEach((key) => {
242
+ result[opMapping[key]] = key;
241
243
  });
242
244
  return result;
243
245
  })();
244
246
  // See https://tezos.gitlab.io/shell/p2p_api.html
245
- const kindMapping$1 = {
247
+ const kindMapping = {
246
248
  0x04: 'activate_account',
247
249
  0x6b: 'reveal',
248
250
  0x6e: 'delegation',
@@ -266,16 +268,16 @@
266
268
  0xe6: 'dal_publish_commitment',
267
269
  0x11: 'failing_noop',
268
270
  };
269
- const kindMappingReverse$1 = (() => {
271
+ const kindMappingReverse = (() => {
270
272
  const result = {};
271
- Object.keys(kindMapping$1).forEach((key) => {
273
+ Object.keys(kindMapping).forEach((key) => {
272
274
  const keyNum = typeof key === 'string' ? parseInt(key, 10) : key;
273
- result[kindMapping$1[keyNum]] = pad(keyNum, 2);
275
+ result[kindMapping[keyNum]] = pad(keyNum, 2);
274
276
  });
275
277
  return result;
276
278
  })();
277
279
  // See https://tezos.gitlab.io/protocols/005_babylon.html#transactions-now-have-an-entrypoint
278
- const entrypointMapping$1 = {
280
+ const entrypointMapping = {
279
281
  '00': 'default',
280
282
  '01': 'root',
281
283
  '02': 'do',
@@ -287,10 +289,10 @@
287
289
  '08': 'finalize_unstake',
288
290
  '09': 'set_delegate_parameters',
289
291
  };
290
- const entrypointMappingReverse$1 = (() => {
292
+ const entrypointMappingReverse = (() => {
291
293
  const result = {};
292
- Object.keys(entrypointMapping$1).forEach((key) => {
293
- result[entrypointMapping$1[key]] = key;
294
+ Object.keys(entrypointMapping).forEach((key) => {
295
+ result[entrypointMapping[key]] = key;
294
296
  });
295
297
  return result;
296
298
  })();
@@ -317,7 +319,7 @@
317
319
  super();
318
320
  this.entrypoint = entrypoint;
319
321
  this.name = 'OversizedEntryPointError';
320
- this.message = `Invalid entrypoint length "${entrypoint.length}", maximum length is "${ENTRYPOINT_MAX_LENGTH$1}".`;
322
+ this.message = `Invalid entrypoint length "${entrypoint.length}", maximum length is "${ENTRYPOINT_MAX_LENGTH}".`;
321
323
  }
322
324
  }
323
325
  /**
@@ -488,73 +490,73 @@
488
490
  }
489
491
  }
490
492
 
491
- const isPrim$1 = (value) => {
493
+ const isPrim = (value) => {
492
494
  return 'prim' in value;
493
495
  };
494
- const isBytes$1 = (value) => {
496
+ const isBytes = (value) => {
495
497
  return 'bytes' in value && typeof value.bytes === 'string';
496
498
  };
497
- const isString$1 = (value) => {
499
+ const isString = (value) => {
498
500
  return 'string' in value && typeof value.string === 'string';
499
501
  };
500
- const isInt$1 = (value) => {
502
+ const isInt = (value) => {
501
503
  return 'int' in value && typeof value.int === 'string';
502
504
  };
503
- const scriptEncoder$1 = (script) => {
504
- const code = valueEncoder$1(script.code);
505
- const storage = valueEncoder$1(script.storage);
505
+ const scriptEncoder = (script) => {
506
+ const code = valueEncoder(script.code);
507
+ const storage = valueEncoder(script.storage);
506
508
  return `${pad(code.length / 2, 8)}${code}${pad(storage.length / 2, 8)}${storage}`;
507
509
  };
508
- const scriptDecoder$1 = (value) => {
509
- const code = extractRequiredLen$1(value);
510
- const storage = extractRequiredLen$1(value);
510
+ const scriptDecoder = (value) => {
511
+ const code = extractRequiredLen(value);
512
+ const storage = extractRequiredLen(value);
511
513
  return {
512
- code: valueDecoder$1(new Uint8ArrayConsumer(code)),
513
- storage: valueDecoder$1(new Uint8ArrayConsumer(storage)),
514
+ code: valueDecoder(new Uint8ArrayConsumer(code)),
515
+ storage: valueDecoder(new Uint8ArrayConsumer(storage)),
514
516
  };
515
517
  };
516
- const valueEncoder$1 = (value) => {
518
+ const valueEncoder = (value) => {
517
519
  if (Array.isArray(value)) {
518
- const encoded = value.map((x) => valueEncoder$1(x)).join('');
520
+ const encoded = value.map((x) => valueEncoder(x)).join('');
519
521
  const len = encoded.length / 2;
520
522
  return `02${pad(len)}${encoded}`;
521
523
  }
522
- else if (isPrim$1(value)) {
523
- return primEncoder$1(value);
524
+ else if (isPrim(value)) {
525
+ return primEncoder(value);
524
526
  }
525
- else if (isBytes$1(value)) {
526
- return bytesEncoder$1(value);
527
+ else if (isBytes(value)) {
528
+ return bytesEncoder(value);
527
529
  }
528
- else if (isString$1(value)) {
529
- return stringEncoder$1(value);
530
+ else if (isString(value)) {
531
+ return stringEncoder(value);
530
532
  }
531
- else if (isInt$1(value)) {
532
- return intEncoder$1(value);
533
+ else if (isInt(value)) {
534
+ return intEncoder(value);
533
535
  }
534
536
  throw new UnexpectedMichelsonValueError(JSON.stringify(value));
535
537
  };
536
- const valueDecoder$1 = (value) => {
538
+ const valueDecoder = (value) => {
537
539
  const preamble = value.consume(1);
538
540
  switch (preamble[0]) {
539
541
  case 0x0a:
540
- return bytesDecoder$1(value);
542
+ return bytesDecoder(value);
541
543
  case 0x01:
542
- return stringDecoder$1(value);
544
+ return stringDecoder(value);
543
545
  case 0x00:
544
- return intDecoder$1(value);
546
+ return intDecoder(value);
545
547
  case 0x02: {
546
- const val = new Uint8ArrayConsumer(extractRequiredLen$1(value));
548
+ const val = new Uint8ArrayConsumer(extractRequiredLen(value));
547
549
  const results = [];
548
550
  while (val.length() > 0) {
549
- results.push(valueDecoder$1(val));
551
+ results.push(valueDecoder(val));
550
552
  }
551
553
  return results;
552
554
  }
553
555
  default:
554
- return primDecoder$1(value, preamble);
556
+ return primDecoder(value, preamble);
555
557
  }
556
558
  };
557
- const extractRequiredLen$1 = (value, bytesLength = 4) => {
559
+ const extractRequiredLen = (value, bytesLength = 4) => {
558
560
  const len = value.consume(bytesLength);
559
561
  const valueLen = parseInt(Buffer.from(len).toString('hex'), 16);
560
562
  return value.consume(valueLen);
@@ -565,7 +567,7 @@
565
567
  * @param bytesLength default 4 bytes for length of variable bytes
566
568
  * @returns array of Uint8Array values for each array item
567
569
  */
568
- const stripLengthPrefixFromBytes$1 = (value, bytesLength = 4) => {
570
+ const stripLengthPrefixFromBytes = (value, bytesLength = 4) => {
569
571
  const ret = [];
570
572
  let values = value;
571
573
  while (values.length()) {
@@ -576,31 +578,31 @@
576
578
  }
577
579
  return ret;
578
580
  };
579
- const bytesEncoder$1 = (value) => {
581
+ const bytesEncoder = (value) => {
580
582
  if (!/^([A-Fa-f0-9]{2})*$/.test(value.bytes)) {
581
583
  throw new core.InvalidHexStringError(value.bytes);
582
584
  }
583
585
  const len = value.bytes.length / 2;
584
586
  return `0a${pad(len)}${value.bytes}`;
585
587
  };
586
- const bytesDecoder$1 = (value) => {
587
- const bytes = extractRequiredLen$1(value);
588
+ const bytesDecoder = (value) => {
589
+ const bytes = extractRequiredLen(value);
588
590
  return {
589
591
  bytes: Buffer.from(bytes).toString('hex'),
590
592
  };
591
593
  };
592
- const stringEncoder$1 = (value) => {
594
+ const stringEncoder = (value) => {
593
595
  const str = Buffer.from(value.string, 'utf8').toString('hex');
594
596
  const hexLength = str.length / 2;
595
597
  return `01${pad(hexLength)}${str}`;
596
598
  };
597
- const stringDecoder$1 = (value) => {
598
- const str = extractRequiredLen$1(value);
599
+ const stringDecoder = (value) => {
600
+ const str = extractRequiredLen(value);
599
601
  return {
600
602
  string: Buffer.from(str).toString('utf8'),
601
603
  };
602
604
  };
603
- const intEncoder$1 = ({ int }) => {
605
+ const intEncoder = ({ int }) => {
604
606
  const num = new BigNumber.BigNumber(int, 10);
605
607
  const positiveMark = num.toString(2)[0] === '-' ? '1' : '0';
606
608
  const binary = num.toString(2).replace(/-/g, '');
@@ -620,7 +622,7 @@
620
622
  .padStart(2, '0'));
621
623
  return `00${numHex.join('')}`;
622
624
  };
623
- const intDecoder$1 = (value) => {
625
+ const intDecoder = (value) => {
624
626
  let c = value.consume(1)[0];
625
627
  const hexNumber = [];
626
628
  const isNotLastChunkMask = 1 << 7;
@@ -645,14 +647,14 @@
645
647
  int: num.toFixed(),
646
648
  };
647
649
  };
648
- const primEncoder$1 = (value) => {
650
+ const primEncoder = (value) => {
649
651
  const hasAnnot = +Array.isArray(value.annots);
650
652
  const argsCount = Array.isArray(value.args) ? value.args.length : 0;
651
653
  // Specify the number of args max is 3 without annotation
652
654
  const preamble = pad(Math.min(2 * argsCount + hasAnnot + 0x03, 9), 2);
653
- const op = opMappingReverse$1[value.prim];
654
- let encodedArgs = (value.args || []).map((arg) => valueEncoder$1(arg)).join('');
655
- const encodedAnnots = Array.isArray(value.annots) ? encodeAnnots$1(value.annots) : '';
655
+ const op = opMappingReverse[value.prim];
656
+ let encodedArgs = (value.args || []).map((arg) => valueEncoder(arg)).join('');
657
+ const encodedAnnots = Array.isArray(value.annots) ? encodeAnnots(value.annots) : '';
656
658
  if ((value.prim === 'LAMBDA' || value.prim === 'LAMBDA_REC') && argsCount) {
657
659
  encodedArgs = pad(encodedArgs.length / 2) + encodedArgs + pad(0);
658
660
  }
@@ -667,19 +669,19 @@
667
669
  }
668
670
  return `${preamble}${op}${encodedArgs}${encodedAnnots}`;
669
671
  };
670
- const primDecoder$1 = (value, preamble) => {
672
+ const primDecoder = (value, preamble) => {
671
673
  const hasAnnot = (preamble[0] - 0x03) % 2 === 1;
672
674
  let argsCount = Math.floor((preamble[0] - 0x03) / 2);
673
675
  const op = value.consume(1)[0].toString(16).padStart(2, '0');
674
676
  const result = {
675
- prim: opMapping$1[op],
677
+ prim: opMapping[op],
676
678
  };
677
- if (opMapping$1[op] === 'LAMBDA' || opMapping$1[op] === 'LAMBDA_REC') {
679
+ if (opMapping[op] === 'LAMBDA' || opMapping[op] === 'LAMBDA_REC') {
678
680
  value.consume(4);
679
681
  }
680
- if (opMapping$1[op] === 'view') {
682
+ if (opMapping[op] === 'view') {
681
683
  if (argsCount != 0) {
682
- return primViewDecoder$1(value, result);
684
+ return primViewDecoder(value, result);
683
685
  }
684
686
  else {
685
687
  return result;
@@ -687,13 +689,13 @@
687
689
  }
688
690
  let combPairArgs;
689
691
  let combPairAnnots;
690
- if ((opMapping$1[op] === 'pair' || opMapping$1[op] === 'Pair') && argsCount > 2) {
691
- combPairArgs = decodeCombPair$1(value);
692
+ if ((opMapping[op] === 'pair' || opMapping[op] === 'Pair') && argsCount > 2) {
693
+ combPairArgs = decodeCombPair(value);
692
694
  argsCount = 0;
693
- combPairAnnots = decodeAnnots$1(value);
695
+ combPairAnnots = decodeAnnots(value);
694
696
  }
695
- const args = new Array(argsCount).fill(0).map(() => valueDecoder$1(value));
696
- if (opMapping$1[op] === 'LAMBDA' || opMapping$1[op] === 'LAMBDA_REC') {
697
+ const args = new Array(argsCount).fill(0).map(() => valueDecoder(value));
698
+ if (opMapping[op] === 'LAMBDA' || opMapping[op] === 'LAMBDA_REC') {
697
699
  value.consume(4);
698
700
  }
699
701
  if (combPairArgs) {
@@ -706,25 +708,25 @@
706
708
  result['annots'] = combPairAnnots;
707
709
  }
708
710
  else if (hasAnnot) {
709
- result['annots'] = decodeAnnots$1(value);
711
+ result['annots'] = decodeAnnots(value);
710
712
  }
711
713
  return result;
712
714
  };
713
- const primViewDecoder$1 = (value, result) => {
715
+ const primViewDecoder = (value, result) => {
714
716
  value.consume(4);
715
- result['args'] = new Array(4).fill(0).map(() => valueDecoder$1(value));
717
+ result['args'] = new Array(4).fill(0).map(() => valueDecoder(value));
716
718
  value.consume(4);
717
719
  return result;
718
720
  };
719
- const decodeCombPair$1 = (val) => {
720
- const array = new Uint8ArrayConsumer(extractRequiredLen$1(val));
721
+ const decodeCombPair = (val) => {
722
+ const array = new Uint8ArrayConsumer(extractRequiredLen(val));
721
723
  const args = [];
722
724
  while (array.length() > 0) {
723
- args.push(valueDecoder$1(array));
725
+ args.push(valueDecoder(array));
724
726
  }
725
727
  return args;
726
728
  };
727
- const encodeAnnots$1 = (value) => {
729
+ const encodeAnnots = (value) => {
728
730
  const mergedAnnot = value
729
731
  .map((x) => {
730
732
  return Buffer.from(x, 'utf8').toString('hex');
@@ -733,7 +735,7 @@
733
735
  const len = mergedAnnot.length / 2;
734
736
  return `${pad(len)}${mergedAnnot}`;
735
737
  };
736
- const decodeAnnots$1 = (val) => {
738
+ const decodeAnnots = (val) => {
737
739
  const len = val.consume(4);
738
740
  const annotLen = parseInt(Buffer.from(len).toString('hex'), 16);
739
741
  const restOfAnnot = val.consume(annotLen);
@@ -742,63 +744,63 @@
742
744
  };
743
745
 
744
746
  // https://tezos.gitlab.io/shell/p2p_api.html specifies data types and structure for forging
745
- const prefixEncoder$1 = (prefix) => (str) => {
747
+ const prefixEncoder = (prefix) => (str) => {
746
748
  const [pl] = utils.b58DecodeAndCheckPrefix(str, [prefix]);
747
749
  return utils.buf2hex(pl);
748
750
  };
749
- const prefixDecoder$1 = (pre) => (str) => {
751
+ const prefixDecoder = (pre) => (str) => {
750
752
  const val = str.consume(utils.payloadLength[pre]);
751
753
  return utils.b58Encode(val, pre);
752
754
  };
753
- const tz1Decoder$1 = prefixDecoder$1(utils.PrefixV2.Ed25519PublicKeyHash);
754
- const branchDecoder$1 = prefixDecoder$1(utils.PrefixV2.BlockHash);
755
- const publicKeyHashDecoder$1 = (val) => {
755
+ const tz1Decoder = prefixDecoder(utils.PrefixV2.Ed25519PublicKeyHash);
756
+ const branchDecoder = prefixDecoder(utils.PrefixV2.BlockHash);
757
+ const publicKeyHashDecoder = (val) => {
756
758
  const prefix = val.consume(1);
757
759
  if (prefix[0] === 0x00) {
758
- return prefixDecoder$1(utils.PrefixV2.Ed25519PublicKeyHash)(val);
760
+ return prefixDecoder(utils.PrefixV2.Ed25519PublicKeyHash)(val);
759
761
  }
760
762
  else if (prefix[0] === 0x01) {
761
- return prefixDecoder$1(utils.PrefixV2.Secp256k1PublicKeyHash)(val);
763
+ return prefixDecoder(utils.PrefixV2.Secp256k1PublicKeyHash)(val);
762
764
  }
763
765
  else if (prefix[0] === 0x02) {
764
- return prefixDecoder$1(utils.PrefixV2.P256PublicKeyHash)(val);
766
+ return prefixDecoder(utils.PrefixV2.P256PublicKeyHash)(val);
765
767
  }
766
768
  else if (prefix[0] === 0x03) {
767
- return prefixDecoder$1(utils.PrefixV2.BLS12_381PublicKeyHash)(val);
769
+ return prefixDecoder(utils.PrefixV2.BLS12_381PublicKeyHash)(val);
768
770
  }
769
771
  };
770
- const publicKeyHashesDecoder$1 = (val) => {
771
- if (!boolDecoder$1(val)) {
772
+ const publicKeyHashesDecoder = (val) => {
773
+ if (!boolDecoder(val)) {
772
774
  return;
773
775
  }
774
776
  const publicKeyHashes = [];
775
777
  val.consume(4);
776
778
  while (val.length() > 0) {
777
- publicKeyHashes.push(publicKeyHashDecoder$1(val));
779
+ publicKeyHashes.push(publicKeyHashDecoder(val));
778
780
  }
779
781
  return publicKeyHashes;
780
782
  };
781
- const branchEncoder$1 = prefixEncoder$1(utils.PrefixV2.BlockHash);
782
- const tz1Encoder$1 = prefixEncoder$1(utils.PrefixV2.Ed25519PublicKeyHash);
783
- const boolEncoder$1 = (bool) => (bool ? 'ff' : '00');
784
- const proposalEncoder$1 = (proposal) => {
785
- return prefixEncoder$1(utils.PrefixV2.ProtocolHash)(proposal);
783
+ const branchEncoder = prefixEncoder(utils.PrefixV2.BlockHash);
784
+ const tz1Encoder = prefixEncoder(utils.PrefixV2.Ed25519PublicKeyHash);
785
+ const boolEncoder = (bool) => (bool ? 'ff' : '00');
786
+ const proposalEncoder = (proposal) => {
787
+ return prefixEncoder(utils.PrefixV2.ProtocolHash)(proposal);
786
788
  };
787
- const proposalDecoder$1 = (proposal) => {
788
- return prefixDecoder$1(utils.PrefixV2.ProtocolHash)(proposal);
789
+ const proposalDecoder = (proposal) => {
790
+ return prefixDecoder(utils.PrefixV2.ProtocolHash)(proposal);
789
791
  };
790
- const proposalsDecoder$1 = (proposal) => {
792
+ const proposalsDecoder = (proposal) => {
791
793
  const proposals = [];
792
794
  proposal.consume(4);
793
795
  while (proposal.length() > 0) {
794
- proposals.push(proposalDecoder$1(proposal));
796
+ proposals.push(proposalDecoder(proposal));
795
797
  }
796
798
  return proposals;
797
799
  };
798
- const proposalsEncoder$1 = (proposals) => {
799
- return pad(32 * proposals.length) + proposals.map((x) => proposalEncoder$1(x)).join('');
800
+ const proposalsEncoder = (proposals) => {
801
+ return pad(32 * proposals.length) + proposals.map((x) => proposalEncoder(x)).join('');
800
802
  };
801
- const ballotEncoder$1 = (ballot) => {
803
+ const ballotEncoder = (ballot) => {
802
804
  switch (ballot) {
803
805
  case 'yay':
804
806
  return '00';
@@ -810,7 +812,7 @@
810
812
  throw new InvalidBallotValueError(ballot);
811
813
  }
812
814
  };
813
- const ballotDecoder$1 = (ballot) => {
815
+ const ballotDecoder = (ballot) => {
814
816
  const value = ballot.consume(1);
815
817
  switch (value[0]) {
816
818
  case 0x00:
@@ -823,7 +825,7 @@
823
825
  throw new DecodeBallotValueError(value[0].toString());
824
826
  }
825
827
  };
826
- const pvmKindEncoder$1 = (pvm) => {
828
+ const pvmKindEncoder = (pvm) => {
827
829
  switch (pvm) {
828
830
  case 'arith':
829
831
  return '00';
@@ -835,7 +837,7 @@
835
837
  throw new UnsupportedPvmKindError(pvm);
836
838
  }
837
839
  };
838
- const pvmKindDecoder$1 = (pvm) => {
840
+ const pvmKindDecoder = (pvm) => {
839
841
  const value = pvm.consume(1);
840
842
  switch (value[0]) {
841
843
  case 0x00:
@@ -848,15 +850,15 @@
848
850
  throw new DecodePvmKindError(value[0].toString());
849
851
  }
850
852
  };
851
- const delegateEncoder$1 = (val) => {
853
+ const delegateEncoder = (val) => {
852
854
  if (val) {
853
- return boolEncoder$1(true) + publicKeyHashEncoder$1(val);
855
+ return boolEncoder(true) + publicKeyHashEncoder(val);
854
856
  }
855
857
  else {
856
- return boolEncoder$1(false);
858
+ return boolEncoder(false);
857
859
  }
858
860
  };
859
- const int32Encoder$1 = (val) => {
861
+ const int32Encoder = (val) => {
860
862
  const num = parseInt(String(val), 10);
861
863
  const byte = [];
862
864
  for (let i = 0; i < 4; i++) {
@@ -865,7 +867,7 @@
865
867
  }
866
868
  return Buffer.from(byte).toString('hex');
867
869
  };
868
- const int32Decoder$1 = (val) => {
870
+ const int32Decoder = (val) => {
869
871
  const num = val.consume(4);
870
872
  let finalNum = 0;
871
873
  for (let i = 0; i < num.length; i++) {
@@ -873,7 +875,7 @@
873
875
  }
874
876
  return finalNum;
875
877
  };
876
- const int16Encoder$1 = (val) => {
878
+ const int16Encoder = (val) => {
877
879
  const num = parseInt(String(val), 10);
878
880
  const byte = [];
879
881
  for (let i = 0; i < 2; i++) {
@@ -882,7 +884,7 @@
882
884
  }
883
885
  return Buffer.from(byte).toString('hex');
884
886
  };
885
- const int16Decoder$1 = (val) => {
887
+ const int16Decoder = (val) => {
886
888
  const num = val.consume(2);
887
889
  let finalNum = 0;
888
890
  for (let i = 0; i < num.length; i++) {
@@ -890,17 +892,17 @@
890
892
  }
891
893
  return finalNum;
892
894
  };
893
- const boolDecoder$1 = (val) => {
895
+ const boolDecoder = (val) => {
894
896
  const bool = val.consume(1);
895
897
  return bool[0] === 0xff;
896
898
  };
897
- const delegateDecoder$1 = (val) => {
898
- const hasDelegate = boolDecoder$1(val);
899
+ const delegateDecoder = (val) => {
900
+ const hasDelegate = boolDecoder(val);
899
901
  if (hasDelegate) {
900
- return publicKeyHashDecoder$1(val);
902
+ return publicKeyHashDecoder(val);
901
903
  }
902
904
  };
903
- const publicKeyHashEncoder$1 = (val) => {
905
+ const publicKeyHashEncoder = (val) => {
904
906
  try {
905
907
  return utils.b58DecodePublicKeyHash(val);
906
908
  }
@@ -908,19 +910,19 @@
908
910
  throw new core.InvalidKeyHashError(val, err instanceof core.ParameterValidationError ? err.result : undefined);
909
911
  }
910
912
  };
911
- const publicKeyHashesEncoder$1 = (val) => {
913
+ const publicKeyHashesEncoder = (val) => {
912
914
  if (!val) {
913
- return boolEncoder$1(false);
915
+ return boolEncoder(false);
914
916
  }
915
917
  if (val.length === 0) {
916
- return boolEncoder$1(true) + pad(0);
918
+ return boolEncoder(true) + pad(0);
917
919
  }
918
920
  const publicKeyHashes = val.reduce((prev, curr) => {
919
- return prev + publicKeyHashEncoder$1(curr);
921
+ return prev + publicKeyHashEncoder(curr);
920
922
  }, '');
921
- return boolEncoder$1(true) + pad(publicKeyHashes.length / 2) + publicKeyHashes;
923
+ return boolEncoder(true) + pad(publicKeyHashes.length / 2) + publicKeyHashes;
922
924
  };
923
- const publicKeyEncoder$1 = (val) => {
925
+ const publicKeyEncoder = (val) => {
924
926
  try {
925
927
  return utils.b58DecodePublicKey(val);
926
928
  }
@@ -928,12 +930,12 @@
928
930
  throw new utils.InvalidPublicKeyError(val, err instanceof core.ParameterValidationError ? err.result : undefined);
929
931
  }
930
932
  };
931
- const addressEncoder$1 = (val) => {
933
+ const addressEncoder = (val) => {
932
934
  return utils.b58DecodeAddress(val);
933
935
  };
934
- const smartRollupAddressEncoder$1 = (val) => {
936
+ const smartRollupAddressEncoder = (val) => {
935
937
  try {
936
- return prefixEncoder$1(utils.PrefixV2.SmartRollupHash)(val);
938
+ return prefixEncoder(utils.PrefixV2.SmartRollupHash)(val);
937
939
  }
938
940
  catch (err) {
939
941
  if (err instanceof core.ParameterValidationError) {
@@ -944,25 +946,25 @@
944
946
  }
945
947
  }
946
948
  };
947
- const smartContractAddressEncoder$1 = (val) => utils.b58DecodeAddress(val);
948
- const publicKeyDecoder$1 = (val) => {
949
+ const smartContractAddressEncoder = (val) => utils.b58DecodeAddress(val);
950
+ const publicKeyDecoder = (val) => {
949
951
  const preamble = val.consume(1);
950
952
  switch (preamble[0]) {
951
953
  case 0x00:
952
- return prefixDecoder$1(utils.PrefixV2.Ed25519PublicKey)(val);
954
+ return prefixDecoder(utils.PrefixV2.Ed25519PublicKey)(val);
953
955
  case 0x01:
954
- return prefixDecoder$1(utils.PrefixV2.Secp256k1PublicKey)(val);
956
+ return prefixDecoder(utils.PrefixV2.Secp256k1PublicKey)(val);
955
957
  case 0x02:
956
- return prefixDecoder$1(utils.PrefixV2.P256PublicKey)(val);
958
+ return prefixDecoder(utils.PrefixV2.P256PublicKey)(val);
957
959
  case 0x03:
958
- return prefixDecoder$1(utils.PrefixV2.BLS12_381PublicKey)(val);
960
+ return prefixDecoder(utils.PrefixV2.BLS12_381PublicKey)(val);
959
961
  default:
960
962
  throw new utils.InvalidPublicKeyError(undefined, utils.ValidationResult.NO_PREFIX_MATCHED);
961
963
  }
962
964
  };
963
- const smartRollupCommitmentHashEncoder$1 = (val) => {
965
+ const smartRollupCommitmentHashEncoder = (val) => {
964
966
  try {
965
- return prefixEncoder$1(utils.PrefixV2.SmartRollupCommitmentHash)(val);
967
+ return prefixEncoder(utils.PrefixV2.SmartRollupCommitmentHash)(val);
966
968
  }
967
969
  catch (err) {
968
970
  if (err instanceof core.ParameterValidationError) {
@@ -973,13 +975,13 @@
973
975
  }
974
976
  }
975
977
  };
976
- const addressDecoder$1 = (val) => {
978
+ const addressDecoder = (val) => {
977
979
  const preamble = val.consume(1);
978
980
  switch (preamble[0]) {
979
981
  case 0x00:
980
- return publicKeyHashDecoder$1(val);
982
+ return publicKeyHashDecoder(val);
981
983
  case 0x01: {
982
- const address = prefixDecoder$1(utils.PrefixV2.ContractHash)(val);
984
+ const address = prefixDecoder(utils.PrefixV2.ContractHash)(val);
983
985
  val.consume(1);
984
986
  return address;
985
987
  }
@@ -987,22 +989,22 @@
987
989
  throw new core.InvalidAddressError(val.toString(), ': Unable to decode.');
988
990
  }
989
991
  };
990
- const smartRollupAddressDecoder$1 = (val) => {
991
- return prefixDecoder$1(utils.PrefixV2.SmartRollupHash)(val);
992
+ const smartRollupAddressDecoder = (val) => {
993
+ return prefixDecoder(utils.PrefixV2.SmartRollupHash)(val);
992
994
  };
993
- const smartContractAddressDecoder$1 = (val) => {
995
+ const smartContractAddressDecoder = (val) => {
994
996
  const preamble = val.consume(1);
995
997
  if (preamble[0] === 0x01) {
996
- const scAddress = prefixDecoder$1(utils.PrefixV2.ContractHash)(val);
998
+ const scAddress = prefixDecoder(utils.PrefixV2.ContractHash)(val);
997
999
  val.consume(1);
998
1000
  return scAddress;
999
1001
  }
1000
1002
  throw new core.InvalidContractAddressError(val.toString(), utils.ValidationResult.NO_PREFIX_MATCHED);
1001
1003
  };
1002
- const smartRollupCommitmentHashDecoder$1 = (val) => {
1003
- return prefixDecoder$1(utils.PrefixV2.SmartRollupCommitmentHash)(val);
1004
+ const smartRollupCommitmentHashDecoder = (val) => {
1005
+ return prefixDecoder(utils.PrefixV2.SmartRollupCommitmentHash)(val);
1004
1006
  };
1005
- const zarithEncoder$1 = (n) => {
1007
+ const zarithEncoder = (n) => {
1006
1008
  const fn = [];
1007
1009
  let nn = new BigNumber(n, 10);
1008
1010
  if (nn.isNaN()) {
@@ -1026,7 +1028,7 @@
1026
1028
  }
1027
1029
  return fn.join('');
1028
1030
  };
1029
- const zarithDecoder$1 = (n) => {
1031
+ const zarithDecoder = (n) => {
1030
1032
  let mostSignificantByte = 0;
1031
1033
  while (mostSignificantByte < n.length() && (n.get(mostSignificantByte) & 128) !== 0) {
1032
1034
  mostSignificantByte += 1;
@@ -1040,97 +1042,97 @@
1040
1042
  n.consume(mostSignificantByte + 1);
1041
1043
  return new BigNumber(num).toString();
1042
1044
  };
1043
- const entrypointDecoder$1 = (value) => {
1045
+ const entrypointDecoder = (value) => {
1044
1046
  const preamble = pad(value.consume(1)[0], 2);
1045
- if (preamble in entrypointMapping$1) {
1046
- return entrypointMapping$1[preamble];
1047
+ if (preamble in entrypointMapping) {
1048
+ return entrypointMapping[preamble];
1047
1049
  }
1048
1050
  else {
1049
- const entry = extractRequiredLen$1(value, 1);
1051
+ const entry = extractRequiredLen(value, 1);
1050
1052
  const entrypoint = Buffer.from(entry).toString('utf8');
1051
- if (entrypoint.length > ENTRYPOINT_MAX_LENGTH$1) {
1053
+ if (entrypoint.length > ENTRYPOINT_MAX_LENGTH) {
1052
1054
  throw new OversizedEntryPointError(entrypoint);
1053
1055
  }
1054
1056
  return entrypoint;
1055
1057
  }
1056
1058
  };
1057
- const parametersDecoder$1 = (val) => {
1059
+ const parametersDecoder = (val) => {
1058
1060
  const preamble = val.consume(1);
1059
1061
  if (preamble[0] === 0x00) {
1060
1062
  return;
1061
1063
  }
1062
1064
  else {
1063
- const encodedEntrypoint = entrypointDecoder$1(val);
1064
- const params = extractRequiredLen$1(val);
1065
- const parameters = valueDecoder$1(new Uint8ArrayConsumer(params));
1065
+ const encodedEntrypoint = entrypointDecoder(val);
1066
+ const params = extractRequiredLen(val);
1067
+ const parameters = valueDecoder(new Uint8ArrayConsumer(params));
1066
1068
  return {
1067
1069
  entrypoint: encodedEntrypoint,
1068
1070
  value: parameters,
1069
1071
  };
1070
1072
  }
1071
1073
  };
1072
- const entrypointEncoder$1 = (entrypoint) => {
1073
- if (entrypoint in entrypointMappingReverse$1) {
1074
- return `${entrypointMappingReverse$1[entrypoint]}`;
1074
+ const entrypointEncoder = (entrypoint) => {
1075
+ if (entrypoint in entrypointMappingReverse) {
1076
+ return `${entrypointMappingReverse[entrypoint]}`;
1075
1077
  }
1076
1078
  else {
1077
- if (entrypoint.length > ENTRYPOINT_MAX_LENGTH$1) {
1079
+ if (entrypoint.length > ENTRYPOINT_MAX_LENGTH) {
1078
1080
  throw new OversizedEntryPointError(entrypoint);
1079
1081
  }
1080
1082
  const value = { string: entrypoint };
1081
- return `ff${valueEncoder$1(value).slice(8)}`;
1083
+ return `ff${valueEncoder(value).slice(8)}`;
1082
1084
  }
1083
1085
  };
1084
- const parametersEncoder$1 = (val) => {
1086
+ const parametersEncoder = (val) => {
1085
1087
  if (!val || (val.entrypoint === 'default' && 'prim' in val.value && val.value.prim === 'Unit')) {
1086
1088
  return '00';
1087
1089
  }
1088
- const encodedEntrypoint = entrypointEncoder$1(val.entrypoint);
1089
- const parameters = valueEncoder$1(val.value);
1090
+ const encodedEntrypoint = entrypointEncoder(val.entrypoint);
1091
+ const parameters = valueEncoder(val.value);
1090
1092
  const length = pad(parameters.length / 2);
1091
1093
  return `ff${encodedEntrypoint}${length}${parameters}`;
1092
1094
  };
1093
- const valueParameterEncoder$1 = (value) => {
1094
- const valueEncoded = valueEncoder$1(value);
1095
+ const valueParameterEncoder = (value) => {
1096
+ const valueEncoded = valueEncoder(value);
1095
1097
  return `${pad(valueEncoded.length / 2)}${valueEncoded}`;
1096
1098
  };
1097
- const valueParameterDecoder$1 = (val) => {
1098
- const value = extractRequiredLen$1(val);
1099
- return valueDecoder$1(new Uint8ArrayConsumer(value));
1099
+ const valueParameterDecoder = (val) => {
1100
+ const value = extractRequiredLen(val);
1101
+ return valueDecoder(new Uint8ArrayConsumer(value));
1100
1102
  };
1101
- const blockPayloadHashEncoder$1 = prefixEncoder$1(utils.PrefixV2.ValueHash);
1102
- const blockPayloadHashDecoder$1 = prefixDecoder$1(utils.PrefixV2.ValueHash);
1103
- const entrypointNameEncoder$1 = (entrypoint) => {
1103
+ const blockPayloadHashEncoder = prefixEncoder(utils.PrefixV2.ValueHash);
1104
+ const blockPayloadHashDecoder = prefixDecoder(utils.PrefixV2.ValueHash);
1105
+ const entrypointNameEncoder = (entrypoint) => {
1104
1106
  const value = { string: entrypoint };
1105
- return `${valueEncoder$1(value).slice(2)}`;
1107
+ return `${valueEncoder(value).slice(2)}`;
1106
1108
  };
1107
- const entrypointNameDecoder$1 = (val) => {
1108
- const entry = extractRequiredLen$1(val);
1109
+ const entrypointNameDecoder = (val) => {
1110
+ const entry = extractRequiredLen(val);
1109
1111
  return Buffer.from(entry).toString('utf8');
1110
1112
  };
1111
- const burnLimitEncoder$1 = (val) => {
1112
- return !val ? '00' : `ff${zarithEncoder$1(val)}`;
1113
+ const burnLimitEncoder = (val) => {
1114
+ return !val ? '00' : `ff${zarithEncoder(val)}`;
1113
1115
  };
1114
- const burnLimitDecoder$1 = (value) => {
1116
+ const burnLimitDecoder = (value) => {
1115
1117
  const prefix = value.consume(1);
1116
1118
  if (Buffer.from(prefix).toString('hex') !== '00') {
1117
- return zarithDecoder$1(value);
1119
+ return zarithDecoder(value);
1118
1120
  }
1119
1121
  };
1120
- const depositsLimitEncoder$1 = (val) => {
1121
- return !val ? '00' : `ff${zarithEncoder$1(val)}`;
1122
+ const depositsLimitEncoder = (val) => {
1123
+ return !val ? '00' : `ff${zarithEncoder(val)}`;
1122
1124
  };
1123
- const depositsLimitDecoder$1 = (value) => {
1125
+ const depositsLimitDecoder = (value) => {
1124
1126
  const prefix = value.consume(1);
1125
1127
  if (Buffer.from(prefix).toString('hex') !== '00') {
1126
- return zarithDecoder$1(value);
1128
+ return zarithDecoder(value);
1127
1129
  }
1128
1130
  };
1129
- const signatureV1Encoder$1 = (val) => {
1131
+ const signatureV1Encoder = (val) => {
1130
1132
  try {
1131
1133
  const [data, pre] = utils.b58DecodeAndCheckPrefix(val, utils.signaturePrefixes);
1132
1134
  if (pre === utils.PrefixV2.BLS12_381Signature) {
1133
- return paddedBytesEncoder$1(utils.buf2hex(data));
1135
+ return paddedBytesEncoder(utils.buf2hex(data));
1134
1136
  }
1135
1137
  else {
1136
1138
  throw new core.ProhibitedActionError('we only support encoding of BLSIG signatures from protocol Seoul');
@@ -1145,50 +1147,50 @@
1145
1147
  }
1146
1148
  }
1147
1149
  };
1148
- const signatureV1Decoder$1 = (val) => {
1150
+ const signatureV1Decoder = (val) => {
1149
1151
  val.consume(4);
1150
1152
  if (val.length().toString() === '96') {
1151
- return prefixDecoder$1(utils.PrefixV2.BLS12_381Signature)(val);
1153
+ return prefixDecoder(utils.PrefixV2.BLS12_381Signature)(val);
1152
1154
  }
1153
1155
  else {
1154
1156
  throw new core.ProhibitedActionError('we only support decoding of BLSIG signatures');
1155
1157
  }
1156
1158
  };
1157
- const signatureProofEncoder$1 = (val) => {
1159
+ const signatureProofEncoder = (val) => {
1158
1160
  if (val) {
1159
- return boolEncoder$1(true) + signatureV1Encoder$1(val);
1161
+ return boolEncoder(true) + signatureV1Encoder(val);
1160
1162
  }
1161
1163
  else {
1162
- return boolEncoder$1(false);
1164
+ return boolEncoder(false);
1163
1165
  }
1164
1166
  };
1165
- const signatureProofDecoder$1 = (value) => {
1166
- const hasProof = boolDecoder$1(value);
1167
+ const signatureProofDecoder = (value) => {
1168
+ const hasProof = boolDecoder(value);
1167
1169
  if (hasProof) {
1168
- return signatureV1Decoder$1(value);
1170
+ return signatureV1Decoder(value);
1169
1171
  }
1170
1172
  };
1171
- const paddedBytesEncoder$1 = (val, paddingLength = 8) => {
1173
+ const paddedBytesEncoder = (val, paddingLength = 8) => {
1172
1174
  return `${pad(val.length / 2, paddingLength)}${val}`;
1173
1175
  };
1174
- const paddedBytesDecoder$1 = (val) => {
1175
- const value = extractRequiredLen$1(val);
1176
+ const paddedBytesDecoder = (val) => {
1177
+ const value = extractRequiredLen(val);
1176
1178
  return Buffer.from(value).toString('hex');
1177
1179
  };
1178
- const smartRollupMessageEncoder$1 = (val) => {
1180
+ const smartRollupMessageEncoder = (val) => {
1179
1181
  const message = val.reduce((prev, curr) => {
1180
1182
  return prev + `${pad(curr.length / 2)}${curr}`;
1181
1183
  }, '');
1182
1184
  return `${pad(message.length / 2)}${message}`;
1183
1185
  };
1184
- const smartRollupMessageDecoder$1 = (val) => {
1185
- const valueArray = extractRequiredLen$1(val);
1186
- const ret = stripLengthPrefixFromBytes$1(new Uint8ArrayConsumer(valueArray));
1186
+ const smartRollupMessageDecoder = (val) => {
1187
+ const valueArray = extractRequiredLen(val);
1188
+ const ret = stripLengthPrefixFromBytes(new Uint8ArrayConsumer(valueArray));
1187
1189
  return ret.map((value) => Buffer.from(value).toString('hex'));
1188
1190
  };
1189
- const dalCommitmentEncoder$1 = (val) => {
1191
+ const dalCommitmentEncoder = (val) => {
1190
1192
  try {
1191
- return prefixEncoder$1(utils.PrefixV2.SlotHeader)(val);
1193
+ return prefixEncoder(utils.PrefixV2.SlotHeader)(val);
1192
1194
  }
1193
1195
  catch (err) {
1194
1196
  if (err instanceof core.ParameterValidationError) {
@@ -1199,30 +1201,30 @@
1199
1201
  }
1200
1202
  }
1201
1203
  };
1202
- const dalCommitmentDecoder$1 = (val) => {
1203
- return prefixDecoder$1(utils.PrefixV2.SlotHeader)(val);
1204
+ const dalCommitmentDecoder = (val) => {
1205
+ return prefixDecoder(utils.PrefixV2.SlotHeader)(val);
1204
1206
  };
1205
- const slotHeaderEncoder$1 = (val) => {
1206
- return pad(val.slot_index, 2) + dalCommitmentEncoder$1(val.commitment) + val.commitment_proof;
1207
+ const slotHeaderEncoder = (val) => {
1208
+ return pad(val.slot_index, 2) + dalCommitmentEncoder(val.commitment) + val.commitment_proof;
1207
1209
  };
1208
- const slotHeaderDecoder$1 = (val) => {
1210
+ const slotHeaderDecoder = (val) => {
1209
1211
  const preamble = val.consume(1);
1210
1212
  return {
1211
1213
  slot_index: Number(preamble[0].toString(10)),
1212
- commitment: dalCommitmentDecoder$1(val),
1214
+ commitment: dalCommitmentDecoder(val),
1213
1215
  commitment_proof: toHexString(val.consume(96)), // rpcForger expect commitment_proof bytes to be len 96
1214
1216
  };
1215
1217
  };
1216
1218
 
1217
- const ManagerOperationSchema$1 = {
1219
+ const ManagerOperationSchema = {
1218
1220
  branch: exports.CODEC.BRANCH,
1219
1221
  contents: [exports.CODEC.OPERATION],
1220
1222
  };
1221
- const ActivationSchema$1 = {
1223
+ const ActivationSchema = {
1222
1224
  pkh: exports.CODEC.TZ1,
1223
1225
  secret: exports.CODEC.SECRET,
1224
1226
  };
1225
- const RevealSchema$1 = {
1227
+ const RevealSchema = {
1226
1228
  source: exports.CODEC.PKH,
1227
1229
  fee: exports.CODEC.ZARITH,
1228
1230
  counter: exports.CODEC.ZARITH,
@@ -1231,7 +1233,7 @@
1231
1233
  public_key: exports.CODEC.PUBLIC_KEY,
1232
1234
  proof: exports.CODEC.SIGNATURE_PROOF,
1233
1235
  };
1234
- const DelegationSchema$1 = {
1236
+ const DelegationSchema = {
1235
1237
  source: exports.CODEC.PKH,
1236
1238
  fee: exports.CODEC.ZARITH,
1237
1239
  counter: exports.CODEC.ZARITH,
@@ -1239,7 +1241,7 @@
1239
1241
  storage_limit: exports.CODEC.ZARITH,
1240
1242
  delegate: exports.CODEC.DELEGATE,
1241
1243
  };
1242
- const TransactionSchema$1 = {
1244
+ const TransactionSchema = {
1243
1245
  source: exports.CODEC.PKH,
1244
1246
  fee: exports.CODEC.ZARITH,
1245
1247
  counter: exports.CODEC.ZARITH,
@@ -1249,7 +1251,7 @@
1249
1251
  destination: exports.CODEC.ADDRESS,
1250
1252
  parameters: exports.CODEC.PARAMETERS,
1251
1253
  };
1252
- const OriginationSchema$1 = {
1254
+ const OriginationSchema = {
1253
1255
  source: exports.CODEC.PKH,
1254
1256
  fee: exports.CODEC.ZARITH,
1255
1257
  counter: exports.CODEC.ZARITH,
@@ -1259,35 +1261,35 @@
1259
1261
  delegate: exports.CODEC.DELEGATE,
1260
1262
  script: exports.CODEC.SCRIPT,
1261
1263
  };
1262
- const BallotSchema$1 = {
1264
+ const BallotSchema = {
1263
1265
  source: exports.CODEC.PKH,
1264
1266
  period: exports.CODEC.INT32,
1265
1267
  proposal: exports.CODEC.PROPOSAL,
1266
1268
  ballot: exports.CODEC.BALLOT_STATEMENT,
1267
1269
  };
1268
- const AttestationSchema$1 = {
1270
+ const AttestationSchema = {
1269
1271
  slot: exports.CODEC.INT16,
1270
1272
  level: exports.CODEC.INT32,
1271
1273
  round: exports.CODEC.INT32,
1272
1274
  block_payload_hash: exports.CODEC.BLOCK_PAYLOAD_HASH,
1273
1275
  };
1274
- const AttestationWithDalSchema$1 = {
1276
+ const AttestationWithDalSchema = {
1275
1277
  slot: exports.CODEC.INT16,
1276
1278
  level: exports.CODEC.INT32,
1277
1279
  round: exports.CODEC.INT32,
1278
1280
  block_payload_hash: exports.CODEC.BLOCK_PAYLOAD_HASH,
1279
1281
  dal_attestation: exports.CODEC.ZARITH,
1280
1282
  };
1281
- const SeedNonceRevelationSchema$1 = {
1283
+ const SeedNonceRevelationSchema = {
1282
1284
  level: exports.CODEC.INT32,
1283
1285
  nonce: exports.CODEC.RAW,
1284
1286
  };
1285
- const ProposalsSchema$1 = {
1287
+ const ProposalsSchema = {
1286
1288
  source: exports.CODEC.PKH,
1287
1289
  period: exports.CODEC.INT32,
1288
1290
  proposals: exports.CODEC.PROPOSAL_ARR,
1289
1291
  };
1290
- const RegisterGlobalConstantSchema$1 = {
1292
+ const RegisterGlobalConstantSchema = {
1291
1293
  source: exports.CODEC.PKH,
1292
1294
  fee: exports.CODEC.ZARITH,
1293
1295
  counter: exports.CODEC.ZARITH,
@@ -1295,7 +1297,7 @@
1295
1297
  storage_limit: exports.CODEC.ZARITH,
1296
1298
  value: exports.CODEC.VALUE,
1297
1299
  };
1298
- const TransferTicketSchema$1 = {
1300
+ const TransferTicketSchema = {
1299
1301
  source: exports.CODEC.PKH,
1300
1302
  fee: exports.CODEC.ZARITH,
1301
1303
  counter: exports.CODEC.ZARITH,
@@ -1308,7 +1310,7 @@
1308
1310
  destination: exports.CODEC.ADDRESS,
1309
1311
  entrypoint: exports.CODEC.ENTRYPOINT,
1310
1312
  };
1311
- const IncreasePaidStorageSchema$1 = {
1313
+ const IncreasePaidStorageSchema = {
1312
1314
  source: exports.CODEC.PKH,
1313
1315
  fee: exports.CODEC.ZARITH,
1314
1316
  counter: exports.CODEC.ZARITH,
@@ -1317,7 +1319,7 @@
1317
1319
  amount: exports.CODEC.ZARITH,
1318
1320
  destination: exports.CODEC.SMART_CONTRACT_ADDRESS,
1319
1321
  };
1320
- const UpdateConsensusKeySchema$1 = {
1322
+ const UpdateConsensusKeySchema = {
1321
1323
  source: exports.CODEC.PKH,
1322
1324
  fee: exports.CODEC.ZARITH,
1323
1325
  counter: exports.CODEC.ZARITH,
@@ -1335,12 +1337,12 @@
1335
1337
  pk: exports.CODEC.PUBLIC_KEY,
1336
1338
  proof: exports.CODEC.SIGNATURE_PROOF,
1337
1339
  };
1338
- const DrainDelegateSchema$1 = {
1340
+ const DrainDelegateSchema = {
1339
1341
  consensus_key: exports.CODEC.PKH,
1340
1342
  delegate: exports.CODEC.PKH,
1341
1343
  destination: exports.CODEC.PKH,
1342
1344
  };
1343
- const SetDepositsLimitSchema$1 = {
1345
+ const SetDepositsLimitSchema = {
1344
1346
  source: exports.CODEC.PKH,
1345
1347
  fee: exports.CODEC.ZARITH,
1346
1348
  counter: exports.CODEC.ZARITH,
@@ -1348,7 +1350,7 @@
1348
1350
  storage_limit: exports.CODEC.ZARITH,
1349
1351
  limit: exports.CODEC.DEPOSITS_LIMIT,
1350
1352
  };
1351
- const SmartRollupOriginateSchema$1 = {
1353
+ const SmartRollupOriginateSchema = {
1352
1354
  source: exports.CODEC.PKH,
1353
1355
  fee: exports.CODEC.ZARITH,
1354
1356
  counter: exports.CODEC.ZARITH,
@@ -1359,7 +1361,7 @@
1359
1361
  parameters_ty: exports.CODEC.VALUE,
1360
1362
  whitelist: exports.CODEC.PKH_ARR,
1361
1363
  };
1362
- const SmartRollupAddMessagesSchema$1 = {
1364
+ const SmartRollupAddMessagesSchema = {
1363
1365
  source: exports.CODEC.PKH,
1364
1366
  fee: exports.CODEC.ZARITH,
1365
1367
  counter: exports.CODEC.ZARITH,
@@ -1367,7 +1369,7 @@
1367
1369
  storage_limit: exports.CODEC.ZARITH,
1368
1370
  message: exports.CODEC.SMART_ROLLUP_MESSAGE,
1369
1371
  };
1370
- const SmartRollupExecuteOutboxMessageSchema$1 = {
1372
+ const SmartRollupExecuteOutboxMessageSchema = {
1371
1373
  source: exports.CODEC.PKH,
1372
1374
  fee: exports.CODEC.ZARITH,
1373
1375
  counter: exports.CODEC.ZARITH,
@@ -1377,7 +1379,7 @@
1377
1379
  cemented_commitment: exports.CODEC.SMART_ROLLUP_COMMITMENT_HASH,
1378
1380
  output_proof: exports.CODEC.PADDED_BYTES,
1379
1381
  };
1380
- const DalPublishCommitmentSchema$1 = {
1382
+ const DalPublishCommitmentSchema = {
1381
1383
  source: exports.CODEC.PKH,
1382
1384
  fee: exports.CODEC.ZARITH,
1383
1385
  counter: exports.CODEC.ZARITH,
@@ -1385,18 +1387,18 @@
1385
1387
  storage_limit: exports.CODEC.ZARITH,
1386
1388
  slot_header: exports.CODEC.SLOT_HEADER,
1387
1389
  };
1388
- const FailingNoopSchema$1 = {
1390
+ const FailingNoopSchema = {
1389
1391
  arbitrary: exports.CODEC.PADDED_BYTES,
1390
1392
  };
1391
- const operationEncoder$1 = (encoders) => (operation) => {
1392
- if (!(operation.kind in encoders) || !(operation.kind in kindMappingReverse$1)) {
1393
+ const operationEncoder = (encoders) => (operation) => {
1394
+ if (!(operation.kind in encoders) || !(operation.kind in kindMappingReverse)) {
1393
1395
  throw new core.InvalidOperationKindError(operation.kind);
1394
1396
  }
1395
- return kindMappingReverse$1[operation.kind] + encoders[operation.kind](operation);
1397
+ return kindMappingReverse[operation.kind] + encoders[operation.kind](operation);
1396
1398
  };
1397
- const operationDecoder$1 = (decoders) => (value) => {
1399
+ const operationDecoder = (decoders) => (value) => {
1398
1400
  const op = value.consume(1);
1399
- const operationName = kindMapping$1[op[0]];
1401
+ const operationName = kindMapping[op[0]];
1400
1402
  if (operationName === undefined) {
1401
1403
  throw new UnsupportedOperationError(op[0].toString());
1402
1404
  }
@@ -1406,7 +1408,7 @@
1406
1408
  }
1407
1409
  return Object.assign({ kind: operationName }, decodedObj);
1408
1410
  };
1409
- const schemaEncoder$1 = (encoders) => (schema) => (value) => {
1411
+ const schemaEncoder = (encoders) => (schema) => (value) => {
1410
1412
  const keys = Object.keys(schema);
1411
1413
  return keys.reduce((prev, key) => {
1412
1414
  const valueToEncode = schema[key];
@@ -1424,7 +1426,7 @@
1424
1426
  }
1425
1427
  }, '');
1426
1428
  };
1427
- const schemaDecoder$1 = (decoders) => (schema) => (value) => {
1429
+ const schemaDecoder = (decoders) => (schema) => (value) => {
1428
1430
  const keys = Object.keys(schema);
1429
1431
  return keys.reduce((prev, key) => {
1430
1432
  const valueToEncode = schema[key];
@@ -1453,1526 +1455,153 @@
1453
1455
  }, {});
1454
1456
  };
1455
1457
 
1456
- const decoders$1 = {
1458
+ const decoders = {
1457
1459
  [exports.CODEC.SECRET]: (val) => toHexString(val.consume(20)),
1458
1460
  [exports.CODEC.RAW]: (val) => toHexString(val.consume(32)),
1459
- [exports.CODEC.TZ1]: tz1Decoder$1,
1460
- [exports.CODEC.BRANCH]: branchDecoder$1,
1461
- [exports.CODEC.ZARITH]: zarithDecoder$1,
1462
- [exports.CODEC.PUBLIC_KEY]: publicKeyDecoder$1,
1463
- [exports.CODEC.PKH]: publicKeyHashDecoder$1,
1464
- [exports.CODEC.PKH_ARR]: publicKeyHashesDecoder$1,
1465
- [exports.CODEC.DELEGATE]: delegateDecoder$1,
1466
- [exports.CODEC.INT32]: int32Decoder$1,
1467
- [exports.CODEC.SCRIPT]: scriptDecoder$1,
1468
- [exports.CODEC.BALLOT_STATEMENT]: ballotDecoder$1,
1469
- [exports.CODEC.PROPOSAL]: proposalDecoder$1,
1470
- [exports.CODEC.PROPOSAL_ARR]: proposalsDecoder$1,
1471
- [exports.CODEC.PARAMETERS]: parametersDecoder$1,
1472
- [exports.CODEC.ADDRESS]: addressDecoder$1,
1473
- [exports.CODEC.SMART_ROLLUP_ADDRESS]: smartRollupAddressDecoder$1,
1474
- [exports.CODEC.SMART_CONTRACT_ADDRESS]: smartContractAddressDecoder$1,
1475
- [exports.CODEC.SMART_ROLLUP_COMMITMENT_HASH]: smartRollupCommitmentHashDecoder$1,
1476
- [exports.CODEC.VALUE]: valueParameterDecoder$1,
1477
- [exports.CODEC.INT16]: int16Decoder$1,
1478
- [exports.CODEC.BLOCK_PAYLOAD_HASH]: blockPayloadHashDecoder$1,
1479
- [exports.CODEC.ENTRYPOINT]: entrypointNameDecoder$1,
1480
- [exports.CODEC.BURN_LIMIT]: burnLimitDecoder$1,
1481
- [exports.CODEC.DEPOSITS_LIMIT]: depositsLimitDecoder$1,
1482
- [exports.CODEC.SIGNATURE_PROOF]: signatureProofDecoder$1,
1483
- [exports.CODEC.PVM_KIND]: pvmKindDecoder$1,
1484
- [exports.CODEC.PADDED_BYTES]: paddedBytesDecoder$1,
1485
- [exports.CODEC.SMART_ROLLUP_MESSAGE]: smartRollupMessageDecoder$1,
1486
- [exports.CODEC.SLOT_HEADER]: slotHeaderDecoder$1,
1487
- };
1488
- decoders$1[exports.CODEC.OPERATION] = operationDecoder$1(decoders$1);
1489
- decoders$1[exports.CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaDecoder$1(decoders$1)(ActivationSchema$1)(val);
1490
- decoders$1[exports.CODEC.OP_FAILING_NOOP] = (val) => schemaDecoder$1(decoders$1)(FailingNoopSchema$1)(val);
1491
- decoders$1[exports.CODEC.OP_DELEGATION] = (val) => schemaDecoder$1(decoders$1)(DelegationSchema$1)(val);
1492
- decoders$1[exports.CODEC.OP_TRANSACTION] = (val) => schemaDecoder$1(decoders$1)(TransactionSchema$1)(val);
1493
- decoders$1[exports.CODEC.OP_ORIGINATION] = (val) => schemaDecoder$1(decoders$1)(OriginationSchema$1)(val);
1494
- decoders$1[exports.CODEC.OP_BALLOT] = (val) => schemaDecoder$1(decoders$1)(BallotSchema$1)(val);
1495
- decoders$1[exports.CODEC.OP_ATTESTATION] = (val) => schemaDecoder$1(decoders$1)(AttestationSchema$1)(val);
1496
- decoders$1[exports.CODEC.OP_ATTESTATION_WITH_DAL] = (val) => schemaDecoder$1(decoders$1)(AttestationWithDalSchema$1)(val);
1497
- decoders$1[exports.CODEC.OP_SEED_NONCE_REVELATION] = (val) => schemaDecoder$1(decoders$1)(SeedNonceRevelationSchema$1)(val);
1498
- decoders$1[exports.CODEC.OP_PROPOSALS] = (val) => schemaDecoder$1(decoders$1)(ProposalsSchema$1)(val);
1499
- decoders$1[exports.CODEC.OP_REVEAL] = (val) => schemaDecoder$1(decoders$1)(RevealSchema$1)(val);
1500
- decoders$1[exports.CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaDecoder$1(decoders$1)(RegisterGlobalConstantSchema$1)(val);
1501
- decoders$1[exports.CODEC.OP_TRANSFER_TICKET] = (val) => schemaDecoder$1(decoders$1)(TransferTicketSchema$1)(val);
1502
- decoders$1[exports.CODEC.OP_INCREASE_PAID_STORAGE] = (val) => schemaDecoder$1(decoders$1)(IncreasePaidStorageSchema$1)(val);
1503
- decoders$1[exports.CODEC.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaDecoder$1(decoders$1)(UpdateConsensusKeySchema$1)(val);
1504
- decoders$1[exports.CODEC.OP_UPDATE_COMPANION_KEY] = (val) => schemaDecoder$1(decoders$1)(UpdateCompanionKeySchema)(val);
1505
- decoders$1[exports.CODEC.OP_DRAIN_DELEGATE] = (val) => schemaDecoder$1(decoders$1)(DrainDelegateSchema$1)(val);
1506
- decoders$1[exports.CODEC.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaDecoder$1(decoders$1)(SmartRollupOriginateSchema$1)(val);
1507
- decoders$1[exports.CODEC.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaDecoder$1(decoders$1)(SmartRollupAddMessagesSchema$1)(val);
1508
- decoders$1[exports.CODEC.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaDecoder$1(decoders$1)(SmartRollupExecuteOutboxMessageSchema$1)(val);
1509
- decoders$1[exports.CODEC.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaDecoder$1(decoders$1)(DalPublishCommitmentSchema$1)(val);
1510
- decoders$1[exports.CODEC.MANAGER] = schemaDecoder$1(decoders$1)(ManagerOperationSchema$1);
1511
- decoders$1[exports.CODEC.OP_SET_DEPOSITS_LIMIT] = (val) => schemaDecoder$1(decoders$1)(SetDepositsLimitSchema$1)(val);
1461
+ [exports.CODEC.TZ1]: tz1Decoder,
1462
+ [exports.CODEC.BRANCH]: branchDecoder,
1463
+ [exports.CODEC.ZARITH]: zarithDecoder,
1464
+ [exports.CODEC.PUBLIC_KEY]: publicKeyDecoder,
1465
+ [exports.CODEC.PKH]: publicKeyHashDecoder,
1466
+ [exports.CODEC.PKH_ARR]: publicKeyHashesDecoder,
1467
+ [exports.CODEC.DELEGATE]: delegateDecoder,
1468
+ [exports.CODEC.INT32]: int32Decoder,
1469
+ [exports.CODEC.SCRIPT]: scriptDecoder,
1470
+ [exports.CODEC.BALLOT_STATEMENT]: ballotDecoder,
1471
+ [exports.CODEC.PROPOSAL]: proposalDecoder,
1472
+ [exports.CODEC.PROPOSAL_ARR]: proposalsDecoder,
1473
+ [exports.CODEC.PARAMETERS]: parametersDecoder,
1474
+ [exports.CODEC.ADDRESS]: addressDecoder,
1475
+ [exports.CODEC.SMART_ROLLUP_ADDRESS]: smartRollupAddressDecoder,
1476
+ [exports.CODEC.SMART_CONTRACT_ADDRESS]: smartContractAddressDecoder,
1477
+ [exports.CODEC.SMART_ROLLUP_COMMITMENT_HASH]: smartRollupCommitmentHashDecoder,
1478
+ [exports.CODEC.VALUE]: valueParameterDecoder,
1479
+ [exports.CODEC.INT16]: int16Decoder,
1480
+ [exports.CODEC.BLOCK_PAYLOAD_HASH]: blockPayloadHashDecoder,
1481
+ [exports.CODEC.ENTRYPOINT]: entrypointNameDecoder,
1482
+ [exports.CODEC.BURN_LIMIT]: burnLimitDecoder,
1483
+ [exports.CODEC.DEPOSITS_LIMIT]: depositsLimitDecoder,
1484
+ [exports.CODEC.SIGNATURE_PROOF]: signatureProofDecoder,
1485
+ [exports.CODEC.PVM_KIND]: pvmKindDecoder,
1486
+ [exports.CODEC.PADDED_BYTES]: paddedBytesDecoder,
1487
+ [exports.CODEC.SMART_ROLLUP_MESSAGE]: smartRollupMessageDecoder,
1488
+ [exports.CODEC.SLOT_HEADER]: slotHeaderDecoder,
1489
+ };
1490
+ decoders[exports.CODEC.OPERATION] = operationDecoder(decoders);
1491
+ decoders[exports.CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaDecoder(decoders)(ActivationSchema)(val);
1492
+ decoders[exports.CODEC.OP_FAILING_NOOP] = (val) => schemaDecoder(decoders)(FailingNoopSchema)(val);
1493
+ decoders[exports.CODEC.OP_DELEGATION] = (val) => schemaDecoder(decoders)(DelegationSchema)(val);
1494
+ decoders[exports.CODEC.OP_TRANSACTION] = (val) => schemaDecoder(decoders)(TransactionSchema)(val);
1495
+ decoders[exports.CODEC.OP_ORIGINATION] = (val) => schemaDecoder(decoders)(OriginationSchema)(val);
1496
+ decoders[exports.CODEC.OP_BALLOT] = (val) => schemaDecoder(decoders)(BallotSchema)(val);
1497
+ decoders[exports.CODEC.OP_ATTESTATION] = (val) => schemaDecoder(decoders)(AttestationSchema)(val);
1498
+ decoders[exports.CODEC.OP_ATTESTATION_WITH_DAL] = (val) => schemaDecoder(decoders)(AttestationWithDalSchema)(val);
1499
+ decoders[exports.CODEC.OP_SEED_NONCE_REVELATION] = (val) => schemaDecoder(decoders)(SeedNonceRevelationSchema)(val);
1500
+ decoders[exports.CODEC.OP_PROPOSALS] = (val) => schemaDecoder(decoders)(ProposalsSchema)(val);
1501
+ decoders[exports.CODEC.OP_REVEAL] = (val) => schemaDecoder(decoders)(RevealSchema)(val);
1502
+ decoders[exports.CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaDecoder(decoders)(RegisterGlobalConstantSchema)(val);
1503
+ decoders[exports.CODEC.OP_TRANSFER_TICKET] = (val) => schemaDecoder(decoders)(TransferTicketSchema)(val);
1504
+ decoders[exports.CODEC.OP_INCREASE_PAID_STORAGE] = (val) => schemaDecoder(decoders)(IncreasePaidStorageSchema)(val);
1505
+ decoders[exports.CODEC.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaDecoder(decoders)(UpdateConsensusKeySchema)(val);
1506
+ decoders[exports.CODEC.OP_UPDATE_COMPANION_KEY] = (val) => schemaDecoder(decoders)(UpdateCompanionKeySchema)(val);
1507
+ decoders[exports.CODEC.OP_DRAIN_DELEGATE] = (val) => schemaDecoder(decoders)(DrainDelegateSchema)(val);
1508
+ decoders[exports.CODEC.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaDecoder(decoders)(SmartRollupOriginateSchema)(val);
1509
+ decoders[exports.CODEC.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaDecoder(decoders)(SmartRollupAddMessagesSchema)(val);
1510
+ decoders[exports.CODEC.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaDecoder(decoders)(SmartRollupExecuteOutboxMessageSchema)(val);
1511
+ decoders[exports.CODEC.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaDecoder(decoders)(DalPublishCommitmentSchema)(val);
1512
+ decoders[exports.CODEC.MANAGER] = schemaDecoder(decoders)(ManagerOperationSchema);
1513
+ decoders[exports.CODEC.OP_SET_DEPOSITS_LIMIT] = (val) => schemaDecoder(decoders)(SetDepositsLimitSchema)(val);
1512
1514
 
1513
- /*
1514
- * Some code in this file is originally from sotez
1515
- * Copyright (c) 2018 Andrew Kishino
1516
- */
1517
- // See: https://tezos.gitlab.io/protocols/005_babylon.html#transactions-now-have-an-entrypoint
1518
- const ENTRYPOINT_MAX_LENGTH = 31;
1519
- var CODEC;
1520
- (function (CODEC) {
1521
- CODEC["SECRET"] = "secret";
1522
- CODEC["RAW"] = "raw";
1523
- CODEC["TZ1"] = "tz1";
1524
- CODEC["BRANCH"] = "branch";
1525
- CODEC["ZARITH"] = "zarith";
1526
- CODEC["PUBLIC_KEY"] = "public_key";
1527
- CODEC["PKH"] = "pkh";
1528
- CODEC["PKH_ARR"] = "pkhArr";
1529
- CODEC["DELEGATE"] = "delegate";
1530
- CODEC["SCRIPT"] = "script";
1531
- CODEC["BALLOT_STATEMENT"] = "ballotStmt";
1532
- CODEC["PROPOSAL"] = "proposal";
1533
- CODEC["PROPOSAL_ARR"] = "proposalArr";
1534
- CODEC["INT32"] = "int32";
1535
- CODEC["INT16"] = "int16";
1536
- CODEC["PARAMETERS"] = "parameters";
1537
- CODEC["ADDRESS"] = "address";
1538
- CODEC["SMART_CONTRACT_ADDRESS"] = "smart_contract_address";
1539
- CODEC["SMART_ROLLUP_ADDRESS"] = "smart_rollup_address";
1540
- CODEC["SMART_ROLLUP_COMMITMENT_HASH"] = "smart_rollup_commitment_hash";
1541
- CODEC["VALUE"] = "value";
1542
- CODEC["PADDED_BYTES"] = "padded_bytes";
1543
- CODEC["SMART_ROLLUP_MESSAGE"] = "smart_rollup_message";
1544
- CODEC["MANAGER"] = "manager";
1545
- CODEC["BLOCK_PAYLOAD_HASH"] = "blockPayloadHash";
1546
- CODEC["ENTRYPOINT"] = "entrypoint";
1547
- CODEC["OPERATION"] = "operation";
1548
- CODEC["OP_ACTIVATE_ACCOUNT"] = "activate_account";
1549
- CODEC["OP_DELEGATION"] = "delegation";
1550
- CODEC["OP_TRANSACTION"] = "transaction";
1551
- CODEC["OP_ORIGINATION"] = "origination";
1552
- CODEC["OP_BALLOT"] = "ballot";
1553
- CODEC["OP_FAILING_NOOP"] = "failing_noop";
1554
- CODEC["OP_ATTESTATION"] = "attestation";
1555
- CODEC["OP_ATTESTATION_WITH_DAL"] = "attestation_with_dal";
1556
- CODEC["OP_SEED_NONCE_REVELATION"] = "seed_nonce_revelation";
1557
- CODEC["OP_REVEAL"] = "reveal";
1558
- CODEC["OP_PROPOSALS"] = "proposals";
1559
- CODEC["OP_REGISTER_GLOBAL_CONSTANT"] = "register_global_constant";
1560
- CODEC["OP_TRANSFER_TICKET"] = "transfer_ticket";
1561
- CODEC["BURN_LIMIT"] = "burn_limit";
1562
- CODEC["OP_INCREASE_PAID_STORAGE"] = "increase_paid_storage";
1563
- CODEC["OP_UPDATE_CONSENSUS_KEY"] = "update_consensus_key";
1564
- CODEC["SIGNATURE_PROOF"] = "signature_proof";
1565
- CODEC["OP_DRAIN_DELEGATE"] = "drain_delegate";
1566
- CODEC["DEPOSITS_LIMIT"] = "deposits_limit";
1567
- CODEC["OP_SET_DEPOSITS_LIMIT"] = "set_deposits_limit";
1568
- CODEC["OP_SMART_ROLLUP_ORIGINATE"] = "smart_rollup_originate";
1569
- CODEC["PVM_KIND"] = "pvm_kind";
1570
- CODEC["OP_SMART_ROLLUP_ADD_MESSAGES"] = "smart_rollup_add_messages";
1571
- CODEC["OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE"] = "smart_rollup_execute_outbox_message";
1572
- CODEC["OP_DAL_PUBLISH_COMMITMENT"] = "dal_publish_commitment";
1573
- CODEC["SLOT_HEADER"] = "slot_header";
1574
- })(CODEC || (CODEC = {}));
1575
- // See https://tezos.gitlab.io/shell/p2p_api.html#alpha-michelson-v1-primitives-enumeration-unsigned-8-bit-integer
1576
- const opMapping = {
1577
- '00': 'parameter',
1578
- '01': 'storage',
1579
- '02': 'code',
1580
- '03': 'False',
1581
- '04': 'Elt',
1582
- '05': 'Left',
1583
- '06': 'None',
1584
- '07': 'Pair',
1585
- '08': 'Right',
1586
- '09': 'Some',
1587
- '0a': 'True',
1588
- '0b': 'Unit',
1589
- '0c': 'PACK',
1590
- '0d': 'UNPACK',
1591
- '0e': 'BLAKE2B',
1592
- '0f': 'SHA256',
1593
- '10': 'SHA512',
1594
- '11': 'ABS',
1595
- '12': 'ADD',
1596
- '13': 'AMOUNT',
1597
- '14': 'AND',
1598
- '15': 'BALANCE',
1599
- '16': 'CAR',
1600
- '17': 'CDR',
1601
- '18': 'CHECK_SIGNATURE',
1602
- '19': 'COMPARE',
1603
- '1a': 'CONCAT',
1604
- '1b': 'CONS',
1605
- '1c': 'CREATE_ACCOUNT', // Removed in Edo
1606
- '1d': 'CREATE_CONTRACT', // Removed in Edo
1607
- '1e': 'IMPLICIT_ACCOUNT',
1608
- '1f': 'DIP',
1609
- '20': 'DROP',
1610
- '21': 'DUP',
1611
- '22': 'EDIV',
1612
- '23': 'EMPTY_MAP',
1613
- '24': 'EMPTY_SET',
1614
- '25': 'EQ',
1615
- '26': 'EXEC',
1616
- '27': 'FAILWITH',
1617
- '28': 'GE',
1618
- '29': 'GET',
1619
- '2a': 'GT',
1620
- '2b': 'HASH_KEY',
1621
- '2c': 'IF',
1622
- '2d': 'IF_CONS',
1623
- '2e': 'IF_LEFT',
1624
- '2f': 'IF_NONE',
1625
- '30': 'INT',
1626
- '31': 'LAMBDA',
1627
- '32': 'LE',
1628
- '33': 'LEFT',
1629
- '34': 'LOOP',
1630
- '35': 'LSL',
1631
- '36': 'LSR',
1632
- '37': 'LT',
1633
- '38': 'MAP',
1634
- '39': 'MEM',
1635
- '3a': 'MUL',
1636
- '3b': 'NEG',
1637
- '3c': 'NEQ',
1638
- '3d': 'NIL',
1639
- '3e': 'NONE',
1640
- '3f': 'NOT',
1641
- '40': 'NOW',
1642
- '41': 'OR',
1643
- '42': 'PAIR',
1644
- '43': 'PUSH',
1645
- '44': 'RIGHT',
1646
- '45': 'SIZE',
1647
- '46': 'SOME',
1648
- '47': 'SOURCE',
1649
- '48': 'SENDER',
1650
- '49': 'SELF',
1651
- '4a': 'STEPS_TO_QUOTA', // Removed in Edo
1652
- '4b': 'SUB',
1653
- '4c': 'SWAP',
1654
- '4d': 'TRANSFER_TOKENS',
1655
- '4e': 'SET_DELEGATE',
1656
- '4f': 'UNIT',
1657
- '50': 'UPDATE',
1658
- '51': 'XOR',
1659
- '52': 'ITER',
1660
- '53': 'LOOP_LEFT',
1661
- '54': 'ADDRESS',
1662
- '55': 'CONTRACT',
1663
- '56': 'ISNAT',
1664
- '57': 'CAST',
1665
- '58': 'RENAME',
1666
- '59': 'bool',
1667
- '5a': 'contract',
1668
- '5b': 'int',
1669
- '5c': 'key',
1670
- '5d': 'key_hash',
1671
- '5e': 'lambda',
1672
- '5f': 'list',
1673
- '60': 'map',
1674
- '61': 'big_map',
1675
- '62': 'nat',
1676
- '63': 'option',
1677
- '64': 'or',
1678
- '65': 'pair',
1679
- '66': 'set',
1680
- '67': 'signature',
1681
- '68': 'string',
1682
- '69': 'bytes',
1683
- '6a': 'mutez',
1684
- '6b': 'timestamp',
1685
- '6c': 'unit',
1686
- '6d': 'operation',
1687
- '6e': 'address',
1688
- '6f': 'SLICE',
1689
- '70': 'DIG',
1690
- '71': 'DUG',
1691
- '72': 'EMPTY_BIG_MAP',
1692
- '73': 'APPLY',
1693
- '74': 'chain_id',
1694
- '75': 'CHAIN_ID',
1695
- '76': 'LEVEL',
1696
- '77': 'SELF_ADDRESS',
1697
- '78': 'never',
1698
- '79': 'NEVER',
1699
- '7a': 'UNPAIR',
1700
- '7b': 'VOTING_POWER',
1701
- '7c': 'TOTAL_VOTING_POWER',
1702
- '7d': 'KECCAK',
1703
- '7e': 'SHA3',
1704
- '7f': 'PAIRING_CHECK',
1705
- '80': 'bls12_381_g1',
1706
- '81': 'bls12_381_g2',
1707
- '82': 'bls12_381_fr',
1708
- '83': 'sapling_state',
1709
- '84': 'sapling_transaction_deprecated',
1710
- '85': 'SAPLING_EMPTY_STATE',
1711
- '86': 'SAPLING_VERIFY_UPDATE',
1712
- '87': 'ticket',
1713
- '88': 'TICKET_DEPRECATED',
1714
- '89': 'READ_TICKET',
1715
- '8a': 'SPLIT_TICKET',
1716
- '8b': 'JOIN_TICKETS',
1717
- '8c': 'GET_AND_UPDATE',
1718
- '8d': 'chest',
1719
- '8e': 'chest_key',
1720
- '8f': 'OPEN_CHEST',
1721
- '90': 'VIEW',
1722
- '91': 'view',
1723
- '92': 'constant',
1724
- '93': 'SUB_MUTEZ',
1725
- '94': 'tx_rollup_l2_address',
1726
- '95': 'MIN_BLOCK_TIME',
1727
- '96': 'sapling_transaction',
1728
- '97': 'EMIT',
1729
- '98': 'Lambda_rec',
1730
- '99': 'LAMBDA_REC',
1731
- '9a': 'TICKET',
1732
- '9b': 'BYTES',
1733
- '9c': 'NAT',
1734
- '9d': 'Ticket',
1735
- };
1736
- const opMappingReverse = (() => {
1737
- const result = {};
1738
- Object.keys(opMapping).forEach((key) => {
1739
- result[opMapping[key]] = key;
1740
- });
1741
- return result;
1742
- })();
1743
- // See https://tezos.gitlab.io/shell/p2p_api.html
1744
- const kindMapping = {
1745
- 0x04: 'activate_account',
1746
- 0x6b: 'reveal',
1747
- 0x6e: 'delegation',
1748
- 0x6c: 'transaction',
1749
- 0x6d: 'origination',
1750
- 0x06: 'ballot',
1751
- 0x15: 'attestation',
1752
- 0x17: 'attestation_with_dal',
1753
- 0x01: 'seed_nonce_revelation',
1754
- 0x05: 'proposals',
1755
- 0x6f: 'register_global_constant',
1756
- 0x9e: 'transfer_ticket',
1757
- 0x70: 'set_deposits_limit',
1758
- 0x71: 'increase_paid_storage',
1759
- 0x72: 'update_consensus_key',
1760
- 0x09: 'drain_delegate',
1761
- 0xc8: 'smart_rollup_originate',
1762
- 0xc9: 'smart_rollup_add_messages',
1763
- 0xce: 'smart_rollup_execute_outbox_message',
1764
- 0xe6: 'dal_publish_commitment',
1765
- 0x11: 'failing_noop',
1766
- };
1767
- const kindMappingReverse = (() => {
1768
- const result = {};
1769
- Object.keys(kindMapping).forEach((key) => {
1770
- const keyNum = typeof key === 'string' ? parseInt(key, 10) : key;
1771
- result[kindMapping[keyNum]] = pad(keyNum, 2);
1772
- });
1773
- return result;
1774
- })();
1775
- // See https://tezos.gitlab.io/protocols/005_babylon.html#transactions-now-have-an-entrypoint
1776
- const entrypointMapping = {
1777
- '00': 'default',
1778
- '01': 'root',
1779
- '02': 'do',
1780
- '03': 'set_delegate',
1781
- '04': 'remove_delegate',
1782
- '05': 'deposit',
1783
- '06': 'stake',
1784
- '07': 'unstake',
1785
- '08': 'finalize_unstake',
1786
- '09': 'set_delegate_parameters',
1787
- };
1788
- const entrypointMappingReverse = (() => {
1789
- const result = {};
1790
- Object.keys(entrypointMapping).forEach((key) => {
1791
- result[entrypointMapping[key]] = key;
1792
- });
1793
- return result;
1794
- })();
1795
-
1796
- const isPrim = (value) => {
1797
- return 'prim' in value;
1798
- };
1799
- const isBytes = (value) => {
1800
- return 'bytes' in value && typeof value.bytes === 'string';
1801
- };
1802
- const isString = (value) => {
1803
- return 'string' in value && typeof value.string === 'string';
1804
- };
1805
- const isInt = (value) => {
1806
- return 'int' in value && typeof value.int === 'string';
1807
- };
1808
- const scriptEncoder = (script) => {
1809
- const code = valueEncoder(script.code);
1810
- const storage = valueEncoder(script.storage);
1811
- return `${pad(code.length / 2, 8)}${code}${pad(storage.length / 2, 8)}${storage}`;
1812
- };
1813
- const scriptDecoder = (value) => {
1814
- const code = extractRequiredLen(value);
1815
- const storage = extractRequiredLen(value);
1816
- return {
1817
- code: valueDecoder(new Uint8ArrayConsumer(code)),
1818
- storage: valueDecoder(new Uint8ArrayConsumer(storage)),
1819
- };
1820
- };
1821
- const valueEncoder = (value) => {
1822
- if (Array.isArray(value)) {
1823
- const encoded = value.map((x) => valueEncoder(x)).join('');
1824
- const len = encoded.length / 2;
1825
- return `02${pad(len)}${encoded}`;
1826
- }
1827
- else if (isPrim(value)) {
1828
- return primEncoder(value);
1829
- }
1830
- else if (isBytes(value)) {
1831
- return bytesEncoder(value);
1832
- }
1833
- else if (isString(value)) {
1834
- return stringEncoder(value);
1835
- }
1836
- else if (isInt(value)) {
1837
- return intEncoder(value);
1838
- }
1839
- throw new UnexpectedMichelsonValueError(JSON.stringify(value));
1840
- };
1841
- const valueDecoder = (value) => {
1842
- const preamble = value.consume(1);
1843
- switch (preamble[0]) {
1844
- case 0x0a:
1845
- return bytesDecoder(value);
1846
- case 0x01:
1847
- return stringDecoder(value);
1848
- case 0x00:
1849
- return intDecoder(value);
1850
- case 0x02: {
1851
- const val = new Uint8ArrayConsumer(extractRequiredLen(value));
1852
- const results = [];
1853
- while (val.length() > 0) {
1854
- results.push(valueDecoder(val));
1855
- }
1856
- return results;
1857
- }
1858
- default:
1859
- return primDecoder(value, preamble);
1860
- }
1861
- };
1862
- const extractRequiredLen = (value, bytesLength = 4) => {
1863
- const len = value.consume(bytesLength);
1864
- const valueLen = parseInt(Buffer.from(len).toString('hex'), 16);
1865
- return value.consume(valueLen);
1866
- };
1867
- /**
1868
- * @description parse bytes into multiple items of an array
1869
- * @param value Uint8ArrayConsumer class of forged segment to parse
1870
- * @param bytesLength default 4 bytes for length of variable bytes
1871
- * @returns array of Uint8Array values for each array item
1872
- */
1873
- const stripLengthPrefixFromBytes = (value, bytesLength = 4) => {
1874
- const ret = [];
1875
- let values = value;
1876
- while (values.length()) {
1877
- const len = values.consume(bytesLength);
1878
- const valueLen = parseInt(Buffer.from(len).toString('hex'), 16);
1879
- ret.push(values.consume(valueLen));
1880
- values = values.slice(valueLen + bytesLength);
1881
- }
1882
- return ret;
1883
- };
1884
- const bytesEncoder = (value) => {
1885
- if (!/^([A-Fa-f0-9]{2})*$/.test(value.bytes)) {
1886
- throw new core.InvalidHexStringError(value.bytes);
1887
- }
1888
- const len = value.bytes.length / 2;
1889
- return `0a${pad(len)}${value.bytes}`;
1890
- };
1891
- const bytesDecoder = (value) => {
1892
- const bytes = extractRequiredLen(value);
1893
- return {
1894
- bytes: Buffer.from(bytes).toString('hex'),
1895
- };
1896
- };
1897
- const stringEncoder = (value) => {
1898
- const str = Buffer.from(value.string, 'utf8').toString('hex');
1899
- const hexLength = str.length / 2;
1900
- return `01${pad(hexLength)}${str}`;
1901
- };
1902
- const stringDecoder = (value) => {
1903
- const str = extractRequiredLen(value);
1904
- return {
1905
- string: Buffer.from(str).toString('utf8'),
1906
- };
1907
- };
1908
- const intEncoder = ({ int }) => {
1909
- const num = new BigNumber.BigNumber(int, 10);
1910
- const positiveMark = num.toString(2)[0] === '-' ? '1' : '0';
1911
- const binary = num.toString(2).replace(/-/g, '');
1912
- const pad = binary.length <= 6
1913
- ? 6
1914
- : (binary.length - 6) % 7
1915
- ? binary.length + 7 - ((binary.length - 6) % 7)
1916
- : binary.length;
1917
- const splitted = binary.padStart(pad, '0').match(/\d{6,7}/g);
1918
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1919
- const reversed = splitted.reverse();
1920
- reversed[0] = positiveMark + reversed[0];
1921
- const numHex = reversed.map((x, i) =>
1922
- // Add one to the last chunk
1923
- parseInt((i === reversed.length - 1 ? '0' : '1') + x, 2)
1924
- .toString(16)
1925
- .padStart(2, '0'));
1926
- return `00${numHex.join('')}`;
1927
- };
1928
- const intDecoder = (value) => {
1929
- let c = value.consume(1)[0];
1930
- const hexNumber = [];
1931
- const isNotLastChunkMask = 1 << 7;
1932
- while (c & isNotLastChunkMask) {
1933
- hexNumber.push(c);
1934
- c = value.consume(1)[0];
1935
- }
1936
- hexNumber.push(c);
1937
- const isNegative = !!((1 << 6) & hexNumber[0]);
1938
- hexNumber[0] = hexNumber[0] & 0b1111111;
1939
- const numBin = hexNumber
1940
- .map((x, i) => x
1941
- .toString(2)
1942
- .slice(i === 0 ? -6 : -7)
1943
- .padStart(i === 0 ? 6 : 7, '0'))
1944
- .reverse();
1945
- let num = new BigNumber.BigNumber(numBin.join(''), 2);
1946
- if (isNegative) {
1947
- num = num.times(-1);
1948
- }
1949
- return {
1950
- int: num.toFixed(),
1951
- };
1952
- };
1953
- const primEncoder = (value) => {
1954
- const hasAnnot = +Array.isArray(value.annots);
1955
- const argsCount = Array.isArray(value.args) ? value.args.length : 0;
1956
- // Specify the number of args max is 3 without annotation
1957
- const preamble = pad(Math.min(2 * argsCount + hasAnnot + 0x03, 9), 2);
1958
- const op = opMappingReverse[value.prim];
1959
- let encodedArgs = (value.args || []).map((arg) => valueEncoder(arg)).join('');
1960
- const encodedAnnots = Array.isArray(value.annots) ? encodeAnnots(value.annots) : '';
1961
- if ((value.prim === 'LAMBDA' || value.prim === 'LAMBDA_REC') && argsCount) {
1962
- encodedArgs = pad(encodedArgs.length / 2) + encodedArgs + pad(0);
1963
- }
1964
- if ((value.prim === 'pair' || value.prim === 'Pair') && argsCount > 2) {
1965
- encodedArgs =
1966
- encodedAnnots === ''
1967
- ? pad(encodedArgs.length / 2) + encodedArgs + pad(0)
1968
- : pad(encodedArgs.length / 2) + encodedArgs;
1969
- }
1970
- if (value.prim === 'view' && value.args) {
1971
- encodedArgs = pad(encodedArgs.length / 2) + encodedArgs + pad(0);
1972
- }
1973
- return `${preamble}${op}${encodedArgs}${encodedAnnots}`;
1974
- };
1975
- const primDecoder = (value, preamble) => {
1976
- const hasAnnot = (preamble[0] - 0x03) % 2 === 1;
1977
- let argsCount = Math.floor((preamble[0] - 0x03) / 2);
1978
- const op = value.consume(1)[0].toString(16).padStart(2, '0');
1979
- const result = {
1980
- prim: opMapping[op],
1981
- };
1982
- if (opMapping[op] === 'LAMBDA' || opMapping[op] === 'LAMBDA_REC') {
1983
- value.consume(4);
1984
- }
1985
- if (opMapping[op] === 'view') {
1986
- if (argsCount != 0) {
1987
- return primViewDecoder(value, result);
1988
- }
1989
- else {
1990
- return result;
1991
- }
1992
- }
1993
- let combPairArgs;
1994
- let combPairAnnots;
1995
- if ((opMapping[op] === 'pair' || opMapping[op] === 'Pair') && argsCount > 2) {
1996
- combPairArgs = decodeCombPair(value);
1997
- argsCount = 0;
1998
- combPairAnnots = decodeAnnots(value);
1999
- }
2000
- const args = new Array(argsCount).fill(0).map(() => valueDecoder(value));
2001
- if (opMapping[op] === 'LAMBDA' || opMapping[op] === 'LAMBDA_REC') {
2002
- value.consume(4);
2003
- }
2004
- if (combPairArgs) {
2005
- result['args'] = combPairArgs;
2006
- }
2007
- else if (args.length) {
2008
- result['args'] = args;
2009
- }
2010
- if (combPairAnnots && combPairAnnots[0] !== '') {
2011
- result['annots'] = combPairAnnots;
2012
- }
2013
- else if (hasAnnot) {
2014
- result['annots'] = decodeAnnots(value);
2015
- }
2016
- return result;
2017
- };
2018
- const primViewDecoder = (value, result) => {
2019
- value.consume(4);
2020
- result['args'] = new Array(4).fill(0).map(() => valueDecoder(value));
2021
- value.consume(4);
2022
- return result;
2023
- };
2024
- const decodeCombPair = (val) => {
2025
- const array = new Uint8ArrayConsumer(extractRequiredLen(val));
2026
- const args = [];
2027
- while (array.length() > 0) {
2028
- args.push(valueDecoder(array));
2029
- }
2030
- return args;
2031
- };
2032
- const encodeAnnots = (value) => {
2033
- const mergedAnnot = value
2034
- .map((x) => {
2035
- return Buffer.from(x, 'utf8').toString('hex');
2036
- })
2037
- .join('20');
2038
- const len = mergedAnnot.length / 2;
2039
- return `${pad(len)}${mergedAnnot}`;
2040
- };
2041
- const decodeAnnots = (val) => {
2042
- const len = val.consume(4);
2043
- const annotLen = parseInt(Buffer.from(len).toString('hex'), 16);
2044
- const restOfAnnot = val.consume(annotLen);
2045
- const restOfAnnotHex = Buffer.from(restOfAnnot).toString('hex');
2046
- return restOfAnnotHex.split('20').map((x) => Buffer.from(x, 'hex').toString('utf8'));
2047
- };
2048
-
2049
- // https://tezos.gitlab.io/shell/p2p_api.html specifies data types and structure for forging
2050
- const prefixEncoder = (prefix) => (str) => {
2051
- return utils.buf2hex(Buffer.from(utils.b58cdecode(str, utils.prefix[prefix])));
2052
- };
2053
- const prefixDecoder = (pre) => (str) => {
2054
- const val = str.consume(utils.prefixLength[pre]);
2055
- return utils.b58cencode(val, utils.prefix[pre]);
2056
- };
2057
- const tz1Decoder = prefixDecoder(utils.Prefix.TZ1);
2058
- const branchDecoder = prefixDecoder(utils.Prefix.B);
2059
- const publicKeyHashDecoder = (val) => {
2060
- const prefix = val.consume(1);
2061
- if (prefix[0] === 0x00) {
2062
- return prefixDecoder(utils.Prefix.TZ1)(val);
2063
- }
2064
- else if (prefix[0] === 0x01) {
2065
- return prefixDecoder(utils.Prefix.TZ2)(val);
2066
- }
2067
- else if (prefix[0] === 0x02) {
2068
- return prefixDecoder(utils.Prefix.TZ3)(val);
2069
- }
2070
- else if (prefix[0] === 0x03) {
2071
- return prefixDecoder(utils.Prefix.TZ4)(val);
2072
- }
2073
- };
2074
- const publicKeyHashesDecoder = (val) => {
2075
- if (!boolDecoder(val)) {
2076
- return;
2077
- }
2078
- const publicKeyHashes = [];
2079
- val.consume(4);
2080
- while (val.length() > 0) {
2081
- publicKeyHashes.push(publicKeyHashDecoder(val));
2082
- }
2083
- return publicKeyHashes;
2084
- };
2085
- const branchEncoder = prefixEncoder(utils.Prefix.B);
2086
- const tz1Encoder = prefixEncoder(utils.Prefix.TZ1);
2087
- const boolEncoder = (bool) => (bool ? 'ff' : '00');
2088
- const proposalEncoder = (proposal) => {
2089
- return prefixEncoder(utils.Prefix.P)(proposal);
2090
- };
2091
- const proposalDecoder = (proposal) => {
2092
- return prefixDecoder(utils.Prefix.P)(proposal);
2093
- };
2094
- const proposalsDecoder = (proposal) => {
2095
- const proposals = [];
2096
- proposal.consume(4);
2097
- while (proposal.length() > 0) {
2098
- proposals.push(proposalDecoder(proposal));
2099
- }
2100
- return proposals;
2101
- };
2102
- const proposalsEncoder = (proposals) => {
2103
- return pad(32 * proposals.length) + proposals.map((x) => proposalEncoder(x)).join('');
2104
- };
2105
- const ballotEncoder = (ballot) => {
2106
- switch (ballot) {
2107
- case 'yay':
2108
- return '00';
2109
- case 'nay':
2110
- return '01';
2111
- case 'pass':
2112
- return '02';
2113
- default:
2114
- throw new InvalidBallotValueError(ballot);
2115
- }
2116
- };
2117
- const ballotDecoder = (ballot) => {
2118
- const value = ballot.consume(1);
2119
- switch (value[0]) {
2120
- case 0x00:
2121
- return 'yay';
2122
- case 0x01:
2123
- return 'nay';
2124
- case 0x02:
2125
- return 'pass';
2126
- default:
2127
- throw new DecodeBallotValueError(value[0].toString());
2128
- }
2129
- };
2130
- const pvmKindEncoder = (pvm) => {
2131
- switch (pvm) {
2132
- case 'arith':
2133
- return '00';
2134
- case 'wasm_2_0_0':
2135
- return '01';
2136
- case 'riscv':
2137
- return '02';
2138
- default:
2139
- throw new UnsupportedPvmKindError(pvm);
2140
- }
2141
- };
2142
- const pvmKindDecoder = (pvm) => {
2143
- const value = pvm.consume(1);
2144
- switch (value[0]) {
2145
- case 0x00:
2146
- return 'arith';
2147
- case 0x01:
2148
- return 'wasm_2_0_0';
2149
- case 0x02:
2150
- return 'riscv';
2151
- default:
2152
- throw new DecodePvmKindError(value[0].toString());
2153
- }
2154
- };
2155
- const delegateEncoder = (val) => {
2156
- if (val) {
2157
- return boolEncoder(true) + publicKeyHashEncoder(val);
2158
- }
2159
- else {
2160
- return boolEncoder(false);
2161
- }
2162
- };
2163
- const int32Encoder = (val) => {
2164
- const num = parseInt(String(val), 10);
2165
- const byte = [];
2166
- for (let i = 0; i < 4; i++) {
2167
- const shiftBy = (4 - (i + 1)) * 8;
2168
- byte.push((num & (0xff << shiftBy)) >> shiftBy);
2169
- }
2170
- return Buffer.from(byte).toString('hex');
2171
- };
2172
- const int32Decoder = (val) => {
2173
- const num = val.consume(4);
2174
- let finalNum = 0;
2175
- for (let i = 0; i < num.length; i++) {
2176
- finalNum = finalNum | (num[i] << ((num.length - (i + 1)) * 8));
2177
- }
2178
- return finalNum;
2179
- };
2180
- const int16Encoder = (val) => {
2181
- const num = parseInt(String(val), 10);
2182
- const byte = [];
2183
- for (let i = 0; i < 2; i++) {
2184
- const shiftBy = (2 - (i + 1)) * 8;
2185
- byte.push((num & (0xff << shiftBy)) >> shiftBy);
2186
- }
2187
- return Buffer.from(byte).toString('hex');
2188
- };
2189
- const int16Decoder = (val) => {
2190
- const num = val.consume(2);
2191
- let finalNum = 0;
2192
- for (let i = 0; i < num.length; i++) {
2193
- finalNum = finalNum | (num[i] << ((num.length - (i + 1)) * 8));
2194
- }
2195
- return finalNum;
2196
- };
2197
- const boolDecoder = (val) => {
2198
- const bool = val.consume(1);
2199
- return bool[0] === 0xff;
2200
- };
2201
- const delegateDecoder = (val) => {
2202
- const hasDelegate = boolDecoder(val);
2203
- if (hasDelegate) {
2204
- return publicKeyHashDecoder(val);
2205
- }
2206
- };
2207
- const publicKeyHashEncoder = (val) => {
2208
- const pubkeyPrefix = val.substring(0, 3);
2209
- switch (pubkeyPrefix) {
2210
- case utils.Prefix.TZ1:
2211
- return '00' + prefixEncoder(utils.Prefix.TZ1)(val);
2212
- case utils.Prefix.TZ2:
2213
- return '01' + prefixEncoder(utils.Prefix.TZ2)(val);
2214
- case utils.Prefix.TZ3:
2215
- return '02' + prefixEncoder(utils.Prefix.TZ3)(val);
2216
- case utils.Prefix.TZ4:
2217
- return '03' + prefixEncoder(utils.Prefix.TZ4)(val);
2218
- default:
2219
- throw new utils.InvalidKeyHashError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) +
2220
- ` expecting one for the following "${utils.Prefix.TZ1}", "${utils.Prefix.TZ2}", "${utils.Prefix.TZ3}" or "${utils.Prefix.TZ4}".`);
2221
- }
2222
- };
2223
- const publicKeyHashesEncoder = (val) => {
2224
- if (!val) {
2225
- return boolEncoder(false);
2226
- }
2227
- if (val.length === 0) {
2228
- return boolEncoder(true) + pad(0);
2229
- }
2230
- const publicKeyHashes = val.reduce((prev, curr) => {
2231
- return prev + publicKeyHashEncoder(curr);
2232
- }, '');
2233
- return boolEncoder(true) + pad(publicKeyHashes.length / 2) + publicKeyHashes;
2234
- };
2235
- const publicKeyEncoder = (val) => {
2236
- const pubkeyPrefix = val.substring(0, 4);
2237
- switch (pubkeyPrefix) {
2238
- case utils.Prefix.EDPK:
2239
- return '00' + prefixEncoder(utils.Prefix.EDPK)(val);
2240
- case utils.Prefix.SPPK:
2241
- return '01' + prefixEncoder(utils.Prefix.SPPK)(val);
2242
- case utils.Prefix.P2PK:
2243
- return '02' + prefixEncoder(utils.Prefix.P2PK)(val);
2244
- case utils.Prefix.BLPK:
2245
- return '03' + prefixEncoder(utils.Prefix.BLPK)(val);
2246
- default:
2247
- throw new utils.InvalidPublicKeyError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) +
2248
- ` expecting one of the following '${utils.Prefix.EDPK}', '${utils.Prefix.SPPK}', '${utils.Prefix.P2PK}' or '${utils.Prefix.BLPK}'.`);
2249
- }
2250
- };
2251
- const addressEncoder = (val) => {
2252
- const pubkeyPrefix = val.substring(0, 3);
2253
- switch (pubkeyPrefix) {
2254
- case utils.Prefix.TZ1:
2255
- case utils.Prefix.TZ2:
2256
- case utils.Prefix.TZ3:
2257
- case utils.Prefix.TZ4:
2258
- return '00' + publicKeyHashEncoder(val);
2259
- case utils.Prefix.KT1:
2260
- return '01' + prefixEncoder(utils.Prefix.KT1)(val) + '00';
2261
- default:
2262
- throw new core.InvalidAddressError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) +
2263
- ` expecting one of the following prefix '${utils.Prefix.TZ1}', ${utils.Prefix.TZ2}', '${utils.Prefix.TZ3}', '${utils.Prefix.TZ4}' or '${utils.Prefix.KT1}'.`);
2264
- }
2265
- };
2266
- const smartRollupAddressEncoder = (val) => {
2267
- if (val.substring(0, 3) !== utils.Prefix.SR1) {
2268
- throw new InvalidSmartRollupAddressError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils.Prefix.SR1}'.`);
2269
- }
2270
- return prefixEncoder(utils.Prefix.SR1)(val);
2271
- };
2272
- const smartContractAddressEncoder = (val) => {
2273
- const prefix = val.substring(0, 3);
2274
- if (prefix === utils.Prefix.KT1) {
2275
- return '01' + prefixEncoder(utils.Prefix.KT1)(val) + '00';
2276
- }
2277
- throw new core.InvalidContractAddressError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils.Prefix.KT1}'.`);
2278
- };
2279
- const publicKeyDecoder = (val) => {
2280
- const preamble = val.consume(1);
2281
- switch (preamble[0]) {
2282
- case 0x00:
2283
- return prefixDecoder(utils.Prefix.EDPK)(val);
2284
- case 0x01:
2285
- return prefixDecoder(utils.Prefix.SPPK)(val);
2286
- case 0x02:
2287
- return prefixDecoder(utils.Prefix.P2PK)(val);
2288
- case 0x03:
2289
- return prefixDecoder(utils.Prefix.BLPK)(val);
2290
- default:
2291
- throw new utils.InvalidPublicKeyError(val.toString(), utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED));
2292
- }
2293
- };
2294
- const smartRollupCommitmentHashEncoder = (val) => {
2295
- const prefix = val.substring(0, 4);
2296
- if (prefix === utils.Prefix.SRC1) {
2297
- return prefixEncoder(utils.Prefix.SRC1)(val);
2298
- }
2299
- throw new InvalidSmartRollupCommitmentHashError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils.Prefix.SRC1}'`);
2300
- };
2301
- const addressDecoder = (val) => {
2302
- const preamble = val.consume(1);
2303
- switch (preamble[0]) {
2304
- case 0x00:
2305
- return publicKeyHashDecoder(val);
2306
- case 0x01: {
2307
- const address = prefixDecoder(utils.Prefix.KT1)(val);
2308
- val.consume(1);
2309
- return address;
2310
- }
2311
- default:
2312
- throw new core.InvalidAddressError(val.toString(), ': Unable to decode.');
2313
- }
2314
- };
2315
- const smartRollupAddressDecoder = (val) => {
2316
- const address = prefixDecoder(utils.Prefix.SR1)(val);
2317
- if (address.substring(0, 3) !== utils.Prefix.SR1) {
2318
- throw new InvalidSmartRollupAddressError(address, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils.Prefix.SR1}'.`);
2319
- }
2320
- return address;
2321
- };
2322
- const smartContractAddressDecoder = (val) => {
2323
- const preamble = val.consume(1);
2324
- if (preamble[0] === 0x01) {
2325
- const scAddress = prefixDecoder(utils.Prefix.KT1)(val);
2326
- val.consume(1);
2327
- return scAddress;
2328
- }
2329
- throw new core.InvalidContractAddressError(val.toString(), utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED));
2330
- };
2331
- const smartRollupCommitmentHashDecoder = (val) => {
2332
- const address = prefixDecoder(utils.Prefix.SRC1)(val);
2333
- if (address.substring(0, 4) !== utils.Prefix.SRC1) {
2334
- throw new InvalidSmartRollupCommitmentHashError(address, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils.Prefix.SRC1}'`);
2335
- }
2336
- return address;
2337
- };
2338
- const zarithEncoder = (n) => {
2339
- const fn = [];
2340
- let nn = new BigNumber(n, 10);
2341
- if (nn.isNaN()) {
2342
- throw new TypeError(`Invalid zarith number ${n}`);
2343
- }
2344
- // eslint-disable-next-line no-constant-condition
2345
- while (true) {
2346
- if (nn.lt(128)) {
2347
- if (nn.lt(16))
2348
- fn.push('0');
2349
- fn.push(nn.toString(16));
2350
- break;
2351
- }
2352
- else {
2353
- let b = nn.mod(128);
2354
- nn = nn.minus(b);
2355
- nn = nn.dividedBy(128);
2356
- b = b.plus(128);
2357
- fn.push(b.toString(16));
2358
- }
2359
- }
2360
- return fn.join('');
2361
- };
2362
- const zarithDecoder = (n) => {
2363
- let mostSignificantByte = 0;
2364
- while (mostSignificantByte < n.length() && (n.get(mostSignificantByte) & 128) !== 0) {
2365
- mostSignificantByte += 1;
2366
- }
2367
- let num = new BigNumber(0);
2368
- for (let i = mostSignificantByte; i >= 0; i -= 1) {
2369
- const tmp = n.get(i) & 0x7f;
2370
- num = num.multipliedBy(128);
2371
- num = num.plus(tmp);
2372
- }
2373
- n.consume(mostSignificantByte + 1);
2374
- return new BigNumber(num).toString();
2375
- };
2376
- const entrypointDecoder = (value) => {
2377
- const preamble = pad(value.consume(1)[0], 2);
2378
- if (preamble in entrypointMapping) {
2379
- return entrypointMapping[preamble];
2380
- }
2381
- else {
2382
- const entry = extractRequiredLen(value, 1);
2383
- const entrypoint = Buffer.from(entry).toString('utf8');
2384
- if (entrypoint.length > ENTRYPOINT_MAX_LENGTH) {
2385
- throw new OversizedEntryPointError(entrypoint);
2386
- }
2387
- return entrypoint;
2388
- }
2389
- };
2390
- const parametersDecoder = (val) => {
2391
- const preamble = val.consume(1);
2392
- if (preamble[0] === 0x00) {
2393
- return;
2394
- }
2395
- else {
2396
- const encodedEntrypoint = entrypointDecoder(val);
2397
- const params = extractRequiredLen(val);
2398
- const parameters = valueDecoder(new Uint8ArrayConsumer(params));
2399
- return {
2400
- entrypoint: encodedEntrypoint,
2401
- value: parameters,
2402
- };
2403
- }
2404
- };
2405
- const entrypointEncoder = (entrypoint) => {
2406
- if (entrypoint in entrypointMappingReverse) {
2407
- return `${entrypointMappingReverse[entrypoint]}`;
2408
- }
2409
- else {
2410
- if (entrypoint.length > ENTRYPOINT_MAX_LENGTH) {
2411
- throw new OversizedEntryPointError(entrypoint);
2412
- }
2413
- const value = { string: entrypoint };
2414
- return `ff${valueEncoder(value).slice(8)}`;
2415
- }
2416
- };
2417
- const parametersEncoder = (val) => {
2418
- if (!val || (val.entrypoint === 'default' && 'prim' in val.value && val.value.prim === 'Unit')) {
2419
- return '00';
2420
- }
2421
- const encodedEntrypoint = entrypointEncoder(val.entrypoint);
2422
- const parameters = valueEncoder(val.value);
2423
- const length = pad(parameters.length / 2);
2424
- return `ff${encodedEntrypoint}${length}${parameters}`;
2425
- };
2426
- const valueParameterEncoder = (value) => {
2427
- const valueEncoded = valueEncoder(value);
2428
- return `${pad(valueEncoded.length / 2)}${valueEncoded}`;
2429
- };
2430
- const valueParameterDecoder = (val) => {
2431
- const value = extractRequiredLen(val);
2432
- return valueDecoder(new Uint8ArrayConsumer(value));
2433
- };
2434
- const blockPayloadHashEncoder = prefixEncoder(utils.Prefix.VH);
2435
- const blockPayloadHashDecoder = prefixDecoder(utils.Prefix.VH);
2436
- const entrypointNameEncoder = (entrypoint) => {
2437
- const value = { string: entrypoint };
2438
- return `${valueEncoder(value).slice(2)}`;
2439
- };
2440
- const entrypointNameDecoder = (val) => {
2441
- const entry = extractRequiredLen(val);
2442
- return Buffer.from(entry).toString('utf8');
2443
- };
2444
- const burnLimitEncoder = (val) => {
2445
- return !val ? '00' : `ff${zarithEncoder(val)}`;
2446
- };
2447
- const burnLimitDecoder = (value) => {
2448
- const prefix = value.consume(1);
2449
- if (Buffer.from(prefix).toString('hex') !== '00') {
2450
- return zarithDecoder(value);
2451
- }
2452
- };
2453
- const depositsLimitEncoder = (val) => {
2454
- return !val ? '00' : `ff${zarithEncoder(val)}`;
2455
- };
2456
- const depositsLimitDecoder = (value) => {
2457
- const prefix = value.consume(1);
2458
- if (Buffer.from(prefix).toString('hex') !== '00') {
2459
- return zarithDecoder(value);
2460
- }
2461
- };
2462
- const signatureV1Encoder = (val) => {
2463
- const signaturePrefix = val.substring(0, 5);
2464
- switch (signaturePrefix) {
2465
- case utils.Prefix.EDSIG:
2466
- return paddedBytesEncoder(prefixEncoder(utils.Prefix.EDSIG)(val));
2467
- case utils.Prefix.SPSIG:
2468
- return paddedBytesEncoder(prefixEncoder(utils.Prefix.SPSIG)(val));
2469
- case utils.Prefix.P2SIG:
2470
- return paddedBytesEncoder(prefixEncoder(utils.Prefix.P2SIG)(val));
2471
- case utils.Prefix.BLSIG:
2472
- return paddedBytesEncoder(prefixEncoder(utils.Prefix.BLSIG)(val));
2473
- default:
2474
- throw new core.InvalidSignatureError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) +
2475
- ` expecting one of the following '${utils.Prefix.EDSIG}', '${utils.Prefix.SPSIG}', '${utils.Prefix.P2SIG}' or '${utils.Prefix.BLSIG}'.`);
2476
- }
2477
- };
2478
- const signatureV1Decoder = (val) => {
2479
- val.consume(4);
2480
- if (val.length().toString() === '96') {
2481
- return prefixDecoder(utils.Prefix.BLSIG)(val);
2482
- }
2483
- else {
2484
- throw new core.ProhibitedActionError('currently we only support decoding of BLSIG signatures');
2485
- }
2486
- };
2487
- const signatureProofEncoder = (val) => {
2488
- if (val) {
2489
- return boolEncoder(true) + signatureV1Encoder(val);
2490
- }
2491
- else {
2492
- return boolEncoder(false);
2493
- }
2494
- };
2495
- const signatureProofDecoder = (value) => {
2496
- const hasProof = boolDecoder(value);
2497
- if (hasProof) {
2498
- return signatureV1Decoder(value);
2499
- }
2500
- };
2501
- const paddedBytesEncoder = (val, paddingLength = 8) => {
2502
- return `${pad(val.length / 2, paddingLength)}${val}`;
2503
- };
2504
- const paddedBytesDecoder = (val) => {
2505
- const value = extractRequiredLen(val);
2506
- return Buffer.from(value).toString('hex');
2507
- };
2508
- const smartRollupMessageEncoder = (val) => {
2509
- const message = val.reduce((prev, curr) => {
2510
- return prev + `${pad(curr.length / 2)}${curr}`;
2511
- }, '');
2512
- return `${pad(message.length / 2)}${message}`;
2513
- };
2514
- const smartRollupMessageDecoder = (val) => {
2515
- const valueArray = extractRequiredLen(val);
2516
- const ret = stripLengthPrefixFromBytes(new Uint8ArrayConsumer(valueArray));
2517
- return ret.map((value) => Buffer.from(value).toString('hex'));
2518
- };
2519
- const dalCommitmentEncoder = (val) => {
2520
- const prefix = val.substring(0, 2);
2521
- if (prefix === utils.Prefix.SH) {
2522
- return prefixEncoder(utils.Prefix.SH)(val);
2523
- }
2524
- throw new InvalidDalCommitmentError(val, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils.Prefix.SH}'`);
2525
- };
2526
- const dalCommitmentDecoder = (val) => {
2527
- const commitment = prefixDecoder(utils.Prefix.SH)(val);
2528
- if (commitment.substring(0, 2) !== utils.Prefix.SH) {
2529
- throw new InvalidDalCommitmentError(commitment, utils.invalidDetail(utils.ValidationResult.NO_PREFIX_MATCHED) + ` expecting prefix '${utils.Prefix.SH}'`);
2530
- }
2531
- return commitment;
2532
- };
2533
- const slotHeaderEncoder = (val) => {
2534
- return pad(val.slot_index, 2) + dalCommitmentEncoder(val.commitment) + val.commitment_proof;
2535
- };
2536
- const slotHeaderDecoder = (val) => {
2537
- const preamble = val.consume(1);
2538
- return {
2539
- slot_index: Number(preamble[0].toString(10)),
2540
- commitment: dalCommitmentDecoder(val),
2541
- commitment_proof: toHexString(val.consume(96)), // rpcForger expect commitment_proof bytes to be len 96
2542
- };
2543
- };
2544
-
2545
- const ManagerOperationSchema = {
2546
- branch: CODEC.BRANCH,
2547
- contents: [CODEC.OPERATION],
2548
- };
2549
- const ActivationSchema = {
2550
- pkh: CODEC.TZ1,
2551
- secret: CODEC.SECRET,
2552
- };
2553
- const RevealSchema = {
2554
- source: CODEC.PKH,
2555
- fee: CODEC.ZARITH,
2556
- counter: CODEC.ZARITH,
2557
- gas_limit: CODEC.ZARITH,
2558
- storage_limit: CODEC.ZARITH,
2559
- public_key: CODEC.PUBLIC_KEY,
2560
- };
2561
- const DelegationSchema = {
2562
- source: CODEC.PKH,
2563
- fee: CODEC.ZARITH,
2564
- counter: CODEC.ZARITH,
2565
- gas_limit: CODEC.ZARITH,
2566
- storage_limit: CODEC.ZARITH,
2567
- delegate: CODEC.DELEGATE,
2568
- };
2569
- const TransactionSchema = {
2570
- source: CODEC.PKH,
2571
- fee: CODEC.ZARITH,
2572
- counter: CODEC.ZARITH,
2573
- gas_limit: CODEC.ZARITH,
2574
- storage_limit: CODEC.ZARITH,
2575
- amount: CODEC.ZARITH,
2576
- destination: CODEC.ADDRESS,
2577
- parameters: CODEC.PARAMETERS,
2578
- };
2579
- const OriginationSchema = {
2580
- source: CODEC.PKH,
2581
- fee: CODEC.ZARITH,
2582
- counter: CODEC.ZARITH,
2583
- gas_limit: CODEC.ZARITH,
2584
- storage_limit: CODEC.ZARITH,
2585
- balance: CODEC.ZARITH,
2586
- delegate: CODEC.DELEGATE,
2587
- script: CODEC.SCRIPT,
2588
- };
2589
- const BallotSchema = {
2590
- source: CODEC.PKH,
2591
- period: CODEC.INT32,
2592
- proposal: CODEC.PROPOSAL,
2593
- ballot: CODEC.BALLOT_STATEMENT,
2594
- };
2595
- const AttestationSchema = {
2596
- slot: CODEC.INT16,
2597
- level: CODEC.INT32,
2598
- round: CODEC.INT32,
2599
- block_payload_hash: CODEC.BLOCK_PAYLOAD_HASH,
2600
- };
2601
- const AttestationWithDalSchema = {
2602
- slot: CODEC.INT16,
2603
- level: CODEC.INT32,
2604
- round: CODEC.INT32,
2605
- block_payload_hash: CODEC.BLOCK_PAYLOAD_HASH,
2606
- dal_attestation: CODEC.ZARITH,
2607
- };
2608
- const SeedNonceRevelationSchema = {
2609
- level: CODEC.INT32,
2610
- nonce: CODEC.RAW,
2611
- };
2612
- const ProposalsSchema = {
2613
- source: CODEC.PKH,
2614
- period: CODEC.INT32,
2615
- proposals: CODEC.PROPOSAL_ARR,
2616
- };
2617
- const RegisterGlobalConstantSchema = {
2618
- source: CODEC.PKH,
2619
- fee: CODEC.ZARITH,
2620
- counter: CODEC.ZARITH,
2621
- gas_limit: CODEC.ZARITH,
2622
- storage_limit: CODEC.ZARITH,
2623
- value: CODEC.VALUE,
2624
- };
2625
- const TransferTicketSchema = {
2626
- source: CODEC.PKH,
2627
- fee: CODEC.ZARITH,
2628
- counter: CODEC.ZARITH,
2629
- gas_limit: CODEC.ZARITH,
2630
- storage_limit: CODEC.ZARITH,
2631
- ticket_contents: CODEC.VALUE,
2632
- ticket_ty: CODEC.VALUE,
2633
- ticket_ticketer: CODEC.ADDRESS,
2634
- ticket_amount: CODEC.ZARITH,
2635
- destination: CODEC.ADDRESS,
2636
- entrypoint: CODEC.ENTRYPOINT,
2637
- };
2638
- const IncreasePaidStorageSchema = {
2639
- source: CODEC.PKH,
2640
- fee: CODEC.ZARITH,
2641
- counter: CODEC.ZARITH,
2642
- gas_limit: CODEC.ZARITH,
2643
- storage_limit: CODEC.ZARITH,
2644
- amount: CODEC.ZARITH,
2645
- destination: CODEC.SMART_CONTRACT_ADDRESS,
2646
- };
2647
- const UpdateConsensusKeySchema = {
2648
- source: CODEC.PKH,
2649
- fee: CODEC.ZARITH,
2650
- counter: CODEC.ZARITH,
2651
- gas_limit: CODEC.ZARITH,
2652
- storage_limit: CODEC.ZARITH,
2653
- pk: CODEC.PUBLIC_KEY,
2654
- proof: CODEC.SIGNATURE_PROOF,
2655
- };
2656
- const DrainDelegateSchema = {
2657
- consensus_key: CODEC.PKH,
2658
- delegate: CODEC.PKH,
2659
- destination: CODEC.PKH,
2660
- };
2661
- const SetDepositsLimitSchema = {
2662
- source: CODEC.PKH,
2663
- fee: CODEC.ZARITH,
2664
- counter: CODEC.ZARITH,
2665
- gas_limit: CODEC.ZARITH,
2666
- storage_limit: CODEC.ZARITH,
2667
- limit: CODEC.DEPOSITS_LIMIT,
2668
- };
2669
- const SmartRollupOriginateSchema = {
2670
- source: CODEC.PKH,
2671
- fee: CODEC.ZARITH,
2672
- counter: CODEC.ZARITH,
2673
- gas_limit: CODEC.ZARITH,
2674
- storage_limit: CODEC.ZARITH,
2675
- pvm_kind: CODEC.PVM_KIND,
2676
- kernel: CODEC.PADDED_BYTES,
2677
- parameters_ty: CODEC.VALUE,
2678
- whitelist: CODEC.PKH_ARR,
2679
- };
2680
- const SmartRollupAddMessagesSchema = {
2681
- source: CODEC.PKH,
2682
- fee: CODEC.ZARITH,
2683
- counter: CODEC.ZARITH,
2684
- gas_limit: CODEC.ZARITH,
2685
- storage_limit: CODEC.ZARITH,
2686
- message: CODEC.SMART_ROLLUP_MESSAGE,
2687
- };
2688
- const SmartRollupExecuteOutboxMessageSchema = {
2689
- source: CODEC.PKH,
2690
- fee: CODEC.ZARITH,
2691
- counter: CODEC.ZARITH,
2692
- gas_limit: CODEC.ZARITH,
2693
- storage_limit: CODEC.ZARITH,
2694
- rollup: CODEC.SMART_ROLLUP_ADDRESS,
2695
- cemented_commitment: CODEC.SMART_ROLLUP_COMMITMENT_HASH,
2696
- output_proof: CODEC.PADDED_BYTES,
2697
- };
2698
- const DalPublishCommitmentSchema = {
2699
- source: CODEC.PKH,
2700
- fee: CODEC.ZARITH,
2701
- counter: CODEC.ZARITH,
2702
- gas_limit: CODEC.ZARITH,
2703
- storage_limit: CODEC.ZARITH,
2704
- slot_header: CODEC.SLOT_HEADER,
2705
- };
2706
- const FailingNoopSchema = {
2707
- arbitrary: CODEC.PADDED_BYTES,
2708
- };
2709
- const operationEncoder = (encoders) => (operation) => {
2710
- if (!(operation.kind in encoders) || !(operation.kind in kindMappingReverse)) {
2711
- throw new core.InvalidOperationKindError(operation.kind);
2712
- }
2713
- return kindMappingReverse[operation.kind] + encoders[operation.kind](operation);
2714
- };
2715
- const operationDecoder = (decoders) => (value) => {
2716
- const op = value.consume(1);
2717
- const operationName = kindMapping[op[0]];
2718
- if (operationName === undefined) {
2719
- throw new UnsupportedOperationError(op[0].toString());
2720
- }
2721
- const decodedObj = decoders[operationName](value);
2722
- if (typeof decodedObj !== 'object') {
2723
- throw new OperationDecodingError('Invalid operation, cannot be decoded.');
2724
- }
2725
- return Object.assign({ kind: operationName }, decodedObj);
2726
- };
2727
- const schemaEncoder = (encoders) => (schema) => (value) => {
2728
- const keys = Object.keys(schema);
2729
- return keys.reduce((prev, key) => {
2730
- const valueToEncode = schema[key];
2731
- if (value && Array.isArray(valueToEncode)) {
2732
- const encoder = encoders[valueToEncode[0]];
2733
- const values = value[key];
2734
- if (!Array.isArray(values)) {
2735
- throw new OperationEncodingError(`Invalid operation value "${JSON.stringify(values)}" of key "${key}, expected value to be Array.`);
2736
- }
2737
- return (prev + values.reduce((prevBytes, current) => prevBytes + encoder(current), ''));
2738
- }
2739
- else {
2740
- const encoder = encoders[valueToEncode];
2741
- return prev + encoder(value[key]);
2742
- }
2743
- }, '');
2744
- };
2745
- const schemaDecoder = (decoders) => (schema) => (value) => {
2746
- const keys = Object.keys(schema);
2747
- return keys.reduce((prev, key) => {
2748
- const valueToEncode = schema[key];
2749
- if (Array.isArray(valueToEncode)) {
2750
- const decoder = decoders[valueToEncode[0]];
2751
- const decoded = [];
2752
- const lastLength = value.length();
2753
- while (value.length() > 0) {
2754
- decoded.push(decoder(value));
2755
- if (lastLength === value.length()) {
2756
- throw new OperationDecodingError('Unable to decode value');
2757
- }
2758
- }
2759
- return Object.assign(Object.assign({}, prev), { [key]: decoded });
2760
- }
2761
- else {
2762
- const decoder = decoders[valueToEncode];
2763
- const result = decoder(value);
2764
- if (typeof result !== 'undefined') {
2765
- return Object.assign(Object.assign({}, prev), { [key]: result });
2766
- }
2767
- else {
2768
- return Object.assign({}, prev);
2769
- }
2770
- }
2771
- }, {});
2772
- };
2773
-
2774
- const decoders = {
2775
- [CODEC.SECRET]: (val) => toHexString(val.consume(20)),
2776
- [CODEC.RAW]: (val) => toHexString(val.consume(32)),
2777
- [CODEC.TZ1]: tz1Decoder,
2778
- [CODEC.BRANCH]: branchDecoder,
2779
- [CODEC.ZARITH]: zarithDecoder,
2780
- [CODEC.PUBLIC_KEY]: publicKeyDecoder,
2781
- [CODEC.PKH]: publicKeyHashDecoder,
2782
- [CODEC.PKH_ARR]: publicKeyHashesDecoder,
2783
- [CODEC.DELEGATE]: delegateDecoder,
2784
- [CODEC.INT32]: int32Decoder,
2785
- [CODEC.SCRIPT]: scriptDecoder,
2786
- [CODEC.BALLOT_STATEMENT]: ballotDecoder,
2787
- [CODEC.PROPOSAL]: proposalDecoder,
2788
- [CODEC.PROPOSAL_ARR]: proposalsDecoder,
2789
- [CODEC.PARAMETERS]: parametersDecoder,
2790
- [CODEC.ADDRESS]: addressDecoder,
2791
- [CODEC.SMART_ROLLUP_ADDRESS]: smartRollupAddressDecoder,
2792
- [CODEC.SMART_CONTRACT_ADDRESS]: smartContractAddressDecoder,
2793
- [CODEC.SMART_ROLLUP_COMMITMENT_HASH]: smartRollupCommitmentHashDecoder,
2794
- [CODEC.VALUE]: valueParameterDecoder,
2795
- [CODEC.INT16]: int16Decoder,
2796
- [CODEC.BLOCK_PAYLOAD_HASH]: blockPayloadHashDecoder,
2797
- [CODEC.ENTRYPOINT]: entrypointNameDecoder,
2798
- [CODEC.BURN_LIMIT]: burnLimitDecoder,
2799
- [CODEC.DEPOSITS_LIMIT]: depositsLimitDecoder,
2800
- [CODEC.SIGNATURE_PROOF]: signatureProofDecoder,
2801
- [CODEC.PVM_KIND]: pvmKindDecoder,
2802
- [CODEC.PADDED_BYTES]: paddedBytesDecoder,
2803
- [CODEC.SMART_ROLLUP_MESSAGE]: smartRollupMessageDecoder,
2804
- [CODEC.SLOT_HEADER]: slotHeaderDecoder,
2805
- };
2806
- decoders[CODEC.OPERATION] = operationDecoder(decoders);
2807
- decoders[CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaDecoder(decoders)(ActivationSchema)(val);
2808
- decoders[CODEC.OP_FAILING_NOOP] = (val) => schemaDecoder(decoders)(FailingNoopSchema)(val);
2809
- decoders[CODEC.OP_DELEGATION] = (val) => schemaDecoder(decoders)(DelegationSchema)(val);
2810
- decoders[CODEC.OP_TRANSACTION] = (val) => schemaDecoder(decoders)(TransactionSchema)(val);
2811
- decoders[CODEC.OP_ORIGINATION] = (val) => schemaDecoder(decoders)(OriginationSchema)(val);
2812
- decoders[CODEC.OP_BALLOT] = (val) => schemaDecoder(decoders)(BallotSchema)(val);
2813
- decoders[CODEC.OP_ATTESTATION] = (val) => schemaDecoder(decoders)(AttestationSchema)(val);
2814
- decoders[CODEC.OP_ATTESTATION_WITH_DAL] = (val) => schemaDecoder(decoders)(AttestationWithDalSchema)(val);
2815
- decoders[CODEC.OP_SEED_NONCE_REVELATION] = (val) => schemaDecoder(decoders)(SeedNonceRevelationSchema)(val);
2816
- decoders[CODEC.OP_PROPOSALS] = (val) => schemaDecoder(decoders)(ProposalsSchema)(val);
2817
- decoders[CODEC.OP_REVEAL] = (val) => schemaDecoder(decoders)(RevealSchema)(val);
2818
- decoders[CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaDecoder(decoders)(RegisterGlobalConstantSchema)(val);
2819
- decoders[CODEC.OP_TRANSFER_TICKET] = (val) => schemaDecoder(decoders)(TransferTicketSchema)(val);
2820
- decoders[CODEC.OP_INCREASE_PAID_STORAGE] = (val) => schemaDecoder(decoders)(IncreasePaidStorageSchema)(val);
2821
- decoders[CODEC.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaDecoder(decoders)(UpdateConsensusKeySchema)(val);
2822
- decoders[CODEC.OP_DRAIN_DELEGATE] = (val) => schemaDecoder(decoders)(DrainDelegateSchema)(val);
2823
- decoders[CODEC.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaDecoder(decoders)(SmartRollupOriginateSchema)(val);
2824
- decoders[CODEC.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaDecoder(decoders)(SmartRollupAddMessagesSchema)(val);
2825
- decoders[CODEC.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaDecoder(decoders)(SmartRollupExecuteOutboxMessageSchema)(val);
2826
- decoders[CODEC.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaDecoder(decoders)(DalPublishCommitmentSchema)(val);
2827
- decoders[CODEC.MANAGER] = schemaDecoder(decoders)(ManagerOperationSchema);
2828
- decoders[CODEC.OP_SET_DEPOSITS_LIMIT] = (val) => schemaDecoder(decoders)(SetDepositsLimitSchema)(val);
2829
-
2830
- const encoders$1 = {
2831
- [exports.CODEC.SECRET]: (val) => val,
2832
- [exports.CODEC.RAW]: (val) => val,
2833
- [exports.CODEC.TZ1]: tz1Encoder$1,
2834
- [exports.CODEC.BRANCH]: branchEncoder$1,
2835
- [exports.CODEC.ZARITH]: zarithEncoder$1,
2836
- [exports.CODEC.PUBLIC_KEY]: publicKeyEncoder$1,
2837
- [exports.CODEC.PKH]: publicKeyHashEncoder$1,
2838
- [exports.CODEC.PKH_ARR]: publicKeyHashesEncoder$1,
2839
- [exports.CODEC.DELEGATE]: delegateEncoder$1,
2840
- [exports.CODEC.SCRIPT]: scriptEncoder$1,
2841
- [exports.CODEC.BALLOT_STATEMENT]: ballotEncoder$1,
2842
- [exports.CODEC.PROPOSAL]: proposalEncoder$1,
2843
- [exports.CODEC.PROPOSAL_ARR]: proposalsEncoder$1,
2844
- [exports.CODEC.INT32]: int32Encoder$1,
2845
- [exports.CODEC.PARAMETERS]: parametersEncoder$1,
2846
- [exports.CODEC.ADDRESS]: addressEncoder$1,
2847
- [exports.CODEC.SMART_ROLLUP_ADDRESS]: smartRollupAddressEncoder$1,
2848
- [exports.CODEC.SMART_CONTRACT_ADDRESS]: smartContractAddressEncoder$1,
2849
- [exports.CODEC.SMART_ROLLUP_COMMITMENT_HASH]: smartRollupCommitmentHashEncoder$1,
2850
- [exports.CODEC.VALUE]: valueParameterEncoder$1,
2851
- [exports.CODEC.INT16]: int16Encoder$1,
2852
- [exports.CODEC.BLOCK_PAYLOAD_HASH]: blockPayloadHashEncoder$1,
2853
- [exports.CODEC.ENTRYPOINT]: entrypointNameEncoder$1,
2854
- [exports.CODEC.BURN_LIMIT]: burnLimitEncoder$1,
2855
- [exports.CODEC.DEPOSITS_LIMIT]: depositsLimitEncoder$1,
2856
- [exports.CODEC.SIGNATURE_PROOF]: signatureProofEncoder$1,
2857
- [exports.CODEC.PVM_KIND]: pvmKindEncoder$1,
2858
- [exports.CODEC.PADDED_BYTES]: paddedBytesEncoder$1,
2859
- [exports.CODEC.SMART_ROLLUP_MESSAGE]: smartRollupMessageEncoder$1,
2860
- [exports.CODEC.SLOT_HEADER]: slotHeaderEncoder$1,
2861
- };
2862
- encoders$1[exports.CODEC.OPERATION] = operationEncoder$1(encoders$1);
2863
- encoders$1[exports.CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaEncoder$1(encoders$1)(ActivationSchema$1)(val);
2864
- encoders$1[exports.CODEC.OP_DELEGATION] = (val) => schemaEncoder$1(encoders$1)(DelegationSchema$1)(val);
2865
- encoders$1[exports.CODEC.OP_TRANSACTION] = (val) => schemaEncoder$1(encoders$1)(TransactionSchema$1)(val);
2866
- encoders$1[exports.CODEC.OP_ORIGINATION] = (val) => schemaEncoder$1(encoders$1)(OriginationSchema$1)(val);
2867
- encoders$1[exports.CODEC.OP_BALLOT] = (val) => schemaEncoder$1(encoders$1)(BallotSchema$1)(val);
2868
- encoders$1[exports.CODEC.OP_ATTESTATION] = (val) => schemaEncoder$1(encoders$1)(AttestationSchema$1)(val);
2869
- encoders$1[exports.CODEC.OP_ATTESTATION_WITH_DAL] = (val) => schemaEncoder$1(encoders$1)(AttestationWithDalSchema$1)(val);
2870
- encoders$1[exports.CODEC.OP_SEED_NONCE_REVELATION] = (val) => schemaEncoder$1(encoders$1)(SeedNonceRevelationSchema$1)(val);
2871
- encoders$1[exports.CODEC.OP_PROPOSALS] = (val) => schemaEncoder$1(encoders$1)(ProposalsSchema$1)(val);
2872
- encoders$1[exports.CODEC.OP_REVEAL] = (val) => schemaEncoder$1(encoders$1)(RevealSchema$1)(val);
2873
- encoders$1[exports.CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaEncoder$1(encoders$1)(RegisterGlobalConstantSchema$1)(val);
2874
- encoders$1[exports.CODEC.OP_TRANSFER_TICKET] = (val) => schemaEncoder$1(encoders$1)(TransferTicketSchema$1)(val);
2875
- encoders$1[exports.CODEC.OP_INCREASE_PAID_STORAGE] = (val) => schemaEncoder$1(encoders$1)(IncreasePaidStorageSchema$1)(val);
2876
- encoders$1[exports.CODEC.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaEncoder$1(encoders$1)(UpdateConsensusKeySchema$1)(val);
2877
- encoders$1[exports.CODEC.OP_UPDATE_COMPANION_KEY] = (val) => schemaEncoder$1(encoders$1)(UpdateCompanionKeySchema)(val);
2878
- encoders$1[exports.CODEC.OP_DRAIN_DELEGATE] = (val) => schemaEncoder$1(encoders$1)(DrainDelegateSchema$1)(val);
2879
- encoders$1[exports.CODEC.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaEncoder$1(encoders$1)(SmartRollupOriginateSchema$1)(val);
2880
- encoders$1[exports.CODEC.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaEncoder$1(encoders$1)(SmartRollupAddMessagesSchema$1)(val);
2881
- encoders$1[exports.CODEC.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaEncoder$1(encoders$1)(SmartRollupExecuteOutboxMessageSchema$1)(val);
2882
- encoders$1[exports.CODEC.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaEncoder$1(encoders$1)(DalPublishCommitmentSchema$1)(val);
2883
- encoders$1[exports.CODEC.MANAGER] = schemaEncoder$1(encoders$1)(ManagerOperationSchema$1);
2884
- encoders$1[exports.CODEC.OP_SET_DEPOSITS_LIMIT] = (val) => schemaEncoder$1(encoders$1)(SetDepositsLimitSchema$1)(val);
2885
- encoders$1[exports.CODEC.OP_FAILING_NOOP] = (val) => schemaEncoder$1(encoders$1)(FailingNoopSchema$1)(val);
2886
-
2887
- const encoders = {
2888
- [CODEC.SECRET]: (val) => val,
2889
- [CODEC.RAW]: (val) => val,
2890
- [CODEC.TZ1]: tz1Encoder,
2891
- [CODEC.BRANCH]: branchEncoder,
2892
- [CODEC.ZARITH]: zarithEncoder,
2893
- [CODEC.PUBLIC_KEY]: publicKeyEncoder,
2894
- [CODEC.PKH]: publicKeyHashEncoder,
2895
- [CODEC.PKH_ARR]: publicKeyHashesEncoder,
2896
- [CODEC.DELEGATE]: delegateEncoder,
2897
- [CODEC.SCRIPT]: scriptEncoder,
2898
- [CODEC.BALLOT_STATEMENT]: ballotEncoder,
2899
- [CODEC.PROPOSAL]: proposalEncoder,
2900
- [CODEC.PROPOSAL_ARR]: proposalsEncoder,
2901
- [CODEC.INT32]: int32Encoder,
2902
- [CODEC.PARAMETERS]: parametersEncoder,
2903
- [CODEC.ADDRESS]: addressEncoder,
2904
- [CODEC.SMART_ROLLUP_ADDRESS]: smartRollupAddressEncoder,
2905
- [CODEC.SMART_CONTRACT_ADDRESS]: smartContractAddressEncoder,
2906
- [CODEC.SMART_ROLLUP_COMMITMENT_HASH]: smartRollupCommitmentHashEncoder,
2907
- [CODEC.VALUE]: valueParameterEncoder,
2908
- [CODEC.INT16]: int16Encoder,
2909
- [CODEC.BLOCK_PAYLOAD_HASH]: blockPayloadHashEncoder,
2910
- [CODEC.ENTRYPOINT]: entrypointNameEncoder,
2911
- [CODEC.BURN_LIMIT]: burnLimitEncoder,
2912
- [CODEC.DEPOSITS_LIMIT]: depositsLimitEncoder,
2913
- [CODEC.SIGNATURE_PROOF]: signatureProofEncoder,
2914
- [CODEC.PVM_KIND]: pvmKindEncoder,
2915
- [CODEC.PADDED_BYTES]: paddedBytesEncoder,
2916
- [CODEC.SMART_ROLLUP_MESSAGE]: smartRollupMessageEncoder,
2917
- [CODEC.SLOT_HEADER]: slotHeaderEncoder,
2918
- };
2919
- encoders[CODEC.OPERATION] = operationEncoder(encoders);
2920
- encoders[CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaEncoder(encoders)(ActivationSchema)(val);
2921
- encoders[CODEC.OP_DELEGATION] = (val) => schemaEncoder(encoders)(DelegationSchema)(val);
2922
- encoders[CODEC.OP_TRANSACTION] = (val) => schemaEncoder(encoders)(TransactionSchema)(val);
2923
- encoders[CODEC.OP_ORIGINATION] = (val) => schemaEncoder(encoders)(OriginationSchema)(val);
2924
- encoders[CODEC.OP_BALLOT] = (val) => schemaEncoder(encoders)(BallotSchema)(val);
2925
- encoders[CODEC.OP_ATTESTATION] = (val) => schemaEncoder(encoders)(AttestationSchema)(val);
2926
- encoders[CODEC.OP_ATTESTATION_WITH_DAL] = (val) => schemaEncoder(encoders)(AttestationWithDalSchema)(val);
2927
- encoders[CODEC.OP_SEED_NONCE_REVELATION] = (val) => schemaEncoder(encoders)(SeedNonceRevelationSchema)(val);
2928
- encoders[CODEC.OP_PROPOSALS] = (val) => schemaEncoder(encoders)(ProposalsSchema)(val);
2929
- encoders[CODEC.OP_REVEAL] = (val) => schemaEncoder(encoders)(RevealSchema)(val);
2930
- encoders[CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaEncoder(encoders)(RegisterGlobalConstantSchema)(val);
2931
- encoders[CODEC.OP_TRANSFER_TICKET] = (val) => schemaEncoder(encoders)(TransferTicketSchema)(val);
2932
- encoders[CODEC.OP_INCREASE_PAID_STORAGE] = (val) => schemaEncoder(encoders)(IncreasePaidStorageSchema)(val);
2933
- encoders[CODEC.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaEncoder(encoders)(UpdateConsensusKeySchema)(val);
2934
- encoders[CODEC.OP_DRAIN_DELEGATE] = (val) => schemaEncoder(encoders)(DrainDelegateSchema)(val);
2935
- encoders[CODEC.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaEncoder(encoders)(SmartRollupOriginateSchema)(val);
2936
- encoders[CODEC.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaEncoder(encoders)(SmartRollupAddMessagesSchema)(val);
2937
- encoders[CODEC.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaEncoder(encoders)(SmartRollupExecuteOutboxMessageSchema)(val);
2938
- encoders[CODEC.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaEncoder(encoders)(DalPublishCommitmentSchema)(val);
2939
- encoders[CODEC.MANAGER] = schemaEncoder(encoders)(ManagerOperationSchema);
2940
- encoders[CODEC.OP_SET_DEPOSITS_LIMIT] = (val) => schemaEncoder(encoders)(SetDepositsLimitSchema)(val);
2941
- encoders[CODEC.OP_FAILING_NOOP] = (val) => schemaEncoder(encoders)(FailingNoopSchema)(val);
2942
-
2943
- const OperationKindMapping = {
2944
- activate_account: ActivationSchema$1,
2945
- reveal: RevealSchema$1,
2946
- delegation: DelegationSchema$1,
2947
- transaction: TransactionSchema$1,
2948
- origination: OriginationSchema$1,
2949
- ballot: BallotSchema$1,
2950
- attestation: AttestationSchema$1,
2951
- attestation_with_dal: AttestationWithDalSchema$1,
2952
- seed_nonce_revelation: SeedNonceRevelationSchema$1,
2953
- proposals: ProposalsSchema$1,
2954
- register_global_constant: RegisterGlobalConstantSchema$1,
2955
- transfer_ticket: TransferTicketSchema$1,
2956
- increase_paid_storage: IncreasePaidStorageSchema$1,
2957
- update_consensus_key: UpdateConsensusKeySchema$1,
2958
- update_companion_key: UpdateCompanionKeySchema,
2959
- drain_delegate: DrainDelegateSchema$1,
2960
- set_deposits_limit: SetDepositsLimitSchema$1,
2961
- smart_rollup_originate: SmartRollupOriginateSchema$1,
2962
- smart_rollup_add_messages: SmartRollupAddMessagesSchema$1,
2963
- smart_rollup_execute_outbox_message: SmartRollupExecuteOutboxMessageSchema$1,
2964
- dal_publish_commitment: DalPublishCommitmentSchema$1,
2965
- failing_noop: FailingNoopSchema$1,
2966
- };
2967
- // Asymmetric difference: only account for things in arr2 that are not present in arr1, not vice versa
2968
- const getArrayDifference = (arr1, arr2) => {
2969
- return arr2.filter((x) => !arr1.includes(x));
2970
- };
2971
- const deleteArrayElementByValue = (array, item) => {
2972
- return array.filter((e) => e !== item);
2973
- };
2974
- /**
2975
- * @returns A boolean value to indicate whether the operation kind is valid or not
1515
+ const encoders = {
1516
+ [exports.CODEC.SECRET]: (val) => val,
1517
+ [exports.CODEC.RAW]: (val) => val,
1518
+ [exports.CODEC.TZ1]: tz1Encoder,
1519
+ [exports.CODEC.BRANCH]: branchEncoder,
1520
+ [exports.CODEC.ZARITH]: zarithEncoder,
1521
+ [exports.CODEC.PUBLIC_KEY]: publicKeyEncoder,
1522
+ [exports.CODEC.PKH]: publicKeyHashEncoder,
1523
+ [exports.CODEC.PKH_ARR]: publicKeyHashesEncoder,
1524
+ [exports.CODEC.DELEGATE]: delegateEncoder,
1525
+ [exports.CODEC.SCRIPT]: scriptEncoder,
1526
+ [exports.CODEC.BALLOT_STATEMENT]: ballotEncoder,
1527
+ [exports.CODEC.PROPOSAL]: proposalEncoder,
1528
+ [exports.CODEC.PROPOSAL_ARR]: proposalsEncoder,
1529
+ [exports.CODEC.INT32]: int32Encoder,
1530
+ [exports.CODEC.PARAMETERS]: parametersEncoder,
1531
+ [exports.CODEC.ADDRESS]: addressEncoder,
1532
+ [exports.CODEC.SMART_ROLLUP_ADDRESS]: smartRollupAddressEncoder,
1533
+ [exports.CODEC.SMART_CONTRACT_ADDRESS]: smartContractAddressEncoder,
1534
+ [exports.CODEC.SMART_ROLLUP_COMMITMENT_HASH]: smartRollupCommitmentHashEncoder,
1535
+ [exports.CODEC.VALUE]: valueParameterEncoder,
1536
+ [exports.CODEC.INT16]: int16Encoder,
1537
+ [exports.CODEC.BLOCK_PAYLOAD_HASH]: blockPayloadHashEncoder,
1538
+ [exports.CODEC.ENTRYPOINT]: entrypointNameEncoder,
1539
+ [exports.CODEC.BURN_LIMIT]: burnLimitEncoder,
1540
+ [exports.CODEC.DEPOSITS_LIMIT]: depositsLimitEncoder,
1541
+ [exports.CODEC.SIGNATURE_PROOF]: signatureProofEncoder,
1542
+ [exports.CODEC.PVM_KIND]: pvmKindEncoder,
1543
+ [exports.CODEC.PADDED_BYTES]: paddedBytesEncoder,
1544
+ [exports.CODEC.SMART_ROLLUP_MESSAGE]: smartRollupMessageEncoder,
1545
+ [exports.CODEC.SLOT_HEADER]: slotHeaderEncoder,
1546
+ };
1547
+ encoders[exports.CODEC.OPERATION] = operationEncoder(encoders);
1548
+ encoders[exports.CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaEncoder(encoders)(ActivationSchema)(val);
1549
+ encoders[exports.CODEC.OP_DELEGATION] = (val) => schemaEncoder(encoders)(DelegationSchema)(val);
1550
+ encoders[exports.CODEC.OP_TRANSACTION] = (val) => schemaEncoder(encoders)(TransactionSchema)(val);
1551
+ encoders[exports.CODEC.OP_ORIGINATION] = (val) => schemaEncoder(encoders)(OriginationSchema)(val);
1552
+ encoders[exports.CODEC.OP_BALLOT] = (val) => schemaEncoder(encoders)(BallotSchema)(val);
1553
+ encoders[exports.CODEC.OP_ATTESTATION] = (val) => schemaEncoder(encoders)(AttestationSchema)(val);
1554
+ encoders[exports.CODEC.OP_ATTESTATION_WITH_DAL] = (val) => schemaEncoder(encoders)(AttestationWithDalSchema)(val);
1555
+ encoders[exports.CODEC.OP_SEED_NONCE_REVELATION] = (val) => schemaEncoder(encoders)(SeedNonceRevelationSchema)(val);
1556
+ encoders[exports.CODEC.OP_PROPOSALS] = (val) => schemaEncoder(encoders)(ProposalsSchema)(val);
1557
+ encoders[exports.CODEC.OP_REVEAL] = (val) => schemaEncoder(encoders)(RevealSchema)(val);
1558
+ encoders[exports.CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaEncoder(encoders)(RegisterGlobalConstantSchema)(val);
1559
+ encoders[exports.CODEC.OP_TRANSFER_TICKET] = (val) => schemaEncoder(encoders)(TransferTicketSchema)(val);
1560
+ encoders[exports.CODEC.OP_INCREASE_PAID_STORAGE] = (val) => schemaEncoder(encoders)(IncreasePaidStorageSchema)(val);
1561
+ encoders[exports.CODEC.OP_UPDATE_CONSENSUS_KEY] = (val) => schemaEncoder(encoders)(UpdateConsensusKeySchema)(val);
1562
+ encoders[exports.CODEC.OP_UPDATE_COMPANION_KEY] = (val) => schemaEncoder(encoders)(UpdateCompanionKeySchema)(val);
1563
+ encoders[exports.CODEC.OP_DRAIN_DELEGATE] = (val) => schemaEncoder(encoders)(DrainDelegateSchema)(val);
1564
+ encoders[exports.CODEC.OP_SMART_ROLLUP_ORIGINATE] = (val) => schemaEncoder(encoders)(SmartRollupOriginateSchema)(val);
1565
+ encoders[exports.CODEC.OP_SMART_ROLLUP_ADD_MESSAGES] = (val) => schemaEncoder(encoders)(SmartRollupAddMessagesSchema)(val);
1566
+ encoders[exports.CODEC.OP_SMART_ROLLUP_EXECUTE_OUTBOX_MESSAGE] = (val) => schemaEncoder(encoders)(SmartRollupExecuteOutboxMessageSchema)(val);
1567
+ encoders[exports.CODEC.OP_DAL_PUBLISH_COMMITMENT] = (val) => schemaEncoder(encoders)(DalPublishCommitmentSchema)(val);
1568
+ encoders[exports.CODEC.MANAGER] = schemaEncoder(encoders)(ManagerOperationSchema);
1569
+ encoders[exports.CODEC.OP_SET_DEPOSITS_LIMIT] = (val) => schemaEncoder(encoders)(SetDepositsLimitSchema)(val);
1570
+ encoders[exports.CODEC.OP_FAILING_NOOP] = (val) => schemaEncoder(encoders)(FailingNoopSchema)(val);
1571
+
1572
+ const OperationKindMapping = {
1573
+ activate_account: ActivationSchema,
1574
+ reveal: RevealSchema,
1575
+ delegation: DelegationSchema,
1576
+ transaction: TransactionSchema,
1577
+ origination: OriginationSchema,
1578
+ ballot: BallotSchema,
1579
+ attestation: AttestationSchema,
1580
+ attestation_with_dal: AttestationWithDalSchema,
1581
+ seed_nonce_revelation: SeedNonceRevelationSchema,
1582
+ proposals: ProposalsSchema,
1583
+ register_global_constant: RegisterGlobalConstantSchema,
1584
+ transfer_ticket: TransferTicketSchema,
1585
+ increase_paid_storage: IncreasePaidStorageSchema,
1586
+ update_consensus_key: UpdateConsensusKeySchema,
1587
+ update_companion_key: UpdateCompanionKeySchema,
1588
+ drain_delegate: DrainDelegateSchema,
1589
+ set_deposits_limit: SetDepositsLimitSchema,
1590
+ smart_rollup_originate: SmartRollupOriginateSchema,
1591
+ smart_rollup_add_messages: SmartRollupAddMessagesSchema,
1592
+ smart_rollup_execute_outbox_message: SmartRollupExecuteOutboxMessageSchema,
1593
+ dal_publish_commitment: DalPublishCommitmentSchema,
1594
+ failing_noop: FailingNoopSchema,
1595
+ };
1596
+ // Asymmetric difference: only account for things in arr2 that are not present in arr1, not vice versa
1597
+ const getArrayDifference = (arr1, arr2) => {
1598
+ return arr2.filter((x) => !arr1.includes(x));
1599
+ };
1600
+ const deleteArrayElementByValue = (array, item) => {
1601
+ return array.filter((e) => e !== item);
1602
+ };
1603
+ /**
1604
+ * @returns A boolean value to indicate whether the operation kind is valid or not
2976
1605
  */
2977
1606
  const validateOperationKind = (opKind) => {
2978
1607
  const opKindList = Object.keys(OperationKindMapping);
@@ -3016,41 +1645,14 @@
3016
1645
  ProtocolsHash["PsQuebecn"] = "PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg";
3017
1646
  ProtocolsHash["PsRiotuma"] = "PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7";
3018
1647
  ProtocolsHash["PtSeouLou"] = "PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh";
1648
+ ProtocolsHash["PtTALLiNt"] = "PtTALLiNtPec7mE7yY4m3k26J8Qukef3E3ehzhfXgFZKGtDdAXu";
3019
1649
  ProtocolsHash["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
3020
1650
  })(exports.ProtocolsHash || (exports.ProtocolsHash = {}));
3021
- const protoLevel = {
3022
- Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd: 4,
3023
- PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU: 5,
3024
- PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS: 5,
3025
- PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb: 6,
3026
- PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo: 7,
3027
- PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA: 8,
3028
- PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i: 9,
3029
- PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV: 10,
3030
- PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx: 11,
3031
- Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A: 12,
3032
- PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY: 13,
3033
- PtKathmankSpLLDALzWw7CGD2j2MtyveTwboEYokqUCP4a1LxMg: 14,
3034
- PtLimaPtLMwfNinJi9rCfDPWea8dFgTZ1MeJ9f1m2SRic6ayiwW: 15,
3035
- PtMumbaiiFFEGbew1rRjzSPyzRbA51Tm3RVZL5suHPxSZYDhCEc: 16,
3036
- PtMumbai2TmsJHNGRkD8v8YDbtao7BLUC3wjASn1inAKLFCjaH1: 16,
3037
- PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf: 17,
3038
- ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH: 19,
3039
- PtParisBxoLz5gzMmn3d9WBQNoPSZakgnkMC2VNuQ3KXfUtUQeZ: 20,
3040
- PsParisCZo7KAh1Z1smVd9ZMZ1HHn5gkzbM94V3PLCpknFWhUAi: 20,
3041
- PsQuebecnLByd3JwTiGadoG4nGWi3HYiLXUjkibeFV8dCFeVMUg: 21,
3042
- PsRiotumaAMotcRoDWW1bysEhQy2n1M5fy8JgRp8jjRfHGmfeA7: 22,
3043
- PtSeouLouXkxhg39oWzjxDWaCydNfR3RxCUrNe4Q9Ro8BTehcbh: 23,
3044
- ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK: 23,
3045
- };
3046
- function ProtoInferiorTo(a, b) {
3047
- return protoLevel[a] < protoLevel[b];
3048
- }
3049
1651
 
3050
1652
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
3051
1653
  const VERSION = {
3052
- "commitHash": "42048d039f6d4345fc59d04b03650bcb8e27bb62",
3053
- "version": "23.0.3"
1654
+ "commitHash": "0e66f21b0164a7add990b5c0d60698086daece99",
1655
+ "version": "24.0.0-RC.0"
3054
1656
  };
3055
1657
 
3056
1658
  /**
@@ -3063,35 +1665,15 @@
3063
1665
  if (typeof globalThis.TextDecoder === 'undefined') {
3064
1666
  globalThis.TextDecoder = TextDecoder;
3065
1667
  }
3066
- const PROTOCOL_CURRENT = exports.ProtocolsHash.PtSeouLou;
1668
+ const PROTOCOL_CURRENT = exports.ProtocolsHash.PtTALLiNt;
3067
1669
  function getCodec(codec, _proto) {
3068
- // use encodersProto022 & decodersProto022 if it's rio or prior
3069
- if (_proto === exports.ProtocolsHash.PsRiotuma || ProtoInferiorTo(_proto, exports.ProtocolsHash.PsRiotuma)) {
3070
- return {
3071
- encoder: encoders[codec],
3072
- decoder: (hex) => {
3073
- const consumer = Uint8ArrayConsumer.fromHexString(hex);
3074
- return decoders[codec](consumer);
3075
- },
3076
- };
3077
- }
3078
- else {
3079
- return {
3080
- encoder: encoders$1[codec],
3081
- decoder: (hex) => {
3082
- const consumer = Uint8ArrayConsumer.fromHexString(hex);
3083
- return decoders$1[codec](consumer);
3084
- },
3085
- };
3086
- }
3087
- // TODO: Remove above if else once mainnet migrated into rio protocol and uncommon the return block below
3088
- // return {
3089
- // encoder: encoders[codec],
3090
- // decoder: (hex: string) => {
3091
- // const consumer = Uint8ArrayConsumer.fromHexString(hex);
3092
- // return decoders[codec](consumer) as any;
3093
- // },
3094
- // };
1670
+ return {
1671
+ encoder: encoders[codec],
1672
+ decoder: (hex) => {
1673
+ const consumer = Uint8ArrayConsumer.fromHexString(hex);
1674
+ return decoders[codec](consumer);
1675
+ },
1676
+ };
3095
1677
  }
3096
1678
  class LocalForger {
3097
1679
  constructor(protocolHash = PROTOCOL_CURRENT) {
@@ -3153,12 +1735,12 @@
3153
1735
  exports.LocalForger = LocalForger;
3154
1736
  exports.Uint8ArrayConsumer = Uint8ArrayConsumer;
3155
1737
  exports.VERSION = VERSION;
3156
- exports.decoders = decoders$1;
3157
- exports.encoders = encoders$1;
1738
+ exports.decoders = decoders;
1739
+ exports.encoders = encoders;
3158
1740
  exports.getCodec = getCodec;
3159
1741
  exports.localForger = localForger;
3160
- exports.opMapping = opMapping$1;
3161
- exports.opMappingReverse = opMappingReverse$1;
1742
+ exports.opMapping = opMapping;
1743
+ exports.opMappingReverse = opMappingReverse;
3162
1744
 
3163
1745
  }));
3164
1746
  //# sourceMappingURL=taquito-local-forging.umd.js.map