@polkadot/types-codec 7.13.1 → 7.13.2-2

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.
@@ -45,11 +45,16 @@ function decodeBitVec(value) {
45
45
 
46
46
  class BitVec extends _Raw.Raw {
47
47
  #decodedLength;
48
+ #isMsb; // In lieu of having the Msb/Lsb identifiers passed through, we default to assuming
49
+ // we are dealing with Lsb, which is the default (as of writing) BitVec format used
50
+ // in the Polkadot code (this only affects the toHuman displays)
48
51
 
49
52
  constructor(registry, value) {
53
+ let isMsb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
50
54
  const [decodedLength, u8a] = decodeBitVec(value);
51
55
  super(registry, u8a);
52
56
  this.#decodedLength = decodedLength;
57
+ this.#isMsb = isMsb;
53
58
  }
54
59
  /**
55
60
  * @description The length of the value when encoded as a Uint8Array
@@ -71,7 +76,7 @@ class BitVec extends _Raw.Raw {
71
76
  }
72
77
 
73
78
  toHuman() {
74
- return `0b${[...this.toU8a(true)].map(d => `00000000${d.toString(2)}`.slice(-8)).join('_')}`;
79
+ return `0b${[...this.toU8a(true)].map(d => `00000000${d.toString(2)}`.slice(-8)).map(s => this.#isMsb ? s : s.split('').reverse().join('')).join('_')}`;
75
80
  }
76
81
  /**
77
82
  * @description Returns the base runtime type name for this instance
@@ -8,7 +8,7 @@ import { Raw } from '../native/Raw';
8
8
  */
9
9
  export declare class BitVec extends Raw {
10
10
  #private;
11
- constructor(registry: Registry, value?: AnyU8a);
11
+ constructor(registry: Registry, value?: AnyU8a, isMsb?: boolean);
12
12
  /**
13
13
  * @description The length of the value when encoded as a Uint8Array
14
14
  */
@@ -36,11 +36,15 @@ function decodeBitVec(value) {
36
36
 
37
37
  export class BitVec extends Raw {
38
38
  #decodedLength;
39
+ #isMsb; // In lieu of having the Msb/Lsb identifiers passed through, we default to assuming
40
+ // we are dealing with Lsb, which is the default (as of writing) BitVec format used
41
+ // in the Polkadot code (this only affects the toHuman displays)
39
42
 
40
- constructor(registry, value) {
43
+ constructor(registry, value, isMsb = false) {
41
44
  const [decodedLength, u8a] = decodeBitVec(value);
42
45
  super(registry, u8a);
43
46
  this.#decodedLength = decodedLength;
47
+ this.#isMsb = isMsb;
44
48
  }
45
49
  /**
46
50
  * @description The length of the value when encoded as a Uint8Array
@@ -62,7 +66,7 @@ export class BitVec extends Raw {
62
66
  }
63
67
 
64
68
  toHuman() {
65
- return `0b${[...this.toU8a(true)].map(d => `00000000${d.toString(2)}`.slice(-8)).join('_')}`;
69
+ return `0b${[...this.toU8a(true)].map(d => `00000000${d.toString(2)}`.slice(-8)).map(s => this.#isMsb ? s : s.split('').reverse().join('')).join('_')}`;
66
70
  }
67
71
  /**
68
72
  * @description Returns the base runtime type name for this instance
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "./detectPackage.cjs"
21
21
  ],
22
22
  "type": "module",
23
- "version": "7.13.1",
23
+ "version": "7.13.2-2",
24
24
  "main": "index.cjs",
25
25
  "module": "index.js",
26
26
  "types": "index.d.ts",
package/packageInfo.cjs CHANGED
@@ -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: '7.13.1'
14
+ version: '7.13.2-2'
15
15
  };
16
16
  exports.packageInfo = packageInfo;
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: '7.13.1'
8
+ version: '7.13.2-2'
9
9
  };