@solana/codecs-core 2.0.0-experimental.5e8ac8d
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/LICENSE +20 -0
- package/README.md +25 -0
- package/dist/index.browser.cjs +185 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.js +168 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.development.js +191 -0
- package/dist/index.development.js.map +1 -0
- package/dist/index.native.js +168 -0
- package/dist/index.native.js.map +1 -0
- package/dist/index.node.cjs +185 -0
- package/dist/index.node.cjs.map +1 -0
- package/dist/index.node.js +168 -0
- package/dist/index.node.js.map +1 -0
- package/dist/index.production.min.js +26 -0
- package/dist/types/assertions.d.ts +16 -0
- package/dist/types/assertions.d.ts.map +1 -0
- package/dist/types/bytes.d.ts +17 -0
- package/dist/types/bytes.d.ts.map +1 -0
- package/dist/types/codec.d.ts +56 -0
- package/dist/types/codec.d.ts.map +1 -0
- package/dist/types/combine-codec.d.ts +8 -0
- package/dist/types/combine-codec.d.ts.map +1 -0
- package/dist/types/fix-codec.d.ts +26 -0
- package/dist/types/fix-codec.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/map-codec.d.ts +15 -0
- package/dist/types/map-codec.d.ts.map +1 -0
- package/dist/types/reverse-codec.d.ts +14 -0
- package/dist/types/reverse-codec.d.ts.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
this.globalThis = this.globalThis || {};
|
|
2
|
+
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
function E(e,r,o=0){if(r.length-o<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function s(e,r,o,n=0){let t=o.length-n;if(t<r)throw new Error(`Codec [${e}] expected ${r} bytes, got ${t}.`)}function a(e,r){if(e.fixedSize===null)throw new Error(r??"Expected a fixed-size codec, got a variable-size one.")}var u=e=>{let r=e.filter(i=>i.length);if(r.length===0)return e.length?e[0]:new Uint8Array;if(r.length===1)return r[0];let o=r.reduce((i,p)=>i+p.length,0),n=new Uint8Array(o),t=0;return r.forEach(i=>{n.set(i,t),t+=i.length;}),n},f=(e,r)=>{if(e.length>=r)return e;let o=new Uint8Array(r).fill(0);return o.set(e),o},m=(e,r)=>f(e.length<=r?e:e.slice(0,r),r);function c(e,r,o){if(e.fixedSize!==r.fixedSize)throw new Error(`Encoder and decoder must have the same fixed size, got [${e.fixedSize}] and [${r.fixedSize}].`);if(e.maxSize!==r.maxSize)throw new Error(`Encoder and decoder must have the same max size, got [${e.maxSize}] and [${r.maxSize}].`);if(o===void 0&&e.description!==r.description)throw new Error(`Encoder and decoder must have the same description, got [${e.description}] and [${r.description}]. Pass a custom description as a third argument if you want to override the description and bypass this error.`);return {decode:r.decode,description:o??e.description,encode:e.encode,fixedSize:e.fixedSize,maxSize:e.maxSize}}function x(e,r,o){return {description:o??`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r}}function l(e,r,o){return {...x(e,r,o),encode:n=>m(e.encode(n),r)}}function T(e,r,o){return {...x(e,r,o),decode:(n,t=0)=>{s("fixCodec",r,n,t),(t>0||n.length>r)&&(n=n.slice(t,t+r)),e.fixedSize!==null&&(n=m(n,e.fixedSize));let[i]=e.decode(n,0);return [i,t+r]}}}function $(e,r,o){return c(l(e,r,o),T(e,r,o))}function z(e,r){return {description:e.description,encode:o=>e.encode(r(o)),fixedSize:e.fixedSize,maxSize:e.maxSize}}function w(e,r){return {decode:(o,n=0)=>{let[t,i]=e.decode(o,n);return [r(t,o,n),i]},description:e.description,fixedSize:e.fixedSize,maxSize:e.maxSize}}function _(e,r,o){return {decode:o?w(e,o).decode:e.decode,description:e.description,encode:z(e,r).encode,fixedSize:e.fixedSize,maxSize:e.maxSize}}function C(e){return a(e,"Cannot reverse a codec of variable size."),{...e,encode:r=>e.encode(r).reverse()}}function F(e){return a(e,"Cannot reverse a codec of variable size."),{...e,decode:(r,o=0)=>{let n=o+e.fixedSize;if(o===0&&r.length===n)return e.decode(r.reverse(),o);let t=u([...o===0?[]:[r.slice(0,o)],r.slice(o,n).reverse(),...r.length===n?[]:[r.slice(n)]]);return e.decode(t,o)}}}function I(e){return c(C(e),F(e))}
|
|
6
|
+
|
|
7
|
+
exports.assertByteArrayHasEnoughBytesForCodec = s;
|
|
8
|
+
exports.assertByteArrayIsNotEmptyForCodec = E;
|
|
9
|
+
exports.assertFixedSizeCodec = a;
|
|
10
|
+
exports.combineCodec = c;
|
|
11
|
+
exports.fixBytes = m;
|
|
12
|
+
exports.fixCodec = $;
|
|
13
|
+
exports.fixDecoder = T;
|
|
14
|
+
exports.fixEncoder = l;
|
|
15
|
+
exports.mapCodec = _;
|
|
16
|
+
exports.mapDecoder = w;
|
|
17
|
+
exports.mapEncoder = z;
|
|
18
|
+
exports.mergeBytes = u;
|
|
19
|
+
exports.padBytes = f;
|
|
20
|
+
exports.reverseCodec = I;
|
|
21
|
+
exports.reverseDecoder = F;
|
|
22
|
+
exports.reverseEncoder = C;
|
|
23
|
+
|
|
24
|
+
return exports;
|
|
25
|
+
|
|
26
|
+
})({});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CodecData } from './codec';
|
|
2
|
+
/**
|
|
3
|
+
* Asserts that a given byte array is not empty.
|
|
4
|
+
*/
|
|
5
|
+
export declare function assertByteArrayIsNotEmptyForCodec(codecDescription: string, bytes: Uint8Array, offset?: number): void;
|
|
6
|
+
/**
|
|
7
|
+
* Asserts that a given byte array has enough bytes to decode.
|
|
8
|
+
*/
|
|
9
|
+
export declare function assertByteArrayHasEnoughBytesForCodec(codecDescription: string, expected: number, bytes: Uint8Array, offset?: number): void;
|
|
10
|
+
/**
|
|
11
|
+
* Asserts that a given codec is fixed-size codec.
|
|
12
|
+
*/
|
|
13
|
+
export declare function assertFixedSizeCodec(data: Pick<CodecData, 'fixedSize'>, message?: string): asserts data is {
|
|
14
|
+
fixedSize: number;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=assertions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../../src/assertions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC;;GAEG;AACH,wBAAgB,iCAAiC,CAAC,gBAAgB,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAI,QAKxG;AAED;;GAEG;AACH,wBAAgB,qCAAqC,CACjD,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,UAAU,EACjB,MAAM,SAAI,QAOb;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,EAClC,OAAO,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,IAAI;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAKvC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Concatenates an array of `Uint8Array`s into a single `Uint8Array`.
|
|
3
|
+
* Reuses the original byte array when applicable.
|
|
4
|
+
*/
|
|
5
|
+
export declare const mergeBytes: (byteArrays: Uint8Array[]) => Uint8Array;
|
|
6
|
+
/**
|
|
7
|
+
* Pads a `Uint8Array` with zeroes to the specified length.
|
|
8
|
+
* If the array is longer than the specified length, it is returned as-is.
|
|
9
|
+
*/
|
|
10
|
+
export declare const padBytes: (bytes: Uint8Array, length: number) => Uint8Array;
|
|
11
|
+
/**
|
|
12
|
+
* Fixes a `Uint8Array` to the specified length.
|
|
13
|
+
* If the array is longer than the specified length, it is truncated.
|
|
14
|
+
* If the array is shorter than the specified length, it is padded with zeroes.
|
|
15
|
+
*/
|
|
16
|
+
export declare const fixBytes: (bytes: Uint8Array, length: number) => Uint8Array;
|
|
17
|
+
//# sourceMappingURL=bytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/bytes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,UAAU,eAAgB,UAAU,EAAE,KAAG,UAkBrD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ,UAAW,UAAU,UAAU,MAAM,KAAG,UAK5D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,UAAW,UAAU,UAAU,MAAM,KAAG,UACgB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines an offset in bytes.
|
|
3
|
+
*/
|
|
4
|
+
export type Offset = number;
|
|
5
|
+
/**
|
|
6
|
+
* The shared attributes between codecs, encoders and decoders.
|
|
7
|
+
*/
|
|
8
|
+
export type CodecData = {
|
|
9
|
+
/** A description for the codec. */
|
|
10
|
+
description: string;
|
|
11
|
+
/** The fixed size of the encoded value in bytes, or `null` if it is variable. */
|
|
12
|
+
fixedSize: number | null;
|
|
13
|
+
/** The maximum size an encoded value can be in bytes, or `null` if it is variable. */
|
|
14
|
+
maxSize: number | null;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* An object that can encode a value to a `Uint8Array`.
|
|
18
|
+
*/
|
|
19
|
+
export type Encoder<T> = CodecData & {
|
|
20
|
+
/** The function that encodes a value into bytes. */
|
|
21
|
+
encode: (value: T) => Uint8Array;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* An object that can decode a value from a `Uint8Array`.
|
|
25
|
+
*/
|
|
26
|
+
export type Decoder<T> = CodecData & {
|
|
27
|
+
/**
|
|
28
|
+
* The function that decodes a value from bytes.
|
|
29
|
+
* It returns the decoded value and the number of bytes read.
|
|
30
|
+
*/
|
|
31
|
+
decode: (bytes: Uint8Array, offset?: Offset) => [T, Offset];
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* An object that can encode and decode a value to and from a `Uint8Array`.
|
|
35
|
+
* It supports encoding looser types than it decodes for convenience.
|
|
36
|
+
* For example, a `bigint` encoder will always decode to a `bigint`
|
|
37
|
+
* but can be used to encode a `number`.
|
|
38
|
+
*
|
|
39
|
+
* @typeParam From - The type of the value to encode.
|
|
40
|
+
* @typeParam To - The type of the decoded value. Defaults to `From`.
|
|
41
|
+
*/
|
|
42
|
+
export type Codec<From, To extends From = From> = Encoder<From> & Decoder<To>;
|
|
43
|
+
/**
|
|
44
|
+
* Defines common options for codec factories.
|
|
45
|
+
*/
|
|
46
|
+
export type BaseCodecOptions = {
|
|
47
|
+
/** A custom description for the Codec. */
|
|
48
|
+
description?: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Wraps all the attributes of an object in Codecs.
|
|
52
|
+
*/
|
|
53
|
+
export type WrapInCodec<T, U extends T = T> = {
|
|
54
|
+
[P in keyof T]: Codec<T[P], U[P]>;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/codec.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACpB,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,sFAAsF;IACtF,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,SAAS,GAAG;IACjC,oDAAoD;IACpD,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,UAAU,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,SAAS,GAAG;IACjC;;;OAGG;IACH,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;CAC/D,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,KAAK,CAAC,IAAI,EAAE,EAAE,SAAS,IAAI,GAAG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC3B,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI;KACzC,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CACpC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Codec, Decoder, Encoder } from './codec';
|
|
2
|
+
/**
|
|
3
|
+
* Combines an encoder and a decoder into a codec.
|
|
4
|
+
* The encoder and decoder must have the same fixed size, max size and description.
|
|
5
|
+
* If a description is provided, it will override the encoder and decoder descriptions.
|
|
6
|
+
*/
|
|
7
|
+
export declare function combineCodec<From, To extends From = From>(encoder: Encoder<From>, decoder: Decoder<To>, description?: string): Codec<From, To>;
|
|
8
|
+
//# sourceMappingURL=combine-codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combine-codec.d.ts","sourceRoot":"","sources":["../../src/combine-codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,SAAS,IAAI,GAAG,IAAI,EACrD,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EACtB,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,EACpB,WAAW,CAAC,EAAE,MAAM,GACrB,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CA8BjB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Codec, Decoder, Encoder } from './codec';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a fixed-size encoder from a given encoder.
|
|
4
|
+
*
|
|
5
|
+
* @param encoder - The encoder to wrap into a fixed-size encoder.
|
|
6
|
+
* @param fixedBytes - The fixed number of bytes to write.
|
|
7
|
+
* @param description - A custom description for the encoder.
|
|
8
|
+
*/
|
|
9
|
+
export declare function fixEncoder<T>(encoder: Encoder<T>, fixedBytes: number, description?: string): Encoder<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a fixed-size decoder from a given decoder.
|
|
12
|
+
*
|
|
13
|
+
* @param decoder - The decoder to wrap into a fixed-size decoder.
|
|
14
|
+
* @param fixedBytes - The fixed number of bytes to read.
|
|
15
|
+
* @param description - A custom description for the decoder.
|
|
16
|
+
*/
|
|
17
|
+
export declare function fixDecoder<T>(decoder: Decoder<T>, fixedBytes: number, description?: string): Decoder<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a fixed-size codec from a given codec.
|
|
20
|
+
*
|
|
21
|
+
* @param codec - The codec to wrap into a fixed-size codec.
|
|
22
|
+
* @param fixedBytes - The fixed number of bytes to read/write.
|
|
23
|
+
* @param description - A custom description for the codec.
|
|
24
|
+
*/
|
|
25
|
+
export declare function fixCodec<T, U extends T = T>(codec: Codec<T, U>, fixedBytes: number, description?: string): Codec<T, U>;
|
|
26
|
+
//# sourceMappingURL=fix-codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-codec.d.ts","sourceRoot":"","sources":["../../src/fix-codec.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAa,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAW7D;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAKvG;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAkBvG;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EACvC,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAClB,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,GACrB,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAEb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Codec, Decoder, Encoder } from './codec';
|
|
2
|
+
/**
|
|
3
|
+
* Converts an encoder A to a encoder B by mapping their values.
|
|
4
|
+
*/
|
|
5
|
+
export declare function mapEncoder<T, U>(encoder: Encoder<T>, unmap: (value: U) => T): Encoder<U>;
|
|
6
|
+
/**
|
|
7
|
+
* Converts an decoder A to a decoder B by mapping their values.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapDecoder<T, U>(decoder: Decoder<T>, map: (value: T, bytes: Uint8Array, offset: number) => U): Decoder<U>;
|
|
10
|
+
/**
|
|
11
|
+
* Converts a codec A to a codec B by mapping their values.
|
|
12
|
+
*/
|
|
13
|
+
export declare function mapCodec<NewFrom, OldFrom, To extends NewFrom & OldFrom>(codec: Codec<OldFrom, To>, unmap: (value: NewFrom) => OldFrom): Codec<NewFrom, To>;
|
|
14
|
+
export declare function mapCodec<NewFrom, OldFrom, NewTo extends NewFrom = NewFrom, OldTo extends OldFrom = OldFrom>(codec: Codec<OldFrom, OldTo>, unmap: (value: NewFrom) => OldFrom, map: (value: OldTo, bytes: Uint8Array, offset: number) => NewTo): Codec<NewFrom, NewTo>;
|
|
15
|
+
//# sourceMappingURL=map-codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-codec.d.ts","sourceRoot":"","sources":["../../src/map-codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElD;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAOxF;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAC3B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC,GACxD,OAAO,CAAC,CAAC,CAAC,CAUZ;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,SAAS,OAAO,GAAG,OAAO,EACnE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,EACzB,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,GACnC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACtB,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,SAAS,OAAO,GAAG,OAAO,EAAE,KAAK,SAAS,OAAO,GAAG,OAAO,EACvG,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,EAC5B,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,EAClC,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,KAAK,KAAK,GAChE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Codec, Decoder, Encoder } from './codec';
|
|
2
|
+
/**
|
|
3
|
+
* Reverses the bytes of a fixed-size encoder.
|
|
4
|
+
*/
|
|
5
|
+
export declare function reverseEncoder<T>(encoder: Encoder<T>): Encoder<T>;
|
|
6
|
+
/**
|
|
7
|
+
* Reverses the bytes of a fixed-size decoder.
|
|
8
|
+
*/
|
|
9
|
+
export declare function reverseDecoder<T>(decoder: Decoder<T>): Decoder<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Reverses the bytes of a fixed-size codec.
|
|
12
|
+
*/
|
|
13
|
+
export declare function reverseCodec<T, U extends T = T>(codec: Codec<T, U>): Codec<T, U>;
|
|
14
|
+
//# sourceMappingURL=reverse-codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reverse-codec.d.ts","sourceRoot":"","sources":["../../src/reverse-codec.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlD;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAMjE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAiBjE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAEhF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@solana/codecs-core",
|
|
3
|
+
"version": "2.0.0-experimental.5e8ac8d",
|
|
4
|
+
"description": "Core types and helpers for encoding and decoding byte arrays on Solana",
|
|
5
|
+
"exports": {
|
|
6
|
+
"browser": {
|
|
7
|
+
"import": "./dist/index.browser.js",
|
|
8
|
+
"require": "./dist/index.browser.cjs"
|
|
9
|
+
},
|
|
10
|
+
"node": {
|
|
11
|
+
"import": "./dist/index.node.js",
|
|
12
|
+
"require": "./dist/index.node.cjs"
|
|
13
|
+
},
|
|
14
|
+
"react-native": "./dist/index.native.js",
|
|
15
|
+
"types": "./dist/types/index.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"browser": {
|
|
18
|
+
"./dist/index.node.cjs": "./dist/index.browser.cjs",
|
|
19
|
+
"./dist/index.node.js": "./dist/index.browser.js"
|
|
20
|
+
},
|
|
21
|
+
"main": "./dist/index.node.cjs",
|
|
22
|
+
"module": "./dist/index.node.js",
|
|
23
|
+
"react-native": "./dist/index.native.js",
|
|
24
|
+
"types": "./dist/types/index.d.ts",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"files": [
|
|
27
|
+
"./dist/"
|
|
28
|
+
],
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"keywords": [
|
|
31
|
+
"blockchain",
|
|
32
|
+
"solana",
|
|
33
|
+
"web3"
|
|
34
|
+
],
|
|
35
|
+
"author": "Solana Labs Maintainers <maintainers@solanalabs.com>",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/solana-labs/solana-web3.js"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "http://github.com/solana-labs/solana-web3.js/issues"
|
|
43
|
+
},
|
|
44
|
+
"browserslist": [
|
|
45
|
+
"supports bigint and not dead",
|
|
46
|
+
"maintained node versions"
|
|
47
|
+
],
|
|
48
|
+
"engine": {
|
|
49
|
+
"node": ">=17.4"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@solana/eslint-config-solana": "^1.0.2",
|
|
53
|
+
"@swc/jest": "^0.2.28",
|
|
54
|
+
"@types/jest": "^29.5.5",
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
|
56
|
+
"@typescript-eslint/parser": "^6.3.0",
|
|
57
|
+
"agadoo": "^3.0.0",
|
|
58
|
+
"eslint": "^8.45.0",
|
|
59
|
+
"eslint-plugin-jest": "^27.2.3",
|
|
60
|
+
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
61
|
+
"jest": "^29.7.0",
|
|
62
|
+
"jest-environment-jsdom": "^29.6.4",
|
|
63
|
+
"jest-runner-eslint": "^2.1.0",
|
|
64
|
+
"jest-runner-prettier": "^1.0.0",
|
|
65
|
+
"prettier": "^2.8",
|
|
66
|
+
"tsup": "7.2.0",
|
|
67
|
+
"typescript": "^5.2.2",
|
|
68
|
+
"version-from-git": "^1.1.1",
|
|
69
|
+
"test-config": "0.0.0",
|
|
70
|
+
"build-scripts": "0.0.0",
|
|
71
|
+
"tsconfig": "0.0.0"
|
|
72
|
+
},
|
|
73
|
+
"bundlewatch": {
|
|
74
|
+
"defaultCompression": "gzip",
|
|
75
|
+
"files": [
|
|
76
|
+
{
|
|
77
|
+
"path": "./dist/index*.js"
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
"scripts": {
|
|
82
|
+
"compile:js": "tsup --config build-scripts/tsup.config.library.ts",
|
|
83
|
+
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
|
|
84
|
+
"dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch",
|
|
85
|
+
"publish-packages": "pnpm publish --tag experimental --access public --no-git-checks",
|
|
86
|
+
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/*",
|
|
87
|
+
"test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent",
|
|
88
|
+
"test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent",
|
|
89
|
+
"test:treeshakability:browser": "agadoo dist/index.browser.js",
|
|
90
|
+
"test:treeshakability:native": "agadoo dist/index.node.js",
|
|
91
|
+
"test:treeshakability:node": "agadoo dist/index.native.js",
|
|
92
|
+
"test:typecheck": "tsc --noEmit",
|
|
93
|
+
"test:unit:browser": "jest -c node_modules/test-config/jest-unit.config.browser.ts --rootDir . --silent",
|
|
94
|
+
"test:unit:node": "jest -c node_modules/test-config/jest-unit.config.node.ts --rootDir . --silent"
|
|
95
|
+
}
|
|
96
|
+
}
|