@polkadot/types-codec 6.12.2-22 → 6.12.2-26

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 (74) hide show
  1. package/abstract/AbstractArray.d.ts +84 -0
  2. package/abstract/AbstractInt.d.ts +75 -0
  3. package/abstract/index.d.ts +2 -0
  4. package/base/Base.d.ts +56 -0
  5. package/base/Compact.d.ts +83 -0
  6. package/base/DoNotConstruct.d.ts +33 -0
  7. package/base/Enum.d.ts +105 -0
  8. package/base/Int.d.ts +16 -0
  9. package/base/Null.d.ts +54 -0
  10. package/base/Option.d.ts +88 -0
  11. package/base/Result.d.ts +46 -0
  12. package/base/Tuple.d.ts +39 -0
  13. package/base/UInt.d.ts +15 -0
  14. package/base/Vec.d.ts +28 -0
  15. package/base/VecAny.d.ts +15 -0
  16. package/base/VecFixed.d.ts +26 -0
  17. package/base/index.d.ts +13 -0
  18. package/bundle.d.ts +7 -0
  19. package/detectPackage.d.ts +1 -0
  20. package/extended/BTreeMap.d.ts +5 -0
  21. package/extended/BTreeSet.d.ts +55 -0
  22. package/extended/BitVec.d.ts +26 -0
  23. package/extended/Bytes.d.ts +25 -0
  24. package/extended/HashMap.d.ts +5 -0
  25. package/extended/Linkage.d.ts +31 -0
  26. package/extended/Map.d.ts +50 -0
  27. package/extended/Range.d.ts +30 -0
  28. package/extended/Type.d.ts +16 -0
  29. package/extended/U8aFixed.d.ts +16 -0
  30. package/extended/WrapperOpaque.d.ts +14 -0
  31. package/extended/index.d.ts +11 -0
  32. package/index.d.ts +2 -0
  33. package/native/Bool.d.ts +62 -0
  34. package/native/Date.d.ts +76 -0
  35. package/native/Json.d.ts +56 -0
  36. package/native/Raw.d.ts +90 -0
  37. package/native/Set.d.ts +76 -0
  38. package/native/Struct.d.ts +93 -0
  39. package/native/Text.d.ts +71 -0
  40. package/native/index.d.ts +7 -0
  41. package/package.json +74 -3
  42. package/packageInfo.cjs +1 -1
  43. package/packageInfo.d.ts +4 -0
  44. package/packageInfo.js +1 -1
  45. package/primitive/I128.d.ts +11 -0
  46. package/primitive/I16.d.ts +11 -0
  47. package/primitive/I256.d.ts +11 -0
  48. package/primitive/I32.d.ts +11 -0
  49. package/primitive/I64.d.ts +11 -0
  50. package/primitive/I8.d.ts +11 -0
  51. package/primitive/U128.d.ts +11 -0
  52. package/primitive/U16.d.ts +11 -0
  53. package/primitive/U256.d.ts +11 -0
  54. package/primitive/U32.d.ts +11 -0
  55. package/primitive/U64.d.ts +11 -0
  56. package/primitive/U8.d.ts +11 -0
  57. package/primitive/USize.d.ts +12 -0
  58. package/primitive/index.d.ts +13 -0
  59. package/types/codec.d.ts +77 -0
  60. package/types/helpers.d.ts +14 -0
  61. package/types/index.d.ts +4 -0
  62. package/types/interfaces.d.ts +69 -0
  63. package/types/registry.d.ts +61 -0
  64. package/utils/compareArray.d.ts +1 -0
  65. package/utils/compareMap.d.ts +1 -0
  66. package/utils/compareSet.d.ts +1 -0
  67. package/utils/decodeU8a.d.ts +13 -0
  68. package/utils/index.d.ts +9 -0
  69. package/utils/mapToTypeMap.d.ts +5 -0
  70. package/utils/sanitize.d.ts +16 -0
  71. package/utils/sortValues.d.ts +13 -0
  72. package/utils/typeToConstructor.d.ts +2 -0
  73. package/utils/typesToMap.d.ts +2 -0
  74. package/utils/util.d.ts +3 -0
@@ -0,0 +1,90 @@
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { AnyJson, AnyU8a, CodecRegistry, IU8a } from '../types';
3
+ /**
4
+ * @name Raw
5
+ * @description
6
+ * A basic wrapper around Uint8Array, with no frills and no fuss. It does differ
7
+ * from other implementations where it will consume the full Uint8Array as passed to it.
8
+ * As such it is meant to be subclassed where the wrapper takes care of the
9
+ * actual lengths instead of used directly.
10
+ * @noInheritDoc
11
+ */
12
+ export declare class Raw extends Uint8Array implements IU8a {
13
+ readonly registry: CodecRegistry;
14
+ createdAtHash?: IU8a;
15
+ readonly initialU8aLength?: number;
16
+ constructor(registry: CodecRegistry, value?: AnyU8a, initialU8aLength?: number);
17
+ /**
18
+ * @description The length of the value when encoded as a Uint8Array
19
+ */
20
+ get encodedLength(): number;
21
+ /**
22
+ * @description returns a hash of the contents
23
+ */
24
+ get hash(): IU8a;
25
+ /**
26
+ * @description Returns true if the wrapped value contains only ASCII printable characters
27
+ */
28
+ get isAscii(): boolean;
29
+ /**
30
+ * @description Returns true if the type wraps an empty/default all-0 value
31
+ */
32
+ get isEmpty(): boolean;
33
+ /**
34
+ * @description Returns true if the wrapped value contains only utf8 characters
35
+ */
36
+ get isUtf8(): boolean;
37
+ /**
38
+ * @description The length of the value
39
+ */
40
+ get length(): number;
41
+ /**
42
+ * @description Returns the number of bits in the value
43
+ */
44
+ bitLength(): number;
45
+ /**
46
+ * @description Compares the value of the input to see if there is a match
47
+ */
48
+ eq(other?: unknown): boolean;
49
+ /**
50
+ * @description Create a new slice from the actual buffer. (compat)
51
+ * @param start The position to start at
52
+ * @param end The position to end at
53
+ */
54
+ slice(start?: number, end?: number): Uint8Array;
55
+ /**
56
+ * @description Create a new subarray from the actual buffer. (compat)
57
+ * @param begin The position to start at
58
+ * @param end The position to end at
59
+ */
60
+ subarray(begin?: number, end?: number): Uint8Array;
61
+ /**
62
+ * @description Returns a hex string representation of the value
63
+ */
64
+ toHex(): HexString;
65
+ /**
66
+ * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
67
+ */
68
+ toHuman(): AnyJson;
69
+ /**
70
+ * @description Converts the Object to JSON, typically used for RPC transfers
71
+ */
72
+ toJSON(): string;
73
+ /**
74
+ * @description Returns the base runtime type name for this instance
75
+ */
76
+ toRawType(): string;
77
+ /**
78
+ * @description Returns the string representation of the value
79
+ */
80
+ toString(): string;
81
+ /**
82
+ * @description Encodes the value as a Uint8Array as per the SCALE specifications
83
+ * @param isBare true when the value has none of the type-specific prefixes (internal)
84
+ */
85
+ toU8a(isBare?: boolean): Uint8Array;
86
+ /**
87
+ * @description Returns the wrapped data as a UTF-8 string
88
+ */
89
+ toUtf8(): string;
90
+ }
@@ -0,0 +1,76 @@
1
+ /// <reference types="bn.js" />
2
+ import type { HexString } from '@polkadot/util/types';
3
+ import type { CodecClass, CodecRegistry, ISet, IU8a } from '../types';
4
+ import { BN } from '@polkadot/util';
5
+ declare type SetValues = Record<string, number | BN>;
6
+ /**
7
+ * @name Set
8
+ * @description
9
+ * An Set is an array of string values, represented an an encoded type by
10
+ * a bitwise representation of the values.
11
+ */
12
+ export declare class CodecSet extends Set<string> implements ISet<string> {
13
+ #private;
14
+ readonly registry: CodecRegistry;
15
+ createdAtHash?: IU8a;
16
+ constructor(registry: CodecRegistry, setValues: SetValues, value?: string[] | Set<string> | Uint8Array | BN | number | string, bitLength?: number);
17
+ static with(values: SetValues, bitLength?: number): CodecClass<CodecSet>;
18
+ /**
19
+ * @description The length of the value when encoded as a Uint8Array
20
+ */
21
+ get encodedLength(): number;
22
+ /**
23
+ * @description returns a hash of the contents
24
+ */
25
+ get hash(): IU8a;
26
+ /**
27
+ * @description true is the Set contains no values
28
+ */
29
+ get isEmpty(): boolean;
30
+ /**
31
+ * @description The actual set values as a string[]
32
+ */
33
+ get strings(): string[];
34
+ /**
35
+ * @description The encoded value for the set members
36
+ */
37
+ get valueEncoded(): BN;
38
+ /**
39
+ * @description adds a value to the Set (extended to allow for validity checking)
40
+ */
41
+ add: (key: string) => this;
42
+ /**
43
+ * @description Compares the value of the input to see if there is a match
44
+ */
45
+ eq(other?: unknown): boolean;
46
+ /**
47
+ * @description Returns a hex string representation of the value
48
+ */
49
+ toHex(): HexString;
50
+ /**
51
+ * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
52
+ */
53
+ toHuman(): string[];
54
+ /**
55
+ * @description Converts the Object to JSON, typically used for RPC transfers
56
+ */
57
+ toJSON(): string[];
58
+ /**
59
+ * @description The encoded value for the set members
60
+ */
61
+ toNumber(): number;
62
+ /**
63
+ * @description Returns the base runtime type name for this instance
64
+ */
65
+ toRawType(): string;
66
+ /**
67
+ * @description Returns the string representation of the value
68
+ */
69
+ toString(): string;
70
+ /**
71
+ * @description Encodes the value as a Uint8Array as per the SCALE specifications
72
+ * @param isBare true when the value has none of the type-specific prefixes (internal)
73
+ */
74
+ toU8a(isBare?: boolean): Uint8Array;
75
+ }
76
+ export {};
@@ -0,0 +1,93 @@
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { AnyJson, BareOpts, Codec, CodecClass, CodecRegistry, IStruct, IU8a } from '../types';
3
+ declare type TypesDef<T = Codec> = Record<string, string | CodecClass<T>>;
4
+ /**
5
+ * @name Struct
6
+ * @description
7
+ * A Struct defines an Object with key-value pairs - where the values are Codec values. It removes
8
+ * a lot of repetition from the actual coding, define a structure type, pass it the key/Codec
9
+ * values in the constructor and it manages the decoding. It is important that the constructor
10
+ * values matches 100% to the order in th Rust code, i.e. don't go crazy and make it alphabetical,
11
+ * it needs to decoded in the specific defined order.
12
+ * @noInheritDoc
13
+ */
14
+ export declare class Struct<S extends TypesDef = TypesDef, V extends {
15
+ [K in keyof S]: any;
16
+ } = {
17
+ [K in keyof S]: any;
18
+ }, E extends {
19
+ [K in keyof S]: string;
20
+ } = {
21
+ [K in keyof S]: string;
22
+ }> extends Map<keyof S, Codec> implements IStruct<keyof S> {
23
+ #private;
24
+ createdAtHash?: IU8a;
25
+ readonly initialU8aLength?: number;
26
+ constructor(registry: CodecRegistry, Types: S, value?: V | Map<unknown, unknown> | unknown[] | HexString | null, jsonMap?: Map<string, string>);
27
+ static with<S extends TypesDef>(Types: S, jsonMap?: Map<string, string>): CodecClass<Struct<S>>;
28
+ /**
29
+ * @description The available keys for this struct
30
+ */
31
+ get defKeys(): string[];
32
+ getT<T>(key: string): T;
33
+ /**
34
+ * @description Checks if the value is an empty value
35
+ */
36
+ get isEmpty(): boolean;
37
+ /**
38
+ * @description Returns the Type description of the structure
39
+ */
40
+ get Type(): E;
41
+ /**
42
+ * @description The length of the value when encoded as a Uint8Array
43
+ */
44
+ get encodedLength(): number;
45
+ /**
46
+ * @description returns a hash of the contents
47
+ */
48
+ get hash(): IU8a;
49
+ get registry(): CodecRegistry;
50
+ /**
51
+ * @description Compares the value of the input to see if there is a match
52
+ */
53
+ eq(other?: unknown): boolean;
54
+ /**
55
+ * @description Returns a specific names entry in the structure
56
+ * @param name The name of the entry to retrieve
57
+ */
58
+ get(name: keyof S): Codec | undefined;
59
+ /**
60
+ * @description Returns the values of a member at a specific index (Rather use get(name) for performance)
61
+ */
62
+ getAtIndex(index: number): Codec;
63
+ /**
64
+ * @description Converts the Object to an standard JavaScript Array
65
+ */
66
+ toArray(): Codec[];
67
+ /**
68
+ * @description Returns a hex string representation of the value
69
+ */
70
+ toHex(): HexString;
71
+ /**
72
+ * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
73
+ */
74
+ toHuman(isExtended?: boolean): Record<string, AnyJson>;
75
+ /**
76
+ * @description Converts the Object to JSON, typically used for RPC transfers
77
+ */
78
+ toJSON(): Record<string, AnyJson>;
79
+ /**
80
+ * @description Returns the base runtime type name for this instance
81
+ */
82
+ toRawType(): string;
83
+ /**
84
+ * @description Returns the string representation of the value
85
+ */
86
+ toString(): string;
87
+ /**
88
+ * @description Encodes the value as a Uint8Array as per the SCALE specifications
89
+ * @param isBare true when the value has none of the type-specific prefixes (internal)
90
+ */
91
+ toU8a(isBare?: BareOpts): Uint8Array;
92
+ }
93
+ export {};
@@ -0,0 +1,71 @@
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { AnyU8a, Codec, CodecRegistry, IU8a } from '../types';
3
+ /**
4
+ * @name Text
5
+ * @description
6
+ * This is a string wrapper, along with the length. It is used both for strings as well
7
+ * as items such as documentation. It simply extends the standard JS `String` built-in
8
+ * object, inheriting all methods exposed from `String`.
9
+ * @noInheritDoc
10
+ */
11
+ export declare class Text extends String implements Codec {
12
+ #private;
13
+ readonly registry: CodecRegistry;
14
+ createdAtHash?: IU8a;
15
+ constructor(registry: CodecRegistry, value?: null | Text | string | AnyU8a | {
16
+ toString: () => string;
17
+ });
18
+ /**
19
+ * @description The length of the value when encoded as a Uint8Array
20
+ */
21
+ get encodedLength(): number;
22
+ /**
23
+ * @description The length of the initial encoded value (Only available when constructed from a Uint8Array)
24
+ */
25
+ get initialU8aLength(): number | undefined;
26
+ /**
27
+ * @description returns a hash of the contents
28
+ */
29
+ get hash(): IU8a;
30
+ /**
31
+ * @description Checks if the value is an empty value
32
+ */
33
+ get isEmpty(): boolean;
34
+ /**
35
+ * @description The length of the value
36
+ */
37
+ get length(): number;
38
+ /**
39
+ * @description Compares the value of the input to see if there is a match
40
+ */
41
+ eq(other?: unknown): boolean;
42
+ /**
43
+ * @description Set an override value for this
44
+ */
45
+ setOverride(override: string): void;
46
+ /**
47
+ * @description Returns a hex string representation of the value
48
+ */
49
+ toHex(): HexString;
50
+ /**
51
+ * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
52
+ */
53
+ toHuman(): string;
54
+ /**
55
+ * @description Converts the Object to JSON, typically used for RPC transfers
56
+ */
57
+ toJSON(): string;
58
+ /**
59
+ * @description Returns the base runtime type name for this instance
60
+ */
61
+ toRawType(): string;
62
+ /**
63
+ * @description Returns the string representation of the value
64
+ */
65
+ toString(): string;
66
+ /**
67
+ * @description Encodes the value as a Uint8Array as per the SCALE specifications
68
+ * @param isBare true when the value has none of the type-specific prefixes (internal)
69
+ */
70
+ toU8a(isBare?: boolean): Uint8Array;
71
+ }
@@ -0,0 +1,7 @@
1
+ export { bool, bool as Bool } from './Bool';
2
+ export { CodecDate, CodecDate as Date } from './Date';
3
+ export { Json } from './Json';
4
+ export { Raw } from './Raw';
5
+ export { CodecSet, CodecSet as Set } from './Set';
6
+ export { Struct } from './Struct';
7
+ export { Text } from './Text';