@polkadot/types-codec 7.13.2-1 → 7.13.2-10
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/extended/BitVec.cjs +6 -1
- package/extended/BitVec.d.ts +1 -1
- package/extended/BitVec.js +6 -2
- package/package.json +1 -1
- package/packageInfo.cjs +1 -1
- package/packageInfo.js +1 -1
package/extended/BitVec.cjs
CHANGED
|
@@ -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
|
package/extended/BitVec.d.ts
CHANGED
|
@@ -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
|
*/
|
package/extended/BitVec.js
CHANGED
|
@@ -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
package/packageInfo.cjs
CHANGED
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.2-
|
|
8
|
+
version: '7.13.2-10'
|
|
9
9
|
};
|