@polkadot/types-codec 6.12.2-23 → 6.12.2-27
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/abstract/AbstractArray.d.ts +84 -0
- package/abstract/AbstractInt.d.ts +75 -0
- package/abstract/index.d.ts +2 -0
- package/base/Base.d.ts +56 -0
- package/base/Compact.d.ts +83 -0
- package/base/DoNotConstruct.d.ts +33 -0
- package/base/Enum.d.ts +105 -0
- package/base/Int.d.ts +16 -0
- package/base/Null.d.ts +54 -0
- package/base/Option.d.ts +88 -0
- package/base/Result.d.ts +46 -0
- package/base/Tuple.d.ts +39 -0
- package/base/UInt.d.ts +15 -0
- package/base/Vec.d.ts +28 -0
- package/base/VecAny.d.ts +15 -0
- package/base/VecFixed.d.ts +26 -0
- package/base/index.d.ts +13 -0
- package/bundle.d.ts +7 -0
- package/detectPackage.d.ts +1 -0
- package/extended/BTreeMap.d.ts +5 -0
- package/extended/BTreeSet.d.ts +55 -0
- package/extended/BitVec.d.ts +26 -0
- package/extended/Bytes.d.ts +25 -0
- package/extended/HashMap.d.ts +5 -0
- package/extended/Linkage.d.ts +31 -0
- package/extended/Map.d.ts +50 -0
- package/extended/Range.d.ts +30 -0
- package/extended/Type.d.ts +16 -0
- package/extended/U8aFixed.d.ts +16 -0
- package/extended/WrapperOpaque.d.ts +14 -0
- package/extended/index.d.ts +11 -0
- package/index.d.ts +2 -0
- package/native/Bool.d.ts +62 -0
- package/native/Date.d.ts +76 -0
- package/native/Json.d.ts +56 -0
- package/native/Raw.d.ts +90 -0
- package/native/Set.d.ts +76 -0
- package/native/Struct.d.ts +93 -0
- package/native/Text.d.ts +71 -0
- package/native/index.d.ts +7 -0
- package/package.json +74 -3
- package/packageInfo.cjs +1 -1
- package/packageInfo.d.ts +4 -0
- package/packageInfo.js +1 -1
- package/primitive/I128.d.ts +11 -0
- package/primitive/I16.d.ts +11 -0
- package/primitive/I256.d.ts +11 -0
- package/primitive/I32.d.ts +11 -0
- package/primitive/I64.d.ts +11 -0
- package/primitive/I8.d.ts +11 -0
- package/primitive/U128.d.ts +11 -0
- package/primitive/U16.d.ts +11 -0
- package/primitive/U256.d.ts +11 -0
- package/primitive/U32.d.ts +11 -0
- package/primitive/U64.d.ts +11 -0
- package/primitive/U8.d.ts +11 -0
- package/primitive/USize.d.ts +12 -0
- package/primitive/index.d.ts +13 -0
- package/types/codec.d.ts +77 -0
- package/types/helpers.d.ts +14 -0
- package/types/index.d.ts +4 -0
- package/types/interfaces.d.ts +69 -0
- package/types/registry.d.ts +61 -0
- package/utils/compareArray.d.ts +1 -0
- package/utils/compareMap.d.ts +1 -0
- package/utils/compareSet.d.ts +1 -0
- package/utils/decodeU8a.d.ts +13 -0
- package/utils/index.d.ts +9 -0
- package/utils/mapToTypeMap.d.ts +5 -0
- package/utils/sanitize.d.ts +16 -0
- package/utils/sortValues.d.ts +13 -0
- package/utils/typeToConstructor.d.ts +2 -0
- package/utils/typesToMap.d.ts +2 -0
- package/utils/util.d.ts +3 -0
package/base/UInt.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CodecClass, UIntBitLength } from '../types';
|
|
2
|
+
import { AbstractInt } from '../abstract/AbstractInt';
|
|
3
|
+
/**
|
|
4
|
+
* @name UInt
|
|
5
|
+
* @description
|
|
6
|
+
* A generic unsigned 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 UInt extends AbstractInt {
|
|
14
|
+
static with(bitLength: UIntBitLength, typeName?: string): CodecClass<UInt>;
|
|
15
|
+
}
|
package/base/Vec.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { Codec, CodecClass, CodecRegistry } from '../types';
|
|
3
|
+
import { AbstractArray } from '../abstract/AbstractArray';
|
|
4
|
+
export declare function decodeVec<T extends Codec>(registry: CodecRegistry, Type: CodecClass<T>, value: Uint8Array | HexString | unknown[], length?: number): [T[], number, number];
|
|
5
|
+
/**
|
|
6
|
+
* @name Vec
|
|
7
|
+
* @description
|
|
8
|
+
* This manages codec arrays. Internally it keeps track of the length (as decoded) and allows
|
|
9
|
+
* construction with the passed `Type` in the constructor. It is an extension to Array, providing
|
|
10
|
+
* specific encoding/decoding on top of the base type.
|
|
11
|
+
*/
|
|
12
|
+
export declare class Vec<T extends Codec> extends AbstractArray<T> {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(registry: CodecRegistry, Type: CodecClass<T> | string, value?: Uint8Array | HexString | unknown[]);
|
|
15
|
+
static with<O extends Codec>(Type: CodecClass<O> | string): CodecClass<Vec<O>>;
|
|
16
|
+
/**
|
|
17
|
+
* @description The type for the items
|
|
18
|
+
*/
|
|
19
|
+
get Type(): string;
|
|
20
|
+
/**
|
|
21
|
+
* @description Finds the index of the value in the array
|
|
22
|
+
*/
|
|
23
|
+
indexOf(_other?: unknown): number;
|
|
24
|
+
/**
|
|
25
|
+
* @description Returns the base runtime type name for this instance
|
|
26
|
+
*/
|
|
27
|
+
toRawType(): string;
|
|
28
|
+
}
|
package/base/VecAny.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Codec } from '../types';
|
|
2
|
+
import { AbstractArray } from '../abstract/AbstractArray';
|
|
3
|
+
/**
|
|
4
|
+
* @name VecAny
|
|
5
|
+
* @description
|
|
6
|
+
* This manages codec arrays, assuming that the inputs are already of type Codec. Unlike
|
|
7
|
+
* a vector, this can be used to manage array-like structures with variable arguments of
|
|
8
|
+
* any types
|
|
9
|
+
*/
|
|
10
|
+
export declare class VecAny<T extends Codec> extends AbstractArray<T> {
|
|
11
|
+
/**
|
|
12
|
+
* @description Returns the base runtime type name for this instance
|
|
13
|
+
*/
|
|
14
|
+
toRawType(): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { Codec, CodecClass, CodecRegistry } from '../types';
|
|
3
|
+
import { AbstractArray } from '../abstract/AbstractArray';
|
|
4
|
+
/**
|
|
5
|
+
* @name VecFixed
|
|
6
|
+
* @description
|
|
7
|
+
* This manages codec arrays of a fixed length
|
|
8
|
+
*/
|
|
9
|
+
export declare class VecFixed<T extends Codec> extends AbstractArray<T> {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(registry: CodecRegistry, Type: CodecClass<T> | string, length: number, value?: Uint8Array | HexString | unknown[]);
|
|
12
|
+
static with<O extends Codec>(Type: CodecClass<O> | string, length: number): CodecClass<VecFixed<O>>;
|
|
13
|
+
/**
|
|
14
|
+
* @description The type for the items
|
|
15
|
+
*/
|
|
16
|
+
get Type(): string;
|
|
17
|
+
/**
|
|
18
|
+
* @description The length of the value when encoded as a Uint8Array
|
|
19
|
+
*/
|
|
20
|
+
get encodedLength(): number;
|
|
21
|
+
toU8a(): Uint8Array;
|
|
22
|
+
/**
|
|
23
|
+
* @description Returns the base runtime type name for this instance
|
|
24
|
+
*/
|
|
25
|
+
toRawType(): string;
|
|
26
|
+
}
|
package/base/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { Base } from './Base';
|
|
2
|
+
export { Compact } from './Compact';
|
|
3
|
+
export { DoNotConstruct } from './DoNotConstruct';
|
|
4
|
+
export { Enum } from './Enum';
|
|
5
|
+
export { Int } from './Int';
|
|
6
|
+
export { Null } from './Null';
|
|
7
|
+
export { Option } from './Option';
|
|
8
|
+
export { Result } from './Result';
|
|
9
|
+
export { Tuple } from './Tuple';
|
|
10
|
+
export { UInt } from './UInt';
|
|
11
|
+
export { Vec } from './Vec';
|
|
12
|
+
export { VecAny } from './VecAny';
|
|
13
|
+
export { VecFixed } from './VecFixed';
|
package/bundle.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Codec, CodecClass } from '../types';
|
|
2
|
+
import { CodecMap } from './Map';
|
|
3
|
+
export declare class BTreeMap<K extends Codec = Codec, V extends Codec = Codec> extends CodecMap<K, V> {
|
|
4
|
+
static with<K extends Codec, V extends Codec>(keyType: CodecClass<K> | string, valType: CodecClass<V> | string): CodecClass<CodecMap<K, V>>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { AnyJson, Codec, CodecClass, CodecRegistry, ISet, IU8a } from '../types';
|
|
3
|
+
export declare class BTreeSet<V extends Codec = Codec> extends Set<V> implements ISet<V> {
|
|
4
|
+
#private;
|
|
5
|
+
readonly registry: CodecRegistry;
|
|
6
|
+
createdAtHash?: IU8a;
|
|
7
|
+
readonly initialU8aLength?: number;
|
|
8
|
+
constructor(registry: CodecRegistry, valType: CodecClass<V> | string, rawValue?: Uint8Array | string | string[] | Set<any>);
|
|
9
|
+
static with<V extends Codec>(valType: CodecClass<V> | string): CodecClass<BTreeSet<V>>;
|
|
10
|
+
/**
|
|
11
|
+
* @description The length of the value when encoded as a Uint8Array
|
|
12
|
+
*/
|
|
13
|
+
get encodedLength(): number;
|
|
14
|
+
/**
|
|
15
|
+
* @description Returns a hash of the value
|
|
16
|
+
*/
|
|
17
|
+
get hash(): IU8a;
|
|
18
|
+
/**
|
|
19
|
+
* @description Checks if the value is an empty value
|
|
20
|
+
*/
|
|
21
|
+
get isEmpty(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* @description The actual set values as a string[]
|
|
24
|
+
*/
|
|
25
|
+
get strings(): string[];
|
|
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(): 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 base runtime type name for this instance
|
|
44
|
+
*/
|
|
45
|
+
toRawType(): string;
|
|
46
|
+
/**
|
|
47
|
+
* @description Returns the string representation of the value
|
|
48
|
+
*/
|
|
49
|
+
toString(): string;
|
|
50
|
+
/**
|
|
51
|
+
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
|
52
|
+
* @param isBare true when the value has none of the type-specific prefixes (internal)
|
|
53
|
+
*/
|
|
54
|
+
toU8a(isBare?: boolean): Uint8Array;
|
|
55
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AnyU8a, CodecRegistry } from '../types';
|
|
2
|
+
import { Raw } from '../native/Raw';
|
|
3
|
+
/**
|
|
4
|
+
* @name BitVec
|
|
5
|
+
* @description
|
|
6
|
+
* A BitVec that represents an array of bits. The bits are however stored encoded. The difference between this
|
|
7
|
+
* and a normal Bytes would be that the length prefix indicates the number of bits encoded, not the bytes
|
|
8
|
+
*/
|
|
9
|
+
export declare class BitVec extends Raw {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(registry: CodecRegistry, value?: AnyU8a);
|
|
12
|
+
/**
|
|
13
|
+
* @description The length of the value when encoded as a Uint8Array
|
|
14
|
+
*/
|
|
15
|
+
get encodedLength(): number;
|
|
16
|
+
toHuman(): string;
|
|
17
|
+
/**
|
|
18
|
+
* @description Returns the base runtime type name for this instance
|
|
19
|
+
*/
|
|
20
|
+
toRawType(): string;
|
|
21
|
+
/**
|
|
22
|
+
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
|
23
|
+
* @param isBare true when the value has none of the type-specific prefixes (internal)
|
|
24
|
+
*/
|
|
25
|
+
toU8a(isBare?: boolean): Uint8Array;
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AnyU8a, CodecRegistry } from '../types';
|
|
2
|
+
import { Raw } from '../native/Raw';
|
|
3
|
+
/**
|
|
4
|
+
* @name Bytes
|
|
5
|
+
* @description
|
|
6
|
+
* A Bytes wrapper for Vec<u8>. The significant difference between this and a normal Uint8Array
|
|
7
|
+
* is that this version allows for length-encoding. (i.e. it is a variable-item codec, the same
|
|
8
|
+
* as what is found in [[Text]] and [[Vec]])
|
|
9
|
+
*/
|
|
10
|
+
export declare class Bytes extends Raw {
|
|
11
|
+
constructor(registry: CodecRegistry, value?: AnyU8a);
|
|
12
|
+
/**
|
|
13
|
+
* @description The length of the value when encoded as a Uint8Array
|
|
14
|
+
*/
|
|
15
|
+
get encodedLength(): number;
|
|
16
|
+
/**
|
|
17
|
+
* @description Returns the base runtime type name for this instance
|
|
18
|
+
*/
|
|
19
|
+
toRawType(): string;
|
|
20
|
+
/**
|
|
21
|
+
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
|
22
|
+
* @param isBare true when the value has none of the type-specific prefixes (internal)
|
|
23
|
+
*/
|
|
24
|
+
toU8a(isBare?: boolean): Uint8Array;
|
|
25
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Codec, CodecClass } from '../types';
|
|
2
|
+
import { CodecMap } from './Map';
|
|
3
|
+
export declare class HashMap<K extends Codec = Codec, V extends Codec = Codec> extends CodecMap<K, V> {
|
|
4
|
+
static with<K extends Codec, V extends Codec>(keyType: CodecClass<K> | string, valType: CodecClass<V> | string): CodecClass<CodecMap<K, V>>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Codec, CodecClass, CodecRegistry } from '../types';
|
|
2
|
+
import { Option } from '../base/Option';
|
|
3
|
+
import { Tuple } from '../base/Tuple';
|
|
4
|
+
import { Struct } from '../native/Struct';
|
|
5
|
+
declare type TypeWithValues = [CodecClass, any[]];
|
|
6
|
+
/**
|
|
7
|
+
* @name Linkage
|
|
8
|
+
* @description The wrapper for the result from a LinkedMap
|
|
9
|
+
*/
|
|
10
|
+
export declare class Linkage<T extends Codec> extends Struct {
|
|
11
|
+
constructor(registry: CodecRegistry, Type: CodecClass | string, value?: unknown);
|
|
12
|
+
static withKey<O extends Codec>(Type: CodecClass | string): CodecClass<Linkage<O>>;
|
|
13
|
+
get previous(): Option<T>;
|
|
14
|
+
get next(): Option<T>;
|
|
15
|
+
/**
|
|
16
|
+
* @description Returns the base runtime type name for this instance
|
|
17
|
+
*/
|
|
18
|
+
toRawType(): string;
|
|
19
|
+
/**
|
|
20
|
+
* @description Custom toU8a which with bare mode does not return the linkage if empty
|
|
21
|
+
*/
|
|
22
|
+
toU8a(): Uint8Array;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @name LinkageResult
|
|
26
|
+
* @description A Linkage keys/Values tuple
|
|
27
|
+
*/
|
|
28
|
+
export declare class LinkageResult extends Tuple {
|
|
29
|
+
constructor(registry: CodecRegistry, [TypeKey, keys]: TypeWithValues, [TypeValue, values]: TypeWithValues);
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { AnyJson, Codec, CodecClass, CodecRegistry, IMap, IU8a } from '../types';
|
|
3
|
+
export declare class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends Map<K, V> implements IMap<K, V> {
|
|
4
|
+
#private;
|
|
5
|
+
readonly registry: CodecRegistry;
|
|
6
|
+
createdAtHash?: IU8a;
|
|
7
|
+
readonly initialU8aLength?: number;
|
|
8
|
+
constructor(registry: CodecRegistry, keyType: CodecClass<K> | string, valType: CodecClass<V> | string, rawValue: Uint8Array | string | Map<any, any> | undefined, type?: 'BTreeMap' | 'HashMap');
|
|
9
|
+
/**
|
|
10
|
+
* @description The length of the value when encoded as a Uint8Array
|
|
11
|
+
*/
|
|
12
|
+
get encodedLength(): number;
|
|
13
|
+
/**
|
|
14
|
+
* @description Returns a hash of the value
|
|
15
|
+
*/
|
|
16
|
+
get hash(): IU8a;
|
|
17
|
+
/**
|
|
18
|
+
* @description Checks if the value is an empty value
|
|
19
|
+
*/
|
|
20
|
+
get isEmpty(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* @description Compares the value of the input to see if there is a match
|
|
23
|
+
*/
|
|
24
|
+
eq(other?: unknown): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @description Returns a hex string representation of the value. isLe returns a LE (number-only) representation
|
|
27
|
+
*/
|
|
28
|
+
toHex(): HexString;
|
|
29
|
+
/**
|
|
30
|
+
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
|
31
|
+
*/
|
|
32
|
+
toHuman(isExtended?: boolean): Record<string, AnyJson>;
|
|
33
|
+
/**
|
|
34
|
+
* @description Converts the Object to JSON, typically used for RPC transfers
|
|
35
|
+
*/
|
|
36
|
+
toJSON(): Record<string, AnyJson>;
|
|
37
|
+
/**
|
|
38
|
+
* @description Returns the base runtime type name for this instance
|
|
39
|
+
*/
|
|
40
|
+
toRawType(): string;
|
|
41
|
+
/**
|
|
42
|
+
* @description Returns the string representation of the value
|
|
43
|
+
*/
|
|
44
|
+
toString(): string;
|
|
45
|
+
/**
|
|
46
|
+
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
|
47
|
+
* @param isBare true when the value has none of the type-specific prefixes (internal)
|
|
48
|
+
*/
|
|
49
|
+
toU8a(isBare?: boolean): Uint8Array;
|
|
50
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AnyTuple, CodecClass, CodecRegistry, INumber } from '../types';
|
|
2
|
+
import { Tuple } from '../base/Tuple';
|
|
3
|
+
declare type RangeType = 'Range' | 'RangeInclusive';
|
|
4
|
+
/**
|
|
5
|
+
* @name Range
|
|
6
|
+
* @description
|
|
7
|
+
* Rust `Range<T>` representation
|
|
8
|
+
*/
|
|
9
|
+
export declare class Range<T extends INumber> extends Tuple {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(registry: CodecRegistry, Type: CodecClass<T> | string, value?: AnyTuple, rangeName?: RangeType);
|
|
12
|
+
static with<T extends INumber>(Types: CodecClass<T> | string): CodecClass<Range<T>>;
|
|
13
|
+
/**
|
|
14
|
+
* @description Returns the starting range value
|
|
15
|
+
*/
|
|
16
|
+
get start(): T;
|
|
17
|
+
/**
|
|
18
|
+
* @description Returns the ending range value
|
|
19
|
+
*/
|
|
20
|
+
get end(): T;
|
|
21
|
+
/**
|
|
22
|
+
* @description Returns the base runtime type name for this instance
|
|
23
|
+
*/
|
|
24
|
+
toRawType(): string;
|
|
25
|
+
}
|
|
26
|
+
export declare class RangeInclusive<T extends INumber = INumber> extends Range<T> {
|
|
27
|
+
constructor(registry: CodecRegistry, type: CodecClass<T> | string, value?: AnyTuple);
|
|
28
|
+
static with<T extends INumber>(Types: CodecClass<T> | string): CodecClass<RangeInclusive<T>>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CodecRegistry } from '../types';
|
|
2
|
+
import { Text } from '../native/Text';
|
|
3
|
+
/**
|
|
4
|
+
* @name Type
|
|
5
|
+
* @description
|
|
6
|
+
* This is a extended version of Text, specifically to handle types. Here we rely fully
|
|
7
|
+
* on what Text provides us, however we also adjust the types received from the runtime,
|
|
8
|
+
* i.e. we remove the `T::` prefixes found in some types for consistency across implementation.
|
|
9
|
+
*/
|
|
10
|
+
export declare class Type extends Text {
|
|
11
|
+
constructor(registry: CodecRegistry, value?: Text | Uint8Array | string);
|
|
12
|
+
/**
|
|
13
|
+
* @description Returns the base runtime type name for this instance
|
|
14
|
+
*/
|
|
15
|
+
toRawType(): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AnyU8a, CodecClass, CodecRegistry, U8aBitLength } from '../types';
|
|
2
|
+
import { Raw } from '../native/Raw';
|
|
3
|
+
/**
|
|
4
|
+
* @name U8aFixed
|
|
5
|
+
* @description
|
|
6
|
+
* A U8a that manages a a sequence of bytes up to the specified bitLength. Not meant
|
|
7
|
+
* to be used directly, rather is should be subclassed with the specific lengths.
|
|
8
|
+
*/
|
|
9
|
+
export declare class U8aFixed extends Raw {
|
|
10
|
+
constructor(registry: CodecRegistry, value?: AnyU8a, bitLength?: U8aBitLength);
|
|
11
|
+
static with(bitLength: U8aBitLength, typeName?: string): CodecClass<U8aFixed>;
|
|
12
|
+
/**
|
|
13
|
+
* @description Returns the base runtime type name for this instance
|
|
14
|
+
*/
|
|
15
|
+
toRawType(): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Codec, CodecClass, CodecRegistry } from '../types';
|
|
2
|
+
import { Base } from '../base/Base';
|
|
3
|
+
export declare class WrapperOpaque<T extends Codec> extends Base<T> {
|
|
4
|
+
constructor(registry: CodecRegistry, Type: CodecClass<T> | string, value?: unknown);
|
|
5
|
+
static with<T extends Codec>(Type: CodecClass<T> | string): CodecClass<WrapperOpaque<T>>;
|
|
6
|
+
/**
|
|
7
|
+
* @description Returns the base runtime type name for this instance
|
|
8
|
+
*/
|
|
9
|
+
toRawType(): string;
|
|
10
|
+
/**
|
|
11
|
+
* @description The length of the value when encoded as a Uint8Array
|
|
12
|
+
*/
|
|
13
|
+
toU8a(isBare?: boolean): Uint8Array;
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { BitVec } from './BitVec';
|
|
2
|
+
export { BTreeMap } from './BTreeMap';
|
|
3
|
+
export { BTreeSet } from './BTreeSet';
|
|
4
|
+
export { Bytes } from './Bytes';
|
|
5
|
+
export { HashMap } from './HashMap';
|
|
6
|
+
export { Linkage } from './Linkage';
|
|
7
|
+
export { CodecMap, CodecMap as Map } from './Map';
|
|
8
|
+
export { Range, RangeInclusive } from './Range';
|
|
9
|
+
export { Type } from './Type';
|
|
10
|
+
export { U8aFixed } from './U8aFixed';
|
|
11
|
+
export { WrapperOpaque } from './WrapperOpaque';
|
package/index.d.ts
ADDED
package/native/Bool.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { Codec, CodecRegistry, IU8a } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* @name bool
|
|
5
|
+
* @description
|
|
6
|
+
* Representation for a boolean value in the system. It extends the base JS `Boolean` class
|
|
7
|
+
* @noInheritDoc
|
|
8
|
+
*/
|
|
9
|
+
export declare class bool extends Boolean implements Codec {
|
|
10
|
+
readonly registry: CodecRegistry;
|
|
11
|
+
createdAtHash?: IU8a;
|
|
12
|
+
constructor(registry: CodecRegistry, value?: bool | Boolean | Uint8Array | boolean | number);
|
|
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 (true when it wraps false/default)
|
|
23
|
+
*/
|
|
24
|
+
get isEmpty(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @description Checks if the value is an empty value (always false)
|
|
27
|
+
*/
|
|
28
|
+
get isFalse(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* @description Checks if the value is an empty value (always false)
|
|
31
|
+
*/
|
|
32
|
+
get isTrue(): boolean;
|
|
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 Returns a hex string representation of the value
|
|
39
|
+
*/
|
|
40
|
+
toHex(): HexString;
|
|
41
|
+
/**
|
|
42
|
+
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
|
43
|
+
*/
|
|
44
|
+
toHuman(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* @description Converts the Object to JSON, typically used for RPC transfers
|
|
47
|
+
*/
|
|
48
|
+
toJSON(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* @description Returns the base runtime type name for this instance
|
|
51
|
+
*/
|
|
52
|
+
toRawType(): string;
|
|
53
|
+
/**
|
|
54
|
+
* @description Returns the string representation of the value
|
|
55
|
+
*/
|
|
56
|
+
toString(): string;
|
|
57
|
+
/**
|
|
58
|
+
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
|
59
|
+
* @param isBare true when the value has none of the type-specific prefixes (internal)
|
|
60
|
+
*/
|
|
61
|
+
toU8a(isBare?: boolean): Uint8Array;
|
|
62
|
+
}
|
package/native/Date.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* @name Date
|
|
7
|
+
* @description
|
|
8
|
+
* A wrapper around seconds/timestamps. Internally the representation only has
|
|
9
|
+
* second precicion (aligning with Rust), so any numbers passed an/out are always
|
|
10
|
+
* per-second. For any encoding/decoding the 1000 multiplier would be applied to
|
|
11
|
+
* get it in line with JavaScript formats. It extends the base JS `Date` object
|
|
12
|
+
* and has all the methods available that are applicable to any `Date`
|
|
13
|
+
* @noInheritDoc
|
|
14
|
+
*/
|
|
15
|
+
export declare class CodecDate extends Date implements INumber {
|
|
16
|
+
readonly registry: CodecRegistry;
|
|
17
|
+
createdAtHash?: IU8a;
|
|
18
|
+
constructor(registry: CodecRegistry, value?: CodecDate | Date | AnyNumber);
|
|
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 Checks if the value is an empty value
|
|
29
|
+
*/
|
|
30
|
+
get isEmpty(): boolean;
|
|
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 Returns the number of bits in the value
|
|
37
|
+
*/
|
|
38
|
+
bitLength(): UIntBitLength;
|
|
39
|
+
/**
|
|
40
|
+
* @description Returns a BigInt representation of the number
|
|
41
|
+
*/
|
|
42
|
+
toBigInt(): bigint;
|
|
43
|
+
/**
|
|
44
|
+
* @description Returns the BN representation of the timestamp
|
|
45
|
+
*/
|
|
46
|
+
toBn(): BN;
|
|
47
|
+
/**
|
|
48
|
+
* @description Returns a hex string representation of the value
|
|
49
|
+
*/
|
|
50
|
+
toHex(isLe?: boolean): HexString;
|
|
51
|
+
/**
|
|
52
|
+
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
|
53
|
+
*/
|
|
54
|
+
toHuman(): string;
|
|
55
|
+
/**
|
|
56
|
+
* @description Converts the Object to JSON, typically used for RPC transfers
|
|
57
|
+
*/
|
|
58
|
+
toJSON(): any;
|
|
59
|
+
/**
|
|
60
|
+
* @description Returns the number representation for the timestamp
|
|
61
|
+
*/
|
|
62
|
+
toNumber(): number;
|
|
63
|
+
/**
|
|
64
|
+
* @description Returns the base runtime type name for this instance
|
|
65
|
+
*/
|
|
66
|
+
toRawType(): string;
|
|
67
|
+
/**
|
|
68
|
+
* @description Returns the string representation of the value
|
|
69
|
+
*/
|
|
70
|
+
toString(): string;
|
|
71
|
+
/**
|
|
72
|
+
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
|
73
|
+
* @param isBare true when the value has none of the type-specific prefixes (internal)
|
|
74
|
+
*/
|
|
75
|
+
toU8a(isBare?: boolean): Uint8Array;
|
|
76
|
+
}
|
package/native/Json.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { HexString } from '@polkadot/util/types';
|
|
2
|
+
import type { AnyJson, Codec, CodecRegistry, IU8a } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* @name Json
|
|
5
|
+
* @description
|
|
6
|
+
* Wraps the a JSON structure retrieve via RPC. It extends the standard JS Map with. While it
|
|
7
|
+
* implements a Codec, it is limited in that it can only be used with input objects via RPC,
|
|
8
|
+
* i.e. no hex decoding. Unlike a struct, this waps a JSON object with unknown keys
|
|
9
|
+
* @noInheritDoc
|
|
10
|
+
*/
|
|
11
|
+
export declare class Json extends Map<string, any> implements Codec {
|
|
12
|
+
readonly registry: CodecRegistry;
|
|
13
|
+
createdAtHash?: IU8a;
|
|
14
|
+
constructor(registry: CodecRegistry, value?: Record<string, unknown> | null);
|
|
15
|
+
/**
|
|
16
|
+
* @description Always 0, never encodes 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 Compares the value of the input to see if there is a match
|
|
29
|
+
*/
|
|
30
|
+
eq(other?: unknown): boolean;
|
|
31
|
+
getT<T>(key: string): T;
|
|
32
|
+
/**
|
|
33
|
+
* @description Unimplemented, will throw
|
|
34
|
+
*/
|
|
35
|
+
toHex(): HexString;
|
|
36
|
+
/**
|
|
37
|
+
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
|
38
|
+
*/
|
|
39
|
+
toHuman(): Record<string, AnyJson>;
|
|
40
|
+
/**
|
|
41
|
+
* @description Converts the Object to JSON, typically used for RPC transfers
|
|
42
|
+
*/
|
|
43
|
+
toJSON(): Record<string, AnyJson>;
|
|
44
|
+
/**
|
|
45
|
+
* @description Returns the base runtime type name for this instance
|
|
46
|
+
*/
|
|
47
|
+
toRawType(): string;
|
|
48
|
+
/**
|
|
49
|
+
* @description Returns the string representation of the value
|
|
50
|
+
*/
|
|
51
|
+
toString(): string;
|
|
52
|
+
/**
|
|
53
|
+
* @description Unimplemented, will throw
|
|
54
|
+
*/
|
|
55
|
+
toU8a(isBare?: boolean): Uint8Array;
|
|
56
|
+
}
|