@polkadot/types-codec 6.12.2-24 → 6.12.2-25

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,84 @@
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { AnyJson, Codec, CodecRegistry, IU8a, IVec } from '../types';
3
+ /**
4
+ * @name AbstractArray
5
+ * @description
6
+ * This manages codec arrays. It is an extension to Array, providing
7
+ * specific encoding/decoding on top of the base type.
8
+ * @noInheritDoc
9
+ */
10
+ export declare abstract class AbstractArray<T extends Codec> extends Array<T> implements IVec<T> {
11
+ readonly registry: CodecRegistry;
12
+ createdAtHash?: IU8a;
13
+ readonly initialU8aLength?: number;
14
+ protected constructor(registry: CodecRegistry, values: T[], initialU8aLength?: number);
15
+ /**
16
+ * @description The length of the value when encoded as a Uint8Array
17
+ */
18
+ get encodedLength(): number;
19
+ /**
20
+ * @description returns a hash of the contents
21
+ */
22
+ get hash(): IU8a;
23
+ /**
24
+ * @description Checks if the value is an empty value
25
+ */
26
+ get isEmpty(): boolean;
27
+ /**
28
+ * @description The length of the value
29
+ */
30
+ get length(): number;
31
+ /**
32
+ * @description Compares the value of the input to see if there is a match
33
+ */
34
+ eq(other?: unknown): boolean;
35
+ /**
36
+ * @description Converts the Object to an standard JavaScript Array
37
+ */
38
+ toArray(): T[];
39
+ /**
40
+ * @description Returns a hex string representation of the value
41
+ */
42
+ toHex(): HexString;
43
+ /**
44
+ * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
45
+ */
46
+ toHuman(isExtended?: boolean): AnyJson;
47
+ /**
48
+ * @description Converts the Object to JSON, typically used for RPC transfers
49
+ */
50
+ toJSON(): AnyJson;
51
+ /**
52
+ * @description Returns the base runtime type name for this instance
53
+ */
54
+ abstract toRawType(): string;
55
+ /**
56
+ * @description Returns the string representation of the value
57
+ */
58
+ toString(): string;
59
+ /**
60
+ * @description Encodes the value as a Uint8Array as per the SCALE specifications
61
+ * @param isBare true when the value has none of the type-specific prefixes (internal)
62
+ */
63
+ toU8a(isBare?: boolean): Uint8Array;
64
+ /**
65
+ * @description Concatenates two arrays
66
+ */
67
+ concat(other: T[]): T[];
68
+ /**
69
+ * @description Filters the array with the callback
70
+ */
71
+ filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: unknown): T[];
72
+ /**
73
+ * @description Maps the array with the callback
74
+ */
75
+ map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: unknown): U[];
76
+ /**
77
+ * @description Checks if the array includes a specific value
78
+ */
79
+ includes(check: unknown): boolean;
80
+ /**
81
+ * @description Returns a slice of an array
82
+ */
83
+ slice(start?: number, end?: number): T[];
84
+ }
@@ -0,0 +1,75 @@
1
+ /// <reference types="bn.js" />
2
+ import type { HexString } from '@polkadot/util/types';
3
+ import type { AnyNumber, CodecRegistry, INumber, IU8a, UIntBitLength } from '../types';
4
+ import { BN } from '@polkadot/util';
5
+ export declare const DEFAULT_UINT_BITS = 64;
6
+ /**
7
+ * @name AbstractInt
8
+ * @ignore
9
+ * @noInheritDoc
10
+ */
11
+ export declare abstract class AbstractInt extends BN implements INumber {
12
+ #private;
13
+ readonly registry: CodecRegistry;
14
+ createdAtHash?: IU8a;
15
+ readonly encodedLength: number;
16
+ constructor(registry: CodecRegistry, value?: AnyNumber, bitLength?: UIntBitLength, isSigned?: boolean);
17
+ /**
18
+ * @description returns a hash of the contents
19
+ */
20
+ get hash(): IU8a;
21
+ /**
22
+ * @description Checks if the value is a zero value (align elsewhere)
23
+ */
24
+ get isEmpty(): boolean;
25
+ /**
26
+ * @description Checks if the value is an unsigned type
27
+ */
28
+ get isUnsigned(): boolean;
29
+ /**
30
+ * @description Returns the number of bits in the value
31
+ */
32
+ bitLength(): number;
33
+ /**
34
+ * @description Compares the value of the input to see if there is a match
35
+ */
36
+ eq(other?: unknown): boolean;
37
+ /**
38
+ * @description True if this value is the max of the type
39
+ */
40
+ isMax(): boolean;
41
+ /**
42
+ * @description Returns a BigInt representation of the number
43
+ */
44
+ toBigInt(): bigint;
45
+ /**
46
+ * @description Returns the BN representation of the number. (Compatibility)
47
+ */
48
+ toBn(): BN;
49
+ /**
50
+ * @description Returns a hex string representation of the value
51
+ */
52
+ toHex(isLe?: boolean): HexString;
53
+ /**
54
+ * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
55
+ */
56
+ toHuman(isExpanded?: boolean): string;
57
+ /**
58
+ * @description Converts the Object to JSON, typically used for RPC transfers
59
+ */
60
+ toJSON(onlyHex?: boolean): any;
61
+ /**
62
+ * @description Returns the base runtime type name for this instance
63
+ */
64
+ toRawType(): string;
65
+ /**
66
+ * @description Returns the string representation of the value
67
+ * @param base The base to use for the conversion
68
+ */
69
+ toString(base?: number): 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
+ }
@@ -0,0 +1,2 @@
1
+ export { AbstractArray } from './AbstractArray';
2
+ export { AbstractInt } from './AbstractInt';
package/base/Base.d.ts ADDED
@@ -0,0 +1,56 @@
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { AnyJson, BareOpts, Codec, CodecRegistry, IU8a } from '../types';
3
+ /**
4
+ * @name Base
5
+ * @description A type extends the Base class, when it holds a value
6
+ */
7
+ export declare abstract class Base<T extends Codec> implements Codec {
8
+ #private;
9
+ createdAtHash?: IU8a;
10
+ readonly initialU8aLength?: number;
11
+ protected constructor(registry: CodecRegistry, value: T, initialU8aLength?: number);
12
+ /**
13
+ * @description The length of the value when encoded as a Uint8Array
14
+ */
15
+ get encodedLength(): number;
16
+ /**
17
+ * @description returns a hash of the contents
18
+ */
19
+ get hash(): IU8a;
20
+ get inner(): T;
21
+ /**
22
+ * @description Checks if the value is an empty value
23
+ */
24
+ get isEmpty(): boolean;
25
+ get registry(): CodecRegistry;
26
+ /**
27
+ * @description Compares the value of the input to see if there is a match
28
+ */
29
+ eq(other?: unknown): boolean;
30
+ /**
31
+ * @description Returns a hex string representation of the value. isLe returns a LE (number-only) representation
32
+ */
33
+ toHex(isLe?: boolean): HexString;
34
+ /**
35
+ * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
36
+ */
37
+ toHuman(isExtended?: boolean): AnyJson;
38
+ /**
39
+ * @description Converts the Object to JSON, typically used for RPC transfers
40
+ */
41
+ toJSON(): AnyJson;
42
+ /**
43
+ * @description Returns the string representation of the value
44
+ */
45
+ toString(): string;
46
+ /**
47
+ * @description Encodes the value as a Uint8Array as per the SCALE specifications
48
+ * @param isBare true when the value has none of the type-specific prefixes (internal)
49
+ */
50
+ toU8a(isBare?: BareOpts): Uint8Array;
51
+ /**
52
+ * @description Returns the base runtime type name for this instance
53
+ */
54
+ toRawType(): string;
55
+ unwrap(): T;
56
+ }
@@ -0,0 +1,83 @@
1
+ /// <reference types="bn.js" />
2
+ import type { BN } from '@polkadot/util';
3
+ import type { HexString } from '@polkadot/util/types';
4
+ import type { AnyJson, AnyNumber, CodecClass, CodecRegistry, ICompact, INumber, IU8a } from '../types';
5
+ /**
6
+ * @name Compact
7
+ * @description
8
+ * A compact length-encoding codec wrapper. It performs the same function as Length, however
9
+ * differs in that it uses a variable number of bytes to do the actual encoding. This is mostly
10
+ * used by other types to add length-prefixed encoding, or in the case of wrapped types, taking
11
+ * a number and making the compact representation thereof
12
+ */
13
+ export declare class Compact<T extends INumber> implements ICompact<T> {
14
+ #private;
15
+ readonly registry: CodecRegistry;
16
+ createdAtHash?: IU8a;
17
+ readonly initialU8aLength?: number;
18
+ constructor(registry: CodecRegistry, Type: CodecClass<T> | string, value?: Compact<T> | AnyNumber);
19
+ static with<T extends INumber>(Type: CodecClass<T> | string): CodecClass<Compact<T>>;
20
+ /** @internal */
21
+ static decodeCompact<T extends INumber>(registry: CodecRegistry, Type: CodecClass<T>, value: Compact<T> | AnyNumber): [T, number];
22
+ /**
23
+ * @description The length of the value when encoded as a Uint8Array
24
+ */
25
+ get encodedLength(): number;
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 Returns the number of bits in the value
36
+ */
37
+ bitLength(): 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 Returns a BigInt representation of the number
44
+ */
45
+ toBigInt(): bigint;
46
+ /**
47
+ * @description Returns the BN representation of the number
48
+ */
49
+ toBn(): BN;
50
+ /**
51
+ * @description Returns a hex string representation of the value. isLe returns a LE (number-only) representation
52
+ */
53
+ toHex(isLe?: boolean): HexString;
54
+ /**
55
+ * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
56
+ */
57
+ toHuman(isExtended?: boolean): AnyJson;
58
+ /**
59
+ * @description Converts the Object to JSON, typically used for RPC transfers
60
+ */
61
+ toJSON(): AnyJson;
62
+ /**
63
+ * @description Returns the number representation for the value
64
+ */
65
+ toNumber(): number;
66
+ /**
67
+ * @description Returns the base runtime type name for this instance
68
+ */
69
+ toRawType(): string;
70
+ /**
71
+ * @description Returns the string representation of the value
72
+ */
73
+ toString(): string;
74
+ /**
75
+ * @description Encodes the value as a Uint8Array as per the SCALE specifications
76
+ * @param isBare true when the value has none of the type-specific prefixes (internal)
77
+ */
78
+ toU8a(isBare?: boolean): Uint8Array;
79
+ /**
80
+ * @description Returns the embedded [[UInt]] or [[Moment]] value
81
+ */
82
+ unwrap(): T;
83
+ }
@@ -0,0 +1,33 @@
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { AnyJson, Codec, CodecClass, CodecRegistry, IU8a } from '../types';
3
+ /**
4
+ * @name DoNotConstruct
5
+ * @description
6
+ * An unknown type that fails on construction with the type info
7
+ */
8
+ export declare class DoNotConstruct implements Codec {
9
+ #private;
10
+ readonly registry: CodecRegistry;
11
+ createdAtHash?: IU8a;
12
+ constructor(registry: CodecRegistry, typeName?: string);
13
+ static with(typeName?: string): CodecClass;
14
+ /**
15
+ * @description The length of the value when encoded as a Uint8Array
16
+ */
17
+ get encodedLength(): number;
18
+ /**
19
+ * @description returns a hash of the contents
20
+ */
21
+ get hash(): IU8a;
22
+ /**
23
+ * @description Checks if the value is an empty value (always true)
24
+ */
25
+ get isEmpty(): boolean;
26
+ eq(): boolean;
27
+ toHex(): HexString;
28
+ toHuman(): AnyJson;
29
+ toJSON(): AnyJson;
30
+ toRawType(): string;
31
+ toString(): string;
32
+ toU8a(): Uint8Array;
33
+ }
package/base/Enum.d.ts ADDED
@@ -0,0 +1,105 @@
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { AnyJson, Codec, CodecClass, CodecRegistry, IEnum, IU8a } from '../types';
3
+ export interface EnumCodecClass<T = Codec> {
4
+ new (registry: CodecRegistry, value?: any, index?: number): T;
5
+ }
6
+ /**
7
+ * @name Enum
8
+ * @description
9
+ * This implements an enum, that based on the value wraps a different type. It is effectively
10
+ * an extension to enum where the value type is determined by the actual index.
11
+ */
12
+ export declare class Enum implements IEnum {
13
+ #private;
14
+ readonly registry: CodecRegistry;
15
+ createdAtHash?: IU8a;
16
+ readonly initialU8aLength?: number;
17
+ constructor(registry: CodecRegistry, Types: Record<string, string | CodecClass> | Record<string, number> | string[], value?: unknown, index?: number);
18
+ static with(Types: Record<string, string | CodecClass> | Record<string, number> | string[]): EnumCodecClass<Enum>;
19
+ /**
20
+ * @description The length of the value when encoded as a Uint8Array
21
+ */
22
+ get encodedLength(): number;
23
+ /**
24
+ * @description returns a hash of the contents
25
+ */
26
+ get hash(): IU8a;
27
+ /**
28
+ * @description The index of the enum value
29
+ */
30
+ get index(): number;
31
+ /**
32
+ * @description The value of the enum
33
+ */
34
+ get inner(): Codec;
35
+ /**
36
+ * @description true if this is a basic enum (no values)
37
+ */
38
+ get isBasic(): boolean;
39
+ /**
40
+ * @description Checks if the value is an empty value
41
+ */
42
+ get isEmpty(): boolean;
43
+ /**
44
+ * @description Checks if the Enum points to a [[Null]] type
45
+ */
46
+ get isNone(): boolean;
47
+ /**
48
+ * @description Checks if the Enum points to a [[Null]] type
49
+ * @deprecated use isNone
50
+ */
51
+ get isNull(): boolean;
52
+ /**
53
+ * @description The available keys for this enum
54
+ */
55
+ get defIndexes(): number[];
56
+ /**
57
+ * @description The available keys for this enum
58
+ */
59
+ get defKeys(): string[];
60
+ /**
61
+ * @description The name of the type this enum value represents
62
+ */
63
+ get type(): string;
64
+ /**
65
+ * @description The value of the enum
66
+ */
67
+ get value(): Codec;
68
+ /**
69
+ * @description Compares the value of the input to see if there is a match
70
+ */
71
+ eq(other?: unknown): boolean;
72
+ /**
73
+ * @description Returns a hex string representation of the value
74
+ */
75
+ toHex(): HexString;
76
+ /**
77
+ * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
78
+ */
79
+ toHuman(isExtended?: boolean): AnyJson;
80
+ /**
81
+ * @description Converts the Object to JSON, typically used for RPC transfers
82
+ */
83
+ toJSON(): AnyJson;
84
+ /**
85
+ * @description Returns the number representation for the value
86
+ */
87
+ toNumber(): number;
88
+ /**
89
+ * @description Returns a raw struct representation of the enum types
90
+ */
91
+ protected _toRawStruct(): string[] | Record<string, string | number>;
92
+ /**
93
+ * @description Returns the base runtime type name for this instance
94
+ */
95
+ toRawType(): string;
96
+ /**
97
+ * @description Returns the string representation of the value
98
+ */
99
+ toString(): string;
100
+ /**
101
+ * @description Encodes the value as a Uint8Array as per the SCALE specifications
102
+ * @param isBare true when the value has none of the type-specific prefixes (internal)
103
+ */
104
+ toU8a(isBare?: boolean): Uint8Array;
105
+ }
package/base/Int.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import type { AnyNumber, CodecClass, CodecRegistry, UIntBitLength } from '../types';
2
+ import { AbstractInt } from '../abstract/AbstractInt';
3
+ /**
4
+ * @name Int
5
+ * @description
6
+ * A generic signed integer codec. For Substrate all numbers are Little Endian encoded,
7
+ * this handles the encoding and decoding of those numbers. Upon construction
8
+ * the bitLength is provided and any additional use keeps the number to this
9
+ * length. This extends `BN`, so all methods available on a normal `BN` object
10
+ * is available here.
11
+ * @noInheritDoc
12
+ */
13
+ export declare class Int extends AbstractInt {
14
+ constructor(registry: CodecRegistry, value?: AnyNumber, bitLength?: UIntBitLength);
15
+ static with(bitLength: UIntBitLength, typeName?: string): CodecClass<Int>;
16
+ }
package/base/Null.d.ts ADDED
@@ -0,0 +1,54 @@
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { Codec, CodecRegistry, IU8a } from '../types';
3
+ /**
4
+ * @name Null
5
+ * @description
6
+ * Implements a type that does not contain anything (apart from `null`)
7
+ */
8
+ export declare class Null implements Codec {
9
+ readonly registry: CodecRegistry;
10
+ createdAtHash?: IU8a;
11
+ readonly initialU8aLength = 0;
12
+ constructor(registry: CodecRegistry);
13
+ /**
14
+ * @description The length of the value when encoded as a Uint8Array
15
+ */
16
+ get encodedLength(): number;
17
+ /**
18
+ * @description returns a hash of the contents
19
+ */
20
+ get hash(): IU8a;
21
+ /**
22
+ * @description Checks if the value is an empty value (always true)
23
+ */
24
+ get isEmpty(): boolean;
25
+ /**
26
+ * @description Compares the value of the input to see if there is a match
27
+ */
28
+ eq(other?: unknown): boolean;
29
+ /**
30
+ * @description Returns a hex string representation of the value
31
+ */
32
+ toHex(): HexString;
33
+ /**
34
+ * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
35
+ */
36
+ toHuman(): null;
37
+ /**
38
+ * @description Converts the Object to JSON, typically used for RPC transfers
39
+ */
40
+ toJSON(): null;
41
+ /**
42
+ * @description Returns the base runtime type name for this instance
43
+ */
44
+ toRawType(): string;
45
+ /**
46
+ * @description Returns the string representation of the value
47
+ */
48
+ toString(): string;
49
+ /**
50
+ * @description Encodes the value as a Uint8Array as per the SCALE specifications
51
+ * @param isBare true when the value has none of the type-specific prefixes (internal)
52
+ */
53
+ toU8a(isBare?: boolean): Uint8Array;
54
+ }
@@ -0,0 +1,88 @@
1
+ import type { HexString } from '@polkadot/util/types';
2
+ import type { AnyJson, Codec, CodecClass, CodecRegistry, IOption, IU8a } from '../types';
3
+ /**
4
+ * @name Option
5
+ * @description
6
+ * An Option is an optional field. Basically the first byte indicates that there is
7
+ * is value to follow. If the byte is `1` there is an actual value. So the Option
8
+ * implements that - decodes, checks for optionality and wraps the required structure
9
+ * with a value if/as required/found.
10
+ */
11
+ export declare class Option<T extends Codec> implements IOption<T> {
12
+ #private;
13
+ readonly registry: CodecRegistry;
14
+ createdAtHash?: IU8a;
15
+ constructor(registry: CodecRegistry, typeName: CodecClass<T> | string, value?: unknown);
16
+ static with<O extends Codec>(Type: CodecClass<O> | string): CodecClass<Option<O>>;
17
+ /**
18
+ * @description The length of the value when encoded as a Uint8Array
19
+ */
20
+ get encodedLength(): number;
21
+ /**
22
+ * @description The length of the initial encoded value (Only available when constructed from a Uint8Array)
23
+ */
24
+ get initialU8aLength(): number | undefined;
25
+ /**
26
+ * @description returns a hash of the contents
27
+ */
28
+ get hash(): IU8a;
29
+ /**
30
+ * @description Checks if the Option has no value
31
+ */
32
+ get isEmpty(): boolean;
33
+ /**
34
+ * @description Checks if the Option has no value
35
+ */
36
+ get isNone(): boolean;
37
+ /**
38
+ * @description Checks if the Option has a value
39
+ */
40
+ get isSome(): boolean;
41
+ /**
42
+ * @description The actual value for the Option
43
+ */
44
+ get value(): Codec;
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 Returns a hex string representation of the value
51
+ */
52
+ toHex(): HexString;
53
+ /**
54
+ * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
55
+ */
56
+ toHuman(isExtended?: boolean): AnyJson;
57
+ /**
58
+ * @description Converts the Object to JSON, typically used for RPC transfers
59
+ */
60
+ toJSON(): AnyJson;
61
+ /**
62
+ * @description Returns the base runtime type name for this instance
63
+ */
64
+ toRawType(isBare?: boolean): string;
65
+ /**
66
+ * @description Returns the string representation of the value
67
+ */
68
+ toString(): string;
69
+ /**
70
+ * @description Encodes the value as a Uint8Array as per the SCALE specifications
71
+ * @param isBare true when the value has none of the type-specific prefixes (internal)
72
+ */
73
+ toU8a(isBare?: boolean): Uint8Array;
74
+ /**
75
+ * @description Returns the value that the Option represents (if available), throws if null
76
+ */
77
+ unwrap(): T;
78
+ /**
79
+ * @description Returns the value that the Option represents (if available) or defaultValue if none
80
+ * @param defaultValue The value to return if the option isNone
81
+ */
82
+ unwrapOr<O>(defaultValue: O): T | O;
83
+ /**
84
+ * @description Returns the value that the Option represents (if available) or defaultValue if none
85
+ * @param defaultValue The value to return if the option isNone
86
+ */
87
+ unwrapOrDefault(): T;
88
+ }
@@ -0,0 +1,46 @@
1
+ import type { Codec, CodecClass, CodecRegistry, IResult } from '../types';
2
+ import { Enum } from './Enum';
3
+ /**
4
+ * @name Result
5
+ * @description
6
+ * A Result maps to the Rust Result type, that can either wrap a success or error value
7
+ */
8
+ export declare class Result<O extends Codec, E extends Codec> extends Enum implements IResult<O, E> {
9
+ constructor(registry: CodecRegistry, Ok: CodecClass<O> | string, Err: CodecClass<E> | string, value?: unknown);
10
+ static with<O extends Codec, E extends Codec>(Types: {
11
+ Ok: CodecClass<O> | string;
12
+ Err: CodecClass<E> | string;
13
+ }): CodecClass<Result<O, E>>;
14
+ /**
15
+ * @description Returns the wrapper Err value (if isErr)
16
+ */
17
+ get asErr(): E;
18
+ /**
19
+ * @deprecated Use asErr
20
+ */
21
+ get asError(): E;
22
+ /**
23
+ * @description Returns the wrapper Ok value (if isOk)
24
+ */
25
+ get asOk(): O;
26
+ /**
27
+ * @description Checks if the Result has no value
28
+ */
29
+ get isEmpty(): boolean;
30
+ /**
31
+ * @description Checks if the Result wraps an Err value
32
+ */
33
+ get isErr(): boolean;
34
+ /**
35
+ * @deprecated Use isErr
36
+ */
37
+ get isError(): boolean;
38
+ /**
39
+ * @description Checks if the Result wraps an Ok value
40
+ */
41
+ get isOk(): boolean;
42
+ /**
43
+ * @description Returns the base runtime type name for this instance
44
+ */
45
+ toRawType(): string;
46
+ }
@@ -0,0 +1,39 @@
1
+ import type { AnyTupleValue, Codec, CodecClass, CodecRegistry, ITuple } from '../types';
2
+ import { AbstractArray } from '../abstract/AbstractArray';
3
+ declare type TupleType = (CodecClass | string);
4
+ declare type TupleTypes = TupleType[] | {
5
+ [index: string]: CodecClass | string;
6
+ };
7
+ /**
8
+ * @name Tuple
9
+ * @description
10
+ * A Tuple defines an anonymous fixed-length array, where each element has its
11
+ * own type. It extends the base JS `Array` object.
12
+ */
13
+ export declare class Tuple extends AbstractArray<Codec> implements ITuple<Codec[]> {
14
+ #private;
15
+ constructor(registry: CodecRegistry, Types: TupleTypes | TupleType, value?: AnyTupleValue);
16
+ static with(Types: TupleTypes | TupleType): CodecClass<Tuple>;
17
+ /**
18
+ * @description The length of the value when encoded as a Uint8Array
19
+ */
20
+ get encodedLength(): number;
21
+ /**
22
+ * @description The types definition of the tuple
23
+ */
24
+ get Types(): string[];
25
+ /**
26
+ * @description Returns the base runtime type name for this instance
27
+ */
28
+ toRawType(): string;
29
+ /**
30
+ * @description Returns the string representation of the value
31
+ */
32
+ toString(): string;
33
+ /**
34
+ * @description Encodes the value as a Uint8Array as per the SCALE specifications
35
+ * @param isBare true when the value has none of the type-specific prefixes (internal)
36
+ */
37
+ toU8a(isBare?: boolean): Uint8Array;
38
+ }
39
+ export {};