@taquito/local-forging 12.0.2 → 12.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 (50) hide show
  1. package/dist/lib/codec.js +10 -9
  2. package/dist/lib/codec.js.map +1 -1
  3. package/dist/lib/constants.js +2 -15
  4. package/dist/lib/constants.js.map +1 -1
  5. package/dist/lib/error.js +101 -5
  6. package/dist/lib/error.js.map +1 -1
  7. package/dist/lib/michelson/codec.js +6 -4
  8. package/dist/lib/michelson/codec.js.map +1 -1
  9. package/dist/lib/proto12-ithaca/constants.js.map +1 -1
  10. package/dist/lib/proto12-ithaca/decoder.js +1 -1
  11. package/dist/lib/proto12-ithaca/decoder.js.map +1 -1
  12. package/dist/lib/proto12-ithaca/encoder.js +1 -1
  13. package/dist/lib/proto12-ithaca/encoder.js.map +1 -1
  14. package/dist/lib/proto12-ithaca/schema.js +8 -8
  15. package/dist/lib/proto12-ithaca/schema.js.map +1 -1
  16. package/dist/lib/proto13-jakarta/codec-proto13.js +60 -0
  17. package/dist/lib/proto13-jakarta/codec-proto13.js.map +1 -0
  18. package/dist/lib/proto13-jakarta/constants-proto13.js +13 -0
  19. package/dist/lib/proto13-jakarta/constants-proto13.js.map +1 -0
  20. package/dist/lib/proto13-jakarta/decoder-proto13.js +23 -0
  21. package/dist/lib/proto13-jakarta/decoder-proto13.js.map +1 -0
  22. package/dist/lib/proto13-jakarta/encoder-proto13.js +23 -0
  23. package/dist/lib/proto13-jakarta/encoder-proto13.js.map +1 -0
  24. package/dist/lib/proto13-jakarta/michelson-proto13/codec-proto13.js +150 -0
  25. package/dist/lib/proto13-jakarta/michelson-proto13/codec-proto13.js.map +1 -0
  26. package/dist/lib/protocols.js +35 -0
  27. package/dist/lib/protocols.js.map +1 -0
  28. package/dist/lib/schema/operation.js +10 -10
  29. package/dist/lib/schema/operation.js.map +1 -1
  30. package/dist/lib/taquito-local-forging.js +20 -6
  31. package/dist/lib/taquito-local-forging.js.map +1 -1
  32. package/dist/lib/uint8array-consumer.js +3 -2
  33. package/dist/lib/uint8array-consumer.js.map +1 -1
  34. package/dist/lib/version.js +2 -2
  35. package/dist/taquito-local-forging.es6.js +406 -78
  36. package/dist/taquito-local-forging.es6.js.map +1 -1
  37. package/dist/taquito-local-forging.umd.js +405 -77
  38. package/dist/taquito-local-forging.umd.js.map +1 -1
  39. package/dist/types/constants.d.ts +2 -14
  40. package/dist/types/error.d.ts +76 -2
  41. package/dist/types/michelson/codec.d.ts +5 -5
  42. package/dist/types/proto12-ithaca/constants.d.ts +0 -3
  43. package/dist/types/proto13-jakarta/codec-proto13.d.ts +13 -0
  44. package/dist/types/proto13-jakarta/constants-proto13.d.ts +6 -0
  45. package/dist/types/proto13-jakarta/decoder-proto13.d.ts +4 -0
  46. package/dist/types/proto13-jakarta/encoder-proto13.d.ts +4 -0
  47. package/dist/types/proto13-jakarta/michelson-proto13/codec-proto13.d.ts +15 -0
  48. package/dist/types/protocols.d.ts +14 -0
  49. package/dist/types/taquito-local-forging.d.ts +4 -2
  50. package/package.json +4 -4
@@ -50,6 +50,7 @@
50
50
  CODEC["OP_REGISTER_GLOBAL_CONSTANT"] = "register_global_constant";
51
51
  CODEC["VALUE"] = "value";
52
52
  CODEC["MANAGER"] = "manager";
53
+ CODEC["BLOCK_PAYLOAD_HASH"] = "blockPayloadHash";
53
54
  })(exports.CODEC || (exports.CODEC = {}));
54
55
  // See https://tezos.gitlab.io/whitedoc/michelson.html#full-grammar
55
56
  const opMapping = {
@@ -244,21 +245,117 @@
244
245
  result[entrypointMapping[key]] = key;
245
246
  });
246
247
  return result;
247
- })();
248
- exports.ProtocolsHash = void 0;
249
- (function (ProtocolsHash) {
250
- ProtocolsHash["Pt24m4xi"] = "Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd";
251
- ProtocolsHash["PsBABY5H"] = "PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU";
252
- ProtocolsHash["PsBabyM1"] = "PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS";
253
- ProtocolsHash["PsCARTHA"] = "PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb";
254
- ProtocolsHash["PsDELPH1"] = "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo";
255
- ProtocolsHash["PtEdo2Zk"] = "PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA";
256
- ProtocolsHash["PsFLorena"] = "PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i";
257
- ProtocolsHash["PtGRANADs"] = "PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV";
258
- ProtocolsHash["PtHangz2"] = "PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx";
259
- ProtocolsHash["PsiThaCa"] = "PsiThaCaT47Zboaw71QWScM8sXeMM7bbQFncK9FLqYc6EKdpjVP";
260
- ProtocolsHash["Psithaca2"] = "Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A";
261
- })(exports.ProtocolsHash || (exports.ProtocolsHash = {}));
248
+ })();
249
+
250
+ /**
251
+ * @category Error
252
+ * @description Error that indicates an invalid block hash being passed or used
253
+ */
254
+ class InvalidBlockHashError extends Error {
255
+ constructor(message) {
256
+ super(message);
257
+ this.message = message;
258
+ this.name = 'InvalidBlockHashError';
259
+ }
260
+ }
261
+ /**
262
+ * @category Error
263
+ * @description Error that indicates an invalid operation schema being passed or used
264
+ */ class InvalidOperationSchemaError extends Error {
265
+ constructor(message) {
266
+ super(message);
267
+ this.message = message;
268
+ this.name = 'InvalidOperationSchemaError';
269
+ }
270
+ }
271
+ /**
272
+ * @category Error
273
+ * @description Error that indicates an entrypoint exceeding maximum size
274
+ */
275
+ class OversizedEntryPointError extends Error {
276
+ constructor(entrypoint) {
277
+ super(`Oversized entrypoint: ${entrypoint}. The maximum length of entrypoint is ${ENTRYPOINT_MAX_LENGTH}`);
278
+ this.entrypoint = entrypoint;
279
+ this.name = 'OversizedEntryPointError';
280
+ }
281
+ }
282
+ /**
283
+ * @category Error
284
+ * @description Error that indicates an invalid ballot value
285
+ */
286
+ class InvalidBallotValueError extends Error {
287
+ constructor(ballotValue) {
288
+ super(`The ballot value '${ballotValue}' is invalid`);
289
+ this.ballotValue = ballotValue;
290
+ this.name = 'InvalidBallotValueError';
291
+ }
292
+ }
293
+ /**
294
+ * @category Error
295
+ * @description Error that indicates a failure when trying to decode ballot value
296
+ */
297
+ class DecodeBallotValueError extends Error {
298
+ constructor(ballotValue) {
299
+ super(`Failed to decode ballot value ${ballotValue}`);
300
+ this.ballotValue = ballotValue;
301
+ this.name = 'DecodeBallotValueError';
302
+ }
303
+ }
304
+ /**
305
+ * @category Error
306
+ * @description Error that indicates an invalid hex string have been passed or used
307
+ */
308
+ class InvalidHexStringError extends Error {
309
+ constructor(hexString) {
310
+ super(`The hex string '${hexString}' is invalid`);
311
+ this.hexString = hexString;
312
+ this.name = 'InvalidHexStringError';
313
+ }
314
+ }
315
+ /**
316
+ * @category Error
317
+ * @description Error that indicates unexpected Michelson Value being passed or used
318
+ */
319
+ class UnexpectedMichelsonValueError extends Error {
320
+ constructor(value) {
321
+ super(`Failed to encode michelson value '${value}'`);
322
+ this.value = value;
323
+ this.name = 'UnexpectedMichelsonValueError';
324
+ }
325
+ }
326
+ /**
327
+ * @category Error
328
+ * @description Error that indicates a failure when trying to decode an operation
329
+ */
330
+ class OperationDecodingError extends Error {
331
+ constructor(message) {
332
+ super(message);
333
+ this.message = message;
334
+ this.name = 'OperationDecodingError';
335
+ }
336
+ }
337
+ /**
338
+ * @category Error
339
+ * @description Error that indicates a failure when trying to encode an operation
340
+ */
341
+ class OperationEncodingError extends Error {
342
+ constructor(message) {
343
+ super(message);
344
+ this.message = message;
345
+ this.name = 'OperationEncodingError';
346
+ }
347
+ }
348
+ /**
349
+ * @category Error
350
+ * @description Error that indicates an unsupported operation being passed or used
351
+ */
352
+ class UnsupportedOperationError extends Error {
353
+ constructor(op) {
354
+ super(`The operation '${op}' is unsupported`);
355
+ this.op = op;
356
+ this.name = 'UnsupportedOperationError';
357
+ }
358
+ }
262
359
 
263
360
  class Uint8ArrayConsumer {
264
361
  constructor(arr, offset = 0) {
@@ -268,11 +365,11 @@
268
365
  static fromHexString(hex) {
269
366
  const lowHex = hex.toLowerCase();
270
367
  if (/^(([a-f]|\d){2})*$/.test(lowHex)) {
271
- const arr = new Uint8Array((lowHex.match(/([a-z]|\d){2}/g) || []).map(byte => parseInt(byte, 16)));
368
+ const arr = new Uint8Array((lowHex.match(/([a-z]|\d){2}/g) || []).map((byte) => parseInt(byte, 16)));
272
369
  return new Uint8ArrayConsumer(arr);
273
370
  }
274
371
  else {
275
- throw new Error('Invalid hex string');
372
+ throw new InvalidHexStringError(lowHex);
276
373
  }
277
374
  }
278
375
  consume(count) {
@@ -331,7 +428,7 @@
331
428
  else if (isInt(value)) {
332
429
  return intEncoder(value);
333
430
  }
334
- throw new Error('Unexpected value');
431
+ throw new UnexpectedMichelsonValueError(value);
335
432
  };
336
433
  const valueDecoder = (value) => {
337
434
  const preamble = value.consume(1);
@@ -361,7 +458,7 @@
361
458
  };
362
459
  const bytesEncoder = (value) => {
363
460
  if (!/^([A-Fa-f0-9]{2})*$/.test(value.bytes)) {
364
- throw new Error(`Invalid hex string: ${value.bytes}`);
461
+ throw new InvalidHexStringError(value.bytes);
365
462
  }
366
463
  const len = value.bytes.length / 2;
367
464
  return `0a${pad(len)}${value.bytes}`;
@@ -471,7 +568,7 @@
471
568
  let combPairArgs;
472
569
  let combPairAnnots;
473
570
  if ((opMapping[op] === 'pair' || opMapping[op] === 'Pair') && argsCount > 2) {
474
- combPairArgs = decodeCombPair(value);
571
+ combPairArgs = decodeCombPair$1(value);
475
572
  argsCount = 0;
476
573
  combPairAnnots = decodeAnnots(value);
477
574
  }
@@ -499,7 +596,7 @@
499
596
  value.consume(4);
500
597
  return result;
501
598
  };
502
- const decodeCombPair = (val) => {
599
+ const decodeCombPair$1 = (val) => {
503
600
  const array = new Uint8ArrayConsumer(extractRequiredLen(val));
504
601
  const args = [];
505
602
  while (array.length() > 0) {
@@ -574,7 +671,7 @@
574
671
  case 'pass':
575
672
  return '02';
576
673
  default:
577
- throw new Error(`Invalid ballot value: ${ballot}`);
674
+ throw new InvalidBallotValueError(ballot);
578
675
  }
579
676
  };
580
677
  const ballotDecoder = (ballot) => {
@@ -587,7 +684,7 @@
587
684
  case 0x02:
588
685
  return 'pass';
589
686
  default:
590
- throw new Error(`Unable to decode ballot value ${value[0]}`);
687
+ throw new DecodeBallotValueError(value[0].toString());
591
688
  }
592
689
  };
593
690
  const delegateEncoder = (val) => {
@@ -652,7 +749,7 @@
652
749
  case utils.Prefix.TZ3:
653
750
  return '02' + prefixEncoder(utils.Prefix.TZ3)(val);
654
751
  default:
655
- throw new Error('Invalid public key hash');
752
+ throw new utils.InvalidKeyHashError(val);
656
753
  }
657
754
  };
658
755
  const publicKeyEncoder = (val) => {
@@ -665,7 +762,7 @@
665
762
  case utils.Prefix.P2PK:
666
763
  return '02' + prefixEncoder(utils.Prefix.P2PK)(val);
667
764
  default:
668
- throw new Error('Invalid PK');
765
+ throw new utils.InvalidPublicKeyError(val);
669
766
  }
670
767
  };
671
768
  const addressEncoder = (val) => {
@@ -678,7 +775,7 @@
678
775
  case utils.Prefix.KT1:
679
776
  return '01' + prefixEncoder(utils.Prefix.KT1)(val) + '00';
680
777
  default:
681
- throw new Error('Invalid address');
778
+ throw new utils.InvalidAddressError(val);
682
779
  }
683
780
  };
684
781
  const publicKeyDecoder = (val) => {
@@ -691,7 +788,7 @@
691
788
  case 0x02:
692
789
  return prefixDecoder(utils.Prefix.P2PK)(val);
693
790
  default:
694
- throw new Error('Invalid PK');
791
+ throw new utils.InvalidPublicKeyError(val.toString());
695
792
  }
696
793
  };
697
794
  const addressDecoder = (val) => {
@@ -705,7 +802,7 @@
705
802
  return address;
706
803
  }
707
804
  default:
708
- throw new Error('Invalid Address');
805
+ throw new utils.InvalidAddressError(val.toString());
709
806
  }
710
807
  };
711
808
  const zarithEncoder = (n) => {
@@ -755,7 +852,7 @@
755
852
  const entry = extractRequiredLen(value, 1);
756
853
  const entrypoint = Buffer.from(entry).toString('utf8');
757
854
  if (entrypoint.length > ENTRYPOINT_MAX_LENGTH) {
758
- throw new Error(`Oversized entrypoint: ${entrypoint}. The maximum length of entrypoint is ${ENTRYPOINT_MAX_LENGTH}`);
855
+ throw new OversizedEntryPointError(entrypoint);
759
856
  }
760
857
  return entrypoint;
761
858
  }
@@ -781,7 +878,7 @@
781
878
  }
782
879
  else {
783
880
  if (entrypoint.length > ENTRYPOINT_MAX_LENGTH) {
784
- throw new Error(`Oversized entrypoint: ${entrypoint}. The maximum length of entrypoint is ${ENTRYPOINT_MAX_LENGTH}`);
881
+ throw new OversizedEntryPointError(entrypoint);
785
882
  }
786
883
  const value = { string: entrypoint };
787
884
  return `ff${valueEncoder(value).slice(8)}`;
@@ -877,23 +974,21 @@
877
974
  };
878
975
  const operationEncoder = (encoders) => (operation) => {
879
976
  if (!(operation.kind in encoders) || !(operation.kind in kindMappingReverse)) {
880
- throw new Error(`Unsupported operation kind: ${operation.kind}`);
977
+ throw new utils.InvalidOperationKindError(operation.kind);
881
978
  }
882
979
  return kindMappingReverse[operation.kind] + encoders[operation.kind](operation);
883
980
  };
884
981
  const operationDecoder = (decoders) => (value) => {
885
982
  const op = value.consume(1);
886
983
  const operationName = kindMapping[op[0]];
984
+ if (operationName === undefined) {
985
+ throw new UnsupportedOperationError(op[0].toString());
986
+ }
887
987
  const decodedObj = decoders[operationName](value);
888
988
  if (typeof decodedObj !== 'object') {
889
- throw new Error('Decoded invalid operation');
890
- }
891
- if (operationName) {
892
- return Object.assign({ kind: operationName }, decodedObj);
893
- }
894
- else {
895
- throw new Error(`Unsupported operation ${op[0]}`);
989
+ throw new OperationDecodingError('Decoded invalid operation');
896
990
  }
991
+ return Object.assign({ kind: operationName }, decodedObj);
897
992
  };
898
993
  const schemaEncoder = (encoders) => (schema) => (value) => {
899
994
  const keys = Object.keys(schema);
@@ -903,7 +998,7 @@
903
998
  const encoder = encoders[valueToEncode[0]];
904
999
  const values = value[key];
905
1000
  if (!Array.isArray(values)) {
906
- throw new Error(`Exepected value to be Array ${JSON.stringify(values)}`);
1001
+ throw new OperationEncodingError(`Expected value to be Array ${JSON.stringify(values)}`);
907
1002
  }
908
1003
  return prev + values.reduce((prevBytes, current) => prevBytes + encoder(current), '');
909
1004
  }
@@ -924,7 +1019,7 @@
924
1019
  while (value.length() > 0) {
925
1020
  decoded.push(decoder(value));
926
1021
  if (lastLength === value.length()) {
927
- throw new Error('Unable to decode value');
1022
+ throw new OperationDecodingError('Unable to decode value');
928
1023
  }
929
1024
  }
930
1025
  return Object.assign(Object.assign({}, prev), { [key]: decoded });
@@ -1053,26 +1148,24 @@
1053
1148
  };
1054
1149
  const operationEncoderProto12 = (encoders) => (operation) => {
1055
1150
  if (!(operation.kind in encoders) || !(operation.kind in kindMappingReverseProto12)) {
1056
- throw new Error(`Unsupported operation kind: ${operation.kind}`);
1151
+ throw new utils.InvalidOperationKindError(operation.kind);
1057
1152
  }
1058
1153
  return kindMappingReverseProto12[operation.kind] + encoders[operation.kind](operation);
1059
1154
  };
1060
1155
  const operationDecoderProto12 = (decoders) => (value) => {
1061
1156
  const op = value.consume(1);
1062
1157
  const operationName = kindMappingProto12[op[0]];
1158
+ if (operationName === undefined) {
1159
+ throw new UnsupportedOperationError(op[0].toString());
1160
+ }
1063
1161
  const decodedObj = decoders[operationName](value);
1064
1162
  if (typeof decodedObj !== 'object') {
1065
- throw new Error('Decoded invalid operation');
1066
- }
1067
- if (operationName) {
1068
- return Object.assign({ kind: operationName }, decodedObj);
1069
- }
1070
- else {
1071
- throw new Error(`Unsupported operation ${op[0]}`);
1163
+ throw new OperationDecodingError('Decoded invalid operation');
1072
1164
  }
1165
+ return Object.assign({ kind: operationName }, decodedObj);
1073
1166
  };
1074
1167
 
1075
- const decodersProto12 = Object.assign(Object.assign({}, decoders), { [exports.CODEC.INT16]: int16Decoder, ["blockPayloadHash" /* BLOCK_PAYLOAD_HASH */]: blockPayloadHashDecoder });
1168
+ const decodersProto12 = Object.assign(Object.assign({}, decoders), { [exports.CODEC.INT16]: int16Decoder, [exports.CODEC.BLOCK_PAYLOAD_HASH]: blockPayloadHashDecoder });
1076
1169
  decodersProto12[exports.CODEC.OPERATION] = operationDecoderProto12(decodersProto12);
1077
1170
  decodersProto12[exports.CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaDecoder(decodersProto12)(ActivationSchema)(val);
1078
1171
  decodersProto12[exports.CODEC.OP_DELEGATION] = (val) => schemaDecoder(decodersProto12)(DelegationSchema)(val);
@@ -1086,7 +1179,7 @@
1086
1179
  decodersProto12[exports.CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaDecoder(decodersProto12)(RegisterGlobalConstantSchema)(val);
1087
1180
  decodersProto12[exports.CODEC.MANAGER] = schemaDecoder(decodersProto12)(ManagerOperationSchema);
1088
1181
 
1089
- const encodersProto12 = Object.assign(Object.assign({}, encoders), { [exports.CODEC.INT16]: int16Encoder, ["blockPayloadHash" /* BLOCK_PAYLOAD_HASH */]: blockPayloadHashEncoder });
1182
+ const encodersProto12 = Object.assign(Object.assign({}, encoders), { [exports.CODEC.INT16]: int16Encoder, [exports.CODEC.BLOCK_PAYLOAD_HASH]: blockPayloadHashEncoder });
1090
1183
  encodersProto12[exports.CODEC.OPERATION] = operationEncoderProto12(encodersProto12);
1091
1184
  encodersProto12[exports.CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaEncoder(encodersProto12)(ActivationSchema)(val);
1092
1185
  encodersProto12[exports.CODEC.OP_DELEGATION] = (val) => schemaEncoder(encodersProto12)(DelegationSchema)(val);
@@ -1100,28 +1193,6 @@
1100
1193
  encodersProto12[exports.CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaEncoder(encodersProto12)(RegisterGlobalConstantSchema)(val);
1101
1194
  encodersProto12[exports.CODEC.MANAGER] = schemaEncoder(encodersProto12)(ManagerOperationSchema);
1102
1195
 
1103
- class InvalidBlockHashError extends Error {
1104
- constructor(message) {
1105
- super(message);
1106
- this.message = message;
1107
- this.name = 'InvalidBlockHashError';
1108
- }
1109
- }
1110
- class InvalidOperationSchemaError extends Error {
1111
- constructor(message) {
1112
- super(message);
1113
- this.message = message;
1114
- this.name = 'InvalidOperationSchemaError';
1115
- }
1116
- }
1117
- class InvalidOperationKindError extends Error {
1118
- constructor(message) {
1119
- super(message);
1120
- this.message = message;
1121
- this.name = 'InvalidOperationKindError';
1122
- }
1123
- }
1124
-
1125
1196
  const OperationKindMapping = {
1126
1197
  activate_account: ActivationSchema,
1127
1198
  reveal: RevealSchema,
@@ -1162,16 +1233,264 @@
1162
1233
  return getArrayDifference(cleanKeys, schemaKeys);
1163
1234
  };
1164
1235
 
1236
+ exports.ProtocolsHash = void 0;
1237
+ (function (ProtocolsHash) {
1238
+ ProtocolsHash["Pt24m4xi"] = "Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd";
1239
+ ProtocolsHash["PsBABY5H"] = "PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU";
1240
+ ProtocolsHash["PsBabyM1"] = "PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS";
1241
+ ProtocolsHash["PsCARTHA"] = "PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb";
1242
+ ProtocolsHash["PsDELPH1"] = "PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo";
1243
+ ProtocolsHash["PtEdo2Zk"] = "PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA";
1244
+ ProtocolsHash["PsFLorena"] = "PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i";
1245
+ ProtocolsHash["PtGRANADs"] = "PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV";
1246
+ ProtocolsHash["PtHangz2"] = "PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx";
1247
+ ProtocolsHash["Psithaca2"] = "Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A";
1248
+ ProtocolsHash["ProtoALpha"] = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK";
1249
+ })(exports.ProtocolsHash || (exports.ProtocolsHash = {}));
1250
+ const protoLevel = {
1251
+ Pt24m4xiPbLDhVgVfABUjirbmda3yohdN82Sp9FeuAXJ4eV9otd: 4,
1252
+ PsBABY5HQTSkA4297zNHfsZNKtxULfL18y95qb3m53QJiXGmrbU: 5,
1253
+ PsBabyM1eUXZseaJdmXFApDSBqj8YBfwELoxZHHW77EMcAbbwAS: 5,
1254
+ PsCARTHAGazKbHtnKfLzQg3kms52kSRpgnDY982a9oYsSXRLQEb: 6,
1255
+ PsDELPH1Kxsxt8f9eWbxQeRxkjfbxoqM52jvs5Y5fBxWWh4ifpo: 7,
1256
+ PtEdo2ZkT9oKpimTah6x2embF25oss54njMuPzkJTEi5RqfdZFA: 8,
1257
+ PsFLorenaUUuikDWvMDr6fGBRG8kt3e3D3fHoXK1j1BFRxeSH4i: 9,
1258
+ PtGRANADsDU8R9daYKAgWnQYAJ64omN1o3KMGVCykShA97vQbvV: 10,
1259
+ PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx: 11,
1260
+ Psithaca2MLRFYargivpo7YvUr7wUDqyxrdhC5CQq78mRvimz6A: 12,
1261
+ ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK: 13,
1262
+ };
1263
+ function ProtoInferiorTo(a, b) {
1264
+ return protoLevel[a] < protoLevel[b];
1265
+ }
1266
+
1267
+ const opMappingProto13 = Object.assign(Object.assign({}, opMapping), { '84': 'sapling_transaction_deprecated', '94': 'tx_rollup_l2_address', '95': 'MIN_BLOCK_TIME', '96': 'sapling_transaction' });
1268
+ const opMappingReverseProto13 = (() => {
1269
+ const result = {};
1270
+ Object.keys(opMappingProto13).forEach((key) => {
1271
+ result[opMappingProto13[key]] = key;
1272
+ });
1273
+ return result;
1274
+ })();
1275
+
1276
+ const scriptEncoderProto13 = (script) => {
1277
+ const code = valueEncoderProto13(script.code);
1278
+ const storage = valueEncoderProto13(script.storage);
1279
+ return `${pad(code.length / 2, 8)}${code}${pad(storage.length / 2, 8)}${storage}`;
1280
+ };
1281
+ const scriptDecoderProto13 = (value) => {
1282
+ const code = extractRequiredLen(value);
1283
+ const storage = extractRequiredLen(value);
1284
+ return {
1285
+ code: valueDecoderProto13(new Uint8ArrayConsumer(code)),
1286
+ storage: valueDecoderProto13(new Uint8ArrayConsumer(storage)),
1287
+ };
1288
+ };
1289
+ const valueEncoderProto13 = (value) => {
1290
+ if (Array.isArray(value)) {
1291
+ const encoded = value.map((x) => valueEncoderProto13(x)).join('');
1292
+ const len = encoded.length / 2;
1293
+ return `02${pad(len)}${encoded}`;
1294
+ }
1295
+ else if (isPrim(value)) {
1296
+ return primEncoderProto13(value);
1297
+ }
1298
+ else if (isBytes(value)) {
1299
+ return bytesEncoder(value);
1300
+ }
1301
+ else if (isString(value)) {
1302
+ return stringEncoder(value);
1303
+ }
1304
+ else if (isInt(value)) {
1305
+ return intEncoder(value);
1306
+ }
1307
+ throw new UnexpectedMichelsonValueError('Unexpected value');
1308
+ };
1309
+ const valueDecoderProto13 = (value) => {
1310
+ const preamble = value.consume(1);
1311
+ switch (preamble[0]) {
1312
+ case 0x0a:
1313
+ return bytesDecoder(value);
1314
+ case 0x01:
1315
+ return stringDecoder(value);
1316
+ case 0x00:
1317
+ return intDecoder(value);
1318
+ case 0x02: {
1319
+ const val = new Uint8ArrayConsumer(extractRequiredLen(value));
1320
+ const results = [];
1321
+ while (val.length() > 0) {
1322
+ results.push(valueDecoderProto13(val));
1323
+ }
1324
+ return results;
1325
+ }
1326
+ default:
1327
+ return primDecoderProto13(value, preamble);
1328
+ }
1329
+ };
1330
+ const primEncoderProto13 = (value) => {
1331
+ const hasAnnot = +Array.isArray(value.annots);
1332
+ const argsCount = Array.isArray(value.args) ? value.args.length : 0;
1333
+ // Specify the number of args max is 3 without annotation
1334
+ const preamble = pad(Math.min(2 * argsCount + hasAnnot + 0x03, 9), 2);
1335
+ const op = opMappingReverseProto13[value.prim];
1336
+ let encodedArgs = (value.args || []).map((arg) => valueEncoderProto13(arg)).join('');
1337
+ const encodedAnnots = Array.isArray(value.annots) ? encodeAnnots(value.annots) : '';
1338
+ if (value.prim === 'LAMBDA' && argsCount) {
1339
+ encodedArgs = pad(encodedArgs.length / 2) + encodedArgs + pad(0);
1340
+ }
1341
+ if ((value.prim === 'pair' || value.prim === 'Pair') && argsCount > 2) {
1342
+ encodedArgs =
1343
+ encodedAnnots === ''
1344
+ ? pad(encodedArgs.length / 2) + encodedArgs + pad(0)
1345
+ : pad(encodedArgs.length / 2) + encodedArgs;
1346
+ }
1347
+ if (value.prim === 'view' && value.args) {
1348
+ encodedArgs = pad(encodedArgs.length / 2) + encodedArgs + pad(0);
1349
+ }
1350
+ return `${preamble}${op}${encodedArgs}${encodedAnnots}`;
1351
+ };
1352
+ const primDecoderProto13 = (value, preamble) => {
1353
+ const hasAnnot = (preamble[0] - 0x03) % 2 === 1;
1354
+ let argsCount = Math.floor((preamble[0] - 0x03) / 2);
1355
+ const op = value.consume(1)[0].toString(16).padStart(2, '0');
1356
+ const result = {
1357
+ prim: opMappingProto13[op],
1358
+ };
1359
+ if (opMappingProto13[op] === 'LAMBDA') {
1360
+ value.consume(4);
1361
+ }
1362
+ if (opMappingProto13[op] === 'view') {
1363
+ if (argsCount != 0) {
1364
+ return primViewDecoderProto13(value, result);
1365
+ }
1366
+ else {
1367
+ return result;
1368
+ }
1369
+ }
1370
+ let combPairArgs;
1371
+ let combPairAnnots;
1372
+ if ((opMappingProto13[op] === 'pair' || opMappingProto13[op] === 'Pair') && argsCount > 2) {
1373
+ combPairArgs = decodeCombPair(value);
1374
+ argsCount = 0;
1375
+ combPairAnnots = decodeAnnots(value);
1376
+ }
1377
+ const args = new Array(argsCount).fill(0).map(() => valueDecoderProto13(value));
1378
+ if (opMappingProto13[op] === 'LAMBDA') {
1379
+ value.consume(4);
1380
+ }
1381
+ if (combPairArgs) {
1382
+ result['args'] = combPairArgs;
1383
+ }
1384
+ else if (args.length) {
1385
+ result['args'] = args;
1386
+ }
1387
+ if (combPairAnnots && combPairAnnots[0] !== '') {
1388
+ result['annots'] = combPairAnnots;
1389
+ }
1390
+ else if (hasAnnot) {
1391
+ result['annots'] = decodeAnnots(value);
1392
+ }
1393
+ return result;
1394
+ };
1395
+ const primViewDecoderProto13 = (value, result) => {
1396
+ value.consume(4);
1397
+ result['args'] = new Array(4).fill(0).map(() => valueDecoderProto13(value));
1398
+ value.consume(4);
1399
+ return result;
1400
+ };
1401
+ const decodeCombPair = (val) => {
1402
+ const array = new Uint8ArrayConsumer(extractRequiredLen(val));
1403
+ const args = [];
1404
+ while (array.length() > 0) {
1405
+ args.push(valueDecoderProto13(array));
1406
+ }
1407
+ return args;
1408
+ };
1409
+
1410
+ const parametersDecoderProto13 = (val) => {
1411
+ const preamble = val.consume(1);
1412
+ if (preamble[0] === 0x00) {
1413
+ return;
1414
+ }
1415
+ else {
1416
+ const encodedEntrypoint = entrypointDecoder(val);
1417
+ const params = extractRequiredLen(val);
1418
+ const parameters = valueDecoderProto13(new Uint8ArrayConsumer(params));
1419
+ return {
1420
+ entrypoint: encodedEntrypoint,
1421
+ value: parameters,
1422
+ };
1423
+ }
1424
+ };
1425
+ const valueParameterDecoderProto13 = (val) => {
1426
+ const value = extractRequiredLen(val);
1427
+ return valueDecoderProto13(new Uint8ArrayConsumer(value));
1428
+ };
1429
+ const entrypointEncoderProto13 = (entrypoint) => {
1430
+ if (entrypoint in entrypointMappingReverse) {
1431
+ return `${entrypointMappingReverse[entrypoint]}`;
1432
+ }
1433
+ else {
1434
+ if (entrypoint.length > ENTRYPOINT_MAX_LENGTH) {
1435
+ throw new OversizedEntryPointError(entrypoint);
1436
+ }
1437
+ const value = { string: entrypoint };
1438
+ return `ff${valueEncoderProto13(value).slice(8)}`;
1439
+ }
1440
+ };
1441
+ const parametersEncoderProto13 = (val) => {
1442
+ if (!val || (val.entrypoint === 'default' && 'prim' in val.value && val.value.prim === 'Unit')) {
1443
+ return '00';
1444
+ }
1445
+ const encodedEntrypoint = entrypointEncoderProto13(val.entrypoint);
1446
+ const parameters = valueEncoderProto13(val.value);
1447
+ const length = (parameters.length / 2).toString(16).padStart(8, '0');
1448
+ return `ff${encodedEntrypoint}${length}${parameters}`;
1449
+ };
1450
+ const valueParameterEncoderProto13 = (value) => {
1451
+ const valueEncoded = valueEncoderProto13(value);
1452
+ return `${pad(valueEncoded.length / 2)}${valueEncoded}`;
1453
+ };
1454
+
1455
+ const encodersProto13 = Object.assign(Object.assign({}, encodersProto12), { [exports.CODEC.SCRIPT]: scriptEncoderProto13, [exports.CODEC.PARAMETERS]: parametersEncoderProto13, [exports.CODEC.VALUE]: valueParameterEncoderProto13 });
1456
+ encodersProto13[exports.CODEC.OPERATION] = operationEncoderProto12(encodersProto13);
1457
+ encodersProto13[exports.CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaEncoder(encodersProto13)(ActivationSchema)(val);
1458
+ encodersProto13[exports.CODEC.OP_DELEGATION] = (val) => schemaEncoder(encodersProto13)(DelegationSchema)(val);
1459
+ encodersProto13[exports.CODEC.OP_TRANSACTION] = (val) => schemaEncoder(encodersProto13)(TransactionSchema)(val);
1460
+ encodersProto13[exports.CODEC.OP_ORIGINATION] = (val) => schemaEncoder(encodersProto13)(OriginationSchema)(val);
1461
+ encodersProto13[exports.CODEC.OP_BALLOT] = (val) => schemaEncoder(encodersProto13)(BallotSchema)(val);
1462
+ encodersProto13[exports.CODEC.OP_ENDORSEMENT] = (val) => schemaEncoder(encodersProto13)(EndorsementSchemaProto12)(val);
1463
+ encodersProto13[exports.CODEC.OP_SEED_NONCE_REVELATION] = (val) => schemaEncoder(encodersProto13)(SeedNonceRevelationSchema)(val);
1464
+ encodersProto13[exports.CODEC.OP_PROPOSALS] = (val) => schemaEncoder(encodersProto13)(ProposalsSchema)(val);
1465
+ encodersProto13[exports.CODEC.OP_REVEAL] = (val) => schemaEncoder(encodersProto13)(RevealSchema)(val);
1466
+ encodersProto13[exports.CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaEncoder(encodersProto13)(RegisterGlobalConstantSchema)(val);
1467
+ encodersProto13[exports.CODEC.MANAGER] = schemaEncoder(encodersProto13)(ManagerOperationSchema);
1468
+
1469
+ const decodersProto13 = Object.assign(Object.assign({}, decodersProto12), { [exports.CODEC.SCRIPT]: scriptDecoderProto13, [exports.CODEC.PARAMETERS]: parametersDecoderProto13, [exports.CODEC.VALUE]: valueParameterDecoderProto13 });
1470
+ decodersProto13[exports.CODEC.OPERATION] = operationDecoderProto12(decodersProto13);
1471
+ decodersProto13[exports.CODEC.OP_ACTIVATE_ACCOUNT] = (val) => schemaDecoder(decodersProto13)(ActivationSchema)(val);
1472
+ decodersProto13[exports.CODEC.OP_DELEGATION] = (val) => schemaDecoder(decodersProto13)(DelegationSchema)(val);
1473
+ decodersProto13[exports.CODEC.OP_TRANSACTION] = (val) => schemaDecoder(decodersProto13)(TransactionSchema)(val);
1474
+ decodersProto13[exports.CODEC.OP_ORIGINATION] = (val) => schemaDecoder(decodersProto13)(OriginationSchema)(val);
1475
+ decodersProto13[exports.CODEC.OP_BALLOT] = (val) => schemaDecoder(decodersProto13)(BallotSchema)(val);
1476
+ decodersProto13[exports.CODEC.OP_ENDORSEMENT] = (val) => schemaDecoder(decodersProto13)(EndorsementSchemaProto12)(val);
1477
+ decodersProto13[exports.CODEC.OP_SEED_NONCE_REVELATION] = (val) => schemaDecoder(decodersProto13)(SeedNonceRevelationSchema)(val);
1478
+ decodersProto13[exports.CODEC.OP_PROPOSALS] = (val) => schemaDecoder(decodersProto13)(ProposalsSchema)(val);
1479
+ decodersProto13[exports.CODEC.OP_REVEAL] = (val) => schemaDecoder(decodersProto13)(RevealSchema)(val);
1480
+ decodersProto13[exports.CODEC.OP_REGISTER_GLOBAL_CONSTANT] = (val) => schemaDecoder(decodersProto13)(RegisterGlobalConstantSchema)(val);
1481
+ decodersProto13[exports.CODEC.MANAGER] = schemaDecoder(decodersProto13)(ManagerOperationSchema);
1482
+
1165
1483
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
1166
1484
  const VERSION = {
1167
- "commitHash": "5996bf6b665e26de3201cf45884b4a2bb9218e09",
1168
- "version": "12.0.2"
1485
+ "commitHash": "cbdd0af87e400489076259d065e2d328feb8e1b4",
1486
+ "version": "12.1.0"
1169
1487
  };
1170
1488
 
1171
1489
  /**
1172
1490
  * @packageDocumentation
1173
1491
  * @module @taquito/local-forging
1174
1492
  */
1493
+ const PROTOCOL_CURRENT = exports.ProtocolsHash.Psithaca2;
1175
1494
  function getCodec(codec, proto) {
1176
1495
  if (proto === exports.ProtocolsHash.Psithaca2) {
1177
1496
  return {
@@ -1182,7 +1501,7 @@
1182
1501
  },
1183
1502
  };
1184
1503
  }
1185
- else {
1504
+ else if (ProtoInferiorTo(proto, exports.ProtocolsHash.Psithaca2)) {
1186
1505
  return {
1187
1506
  encoder: encoders[codec],
1188
1507
  decoder: (hex) => {
@@ -1191,9 +1510,18 @@
1191
1510
  },
1192
1511
  };
1193
1512
  }
1513
+ else {
1514
+ return {
1515
+ encoder: encodersProto13[codec],
1516
+ decoder: (hex) => {
1517
+ const consumer = Uint8ArrayConsumer.fromHexString(hex);
1518
+ return decodersProto13[codec](consumer);
1519
+ },
1520
+ };
1521
+ }
1194
1522
  }
1195
1523
  class LocalForger {
1196
- constructor(protocolHash = exports.ProtocolsHash.Psithaca2) {
1524
+ constructor(protocolHash = PROTOCOL_CURRENT) {
1197
1525
  this.protocolHash = protocolHash;
1198
1526
  this.codec = getCodec(exports.CODEC.MANAGER, this.protocolHash);
1199
1527
  }
@@ -1203,7 +1531,7 @@
1203
1531
  }
1204
1532
  for (const content of params.contents) {
1205
1533
  if (!validateOperationKind(content.kind)) {
1206
- throw new InvalidOperationKindError(`The operation kind '${content.kind}' does not exist`);
1534
+ throw new utils.InvalidOperationKindError(content.kind);
1207
1535
  }
1208
1536
  const diff = validateMissingProperty(content);
1209
1537
  if (diff.length === 1) {