@taquito/michelson-encoder 23.0.2 → 23.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/lib/constants.js +11 -0
  2. package/dist/lib/michelson-map.js +8 -14
  3. package/dist/lib/schema/parameter.js +1 -8
  4. package/dist/lib/schema/storage.js +18 -25
  5. package/dist/lib/schema/view-schema.js +2 -2
  6. package/dist/lib/taquito-michelson-encoder.js +3 -2
  7. package/dist/lib/tokens/bigmap.js +0 -12
  8. package/dist/lib/tokens/bls12-381-fr.js +0 -7
  9. package/dist/lib/tokens/bls12-381-g1.js +0 -7
  10. package/dist/lib/tokens/bls12-381-g2.js +0 -7
  11. package/dist/lib/tokens/chain-id.js +0 -7
  12. package/dist/lib/tokens/chest-key.js +0 -7
  13. package/dist/lib/tokens/chest.js +0 -7
  14. package/dist/lib/tokens/comparable/address.js +0 -7
  15. package/dist/lib/tokens/comparable/bool.js +0 -7
  16. package/dist/lib/tokens/comparable/bytes.js +0 -7
  17. package/dist/lib/tokens/comparable/int.js +0 -7
  18. package/dist/lib/tokens/comparable/key_hash.js +0 -7
  19. package/dist/lib/tokens/comparable/mutez.js +0 -7
  20. package/dist/lib/tokens/comparable/nat.js +0 -7
  21. package/dist/lib/tokens/comparable/string.js +0 -7
  22. package/dist/lib/tokens/comparable/timestamp.js +0 -7
  23. package/dist/lib/tokens/constant.js +0 -7
  24. package/dist/lib/tokens/contract.js +0 -7
  25. package/dist/lib/tokens/key.js +10 -29
  26. package/dist/lib/tokens/lambda.js +0 -12
  27. package/dist/lib/tokens/list.js +0 -9
  28. package/dist/lib/tokens/map.js +0 -12
  29. package/dist/lib/tokens/never.js +0 -7
  30. package/dist/lib/tokens/operation.js +0 -7
  31. package/dist/lib/tokens/option.js +0 -7
  32. package/dist/lib/tokens/or.js +7 -13
  33. package/dist/lib/tokens/pair.js +3 -10
  34. package/dist/lib/tokens/sapling-state.js +0 -11
  35. package/dist/lib/tokens/sapling-transaction-deprecated.js +0 -11
  36. package/dist/lib/tokens/sapling-transaction.js +0 -11
  37. package/dist/lib/tokens/set.js +0 -7
  38. package/dist/lib/tokens/signature.js +0 -7
  39. package/dist/lib/tokens/ticket-deprecated.js +0 -11
  40. package/dist/lib/tokens/ticket.js +0 -11
  41. package/dist/lib/tokens/token.js +1 -1
  42. package/dist/lib/tokens/unit.js +3 -10
  43. package/dist/lib/version.js +2 -2
  44. package/dist/taquito-michelson-encoder.es6.js +63 -374
  45. package/dist/taquito-michelson-encoder.es6.js.map +1 -1
  46. package/dist/taquito-michelson-encoder.umd.js +65 -376
  47. package/dist/taquito-michelson-encoder.umd.js.map +1 -1
  48. package/dist/types/constants.d.ts +8 -0
  49. package/dist/types/schema/parameter.d.ts +1 -6
  50. package/dist/types/schema/storage.d.ts +8 -12
  51. package/dist/types/schema/view-schema.d.ts +2 -2
  52. package/dist/types/taquito-michelson-encoder.d.ts +1 -2
  53. package/dist/types/tokens/bigmap.d.ts +0 -10
  54. package/dist/types/tokens/bls12-381-fr.d.ts +0 -5
  55. package/dist/types/tokens/bls12-381-g1.d.ts +0 -5
  56. package/dist/types/tokens/bls12-381-g2.d.ts +0 -5
  57. package/dist/types/tokens/chain-id.d.ts +0 -5
  58. package/dist/types/tokens/chest-key.d.ts +0 -5
  59. package/dist/types/tokens/chest.d.ts +0 -5
  60. package/dist/types/tokens/comparable/address.d.ts +0 -5
  61. package/dist/types/tokens/comparable/bool.d.ts +0 -5
  62. package/dist/types/tokens/comparable/bytes.d.ts +0 -5
  63. package/dist/types/tokens/comparable/int.d.ts +0 -5
  64. package/dist/types/tokens/comparable/key_hash.d.ts +0 -5
  65. package/dist/types/tokens/comparable/mutez.d.ts +0 -5
  66. package/dist/types/tokens/comparable/nat.d.ts +0 -5
  67. package/dist/types/tokens/comparable/string.d.ts +0 -5
  68. package/dist/types/tokens/comparable/timestamp.d.ts +0 -5
  69. package/dist/types/tokens/constant.d.ts +0 -5
  70. package/dist/types/tokens/contract.d.ts +0 -5
  71. package/dist/types/tokens/key.d.ts +0 -6
  72. package/dist/types/tokens/lambda.d.ts +0 -10
  73. package/dist/types/tokens/list.d.ts +0 -7
  74. package/dist/types/tokens/map.d.ts +0 -10
  75. package/dist/types/tokens/never.d.ts +0 -5
  76. package/dist/types/tokens/operation.d.ts +0 -5
  77. package/dist/types/tokens/option.d.ts +1 -8
  78. package/dist/types/tokens/or.d.ts +0 -5
  79. package/dist/types/tokens/pair.d.ts +0 -5
  80. package/dist/types/tokens/sapling-state.d.ts +0 -9
  81. package/dist/types/tokens/sapling-transaction-deprecated.d.ts +0 -9
  82. package/dist/types/tokens/sapling-transaction.d.ts +0 -9
  83. package/dist/types/tokens/set.d.ts +0 -5
  84. package/dist/types/tokens/signature.d.ts +0 -5
  85. package/dist/types/tokens/ticket-deprecated.d.ts +0 -9
  86. package/dist/types/tokens/ticket.d.ts +0 -9
  87. package/dist/types/tokens/token.d.ts +1 -6
  88. package/dist/types/tokens/unit.d.ts +0 -5
  89. package/package.json +9 -8
@@ -1,8 +1,8 @@
1
1
  import stringify from 'fast-json-stable-stringify';
2
2
  import { TaquitoError, InvalidViewParameterError } from '@taquito/core';
3
3
  import BigNumber from 'bignumber.js';
4
- import { b58DecodeAddress, validateAddress, ValidationResult, encodeAddress, splitAddress, compareArrays, stripHexPrefix, encodeKey, validatePublicKey, b58DecodePublicKey, encodeKeyHash, validateKeyHash, b58DecodePublicKeyHash, validateSignature, validateChain } from '@taquito/utils';
5
- import elliptic from 'elliptic';
4
+ import { b58DecodeAddress, validateAddress, ValidationResult, encodeAddress, splitAddress, compareArrays, stripHexPrefix, encodeKey, validatePublicKey, encodeKeyHash, validateKeyHash, b58DecodePublicKeyHash, validateSignature, validateChain } from '@taquito/utils';
5
+ import { publicKeyFromString } from '@taquito/signer';
6
6
 
7
7
  var _a$1;
8
8
  /**
@@ -100,35 +100,29 @@ class MichelsonMap {
100
100
  if (!this.keySchema) {
101
101
  return;
102
102
  }
103
- this.keySchema.Typecheck(key);
103
+ if (!this.keySchema.Typecheck(key)) {
104
+ throw new MapTypecheckError(key, this.keySchema, 'key', 'Type validation failed');
105
+ }
104
106
  }
105
107
  typecheckValue(value) {
106
108
  if (!this.valueSchema) {
107
109
  return;
108
110
  }
109
- this.valueSchema.Typecheck(value);
111
+ if (!this.valueSchema.Typecheck(value)) {
112
+ throw new MapTypecheckError(value, this.valueSchema, 'value', 'Type validation failed');
113
+ }
110
114
  }
111
115
  /**
112
116
  * @throws {@link MapTypecheckError} when the argument passed does not match the expected schema for value
113
117
  */
114
118
  assertTypecheckValue(value) {
115
- try {
116
- this.typecheckValue(value);
117
- }
118
- catch (e) {
119
- throw new MapTypecheckError(value, this.valueSchema, 'value', e);
120
- }
119
+ this.typecheckValue(value);
121
120
  }
122
121
  /**
123
122
  * @throws {@link MapTypecheckError} when the argument passed does not match the expected schema for key
124
123
  */
125
124
  assertTypecheckKey(key) {
126
- try {
127
- this.typecheckKey(key);
128
- }
129
- catch (e) {
130
- throw new MapTypecheckError(key, this.keySchema, 'key', e);
131
- }
125
+ this.typecheckKey(key);
132
126
  }
133
127
  serializeDeterministically(key) {
134
128
  return stringify(key);
@@ -284,7 +278,7 @@ class Token {
284
278
  return this.val;
285
279
  }
286
280
  ExtractSignature() {
287
- return [[this.ExtractSchema()]];
281
+ return [[this.generateSchema()]];
288
282
  }
289
283
  }
290
284
  Token._fieldNumberingStrategy = 'Latest';
@@ -319,18 +313,6 @@ class BigMapToken extends Token {
319
313
  get KeySchema() {
320
314
  return this.createToken(this.val.args[0], 0);
321
315
  }
322
- /**
323
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
324
- *
325
- */
326
- ExtractSchema() {
327
- return {
328
- big_map: {
329
- key: this.KeySchema.ExtractSchema(),
330
- value: this.ValueSchema.ExtractSchema(),
331
- },
332
- };
333
- }
334
316
  generateSchema() {
335
317
  return {
336
318
  __michelsonType: BigMapToken.prim,
@@ -455,7 +437,7 @@ class OrToken extends ComparableToken {
455
437
  const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
456
438
  let keyCount = 1;
457
439
  if (leftToken instanceof OrToken) {
458
- keyCount = Object.keys(leftToken.ExtractSchema()).length;
440
+ keyCount = Object.keys(leftToken.generateSchema().schema).length;
459
441
  }
460
442
  const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
461
443
  if (String(leftToken.annot()) === String(label) && !(leftToken instanceof OrToken)) {
@@ -486,7 +468,7 @@ class OrToken extends ComparableToken {
486
468
  const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
487
469
  let keyCount = 1;
488
470
  if (leftToken instanceof OrToken) {
489
- keyCount = Object.keys(leftToken.ExtractSchema()).length;
471
+ keyCount = Object.keys(leftToken.generateSchema().schema).length;
490
472
  }
491
473
  const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
492
474
  const newSig = [];
@@ -517,7 +499,7 @@ class OrToken extends ComparableToken {
517
499
  const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
518
500
  let keyCount = 1;
519
501
  if (leftToken instanceof OrToken) {
520
- keyCount = Object.keys(leftToken.ExtractSchema()).length;
502
+ keyCount = Object.keys(leftToken.generateSchema().schema).length;
521
503
  }
522
504
  const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
523
505
  if (String(leftToken.annot()) === String(label) && !(leftToken instanceof OrToken)) {
@@ -560,7 +542,7 @@ class OrToken extends ComparableToken {
560
542
  const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
561
543
  let keyCount = 1;
562
544
  if (leftToken instanceof OrToken) {
563
- keyCount = Object.keys(leftToken.ExtractSchema()).length;
545
+ keyCount = Object.keys(leftToken.generateSchema().schema).length;
564
546
  }
565
547
  const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
566
548
  if (val.prim === 'Right') {
@@ -591,7 +573,7 @@ class OrToken extends ComparableToken {
591
573
  let leftValue;
592
574
  if (leftToken instanceof OrToken) {
593
575
  leftValue = getLeftValue(leftToken);
594
- keyCount = Object.keys(leftToken.ExtractSchema()).length;
576
+ keyCount = Object.keys(leftToken.generateSchema().schema).length;
595
577
  }
596
578
  else {
597
579
  leftValue = { [leftToken.annot()]: getLeftValue(leftToken) };
@@ -607,13 +589,6 @@ class OrToken extends ComparableToken {
607
589
  const res = concat(leftValue, rightValue);
608
590
  return res;
609
591
  }
610
- /**
611
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
612
- *
613
- */
614
- ExtractSchema() {
615
- return this.traversal((leftToken) => leftToken.ExtractSchema(), (rightToken) => rightToken.ExtractSchema(), (leftValue, rightValue) => (Object.assign(Object.assign({}, leftValue), rightValue)));
616
- }
617
592
  generateSchema() {
618
593
  return {
619
594
  __michelsonType: OrToken.prim,
@@ -638,7 +613,8 @@ class OrToken extends ComparableToken {
638
613
  const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
639
614
  let keyCount = 1;
640
615
  if (leftToken instanceof OrToken) {
641
- keyCount = Object.keys(leftToken.ExtractSchema()).length;
616
+ const schema = leftToken.generateSchema();
617
+ keyCount = Object.keys(schema.schema).length;
642
618
  }
643
619
  const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
644
620
  if (String(leftToken.annot()) === String(label) &&
@@ -779,7 +755,7 @@ class PairToken extends ComparableToken {
779
755
  return this.args().map((a) => {
780
756
  const tok = this.createToken(a, this.getIdxForChildren() + cnt, 'Pair');
781
757
  if (tok instanceof PairToken) {
782
- cnt += Object.keys(tok.ExtractSchema()).length;
758
+ cnt += Object.keys(tok.generateSchema()).length;
783
759
  }
784
760
  else {
785
761
  cnt++;
@@ -798,7 +774,7 @@ class PairToken extends ComparableToken {
798
774
  const leftToken = this.createToken(args[0], this.getIdxForChildren(), 'Pair');
799
775
  let keyCount = 1;
800
776
  if (leftToken instanceof OrToken) {
801
- keyCount = Object.keys(leftToken.ExtractSchema()).length;
777
+ keyCount = Object.keys(leftToken.generateSchema()).length;
802
778
  }
803
779
  const rightToken = this.createToken(args[1], this.getIdxForChildren() + keyCount, 'Pair');
804
780
  const newSig = [];
@@ -850,7 +826,7 @@ class PairToken extends ComparableToken {
850
826
  if (leftToken instanceof PairToken && !leftToken.hasAnnotations()) {
851
827
  leftValue = getLeftValue(leftToken);
852
828
  if (leftToken instanceof PairToken) {
853
- keyCount = Object.keys(leftToken.ExtractSchema()).length;
829
+ keyCount = Object.keys(leftToken.generateSchema()).length;
854
830
  }
855
831
  }
856
832
  else {
@@ -871,13 +847,6 @@ class PairToken extends ComparableToken {
871
847
  const args = collapse$1(val, 'Pair');
872
848
  return this.traversal((leftToken) => leftToken.Execute(args[0], semantics), (rightToken) => rightToken.Execute(args[1], semantics));
873
849
  }
874
- /**
875
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
876
- *
877
- */
878
- ExtractSchema() {
879
- return this.traversal((leftToken) => leftToken.ExtractSchema(), (rightToken) => rightToken.ExtractSchema());
880
- }
881
850
  generateSchema() {
882
851
  return {
883
852
  __michelsonType: PairToken.prim,
@@ -988,13 +957,6 @@ class NatToken extends ComparableToken {
988
957
  }
989
958
  return { int: new BigNumber(val).toFixed() };
990
959
  }
991
- /**
992
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
993
- *
994
- */
995
- ExtractSchema() {
996
- return NatToken.prim;
997
- }
998
960
  generateSchema() {
999
961
  return {
1000
962
  __michelsonType: NatToken.prim,
@@ -1037,13 +999,6 @@ class StringToken extends ComparableToken {
1037
999
  Execute(val) {
1038
1000
  return val[Object.keys(val)[0]];
1039
1001
  }
1040
- /**
1041
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
1042
- *
1043
- */
1044
- ExtractSchema() {
1045
- return StringToken.prim;
1046
- }
1047
1002
  generateSchema() {
1048
1003
  return {
1049
1004
  __michelsonType: StringToken.prim,
@@ -1145,13 +1100,6 @@ class AddressToken extends ComparableToken {
1145
1100
  }
1146
1101
  return encodeAddress(val.bytes);
1147
1102
  }
1148
- /**
1149
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
1150
- *
1151
- */
1152
- ExtractSchema() {
1153
- return AddressToken.prim;
1154
- }
1155
1103
  generateSchema() {
1156
1104
  return {
1157
1105
  __michelsonType: AddressToken.prim,
@@ -1281,18 +1229,6 @@ class MapToken extends Token {
1281
1229
  };
1282
1230
  });
1283
1231
  }
1284
- /**
1285
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
1286
- *
1287
- */
1288
- ExtractSchema() {
1289
- return {
1290
- map: {
1291
- key: this.KeySchema.ExtractSchema(),
1292
- value: this.ValueSchema.ExtractSchema(),
1293
- },
1294
- };
1295
- }
1296
1232
  generateSchema() {
1297
1233
  return {
1298
1234
  __michelsonType: MapToken.prim,
@@ -1333,13 +1269,6 @@ class BoolToken extends ComparableToken {
1333
1269
  }
1334
1270
  return { prim: val ? 'True' : 'False' };
1335
1271
  }
1336
- /**
1337
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
1338
- *
1339
- */
1340
- ExtractSchema() {
1341
- return BoolToken.prim;
1342
- }
1343
1272
  generateSchema() {
1344
1273
  return {
1345
1274
  __michelsonType: BoolToken.prim,
@@ -1437,13 +1366,6 @@ class ContractToken extends Token {
1437
1366
  }
1438
1367
  return { string: val };
1439
1368
  }
1440
- /**
1441
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
1442
- *
1443
- */
1444
- ExtractSchema() {
1445
- return ContractToken.prim;
1446
- }
1447
1369
  generateSchema() {
1448
1370
  const valueSchema = this.createToken(this.val.args[0], 0);
1449
1371
  return {
@@ -1526,15 +1448,6 @@ class ListToken extends Token {
1526
1448
  return [...prev, schema.EncodeObject(current)];
1527
1449
  }, []);
1528
1450
  }
1529
- /**
1530
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
1531
- *
1532
- */
1533
- ExtractSchema() {
1534
- return {
1535
- [ListToken.prim]: this.valueSchema.ExtractSchema(),
1536
- };
1537
- }
1538
1451
  generateSchema() {
1539
1452
  return {
1540
1453
  __michelsonType: ListToken.prim,
@@ -1573,13 +1486,6 @@ class MutezToken extends ComparableToken {
1573
1486
  Execute(val) {
1574
1487
  return new BigNumber(val[Object.keys(val)[0]]);
1575
1488
  }
1576
- /**
1577
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
1578
- *
1579
- */
1580
- ExtractSchema() {
1581
- return MutezToken.prim;
1582
- }
1583
1489
  generateSchema() {
1584
1490
  return {
1585
1491
  __michelsonType: MutezToken.prim,
@@ -1702,13 +1608,6 @@ class BytesToken extends ComparableToken {
1702
1608
  Execute(val) {
1703
1609
  return val.bytes;
1704
1610
  }
1705
- /**
1706
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
1707
- *
1708
- */
1709
- ExtractSchema() {
1710
- return BytesToken.prim;
1711
- }
1712
1611
  generateSchema() {
1713
1612
  return {
1714
1613
  __michelsonType: BytesToken.prim,
@@ -1774,13 +1673,6 @@ class OptionToken extends ComparableToken {
1774
1673
  }
1775
1674
  return { Some: this.schema().Execute(val.args[0], semantics) };
1776
1675
  }
1777
- /**
1778
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
1779
- *
1780
- */
1781
- ExtractSchema() {
1782
- return { Some: this.schema().ExtractSchema() };
1783
- }
1784
1676
  generateSchema() {
1785
1677
  return {
1786
1678
  __michelsonType: OptionToken.prim,
@@ -1859,13 +1751,6 @@ class TimestampToken extends ComparableToken {
1859
1751
  return { string: val };
1860
1752
  }
1861
1753
  }
1862
- /**
1863
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
1864
- *
1865
- */
1866
- ExtractSchema() {
1867
- return TimestampToken.prim;
1868
- }
1869
1754
  generateSchema() {
1870
1755
  return {
1871
1756
  __michelsonType: TimestampToken.prim,
@@ -1912,13 +1797,6 @@ class IntToken extends ComparableToken {
1912
1797
  Execute(val) {
1913
1798
  return new BigNumber(val[Object.keys(val)[0]]);
1914
1799
  }
1915
- /**
1916
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
1917
- *
1918
- */
1919
- ExtractSchema() {
1920
- return IntToken.prim;
1921
- }
1922
1800
  generateSchema() {
1923
1801
  return {
1924
1802
  __michelsonType: IntToken.prim,
@@ -1978,6 +1856,15 @@ class IntToken extends ComparableToken {
1978
1856
  }
1979
1857
  IntToken.prim = 'int';
1980
1858
 
1859
+ /**
1860
+ * Symbol representing Unit value in Michelson
1861
+ */
1862
+ const UnitValue = Symbol();
1863
+ /**
1864
+ * Sapling state placeholder value
1865
+ */
1866
+ const SaplingStateValue = {};
1867
+
1981
1868
  class UnitToken extends ComparableToken {
1982
1869
  constructor(val, idx, fac) {
1983
1870
  super(val, idx, fac);
@@ -1998,13 +1885,6 @@ class UnitToken extends ComparableToken {
1998
1885
  Execute(_val) {
1999
1886
  return UnitValue;
2000
1887
  }
2001
- /**
2002
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
2003
- *
2004
- */
2005
- ExtractSchema() {
2006
- return UnitToken.prim;
2007
- }
2008
1888
  generateSchema() {
2009
1889
  return {
2010
1890
  __michelsonType: UnitToken.prim,
@@ -2032,7 +1912,6 @@ class UnitToken extends ComparableToken {
2032
1912
  }
2033
1913
  UnitToken.prim = 'unit';
2034
1914
 
2035
- const ec = new elliptic.ec('p256');
2036
1915
  /**
2037
1916
  * @category Error
2038
1917
  * @description Error that indicates a failure happening when parsing encoding/executing a Key
@@ -2084,13 +1963,6 @@ class KeyToken extends ComparableToken {
2084
1963
  }
2085
1964
  return { string: val };
2086
1965
  }
2087
- /**
2088
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
2089
- *
2090
- */
2091
- ExtractSchema() {
2092
- return KeyToken.prim;
2093
- }
2094
1966
  generateSchema() {
2095
1967
  return {
2096
1968
  __michelsonType: KeyToken.prim,
@@ -2106,31 +1978,20 @@ class KeyToken extends ComparableToken {
2106
1978
  type: { prim: KeyToken.prim },
2107
1979
  };
2108
1980
  }
2109
- decompressP256PublicKey(compressedKey) {
2110
- const compressedArray = Array.from(compressedKey);
2111
- const keyPair = ec.keyFromPublic(compressedArray);
2112
- const publicKey = keyPair.getPublic();
2113
- const uncompressedArray = publicKey.encode('array', false);
2114
- return Buffer.concat([new Uint8Array([0x02]), new Uint8Array(uncompressedArray)]); // add back prefix 0x02
2115
- }
2116
1981
  compare(key1, key2) {
2117
- const bytes1 = b58DecodePublicKey(key1, 'array');
2118
- const bytes2 = b58DecodePublicKey(key2, 'array');
2119
- let array1;
2120
- let array2;
2121
- if (bytes1[0] === 0x02) {
2122
- array1 = this.decompressP256PublicKey(bytes1.slice(1)); // remove prefix 0x02
2123
- }
2124
- else {
2125
- array1 = bytes1;
2126
- }
2127
- if (bytes2[0] === 0x02) {
2128
- array2 = this.decompressP256PublicKey(bytes2.slice(1)); // remove prefix 0x02
1982
+ const publicKey1 = publicKeyFromString(key1);
1983
+ const publicKey2 = publicKeyFromString(key2);
1984
+ const bytes1 = publicKey1.toProtocol();
1985
+ const bytes2 = publicKey2.toProtocol();
1986
+ if (bytes1[0] === bytes2[0]) {
1987
+ return publicKey1.compare(publicKey2);
1988
+ }
1989
+ else if (bytes1[0] > bytes2[0]) {
1990
+ return 1;
2129
1991
  }
2130
1992
  else {
2131
- array2 = bytes2;
1993
+ return -1;
2132
1994
  }
2133
- return compareArrays(array1, array2);
2134
1995
  }
2135
1996
  findAndReturnTokens(tokenToFind, tokens) {
2136
1997
  if (KeyToken.prim === tokenToFind) {
@@ -2192,13 +2053,6 @@ class KeyHashToken extends ComparableToken {
2192
2053
  }
2193
2054
  return { string: val };
2194
2055
  }
2195
- /**
2196
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
2197
- *
2198
- */
2199
- ExtractSchema() {
2200
- return KeyHashToken.prim;
2201
- }
2202
2056
  generateSchema() {
2203
2057
  return {
2204
2058
  __michelsonType: KeyHashToken.prim,
@@ -2284,13 +2138,6 @@ class SignatureToken extends ComparableToken {
2284
2138
  }
2285
2139
  return { string: val };
2286
2140
  }
2287
- /**
2288
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
2289
- *
2290
- */
2291
- ExtractSchema() {
2292
- return SignatureToken.prim;
2293
- }
2294
2141
  generateSchema() {
2295
2142
  return {
2296
2143
  __michelsonType: SignatureToken.prim,
@@ -2346,18 +2193,6 @@ class LambdaToken extends Token {
2346
2193
  }
2347
2194
  return val;
2348
2195
  }
2349
- /**
2350
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
2351
- *
2352
- */
2353
- ExtractSchema() {
2354
- return {
2355
- [LambdaToken.prim]: {
2356
- parameters: this.paramSchema.ExtractSchema(),
2357
- returns: this.returnSchema.ExtractSchema(),
2358
- },
2359
- };
2360
- }
2361
2196
  generateSchema() {
2362
2197
  return {
2363
2198
  __michelsonType: LambdaToken.prim,
@@ -2398,13 +2233,6 @@ class OperationToken extends Token {
2398
2233
  }
2399
2234
  return { string: val };
2400
2235
  }
2401
- /**
2402
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
2403
- *
2404
- */
2405
- ExtractSchema() {
2406
- return OperationToken.prim;
2407
- }
2408
2236
  generateSchema() {
2409
2237
  return {
2410
2238
  __michelsonType: OperationToken.prim,
@@ -2481,13 +2309,6 @@ class SetToken extends Token {
2481
2309
  return [...prev, this.KeySchema.EncodeObject(current)];
2482
2310
  }, []);
2483
2311
  }
2484
- /**
2485
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
2486
- *
2487
- */
2488
- ExtractSchema() {
2489
- return SetToken.prim;
2490
- }
2491
2312
  generateSchema() {
2492
2313
  return {
2493
2314
  __michelsonType: SetToken.prim,
@@ -2534,13 +2355,6 @@ class ChainIDToken extends ComparableToken {
2534
2355
  Execute(val) {
2535
2356
  return val[Object.keys(val)[0]];
2536
2357
  }
2537
- /**
2538
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
2539
- *
2540
- */
2541
- ExtractSchema() {
2542
- return ChainIDToken.prim;
2543
- }
2544
2358
  generateSchema() {
2545
2359
  return {
2546
2360
  __michelsonType: ChainIDToken.prim,
@@ -2641,17 +2455,6 @@ class TicketToken extends Token {
2641
2455
  amount: amount.Execute(val.args[2], semantics),
2642
2456
  };
2643
2457
  }
2644
- /**
2645
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
2646
- *
2647
- */
2648
- ExtractSchema() {
2649
- return {
2650
- ticketer: ContractToken.prim,
2651
- value: this.valueToken.ExtractSchema(),
2652
- amount: IntToken.prim,
2653
- };
2654
- }
2655
2458
  generateSchema() {
2656
2459
  return {
2657
2460
  __michelsonType: TicketToken.prim,
@@ -2736,17 +2539,6 @@ class TicketDeprecatedToken extends Token {
2736
2539
  amount: amount.Execute(val.args[2], semantics),
2737
2540
  };
2738
2541
  }
2739
- /**
2740
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
2741
- *
2742
- */
2743
- ExtractSchema() {
2744
- return {
2745
- ticketer: ContractToken.prim,
2746
- value: this.valueToken.ExtractSchema(),
2747
- amount: IntToken.prim,
2748
- };
2749
- }
2750
2542
  generateSchema() {
2751
2543
  return {
2752
2544
  __michelsonType: TicketDeprecatedToken.prim,
@@ -2814,13 +2606,6 @@ class NeverToken extends Token {
2814
2606
  Execute(val) {
2815
2607
  throw new NeverTokenError(val, this, `There is no literal value for the type never. Trying to execute ${JSON.stringify(val)}.`);
2816
2608
  }
2817
- /**
2818
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
2819
- *
2820
- */
2821
- ExtractSchema() {
2822
- return NeverToken.prim;
2823
- }
2824
2609
  generateSchema() {
2825
2610
  return {
2826
2611
  __michelsonType: NeverToken.prim,
@@ -2898,17 +2683,6 @@ class SaplingStateToken extends Token {
2898
2683
  throw new SaplingStateValidationError(val, this, `Invalid sapling_state. Received: ${JSON.stringify(val)} while expecting: {}`);
2899
2684
  }
2900
2685
  }
2901
- /**
2902
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
2903
- *
2904
- */
2905
- ExtractSchema() {
2906
- return {
2907
- [SaplingStateToken.prim]: {
2908
- 'memo-size': Number(this.val.args[0]['int']),
2909
- },
2910
- };
2911
- }
2912
2686
  generateSchema() {
2913
2687
  return {
2914
2688
  __michelsonType: SaplingStateToken.prim,
@@ -2978,17 +2752,6 @@ class SaplingTransactionToken extends Token {
2978
2752
  }
2979
2753
  return { bytes: String(val).toString() };
2980
2754
  }
2981
- /**
2982
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
2983
- *
2984
- */
2985
- ExtractSchema() {
2986
- return {
2987
- [SaplingTransactionToken.prim]: {
2988
- 'memo-size': Number(this.val.args[0]['int']),
2989
- },
2990
- };
2991
- }
2992
2755
  generateSchema() {
2993
2756
  return {
2994
2757
  __michelsonType: SaplingTransactionToken.prim,
@@ -3058,17 +2821,6 @@ class SaplingTransactionDeprecatedToken extends Token {
3058
2821
  }
3059
2822
  return { bytes: String(val).toString() };
3060
2823
  }
3061
- /**
3062
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
3063
- *
3064
- */
3065
- ExtractSchema() {
3066
- return {
3067
- [SaplingTransactionDeprecatedToken.prim]: {
3068
- 'memo-size': Number(this.val.args[0]['int']),
3069
- },
3070
- };
3071
- }
3072
2824
  generateSchema() {
3073
2825
  return {
3074
2826
  __michelsonType: SaplingTransactionDeprecatedToken.prim,
@@ -3150,13 +2902,6 @@ class Bls12381frToken extends Token {
3150
2902
  Execute(val) {
3151
2903
  return val.bytes;
3152
2904
  }
3153
- /**
3154
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
3155
- *
3156
- */
3157
- ExtractSchema() {
3158
- return Bls12381frToken.prim;
3159
- }
3160
2905
  generateSchema() {
3161
2906
  return {
3162
2907
  __michelsonType: Bls12381frToken.prim,
@@ -3228,13 +2973,6 @@ class Bls12381g1Token extends Token {
3228
2973
  Execute(val) {
3229
2974
  return val.bytes;
3230
2975
  }
3231
- /**
3232
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
3233
- *
3234
- */
3235
- ExtractSchema() {
3236
- return Bls12381g1Token.prim;
3237
- }
3238
2976
  generateSchema() {
3239
2977
  return {
3240
2978
  __michelsonType: Bls12381g1Token.prim,
@@ -3306,13 +3044,6 @@ class Bls12381g2Token extends Token {
3306
3044
  Execute(val) {
3307
3045
  return val.bytes;
3308
3046
  }
3309
- /**
3310
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
3311
- *
3312
- */
3313
- ExtractSchema() {
3314
- return Bls12381g2Token.prim;
3315
- }
3316
3047
  generateSchema() {
3317
3048
  return {
3318
3049
  __michelsonType: Bls12381g2Token.prim,
@@ -3384,13 +3115,6 @@ class ChestToken extends Token {
3384
3115
  Execute(val) {
3385
3116
  return val.bytes;
3386
3117
  }
3387
- /**
3388
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
3389
- *
3390
- */
3391
- ExtractSchema() {
3392
- return ChestToken.prim;
3393
- }
3394
3118
  generateSchema() {
3395
3119
  return {
3396
3120
  __michelsonType: ChestToken.prim,
@@ -3460,13 +3184,6 @@ class ChestKeyToken extends Token {
3460
3184
  Execute(val) {
3461
3185
  return val.bytes;
3462
3186
  }
3463
- /**
3464
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
3465
- *
3466
- */
3467
- ExtractSchema() {
3468
- return ChestKeyToken.prim;
3469
- }
3470
3187
  generateSchema() {
3471
3188
  return {
3472
3189
  __michelsonType: ChestKeyToken.prim,
@@ -3539,13 +3256,6 @@ class GlobalConstantToken extends Token {
3539
3256
  }
3540
3257
  throw new GlobalConstantEncodingError(val, this, `Unable to encode a script containing global constants. Please provide an expanded script to the Michelson-Encoder. The following global constant hash was encountered: ${this.val.args[0]['string']}.`);
3541
3258
  }
3542
- /**
3543
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
3544
- *
3545
- */
3546
- ExtractSchema() {
3547
- return GlobalConstantToken.prim;
3548
- }
3549
3259
  generateSchema() {
3550
3260
  return {
3551
3261
  __michelsonType: GlobalConstantToken.prim,
@@ -3846,20 +3556,33 @@ class Schema {
3846
3556
  const storage = this.root.Execute(val, semantics);
3847
3557
  return this.removeTopLevelAnnotation(storage);
3848
3558
  }
3559
+ /**
3560
+ * @description Validates that a value matches the schema type.
3561
+ * Performs type checking with special handling for BigMap, Ticket, and nested Map tokens.
3562
+ *
3563
+ * @param val - The value to validate against the schema
3564
+ * @returns Returns true if validation passes, false if validation fails
3565
+ */
3849
3566
  Typecheck(val) {
3850
3567
  if (this.root instanceof BigMapToken && Number.isInteger(Number(val))) {
3851
- return;
3568
+ return true;
3852
3569
  }
3853
3570
  if (this.root instanceof TicketToken && val.ticketer && val.value && val.amount) {
3854
- return;
3571
+ return true;
3855
3572
  }
3856
3573
  if (this.root instanceof TicketDeprecatedToken && val.ticketer && val.value && val.amount) {
3857
- return;
3574
+ return true;
3858
3575
  }
3859
3576
  if (this.root instanceof MapToken && this.root.ValueSchema instanceof BigMapToken) {
3860
- return;
3577
+ return true;
3578
+ }
3579
+ try {
3580
+ this.root.EncodeObject(val);
3581
+ return true;
3582
+ }
3583
+ catch (error) {
3584
+ return false;
3861
3585
  }
3862
- this.root.EncodeObject(val);
3863
3586
  }
3864
3587
  /**
3865
3588
  * @throws {@link InvalidBigMapSchemaError}
@@ -3914,13 +3637,6 @@ class Schema {
3914
3637
  throw new StorageEncodingError('storage object', ex, this.root, value, semantics);
3915
3638
  }
3916
3639
  }
3917
- /**
3918
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
3919
- *
3920
- */
3921
- ExtractSchema() {
3922
- return this.removeTopLevelAnnotation(this.root.ExtractSchema());
3923
- }
3924
3640
  /**
3925
3641
  * @description Produce a representation of the storage schema.
3926
3642
  * Note: Provide guidance on how to write the storage object for the origination operation with Taquito.
@@ -3928,19 +3644,6 @@ class Schema {
3928
3644
  generateSchema() {
3929
3645
  return this.removeTopLevelAnnotation(this.root.generateSchema());
3930
3646
  }
3931
- /**
3932
- * @deprecated
3933
- * @throws {@link InvalidBigMapSchemaError}
3934
- */
3935
- ComputeState(tx, state) {
3936
- if (!this.bigMap) {
3937
- throw new InvalidBigMapSchemaError('Big map schema is undefined');
3938
- }
3939
- const bigMap = tx.reduce((prev, current) => {
3940
- return Object.assign(Object.assign({}, prev), this.ExecuteOnBigMapDiff(current.contents[0].metadata.operation_result.big_map_diff));
3941
- }, {});
3942
- return Object.assign(Object.assign({}, this.Execute(state)), { [this.bigMap.annot()]: bigMap });
3943
- }
3944
3647
  /**
3945
3648
  * @description Look up in top-level pairs of the storage to find a value matching the specified type
3946
3649
  *
@@ -4040,7 +3743,7 @@ class ParameterSchema {
4040
3743
  */
4041
3744
  get hasAnnotation() {
4042
3745
  if (this.isMultipleEntryPoint) {
4043
- return Object.keys(this.ExtractSchema())[0] !== '0';
3746
+ return Object.keys(this.generateSchema())[0] !== '0';
4044
3747
  }
4045
3748
  else {
4046
3749
  return true;
@@ -4091,13 +3794,6 @@ class ParameterSchema {
4091
3794
  throw new ParameterEncodingError('Unable to encode parameter object', this.root, value, ex);
4092
3795
  }
4093
3796
  }
4094
- /**
4095
- * @deprecated ExtractSchema has been deprecated in favor of generateSchema
4096
- *
4097
- */
4098
- ExtractSchema() {
4099
- return this.root.ExtractSchema();
4100
- }
4101
3797
  /**
4102
3798
  * @description Produce a schema grouping together all the entry points of a contract.
4103
3799
  */
@@ -4183,14 +3879,14 @@ class ViewSchema {
4183
3879
  * @description Return the signature of the view parameter
4184
3880
  */
4185
3881
  extractArgsSchema() {
4186
- return this.rootArgsType.ExtractSchema();
3882
+ return this.rootArgsType.generateSchema();
4187
3883
  }
4188
3884
  /**
4189
3885
  *
4190
3886
  * @description Return the format of the view result
4191
3887
  */
4192
3888
  extractResultSchema() {
4193
- return this.rootReturnType.ExtractSchema();
3889
+ return this.rootReturnType.generateSchema();
4194
3890
  }
4195
3891
  }
4196
3892
 
@@ -4245,16 +3941,9 @@ class EventSchema {
4245
3941
 
4246
3942
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
4247
3943
  const VERSION = {
4248
- "commitHash": "20b6624f217ec85f28023ca02b2d3b73777a8df9",
4249
- "version": "23.0.2"
3944
+ "commitHash": "c77fe4b0989665d8b5cfd15a7cc977499021f6fd",
3945
+ "version": "23.1.0"
4250
3946
  };
4251
3947
 
4252
- /**
4253
- * @packageDocumentation
4254
- * @module @taquito/michelson-encoder
4255
- */
4256
- const UnitValue = Symbol();
4257
- const SaplingStateValue = {};
4258
-
4259
3948
  export { AddressValidationError, BigMapEncodingError, BigMapValidationError, BytesValidationError, ChainIDValidationError, ContractValidationError, EncodeTicketError, EventSchema, IntValidationError, InvalidBigMapDiffError, InvalidBigMapSchemaError, InvalidMapTypeError, InvalidRpcResponseError, InvalidScriptError, KeyHashValidationError, KeyValidationError, ListValidationError, MapTypecheckError, MapValidationError, MichelsonMap, MissingArgumentError, MutezValidationError, NatValidationError, OrValidationError, ParameterEncodingError, ParameterSchema, SaplingStateValue, Schema, SetValidationError, SignatureValidationError, StorageEncodingError, Token, TokenArgumentValidationError, TokenComparisonError, UnitValue, VERSION, ViewSchema, deepEqual };
4260
3949
  //# sourceMappingURL=taquito-michelson-encoder.es6.js.map