@solana/codecs-data-structures 2.0.0-experimental.df45965 → 2.0.0-experimental.dfb72ea
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/README.md +482 -4
- package/dist/index.browser.cjs +386 -484
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +390 -482
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +388 -482
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +386 -484
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +390 -482
- package/dist/index.node.js.map +1 -1
- package/dist/types/array.d.ts +39 -10
- package/dist/types/array.d.ts.map +1 -0
- package/dist/types/assertions.d.ts.map +1 -0
- package/dist/types/bit-array.d.ts +9 -9
- package/dist/types/bit-array.d.ts.map +1 -0
- package/dist/types/boolean.d.ts +22 -10
- package/dist/types/boolean.d.ts.map +1 -0
- package/dist/types/bytes.d.ts +18 -9
- package/dist/types/bytes.d.ts.map +1 -0
- package/dist/types/data-enum.d.ts +22 -24
- package/dist/types/data-enum.d.ts.map +1 -0
- package/dist/types/index.d.ts +13 -14
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/map.d.ts +28 -10
- package/dist/types/map.d.ts.map +1 -0
- package/dist/types/nullable.d.ts +28 -10
- package/dist/types/nullable.d.ts.map +1 -0
- package/dist/types/scalar-enum.d.ts +46 -15
- package/dist/types/scalar-enum.d.ts.map +1 -0
- package/dist/types/set.d.ts +28 -10
- package/dist/types/set.d.ts.map +1 -0
- package/dist/types/struct.d.ts +16 -21
- package/dist/types/struct.d.ts.map +1 -0
- package/dist/types/tuple.d.ts +22 -15
- package/dist/types/tuple.d.ts.map +1 -0
- package/dist/types/unit.d.ts +4 -12
- package/dist/types/unit.d.ts.map +1 -0
- package/dist/types/utils.d.ts +10 -2
- package/dist/types/utils.d.ts.map +1 -0
- package/package.json +12 -34
- package/dist/index.development.js +0 -865
- package/dist/index.development.js.map +0 -1
- package/dist/index.production.min.js +0 -51
- package/dist/types/array-like-codec-size.d.ts +0 -20
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Codec, Decoder, Encoder } from '@solana/codecs-core';
|
|
2
2
|
import { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';
|
|
3
3
|
/**
|
|
4
4
|
* Defines a data enum using discriminated union types.
|
|
@@ -43,48 +43,46 @@ export type GetDataEnumKind<T extends DataEnum, K extends T['__kind']> = Extract
|
|
|
43
43
|
export type GetDataEnumKindContent<T extends DataEnum, K extends T['__kind']> = Omit<Extract<T, {
|
|
44
44
|
__kind: K;
|
|
45
45
|
}>, '__kind'>;
|
|
46
|
-
/**
|
|
47
|
-
export type
|
|
48
|
-
T['__kind'],
|
|
49
|
-
keyof Omit<T, '__kind'> extends never ? Codec<Omit<T, '__kind'>, Omit<U, '__kind'>> | Codec<void> : Codec<Omit<T, '__kind'>, Omit<U, '__kind'>>
|
|
50
|
-
]>;
|
|
51
|
-
/** Get the name and encoder of each variant in a data enum. */
|
|
52
|
-
export type DataEnumToEncoderTuple<T extends DataEnum> = Array<T extends never ? never : [
|
|
53
|
-
T['__kind'],
|
|
54
|
-
keyof Omit<T, '__kind'> extends never ? Encoder<Omit<T, '__kind'>> | Encoder<void> : Encoder<Omit<T, '__kind'>>
|
|
55
|
-
]>;
|
|
56
|
-
/** Get the name and decoder of each variant in a data enum. */
|
|
57
|
-
export type DataEnumToDecoderTuple<T extends DataEnum> = Array<T extends never ? never : [
|
|
58
|
-
T['__kind'],
|
|
59
|
-
keyof Omit<T, '__kind'> extends never ? Decoder<Omit<T, '__kind'>> | Decoder<void> : Decoder<Omit<T, '__kind'>>
|
|
60
|
-
]>;
|
|
61
|
-
/** Defines the options for data enum codecs. */
|
|
62
|
-
export type DataEnumCodecOptions<TDiscriminator = NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecOptions & {
|
|
46
|
+
/** Defines the config for data enum codecs. */
|
|
47
|
+
export type DataEnumCodecConfig<TDiscriminator = NumberCodec | NumberEncoder | NumberDecoder> = {
|
|
63
48
|
/**
|
|
64
49
|
* The codec to use for the enum discriminator prefixing the variant.
|
|
65
50
|
* @defaultValue u8 prefix.
|
|
66
51
|
*/
|
|
67
52
|
size?: TDiscriminator;
|
|
68
53
|
};
|
|
54
|
+
type Variants<T> = readonly (readonly [string, T])[];
|
|
55
|
+
type ArrayIndices<T extends readonly unknown[]> = Exclude<Partial<T>['length'], T['length']> & number;
|
|
56
|
+
type GetEncoderTypeFromVariants<TVariants extends Variants<Encoder<any>>> = {
|
|
57
|
+
[I in ArrayIndices<TVariants>]: {
|
|
58
|
+
__kind: TVariants[I][0];
|
|
59
|
+
} & (TVariants[I][1] extends Encoder<infer TFrom> ? TFrom extends object ? TFrom : object : never);
|
|
60
|
+
}[ArrayIndices<TVariants>];
|
|
61
|
+
type GetDecoderTypeFromVariants<TVariants extends Variants<Decoder<any>>> = {
|
|
62
|
+
[I in ArrayIndices<TVariants>]: {
|
|
63
|
+
__kind: TVariants[I][0];
|
|
64
|
+
} & (TVariants[I][1] extends Decoder<infer TTo> ? TTo extends object ? TTo : object : never);
|
|
65
|
+
}[ArrayIndices<TVariants>];
|
|
69
66
|
/**
|
|
70
67
|
* Creates a data enum encoder.
|
|
71
68
|
*
|
|
72
69
|
* @param variants - The variant encoders of the data enum.
|
|
73
|
-
* @param
|
|
70
|
+
* @param config - A set of config for the encoder.
|
|
74
71
|
*/
|
|
75
|
-
export declare function getDataEnumEncoder<
|
|
72
|
+
export declare function getDataEnumEncoder<const TVariants extends Variants<Encoder<any>>>(variants: TVariants, config?: DataEnumCodecConfig<NumberEncoder>): Encoder<GetEncoderTypeFromVariants<TVariants>>;
|
|
76
73
|
/**
|
|
77
74
|
* Creates a data enum decoder.
|
|
78
75
|
*
|
|
79
76
|
* @param variants - The variant decoders of the data enum.
|
|
80
|
-
* @param
|
|
77
|
+
* @param config - A set of config for the decoder.
|
|
81
78
|
*/
|
|
82
|
-
export declare function getDataEnumDecoder<
|
|
79
|
+
export declare function getDataEnumDecoder<const TVariants extends Variants<Decoder<any>>>(variants: TVariants, config?: DataEnumCodecConfig<NumberDecoder>): Decoder<GetDecoderTypeFromVariants<TVariants>>;
|
|
83
80
|
/**
|
|
84
81
|
* Creates a data enum codec.
|
|
85
82
|
*
|
|
86
83
|
* @param variants - The variant codecs of the data enum.
|
|
87
|
-
* @param
|
|
84
|
+
* @param config - A set of config for the codec.
|
|
88
85
|
*/
|
|
89
|
-
export declare function getDataEnumCodec<
|
|
86
|
+
export declare function getDataEnumCodec<const TVariants extends Variants<Codec<any, any>>>(variants: TVariants, config?: DataEnumCodecConfig<NumberCodec>): Codec<GetEncoderTypeFromVariants<TVariants>, GetDecoderTypeFromVariants<TVariants> & GetEncoderTypeFromVariants<TVariants>>;
|
|
87
|
+
export {};
|
|
90
88
|
//# sourceMappingURL=data-enum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-enum.d.ts","sourceRoot":"","sources":["../../src/data-enum.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,KAAK,EAIL,OAAO,EACP,OAAO,EAGV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAA8B,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAI/G;;;;;;;;;GASG;AACH,MAAM,MAAM,QAAQ,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE;IAAE,MAAM,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AAEnG;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,IA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AAM,GAAG,CAAC,GACnG,GAAG,SAAS,MAAM,GACd,GAAG,GACH,MAAM,GACV,KAAK,CAAC;CACf,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;AAE3B;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,SAAS,SAAS,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAC7E,QAAQ,EAAE,SAAS,EACnB,MAAM,GAAE,mBAAmB,CAAC,aAAa,CAAM,GAChD,OAAO,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC,CAyBhD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,SAAS,SAAS,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAC7E,QAAQ,EAAE,SAAS,EACnB,MAAM,GAAE,mBAAmB,CAAC,aAAa,CAAM,GAChD,OAAO,CAAC,0BAA0B,CAAC,SAAS,CAAC,CAAC,CAuBhD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,SAAS,SAAS,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAC9E,QAAQ,EAAE,SAAS,EACnB,MAAM,GAAE,mBAAmB,CAAC,WAAW,CAAM,GAC9C,KAAK,CACJ,0BAA0B,CAAC,SAAS,CAAC,EACrC,0BAA0B,CAAC,SAAS,CAAC,GAAG,0BAA0B,CAAC,SAAS,CAAC,CAChF,CAOA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
export * from './array';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './
|
|
14
|
-
export * from './unit';
|
|
1
|
+
export * from './array.js';
|
|
2
|
+
export * from './assertions.js';
|
|
3
|
+
export * from './bit-array.js';
|
|
4
|
+
export * from './boolean.js';
|
|
5
|
+
export * from './bytes.js';
|
|
6
|
+
export * from './data-enum.js';
|
|
7
|
+
export * from './map.js';
|
|
8
|
+
export * from './nullable.js';
|
|
9
|
+
export * from './scalar-enum.js';
|
|
10
|
+
export * from './set.js';
|
|
11
|
+
export * from './struct.js';
|
|
12
|
+
export * from './tuple.js';
|
|
13
|
+
export * from './unit.js';
|
|
15
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
|
package/dist/types/map.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
|
|
2
2
|
import { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';
|
|
3
|
-
import { ArrayLikeCodecSize } from './array
|
|
4
|
-
/** Defines the
|
|
5
|
-
export type
|
|
3
|
+
import { ArrayLikeCodecSize } from './array.js';
|
|
4
|
+
/** Defines the config for Map codecs. */
|
|
5
|
+
export type MapCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = {
|
|
6
6
|
/**
|
|
7
7
|
* The size of the array.
|
|
8
8
|
* @defaultValue u32 prefix.
|
|
@@ -14,23 +14,41 @@ export type MapCodecOptions<TPrefix extends NumberCodec | NumberEncoder | Number
|
|
|
14
14
|
*
|
|
15
15
|
* @param key - The encoder to use for the map's keys.
|
|
16
16
|
* @param value - The encoder to use for the map's values.
|
|
17
|
-
* @param
|
|
17
|
+
* @param config - A set of config for the encoder.
|
|
18
18
|
*/
|
|
19
|
-
export declare function getMapEncoder<
|
|
19
|
+
export declare function getMapEncoder<TFromKey, TFromValue>(key: Encoder<TFromKey>, value: Encoder<TFromValue>, config: MapCodecConfig<NumberEncoder> & {
|
|
20
|
+
size: 0;
|
|
21
|
+
}): FixedSizeEncoder<Map<TFromKey, TFromValue>, 0>;
|
|
22
|
+
export declare function getMapEncoder<TFromKey, TFromValue>(key: FixedSizeEncoder<TFromKey>, value: FixedSizeEncoder<TFromValue>, config: MapCodecConfig<NumberEncoder> & {
|
|
23
|
+
size: number;
|
|
24
|
+
}): FixedSizeEncoder<Map<TFromKey, TFromValue>>;
|
|
25
|
+
export declare function getMapEncoder<TFromKey, TFromValue>(key: Encoder<TFromKey>, value: Encoder<TFromValue>, config?: MapCodecConfig<NumberEncoder>): VariableSizeEncoder<Map<TFromKey, TFromValue>>;
|
|
20
26
|
/**
|
|
21
27
|
* Creates a decoder for a map.
|
|
22
28
|
*
|
|
23
29
|
* @param key - The decoder to use for the map's keys.
|
|
24
30
|
* @param value - The decoder to use for the map's values.
|
|
25
|
-
* @param
|
|
31
|
+
* @param config - A set of config for the decoder.
|
|
26
32
|
*/
|
|
27
|
-
export declare function getMapDecoder<
|
|
33
|
+
export declare function getMapDecoder<TToKey, TToValue>(key: Decoder<TToKey>, value: Decoder<TToValue>, config: MapCodecConfig<NumberDecoder> & {
|
|
34
|
+
size: 0;
|
|
35
|
+
}): FixedSizeDecoder<Map<TToKey, TToValue>, 0>;
|
|
36
|
+
export declare function getMapDecoder<TToKey, TToValue>(key: FixedSizeDecoder<TToKey>, value: FixedSizeDecoder<TToValue>, config: MapCodecConfig<NumberDecoder> & {
|
|
37
|
+
size: number;
|
|
38
|
+
}): FixedSizeDecoder<Map<TToKey, TToValue>>;
|
|
39
|
+
export declare function getMapDecoder<TToKey, TToValue>(key: Decoder<TToKey>, value: Decoder<TToValue>, config?: MapCodecConfig<NumberDecoder>): VariableSizeDecoder<Map<TToKey, TToValue>>;
|
|
28
40
|
/**
|
|
29
41
|
* Creates a codec for a map.
|
|
30
42
|
*
|
|
31
43
|
* @param key - The codec to use for the map's keys.
|
|
32
44
|
* @param value - The codec to use for the map's values.
|
|
33
|
-
* @param
|
|
45
|
+
* @param config - A set of config for the codec.
|
|
34
46
|
*/
|
|
35
|
-
export declare function getMapCodec<
|
|
47
|
+
export declare function getMapCodec<TFromKey, TFromValue, TToKey extends TFromKey = TFromKey, TToValue extends TFromValue = TFromValue>(key: Codec<TFromKey, TToKey>, value: Codec<TFromValue, TToValue>, config: MapCodecConfig<NumberCodec> & {
|
|
48
|
+
size: 0;
|
|
49
|
+
}): FixedSizeCodec<Map<TFromKey, TFromValue>, Map<TToKey, TToValue>, 0>;
|
|
50
|
+
export declare function getMapCodec<TFromKey, TFromValue, TToKey extends TFromKey = TFromKey, TToValue extends TFromValue = TFromValue>(key: FixedSizeCodec<TFromKey, TToKey>, value: FixedSizeCodec<TFromValue, TToValue>, config: MapCodecConfig<NumberCodec> & {
|
|
51
|
+
size: number;
|
|
52
|
+
}): FixedSizeCodec<Map<TFromKey, TFromValue>, Map<TToKey, TToValue>>;
|
|
53
|
+
export declare function getMapCodec<TFromKey, TFromValue, TToKey extends TFromKey = TFromKey, TToValue extends TFromValue = TFromValue>(key: Codec<TFromKey, TToKey>, value: Codec<TFromValue, TToValue>, config?: MapCodecConfig<NumberCodec>): VariableSizeCodec<Map<TFromKey, TFromValue>, Map<TToKey, TToValue>>;
|
|
36
54
|
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 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4
|
-
export type
|
|
1
|
+
import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
|
|
2
|
+
import { FixedSizeNumberCodec, FixedSizeNumberDecoder, FixedSizeNumberEncoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';
|
|
3
|
+
/** Defines the config for nullable codecs. */
|
|
4
|
+
export type NullableCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = {
|
|
5
5
|
/**
|
|
6
6
|
* The codec to use for the boolean prefix.
|
|
7
7
|
* @defaultValue u8 prefix.
|
|
@@ -21,21 +21,39 @@ export type NullableCodecOptions<TPrefix extends NumberCodec | NumberEncoder | N
|
|
|
21
21
|
* Creates a encoder for an optional value using `null` as the `None` value.
|
|
22
22
|
*
|
|
23
23
|
* @param item - The encoder to use for the value that may be present.
|
|
24
|
-
* @param
|
|
24
|
+
* @param config - A set of config for the encoder.
|
|
25
25
|
*/
|
|
26
|
-
export declare function getNullableEncoder<
|
|
26
|
+
export declare function getNullableEncoder<TFrom>(item: FixedSizeEncoder<TFrom>, config: NullableCodecConfig<FixedSizeNumberEncoder> & {
|
|
27
|
+
fixed: true;
|
|
28
|
+
}): FixedSizeEncoder<TFrom | null>;
|
|
29
|
+
export declare function getNullableEncoder<TFrom>(item: FixedSizeEncoder<TFrom, 0>, config?: NullableCodecConfig<FixedSizeNumberEncoder>): FixedSizeEncoder<TFrom | null>;
|
|
30
|
+
export declare function getNullableEncoder<TFrom>(item: Encoder<TFrom>, config?: NullableCodecConfig<NumberEncoder> & {
|
|
31
|
+
fixed?: false;
|
|
32
|
+
}): VariableSizeEncoder<TFrom | null>;
|
|
27
33
|
/**
|
|
28
34
|
* Creates a decoder for an optional value using `null` as the `None` value.
|
|
29
35
|
*
|
|
30
36
|
* @param item - The decoder to use for the value that may be present.
|
|
31
|
-
* @param
|
|
37
|
+
* @param config - A set of config for the decoder.
|
|
32
38
|
*/
|
|
33
|
-
export declare function getNullableDecoder<
|
|
39
|
+
export declare function getNullableDecoder<TTo>(item: FixedSizeDecoder<TTo>, config: NullableCodecConfig<FixedSizeNumberDecoder> & {
|
|
40
|
+
fixed: true;
|
|
41
|
+
}): FixedSizeDecoder<TTo | null>;
|
|
42
|
+
export declare function getNullableDecoder<TTo>(item: FixedSizeDecoder<TTo, 0>, config?: NullableCodecConfig<FixedSizeNumberDecoder>): FixedSizeDecoder<TTo | null>;
|
|
43
|
+
export declare function getNullableDecoder<TTo>(item: Decoder<TTo>, config?: NullableCodecConfig<NumberDecoder> & {
|
|
44
|
+
fixed?: false;
|
|
45
|
+
}): VariableSizeDecoder<TTo | null>;
|
|
34
46
|
/**
|
|
35
47
|
* Creates a codec for an optional value using `null` as the `None` value.
|
|
36
48
|
*
|
|
37
49
|
* @param item - The codec to use for the value that may be present.
|
|
38
|
-
* @param
|
|
50
|
+
* @param config - A set of config for the codec.
|
|
39
51
|
*/
|
|
40
|
-
export declare function getNullableCodec<
|
|
52
|
+
export declare function getNullableCodec<TFrom, TTo extends TFrom = TFrom>(item: FixedSizeCodec<TFrom, TTo>, config: NullableCodecConfig<FixedSizeNumberCodec> & {
|
|
53
|
+
fixed: true;
|
|
54
|
+
}): FixedSizeCodec<TFrom | null, TTo | null>;
|
|
55
|
+
export declare function getNullableCodec<TFrom, TTo extends TFrom = TFrom>(item: FixedSizeCodec<TFrom, TTo, 0>, config?: NullableCodecConfig<FixedSizeNumberCodec>): FixedSizeCodec<TFrom | null, TTo | null>;
|
|
56
|
+
export declare function getNullableCodec<TFrom, TTo extends TFrom = TFrom>(item: Codec<TFrom, TTo>, config?: NullableCodecConfig<NumberCodec> & {
|
|
57
|
+
fixed?: false;
|
|
58
|
+
}): VariableSizeCodec<TFrom | null, TTo | null>;
|
|
41
59
|
//# sourceMappingURL=nullable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nullable.d.ts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AAG,SAAS,KAAK,GAAG,KAAK,EAC7D,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EACvB,MAAM,CAAC,EAAE,mBAAmB,CAAC,WAAW,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,GAC9D,iBAAiB,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC,CAAC"}
|
|
@@ -1,19 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';
|
|
1
|
+
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
|
|
2
|
+
import { FixedSizeNumberCodec, FixedSizeNumberDecoder, FixedSizeNumberEncoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';
|
|
3
3
|
/**
|
|
4
|
-
* Defines
|
|
4
|
+
* Defines the "lookup object" of a scalar enum.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
8
8
|
* enum Direction { Left, Right };
|
|
9
|
-
* type DirectionType = ScalarEnum<Direction>;
|
|
10
9
|
* ```
|
|
11
10
|
*/
|
|
12
|
-
export type ScalarEnum
|
|
13
|
-
[key:
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
|
|
11
|
+
export type ScalarEnum = {
|
|
12
|
+
[key: string]: string | number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Returns the allowed input for a scalar enum.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* enum Direction { Left, Right };
|
|
20
|
+
* type DirectionInput = ScalarEnumFrom<Direction>; // "Left" | "Right" | 0 | 1
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export type ScalarEnumFrom<TEnum extends ScalarEnum> = keyof TEnum | TEnum[keyof TEnum];
|
|
24
|
+
/**
|
|
25
|
+
* Returns all the available variants of a scalar enum.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* enum Direction { Left, Right };
|
|
30
|
+
* type DirectionOutput = ScalarEnumFrom<Direction>; // 0 | 1
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export type ScalarEnumTo<TEnum extends ScalarEnum> = TEnum[keyof TEnum];
|
|
34
|
+
/** Defines the config for scalar enum codecs. */
|
|
35
|
+
export type ScalarEnumCodecConfig<TDiscriminator extends NumberCodec | NumberEncoder | NumberDecoder> = {
|
|
17
36
|
/**
|
|
18
37
|
* The codec to use for the enum discriminator.
|
|
19
38
|
* @defaultValue u8 discriminator.
|
|
@@ -24,21 +43,33 @@ export type ScalarEnumCodecOptions<TDiscriminator extends NumberCodec | NumberEn
|
|
|
24
43
|
* Creates a scalar enum encoder.
|
|
25
44
|
*
|
|
26
45
|
* @param constructor - The constructor of the scalar enum.
|
|
27
|
-
* @param
|
|
46
|
+
* @param config - A set of config for the encoder.
|
|
28
47
|
*/
|
|
29
|
-
export declare function getScalarEnumEncoder<
|
|
48
|
+
export declare function getScalarEnumEncoder<TEnum extends ScalarEnum>(constructor: TEnum): FixedSizeEncoder<ScalarEnumFrom<TEnum>, 1>;
|
|
49
|
+
export declare function getScalarEnumEncoder<TEnum extends ScalarEnum, TSize extends number>(constructor: TEnum, config: ScalarEnumCodecConfig<NumberEncoder> & {
|
|
50
|
+
size: FixedSizeNumberEncoder<TSize>;
|
|
51
|
+
}): FixedSizeEncoder<ScalarEnumFrom<TEnum>, TSize>;
|
|
52
|
+
export declare function getScalarEnumEncoder<TEnum extends ScalarEnum>(constructor: TEnum, config?: ScalarEnumCodecConfig<NumberEncoder>): VariableSizeEncoder<ScalarEnumFrom<TEnum>>;
|
|
30
53
|
/**
|
|
31
54
|
* Creates a scalar enum decoder.
|
|
32
55
|
*
|
|
33
56
|
* @param constructor - The constructor of the scalar enum.
|
|
34
|
-
* @param
|
|
57
|
+
* @param config - A set of config for the decoder.
|
|
35
58
|
*/
|
|
36
|
-
export declare function getScalarEnumDecoder<
|
|
59
|
+
export declare function getScalarEnumDecoder<TEnum extends ScalarEnum>(constructor: TEnum): FixedSizeDecoder<ScalarEnumTo<TEnum>, 1>;
|
|
60
|
+
export declare function getScalarEnumDecoder<TEnum extends ScalarEnum, TSize extends number>(constructor: TEnum, config: ScalarEnumCodecConfig<NumberDecoder> & {
|
|
61
|
+
size: FixedSizeNumberDecoder<TSize>;
|
|
62
|
+
}): FixedSizeDecoder<ScalarEnumTo<TEnum>, TSize>;
|
|
63
|
+
export declare function getScalarEnumDecoder<TEnum extends ScalarEnum>(constructor: TEnum, config?: ScalarEnumCodecConfig<NumberDecoder>): VariableSizeDecoder<ScalarEnumTo<TEnum>>;
|
|
37
64
|
/**
|
|
38
65
|
* Creates a scalar enum codec.
|
|
39
66
|
*
|
|
40
67
|
* @param constructor - The constructor of the scalar enum.
|
|
41
|
-
* @param
|
|
68
|
+
* @param config - A set of config for the codec.
|
|
42
69
|
*/
|
|
43
|
-
export declare function getScalarEnumCodec<
|
|
70
|
+
export declare function getScalarEnumCodec<TEnum extends ScalarEnum>(constructor: TEnum): FixedSizeCodec<ScalarEnumFrom<TEnum>, ScalarEnumTo<TEnum>, 1>;
|
|
71
|
+
export declare function getScalarEnumCodec<TEnum extends ScalarEnum, TSize extends number>(constructor: TEnum, config: ScalarEnumCodecConfig<NumberCodec> & {
|
|
72
|
+
size: FixedSizeNumberCodec<TSize>;
|
|
73
|
+
}): FixedSizeCodec<ScalarEnumFrom<TEnum>, ScalarEnumTo<TEnum>, TSize>;
|
|
74
|
+
export declare function getScalarEnumCodec<TEnum extends ScalarEnum>(constructor: TEnum, config?: ScalarEnumCodecConfig<NumberCodec>): VariableSizeCodec<ScalarEnumFrom<TEnum>, ScalarEnumTo<TEnum>>;
|
|
44
75
|
//# sourceMappingURL=scalar-enum.d.ts.map
|
|
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E,GACnF,cAAc,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;AACrE,wBAAgB,kBAAkB,CAAC,KAAK,SAAS,UAAU,EACvD,WAAW,EAAE,KAAK,EAClB,MAAM,CAAC,EAAE,qBAAqB,CAAC,WAAW,CAAC,GAC5C,iBAAiB,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC"}
|
package/dist/types/set.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
|
|
2
2
|
import { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';
|
|
3
|
-
import { ArrayLikeCodecSize } from './array
|
|
4
|
-
/** Defines the
|
|
5
|
-
export type
|
|
3
|
+
import { ArrayLikeCodecSize } from './array.js';
|
|
4
|
+
/** Defines the config for set codecs. */
|
|
5
|
+
export type SetCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = {
|
|
6
6
|
/**
|
|
7
7
|
* The size of the set.
|
|
8
8
|
* @defaultValue u32 prefix.
|
|
@@ -13,21 +13,39 @@ export type SetCodecOptions<TPrefix extends NumberCodec | NumberEncoder | Number
|
|
|
13
13
|
* Encodes an set of items.
|
|
14
14
|
*
|
|
15
15
|
* @param item - The encoder to use for the set's items.
|
|
16
|
-
* @param
|
|
16
|
+
* @param config - A set of config for the encoder.
|
|
17
17
|
*/
|
|
18
|
-
export declare function getSetEncoder<
|
|
18
|
+
export declare function getSetEncoder<TFrom>(item: Encoder<TFrom>, config: SetCodecConfig<NumberEncoder> & {
|
|
19
|
+
size: 0;
|
|
20
|
+
}): FixedSizeEncoder<Set<TFrom>, 0>;
|
|
21
|
+
export declare function getSetEncoder<TFrom>(item: FixedSizeEncoder<TFrom>, config: SetCodecConfig<NumberEncoder> & {
|
|
22
|
+
size: number;
|
|
23
|
+
}): FixedSizeEncoder<Set<TFrom>>;
|
|
24
|
+
export declare function getSetEncoder<TFrom>(item: Encoder<TFrom>, config?: SetCodecConfig<NumberEncoder>): VariableSizeEncoder<Set<TFrom>>;
|
|
19
25
|
/**
|
|
20
26
|
* Decodes an set of items.
|
|
21
27
|
*
|
|
22
28
|
* @param item - The encoder to use for the set's items.
|
|
23
|
-
* @param
|
|
29
|
+
* @param config - A set of config for the encoder.
|
|
24
30
|
*/
|
|
25
|
-
export declare function getSetDecoder<
|
|
31
|
+
export declare function getSetDecoder<TTo>(item: Decoder<TTo>, config: SetCodecConfig<NumberDecoder> & {
|
|
32
|
+
size: 0;
|
|
33
|
+
}): FixedSizeDecoder<Set<TTo>, 0>;
|
|
34
|
+
export declare function getSetDecoder<TTo>(item: FixedSizeDecoder<TTo>, config: SetCodecConfig<NumberDecoder> & {
|
|
35
|
+
size: number;
|
|
36
|
+
}): FixedSizeDecoder<Set<TTo>>;
|
|
37
|
+
export declare function getSetDecoder<TTo>(item: Decoder<TTo>, config?: SetCodecConfig<NumberDecoder>): VariableSizeDecoder<Set<TTo>>;
|
|
26
38
|
/**
|
|
27
39
|
* Creates a codec for an set of items.
|
|
28
40
|
*
|
|
29
41
|
* @param item - The codec to use for the set's items.
|
|
30
|
-
* @param
|
|
42
|
+
* @param config - A set of config for the codec.
|
|
31
43
|
*/
|
|
32
|
-
export declare function getSetCodec<
|
|
44
|
+
export declare function getSetCodec<TFrom, TTo extends TFrom = TFrom>(item: Codec<TFrom, TTo>, config: SetCodecConfig<NumberCodec> & {
|
|
45
|
+
size: 0;
|
|
46
|
+
}): FixedSizeCodec<Set<TFrom>, Set<TTo>, 0>;
|
|
47
|
+
export declare function getSetCodec<TFrom, TTo extends TFrom = TFrom>(item: FixedSizeCodec<TFrom, TTo>, config: SetCodecConfig<NumberCodec> & {
|
|
48
|
+
size: number;
|
|
49
|
+
}): FixedSizeCodec<Set<TFrom>, Set<TTo>>;
|
|
50
|
+
export declare function getSetCodec<TFrom, TTo extends TFrom = TFrom>(item: Codec<TFrom, TTo>, config?: SetCodecConfig<NumberCodec>): VariableSizeCodec<Set<TFrom>, Set<TTo>>;
|
|
33
51
|
//# sourceMappingURL=set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../src/set.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EAEL,OAAO,EACP,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAGhB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEnF,OAAO,EAAE,kBAAkB,EAAoC,MAAM,SAAS,CAAC;AAE/E,yCAAyC;AACzC,MAAM,MAAM,cAAc,CAAC,OAAO,SAAS,WAAW,GAAG,aAAa,GAAG,aAAa,IAAI;IACtF;;;OAGG;IACH,IAAI,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;CACtC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAC/B,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,EACpB,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,GAAG;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,GACpD,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AACnC,wBAAgB,aAAa,CAAC,KAAK,EAC/B,IAAI,EAAE,gBAAgB,CAAC,KAAK,CAAC,EAC7B,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GACzD,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,CA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,IAAI,EAAE,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,EAChC,MAAM,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GACvD,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AACxC,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,SAAS,KAAK,GAAG,KAAK,EACxD,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EACvB,MAAM,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,GACrC,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC"}
|
package/dist/types/struct.d.ts
CHANGED
|
@@ -1,37 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
[
|
|
9
|
-
}
|
|
10
|
-
/** Get the name and codec of each field in a struct. */
|
|
11
|
-
export type StructToCodecTuple<T extends object, U extends T> = Array<{
|
|
12
|
-
[K in keyof T]: [K, Codec<T[K], U[K]>];
|
|
13
|
-
}[keyof T]>;
|
|
14
|
-
/** Defines the options for struct codecs. */
|
|
15
|
-
export type StructCodecOptions = BaseCodecOptions;
|
|
1
|
+
import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
|
|
2
|
+
type Fields<T> = readonly (readonly [string, T])[];
|
|
3
|
+
type ArrayIndices<T extends readonly unknown[]> = Exclude<Partial<T>['length'], T['length']> & number;
|
|
4
|
+
type GetEncoderTypeFromFields<TFields extends Fields<Encoder<any>>> = {
|
|
5
|
+
[I in ArrayIndices<TFields> as TFields[I][0]]: TFields[I][1] extends Encoder<infer TFrom> ? TFrom : never;
|
|
6
|
+
};
|
|
7
|
+
type GetDecoderTypeFromFields<TFields extends Fields<Decoder<any>>> = {
|
|
8
|
+
[I in ArrayIndices<TFields> as TFields[I][0]]: TFields[I][1] extends Decoder<infer TTo> ? TTo : never;
|
|
9
|
+
};
|
|
16
10
|
/**
|
|
17
11
|
* Creates a encoder for a custom object.
|
|
18
12
|
*
|
|
19
13
|
* @param fields - The name and encoder of each field.
|
|
20
|
-
* @param options - A set of options for the encoder.
|
|
21
14
|
*/
|
|
22
|
-
export declare function getStructEncoder<
|
|
15
|
+
export declare function getStructEncoder<const TFields extends Fields<FixedSizeEncoder<any>>>(fields: TFields): FixedSizeEncoder<GetEncoderTypeFromFields<TFields>>;
|
|
16
|
+
export declare function getStructEncoder<const TFields extends Fields<Encoder<any>>>(fields: TFields): VariableSizeEncoder<GetEncoderTypeFromFields<TFields>>;
|
|
23
17
|
/**
|
|
24
18
|
* Creates a decoder for a custom object.
|
|
25
19
|
*
|
|
26
20
|
* @param fields - The name and decoder of each field.
|
|
27
|
-
* @param options - A set of options for the decoder.
|
|
28
21
|
*/
|
|
29
|
-
export declare function getStructDecoder<
|
|
22
|
+
export declare function getStructDecoder<const TFields extends Fields<FixedSizeDecoder<any>>>(fields: TFields): FixedSizeDecoder<GetDecoderTypeFromFields<TFields>>;
|
|
23
|
+
export declare function getStructDecoder<const TFields extends Fields<Decoder<any>>>(fields: TFields): VariableSizeDecoder<GetDecoderTypeFromFields<TFields>>;
|
|
30
24
|
/**
|
|
31
25
|
* Creates a codec for a custom object.
|
|
32
26
|
*
|
|
33
27
|
* @param fields - The name and codec of each field.
|
|
34
|
-
* @param options - A set of options for the codec.
|
|
35
28
|
*/
|
|
36
|
-
export declare function getStructCodec<
|
|
29
|
+
export declare function getStructCodec<const TFields extends Fields<FixedSizeCodec<any>>>(fields: TFields): FixedSizeCodec<GetEncoderTypeFromFields<TFields>, GetDecoderTypeFromFields<TFields> & GetEncoderTypeFromFields<TFields>>;
|
|
30
|
+
export declare function getStructCodec<const TFields extends Fields<Codec<any>>>(fields: TFields): VariableSizeCodec<GetEncoderTypeFromFields<TFields>, GetDecoderTypeFromFields<TFields> & GetEncoderTypeFromFields<TFields>>;
|
|
31
|
+
export {};
|
|
37
32
|
//# sourceMappingURL=struct.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"struct.d.ts","sourceRoot":"","sources":["../../src/struct.ts"],"names":[],"mappings":"AACA,OAAO,EACH,KAAK,EAIL,OAAO,EACP,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAEhB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,qBAAqB,CAAC;AAI7B,KAAK,MAAM,CAAC,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACnD,KAAK,YAAY,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,MAAM,CAAC;AAEtG,KAAK,wBAAwB,CAAC,OAAO,SAAS,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI;KACjE,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,KAAK,CAAC,GAAG,KAAK,GAAG,KAAK;CAC5G,CAAC;AAEF,KAAK,wBAAwB,CAAC,OAAO,SAAS,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI;KACjE,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS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,EACjC,wBAAwB,CAAC,OAAO,CAAC,GAAG,wBAAwB,CAAC,OAAO,CAAC,CACxE,CAAC"}
|
package/dist/types/tuple.d.ts
CHANGED
|
@@ -1,36 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type WrapInEncoder<T> = {
|
|
5
|
-
[P in keyof T]: Encoder<T[P]>;
|
|
1
|
+
import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
|
|
2
|
+
type WrapInFixedSizeEncoder<TFrom> = {
|
|
3
|
+
[P in keyof TFrom]: FixedSizeEncoder<TFrom[P]>;
|
|
6
4
|
};
|
|
7
|
-
type
|
|
8
|
-
[P in keyof
|
|
5
|
+
type WrapInEncoder<TFrom> = {
|
|
6
|
+
[P in keyof TFrom]: Encoder<TFrom[P]>;
|
|
9
7
|
};
|
|
10
|
-
type
|
|
11
|
-
[P in keyof
|
|
8
|
+
type WrapInFixedSizeDecoder<TTo> = {
|
|
9
|
+
[P in keyof TTo]: FixedSizeDecoder<TTo[P]>;
|
|
10
|
+
};
|
|
11
|
+
type WrapInDecoder<TTo> = {
|
|
12
|
+
[P in keyof TTo]: Decoder<TTo[P]>;
|
|
13
|
+
};
|
|
14
|
+
type WrapInCodec<TFrom, TTo extends TFrom> = {
|
|
15
|
+
[P in keyof TFrom]: Codec<TFrom[P], TTo[P]>;
|
|
16
|
+
};
|
|
17
|
+
type WrapInFixedSizeCodec<TFrom, TTo extends TFrom> = {
|
|
18
|
+
[P in keyof TFrom]: FixedSizeCodec<TFrom[P], TTo[P]>;
|
|
12
19
|
};
|
|
13
20
|
type AnyArray = any[];
|
|
14
21
|
/**
|
|
15
22
|
* Creates a encoder for a tuple-like array.
|
|
16
23
|
*
|
|
17
24
|
* @param items - The encoders to use for each item in the tuple.
|
|
18
|
-
* @param options - A set of options for the encoder.
|
|
19
25
|
*/
|
|
20
|
-
export declare function getTupleEncoder<
|
|
26
|
+
export declare function getTupleEncoder<TFrom extends AnyArray>(items: WrapInFixedSizeEncoder<[...TFrom]>): FixedSizeEncoder<TFrom>;
|
|
27
|
+
export declare function getTupleEncoder<TFrom extends AnyArray>(items: WrapInEncoder<[...TFrom]>): VariableSizeEncoder<TFrom>;
|
|
21
28
|
/**
|
|
22
29
|
* Creates a decoder for a tuple-like array.
|
|
23
30
|
*
|
|
24
31
|
* @param items - The decoders to use for each item in the tuple.
|
|
25
|
-
* @param options - A set of options for the decoder.
|
|
26
32
|
*/
|
|
27
|
-
export declare function getTupleDecoder<
|
|
33
|
+
export declare function getTupleDecoder<TTo extends AnyArray>(items: WrapInFixedSizeDecoder<[...TTo]>): FixedSizeDecoder<TTo>;
|
|
34
|
+
export declare function getTupleDecoder<TTo extends AnyArray>(items: WrapInDecoder<[...TTo]>): VariableSizeDecoder<TTo>;
|
|
28
35
|
/**
|
|
29
36
|
* Creates a codec for a tuple-like array.
|
|
30
37
|
*
|
|
31
38
|
* @param items - The codecs to use for each item in the tuple.
|
|
32
|
-
* @param options - A set of options for the codec.
|
|
33
39
|
*/
|
|
34
|
-
export declare function getTupleCodec<
|
|
40
|
+
export declare function getTupleCodec<TFrom extends AnyArray, TTo extends TFrom = TFrom>(items: WrapInFixedSizeCodec<[...TFrom], [...TTo]>): FixedSizeCodec<TFrom, TTo>;
|
|
41
|
+
export declare function getTupleCodec<TFrom extends AnyArray, TTo extends TFrom = TFrom>(items: WrapInCodec<[...TFrom], [...TTo]>): VariableSizeCodec<TFrom, TTo>;
|
|
35
42
|
export {};
|
|
36
43
|
//# sourceMappingURL=tuple.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tuple.d.ts","sourceRoot":"","sources":["../../src/tuple.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EAIL,OAAO,EACP,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAEhB,i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AG,KAAK,CAAC,CAAC,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAuBtH;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,SAAS,QAAQ,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;AACtH,wBAAgB,eAAe,CAAC,GAAG,SAAS,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;AAmBhH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,SAAS,QAAQ,EAAE,GAAG,SAAS,KAAK,GAAG,KAAK,EAC3E,KAAK,EAAE,oBAAoB,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAClD,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC9B,wBAAgB,aAAa,CAAC,KAAK,SAAS,QAAQ,EAAE,GAAG,SAAS,KAAK,GAAG,KAAK,EAC3E,KAAK,EAAE,WAAW,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GACzC,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC"}
|
package/dist/types/unit.d.ts
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/** Defines the options for unit codecs. */
|
|
3
|
-
export type UnitSerializerOptions = BaseCodecOptions;
|
|
1
|
+
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
|
|
4
2
|
/**
|
|
5
3
|
* Creates a void encoder.
|
|
6
|
-
*
|
|
7
|
-
* @param options - A set of options for the encoder.
|
|
8
4
|
*/
|
|
9
|
-
export declare function getUnitEncoder(
|
|
5
|
+
export declare function getUnitEncoder(): FixedSizeEncoder<void, 0>;
|
|
10
6
|
/**
|
|
11
7
|
* Creates a void decoder.
|
|
12
|
-
*
|
|
13
|
-
* @param options - A set of options for the decoder.
|
|
14
8
|
*/
|
|
15
|
-
export declare function getUnitDecoder(
|
|
9
|
+
export declare function getUnitDecoder(): FixedSizeDecoder<void, 0>;
|
|
16
10
|
/**
|
|
17
11
|
* Creates a void codec.
|
|
18
|
-
*
|
|
19
|
-
* @param options - A set of options for the codec.
|
|
20
12
|
*/
|
|
21
|
-
export declare function getUnitCodec(
|
|
13
|
+
export declare function getUnitCodec(): FixedSizeCodec<void, void, 0>;
|
|
22
14
|
//# sourceMappingURL=unit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit.d.ts","sourceRoot":"","sources":["../../src/unit.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EACnB,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,wBAAgB,cAAc,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,CAK1D;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,CAK1D;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAE5D"}
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
/** Returns the max size or null if at least one size is null. */
|
|
2
1
|
export declare function maxCodecSizes(sizes: (number | null)[]): number | null;
|
|
3
|
-
/** Returns the sum of all sizes or null if at least one size is null. */
|
|
4
2
|
export declare function sumCodecSizes(sizes: (number | null)[]): number | null;
|
|
3
|
+
export declare function getFixedSize(codec: {
|
|
4
|
+
fixedSize: number;
|
|
5
|
+
} | {
|
|
6
|
+
maxSize?: number;
|
|
7
|
+
}): number | null;
|
|
8
|
+
export declare function getMaxSize(codec: {
|
|
9
|
+
fixedSize: number;
|
|
10
|
+
} | {
|
|
11
|
+
maxSize?: number;
|
|
12
|
+
}): number | null;
|
|
5
13
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,MAAM,GAAG,IAAI,CAKrE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,MAAM,GAAG,IAAI,CAErE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,IAAI,CAE/F;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,IAAI,CAE7F"}
|