@polkadot/types-codec 10.8.1 → 10.10.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/base/Enum.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import type { HexString } from '@polkadot/util/types';
2
2
  import type { AnyJson, Codec, CodecClass, DefinitionSetter, IEnum, Inspect, IU8a, Registry } from '../types/index.js';
3
- export interface EnumCodecClass<T = Codec> {
4
- new (registry: Registry, value?: any, index?: number): T;
5
- }
3
+ export type EnumCodecClass<T = Codec> = new (registry: Registry, value?: any, index?: number) => T;
6
4
  interface Definition {
7
5
  def: TypesDef;
8
6
  isBasic: boolean;
package/base/Enum.js CHANGED
@@ -47,7 +47,7 @@ function extractDef(registry, _def) {
47
47
  }
48
48
  function getEntryType(def, checkIdx) {
49
49
  const values = Object.values(def);
50
- for (let i = 0; i < values.length; i++) {
50
+ for (let i = 0, count = values.length; i < count; i++) {
51
51
  const { Type, index } = values[i];
52
52
  if (index === checkIdx) {
53
53
  return Type;
package/base/Tuple.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import type { AnyTupleValue, Codec, CodecClass, DefinitionSetter, Inspect, ITuple, Registry } from '../types/index.js';
2
2
  import { AbstractArray } from '../abstract/Array.js';
3
3
  type TupleType = (CodecClass | string);
4
- type TupleTypes = TupleType[] | {
5
- [index: string]: CodecClass | string;
6
- };
4
+ type TupleTypes = TupleType[] | Record<string, CodecClass | string>;
7
5
  type Definition = [CodecClass[], string[]];
8
6
  /**
9
7
  * @name Tuple
package/cjs/base/Enum.js CHANGED
@@ -50,7 +50,7 @@ function extractDef(registry, _def) {
50
50
  }
51
51
  function getEntryType(def, checkIdx) {
52
52
  const values = Object.values(def);
53
- for (let i = 0; i < values.length; i++) {
53
+ for (let i = 0, count = values.length; i < count; i++) {
54
54
  const { Type, index } = values[i];
55
55
  if (index === checkIdx) {
56
56
  return Type;
@@ -5,7 +5,7 @@ const util_1 = require("@polkadot/util");
5
5
  const Raw_js_1 = require("../native/Raw.js");
6
6
  /** @internal */
7
7
  function decodeBitVecU8a(value) {
8
- if (!value || !value.length) {
8
+ if (!value?.length) {
9
9
  return [0, new Uint8Array()];
10
10
  }
11
11
  // handle all other Uint8Array inputs, these do have a length prefix which is the number of bits encoded
@@ -28,7 +28,7 @@ class OptionBool extends Option_js_1.Option {
28
28
  * @description The length of the value when encoded as a Uint8Array
29
29
  */
30
30
  get encodedLength() {
31
- return 1;
31
+ return 1 | 0;
32
32
  }
33
33
  /**
34
34
  * @description Checks if the value is an empty value (always false)
@@ -22,7 +22,7 @@ class bool extends Boolean {
22
22
  * @description The length of the value when encoded as a Uint8Array
23
23
  */
24
24
  get encodedLength() {
25
- return 1;
25
+ return 1 | 0;
26
26
  }
27
27
  /**
28
28
  * @description returns a hash of the contents
@@ -26,7 +26,7 @@ class Json extends Map {
26
26
  * @description Always 0, never encodes as a Uint8Array
27
27
  */
28
28
  get encodedLength() {
29
- return 0;
29
+ return 0 | 0;
30
30
  }
31
31
  /**
32
32
  * @description returns a hash of the contents
@@ -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: '10.8.1' };
4
+ exports.packageInfo = { name: '@polkadot/types-codec', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.10.1' };
@@ -2,7 +2,7 @@ import { compactFromU8aLim, compactToU8a, isString, u8aConcatStrict, u8aToU8a }
2
2
  import { Raw } from '../native/Raw.js';
3
3
  /** @internal */
4
4
  function decodeBitVecU8a(value) {
5
- if (!value || !value.length) {
5
+ if (!value?.length) {
6
6
  return [0, new Uint8Array()];
7
7
  }
8
8
  // handle all other Uint8Array inputs, these do have a length prefix which is the number of bits encoded
@@ -25,7 +25,7 @@ export class OptionBool extends Option {
25
25
  * @description The length of the value when encoded as a Uint8Array
26
26
  */
27
27
  get encodedLength() {
28
- return 1;
28
+ return 1 | 0;
29
29
  }
30
30
  /**
31
31
  * @description Checks if the value is an empty value (always false)
package/native/Bool.js CHANGED
@@ -19,7 +19,7 @@ export class bool extends Boolean {
19
19
  * @description The length of the value when encoded as a Uint8Array
20
20
  */
21
21
  get encodedLength() {
22
- return 1;
22
+ return 1 | 0;
23
23
  }
24
24
  /**
25
25
  * @description returns a hash of the contents
package/native/Json.js CHANGED
@@ -23,7 +23,7 @@ export class Json extends Map {
23
23
  * @description Always 0, never encodes as a Uint8Array
24
24
  */
25
25
  get encodedLength() {
26
- return 0;
26
+ return 0 | 0;
27
27
  }
28
28
  /**
29
29
  * @description returns a hash of the contents
@@ -64,7 +64,7 @@ export declare class Struct<S extends TypesDef = TypesDef, V extends {
64
64
  /**
65
65
  * @description Returns the a types value by name
66
66
  */
67
- getT<T>(key: string): T;
67
+ getT<T = Codec>(key: string): T;
68
68
  /**
69
69
  * @description Returns a breakdown of the hex encoding for this Codec
70
70
  */
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "./cjs/detectPackage.js"
19
19
  ],
20
20
  "type": "module",
21
- "version": "10.8.1",
21
+ "version": "10.10.1",
22
22
  "main": "./cjs/index.js",
23
23
  "module": "./index.js",
24
24
  "types": "./index.d.ts",
@@ -516,8 +516,8 @@
516
516
  }
517
517
  },
518
518
  "dependencies": {
519
- "@polkadot/util": "^12.2.2",
520
- "@polkadot/x-bigint": "^12.2.2",
521
- "tslib": "^2.5.3"
519
+ "@polkadot/util": "^12.5.1",
520
+ "@polkadot/x-bigint": "^12.5.1",
521
+ "tslib": "^2.6.2"
522
522
  }
523
523
  }
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: '10.8.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: '10.10.1' };
@@ -1,5 +1,5 @@
1
1
  import { Float } from '../native/Float.js';
2
- declare const f32_base: import("../types/codec.js").CodecClass<Float>;
2
+ declare const f32_base: import("../types/codec.js").CodecClass<Float, any[]>;
3
3
  /**
4
4
  * @name f32
5
5
  * @description
@@ -1,5 +1,5 @@
1
1
  import { Float } from '../native/Float.js';
2
- declare const f64_base: import("../types/codec.js").CodecClass<Float>;
2
+ declare const f64_base: import("../types/codec.js").CodecClass<Float, any[]>;
3
3
  /**
4
4
  * @name f64
5
5
  * @description
@@ -1,5 +1,5 @@
1
1
  import { Int } from '../base/Int.js';
2
- declare const i128_base: import("../types/codec.js").CodecClass<Int>;
2
+ declare const i128_base: import("../types/codec.js").CodecClass<Int, any[]>;
3
3
  /**
4
4
  * @name i128
5
5
  * @description
@@ -1,5 +1,5 @@
1
1
  import { Int } from '../base/Int.js';
2
- declare const i16_base: import("../types/codec.js").CodecClass<Int>;
2
+ declare const i16_base: import("../types/codec.js").CodecClass<Int, any[]>;
3
3
  /**
4
4
  * @name i16
5
5
  * @description
@@ -1,5 +1,5 @@
1
1
  import { Int } from '../base/Int.js';
2
- declare const i256_base: import("../types/codec.js").CodecClass<Int>;
2
+ declare const i256_base: import("../types/codec.js").CodecClass<Int, any[]>;
3
3
  /**
4
4
  * @name i256
5
5
  * @description
@@ -1,5 +1,5 @@
1
1
  import { Int } from '../base/Int.js';
2
- declare const i32_base: import("../types/codec.js").CodecClass<Int>;
2
+ declare const i32_base: import("../types/codec.js").CodecClass<Int, any[]>;
3
3
  /**
4
4
  * @name i32
5
5
  * @description
@@ -1,5 +1,5 @@
1
1
  import { Int } from '../base/Int.js';
2
- declare const i64_base: import("../types/codec.js").CodecClass<Int>;
2
+ declare const i64_base: import("../types/codec.js").CodecClass<Int, any[]>;
3
3
  /**
4
4
  * @name i64
5
5
  * @description
package/primitive/I8.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Int } from '../base/Int.js';
2
- declare const i8_base: import("../types/codec.js").CodecClass<Int>;
2
+ declare const i8_base: import("../types/codec.js").CodecClass<Int, any[]>;
3
3
  /**
4
4
  * @name i8
5
5
  * @description
@@ -1,5 +1,5 @@
1
1
  import { UInt } from '../base/UInt.js';
2
- declare const u128_base: import("../types/codec.js").CodecClass<UInt>;
2
+ declare const u128_base: import("../types/codec.js").CodecClass<UInt, any[]>;
3
3
  /**
4
4
  * @name u128
5
5
  * @description
@@ -1,5 +1,5 @@
1
1
  import { UInt } from '../base/UInt.js';
2
- declare const u16_base: import("../types/codec.js").CodecClass<UInt>;
2
+ declare const u16_base: import("../types/codec.js").CodecClass<UInt, any[]>;
3
3
  /**
4
4
  * @name u16
5
5
  * @description
@@ -1,5 +1,5 @@
1
1
  import { UInt } from '../base/UInt.js';
2
- declare const u256_base: import("../types/codec.js").CodecClass<UInt>;
2
+ declare const u256_base: import("../types/codec.js").CodecClass<UInt, any[]>;
3
3
  /**
4
4
  * @name u256
5
5
  * @description
@@ -1,5 +1,5 @@
1
1
  import { UInt } from '../base/UInt.js';
2
- declare const u32_base: import("../types/codec.js").CodecClass<UInt>;
2
+ declare const u32_base: import("../types/codec.js").CodecClass<UInt, any[]>;
3
3
  /**
4
4
  * @name u32
5
5
  * @description
@@ -1,5 +1,5 @@
1
1
  import { UInt } from '../base/UInt.js';
2
- declare const u64_base: import("../types/codec.js").CodecClass<UInt>;
2
+ declare const u64_base: import("../types/codec.js").CodecClass<UInt, any[]>;
3
3
  /**
4
4
  * @name u64
5
5
  * @description
package/primitive/U8.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { UInt } from '../base/UInt.js';
2
- declare const u8_base: import("../types/codec.js").CodecClass<UInt>;
2
+ declare const u8_base: import("../types/codec.js").CodecClass<UInt, any[]>;
3
3
  /**
4
4
  * @name u8
5
5
  * @description
package/types/codec.d.ts CHANGED
@@ -95,12 +95,12 @@ export interface Codec {
95
95
  */
96
96
  toU8a(isBare?: BareOpts): Uint8Array;
97
97
  }
98
- export interface CodecClass<T = Codec> {
98
+ export interface CodecClass<T = Codec, A extends unknown[] = any[]> {
99
99
  /**
100
100
  * @description An internal fallback type (previous generation) if encoding fails
101
101
  */
102
102
  readonly __fallbackType?: string;
103
- new (registry: Registry, ...args: any[]): T;
103
+ new (registry: Registry, ...args: A): T;
104
104
  }
105
105
  export interface CodecObject<T extends ToString> extends Codec {
106
106
  readonly $: T;