@typeberry/convert 0.5.3-fb6e98a → 0.5.4-472e282

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.3"};
4958
+ const package_namespaceObject = {"rE":"0.5.4"};
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) => {
@@ -9752,14 +9751,18 @@ class work_item_WorkItem extends WithDebug {
9752
9751
 
9753
9752
 
9754
9753
 
9755
- /** Verify the value is within the `WorkItemsCount` bounds. */
9754
+ /** Convert the value to `WorkItemsCount` bounds. */
9756
9755
  function tryAsWorkItemsCount(len) {
9757
9756
  debug_check `
9758
- ${len >= MIN_NUMBER_OF_WORK_ITEMS && len <= work_package_MAX_NUMBER_OF_WORK_ITEMS}
9757
+ ${isWorkItemsCount(len)}
9759
9758
  WorkItemsCount: Expected '${MIN_NUMBER_OF_WORK_ITEMS} <= count <= ${work_package_MAX_NUMBER_OF_WORK_ITEMS}' got ${len}
9760
9759
  `;
9761
9760
  return tryAsU8(len);
9762
9761
  }
9762
+ /** Verify the value is within the `WorkItemsCount` bounds. */
9763
+ function isWorkItemsCount(len) {
9764
+ return len >= MIN_NUMBER_OF_WORK_ITEMS && len <= work_package_MAX_NUMBER_OF_WORK_ITEMS;
9765
+ }
9763
9766
  /** Minimal number of work items in the work package or results in work report. */
9764
9767
  const MIN_NUMBER_OF_WORK_ITEMS = 1;
9765
9768
  /** `I`: Maximal number of work items in the work package or results in work report. */
@@ -11169,6 +11172,13 @@ const blockFromJson = (spec) => json.object({
11169
11172
  header: headerFromJson,
11170
11173
  extrinsic: getExtrinsicFromJson(spec),
11171
11174
  }, ({ header, extrinsic }) => Block.create({ header, extrinsic }));
11175
+ const blockViewFromJson = (spec) => {
11176
+ const parseBlock = blockFromJson(spec);
11177
+ return json.fromAny((p) => {
11178
+ const block = parse_parseFromJson(p, parseBlock);
11179
+ return reencodeAsView(Block.Codec, block, spec);
11180
+ });
11181
+ };
11172
11182
 
11173
11183
  ;// CONCATENATED MODULE: ./packages/jam/block-json/index.ts
11174
11184
 
@@ -11663,13 +11673,13 @@ const getStateCodec = codec_codec.bytes(hash_HASH_SIZE).asOpaque();
11663
11673
  /** StateRoot ::= StateRootHash */
11664
11674
  const stateRootCodec = codec_codec.bytes(hash_HASH_SIZE).asOpaque();
11665
11675
  /** Error ::= UTF8String */
11666
- class ErrorMessage extends WithDebug {
11676
+ class types_ErrorMessage extends WithDebug {
11667
11677
  message;
11668
- static Codec = codec_codec.Class(ErrorMessage, {
11678
+ static Codec = codec_codec.Class(types_ErrorMessage, {
11669
11679
  message: codec_codec.string,
11670
11680
  });
11671
11681
  static create({ message }) {
11672
- return new ErrorMessage(message);
11682
+ return new types_ErrorMessage(message);
11673
11683
  }
11674
11684
  constructor(message) {
11675
11685
  super();
@@ -11723,7 +11733,7 @@ const types_messageCodec = codec_codec.custom({
11723
11733
  stateCodec.encode(e, msg.value);
11724
11734
  break;
11725
11735
  case types_MessageType.Error:
11726
- ErrorMessage.Codec.encode(e, msg.value);
11736
+ types_ErrorMessage.Codec.encode(e, msg.value);
11727
11737
  break;
11728
11738
  default:
11729
11739
  throw new Error(`Unknown message type: ${msg}`);
@@ -11744,7 +11754,7 @@ const types_messageCodec = codec_codec.custom({
11744
11754
  case types_MessageType.State:
11745
11755
  return { type: types_MessageType.State, value: stateCodec.decode(d) };
11746
11756
  case types_MessageType.Error:
11747
- return { type: types_MessageType.Error, value: ErrorMessage.Codec.decode(d) };
11757
+ return { type: types_MessageType.Error, value: types_ErrorMessage.Codec.decode(d) };
11748
11758
  default:
11749
11759
  throw new Error(`Unknown message type: ${type}`);
11750
11760
  }
@@ -11770,7 +11780,7 @@ const types_messageCodec = codec_codec.custom({
11770
11780
  stateCodec.View.skip(s);
11771
11781
  break;
11772
11782
  case types_MessageType.Error:
11773
- ErrorMessage.Codec.View.skip(s);
11783
+ types_ErrorMessage.Codec.View.skip(s);
11774
11784
  break;
11775
11785
  default:
11776
11786
  throw new Error(`Unknown message type: ${type}`);
@@ -11833,35 +11843,59 @@ class FuzzTarget {
11833
11843
  break;
11834
11844
  }
11835
11845
  case MessageType.Initialize: {
11836
- const stateRoot = await this.msgHandler.initialize(message.value);
11837
- response = {
11838
- type: MessageType.StateRoot,
11839
- value: stateRoot,
11840
- };
11841
- break;
11842
- }
11843
- case MessageType.ImportBlock: {
11844
- const result = await this.msgHandler.importBlock(message.value);
11845
- if (result.isOk) {
11846
+ try {
11847
+ const stateRoot = await this.msgHandler.initialize(message.value);
11846
11848
  response = {
11847
11849
  type: MessageType.StateRoot,
11848
- value: result.ok,
11850
+ value: stateRoot,
11849
11851
  };
11850
11852
  }
11851
- else {
11853
+ catch (e) {
11852
11854
  response = {
11853
11855
  type: MessageType.Error,
11854
- value: result.error,
11856
+ value: ErrorMessage.create({ message: `initialize error: ${e}` }),
11857
+ };
11858
+ }
11859
+ break;
11860
+ }
11861
+ case MessageType.ImportBlock: {
11862
+ try {
11863
+ const result = await this.msgHandler.importBlock(message.value);
11864
+ if (result.isOk) {
11865
+ response = {
11866
+ type: MessageType.StateRoot,
11867
+ value: result.ok,
11868
+ };
11869
+ }
11870
+ else {
11871
+ response = {
11872
+ type: MessageType.Error,
11873
+ value: result.error,
11874
+ };
11875
+ }
11876
+ }
11877
+ catch (e) {
11878
+ response = {
11879
+ type: MessageType.Error,
11880
+ value: ErrorMessage.create({ message: `importBlock error: ${e}` }),
11855
11881
  };
11856
11882
  }
11857
11883
  break;
11858
11884
  }
11859
11885
  case MessageType.GetState: {
11860
- const state = await this.msgHandler.getSerializedState(message.value);
11861
- response = {
11862
- type: MessageType.State,
11863
- value: state,
11864
- };
11886
+ try {
11887
+ const state = await this.msgHandler.getSerializedState(message.value);
11888
+ response = {
11889
+ type: MessageType.State,
11890
+ value: state,
11891
+ };
11892
+ }
11893
+ catch (e) {
11894
+ response = {
11895
+ type: MessageType.Error,
11896
+ value: ErrorMessage.create({ message: `getState error: ${e}` }),
11897
+ };
11898
+ }
11865
11899
  break;
11866
11900
  }
11867
11901
  case MessageType.StateRoot: {
@@ -12575,7 +12609,7 @@ const zeroSizeHint = {
12575
12609
  /** 0-byte read, return given default value */
12576
12610
  const ignoreValueWithDefault = (defaultValue) => Descriptor.new("ignoreValue", zeroSizeHint, (_e, _v) => { }, (_d) => defaultValue, (_s) => { });
12577
12611
  /** Encode and decode object with leading version number. */
12578
- const codecWithVersion = (val) => Descriptor.new("withVersion", {
12612
+ const codecWithVersion = (val) => descriptor_Descriptor.new("withVersion", {
12579
12613
  bytes: val.sizeHint.bytes + 8,
12580
12614
  isExact: false,
12581
12615
  }, (e, v) => {
@@ -12738,8 +12772,6 @@ class LookupHistoryItem {
12738
12772
 
12739
12773
 
12740
12774
 
12741
-
12742
-
12743
12775
  /**
12744
12776
  * Activity Record of a single validator.
12745
12777
  *
@@ -12870,42 +12902,20 @@ class ServiceStatistics {
12870
12902
  extrinsicCount;
12871
12903
  accumulateCount;
12872
12904
  accumulateGasUsed;
12873
- onTransfersCount;
12874
- onTransfersGasUsed;
12875
- static Codec = Compatibility.selectIfGreaterOrEqual({
12876
- fallback: codec_codec.Class(ServiceStatistics, {
12877
- providedCount: codecVarU16,
12878
- providedSize: codec_codec.varU32,
12879
- refinementCount: codec_codec.varU32,
12880
- refinementGasUsed: codecVarGas,
12881
- imports: codecVarU16,
12882
- extrinsicCount: codecVarU16,
12883
- extrinsicSize: codec_codec.varU32,
12884
- exports: codecVarU16,
12885
- accumulateCount: codec_codec.varU32,
12886
- accumulateGasUsed: codecVarGas,
12887
- onTransfersCount: codec_codec.varU32,
12888
- onTransfersGasUsed: codecVarGas,
12889
- }),
12890
- versions: {
12891
- [GpVersion.V0_7_1]: codec_codec.Class(ServiceStatistics, {
12892
- providedCount: codecVarU16,
12893
- providedSize: codec_codec.varU32,
12894
- refinementCount: codec_codec.varU32,
12895
- refinementGasUsed: codecVarGas,
12896
- imports: codecVarU16,
12897
- extrinsicCount: codecVarU16,
12898
- extrinsicSize: codec_codec.varU32,
12899
- exports: codecVarU16,
12900
- accumulateCount: codec_codec.varU32,
12901
- accumulateGasUsed: codecVarGas,
12902
- onTransfersCount: ignoreValueWithDefault(numbers_tryAsU32(0)),
12903
- onTransfersGasUsed: ignoreValueWithDefault(tryAsServiceGas(0)),
12904
- }),
12905
- },
12905
+ static Codec = codec_codec.Class(ServiceStatistics, {
12906
+ providedCount: codecVarU16,
12907
+ providedSize: codec_codec.varU32,
12908
+ refinementCount: codec_codec.varU32,
12909
+ refinementGasUsed: codecVarGas,
12910
+ imports: codecVarU16,
12911
+ extrinsicCount: codecVarU16,
12912
+ extrinsicSize: codec_codec.varU32,
12913
+ exports: codecVarU16,
12914
+ accumulateCount: codec_codec.varU32,
12915
+ accumulateGasUsed: codecVarGas,
12906
12916
  });
12907
12917
  static create(v) {
12908
- 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);
12918
+ return new ServiceStatistics(v.providedCount, v.providedSize, v.refinementCount, v.refinementGasUsed, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.accumulateCount, v.accumulateGasUsed);
12909
12919
  }
12910
12920
  constructor(
12911
12921
  /** `p.0` */
@@ -12927,11 +12937,7 @@ class ServiceStatistics {
12927
12937
  /** `a.0` */
12928
12938
  accumulateCount,
12929
12939
  /** `a.1` */
12930
- accumulateGasUsed,
12931
- /** `t.0` @deprecated since 0.7.1 */
12932
- onTransfersCount,
12933
- /** `t.1` @deprecated since 0.7.1 */
12934
- onTransfersGasUsed) {
12940
+ accumulateGasUsed) {
12935
12941
  this.providedCount = providedCount;
12936
12942
  this.providedSize = providedSize;
12937
12943
  this.refinementCount = refinementCount;
@@ -12942,14 +12948,12 @@ class ServiceStatistics {
12942
12948
  this.extrinsicCount = extrinsicCount;
12943
12949
  this.accumulateCount = accumulateCount;
12944
12950
  this.accumulateGasUsed = accumulateGasUsed;
12945
- this.onTransfersCount = onTransfersCount;
12946
- this.onTransfersGasUsed = onTransfersGasUsed;
12947
12951
  }
12948
12952
  static empty() {
12949
12953
  const zero = numbers_tryAsU32(0);
12950
12954
  const zero16 = numbers_tryAsU16(0);
12951
12955
  const zeroGas = tryAsServiceGas(0);
12952
- return new ServiceStatistics(zero16, zero, zero, zeroGas, zero16, zero16, zero, zero16, zero, zeroGas, zero, zeroGas);
12956
+ return new ServiceStatistics(zero16, zero, zero, zeroGas, zero16, zero16, zero, zero16, zero, zeroGas);
12953
12957
  }
12954
12958
  }
12955
12959
  /** `pi`: Statistics of each validator, cores statistics and services statistics. */
@@ -13048,9 +13052,6 @@ class InMemoryStateView {
13048
13052
  ;// CONCATENATED MODULE: ./packages/jam/state/privileged-services.ts
13049
13053
 
13050
13054
 
13051
-
13052
-
13053
-
13054
13055
  /**
13055
13056
  * https://graypaper.fluffylabs.dev/#/ab2cdbd/114402114402?v=0.7.2
13056
13057
  */
@@ -13065,9 +13066,7 @@ class PrivilegedServices {
13065
13066
  manager: codec_codec.u32.asOpaque(),
13066
13067
  assigners: codecPerCore(codec_codec.u32.asOpaque()),
13067
13068
  delegator: codec_codec.u32.asOpaque(),
13068
- registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
13069
- ? codec_codec.u32.asOpaque()
13070
- : ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
13069
+ registrar: codec_codec.u32.asOpaque(),
13071
13070
  autoAccumulateServices: codec_codec.dictionary(codec_codec.u32.asOpaque(), codec_codec.u64.asOpaque(), {
13072
13071
  sortKeys: (a, b) => a - b,
13073
13072
  }),
@@ -13782,7 +13781,7 @@ const serviceDataCodec = codec_codec.dictionary(codec_codec.u32.asOpaque(), serv
13782
13781
 
13783
13782
  class JsonServiceInfo {
13784
13783
  static fromJson = json.object({
13785
- ...(Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) ? { version: "number" } : {}),
13784
+ version: "number",
13786
13785
  code_hash: fromJson.bytes32(),
13787
13786
  balance: json.fromNumber((x) => numbers_tryAsU64(x)),
13788
13787
  min_item_gas: json.fromNumber((x) => tryAsServiceGas(x)),
@@ -13835,33 +13834,61 @@ class JsonStorageItem {
13835
13834
  key;
13836
13835
  value;
13837
13836
  }
13838
- const lookupMetaFromJson = json.object({
13837
+ const preimageStatusFromJson = json.object({
13839
13838
  key: {
13840
13839
  hash: fromJson.bytes32(),
13841
13840
  length: "number",
13842
13841
  },
13843
13842
  value: json.array("number"),
13844
- }, ({ key, value }) => new LookupHistoryItem(key.hash, key.length, value));
13845
- const preimageStatusFromJson = json.object({
13843
+ }, ({ key, value }) => new LookupHistoryItem(key.hash, numbers_tryAsU32(key.length), value));
13844
+ class JsonService {
13845
+ static fromJson = json.object({
13846
+ id: "number",
13847
+ data: {
13848
+ service: JsonServiceInfo.fromJson,
13849
+ storage: json.optional(json.array(JsonStorageItem.fromJson)),
13850
+ preimage_blobs: json.optional(json.array(JsonPreimageItem.fromJson)),
13851
+ preimage_requests: json.optional(json.array(preimageStatusFromJson)),
13852
+ },
13853
+ }, ({ id, data }) => {
13854
+ const preimages = HashDictionary.fromEntries((data.preimage_blobs ?? []).map((x) => [x.hash, x]));
13855
+ const lookupHistory = HashDictionary.new();
13856
+ for (const item of data.preimage_requests ?? []) {
13857
+ const data = lookupHistory.get(item.hash) ?? [];
13858
+ data.push(item);
13859
+ lookupHistory.set(item.hash, data);
13860
+ }
13861
+ const storage = new Map();
13862
+ const entries = (data.storage ?? []).map(({ key, value }) => {
13863
+ const opaqueKey = opaque_asOpaqueType(key);
13864
+ return [opaqueKey, StorageItem.create({ key: opaqueKey, value })];
13865
+ });
13866
+ for (const [key, item] of entries) {
13867
+ storage.set(key.toString(), item);
13868
+ }
13869
+ return new InMemoryService(id, {
13870
+ info: data.service,
13871
+ preimages,
13872
+ storage,
13873
+ lookupHistory,
13874
+ });
13875
+ });
13876
+ id;
13877
+ data;
13878
+ }
13879
+ const preimageStatusFromJson072 = json.object({
13846
13880
  hash: fromJson.bytes32(),
13847
13881
  status: json.array("number"),
13848
13882
  }, ({ hash, status }) => new LookupHistoryItem(hash, numbers_tryAsU32(0), status));
13849
- class JsonService {
13883
+ class JsonServicePre072 {
13850
13884
  static fromJson = json.object({
13851
13885
  id: "number",
13852
- data: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
13853
- ? {
13854
- service: JsonServiceInfo.fromJson,
13855
- storage: json.optional(json.array(JsonStorageItem.fromJson)),
13856
- preimages_blob: json.optional(json.array(JsonPreimageItem.fromJson)),
13857
- preimages_status: json.optional(json.array(preimageStatusFromJson)),
13858
- }
13859
- : {
13860
- service: JsonServiceInfo.fromJson,
13861
- preimages: json.optional(json.array(JsonPreimageItem.fromJson)),
13862
- storage: json.optional(json.array(JsonStorageItem.fromJson)),
13863
- lookup_meta: json.optional(json.array(lookupMetaFromJson)),
13864
- },
13886
+ data: {
13887
+ service: JsonServiceInfo.fromJson,
13888
+ storage: json.optional(json.array(JsonStorageItem.fromJson)),
13889
+ preimages_blob: json.optional(json.array(JsonPreimageItem.fromJson)),
13890
+ preimages_status: json.optional(json.array(preimageStatusFromJson072)),
13891
+ },
13865
13892
  }, ({ id, data }) => {
13866
13893
  const preimages = HashDictionary.fromEntries((data.preimages ?? data.preimages_blob ?? []).map((x) => [x.hash, x]));
13867
13894
  const lookupHistory = HashDictionary.new();
@@ -14020,8 +14047,6 @@ class TicketsOrKeys {
14020
14047
 
14021
14048
 
14022
14049
 
14023
-
14024
-
14025
14050
  class JsonValidatorStatistics {
14026
14051
  static fromJson = json.object({
14027
14052
  blocks: "number",
@@ -14090,13 +14115,7 @@ class JsonServiceStatistics {
14090
14115
  extrinsic_count: "number",
14091
14116
  accumulate_count: "number",
14092
14117
  accumulate_gas_used: json.fromBigInt(tryAsServiceGas),
14093
- ...(Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
14094
- ? {}
14095
- : {
14096
- on_transfers_count: "number",
14097
- on_transfers_gas_used: json.fromBigInt(tryAsServiceGas),
14098
- }),
14099
- }, ({ 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, }) => {
14118
+ }, ({ provided_count, provided_size, refinement_count, refinement_gas_used, imports, exports, extrinsic_size, extrinsic_count, accumulate_count, accumulate_gas_used, }) => {
14100
14119
  return ServiceStatistics.create({
14101
14120
  providedCount: provided_count,
14102
14121
  providedSize: provided_size,
@@ -14108,8 +14127,6 @@ class JsonServiceStatistics {
14108
14127
  extrinsicCount: extrinsic_count,
14109
14128
  accumulateCount: accumulate_count,
14110
14129
  accumulateGasUsed: accumulate_gas_used,
14111
- onTransfersCount: on_transfers_count ?? numbers_tryAsU32(0),
14112
- onTransfersGasUsed: on_transfers_gas_used ?? tryAsServiceGas(0),
14113
14130
  });
14114
14131
  });
14115
14132
  provided_count;
@@ -14122,8 +14139,6 @@ class JsonServiceStatistics {
14122
14139
  extrinsic_count;
14123
14140
  accumulate_count;
14124
14141
  accumulate_gas_used;
14125
- on_transfers_count;
14126
- on_transfers_gas_used;
14127
14142
  }
14128
14143
  const serviceStatisticsEntryFromJson = {
14129
14144
  id: "number",
@@ -14182,7 +14197,6 @@ const validatorDataFromJson = json.object({
14182
14197
 
14183
14198
 
14184
14199
 
14185
-
14186
14200
  const fullStateDumpFromJson = (spec) => json.object({
14187
14201
  alpha: json.array(json.array(fromJson.bytes32())),
14188
14202
  varphi: json.array(json.array(fromJson.bytes32())),
@@ -14204,18 +14218,15 @@ const fullStateDumpFromJson = (spec) => json.object({
14204
14218
  chi_m: "number",
14205
14219
  chi_a: json.array("number"),
14206
14220
  chi_v: "number",
14207
- chi_r: json.optional("number"),
14221
+ chi_r: "number",
14208
14222
  chi_g: json.nullable(json.map("number", json.fromNumber((v) => tryAsServiceGas(v)))),
14209
14223
  },
14210
14224
  pi: JsonStatisticsData.fromJson,
14211
14225
  omega: json.array(json.array(notYetAccumulatedFromJson)),
14212
14226
  xi: json.array(json.array(fromJson.bytes32())),
14213
14227
  theta: json.nullable(json.array(accumulationOutput)),
14214
- accounts: json.array(JsonService.fromJson),
14228
+ accounts: json.array(JsonServicePre072.fromJson),
14215
14229
  }, ({ alpha, varphi, beta, gamma, psi, eta, iota, kappa, lambda, rho, tau, chi, pi, omega, xi, theta, accounts, }) => {
14216
- if (Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) && chi.chi_r === undefined) {
14217
- throw new Error("Registrar is required in Privileges GP ^0.7.1");
14218
- }
14219
14230
  return InMemoryState.new(spec, {
14220
14231
  authPools: tryAsPerCore(alpha.map((perCore) => {
14221
14232
  if (perCore.length > MAX_AUTH_POOL_SIZE) {
@@ -14245,7 +14256,7 @@ const fullStateDumpFromJson = (spec) => json.object({
14245
14256
  manager: chi.chi_m,
14246
14257
  assigners: chi.chi_a,
14247
14258
  delegator: chi.chi_v,
14248
- registrar: chi.chi_r ?? tryAsServiceId(2 ** 32 - 1),
14259
+ registrar: chi.chi_r,
14249
14260
  autoAccumulateServices: chi.chi_g ?? new Map(),
14250
14261
  }),
14251
14262
  statistics: JsonStatisticsData.toStatisticsData(spec, pi),
@@ -14421,7 +14432,6 @@ function legacyServiceNested(serviceId, hash) {
14421
14432
 
14422
14433
 
14423
14434
 
14424
-
14425
14435
  /** Serialization for particular state entries. */
14426
14436
  var serialize_serialize;
14427
14437
  (function (serialize) {
@@ -14529,24 +14539,22 @@ var serialize_serialize;
14529
14539
  Codec: codec_codec.sequenceVarLen(AccumulationOutput.Codec).convert((i) => i.array, (o) => SortedArray.fromSortedArray(accumulationOutputComparator, o)),
14530
14540
  extract: (s) => s.accumulationOutputLog,
14531
14541
  };
14532
- /** C(255, s): https://graypaper.fluffylabs.dev/#/85129da/383103383103?v=0.6.3 */
14542
+ /** C(255, s): https://graypaper.fluffylabs.dev/#/ab2cdbd/3b7d033b7d03?v=0.7.2 */
14533
14543
  serialize.serviceData = (serviceId) => ({
14534
14544
  key: stateKeys.serviceInfo(serviceId),
14535
- Codec: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
14536
- ? codecWithVersion(ServiceAccountInfo.Codec)
14537
- : ServiceAccountInfo.Codec,
14545
+ Codec: codecWithVersion(ServiceAccountInfo.Codec),
14538
14546
  });
14539
- /** https://graypaper.fluffylabs.dev/#/85129da/384803384803?v=0.6.3 */
14547
+ /** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bac033bac03?v=0.7.2 */
14540
14548
  serialize.serviceStorage = (blake2b, serviceId, key) => ({
14541
14549
  key: stateKeys.serviceStorage(blake2b, serviceId, key),
14542
14550
  Codec: dumpCodec,
14543
14551
  });
14544
- /** https://graypaper.fluffylabs.dev/#/85129da/385b03385b03?v=0.6.3 */
14552
+ /** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bc9033bc903?v=0.7.2 */
14545
14553
  serialize.servicePreimages = (blake2b, serviceId, hash) => ({
14546
14554
  key: stateKeys.servicePreimage(blake2b, serviceId, hash),
14547
14555
  Codec: dumpCodec,
14548
14556
  });
14549
- /** https://graypaper.fluffylabs.dev/#/85129da/387603387603?v=0.6.3 */
14557
+ /** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bea033b0904?v=0.7.2 */
14550
14558
  serialize.serviceLookupHistory = (blake2b, serviceId, hash, len) => ({
14551
14559
  key: stateKeys.serviceLookupHistory(blake2b, serviceId, hash, len),
14552
14560
  Codec: codec_codec.readonlyArray(codec_codec.sequenceVarLen(codec_codec.u32)),
@@ -14559,7 +14567,7 @@ var serialize_serialize;
14559
14567
  * determine the boundary of the bytes, so it can only be used
14560
14568
  * as the last element of the codec and can't be used in sequences!
14561
14569
  */
14562
- 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()));
14570
+ 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()));
14563
14571
 
14564
14572
  ;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialized-state-view.ts
14565
14573
 
@@ -15887,7 +15895,7 @@ const codecMap = (value, extractKey, { typicalLength = codec_codec.TYPICAL_DICTI
15887
15895
  }
15888
15896
  return Ordering.Equal;
15889
15897
  }, } = {}) => {
15890
- return Descriptor.new(`Map<${value.name}>[?]`, {
15898
+ return descriptor_Descriptor.new(`Map<${value.name}>[?]`, {
15891
15899
  bytes: typicalLength * value.sizeHint.bytes,
15892
15900
  isExact: false,
15893
15901
  }, (e, v) => {
@@ -16064,11 +16072,11 @@ class StateTransition {
16064
16072
  static fromJson = {
16065
16073
  pre_state: TestState.fromJson,
16066
16074
  post_state: TestState.fromJson,
16067
- block: blockFromJson(chain_spec_tinyChainSpec),
16075
+ block: blockViewFromJson(chain_spec_tinyChainSpec),
16068
16076
  };
16069
16077
  static Codec = codec_codec.object({
16070
16078
  pre_state: TestState.Codec,
16071
- block: Block.Codec,
16079
+ block: Block.Codec.View,
16072
16080
  post_state: TestState.Codec,
16073
16081
  });
16074
16082
  pre_state;
@@ -16146,41 +16154,21 @@ async function runWorkItemTest(test, { path }) {
16146
16154
 
16147
16155
 
16148
16156
 
16149
-
16150
- const authorizerFromJson = {
16151
- code_hash: fromJson.bytes32(),
16152
- params: json.fromString(bytes_BytesBlob.parseBlob),
16153
- };
16154
- const workPackageFromJson = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
16155
- ? json.object({
16156
- authorization: json.fromString(bytes_BytesBlob.parseBlob),
16157
- auth_code_host: "number",
16158
- auth_code_hash: fromJson.bytes32(),
16159
- authorizer_config: json.fromString(bytes_BytesBlob.parseBlob),
16160
- context: refineContextFromJson,
16161
- items: json.array(workItemFromJson),
16162
- }, ({ authorization, auth_code_host, auth_code_hash, authorizer_config, context, items }) => work_package_WorkPackage.create({
16163
- authorization,
16164
- authCodeHost: auth_code_host,
16165
- authCodeHash: auth_code_hash,
16166
- parametrization: authorizer_config,
16167
- context,
16168
- items: FixedSizeArray.new(items, tryAsWorkItemsCount(items.length)),
16169
- }))
16170
- : json.object({
16171
- authorization: json.fromString(bytes_BytesBlob.parseBlob),
16172
- auth_code_host: "number",
16173
- authorizer: authorizerFromJson,
16174
- context: refineContextFromJson,
16175
- items: json.array(workItemFromJson),
16176
- }, ({ authorization, auth_code_host, authorizer, context, items }) => work_package_WorkPackage.create({
16177
- authorization,
16178
- authCodeHost: auth_code_host,
16179
- authCodeHash: authorizer.code_hash,
16180
- parametrization: authorizer.params,
16181
- context,
16182
- items: FixedSizeArray.new(items, tryAsWorkItemsCount(items.length)),
16183
- }));
16157
+ const workPackageFromJson = json.object({
16158
+ authorization: json.fromString(bytes_BytesBlob.parseBlob),
16159
+ auth_code_host: "number",
16160
+ auth_code_hash: fromJson.bytes32(),
16161
+ authorizer_config: json.fromString(bytes_BytesBlob.parseBlob),
16162
+ context: refineContextFromJson,
16163
+ items: json.array(workItemFromJson),
16164
+ }, ({ authorization, auth_code_host, auth_code_hash, authorizer_config, context, items }) => work_package_WorkPackage.create({
16165
+ authorization,
16166
+ authCodeHost: auth_code_host,
16167
+ authCodeHash: auth_code_hash,
16168
+ parametrization: authorizer_config,
16169
+ context,
16170
+ items: FixedSizeArray.new(items, tryAsWorkItemsCount(items.length)),
16171
+ }));
16184
16172
  async function runWorkPackageTest(test, { path: file }) {
16185
16173
  runCodecTest(WorkPackage.Codec, test, file);
16186
16174
  }
@@ -20272,7 +20260,7 @@ const SUPPORTED_TYPES = [
20272
20260
  if (option === "as-block") {
20273
20261
  return looseType({
20274
20262
  encode: Block.Codec,
20275
- value: test.block,
20263
+ value: test.block.materialize(),
20276
20264
  });
20277
20265
  }
20278
20266
  if (option === "as-fuzz-message") {
@@ -20280,11 +20268,9 @@ const SUPPORTED_TYPES = [
20280
20268
  console.warn("⚠️ Warning: 'as-fuzz-message' is deprecated and will be removed in version 0.6.0. Use 'as-block-fuzz-message' instead.");
20281
20269
  }
20282
20270
  if (option === "as-block-fuzz-message" || option === "as-fuzz-message") {
20283
- const encoded = encoder_Encoder.encodeObject(Block.Codec, test.block, spec);
20284
- const blockView = decoder_Decoder.decodeObject(Block.Codec.View, encoded, spec);
20285
20271
  const msg = {
20286
20272
  type: types_MessageType.ImportBlock,
20287
- value: blockView,
20273
+ value: test.block,
20288
20274
  };
20289
20275
  return looseType({
20290
20276
  value: msg,
@@ -20292,13 +20278,14 @@ const SUPPORTED_TYPES = [
20292
20278
  });
20293
20279
  }
20294
20280
  if (option === "as-state-fuzz-message") {
20281
+ const blockHeader = test.block.header.materialize();
20295
20282
  const init = Initialize.create({
20296
20283
  header: header_Header.empty(),
20297
20284
  keyvals: test.pre_state.keyvals,
20298
20285
  ancestry: [
20299
20286
  AncestryItem.create({
20300
- headerHash: test.block.header.parentHeaderHash,
20301
- slot: common_tryAsTimeSlot(Math.max(0, test.block.header.timeSlotIndex - 1)),
20287
+ headerHash: blockHeader.parentHeaderHash,
20288
+ slot: common_tryAsTimeSlot(Math.max(0, blockHeader.timeSlotIndex - 1)),
20302
20289
  }),
20303
20290
  ],
20304
20291
  });