@typeberry/convert 0.5.4-9233977 → 0.5.4-b8c8d3f

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/README.md CHANGED
@@ -17,7 +17,6 @@ the submitted code. By creating the PR you accept this requirement.**
17
17
 
18
18
  Gray Paper compliance can be controlled via `GP_VERSION` environment variable.
19
19
 
20
- - [x] 0.7.0
21
20
  - [x] 0.7.1
22
21
  - [x] 0.7.2
23
22
 
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;
@@ -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) => {
@@ -12610,7 +12609,7 @@ const zeroSizeHint = {
12610
12609
  /** 0-byte read, return given default value */
12611
12610
  const ignoreValueWithDefault = (defaultValue) => Descriptor.new("ignoreValue", zeroSizeHint, (_e, _v) => { }, (_d) => defaultValue, (_s) => { });
12612
12611
  /** Encode and decode object with leading version number. */
12613
- const codecWithVersion = (val) => Descriptor.new("withVersion", {
12612
+ const codecWithVersion = (val) => descriptor_Descriptor.new("withVersion", {
12614
12613
  bytes: val.sizeHint.bytes + 8,
12615
12614
  isExact: false,
12616
12615
  }, (e, v) => {
@@ -12773,8 +12772,6 @@ class LookupHistoryItem {
12773
12772
 
12774
12773
 
12775
12774
 
12776
-
12777
-
12778
12775
  /**
12779
12776
  * Activity Record of a single validator.
12780
12777
  *
@@ -12905,42 +12902,20 @@ class ServiceStatistics {
12905
12902
  extrinsicCount;
12906
12903
  accumulateCount;
12907
12904
  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
- },
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,
12941
12916
  });
12942
12917
  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);
12918
+ return new ServiceStatistics(v.providedCount, v.providedSize, v.refinementCount, v.refinementGasUsed, v.imports, v.exports, v.extrinsicSize, v.extrinsicCount, v.accumulateCount, v.accumulateGasUsed);
12944
12919
  }
12945
12920
  constructor(
12946
12921
  /** `p.0` */
@@ -12962,11 +12937,7 @@ class ServiceStatistics {
12962
12937
  /** `a.0` */
12963
12938
  accumulateCount,
12964
12939
  /** `a.1` */
12965
- accumulateGasUsed,
12966
- /** `t.0` @deprecated since 0.7.1 */
12967
- onTransfersCount,
12968
- /** `t.1` @deprecated since 0.7.1 */
12969
- onTransfersGasUsed) {
12940
+ accumulateGasUsed) {
12970
12941
  this.providedCount = providedCount;
12971
12942
  this.providedSize = providedSize;
12972
12943
  this.refinementCount = refinementCount;
@@ -12977,14 +12948,12 @@ class ServiceStatistics {
12977
12948
  this.extrinsicCount = extrinsicCount;
12978
12949
  this.accumulateCount = accumulateCount;
12979
12950
  this.accumulateGasUsed = accumulateGasUsed;
12980
- this.onTransfersCount = onTransfersCount;
12981
- this.onTransfersGasUsed = onTransfersGasUsed;
12982
12951
  }
12983
12952
  static empty() {
12984
12953
  const zero = numbers_tryAsU32(0);
12985
12954
  const zero16 = numbers_tryAsU16(0);
12986
12955
  const zeroGas = tryAsServiceGas(0);
12987
- 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);
12988
12957
  }
12989
12958
  }
12990
12959
  /** `pi`: Statistics of each validator, cores statistics and services statistics. */
@@ -13083,9 +13052,6 @@ class InMemoryStateView {
13083
13052
  ;// CONCATENATED MODULE: ./packages/jam/state/privileged-services.ts
13084
13053
 
13085
13054
 
13086
-
13087
-
13088
-
13089
13055
  /**
13090
13056
  * https://graypaper.fluffylabs.dev/#/ab2cdbd/114402114402?v=0.7.2
13091
13057
  */
@@ -13100,9 +13066,7 @@ class PrivilegedServices {
13100
13066
  manager: codec_codec.u32.asOpaque(),
13101
13067
  assigners: codecPerCore(codec_codec.u32.asOpaque()),
13102
13068
  delegator: codec_codec.u32.asOpaque(),
13103
- registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
13104
- ? codec_codec.u32.asOpaque()
13105
- : ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
13069
+ registrar: codec_codec.u32.asOpaque(),
13106
13070
  autoAccumulateServices: codec_codec.dictionary(codec_codec.u32.asOpaque(), codec_codec.u64.asOpaque(), {
13107
13071
  sortKeys: (a, b) => a - b,
13108
13072
  }),
@@ -13817,7 +13781,7 @@ const serviceDataCodec = codec_codec.dictionary(codec_codec.u32.asOpaque(), serv
13817
13781
 
13818
13782
  class JsonServiceInfo {
13819
13783
  static fromJson = json.object({
13820
- ...(Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) ? { version: "number" } : {}),
13784
+ version: "number",
13821
13785
  code_hash: fromJson.bytes32(),
13822
13786
  balance: json.fromNumber((x) => numbers_tryAsU64(x)),
13823
13787
  min_item_gas: json.fromNumber((x) => tryAsServiceGas(x)),
@@ -13870,33 +13834,61 @@ class JsonStorageItem {
13870
13834
  key;
13871
13835
  value;
13872
13836
  }
13873
- const lookupMetaFromJson = json.object({
13837
+ const preimageStatusFromJson = json.object({
13874
13838
  key: {
13875
13839
  hash: fromJson.bytes32(),
13876
13840
  length: "number",
13877
13841
  },
13878
13842
  value: json.array("number"),
13879
- }, ({ key, value }) => new LookupHistoryItem(key.hash, key.length, value));
13880
- 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({
13881
13880
  hash: fromJson.bytes32(),
13882
13881
  status: json.array("number"),
13883
13882
  }, ({ hash, status }) => new LookupHistoryItem(hash, numbers_tryAsU32(0), status));
13884
- class JsonService {
13883
+ class JsonServicePre072 {
13885
13884
  static fromJson = json.object({
13886
13885
  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
- },
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
+ },
13900
13892
  }, ({ id, data }) => {
13901
13893
  const preimages = HashDictionary.fromEntries((data.preimages ?? data.preimages_blob ?? []).map((x) => [x.hash, x]));
13902
13894
  const lookupHistory = HashDictionary.new();
@@ -14055,8 +14047,6 @@ class TicketsOrKeys {
14055
14047
 
14056
14048
 
14057
14049
 
14058
-
14059
-
14060
14050
  class JsonValidatorStatistics {
14061
14051
  static fromJson = json.object({
14062
14052
  blocks: "number",
@@ -14125,13 +14115,7 @@ class JsonServiceStatistics {
14125
14115
  extrinsic_count: "number",
14126
14116
  accumulate_count: "number",
14127
14117
  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, }) => {
14118
+ }, ({ provided_count, provided_size, refinement_count, refinement_gas_used, imports, exports, extrinsic_size, extrinsic_count, accumulate_count, accumulate_gas_used, }) => {
14135
14119
  return ServiceStatistics.create({
14136
14120
  providedCount: provided_count,
14137
14121
  providedSize: provided_size,
@@ -14143,8 +14127,6 @@ class JsonServiceStatistics {
14143
14127
  extrinsicCount: extrinsic_count,
14144
14128
  accumulateCount: accumulate_count,
14145
14129
  accumulateGasUsed: accumulate_gas_used,
14146
- onTransfersCount: on_transfers_count ?? numbers_tryAsU32(0),
14147
- onTransfersGasUsed: on_transfers_gas_used ?? tryAsServiceGas(0),
14148
14130
  });
14149
14131
  });
14150
14132
  provided_count;
@@ -14157,8 +14139,6 @@ class JsonServiceStatistics {
14157
14139
  extrinsic_count;
14158
14140
  accumulate_count;
14159
14141
  accumulate_gas_used;
14160
- on_transfers_count;
14161
- on_transfers_gas_used;
14162
14142
  }
14163
14143
  const serviceStatisticsEntryFromJson = {
14164
14144
  id: "number",
@@ -14217,7 +14197,6 @@ const validatorDataFromJson = json.object({
14217
14197
 
14218
14198
 
14219
14199
 
14220
-
14221
14200
  const fullStateDumpFromJson = (spec) => json.object({
14222
14201
  alpha: json.array(json.array(fromJson.bytes32())),
14223
14202
  varphi: json.array(json.array(fromJson.bytes32())),
@@ -14239,18 +14218,15 @@ const fullStateDumpFromJson = (spec) => json.object({
14239
14218
  chi_m: "number",
14240
14219
  chi_a: json.array("number"),
14241
14220
  chi_v: "number",
14242
- chi_r: json.optional("number"),
14221
+ chi_r: "number",
14243
14222
  chi_g: json.nullable(json.map("number", json.fromNumber((v) => tryAsServiceGas(v)))),
14244
14223
  },
14245
14224
  pi: JsonStatisticsData.fromJson,
14246
14225
  omega: json.array(json.array(notYetAccumulatedFromJson)),
14247
14226
  xi: json.array(json.array(fromJson.bytes32())),
14248
14227
  theta: json.nullable(json.array(accumulationOutput)),
14249
- accounts: json.array(JsonService.fromJson),
14228
+ accounts: json.array(JsonServicePre072.fromJson),
14250
14229
  }, ({ 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
14230
  return InMemoryState.new(spec, {
14255
14231
  authPools: tryAsPerCore(alpha.map((perCore) => {
14256
14232
  if (perCore.length > MAX_AUTH_POOL_SIZE) {
@@ -14280,7 +14256,7 @@ const fullStateDumpFromJson = (spec) => json.object({
14280
14256
  manager: chi.chi_m,
14281
14257
  assigners: chi.chi_a,
14282
14258
  delegator: chi.chi_v,
14283
- registrar: chi.chi_r ?? tryAsServiceId(2 ** 32 - 1),
14259
+ registrar: chi.chi_r,
14284
14260
  autoAccumulateServices: chi.chi_g ?? new Map(),
14285
14261
  }),
14286
14262
  statistics: JsonStatisticsData.toStatisticsData(spec, pi),
@@ -14456,7 +14432,6 @@ function legacyServiceNested(serviceId, hash) {
14456
14432
 
14457
14433
 
14458
14434
 
14459
-
14460
14435
  /** Serialization for particular state entries. */
14461
14436
  var serialize_serialize;
14462
14437
  (function (serialize) {
@@ -14564,24 +14539,22 @@ var serialize_serialize;
14564
14539
  Codec: codec_codec.sequenceVarLen(AccumulationOutput.Codec).convert((i) => i.array, (o) => SortedArray.fromSortedArray(accumulationOutputComparator, o)),
14565
14540
  extract: (s) => s.accumulationOutputLog,
14566
14541
  };
14567
- /** 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 */
14568
14543
  serialize.serviceData = (serviceId) => ({
14569
14544
  key: stateKeys.serviceInfo(serviceId),
14570
- Codec: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
14571
- ? codecWithVersion(ServiceAccountInfo.Codec)
14572
- : ServiceAccountInfo.Codec,
14545
+ Codec: codecWithVersion(ServiceAccountInfo.Codec),
14573
14546
  });
14574
- /** https://graypaper.fluffylabs.dev/#/85129da/384803384803?v=0.6.3 */
14547
+ /** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bac033bac03?v=0.7.2 */
14575
14548
  serialize.serviceStorage = (blake2b, serviceId, key) => ({
14576
14549
  key: stateKeys.serviceStorage(blake2b, serviceId, key),
14577
14550
  Codec: dumpCodec,
14578
14551
  });
14579
- /** https://graypaper.fluffylabs.dev/#/85129da/385b03385b03?v=0.6.3 */
14552
+ /** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bc9033bc903?v=0.7.2 */
14580
14553
  serialize.servicePreimages = (blake2b, serviceId, hash) => ({
14581
14554
  key: stateKeys.servicePreimage(blake2b, serviceId, hash),
14582
14555
  Codec: dumpCodec,
14583
14556
  });
14584
- /** https://graypaper.fluffylabs.dev/#/85129da/387603387603?v=0.6.3 */
14557
+ /** https://graypaper.fluffylabs.dev/#/ab2cdbd/3bea033b0904?v=0.7.2 */
14585
14558
  serialize.serviceLookupHistory = (blake2b, serviceId, hash, len) => ({
14586
14559
  key: stateKeys.serviceLookupHistory(blake2b, serviceId, hash, len),
14587
14560
  Codec: codec_codec.readonlyArray(codec_codec.sequenceVarLen(codec_codec.u32)),
@@ -14594,7 +14567,7 @@ var serialize_serialize;
14594
14567
  * determine the boundary of the bytes, so it can only be used
14595
14568
  * as the last element of the codec and can't be used in sequences!
14596
14569
  */
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()));
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()));
14598
14571
 
14599
14572
  ;// CONCATENATED MODULE: ./packages/jam/state-merkleization/serialized-state-view.ts
14600
14573
 
@@ -15922,7 +15895,7 @@ const codecMap = (value, extractKey, { typicalLength = codec_codec.TYPICAL_DICTI
15922
15895
  }
15923
15896
  return Ordering.Equal;
15924
15897
  }, } = {}) => {
15925
- return Descriptor.new(`Map<${value.name}>[?]`, {
15898
+ return descriptor_Descriptor.new(`Map<${value.name}>[?]`, {
15926
15899
  bytes: typicalLength * value.sizeHint.bytes,
15927
15900
  isExact: false,
15928
15901
  }, (e, v) => {
@@ -16181,41 +16154,21 @@ async function runWorkItemTest(test, { path }) {
16181
16154
 
16182
16155
 
16183
16156
 
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
- }));
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
+ }));
16219
16172
  async function runWorkPackageTest(test, { path: file }) {
16220
16173
  runCodecTest(WorkPackage.Codec, test, file);
16221
16174
  }