UNPKG

@stable-io/cctp-sdk-definitions

Version:

Definitions for the CCTP SDK

31 lines 1.71 kB
import type { PlainObject, RoPair, RoTuple, Column, Entries, TupleZip, Spread } from "@stable-io/map-utils"; import type { Layout, DeriveType, ProperLayout } from "binary-layout"; export declare function transform<const L extends Layout, T>(layout: L, to: (derived: DeriveType<L>) => T, from: (transformed: T) => DeriveType<L>): { readonly binary: "bytes"; readonly layout: L; readonly custom: { readonly to: (derived: DeriveType<L>) => T; readonly from: (transformed: T) => DeriveType<L>; }; }; type NestedBytesItem = { name: string; binary: "bytes"; layout: ProperLayout; }; type Unwrap<L extends Layout, I extends NestedBytesItem> = DeriveType<L> extends infer O extends PlainObject ? I["name"] extends infer N extends keyof O ? ReturnType<typeof transform<L, Spread<O, N>>> : never : never; export declare function unwrap<const L extends Layout, const I extends NestedBytesItem>(layout: L, item: I): Unwrap<L, I>; type EnumSwitchVariants<V extends RoTuple<RoPair<string, RoTuple>>> = Entries<Column<V, 0>> extends infer VE extends RoTuple ? Column<V, 1> extends infer VC extends RoTuple ? TupleZip<[VE, VC]> : never : never; export declare const enumSwitchVariants: <const V extends RoTuple<RoPair<string, RoTuple>>>(variants: V) => EnumSwitchVariants<V>; export declare const byteSwitchLayout: <const I extends string, const L extends RoTuple>(idTag: I, layouts: L) => { readonly binary: "switch"; readonly idSize: 1; readonly idTag: I; readonly layouts: L; }; export declare const arrayLayout: <const L extends Layout>(layout: L) => { readonly binary: "array"; readonly layout: L; }; export {}; //# sourceMappingURL=layouting.d.ts.map