@typeberry/convert 0.5.4 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -4362,7 +4362,6 @@ const env = typeof process === "undefined" ? {} : process.env;
4362
4362
 
4363
4363
  var GpVersion;
4364
4364
  (function (GpVersion) {
4365
- GpVersion["V0_7_0"] = "0.7.0";
4366
4365
  GpVersion["V0_7_1"] = "0.7.1";
4367
4366
  GpVersion["V0_7_2"] = "0.7.2";
4368
4367
  })(GpVersion || (GpVersion = {}));
@@ -4371,7 +4370,7 @@ var TestSuite;
4371
4370
  TestSuite["W3F_DAVXY"] = "w3f-davxy";
4372
4371
  })(TestSuite || (TestSuite = {}));
4373
4372
  // NOTE: Also acts as a supported versions
4374
- const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
4373
+ const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_7_1, GpVersion.V0_7_2];
4375
4374
  const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
4376
4375
  const DEFAULT_VERSION = GpVersion.V0_7_2;
4377
4376
  let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
@@ -4956,7 +4955,7 @@ function isResult(x) {
4956
4955
  var minimist = __nccwpck_require__(595);
4957
4956
  var minimist_default = /*#__PURE__*/__nccwpck_require__.n(minimist);
4958
4957
  ;// CONCATENATED MODULE: ./bin/convert/package.json
4959
- const package_namespaceObject = {"rE":"0.5.4"};
4958
+ const package_namespaceObject = {"rE":"0.5.5"};
4960
4959
  ;// CONCATENATED MODULE: ./packages/core/bytes/bitvec.ts
4961
4960
 
4962
4961
  /**
@@ -5850,7 +5849,7 @@ class Skipper {
5850
5849
  *
5851
5850
  * Descriptors can be composed to form more complex typings.
5852
5851
  */
5853
- class Descriptor {
5852
+ class descriptor_Descriptor {
5854
5853
  name;
5855
5854
  sizeHint;
5856
5855
  encode;
@@ -5860,11 +5859,11 @@ class Descriptor {
5860
5859
  View;
5861
5860
  /** New descriptor with specialized `View`. */
5862
5861
  static withView(name, sizeHint, encode, decode, skip, view) {
5863
- return new Descriptor(name, sizeHint, encode, decode, skip, view);
5862
+ return new descriptor_Descriptor(name, sizeHint, encode, decode, skip, view);
5864
5863
  }
5865
5864
  /** Create a new descriptor without a specialized `View`. */
5866
5865
  static new(name, sizeHint, encode, decode, skip) {
5867
- return new Descriptor(name, sizeHint, encode, decode, skip, null);
5866
+ return new descriptor_Descriptor(name, sizeHint, encode, decode, skip, null);
5868
5867
  }
5869
5868
  constructor(
5870
5869
  /** Descriptive name of the coded data. */
@@ -5901,7 +5900,7 @@ class Descriptor {
5901
5900
  }
5902
5901
  /** Return a new descriptor that converts data into some other type. */
5903
5902
  convert(input, output) {
5904
- return new Descriptor(this.name, this.sizeHint, (e, elem) => this.encode(e, input(elem)), (d) => output(this.decode(d)), this.skip, this.View);
5903
+ return new descriptor_Descriptor(this.name, this.sizeHint, (e, elem) => this.encode(e, input(elem)), (d) => output(this.decode(d)), this.skip, this.View);
5905
5904
  }
5906
5905
  /** Safely cast the descriptor value to a opaque type. */
5907
5906
  asOpaque() {
@@ -6600,53 +6599,53 @@ const bytes = (() => {
6600
6599
  return (len) => {
6601
6600
  let ret = cache.get(len);
6602
6601
  if (ret === undefined) {
6603
- ret = Descriptor.new(`Bytes<${len}>`, exactHint(len), (e, v) => e.bytes(v), (d) => d.bytes(len), (s) => s.bytes(len));
6602
+ ret = descriptor_Descriptor.new(`Bytes<${len}>`, exactHint(len), (e, v) => e.bytes(v), (d) => d.bytes(len), (s) => s.bytes(len));
6604
6603
  cache.set(len, ret);
6605
6604
  }
6606
6605
  return ret;
6607
6606
  };
6608
6607
  })();
6609
6608
  /** Zero-size `void` value. */
6610
- const nothing = Descriptor.new("void", { bytes: 0, isExact: true }, (_e, _v) => { }, (_d) => { }, (_s) => { });
6609
+ const nothing = descriptor_Descriptor.new("void", { bytes: 0, isExact: true }, (_e, _v) => { }, (_d) => { }, (_s) => { });
6611
6610
  /** Variable-length U32. */
6612
- const varU32 = Descriptor.new("var_u32", { bytes: 4, isExact: false }, (e, v) => e.varU32(v), (d) => d.varU32(), (d) => d.varU32());
6611
+ const varU32 = descriptor_Descriptor.new("var_u32", { bytes: 4, isExact: false }, (e, v) => e.varU32(v), (d) => d.varU32(), (d) => d.varU32());
6613
6612
  /** Variable-length U64. */
6614
- const varU64 = Descriptor.new("var_u64", { bytes: 8, isExact: false }, (e, v) => e.varU64(v), (d) => d.varU64(), (d) => d.varU64());
6613
+ const varU64 = descriptor_Descriptor.new("var_u64", { bytes: 8, isExact: false }, (e, v) => e.varU64(v), (d) => d.varU64(), (d) => d.varU64());
6615
6614
  /** Unsigned 64-bit number. */
6616
- const u64 = Descriptor.withView("u64", exactHint(8), (e, v) => e.i64(v), (d) => d.u64(), (d) => d.u64(), bytes(8));
6615
+ const u64 = descriptor_Descriptor.withView("u64", exactHint(8), (e, v) => e.i64(v), (d) => d.u64(), (d) => d.u64(), bytes(8));
6617
6616
  /** Unsigned 32-bit number. */
6618
- const u32 = Descriptor.withView("u32", exactHint(4), (e, v) => e.i32(v), (d) => d.u32(), (d) => d.u32(), bytes(4));
6617
+ const u32 = descriptor_Descriptor.withView("u32", exactHint(4), (e, v) => e.i32(v), (d) => d.u32(), (d) => d.u32(), bytes(4));
6619
6618
  /** Unsigned 24-bit number. */
6620
- const u24 = Descriptor.withView("u24", exactHint(3), (e, v) => e.i24(v), (d) => d.u24(), (d) => d.u24(), bytes(3));
6619
+ const u24 = descriptor_Descriptor.withView("u24", exactHint(3), (e, v) => e.i24(v), (d) => d.u24(), (d) => d.u24(), bytes(3));
6621
6620
  /** Unsigned 16-bit number. */
6622
- const u16 = Descriptor.withView("u16", exactHint(2), (e, v) => e.i16(v), (d) => d.u16(), (d) => d.u16(), bytes(2));
6621
+ const u16 = descriptor_Descriptor.withView("u16", exactHint(2), (e, v) => e.i16(v), (d) => d.u16(), (d) => d.u16(), bytes(2));
6623
6622
  /** Unsigned 8-bit number. */
6624
- const u8 = Descriptor.new("u8", exactHint(1), (e, v) => e.i8(v), (d) => d.u8(), (d) => d.u8());
6623
+ const u8 = descriptor_Descriptor.new("u8", exactHint(1), (e, v) => e.i8(v), (d) => d.u8(), (d) => d.u8());
6625
6624
  /** Signed 64-bit number. */
6626
- const i64 = Descriptor.withView("i64", exactHint(8), (e, v) => e.i64(v), (d) => d.i64(), (s) => s.u64(), bytes(8));
6625
+ const i64 = descriptor_Descriptor.withView("i64", exactHint(8), (e, v) => e.i64(v), (d) => d.i64(), (s) => s.u64(), bytes(8));
6627
6626
  /** Signed 32-bit number. */
6628
- const i32 = Descriptor.withView("i32", exactHint(4), (e, v) => e.i32(v), (d) => d.i32(), (s) => s.u32(), bytes(4));
6627
+ const i32 = descriptor_Descriptor.withView("i32", exactHint(4), (e, v) => e.i32(v), (d) => d.i32(), (s) => s.u32(), bytes(4));
6629
6628
  /** Signed 24-bit number. */
6630
- const i24 = Descriptor.withView("i24", exactHint(3), (e, v) => e.i24(v), (d) => d.i24(), (s) => s.u24(), bytes(3));
6629
+ const i24 = descriptor_Descriptor.withView("i24", exactHint(3), (e, v) => e.i24(v), (d) => d.i24(), (s) => s.u24(), bytes(3));
6631
6630
  /** Signed 16-bit number. */
6632
- const i16 = Descriptor.withView("i16", exactHint(2), (e, v) => e.i16(v), (d) => d.i16(), (s) => s.u16(), bytes(2));
6631
+ const i16 = descriptor_Descriptor.withView("i16", exactHint(2), (e, v) => e.i16(v), (d) => d.i16(), (s) => s.u16(), bytes(2));
6633
6632
  /** Signed 8-bit number. */
6634
- const i8 = Descriptor.new("i8", exactHint(1), (e, v) => e.i8(v), (d) => d.i8(), (s) => s.u8());
6633
+ const i8 = descriptor_Descriptor.new("i8", exactHint(1), (e, v) => e.i8(v), (d) => d.i8(), (s) => s.u8());
6635
6634
  /** 1-byte boolean value. */
6636
- const bool = Descriptor.new("bool", exactHint(1), (e, v) => e.bool(v), (d) => d.bool(), (s) => s.bool());
6635
+ const bool = descriptor_Descriptor.new("bool", exactHint(1), (e, v) => e.bool(v), (d) => d.bool(), (s) => s.bool());
6637
6636
  /** Variable-length bytes blob. */
6638
- const blob = Descriptor.new("BytesBlob", { bytes: TYPICAL_SEQUENCE_LENGTH, isExact: false }, (e, v) => e.bytesBlob(v), (d) => d.bytesBlob(), (s) => s.bytesBlob());
6637
+ const blob = descriptor_Descriptor.new("BytesBlob", { bytes: TYPICAL_SEQUENCE_LENGTH, isExact: false }, (e, v) => e.bytesBlob(v), (d) => d.bytesBlob(), (s) => s.bytesBlob());
6639
6638
  /** String encoded as variable-length bytes blob. */
6640
- const string = Descriptor.withView("string", { bytes: TYPICAL_SEQUENCE_LENGTH, isExact: false }, (e, v) => e.bytesBlob(bytes_BytesBlob.blobFrom(new TextEncoder().encode(v))), (d) => new TextDecoder("utf8", { fatal: true }).decode(d.bytesBlob().raw), (s) => s.bytesBlob(), blob);
6639
+ const string = descriptor_Descriptor.withView("string", { bytes: TYPICAL_SEQUENCE_LENGTH, isExact: false }, (e, v) => e.bytesBlob(bytes_BytesBlob.blobFrom(new TextEncoder().encode(v))), (d) => new TextDecoder("utf8", { fatal: true }).decode(d.bytesBlob().raw), (s) => s.bytesBlob(), blob);
6641
6640
  /** Variable-length bit vector. */
6642
- const bitVecVarLen = Descriptor.new("BitVec[?]", { bytes: TYPICAL_SEQUENCE_LENGTH >>> 3, isExact: false }, (e, v) => e.bitVecVarLen(v), (d) => d.bitVecVarLen(), (s) => s.bitVecVarLen());
6641
+ const bitVecVarLen = descriptor_Descriptor.new("BitVec[?]", { bytes: TYPICAL_SEQUENCE_LENGTH >>> 3, isExact: false }, (e, v) => e.bitVecVarLen(v), (d) => d.bitVecVarLen(), (s) => s.bitVecVarLen());
6643
6642
  /** Fixed-length bit vector. */
6644
- const bitVecFixLen = (bitLen) => Descriptor.new(`BitVec[${bitLen}]`, exactHint(bitLen >>> 3), (e, v) => e.bitVecFixLen(v), (d) => d.bitVecFixLen(bitLen), (s) => s.bitVecFixLen(bitLen));
6643
+ const bitVecFixLen = (bitLen) => descriptor_Descriptor.new(`BitVec[${bitLen}]`, exactHint(bitLen >>> 3), (e, v) => e.bitVecFixLen(v), (d) => d.bitVecFixLen(bitLen), (s) => s.bitVecFixLen(bitLen));
6645
6644
  /** Optionality wrapper for given type. */
6646
6645
  const optional = (type) => {
6647
- const self = Descriptor.new(`Optional<${type.name}>`, addSizeHints({ bytes: 1, isExact: false }, type.sizeHint), (e, v) => e.optional(type, v), (d) => d.optional(type), (s) => s.optional(type));
6646
+ const self = descriptor_Descriptor.new(`Optional<${type.name}>`, addSizeHints({ bytes: 1, isExact: false }, type.sizeHint), (e, v) => e.optional(type, v), (d) => d.optional(type), (s) => s.optional(type));
6648
6647
  if (hasUniqueView(type)) {
6649
- return Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, optional(type.View));
6648
+ return descriptor_Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, optional(type.View));
6650
6649
  }
6651
6650
  return self;
6652
6651
  };
@@ -6657,7 +6656,7 @@ const sequenceVarLen = (type, options = {
6657
6656
  }) => {
6658
6657
  const name = `Sequence<${type.name}>[?]`;
6659
6658
  const typicalLength = options.typicalLength ?? TYPICAL_SEQUENCE_LENGTH;
6660
- return Descriptor.withView(name, { bytes: typicalLength * type.sizeHint.bytes, isExact: false }, (e, v) => {
6659
+ return descriptor_Descriptor.withView(name, { bytes: typicalLength * type.sizeHint.bytes, isExact: false }, (e, v) => {
6661
6660
  validateLength(options, v.length, name);
6662
6661
  e.sequenceVarLen(type, v);
6663
6662
  }, (d) => {
@@ -6671,10 +6670,10 @@ const sequenceVarLen = (type, options = {
6671
6670
  }, sequenceViewVarLen(type, options));
6672
6671
  };
6673
6672
  /** Fixed-length sequence of given type. */
6674
- const sequenceFixLen = (type, len) => Descriptor.withView(`Sequence<${type.name}>[${len}]`, { bytes: len * type.sizeHint.bytes, isExact: type.sizeHint.isExact }, (e, v) => e.sequenceFixLen(type, v), (d) => d.sequenceFixLen(type, len), (s) => s.sequenceFixLen(type, len), sequenceViewFixLen(type, { fixedLength: len }));
6673
+ const sequenceFixLen = (type, len) => descriptor_Descriptor.withView(`Sequence<${type.name}>[${len}]`, { bytes: len * type.sizeHint.bytes, isExact: type.sizeHint.isExact }, (e, v) => e.sequenceFixLen(type, v), (d) => d.sequenceFixLen(type, len), (s) => s.sequenceFixLen(type, len), sequenceViewFixLen(type, { fixedLength: len }));
6675
6674
  /** Small dictionary codec. */
6676
6675
  const dictionary = (key, value, { sortKeys, fixedLength, }) => {
6677
- const self = Descriptor.new(`Dictionary<${key.name}, ${value.name}>[${fixedLength ?? "?"}]`, {
6676
+ const self = descriptor_Descriptor.new(`Dictionary<${key.name}, ${value.name}>[${fixedLength ?? "?"}]`, {
6678
6677
  bytes: fixedLength !== undefined
6679
6678
  ? fixedLength * addSizeHints(key.sizeHint, value.sizeHint).bytes
6680
6679
  : TYPICAL_DICTIONARY_LENGTH * (addSizeHints(key.sizeHint, value.sizeHint).bytes ?? 0),
@@ -6713,13 +6712,13 @@ const dictionary = (key, value, { sortKeys, fixedLength, }) => {
6713
6712
  s.sequenceFixLen(value, len);
6714
6713
  });
6715
6714
  if (hasUniqueView(value)) {
6716
- return Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, dictionary(key, value.View, { sortKeys, fixedLength }));
6715
+ return descriptor_Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, dictionary(key, value.View, { sortKeys, fixedLength }));
6717
6716
  }
6718
6717
  return self;
6719
6718
  };
6720
6719
  /** Encoding of pair of two values. */
6721
6720
  const pair = (a, b) => {
6722
- const self = Descriptor.new(`Pair<${a.name}, ${b.name}>`, addSizeHints(a.sizeHint, b.sizeHint), (e, elem) => {
6721
+ const self = descriptor_Descriptor.new(`Pair<${a.name}, ${b.name}>`, addSizeHints(a.sizeHint, b.sizeHint), (e, elem) => {
6723
6722
  a.encode(e, elem[0]);
6724
6723
  b.encode(e, elem[1]);
6725
6724
  }, (d) => {
@@ -6731,12 +6730,12 @@ const pair = (a, b) => {
6731
6730
  b.skip(s);
6732
6731
  });
6733
6732
  if (hasUniqueView(a) && hasUniqueView(b)) {
6734
- return Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, pair(a.View, b.View));
6733
+ return descriptor_Descriptor.withView(self.name, self.sizeHint, self.encode, self.decode, self.skip, pair(a.View, b.View));
6735
6734
  }
6736
6735
  return self;
6737
6736
  };
6738
6737
  /** Custom encoding / decoding logic. */
6739
- const custom = ({ name, sizeHint = { bytes: 0, isExact: false }, }, encode, decode, skip) => Descriptor.new(name, sizeHint, encode, decode, skip);
6738
+ const custom = ({ name, sizeHint = { bytes: 0, isExact: false }, }, encode, decode, skip) => descriptor_Descriptor.new(name, sizeHint, encode, decode, skip);
6740
6739
  /** Tagged union type encoding. */
6741
6740
  const union = (name, variants) => {
6742
6741
  const keys = Object.keys(variants).map(Number);
@@ -6777,12 +6776,12 @@ const union = (name, variants) => {
6777
6776
  const codec = variants[kind];
6778
6777
  codec.skip(s);
6779
6778
  };
6780
- return Descriptor.new(name, sizeHint, encode, decode, skip);
6779
+ return descriptor_Descriptor.new(name, sizeHint, encode, decode, skip);
6781
6780
  };
6782
6781
  /** Choose a descriptor depending on the encoding/decoding context. */
6783
6782
  const descriptors_select = ({ name, sizeHint, }, chooser) => {
6784
6783
  const Self = chooser(null);
6785
- return Descriptor.withView(name, sizeHint, (e, x) => chooser(e.getContext()).encode(e, x), (d) => chooser(d.getContext()).decode(d), (s) => chooser(s.decoder.getContext()).skip(s), hasUniqueView(Self)
6784
+ return descriptor_Descriptor.withView(name, sizeHint, (e, x) => chooser(e.getContext()).encode(e, x), (d) => chooser(d.getContext()).decode(d), (s) => chooser(s.decoder.getContext()).skip(s), hasUniqueView(Self)
6786
6785
  ? descriptors_select({
6787
6786
  name: Self.View.name,
6788
6787
  sizeHint: Self.View.sizeHint,
@@ -6825,7 +6824,7 @@ const Class = (Class, descriptors) => {
6825
6824
  };
6826
6825
  const view = objectView(Class, descriptors, sizeHint, skipper);
6827
6826
  // and create the descriptor for the entire class.
6828
- return Descriptor.withView(Class.name, sizeHint, (e, t) => {
6827
+ return descriptor_Descriptor.withView(Class.name, sizeHint, (e, t) => {
6829
6828
  forEachDescriptor(descriptors, (key, descriptor) => {
6830
6829
  const value = t[key];
6831
6830
  descriptor.encode(e, value);
@@ -6878,7 +6877,7 @@ function objectView(Class, descriptors, sizeHint, skipper) {
6878
6877
  });
6879
6878
  }
6880
6879
  });
6881
- return Descriptor.new(`View<${Class.name}>`, sizeHint, (e, t) => {
6880
+ return descriptor_Descriptor.new(`View<${Class.name}>`, sizeHint, (e, t) => {
6882
6881
  const encoded = t.encoded();
6883
6882
  e.bytes(bytes_Bytes.fromBlob(encoded.raw, encoded.length));
6884
6883
  }, (d) => {
@@ -6897,7 +6896,7 @@ function sequenceViewVarLen(type, options) {
6897
6896
  validateLength(options, length, name);
6898
6897
  return s.sequenceFixLen(type, length);
6899
6898
  };
6900
- return Descriptor.new(name, sizeHint, (e, t) => {
6899
+ return descriptor_Descriptor.new(name, sizeHint, (e, t) => {
6901
6900
  validateLength(options, t.length, name);
6902
6901
  const encoded = t.encoded();
6903
6902
  e.bytes(bytes_Bytes.fromBlob(encoded.raw, encoded.length));
@@ -6913,7 +6912,7 @@ function sequenceViewFixLen(type, { fixedLength }) {
6913
6912
  const skipper = (s) => s.sequenceFixLen(type, fixedLength);
6914
6913
  const view = type.name !== type.View.name ? `, ${type.View.name}` : "";
6915
6914
  const name = `SeqView<${type.name}${view}>[${fixedLength}]`;
6916
- return Descriptor.new(name, sizeHint, (e, t) => {
6915
+ return descriptor_Descriptor.new(name, sizeHint, (e, t) => {
6917
6916
  const encoded = t.encoded();
6918
6917
  e.bytes(bytes_Bytes.fromBlob(encoded.raw, encoded.length));
6919
6918
  }, (d) => {
@@ -9177,7 +9176,7 @@ const codecFixedSizeArray = (val, len) => {
9177
9176
  };
9178
9177
  /** Codec for a hash-dictionary. */
9179
9178
  const codecHashDictionary = (value, extractKey, { typicalLength = codec_codec.TYPICAL_DICTIONARY_LENGTH, compare = (a, b) => extractKey(a).compare(extractKey(b)), } = {}) => {
9180
- return Descriptor.new(`HashDictionary<${value.name}>[?]`, {
9179
+ return descriptor_Descriptor.new(`HashDictionary<${value.name}>[?]`, {
9181
9180
  bytes: typicalLength * value.sizeHint.bytes,
9182
9181
  isExact: false,
9183
9182
  }, (e, v) => {
@@ -10811,6 +10810,9 @@ var json;
10811
10810
  if (typeof inJson !== "object" || inJson === null) {
10812
10811
  throw new Error("Expected map for parsing");
10813
10812
  }
10813
+ if (Array.isArray(inJson)) {
10814
+ throw new Error("Expected map, got array");
10815
+ }
10814
10816
  const result = new Map();
10815
10817
  for (const [key, value] of Object.entries(inJson)) {
10816
10818
  result.set(parse_parseFromJson(key, K, `${context}.key`), parse_parseFromJson(value, V, `${context}.value`));
@@ -12610,7 +12612,7 @@ const zeroSizeHint = {
12610
12612
  /** 0-byte read, return given default value */
12611
12613
  const ignoreValueWithDefault = (defaultValue) => Descriptor.new("ignoreValue", zeroSizeHint, (_e, _v) => { }, (_d) => defaultValue, (_s) => { });
12612
12614
  /** Encode and decode object with leading version number. */
12613
- const codecWithVersion = (val) => Descriptor.new("withVersion", {
12615
+ const codecWithVersion = (val) => descriptor_Descriptor.new("withVersion", {
12614
12616
  bytes: val.sizeHint.bytes + 8,
12615
12617
  isExact: false,
12616
12618
  }, (e, v) => {
@@ -12773,8 +12775,6 @@ class LookupHistoryItem {
12773
12775
 
12774
12776
 
12775
12777
 
12776
-
12777
-
12778
12778
  /**
12779
12779
  * Activity Record of a single validator.
12780
12780
  *
@@ -12905,42 +12905,20 @@ class ServiceStatistics {
12905
12905
  extrinsicCount;
12906
12906
  accumulateCount;
12907
12907
  accumulateGasUsed;
12908
- onTransfersCount;
12909
- onTransfersGasUsed;
12910
- static Codec = Compatibility.selectIfGreaterOrEqual({
12911
- fallback: codec_codec.Class(ServiceStatistics, {
12912
- providedCount: codecVarU16,
12913
- providedSize: codec_codec.varU32,
12914
- refinementCount: codec_codec.varU32,
12915
- refinementGasUsed: codecVarGas,
12916
- imports: codecVarU16,
12917
- extrinsicCount: codecVarU16,
12918
- extrinsicSize: codec_codec.varU32,
12919
- exports: codecVarU16,
12920
- accumulateCount: codec_codec.varU32,
12921
- accumulateGasUsed: codecVarGas,
12922
- onTransfersCount: codec_codec.varU32,
12923
- onTransfersGasUsed: codecVarGas,
12924
- }),
12925
- versions: {
12926
- [GpVersion.V0_7_1]: codec_codec.Class(ServiceStatistics, {
12927
- providedCount: codecVarU16,
12928
- providedSize: codec_codec.varU32,
12929
- refinementCount: codec_codec.varU32,
12930
- refinementGasUsed: codecVarGas,
12931
- imports: codecVarU16,
12932
- extrinsicCount: codecVarU16,
12933
- extrinsicSize: codec_codec.varU32,
12934
- exports: codecVarU16,
12935
- accumulateCount: codec_codec.varU32,
12936
- accumulateGasUsed: codecVarGas,
12937
- onTransfersCount: ignoreValueWithDefault(numbers_tryAsU32(0)),
12938
- onTransfersGasUsed: ignoreValueWithDefault(tryAsServiceGas(0)),
12939
- }),
12940
- },
12908
+ static Codec = codec_codec.Class(ServiceStatistics, {
12909
+ providedCount: codecVarU16,
12910
+ providedSize: codec_codec.varU32,
12911
+ refinementCount: codec_codec.varU32,
12912
+ refinementGasUsed: codecVarGas,
12913
+ imports: codecVarU16,
12914
+ extrinsicCount: codecVarU16,
12915
+ extrinsicSize: codec_codec.varU32,
12916
+ exports: codecVarU16,
12917
+ accumulateCount: codec_codec.varU32,
12918
+ accumulateGasUsed: codecVarGas,
12941
12919
  });
12942
12920
  static create(v) {
12943
- return new ServiceStatistics(v.providedCount, v.providedSize, v.refinementCount, v.refinementGasUsed, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.accumulateCount, v.accumulateGasUsed, v.onTransfersCount, v.onTransfersGasUsed);
12921
+ return new ServiceStatistics(v.providedCount, v.providedSize, v.refinementCount, v.refinementGasUsed, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.accumulateCount, v.accumulateGasUsed);
12944
12922
  }
12945
12923
  constructor(
12946
12924
  /** `p.0` */
@@ -12962,11 +12940,7 @@ class ServiceStatistics {
12962
12940
  /** `a.0` */
12963
12941
  accumulateCount,
12964
12942
  /** `a.1` */
12965
- accumulateGasUsed,
12966
- /** `t.0` @deprecated since 0.7.1 */
12967
- onTransfersCount,
12968
- /** `t.1` @deprecated since 0.7.1 */
12969
- onTransfersGasUsed) {
12943
+ accumulateGasUsed) {
12970
12944
  this.providedCount = providedCount;
12971
12945
  this.providedSize = providedSize;
12972
12946
  this.refinementCount = refinementCount;
@@ -12977,14 +12951,12 @@ class ServiceStatistics {
12977
12951
  this.extrinsicCount = extrinsicCount;
12978
12952
  this.accumulateCount = accumulateCount;
12979
12953
  this.accumulateGasUsed = accumulateGasUsed;
12980
- this.onTransfersCount = onTransfersCount;
12981
- this.onTransfersGasUsed = onTransfersGasUsed;
12982
12954
  }
12983
12955
  static empty() {
12984
12956
  const zero = numbers_tryAsU32(0);
12985
12957
  const zero16 = numbers_tryAsU16(0);
12986
12958
  const zeroGas = tryAsServiceGas(0);
12987
- return new ServiceStatistics(zero16, zero, zero, zeroGas, zero16, zero16, zero, zero16, zero, zeroGas, zero, zeroGas);
12959
+ return new ServiceStatistics(zero16, zero, zero, zeroGas, zero16, zero16, zero, zero16, zero, zeroGas);
12988
12960
  }
12989
12961
  }
12990
12962
  /** `pi`: Statistics of each validator, cores statistics and services statistics. */
@@ -13083,9 +13055,6 @@ class InMemoryStateView {
13083
13055
  ;// CONCATENATED MODULE: ./packages/jam/state/privileged-services.ts
13084
13056
 
13085
13057
 
13086
-
13087
-
13088
-
13089
13058
  /**
13090
13059
  * https://graypaper.fluffylabs.dev/#/ab2cdbd/114402114402?v=0.7.2
13091
13060
  */
@@ -13100,9 +13069,7 @@ class PrivilegedServices {
13100
13069
  manager: codec_codec.u32.asOpaque(),
13101
13070
  assigners: codecPerCore(codec_codec.u32.asOpaque()),
13102
13071
  delegator: codec_codec.u32.asOpaque(),
13103
- registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
13104
- ? codec_codec.u32.asOpaque()
13105
- : ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
13072
+ registrar: codec_codec.u32.asOpaque(),
13106
13073
  autoAccumulateServices: codec_codec.dictionary(codec_codec.u32.asOpaque(), codec_codec.u64.asOpaque(), {
13107
13074
  sortKeys: (a, b) => a - b,
13108
13075
  }),
@@ -13817,7 +13784,7 @@ const serviceDataCodec = codec_codec.dictionary(codec_codec.u32.asOpaque(), serv
13817
13784
 
13818
13785
  class JsonServiceInfo {
13819
13786
  static fromJson = json.object({
13820
- ...(Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) ? { version: "number" } : {}),
13787
+ version: "number",
13821
13788
  code_hash: fromJson.bytes32(),
13822
13789
  balance: json.fromNumber((x) => numbers_tryAsU64(x)),
13823
13790
  min_item_gas: json.fromNumber((x) => tryAsServiceGas(x)),
@@ -13870,33 +13837,61 @@ class JsonStorageItem {
13870
13837
  key;
13871
13838
  value;
13872
13839
  }
13873
- const lookupMetaFromJson = json.object({
13840
+ const preimageStatusFromJson = json.object({
13874
13841
  key: {
13875
13842
  hash: fromJson.bytes32(),
13876
13843
  length: "number",
13877
13844
  },
13878
13845
  value: json.array("number"),
13879
- }, ({ key, value }) => new LookupHistoryItem(key.hash, key.length, value));
13880
- const preimageStatusFromJson = json.object({
13846
+ }, ({ key, value }) => new LookupHistoryItem(key.hash, numbers_tryAsU32(key.length), value));
13847
+ class JsonService {
13848
+ static fromJson = json.object({
13849
+ id: "number",
13850
+ data: {
13851
+ service: JsonServiceInfo.fromJson,
13852
+ storage: json.optional(json.array(JsonStorageItem.fromJson)),
13853
+ preimage_blobs: json.optional(json.array(JsonPreimageItem.fromJson)),
13854
+ preimage_requests: json.optional(json.array(preimageStatusFromJson)),
13855
+ },
13856
+ }, ({ id, data }) => {
13857
+ const preimages = HashDictionary.fromEntries((data.preimage_blobs ?? []).map((x) => [x.hash, x]));
13858
+ const lookupHistory = HashDictionary.new();
13859
+ for (const item of data.preimage_requests ?? []) {
13860
+ const data = lookupHistory.get(item.hash) ?? [];
13861
+ data.push(item);
13862
+ lookupHistory.set(item.hash, data);
13863
+ }
13864
+ const storage = new Map();
13865
+ const entries = (data.storage ?? []).map(({ key, value }) => {
13866
+ const opaqueKey = opaque_asOpaqueType(key);
13867
+ return [opaqueKey, StorageItem.create({ key: opaqueKey, value })];
13868
+ });
13869
+ for (const [key, item] of entries) {
13870
+ storage.set(key.toString(), item);
13871
+ }
13872
+ return new InMemoryService(id, {
13873
+ info: data.service,
13874
+ preimages,
13875
+ storage,
13876
+ lookupHistory,
13877
+ });
13878
+ });
13879
+ id;
13880
+ data;
13881
+ }
13882
+ const preimageStatusFromJson072 = json.object({
13881
13883
  hash: fromJson.bytes32(),
13882
13884
  status: json.array("number"),
13883
13885
  }, ({ hash, status }) => new LookupHistoryItem(hash, numbers_tryAsU32(0), status));
13884
- class JsonService {
13886
+ class JsonServicePre072 {
13885
13887
  static fromJson = json.object({
13886
13888
  id: "number",
13887
- data: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
13888
- ? {
13889
- service: JsonServiceInfo.fromJson,
13890
- storage: json.optional(json.array(JsonStorageItem.fromJson)),
13891
- preimages_blob: json.optional(json.array(JsonPreimageItem.fromJson)),
13892
- preimages_status: json.optional(json.array(preimageStatusFromJson)),
13893
- }
13894
- : {
13895
- service: JsonServiceInfo.fromJson,
13896
- preimages: json.optional(json.array(JsonPreimageItem.fromJson)),
13897
- storage: json.optional(json.array(JsonStorageItem.fromJson)),
13898
- lookup_meta: json.optional(json.array(lookupMetaFromJson)),
13899
- },
13889
+ data: {
13890
+ service: JsonServiceInfo.fromJson,
13891
+ storage: json.optional(json.array(JsonStorageItem.fromJson)),
13892
+ preimages_blob: json.optional(json.array(JsonPreimageItem.fromJson)),
13893
+ preimages_status: json.optional(json.array(preimageStatusFromJson072)),
13894
+ },
13900
13895
  }, ({ id, data }) => {
13901
13896
  const preimages = HashDictionary.fromEntries((data.preimages ?? data.preimages_blob ?? []).map((x) => [x.hash, x]));
13902
13897
  const lookupHistory = HashDictionary.new();
@@ -14055,8 +14050,6 @@ class TicketsOrKeys {
14055
14050
 
14056
14051
 
14057
14052
 
14058
-
14059
-
14060
14053
  class JsonValidatorStatistics {
14061
14054
  static fromJson = json.object({
14062
14055
  blocks: "number",
@@ -14125,13 +14118,7 @@ class JsonServiceStatistics {
14125
14118
  extrinsic_count: "number",
14126
14119
  accumulate_count: "number",
14127
14120
  accumulate_gas_used: json.fromBigInt(tryAsServiceGas),
14128
- ...(Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
14129
- ? {}
14130
- : {
14131
- on_transfers_count: "number",
14132
- on_transfers_gas_used: json.fromBigInt(tryAsServiceGas),
14133
- }),
14134
- }, ({ provided_count, provided_size, refinement_count, refinement_gas_used, imports, exports, extrinsic_size, extrinsic_count, accumulate_count, accumulate_gas_used, on_transfers_count, on_transfers_gas_used, }) => {
14121
+ }, ({ provided_count, provided_size, refinement_count, refinement_gas_used, imports, exports, extrinsic_size, extrinsic_count, accumulate_count, accumulate_gas_used, }) => {
14135
14122
  return ServiceStatistics.create({
14136
14123
  providedCount: provided_count,
14137
14124
  providedSize: provided_size,
@@ -14143,8 +14130,6 @@ class JsonServiceStatistics {
14143
14130
  extrinsicCount: extrinsic_count,
14144
14131
  accumulateCount: accumulate_count,
14145
14132
  accumulateGasUsed: accumulate_gas_used,
14146
- onTransfersCount: on_transfers_count ?? numbers_tryAsU32(0),
14147
- onTransfersGasUsed: on_transfers_gas_used ?? tryAsServiceGas(0),
14148
14133
  });
14149
14134
  });
14150
14135
  provided_count;
@@ -14157,8 +14142,6 @@ class JsonServiceStatistics {
14157
14142
  extrinsic_count;
14158
14143
  accumulate_count;
14159
14144
  accumulate_gas_used;
14160
- on_transfers_count;
14161
- on_transfers_gas_used;
14162
14145
  }
14163
14146
  const serviceStatisticsEntryFromJson = {
14164
14147
  id: "number",
@@ -14217,7 +14200,6 @@ const validatorDataFromJson = json.object({
14217
14200
 
14218
14201
 
14219
14202
 
14220
-
14221
14203
  const fullStateDumpFromJson = (spec) => json.object({
14222
14204
  alpha: json.array(json.array(fromJson.bytes32())),
14223
14205
  varphi: json.array(json.array(fromJson.bytes32())),
@@ -14239,18 +14221,15 @@ const fullStateDumpFromJson = (spec) => json.object({
14239
14221
  chi_m: "number",
14240
14222
  chi_a: json.array("number"),
14241
14223
  chi_v: "number",
14242
- chi_r: json.optional("number"),
14224
+ chi_r: "number",
14243
14225
  chi_g: json.nullable(json.map("number", json.fromNumber((v) => tryAsServiceGas(v)))),
14244
14226
  },
14245
14227
  pi: JsonStatisticsData.fromJson,
14246
14228
  omega: json.array(json.array(notYetAccumulatedFromJson)),
14247
14229
  xi: json.array(json.array(fromJson.bytes32())),
14248
14230
  theta: json.nullable(json.array(accumulationOutput)),
14249
- accounts: json.array(JsonService.fromJson),
14231
+ accounts: json.array(JsonServicePre072.fromJson),
14250
14232
  }, ({ alpha, varphi, beta, gamma, psi, eta, iota, kappa, lambda, rho, tau, chi, pi, omega, xi, theta, accounts, }) => {
14251
- if (Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) && chi.chi_r === undefined) {
14252
- throw new Error("Registrar is required in Privileges GP ^0.7.1");
14253
- }
14254
14233
  return InMemoryState.new(spec, {
14255
14234
  authPools: tryAsPerCore(alpha.map((perCore) => {
14256
14235
  if (perCore.length > MAX_AUTH_POOL_SIZE) {
@@ -14280,7 +14259,7 @@ const fullStateDumpFromJson = (spec) => json.object({
14280
14259
  manager: chi.chi_m,
14281
14260
  assigners: chi.chi_a,
14282
14261
  delegator: chi.chi_v,
14283
- registrar: chi.chi_r ?? tryAsServiceId(2 ** 32 - 1),
14262
+ registrar: chi.chi_r,
14284
14263
  autoAccumulateServices: chi.chi_g ?? new Map(),
14285
14264
  }),
14286
14265
  statistics: JsonStatisticsData.toStatisticsData(spec, pi),
@@ -14456,7 +14435,6 @@ function legacyServiceNested(serviceId, hash) {
14456
14435
 
14457
14436
 
14458
14437
 
14459
-
14460
14438
  /** Serialization for particular state entries. */
14461
14439
  var serialize_serialize;
14462
14440
  (function (serialize) {
@@ -14564,24 +14542,22 @@ var serialize_serialize;
14564
14542
  Codec: codec_codec.sequenceVarLen(AccumulationOutput.Codec).convert((i) => i.array, (o) => SortedArray.fromSortedArray(accumulationOutputComparator, o)),
14565
14543
  extract: (s) => s.accumulationOutputLog,
14566
14544
  };
14567
- /** C(255, s): https://graypaper.fluffylabs.dev/#/85129da/383103383103?v=0.6.3 */
14545
+ /** C(255, s): https://graypaper.fluffylabs.dev/#/ab2cdbd/3b7d033b7d03?v=0.7.2 */
14568
14546
  serialize.serviceData = (serviceId) => ({
14569
14547
  key: stateKeys.serviceInfo(serviceId),
14570
- Codec: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
14571
- ? codecWithVersion(ServiceAccountInfo.Codec)
14572
- : ServiceAccountInfo.Codec,
14548
+ Codec: codecWithVersion(ServiceAccountInfo.Codec),
14573
14549
  });
14574
- /** https://graypaper.fluffylabs.dev/#/85129da/384803384803?v=0.6.3 */
14550
+ /** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bac033bac03?v=0.7.2 */
14575
14551
  serialize.serviceStorage = (blake2b, serviceId, key) => ({
14576
14552
  key: stateKeys.serviceStorage(blake2b, serviceId, key),
14577
14553
  Codec: dumpCodec,
14578
14554
  });
14579
- /** https://graypaper.fluffylabs.dev/#/85129da/385b03385b03?v=0.6.3 */
14555
+ /** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bc9033bc903?v=0.7.2 */
14580
14556
  serialize.servicePreimages = (blake2b, serviceId, hash) => ({
14581
14557
  key: stateKeys.servicePreimage(blake2b, serviceId, hash),
14582
14558
  Codec: dumpCodec,
14583
14559
  });
14584
- /** https://graypaper.fluffylabs.dev/#/85129da/387603387603?v=0.6.3 */
14560
+ /** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bea033b0904?v=0.7.2 */
14585
14561
  serialize.serviceLookupHistory = (blake2b, serviceId, hash, len) => ({
14586
14562
  key: stateKeys.serviceLookupHistory(blake2b, serviceId, hash, len),
14587
14563
  Codec: codec_codec.readonlyArray(codec_codec.sequenceVarLen(codec_codec.u32)),
@@ -14594,7 +14570,7 @@ var serialize_serialize;
14594
14570
  * determine the boundary of the bytes, so it can only be used
14595
14571
  * as the last element of the codec and can't be used in sequences!
14596
14572
  */
14597
- const dumpCodec = Descriptor.new("Dump", { bytes: 64, isExact: false }, (e, v) => e.bytes(bytes_Bytes.fromBlob(v.raw, v.raw.length)), (d) => bytes_BytesBlob.blobFrom(d.bytes(d.source.length - d.bytesRead()).raw), (s) => s.bytes(s.decoder.source.length - s.decoder.bytesRead()));
14573
+ const dumpCodec = descriptor_Descriptor.new("Dump", { bytes: 64, isExact: false }, (e, v) => e.bytes(bytes_Bytes.fromBlob(v.raw, v.raw.length)), (d) => bytes_BytesBlob.blobFrom(d.bytes(d.source.length - d.bytesRead()).raw), (s) => s.bytes(s.decoder.source.length - s.decoder.bytesRead()));
14598
14574
 
14599
14575
  ;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialized-state-view.ts
14600
14576
 
@@ -15922,7 +15898,7 @@ const codecMap = (value, extractKey, { typicalLength = codec_codec.TYPICAL_DICTI
15922
15898
  }
15923
15899
  return Ordering.Equal;
15924
15900
  }, } = {}) => {
15925
- return Descriptor.new(`Map<${value.name}>[?]`, {
15901
+ return descriptor_Descriptor.new(`Map<${value.name}>[?]`, {
15926
15902
  bytes: typicalLength * value.sizeHint.bytes,
15927
15903
  isExact: false,
15928
15904
  }, (e, v) => {
@@ -16181,41 +16157,21 @@ async function runWorkItemTest(test, { path }) {
16181
16157
 
16182
16158
 
16183
16159
 
16184
-
16185
- const authorizerFromJson = {
16186
- code_hash: fromJson.bytes32(),
16187
- params: json.fromString(bytes_BytesBlob.parseBlob),
16188
- };
16189
- const workPackageFromJson = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
16190
- ? json.object({
16191
- authorization: json.fromString(bytes_BytesBlob.parseBlob),
16192
- auth_code_host: "number",
16193
- auth_code_hash: fromJson.bytes32(),
16194
- authorizer_config: json.fromString(bytes_BytesBlob.parseBlob),
16195
- context: refineContextFromJson,
16196
- items: json.array(workItemFromJson),
16197
- }, ({ authorization, auth_code_host, auth_code_hash, authorizer_config, context, items }) => work_package_WorkPackage.create({
16198
- authorization,
16199
- authCodeHost: auth_code_host,
16200
- authCodeHash: auth_code_hash,
16201
- parametrization: authorizer_config,
16202
- context,
16203
- items: FixedSizeArray.new(items, tryAsWorkItemsCount(items.length)),
16204
- }))
16205
- : json.object({
16206
- authorization: json.fromString(bytes_BytesBlob.parseBlob),
16207
- auth_code_host: "number",
16208
- authorizer: authorizerFromJson,
16209
- context: refineContextFromJson,
16210
- items: json.array(workItemFromJson),
16211
- }, ({ authorization, auth_code_host, authorizer, context, items }) => work_package_WorkPackage.create({
16212
- authorization,
16213
- authCodeHost: auth_code_host,
16214
- authCodeHash: authorizer.code_hash,
16215
- parametrization: authorizer.params,
16216
- context,
16217
- items: FixedSizeArray.new(items, tryAsWorkItemsCount(items.length)),
16218
- }));
16160
+ const workPackageFromJson = json.object({
16161
+ authorization: json.fromString(bytes_BytesBlob.parseBlob),
16162
+ auth_code_host: "number",
16163
+ auth_code_hash: fromJson.bytes32(),
16164
+ authorizer_config: json.fromString(bytes_BytesBlob.parseBlob),
16165
+ context: refineContextFromJson,
16166
+ items: json.array(workItemFromJson),
16167
+ }, ({ authorization, auth_code_host, auth_code_hash, authorizer_config, context, items }) => work_package_WorkPackage.create({
16168
+ authorization,
16169
+ authCodeHost: auth_code_host,
16170
+ authCodeHash: auth_code_hash,
16171
+ parametrization: authorizer_config,
16172
+ context,
16173
+ items: FixedSizeArray.new(items, tryAsWorkItemsCount(items.length)),
16174
+ }));
16219
16175
  async function runWorkPackageTest(test, { path: file }) {
16220
16176
  runCodecTest(WorkPackage.Codec, test, file);
16221
16177
  }