UNPKG

wowok

Version:

Wowok Blockchain TypeScript API

50 lines (49 loc) 4.49 kB
import type { BcsTypeOptions } from "./bcs-type.js"; import { BcsEnum, BcsStruct, BcsTuple, BcsType } from "./bcs-type.js"; import type { EnumInputShape, EnumOutputShape, InferBcsInput, InferBcsType, JoinString } from "./types.js"; declare function fixedArray<T extends BcsType<any>, Name extends string = string>(size: number, type: T, options?: BcsTypeOptions<InferBcsType<T>[], Iterable<InferBcsInput<T>> & { length: number; }, Name>): BcsType<InferBcsType<T>[], Iterable<InferBcsInput<T>> & { length: number; }, Name>; declare function fixedArray<T, Input, Name extends string = string>(size: number, type: BcsType<T, Input>, options?: BcsTypeOptions<T[], Iterable<Input> & { length: number; }, Name>): BcsType<T[], Iterable<Input> & { length: number; }, Name>; declare function option<T extends BcsType<any>>(type: T): BcsType<InferBcsType<T> | null, InferBcsInput<T> | null | undefined, `Option<${T["name"]}>`>; declare function option<T, Input, Name extends string = string>(type: BcsType<T, Input, Name>): BcsType<T | null, Input | null | undefined>; declare function vector<T extends BcsType<any>, Name extends string = `vector<${T["name"]}>`>(type: T, options?: BcsTypeOptions<InferBcsType<T>[], Iterable<InferBcsInput<T>> & { length: number; }, Name>): BcsType<InferBcsType<T>[], Iterable<InferBcsInput<T>> & { length: number; }, Name>; declare function vector<T, Input, Name extends string = string>(type: BcsType<T, Input, Name>, options?: BcsTypeOptions<T[], Iterable<Input> & { length: number; }, `vector<${Name}>`>): BcsType<T[], Iterable<Input> & { length: number; }, `vector<${Name}>`>; declare function map<K extends BcsType<any>, V extends BcsType<any>>(keyType: K, valueType: V): BcsType<Map<InferBcsType<K>, InferBcsType<V>>, Map<InferBcsInput<K>, InferBcsInput<V>>, `Map<${K["name"]}, ${V["name"]}>`>; declare function map<K, V, InputK = K, InputV = V>(keyType: BcsType<K, InputK>, valueType: BcsType<V, InputV>): BcsType<Map<K, V>, Map<InputK, InputV>, `Map<${string}, ${string}>`>; export declare const bcs: { u8(options?: BcsTypeOptions<number>): BcsType<number, number, "u8">; u16(options?: BcsTypeOptions<number>): BcsType<number, number, "u16">; u32(options?: BcsTypeOptions<number>): BcsType<number, number, "u32">; u64(options?: BcsTypeOptions<string, number | bigint | string>): BcsType<string, string | number | bigint, "u64">; u128(options?: BcsTypeOptions<string, number | bigint | string>): BcsType<string, string | number | bigint, "u128">; u256(options?: BcsTypeOptions<string, number | bigint | string>): BcsType<string, string | number | bigint, "u256">; bool(options?: BcsTypeOptions<boolean>): BcsType<boolean, boolean, "bool">; uleb128(options?: BcsTypeOptions<number>): BcsType<number, number, string>; bytes<T extends number>(size: T, options?: BcsTypeOptions<Uint8Array, Iterable<number>>): BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, `bytes[${T}]`>; byteVector(options?: BcsTypeOptions<Uint8Array, Iterable<number>>): BcsType<Uint8Array<ArrayBufferLike>, Iterable<number>, "vector<u8>">; string(options?: BcsTypeOptions<string>): BcsType<string, string, "string">; fixedArray: typeof fixedArray; option: typeof option; vector: typeof vector; tuple<const T extends readonly BcsType<any, any>[], const Name extends string = `(${JoinString<{ [K in keyof T]: T[K] extends BcsType<any, any, infer T_1 extends string> ? T_1 : never; }, ", ">})`>(fields: T, options?: BcsTypeOptions<{ -readonly [K_1 in keyof T]: T[K_1] extends BcsType<infer T_1, any> ? T_1 : never; }, { [K_1 in keyof T]: T[K_1] extends BcsType<any, infer T_1> ? T_1 : never; }, Name>): BcsTuple<T, Name>; struct<T extends Record<string, BcsType<any>>, const Name extends string = string>(name: Name, fields: T, options?: Omit<BcsTypeOptions<{ [K in keyof T]: T[K] extends BcsType<infer U, any> ? U : never; }, { [K in keyof T]: T[K] extends BcsType<any, infer U> ? U : never; }>, "name">): BcsStruct<T, string>; enum<T extends Record<string, BcsType<any> | null>, const Name extends string = string>(name: Name, fields: T, options?: Omit<BcsTypeOptions<EnumOutputShape<{ [K in keyof T]: T[K] extends BcsType<infer U, any, any> ? U : true; }>, EnumInputShape<{ [K in keyof T]: T[K] extends BcsType<any, infer U, any> ? U : boolean | object | null; }>, Name>, "name">): BcsEnum<T, Name>; map: typeof map; lazy<T extends BcsType<any>>(cb: () => T): T; }; export {};