@taquito/michelson-encoder 20.0.0-beta.0 → 20.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,14 +22,14 @@ exports.InvalidTokenError = InvalidTokenError;
22
22
  * @description Create a token from a value
23
23
  * @throws {@link InvalidTokenError} If the value passed is not supported by the Michelson Encoder
24
24
  */
25
- function createToken(val, idx) {
25
+ function createToken(val, idx, parentTokenType) {
26
26
  if (Array.isArray(val)) {
27
- return new pair_1.PairToken(val, idx, createToken);
27
+ return new pair_1.PairToken(val, idx, createToken, parentTokenType);
28
28
  }
29
29
  const t = tokens_1.tokens.find((x) => x.prim === val.prim);
30
30
  if (!t) {
31
31
  throw new InvalidTokenError(`Malformed data: ${JSON.stringify(val)}. Expected a value with a valid prim property`, val);
32
32
  }
33
- return new t(val, idx, createToken);
33
+ return new t(val, idx, createToken, parentTokenType);
34
34
  }
35
35
  exports.createToken = createToken;
@@ -16,20 +16,21 @@ class OrValidationError extends token_1.TokenValidationError {
16
16
  }
17
17
  exports.OrValidationError = OrValidationError;
18
18
  class OrToken extends token_1.ComparableToken {
19
- constructor(val, idx, fac) {
20
- super(val, idx, fac);
19
+ constructor(val, idx, fac, parentTokenType) {
20
+ super(val, idx, fac, parentTokenType);
21
21
  this.val = val;
22
22
  this.idx = idx;
23
23
  this.fac = fac;
24
+ this.parentTokenType = parentTokenType;
24
25
  }
25
26
  Encode(args) {
26
27
  const label = args[args.length - 1];
27
- const leftToken = this.createToken(this.val.args[0], this.idx);
28
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
28
29
  let keyCount = 1;
29
30
  if (leftToken instanceof OrToken) {
30
31
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
31
32
  }
32
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
33
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
33
34
  if (String(leftToken.annot()) === String(label) && !(leftToken instanceof OrToken)) {
34
35
  args.pop();
35
36
  return { prim: 'Left', args: [leftToken.Encode(args)] };
@@ -55,12 +56,12 @@ class OrToken extends token_1.ComparableToken {
55
56
  }
56
57
  }
57
58
  ExtractSignature() {
58
- const leftToken = this.createToken(this.val.args[0], this.idx);
59
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
59
60
  let keyCount = 1;
60
61
  if (leftToken instanceof OrToken) {
61
62
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
62
63
  }
63
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
64
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
64
65
  const newSig = [];
65
66
  if (leftToken instanceof OrToken) {
66
67
  newSig.push(...leftToken.ExtractSignature());
@@ -86,12 +87,12 @@ class OrToken extends token_1.ComparableToken {
86
87
  EncodeObject(args, semantic) {
87
88
  this.validateJavascriptObject(args);
88
89
  const label = Object.keys(args)[0];
89
- const leftToken = this.createToken(this.val.args[0], this.idx);
90
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
90
91
  let keyCount = 1;
91
92
  if (leftToken instanceof OrToken) {
92
93
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
93
94
  }
94
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
95
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
95
96
  if (String(leftToken.annot()) === String(label) && !(leftToken instanceof OrToken)) {
96
97
  return { prim: 'Left', args: [leftToken.EncodeObject(args[label], semantic)] };
97
98
  }
@@ -129,12 +130,12 @@ class OrToken extends token_1.ComparableToken {
129
130
  * @throws {@link OrValidationError}
130
131
  */
131
132
  Execute(val, semantics) {
132
- const leftToken = this.createToken(this.val.args[0], this.idx);
133
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
133
134
  let keyCount = 1;
134
135
  if (leftToken instanceof OrToken) {
135
136
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
136
137
  }
137
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
138
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
138
139
  if (val.prim === 'Right') {
139
140
  if (rightToken instanceof OrToken) {
140
141
  return rightToken.Execute(val.args[0], semantics);
@@ -158,7 +159,7 @@ class OrToken extends token_1.ComparableToken {
158
159
  }
159
160
  }
160
161
  traversal(getLeftValue, getRightValue, concat) {
161
- const leftToken = this.createToken(this.val.args[0], this.idx);
162
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
162
163
  let keyCount = 1;
163
164
  let leftValue;
164
165
  if (leftToken instanceof OrToken) {
@@ -168,7 +169,7 @@ class OrToken extends token_1.ComparableToken {
168
169
  else {
169
170
  leftValue = { [leftToken.annot()]: getLeftValue(leftToken) };
170
171
  }
171
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
172
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
172
173
  let rightValue;
173
174
  if (rightToken instanceof OrToken) {
174
175
  rightValue = getRightValue(rightToken);
@@ -207,12 +208,12 @@ class OrToken extends token_1.ComparableToken {
207
208
  };
208
209
  }
209
210
  findToken(label) {
210
- const leftToken = this.createToken(this.val.args[0], this.idx);
211
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
211
212
  let keyCount = 1;
212
213
  if (leftToken instanceof OrToken) {
213
214
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
214
215
  }
215
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
216
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
216
217
  if (String(leftToken.annot()) === String(label) &&
217
218
  !(leftToken instanceof OrToken) &&
218
219
  leftToken instanceof token_1.ComparableToken) {
@@ -270,6 +271,12 @@ class OrToken extends token_1.ComparableToken {
270
271
  this.traversal((leftToken) => leftToken.findAndReturnTokens(tokenToFind, tokens), (rightToken) => rightToken.findAndReturnTokens(tokenToFind, tokens), (leftValue, rightValue) => (Object.assign(Object.assign({}, leftValue), rightValue)));
271
272
  return tokens;
272
273
  }
274
+ getIdxForChildren() {
275
+ if (token_1.Token.fieldNumberingStrategy === 'Legacy') {
276
+ return this.idx;
277
+ }
278
+ return this.parentTokenType === 'Or' ? this.idx : 0;
279
+ }
273
280
  }
274
281
  exports.OrToken = OrToken;
275
282
  OrToken.prim = 'or';
@@ -56,7 +56,7 @@ function collapse(val, prim = PairToken.prim) {
56
56
  return [val.args[0], val.args[1]];
57
57
  }
58
58
  class PairToken extends token_1.ComparableToken {
59
- constructor(val, idx, fac) {
59
+ constructor(val, idx, fac, parentTokenType) {
60
60
  super(Array.isArray(val)
61
61
  ? {
62
62
  prim: PairToken.prim,
@@ -67,7 +67,7 @@ class PairToken extends token_1.ComparableToken {
67
67
  : {
68
68
  prim: PairToken.prim,
69
69
  args: val,
70
- }, idx, fac);
70
+ }, idx, fac, parentTokenType);
71
71
  }
72
72
  args() {
73
73
  // collapse comb pair
@@ -76,7 +76,7 @@ class PairToken extends token_1.ComparableToken {
76
76
  tokens() {
77
77
  let cnt = 0;
78
78
  return this.args().map((a) => {
79
- const tok = this.createToken(a, this.idx + cnt);
79
+ const tok = this.createToken(a, this.getIdxForChildren() + cnt, 'Pair');
80
80
  if (tok instanceof PairToken) {
81
81
  cnt += Object.keys(tok.ExtractSchema()).length;
82
82
  }
@@ -94,12 +94,12 @@ class PairToken extends token_1.ComparableToken {
94
94
  }
95
95
  ExtractSignature() {
96
96
  const args = this.args();
97
- const leftToken = this.createToken(args[0], this.idx);
97
+ const leftToken = this.createToken(args[0], this.getIdxForChildren(), 'Pair');
98
98
  let keyCount = 1;
99
99
  if (leftToken instanceof or_1.OrToken) {
100
100
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
101
101
  }
102
- const rightToken = this.createToken(args[1], this.idx + keyCount);
102
+ const rightToken = this.createToken(args[1], this.getIdxForChildren() + keyCount, 'Pair');
103
103
  const newSig = [];
104
104
  for (const leftSig of leftToken.ExtractSignature()) {
105
105
  for (const rightSig of rightToken.ExtractSignature()) {
@@ -143,7 +143,7 @@ class PairToken extends token_1.ComparableToken {
143
143
  }
144
144
  traversal(getLeftValue, getRightValue) {
145
145
  const args = this.args();
146
- const leftToken = this.createToken(args[0], this.idx);
146
+ const leftToken = this.createToken(args[0], this.getIdxForChildren(), 'Pair');
147
147
  let keyCount = 1;
148
148
  let leftValue;
149
149
  if (leftToken instanceof PairToken && !leftToken.hasAnnotations()) {
@@ -155,7 +155,7 @@ class PairToken extends token_1.ComparableToken {
155
155
  else {
156
156
  leftValue = { [leftToken.annot()]: getLeftValue(leftToken) };
157
157
  }
158
- const rightToken = this.createToken(args[1], this.idx + keyCount);
158
+ const rightToken = this.createToken(args[1], this.getIdxForChildren() + keyCount, 'Pair');
159
159
  let rightValue;
160
160
  if (rightToken instanceof PairToken && !rightToken.hasAnnotations()) {
161
161
  rightValue = getRightValue(rightToken);
@@ -226,6 +226,12 @@ class PairToken extends token_1.ComparableToken {
226
226
  this.tokens().map((t) => t.findAndReturnTokens(tokenToFind, tokens));
227
227
  return tokens;
228
228
  }
229
+ getIdxForChildren() {
230
+ if (token_1.Token.fieldNumberingStrategy === 'Legacy') {
231
+ return this.idx;
232
+ }
233
+ return this.parentTokenType === 'Pair' ? this.idx : 0;
234
+ }
229
235
  }
230
236
  exports.PairToken = PairToken;
231
237
  PairToken.prim = 'pair';
@@ -19,10 +19,23 @@ class TokenValidationError extends core_1.TaquitoError {
19
19
  }
20
20
  exports.TokenValidationError = TokenValidationError;
21
21
  class Token {
22
- constructor(val, idx, fac) {
22
+ /**
23
+ * @description Gets the strategy used for field numbering in Token execute/encode/decode to convert Michelson values to/from javascript objects, returns a value of type {@link FieldNumberingStrategy} that controls how field numbers are calculated
24
+ */
25
+ static get fieldNumberingStrategy() {
26
+ return Token._fieldNumberingStrategy;
27
+ }
28
+ /**
29
+ * @description Sets the strategy used for field numbering in Token execute/encode/decode to convert Michelson values to/from javascript objects, accepts a value of type {@link FieldNumberingStrategy} that controls how field numbers are calculated
30
+ */
31
+ static set fieldNumberingStrategy(value) {
32
+ Token._fieldNumberingStrategy = value;
33
+ }
34
+ constructor(val, idx, fac, parentTokenType) {
23
35
  this.val = val;
24
36
  this.idx = idx;
25
37
  this.fac = fac;
38
+ this.parentTokenType = parentTokenType;
26
39
  this.createToken = this.fac;
27
40
  }
28
41
  typeWithoutAnnotations() {
@@ -78,6 +91,7 @@ class Token {
78
91
  }
79
92
  }
80
93
  exports.Token = Token;
94
+ Token._fieldNumberingStrategy = 'Latest';
81
95
  class ComparableToken extends Token {
82
96
  compare(o1, o2) {
83
97
  if (o1 === o2) {
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
5
5
  exports.VERSION = {
6
- "commitHash": "0ef631853ccfda5c5faed584f16069f34085817e",
7
- "version": "20.0.0-beta.0"
6
+ "commitHash": "45fea4a361f29598063e448574800220c4687001",
7
+ "version": "20.0.0"
8
8
  };
@@ -215,10 +215,23 @@ class TokenValidationError extends TaquitoError {
215
215
  }
216
216
  }
217
217
  class Token {
218
- constructor(val, idx, fac) {
218
+ /**
219
+ * @description Gets the strategy used for field numbering in Token execute/encode/decode to convert Michelson values to/from javascript objects, returns a value of type {@link FieldNumberingStrategy} that controls how field numbers are calculated
220
+ */
221
+ static get fieldNumberingStrategy() {
222
+ return Token._fieldNumberingStrategy;
223
+ }
224
+ /**
225
+ * @description Sets the strategy used for field numbering in Token execute/encode/decode to convert Michelson values to/from javascript objects, accepts a value of type {@link FieldNumberingStrategy} that controls how field numbers are calculated
226
+ */
227
+ static set fieldNumberingStrategy(value) {
228
+ Token._fieldNumberingStrategy = value;
229
+ }
230
+ constructor(val, idx, fac, parentTokenType) {
219
231
  this.val = val;
220
232
  this.idx = idx;
221
233
  this.fac = fac;
234
+ this.parentTokenType = parentTokenType;
222
235
  this.createToken = this.fac;
223
236
  }
224
237
  typeWithoutAnnotations() {
@@ -273,6 +286,7 @@ class Token {
273
286
  return [[this.ExtractSchema()]];
274
287
  }
275
288
  }
289
+ Token._fieldNumberingStrategy = 'Latest';
276
290
  class ComparableToken extends Token {
277
291
  compare(o1, o2) {
278
292
  if (o1 === o2) {
@@ -431,20 +445,21 @@ class OrValidationError extends TokenValidationError {
431
445
  }
432
446
  }
433
447
  class OrToken extends ComparableToken {
434
- constructor(val, idx, fac) {
435
- super(val, idx, fac);
448
+ constructor(val, idx, fac, parentTokenType) {
449
+ super(val, idx, fac, parentTokenType);
436
450
  this.val = val;
437
451
  this.idx = idx;
438
452
  this.fac = fac;
453
+ this.parentTokenType = parentTokenType;
439
454
  }
440
455
  Encode(args) {
441
456
  const label = args[args.length - 1];
442
- const leftToken = this.createToken(this.val.args[0], this.idx);
457
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
443
458
  let keyCount = 1;
444
459
  if (leftToken instanceof OrToken) {
445
460
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
446
461
  }
447
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
462
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
448
463
  if (String(leftToken.annot()) === String(label) && !(leftToken instanceof OrToken)) {
449
464
  args.pop();
450
465
  return { prim: 'Left', args: [leftToken.Encode(args)] };
@@ -470,12 +485,12 @@ class OrToken extends ComparableToken {
470
485
  }
471
486
  }
472
487
  ExtractSignature() {
473
- const leftToken = this.createToken(this.val.args[0], this.idx);
488
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
474
489
  let keyCount = 1;
475
490
  if (leftToken instanceof OrToken) {
476
491
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
477
492
  }
478
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
493
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
479
494
  const newSig = [];
480
495
  if (leftToken instanceof OrToken) {
481
496
  newSig.push(...leftToken.ExtractSignature());
@@ -501,12 +516,12 @@ class OrToken extends ComparableToken {
501
516
  EncodeObject(args, semantic) {
502
517
  this.validateJavascriptObject(args);
503
518
  const label = Object.keys(args)[0];
504
- const leftToken = this.createToken(this.val.args[0], this.idx);
519
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
505
520
  let keyCount = 1;
506
521
  if (leftToken instanceof OrToken) {
507
522
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
508
523
  }
509
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
524
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
510
525
  if (String(leftToken.annot()) === String(label) && !(leftToken instanceof OrToken)) {
511
526
  return { prim: 'Left', args: [leftToken.EncodeObject(args[label], semantic)] };
512
527
  }
@@ -544,12 +559,12 @@ class OrToken extends ComparableToken {
544
559
  * @throws {@link OrValidationError}
545
560
  */
546
561
  Execute(val, semantics) {
547
- const leftToken = this.createToken(this.val.args[0], this.idx);
562
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
548
563
  let keyCount = 1;
549
564
  if (leftToken instanceof OrToken) {
550
565
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
551
566
  }
552
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
567
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
553
568
  if (val.prim === 'Right') {
554
569
  if (rightToken instanceof OrToken) {
555
570
  return rightToken.Execute(val.args[0], semantics);
@@ -573,7 +588,7 @@ class OrToken extends ComparableToken {
573
588
  }
574
589
  }
575
590
  traversal(getLeftValue, getRightValue, concat) {
576
- const leftToken = this.createToken(this.val.args[0], this.idx);
591
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
577
592
  let keyCount = 1;
578
593
  let leftValue;
579
594
  if (leftToken instanceof OrToken) {
@@ -583,7 +598,7 @@ class OrToken extends ComparableToken {
583
598
  else {
584
599
  leftValue = { [leftToken.annot()]: getLeftValue(leftToken) };
585
600
  }
586
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
601
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
587
602
  let rightValue;
588
603
  if (rightToken instanceof OrToken) {
589
604
  rightValue = getRightValue(rightToken);
@@ -622,12 +637,12 @@ class OrToken extends ComparableToken {
622
637
  };
623
638
  }
624
639
  findToken(label) {
625
- const leftToken = this.createToken(this.val.args[0], this.idx);
640
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
626
641
  let keyCount = 1;
627
642
  if (leftToken instanceof OrToken) {
628
643
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
629
644
  }
630
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
645
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
631
646
  if (String(leftToken.annot()) === String(label) &&
632
647
  !(leftToken instanceof OrToken) &&
633
648
  leftToken instanceof ComparableToken) {
@@ -685,6 +700,12 @@ class OrToken extends ComparableToken {
685
700
  this.traversal((leftToken) => leftToken.findAndReturnTokens(tokenToFind, tokens), (rightToken) => rightToken.findAndReturnTokens(tokenToFind, tokens), (leftValue, rightValue) => (Object.assign(Object.assign({}, leftValue), rightValue)));
686
701
  return tokens;
687
702
  }
703
+ getIdxForChildren() {
704
+ if (Token.fieldNumberingStrategy === 'Legacy') {
705
+ return this.idx;
706
+ }
707
+ return this.parentTokenType === 'Or' ? this.idx : 0;
708
+ }
688
709
  }
689
710
  OrToken.prim = 'or';
690
711
 
@@ -738,7 +759,7 @@ function collapse$1(val, prim = PairToken.prim) {
738
759
  return [val.args[0], val.args[1]];
739
760
  }
740
761
  class PairToken extends ComparableToken {
741
- constructor(val, idx, fac) {
762
+ constructor(val, idx, fac, parentTokenType) {
742
763
  super(Array.isArray(val)
743
764
  ? {
744
765
  prim: PairToken.prim,
@@ -749,7 +770,7 @@ class PairToken extends ComparableToken {
749
770
  : {
750
771
  prim: PairToken.prim,
751
772
  args: val,
752
- }, idx, fac);
773
+ }, idx, fac, parentTokenType);
753
774
  }
754
775
  args() {
755
776
  // collapse comb pair
@@ -758,7 +779,7 @@ class PairToken extends ComparableToken {
758
779
  tokens() {
759
780
  let cnt = 0;
760
781
  return this.args().map((a) => {
761
- const tok = this.createToken(a, this.idx + cnt);
782
+ const tok = this.createToken(a, this.getIdxForChildren() + cnt, 'Pair');
762
783
  if (tok instanceof PairToken) {
763
784
  cnt += Object.keys(tok.ExtractSchema()).length;
764
785
  }
@@ -776,12 +797,12 @@ class PairToken extends ComparableToken {
776
797
  }
777
798
  ExtractSignature() {
778
799
  const args = this.args();
779
- const leftToken = this.createToken(args[0], this.idx);
800
+ const leftToken = this.createToken(args[0], this.getIdxForChildren(), 'Pair');
780
801
  let keyCount = 1;
781
802
  if (leftToken instanceof OrToken) {
782
803
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
783
804
  }
784
- const rightToken = this.createToken(args[1], this.idx + keyCount);
805
+ const rightToken = this.createToken(args[1], this.getIdxForChildren() + keyCount, 'Pair');
785
806
  const newSig = [];
786
807
  for (const leftSig of leftToken.ExtractSignature()) {
787
808
  for (const rightSig of rightToken.ExtractSignature()) {
@@ -825,7 +846,7 @@ class PairToken extends ComparableToken {
825
846
  }
826
847
  traversal(getLeftValue, getRightValue) {
827
848
  const args = this.args();
828
- const leftToken = this.createToken(args[0], this.idx);
849
+ const leftToken = this.createToken(args[0], this.getIdxForChildren(), 'Pair');
829
850
  let keyCount = 1;
830
851
  let leftValue;
831
852
  if (leftToken instanceof PairToken && !leftToken.hasAnnotations()) {
@@ -837,7 +858,7 @@ class PairToken extends ComparableToken {
837
858
  else {
838
859
  leftValue = { [leftToken.annot()]: getLeftValue(leftToken) };
839
860
  }
840
- const rightToken = this.createToken(args[1], this.idx + keyCount);
861
+ const rightToken = this.createToken(args[1], this.getIdxForChildren() + keyCount, 'Pair');
841
862
  let rightValue;
842
863
  if (rightToken instanceof PairToken && !rightToken.hasAnnotations()) {
843
864
  rightValue = getRightValue(rightToken);
@@ -908,6 +929,12 @@ class PairToken extends ComparableToken {
908
929
  this.tokens().map((t) => t.findAndReturnTokens(tokenToFind, tokens));
909
930
  return tokens;
910
931
  }
932
+ getIdxForChildren() {
933
+ if (Token.fieldNumberingStrategy === 'Legacy') {
934
+ return this.idx;
935
+ }
936
+ return this.parentTokenType === 'Pair' ? this.idx : 0;
937
+ }
911
938
  }
912
939
  PairToken.prim = 'pair';
913
940
 
@@ -3578,15 +3605,15 @@ class InvalidTokenError extends TaquitoError {
3578
3605
  * @description Create a token from a value
3579
3606
  * @throws {@link InvalidTokenError} If the value passed is not supported by the Michelson Encoder
3580
3607
  */
3581
- function createToken(val, idx) {
3608
+ function createToken(val, idx, parentTokenType) {
3582
3609
  if (Array.isArray(val)) {
3583
- return new PairToken(val, idx, createToken);
3610
+ return new PairToken(val, idx, createToken, parentTokenType);
3584
3611
  }
3585
3612
  const t = tokens.find((x) => x.prim === val.prim);
3586
3613
  if (!t) {
3587
3614
  throw new InvalidTokenError(`Malformed data: ${JSON.stringify(val)}. Expected a value with a valid prim property`, val);
3588
3615
  }
3589
- return new t(val, idx, createToken);
3616
+ return new t(val, idx, createToken, parentTokenType);
3590
3617
  }
3591
3618
 
3592
3619
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -4205,8 +4232,8 @@ class EventSchema {
4205
4232
 
4206
4233
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
4207
4234
  const VERSION = {
4208
- "commitHash": "0ef631853ccfda5c5faed584f16069f34085817e",
4209
- "version": "20.0.0-beta.0"
4235
+ "commitHash": "45fea4a361f29598063e448574800220c4687001",
4236
+ "version": "20.0.0"
4210
4237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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -216,10 +216,23 @@
216
216
  }
217
217
  }
218
218
  class Token {
219
- constructor(val, idx, fac) {
219
+ /**
220
+ * @description Gets the strategy used for field numbering in Token execute/encode/decode to convert Michelson values to/from javascript objects, returns a value of type {@link FieldNumberingStrategy} that controls how field numbers are calculated
221
+ */
222
+ static get fieldNumberingStrategy() {
223
+ return Token._fieldNumberingStrategy;
224
+ }
225
+ /**
226
+ * @description Sets the strategy used for field numbering in Token execute/encode/decode to convert Michelson values to/from javascript objects, accepts a value of type {@link FieldNumberingStrategy} that controls how field numbers are calculated
227
+ */
228
+ static set fieldNumberingStrategy(value) {
229
+ Token._fieldNumberingStrategy = value;
230
+ }
231
+ constructor(val, idx, fac, parentTokenType) {
220
232
  this.val = val;
221
233
  this.idx = idx;
222
234
  this.fac = fac;
235
+ this.parentTokenType = parentTokenType;
223
236
  this.createToken = this.fac;
224
237
  }
225
238
  typeWithoutAnnotations() {
@@ -274,6 +287,7 @@
274
287
  return [[this.ExtractSchema()]];
275
288
  }
276
289
  }
290
+ Token._fieldNumberingStrategy = 'Latest';
277
291
  class ComparableToken extends Token {
278
292
  compare(o1, o2) {
279
293
  if (o1 === o2) {
@@ -432,20 +446,21 @@
432
446
  }
433
447
  }
434
448
  class OrToken extends ComparableToken {
435
- constructor(val, idx, fac) {
436
- super(val, idx, fac);
449
+ constructor(val, idx, fac, parentTokenType) {
450
+ super(val, idx, fac, parentTokenType);
437
451
  this.val = val;
438
452
  this.idx = idx;
439
453
  this.fac = fac;
454
+ this.parentTokenType = parentTokenType;
440
455
  }
441
456
  Encode(args) {
442
457
  const label = args[args.length - 1];
443
- const leftToken = this.createToken(this.val.args[0], this.idx);
458
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
444
459
  let keyCount = 1;
445
460
  if (leftToken instanceof OrToken) {
446
461
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
447
462
  }
448
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
463
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
449
464
  if (String(leftToken.annot()) === String(label) && !(leftToken instanceof OrToken)) {
450
465
  args.pop();
451
466
  return { prim: 'Left', args: [leftToken.Encode(args)] };
@@ -471,12 +486,12 @@
471
486
  }
472
487
  }
473
488
  ExtractSignature() {
474
- const leftToken = this.createToken(this.val.args[0], this.idx);
489
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
475
490
  let keyCount = 1;
476
491
  if (leftToken instanceof OrToken) {
477
492
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
478
493
  }
479
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
494
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
480
495
  const newSig = [];
481
496
  if (leftToken instanceof OrToken) {
482
497
  newSig.push(...leftToken.ExtractSignature());
@@ -502,12 +517,12 @@
502
517
  EncodeObject(args, semantic) {
503
518
  this.validateJavascriptObject(args);
504
519
  const label = Object.keys(args)[0];
505
- const leftToken = this.createToken(this.val.args[0], this.idx);
520
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
506
521
  let keyCount = 1;
507
522
  if (leftToken instanceof OrToken) {
508
523
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
509
524
  }
510
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
525
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
511
526
  if (String(leftToken.annot()) === String(label) && !(leftToken instanceof OrToken)) {
512
527
  return { prim: 'Left', args: [leftToken.EncodeObject(args[label], semantic)] };
513
528
  }
@@ -545,12 +560,12 @@
545
560
  * @throws {@link OrValidationError}
546
561
  */
547
562
  Execute(val, semantics) {
548
- const leftToken = this.createToken(this.val.args[0], this.idx);
563
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
549
564
  let keyCount = 1;
550
565
  if (leftToken instanceof OrToken) {
551
566
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
552
567
  }
553
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
568
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
554
569
  if (val.prim === 'Right') {
555
570
  if (rightToken instanceof OrToken) {
556
571
  return rightToken.Execute(val.args[0], semantics);
@@ -574,7 +589,7 @@
574
589
  }
575
590
  }
576
591
  traversal(getLeftValue, getRightValue, concat) {
577
- const leftToken = this.createToken(this.val.args[0], this.idx);
592
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
578
593
  let keyCount = 1;
579
594
  let leftValue;
580
595
  if (leftToken instanceof OrToken) {
@@ -584,7 +599,7 @@
584
599
  else {
585
600
  leftValue = { [leftToken.annot()]: getLeftValue(leftToken) };
586
601
  }
587
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
602
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
588
603
  let rightValue;
589
604
  if (rightToken instanceof OrToken) {
590
605
  rightValue = getRightValue(rightToken);
@@ -623,12 +638,12 @@
623
638
  };
624
639
  }
625
640
  findToken(label) {
626
- const leftToken = this.createToken(this.val.args[0], this.idx);
641
+ const leftToken = this.createToken(this.val.args[0], this.getIdxForChildren(), 'Or');
627
642
  let keyCount = 1;
628
643
  if (leftToken instanceof OrToken) {
629
644
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
630
645
  }
631
- const rightToken = this.createToken(this.val.args[1], this.idx + keyCount);
646
+ const rightToken = this.createToken(this.val.args[1], this.getIdxForChildren() + keyCount, 'Or');
632
647
  if (String(leftToken.annot()) === String(label) &&
633
648
  !(leftToken instanceof OrToken) &&
634
649
  leftToken instanceof ComparableToken) {
@@ -686,6 +701,12 @@
686
701
  this.traversal((leftToken) => leftToken.findAndReturnTokens(tokenToFind, tokens), (rightToken) => rightToken.findAndReturnTokens(tokenToFind, tokens), (leftValue, rightValue) => (Object.assign(Object.assign({}, leftValue), rightValue)));
687
702
  return tokens;
688
703
  }
704
+ getIdxForChildren() {
705
+ if (Token.fieldNumberingStrategy === 'Legacy') {
706
+ return this.idx;
707
+ }
708
+ return this.parentTokenType === 'Or' ? this.idx : 0;
709
+ }
689
710
  }
690
711
  OrToken.prim = 'or';
691
712
 
@@ -739,7 +760,7 @@
739
760
  return [val.args[0], val.args[1]];
740
761
  }
741
762
  class PairToken extends ComparableToken {
742
- constructor(val, idx, fac) {
763
+ constructor(val, idx, fac, parentTokenType) {
743
764
  super(Array.isArray(val)
744
765
  ? {
745
766
  prim: PairToken.prim,
@@ -750,7 +771,7 @@
750
771
  : {
751
772
  prim: PairToken.prim,
752
773
  args: val,
753
- }, idx, fac);
774
+ }, idx, fac, parentTokenType);
754
775
  }
755
776
  args() {
756
777
  // collapse comb pair
@@ -759,7 +780,7 @@
759
780
  tokens() {
760
781
  let cnt = 0;
761
782
  return this.args().map((a) => {
762
- const tok = this.createToken(a, this.idx + cnt);
783
+ const tok = this.createToken(a, this.getIdxForChildren() + cnt, 'Pair');
763
784
  if (tok instanceof PairToken) {
764
785
  cnt += Object.keys(tok.ExtractSchema()).length;
765
786
  }
@@ -777,12 +798,12 @@
777
798
  }
778
799
  ExtractSignature() {
779
800
  const args = this.args();
780
- const leftToken = this.createToken(args[0], this.idx);
801
+ const leftToken = this.createToken(args[0], this.getIdxForChildren(), 'Pair');
781
802
  let keyCount = 1;
782
803
  if (leftToken instanceof OrToken) {
783
804
  keyCount = Object.keys(leftToken.ExtractSchema()).length;
784
805
  }
785
- const rightToken = this.createToken(args[1], this.idx + keyCount);
806
+ const rightToken = this.createToken(args[1], this.getIdxForChildren() + keyCount, 'Pair');
786
807
  const newSig = [];
787
808
  for (const leftSig of leftToken.ExtractSignature()) {
788
809
  for (const rightSig of rightToken.ExtractSignature()) {
@@ -826,7 +847,7 @@
826
847
  }
827
848
  traversal(getLeftValue, getRightValue) {
828
849
  const args = this.args();
829
- const leftToken = this.createToken(args[0], this.idx);
850
+ const leftToken = this.createToken(args[0], this.getIdxForChildren(), 'Pair');
830
851
  let keyCount = 1;
831
852
  let leftValue;
832
853
  if (leftToken instanceof PairToken && !leftToken.hasAnnotations()) {
@@ -838,7 +859,7 @@
838
859
  else {
839
860
  leftValue = { [leftToken.annot()]: getLeftValue(leftToken) };
840
861
  }
841
- const rightToken = this.createToken(args[1], this.idx + keyCount);
862
+ const rightToken = this.createToken(args[1], this.getIdxForChildren() + keyCount, 'Pair');
842
863
  let rightValue;
843
864
  if (rightToken instanceof PairToken && !rightToken.hasAnnotations()) {
844
865
  rightValue = getRightValue(rightToken);
@@ -909,6 +930,12 @@
909
930
  this.tokens().map((t) => t.findAndReturnTokens(tokenToFind, tokens));
910
931
  return tokens;
911
932
  }
933
+ getIdxForChildren() {
934
+ if (Token.fieldNumberingStrategy === 'Legacy') {
935
+ return this.idx;
936
+ }
937
+ return this.parentTokenType === 'Pair' ? this.idx : 0;
938
+ }
912
939
  }
913
940
  PairToken.prim = 'pair';
914
941
 
@@ -3579,15 +3606,15 @@
3579
3606
  * @description Create a token from a value
3580
3607
  * @throws {@link InvalidTokenError} If the value passed is not supported by the Michelson Encoder
3581
3608
  */
3582
- function createToken(val, idx) {
3609
+ function createToken(val, idx, parentTokenType) {
3583
3610
  if (Array.isArray(val)) {
3584
- return new PairToken(val, idx, createToken);
3611
+ return new PairToken(val, idx, createToken, parentTokenType);
3585
3612
  }
3586
3613
  const t = tokens.find((x) => x.prim === val.prim);
3587
3614
  if (!t) {
3588
3615
  throw new InvalidTokenError(`Malformed data: ${JSON.stringify(val)}. Expected a value with a valid prim property`, val);
3589
3616
  }
3590
- return new t(val, idx, createToken);
3617
+ return new t(val, idx, createToken, parentTokenType);
3591
3618
  }
3592
3619
 
3593
3620
  /* eslint-disable @typescript-eslint/no-explicit-any */
@@ -4206,8 +4233,8 @@
4206
4233
 
4207
4234
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
4208
4235
  const VERSION = {
4209
- "commitHash": "0ef631853ccfda5c5faed584f16069f34085817e",
4210
- "version": "20.0.0-beta.0"
4236
+ "commitHash": "45fea4a361f29598063e448574800220c4687001",
4237
+ "version": "20.0.0"
4211
4238
  };
4212
4239
 
4213
4240
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-michelson-encoder.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -14,4 +14,4 @@ export declare const UnitValue: unique symbol;
14
14
  export declare const SaplingStateValue: {};
15
15
  export * from './michelson-map';
16
16
  export { VERSION } from './version';
17
- export { Token } from './tokens/token';
17
+ export { FieldNumberingStrategy, Token } from './tokens/token';
@@ -15,4 +15,4 @@ export declare class InvalidTokenError extends TaquitoError {
15
15
  * @description Create a token from a value
16
16
  * @throws {@link InvalidTokenError} If the value passed is not supported by the Michelson Encoder
17
17
  */
18
- export declare function createToken(val: any, idx: number): Token;
18
+ export declare function createToken(val: any, idx: number, parentTokenType?: 'Or' | 'Pair' | 'Other' | undefined): Token;
@@ -18,12 +18,13 @@ export declare class OrToken extends ComparableToken {
18
18
  };
19
19
  protected idx: number;
20
20
  protected fac: TokenFactory;
21
+ protected parentTokenType?: "Or" | "Pair" | "Other" | undefined;
21
22
  static prim: 'or';
22
23
  constructor(val: {
23
24
  prim: string;
24
25
  args: any[];
25
26
  annots: any[];
26
- }, idx: number, fac: TokenFactory);
27
+ }, idx: number, fac: TokenFactory, parentTokenType?: "Or" | "Pair" | "Other" | undefined);
27
28
  Encode(args: any[]): any;
28
29
  ExtractSignature(): any;
29
30
  /**
@@ -53,4 +54,5 @@ export declare class OrToken extends ComparableToken {
53
54
  type: Omit<import("@taquito/rpc").MichelsonV1ExpressionExtended, "annots">;
54
55
  };
55
56
  findAndReturnTokens(tokenToFind: string, tokens: Token[]): Token[];
57
+ protected getIdxForChildren(): number;
56
58
  }
@@ -23,7 +23,7 @@ export declare class TokenComparisonError extends TaquitoError {
23
23
  }
24
24
  export declare class PairToken extends ComparableToken {
25
25
  static prim: 'pair';
26
- constructor(val: MichelsonV1Expression, idx: number, fac: TokenFactory);
26
+ constructor(val: MichelsonV1Expression, idx: number, fac: TokenFactory, parentTokenType?: 'Or' | 'Pair' | 'Other' | undefined);
27
27
  private args;
28
28
  private tokens;
29
29
  Encode(args: any[]): any;
@@ -51,4 +51,5 @@ export declare class PairToken extends ComparableToken {
51
51
  */
52
52
  compare(val1: any, val2: any): number;
53
53
  findAndReturnTokens(tokenToFind: string, tokens: Token[]): Token[];
54
+ protected getIdxForChildren(): number;
54
55
  }
@@ -11,18 +11,35 @@ export declare abstract class TokenValidationError extends TaquitoError {
11
11
  name: string;
12
12
  constructor(value: any, token: Token, baseMessage: string);
13
13
  }
14
- export type TokenFactory = (val: any, idx: number) => Token;
14
+ export type TokenFactory = (val: any, idx: number, parentTokenType?: 'Or' | 'Pair' | 'Other') => Token;
15
15
  export interface Semantic {
16
16
  [key: string]: (value: MichelsonV1Expression, schema: MichelsonV1Expression) => any;
17
17
  }
18
18
  export interface SemanticEncoding {
19
19
  [key: string]: (value: any, type?: MichelsonV1Expression) => MichelsonV1Expression;
20
20
  }
21
+ /**
22
+ * @description Possible strategies for mapping between javascript classes and Michelson values
23
+ * Legacy: The old behaviour: { annot1: 'some value', annot2: 'other Value', annot3: { 2: 'yet another value', 3: 'also some value' }}
24
+ * ResetFieldNumbersInNestedObjects: { annot1: 'some value', annot2: 'other Value', annot3: { 0: 'yet another value', 1: 'also some value' }}
25
+ * Latest: This will include new changes as we might implement in the future. This is the suggested value if it does not break your code
26
+ */
27
+ export type FieldNumberingStrategy = 'Legacy' | 'ResetFieldNumbersInNestedObjects' | 'Latest';
21
28
  export declare abstract class Token {
22
29
  protected val: MichelsonV1ExpressionExtended;
23
30
  protected idx: number;
24
31
  protected fac: TokenFactory;
25
- constructor(val: MichelsonV1ExpressionExtended, idx: number, fac: TokenFactory);
32
+ protected parentTokenType?: "Or" | "Pair" | "Other" | undefined;
33
+ private static _fieldNumberingStrategy;
34
+ /**
35
+ * @description Gets the strategy used for field numbering in Token execute/encode/decode to convert Michelson values to/from javascript objects, returns a value of type {@link FieldNumberingStrategy} that controls how field numbers are calculated
36
+ */
37
+ static get fieldNumberingStrategy(): FieldNumberingStrategy;
38
+ /**
39
+ * @description Sets the strategy used for field numbering in Token execute/encode/decode to convert Michelson values to/from javascript objects, accepts a value of type {@link FieldNumberingStrategy} that controls how field numbers are calculated
40
+ */
41
+ static set fieldNumberingStrategy(value: FieldNumberingStrategy);
42
+ constructor(val: MichelsonV1ExpressionExtended, idx: number, fac: TokenFactory, parentTokenType?: "Or" | "Pair" | "Other" | undefined);
26
43
  protected typeWithoutAnnotations(): Omit<MichelsonV1ExpressionExtended, "annots">;
27
44
  annot(): string;
28
45
  hasAnnotations(): number | false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taquito/michelson-encoder",
3
- "version": "20.0.0-beta.0",
3
+ "version": "20.0.0",
4
4
  "description": "converts michelson data and types into convenient JS/TS objects",
5
5
  "keywords": [
6
6
  "tezos",
@@ -67,9 +67,9 @@
67
67
  ]
68
68
  },
69
69
  "dependencies": {
70
- "@taquito/core": "^20.0.0-beta.0",
71
- "@taquito/rpc": "^20.0.0-beta.0",
72
- "@taquito/utils": "^20.0.0-beta.0",
70
+ "@taquito/core": "^20.0.0",
71
+ "@taquito/rpc": "^20.0.0",
72
+ "@taquito/utils": "^20.0.0",
73
73
  "bignumber.js": "^9.1.2",
74
74
  "fast-json-stable-stringify": "^2.1.0"
75
75
  },
@@ -100,5 +100,5 @@
100
100
  "ts-toolbelt": "^9.6.0",
101
101
  "typescript": "~5.2.2"
102
102
  },
103
- "gitHead": "88980709574468fad5e4e7d63d34e1d71accf550"
103
+ "gitHead": "4871f03155be8dfce81ff24cb45fe0e3049c7646"
104
104
  }