@polkadot/types-codec 8.11.3 → 8.12.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.
@@ -20,7 +20,7 @@ function decodeRaw(registry, typeName, value) {
20
20
 
21
21
  if ((0, _util.isU8a)(value) || (0, _util.isHex)(value)) {
22
22
  try {
23
- const [, u8a] = (0, _util.isHex)(value) || value instanceof _Raw.Raw ? [0, value] : (0, _util.compactStripLength)(value);
23
+ const [, u8a] = (0, _util.isHex)(value) ? [0, (0, _util.u8aToU8a)(value)] : value instanceof _Raw.Raw ? [0, value.subarray()] : (0, _util.compactStripLength)(value);
24
24
  return [Type, new Type(registry, u8a), value];
25
25
  } catch {
26
26
  return [Type, null, value];
@@ -10,6 +10,10 @@ var _util = require("@polkadot/util");
10
10
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
11
11
  // SPDX-License-Identifier: Apache-2.0
12
12
  const BITLENGTH = 64;
13
+ const U8A_OPTS = {
14
+ bitLength: BITLENGTH,
15
+ isLe: true
16
+ };
13
17
 
14
18
  function decodeDate(value) {
15
19
  if ((0, _util.isU8a)(value)) {
@@ -170,7 +174,7 @@ class CodecDate extends Date {
170
174
 
171
175
 
172
176
  toU8a(isBare) {
173
- return (0, _util.bnToU8a)(this.toNumber(), BITLENGTH, true);
177
+ return (0, _util.bnToU8a)(this.toNumber(), U8A_OPTS);
174
178
  }
175
179
 
176
180
  }
@@ -11,6 +11,6 @@ const packageInfo = {
11
11
  name: '@polkadot/types-codec',
12
12
  path: typeof __dirname === 'string' ? __dirname : 'auto',
13
13
  type: 'cjs',
14
- version: '8.11.3'
14
+ version: '8.12.1'
15
15
  };
16
16
  exports.packageInfo = packageInfo;
@@ -18,7 +18,7 @@ exports.trim = trim;
18
18
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
19
19
  // SPDX-License-Identifier: Apache-2.0
20
20
  const BOUNDED = ['BTreeMap', 'BTreeSet', 'HashMap', 'Vec'];
21
- const ALLOWED_BOXES = BOUNDED.concat(['Compact', 'DoNotConstruct', 'Int', 'Linkage', 'Range', 'RangeInclusive', 'Result', 'Option', 'UInt', 'WrapperKeepOpaque', 'WrapperOpaque']);
21
+ const ALLOWED_BOXES = BOUNDED.concat(['Compact', 'DoNotConstruct', 'Int', 'Linkage', 'Range', 'RangeInclusive', 'Result', 'Opaque', 'Option', 'UInt', 'WrapperKeepOpaque', 'WrapperOpaque']);
22
22
  const BOX_PRECEDING = ['<', '(', '[', '"', ',', ' ']; // start of vec, tuple, fixed array, part of struct def or in tuple
23
23
 
24
24
  const mappings = [// alias <T::InherentOfflineReport as InherentOfflineReport>::Inherent -> InherentOfflineReport
@@ -1,6 +1,6 @@
1
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { compactAddLength, compactStripLength, compactToU8a, isHex, isU8a } from '@polkadot/util';
3
+ import { compactAddLength, compactStripLength, compactToU8a, isHex, isU8a, u8aToU8a } from '@polkadot/util';
4
4
  import { Raw } from "../native/Raw.js";
5
5
  import { typeToConstructor } from "../utils/index.js";
6
6
  import { Bytes } from "./Bytes.js";
@@ -10,7 +10,7 @@ function decodeRaw(registry, typeName, value) {
10
10
 
11
11
  if (isU8a(value) || isHex(value)) {
12
12
  try {
13
- const [, u8a] = isHex(value) || value instanceof Raw ? [0, value] : compactStripLength(value);
13
+ const [, u8a] = isHex(value) ? [0, u8aToU8a(value)] : value instanceof Raw ? [0, value.subarray()] : compactStripLength(value);
14
14
  return [Type, new Type(registry, u8a), value];
15
15
  } catch {
16
16
  return [Type, null, value];
package/native/Date.js CHANGED
@@ -2,6 +2,10 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { BN, bnToBn, bnToHex, bnToU8a, isString, isU8a, u8aToBn } from '@polkadot/util';
4
4
  const BITLENGTH = 64;
5
+ const U8A_OPTS = {
6
+ bitLength: BITLENGTH,
7
+ isLe: true
8
+ };
5
9
 
6
10
  function decodeDate(value) {
7
11
  if (isU8a(value)) {
@@ -160,7 +164,7 @@ export class CodecDate extends Date {
160
164
 
161
165
 
162
166
  toU8a(isBare) {
163
- return bnToU8a(this.toNumber(), BITLENGTH, true);
167
+ return bnToU8a(this.toNumber(), U8A_OPTS);
164
168
  }
165
169
 
166
170
  }
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "./cjs/detectPackage.js"
21
21
  ],
22
22
  "type": "module",
23
- "version": "8.11.3",
23
+ "version": "8.12.1",
24
24
  "main": "./cjs/index.js",
25
25
  "module": "./index.js",
26
26
  "types": "./index.d.ts",
@@ -435,7 +435,7 @@
435
435
  },
436
436
  "dependencies": {
437
437
  "@babel/runtime": "^7.18.6",
438
- "@polkadot/util": "^9.7.2",
439
- "@polkadot/x-bigint": "^9.7.2"
438
+ "@polkadot/util": "^10.0.1",
439
+ "@polkadot/x-bigint": "^10.0.1"
440
440
  }
441
441
  }
package/packageInfo.js CHANGED
@@ -5,5 +5,5 @@ export const packageInfo = {
5
5
  name: '@polkadot/types-codec',
6
6
  path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
7
7
  type: 'esm',
8
- version: '8.11.3'
8
+ version: '8.12.1'
9
9
  };
package/utils/sanitize.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  const BOUNDED = ['BTreeMap', 'BTreeSet', 'HashMap', 'Vec'];
4
- const ALLOWED_BOXES = BOUNDED.concat(['Compact', 'DoNotConstruct', 'Int', 'Linkage', 'Range', 'RangeInclusive', 'Result', 'Option', 'UInt', 'WrapperKeepOpaque', 'WrapperOpaque']);
4
+ const ALLOWED_BOXES = BOUNDED.concat(['Compact', 'DoNotConstruct', 'Int', 'Linkage', 'Range', 'RangeInclusive', 'Result', 'Opaque', 'Option', 'UInt', 'WrapperKeepOpaque', 'WrapperOpaque']);
5
5
  const BOX_PRECEDING = ['<', '(', '[', '"', ',', ' ']; // start of vec, tuple, fixed array, part of struct def or in tuple
6
6
 
7
7
  const mappings = [// alias <T::InherentOfflineReport as InherentOfflineReport>::Inherent -> InherentOfflineReport