@polkadot/types-codec 7.7.1 → 7.7.2-11

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.
Files changed (70) hide show
  1. package/abstract/AbstractArray.cjs +27 -1
  2. package/abstract/AbstractArray.d.ts +7 -1
  3. package/abstract/AbstractArray.js +27 -1
  4. package/abstract/AbstractInt.cjs +10 -0
  5. package/abstract/AbstractInt.d.ts +5 -1
  6. package/abstract/AbstractInt.js +10 -0
  7. package/base/Base.cjs +8 -0
  8. package/base/Base.d.ts +5 -1
  9. package/base/Base.js +8 -0
  10. package/base/Compact.cjs +10 -0
  11. package/base/Compact.d.ts +5 -1
  12. package/base/Compact.js +10 -0
  13. package/base/DoNotConstruct.cjs +4 -0
  14. package/base/DoNotConstruct.d.ts +2 -1
  15. package/base/DoNotConstruct.js +4 -0
  16. package/base/Enum.cjs +22 -0
  17. package/base/Enum.d.ts +5 -1
  18. package/base/Enum.js +21 -0
  19. package/base/Null.cjs +8 -0
  20. package/base/Null.d.ts +5 -1
  21. package/base/Null.js +8 -0
  22. package/base/Option.cjs +22 -0
  23. package/base/Option.d.ts +5 -1
  24. package/base/Option.js +21 -0
  25. package/base/Tuple.cjs +11 -7
  26. package/base/Tuple.d.ts +5 -1
  27. package/base/Tuple.js +11 -7
  28. package/base/VecFixed.cjs +11 -6
  29. package/base/VecFixed.d.ts +5 -1
  30. package/base/VecFixed.js +11 -6
  31. package/extended/BTreeSet.cjs +17 -0
  32. package/extended/BTreeSet.d.ts +5 -1
  33. package/extended/BTreeSet.js +17 -0
  34. package/extended/BitVec.cjs +10 -0
  35. package/extended/BitVec.d.ts +5 -1
  36. package/extended/BitVec.js +10 -0
  37. package/extended/Bytes.cjs +11 -0
  38. package/extended/Bytes.d.ts +5 -1
  39. package/extended/Bytes.js +11 -0
  40. package/extended/Map.cjs +19 -1
  41. package/extended/Map.d.ts +5 -1
  42. package/extended/Map.js +19 -1
  43. package/extended/WrapperKeepOpaque.cjs +13 -0
  44. package/extended/WrapperKeepOpaque.d.ts +5 -1
  45. package/extended/WrapperKeepOpaque.js +14 -1
  46. package/native/Bool.cjs +10 -0
  47. package/native/Bool.d.ts +5 -1
  48. package/native/Bool.js +10 -0
  49. package/native/Date.cjs +13 -3
  50. package/native/Date.d.ts +7 -3
  51. package/native/Date.js +13 -3
  52. package/native/Json.cjs +8 -0
  53. package/native/Json.d.ts +5 -1
  54. package/native/Json.js +8 -0
  55. package/native/Raw.cjs +10 -0
  56. package/native/Raw.d.ts +5 -1
  57. package/native/Raw.js +10 -0
  58. package/native/Set.cjs +10 -0
  59. package/native/Set.d.ts +5 -1
  60. package/native/Set.js +10 -0
  61. package/native/Struct.cjs +18 -0
  62. package/native/Struct.d.ts +5 -1
  63. package/native/Struct.js +18 -0
  64. package/native/Text.cjs +11 -0
  65. package/native/Text.d.ts +5 -1
  66. package/native/Text.js +12 -1
  67. package/package.json +3 -3
  68. package/packageInfo.cjs +1 -1
  69. package/packageInfo.js +1 -1
  70. package/types/codec.d.ts +9 -0
package/native/Struct.cjs CHANGED
@@ -218,6 +218,24 @@ class Struct extends Map {
218
218
  getAtIndex(index) {
219
219
  return this.toArray()[index];
220
220
  }
221
+ /**
222
+ * @description Returns a breakdown of the hex encoding for this Codec
223
+ */
224
+
225
+
226
+ inspect() {
227
+ const inner = new Array();
228
+
229
+ for (const [k, v] of this.entries()) {
230
+ inner.push({ ...v.inspect(),
231
+ name: k.toString()
232
+ });
233
+ }
234
+
235
+ return {
236
+ inner
237
+ };
238
+ }
221
239
  /**
222
240
  * @description Converts the Object to an standard JavaScript Array
223
241
  */
@@ -1,5 +1,5 @@
1
1
  import type { HexString } from '@polkadot/util/types';
2
- import type { AnyJson, BareOpts, Codec, CodecClass, IStruct, IU8a, Registry } from '../types';
2
+ import type { AnyJson, BareOpts, Codec, CodecClass, Inspect, IStruct, IU8a, Registry } from '../types';
3
3
  declare type TypesDef<T = Codec> = Record<string, string | CodecClass<T>>;
4
4
  /**
5
5
  * @name Struct
@@ -60,6 +60,10 @@ export declare class Struct<S extends TypesDef = TypesDef, V extends {
60
60
  * @description Returns the values of a member at a specific index (Rather use get(name) for performance)
61
61
  */
62
62
  getAtIndex(index: number): Codec;
63
+ /**
64
+ * @description Returns a breakdown of the hex encoding for this Codec
65
+ */
66
+ inspect(): Inspect;
63
67
  /**
64
68
  * @description Converts the Object to an standard JavaScript Array
65
69
  */
package/native/Struct.js CHANGED
@@ -186,6 +186,24 @@ export class Struct extends Map {
186
186
  getAtIndex(index) {
187
187
  return this.toArray()[index];
188
188
  }
189
+ /**
190
+ * @description Returns a breakdown of the hex encoding for this Codec
191
+ */
192
+
193
+
194
+ inspect() {
195
+ const inner = new Array();
196
+
197
+ for (const [k, v] of this.entries()) {
198
+ inner.push({ ...v.inspect(),
199
+ name: k.toString()
200
+ });
201
+ }
202
+
203
+ return {
204
+ inner
205
+ };
206
+ }
189
207
  /**
190
208
  * @description Converts the Object to an standard JavaScript Array
191
209
  */
package/native/Text.cjs CHANGED
@@ -125,6 +125,17 @@ class Text extends String {
125
125
  eq(other) {
126
126
  return (0, _util.isString)(other) ? this.toString() === other.toString() : false;
127
127
  }
128
+ /**
129
+ * @description Returns a breakdown of the hex encoding for this Codec
130
+ */
131
+
132
+
133
+ inspect() {
134
+ const value = (0, _util.stringToU8a)(super.toString());
135
+ return {
136
+ outer: value.length ? [(0, _util.compactToU8a)(value.length), value] : [(0, _util.compactToU8a)(value.length)]
137
+ };
138
+ }
128
139
  /**
129
140
  * @description Set an override value for this
130
141
  */
package/native/Text.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { HexString } from '@polkadot/util/types';
2
- import type { AnyU8a, Codec, IU8a, Registry } from '../types';
2
+ import type { AnyU8a, Codec, Inspect, IU8a, Registry } from '../types';
3
3
  /**
4
4
  * @name Text
5
5
  * @description
@@ -39,6 +39,10 @@ export declare class Text extends String implements Codec {
39
39
  * @description Compares the value of the input to see if there is a match
40
40
  */
41
41
  eq(other?: unknown): boolean;
42
+ /**
43
+ * @description Returns a breakdown of the hex encoding for this Codec
44
+ */
45
+ inspect(): Inspect;
42
46
  /**
43
47
  * @description Set an override value for this
44
48
  */
package/native/Text.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { assert, compactAddLength, compactFromU8a, hexToU8a, isHex, isString, isU8a, stringToU8a, u8aToHex, u8aToString } from '@polkadot/util';
3
+ import { assert, compactAddLength, compactFromU8a, compactToU8a, hexToU8a, isHex, isString, isU8a, stringToU8a, u8aToHex, u8aToString } from '@polkadot/util';
4
4
  import { Raw } from "./Raw.js";
5
5
  const MAX_LENGTH = 128 * 1024;
6
6
  /** @internal */
@@ -99,6 +99,17 @@ export class Text extends String {
99
99
  eq(other) {
100
100
  return isString(other) ? this.toString() === other.toString() : false;
101
101
  }
102
+ /**
103
+ * @description Returns a breakdown of the hex encoding for this Codec
104
+ */
105
+
106
+
107
+ inspect() {
108
+ const value = stringToU8a(super.toString());
109
+ return {
110
+ outer: value.length ? [compactToU8a(value.length), value] : [compactToU8a(value.length)]
111
+ };
112
+ }
102
113
  /**
103
114
  * @description Set an override value for this
104
115
  */
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "./detectPackage.cjs"
21
21
  ],
22
22
  "type": "module",
23
- "version": "7.7.1",
23
+ "version": "7.7.2-11",
24
24
  "main": "index.cjs",
25
25
  "module": "index.js",
26
26
  "types": "index.d.ts",
@@ -404,7 +404,7 @@
404
404
  }
405
405
  },
406
406
  "dependencies": {
407
- "@babel/runtime": "^7.17.0",
408
- "@polkadot/util": "^8.3.3"
407
+ "@babel/runtime": "^7.17.2",
408
+ "@polkadot/util": "^8.3.4-10"
409
409
  }
410
410
  }
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.7.1'
14
+ version: '7.7.2-11'
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: new URL('.', import.meta.url).pathname,
7
7
  type: 'esm',
8
- version: '7.7.1'
8
+ version: '7.7.2-11'
9
9
  };
package/types/codec.d.ts CHANGED
@@ -3,6 +3,11 @@ import type { AnyJson } from './helpers';
3
3
  import type { IU8a } from './interfaces';
4
4
  import type { Registry } from './registry';
5
5
  export declare type BareOpts = boolean | Record<string, boolean>;
6
+ export interface Inspect {
7
+ inner?: Inspect[];
8
+ name?: string;
9
+ outer?: Uint8Array[];
10
+ }
6
11
  /**
7
12
  * @name Codec
8
13
  * @description
@@ -39,6 +44,10 @@ export interface Codec {
39
44
  * @description Compares the value of the input to see if there is a match
40
45
  */
41
46
  eq(other?: unknown): boolean;
47
+ /**
48
+ * @description Returns a breakdown of the hex encoding for this Codec
49
+ */
50
+ inspect(): Inspect;
42
51
  /**
43
52
  * @description Returns a hex string representation of the value. isLe returns a LE (number-only) representation
44
53
  */