@polkadot/types-codec 12.4.2 → 13.1.1

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/abstract/Int.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import type { HexString } from '@polkadot/util/types';
3
2
  import type { AnyNumber, Inspect, INumber, IU8a, Registry, UIntBitLength } from '../types/index.js';
4
3
  import { BN } from '@polkadot/util';
package/abstract/Int.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_QUINTILL, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isBigInt, isBn, isFunction, isHex, isNumber, isObject, isString, isU8a, u8aToBn, u8aToNumber } from '@polkadot/util';
2
2
  export const DEFAULT_UINT_BITS = 64;
3
3
  const MAX_NUMBER_BITS = 52;
4
- const MUL_P = new BN(10000);
4
+ const MUL_P = new BN(1_00_00);
5
5
  const FORMATTERS = [
6
6
  ['Perquintill', BN_QUINTILL],
7
7
  ['Perbill', BN_BILLION],
package/base/Compact.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import type { BN } from '@polkadot/util';
3
2
  import type { HexString } from '@polkadot/util/types';
4
3
  import type { AnyJson, AnyNumber, CodecClass, DefinitionSetter, ICompact, Inspect, INumber, IU8a, Registry } from '../types/index.js';
@@ -4,7 +4,7 @@ exports.AbstractInt = exports.DEFAULT_UINT_BITS = void 0;
4
4
  const util_1 = require("@polkadot/util");
5
5
  exports.DEFAULT_UINT_BITS = 64;
6
6
  const MAX_NUMBER_BITS = 52;
7
- const MUL_P = new util_1.BN(10000);
7
+ const MUL_P = new util_1.BN(1_00_00);
8
8
  const FORMATTERS = [
9
9
  ['Perquintill', util_1.BN_QUINTILL],
10
10
  ['Perbill', util_1.BN_BILLION],
package/cjs/base/Vec.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Vec = exports.decodeVec = void 0;
3
+ exports.Vec = void 0;
4
+ exports.decodeVec = decodeVec;
4
5
  const util_1 = require("@polkadot/util");
5
6
  const Array_js_1 = require("../abstract/Array.js");
6
7
  const index_js_1 = require("../utils/index.js");
@@ -48,7 +49,6 @@ function decodeVec(registry, result, value, startAt, Type) {
48
49
  // we don't need more checks, we already limited it via the length decoding
49
50
  return (0, index_js_1.decodeU8aVec)(registry, result, (0, util_1.u8aToU8a)(value), startAt, Type);
50
51
  }
51
- exports.decodeVec = decodeVec;
52
52
  /**
53
53
  * @name Vec
54
54
  * @description
@@ -61,14 +61,14 @@ class BitVec extends Raw_js_1.Raw {
61
61
  */
62
62
  toBoolArray() {
63
63
  const map = [...this.toU8a(true)].map((v) => [
64
- !!(v & 128),
65
- !!(v & 64),
66
- !!(v & 32),
67
- !!(v & 16),
68
- !!(v & 8),
69
- !!(v & 4),
70
- !!(v & 2),
71
- !!(v & 1)
64
+ !!(v & 0b1000_0000),
65
+ !!(v & 0b0100_0000),
66
+ !!(v & 0b0010_0000),
67
+ !!(v & 0b0001_0000),
68
+ !!(v & 0b0000_1000),
69
+ !!(v & 0b0000_0100),
70
+ !!(v & 0b0000_0010),
71
+ !!(v & 0b0000_0001)
72
72
  ]);
73
73
  const count = map.length;
74
74
  const result = new Array(8 * count);
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.packageInfo = void 0;
4
- exports.packageInfo = { name: '@polkadot/types-codec', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '12.4.2' };
4
+ exports.packageInfo = { name: '@polkadot/types-codec', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '13.1.1' };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compareArray = void 0;
3
+ exports.compareArray = compareArray;
4
4
  const util_1 = require("@polkadot/util");
5
5
  const util_js_1 = require("./util.js");
6
6
  function compareArray(a, b) {
@@ -11,4 +11,3 @@ function compareArray(a, b) {
11
11
  }
12
12
  return false;
13
13
  }
14
- exports.compareArray = compareArray;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compareMap = void 0;
3
+ exports.compareMap = compareMap;
4
4
  const util_1 = require("@polkadot/util");
5
5
  const util_js_1 = require("./util.js");
6
6
  function hasMismatch(a, b) {
@@ -28,4 +28,3 @@ function compareMap(a, b) {
28
28
  }
29
29
  return false;
30
30
  }
31
- exports.compareMap = compareMap;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compareSet = void 0;
3
+ exports.compareSet = compareSet;
4
4
  const util_1 = require("@polkadot/util");
5
5
  function compareSetArray(a, b) {
6
6
  // equal number of entries and each entry in the array should match
@@ -18,4 +18,3 @@ function compareSet(a, b) {
18
18
  }
19
19
  return false;
20
20
  }
21
- exports.compareSet = compareSet;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decodeU8aVec = exports.decodeU8aStruct = exports.decodeU8a = void 0;
3
+ exports.decodeU8a = decodeU8a;
4
+ exports.decodeU8aStruct = decodeU8aStruct;
5
+ exports.decodeU8aVec = decodeU8aVec;
4
6
  const util_1 = require("@polkadot/util");
5
7
  /** @internal */
6
8
  function formatFailure(registry, fn, _result, { message }, u8a, i, count, Type, key) {
@@ -43,7 +45,6 @@ function decodeU8a(registry, result, u8a, [Types, keys]) {
43
45
  }
44
46
  return [result, offset];
45
47
  }
46
- exports.decodeU8a = decodeU8a;
47
48
  /**
48
49
  * @internal
49
50
  *
@@ -67,7 +68,6 @@ function decodeU8aStruct(registry, result, u8a, [Types, keys]) {
67
68
  }
68
69
  return [result, offset];
69
70
  }
70
- exports.decodeU8aStruct = decodeU8aStruct;
71
71
  /**
72
72
  * @internal
73
73
  *
@@ -91,4 +91,3 @@ function decodeU8aVec(registry, result, u8a, startAt, Type) {
91
91
  }
92
92
  return [offset, offset - startAt];
93
93
  }
94
- exports.decodeU8aVec = decodeU8aVec;
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sanitize = exports.removeWrap = exports.removeTraits = exports.removePairOf = exports.removeGenerics = exports.removeColons = exports.removeExtensions = exports.flattenSingleTuple = exports.cleanupCompact = exports.alias = exports.findClosing = exports.trim = void 0;
3
+ exports.trim = trim;
4
+ exports.findClosing = findClosing;
5
+ exports.alias = alias;
6
+ exports.cleanupCompact = cleanupCompact;
7
+ exports.flattenSingleTuple = flattenSingleTuple;
8
+ exports.removeExtensions = removeExtensions;
9
+ exports.removeColons = removeColons;
10
+ exports.removeGenerics = removeGenerics;
11
+ exports.removePairOf = removePairOf;
12
+ exports.removeTraits = removeTraits;
13
+ exports.removeWrap = removeWrap;
14
+ exports.sanitize = sanitize;
4
15
  const BOUNDED = ['BTreeMap', 'BTreeSet', 'HashMap', 'Vec'];
5
16
  const ALLOWED_BOXES = BOUNDED.concat(['Compact', 'DoNotConstruct', 'Int', 'Linkage', 'Range', 'RangeInclusive', 'Result', 'Opaque', 'Option', 'UInt', 'WrapperKeepOpaque', 'WrapperOpaque']);
6
17
  const BOX_PRECEDING = ['<', '(', '[', '"', ',', ' ']; // start of vec, tuple, fixed array, part of struct def or in tuple
@@ -45,7 +56,6 @@ const mappings = [
45
56
  function trim() {
46
57
  return (value) => value.trim();
47
58
  }
48
- exports.trim = trim;
49
59
  function findClosing(value, start) {
50
60
  let depth = 0;
51
61
  for (let i = start, count = value.length; i < count; i++) {
@@ -61,7 +71,6 @@ function findClosing(value, start) {
61
71
  }
62
72
  throw new Error(`Unable to find closing matching <> on '${value}' (start ${start})`);
63
73
  }
64
- exports.findClosing = findClosing;
65
74
  function alias(src, dest, withChecks = true) {
66
75
  const from = new RegExp(`(^${src}|${BOX_PRECEDING.map((box) => `\\${box}${src}`).join('|')})`, 'g');
67
76
  const to = (src) => {
@@ -72,7 +81,6 @@ function alias(src, dest, withChecks = true) {
72
81
  };
73
82
  return (value) => value.replace(from, to);
74
83
  }
75
- exports.alias = alias;
76
84
  function cleanupCompact() {
77
85
  return (value) => {
78
86
  if (value.includes(' as HasCompact')) {
@@ -88,7 +96,6 @@ function cleanupCompact() {
88
96
  return value;
89
97
  };
90
98
  }
91
- exports.cleanupCompact = cleanupCompact;
92
99
  function flattenSingleTuple() {
93
100
  const from1 = /,\)/g;
94
101
  const from2 = /\(([^,]+)\)/;
@@ -101,7 +108,6 @@ function flattenSingleTuple() {
101
108
  .replace(from2, '$1');
102
109
  };
103
110
  }
104
- exports.flattenSingleTuple = flattenSingleTuple;
105
111
  function replaceTagWith(value, matcher, replacer) {
106
112
  let index = -1;
107
113
  while (true) {
@@ -132,7 +138,6 @@ function removeExtensions(type, isSized) {
132
138
  return value;
133
139
  };
134
140
  }
135
- exports.removeExtensions = removeExtensions;
136
141
  function removeColons() {
137
142
  return (value) => {
138
143
  let index = 0;
@@ -152,7 +157,6 @@ function removeColons() {
152
157
  return value;
153
158
  };
154
159
  }
155
- exports.removeColons = removeColons;
156
160
  function removeGenerics() {
157
161
  return (value) => {
158
162
  for (let i = 0, count = value.length; i < count; i++) {
@@ -176,12 +180,10 @@ function removeGenerics() {
176
180
  return value;
177
181
  };
178
182
  }
179
- exports.removeGenerics = removeGenerics;
180
183
  function removePairOf() {
181
184
  const replacer = (v) => `(${v},${v})`;
182
185
  return (value) => replaceTagWith(value, 'PairOf<', replacer);
183
186
  }
184
- exports.removePairOf = removePairOf;
185
187
  function removeTraits() {
186
188
  const from1 = /\s/g;
187
189
  const from2 = /(T|Self)::/g;
@@ -211,12 +213,10 @@ function removeTraits() {
211
213
  .replace(from6, '');
212
214
  };
213
215
  }
214
- exports.removeTraits = removeTraits;
215
216
  function removeWrap(check) {
216
217
  const replacer = (v) => v;
217
218
  return (value) => replaceTagWith(value, check, replacer);
218
219
  }
219
- exports.removeWrap = removeWrap;
220
220
  const sanitizeMap = new Map();
221
221
  function sanitize(value) {
222
222
  const startValue = value.toString();
@@ -231,4 +231,3 @@ function sanitize(value) {
231
231
  sanitizeMap.set(startValue, result);
232
232
  return result;
233
233
  }
234
- exports.sanitize = sanitize;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sortMap = exports.sortSet = exports.sortAsc = void 0;
3
+ exports.sortAsc = sortAsc;
4
+ exports.sortSet = sortSet;
5
+ exports.sortMap = sortMap;
4
6
  const util_1 = require("@polkadot/util");
5
7
  /** @internal **/
6
8
  function isArrayLike(arg) {
@@ -72,14 +74,11 @@ function sortAsc(a, b) {
72
74
  }
73
75
  throw new Error(`Attempting to sort unrecognized values: ${(0, util_1.stringify)(a)} (typeof ${typeof a}) <-> ${(0, util_1.stringify)(b)} (typeof ${typeof b})`);
74
76
  }
75
- exports.sortAsc = sortAsc;
76
77
  function sortSet(set) {
77
78
  const seen = new Set();
78
79
  return new Set(Array.from(set).filter((value) => checkForDuplicates('BTreeSet', seen, value)).sort(sortAsc));
79
80
  }
80
- exports.sortSet = sortSet;
81
81
  function sortMap(map) {
82
82
  const seen = new Set();
83
83
  return new Map(Array.from(map.entries()).filter(([key]) => checkForDuplicates('BTreeMap', seen, key)).sort(([keyA], [keyB]) => sortAsc(keyA, keyB)));
84
84
  }
85
- exports.sortMap = sortMap;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapToTypeMap = exports.typesToConstructors = exports.typeToConstructor = void 0;
3
+ exports.typeToConstructor = typeToConstructor;
4
+ exports.typesToConstructors = typesToConstructors;
5
+ exports.mapToTypeMap = mapToTypeMap;
4
6
  /**
5
7
  * @internal
6
8
  * From a type string or class, return the associated type class
@@ -10,7 +12,6 @@ function typeToConstructor(registry, type) {
10
12
  ? type
11
13
  : registry.createClassUnsafe(type);
12
14
  }
13
- exports.typeToConstructor = typeToConstructor;
14
15
  /**
15
16
  * @internal
16
17
  * Takes an input array of types and returns the associated classes for it
@@ -23,7 +24,6 @@ function typesToConstructors(registry, types) {
23
24
  }
24
25
  return result;
25
26
  }
26
- exports.typesToConstructors = typesToConstructors;
27
27
  /**
28
28
  * @internal
29
29
  * Takes an input map of the form `{ [string]: string | CodecClass }` and returns a map of `{ [string]: CodecClass }`
@@ -38,4 +38,3 @@ function mapToTypeMap(registry, input) {
38
38
  }
39
39
  return output;
40
40
  }
41
- exports.mapToTypeMap = mapToTypeMap;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.typesToMap = void 0;
3
+ exports.typesToMap = typesToMap;
4
4
  function typesToMap(registry, [Types, keys]) {
5
5
  const result = {};
6
6
  for (let i = 0, count = keys.length; i < count; i++) {
@@ -8,4 +8,3 @@ function typesToMap(registry, [Types, keys]) {
8
8
  }
9
9
  return result;
10
10
  }
11
- exports.typesToMap = typesToMap;
package/cjs/utils/util.js CHANGED
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasEq = void 0;
3
+ exports.hasEq = hasEq;
4
4
  const util_1 = require("@polkadot/util");
5
5
  function hasEq(o) {
6
6
  return (0, util_1.isFunction)(o.eq);
7
7
  }
8
- exports.hasEq = hasEq;
@@ -58,14 +58,14 @@ export class BitVec extends Raw {
58
58
  */
59
59
  toBoolArray() {
60
60
  const map = [...this.toU8a(true)].map((v) => [
61
- !!(v & 128),
62
- !!(v & 64),
63
- !!(v & 32),
64
- !!(v & 16),
65
- !!(v & 8),
66
- !!(v & 4),
67
- !!(v & 2),
68
- !!(v & 1)
61
+ !!(v & 0b1000_0000),
62
+ !!(v & 0b0100_0000),
63
+ !!(v & 0b0010_0000),
64
+ !!(v & 0b0001_0000),
65
+ !!(v & 0b0000_1000),
66
+ !!(v & 0b0000_0100),
67
+ !!(v & 0b0000_0010),
68
+ !!(v & 0b0000_0001)
69
69
  ]);
70
70
  const count = map.length;
71
71
  const result = new Array(8 * count);
package/native/Date.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import type { HexString } from '@polkadot/util/types';
3
2
  import type { AnyNumber, Inspect, INumber, IU8a, Registry, UIntBitLength } from '../types/index.js';
4
3
  import { BN } from '@polkadot/util';
package/native/Set.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import type { HexString } from '@polkadot/util/types';
3
2
  import type { CodecClass, Inspect, ISet, IU8a, Registry } from '../types/index.js';
4
3
  import { BN } from '@polkadot/util';
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "./cjs/packageDetect.js"
19
19
  ],
20
20
  "type": "module",
21
- "version": "12.4.2",
21
+ "version": "13.1.1",
22
22
  "main": "./cjs/index.js",
23
23
  "module": "./index.js",
24
24
  "types": "./index.d.ts",
@@ -510,8 +510,8 @@
510
510
  }
511
511
  },
512
512
  "dependencies": {
513
- "@polkadot/util": "^13.0.2",
514
- "@polkadot/x-bigint": "^13.0.2",
515
- "tslib": "^2.6.3"
513
+ "@polkadot/util": "^13.1.1",
514
+ "@polkadot/x-bigint": "^13.1.1",
515
+ "tslib": "^2.7.0"
516
516
  }
517
517
  }
package/packageInfo.js CHANGED
@@ -1 +1 @@
1
- export const packageInfo = { name: '@polkadot/types-codec', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '12.4.2' };
1
+ export const packageInfo = { name: '@polkadot/types-codec', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '13.1.1' };
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import type { BN } from '@polkadot/util';
3
2
  import type { HexString } from '@polkadot/util/types';
4
3
  import type { Codec } from './codec.js';
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import type { BN } from '@polkadot/util';
3
2
  import type { ArgsDef, Codec } from './codec.js';
4
3
  import type { AnyTuple } from './helpers.js';
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import type { BN } from '@polkadot/util';
3
2
  import type { Codec, CodecClass } from './codec.js';
4
3
  import type { AnyTuple, LookupString } from './helpers.js';
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import type { BN } from '@polkadot/util';
3
2
  import type { Codec } from '../types/index.js';
4
3
  type SortArg = Codec | Codec[] | number[] | BN | bigint | number | Uint8Array;