import { Buffer } from 'buffer/index.js'; import { ConfigureBakerPayload, ConfigureDelegationPayload, DelegationTargetType, VerifyKey } from './types.js'; import { DataBlob } from './types/DataBlob.js'; export declare const mapTagToType: DelegationTargetType[]; export declare function serializeMap(map: Record, encodeSize: (size: number) => Uint8Array, encodeKey: (k: string) => Uint8Array, encodeValue: (t: T) => Uint8Array): Buffer; export declare function serializeList(list: T[], putSize: (size: number) => Uint8Array, putMember: (t: T) => Uint8Array): Buffer; /** * Encodes a boolean to a Buffer using big endian. * @param value a boolean value * @returns boolean serialization of the input */ export declare function encodeBool(value: boolean): Buffer; /** * Encodes a 64 bit unsigned integer to a Buffer using big endian. * @param value a 64 bit integer * @param useLittleEndian a boolean value, if not given, the value is serialized in big endian. * @returns big endian serialization of the input */ export declare function encodeWord64(value: bigint, useLittleEndian?: boolean): Buffer; /** * Encodes a 32 bit signed integer to a Buffer using big endian. * @param value a 32 bit integer * @param useLittleEndian a boolean value, if not given, the value is serialized in big endian. * @returns big endian serialization of the input */ export declare function encodeInt32(value: number, useLittleEndian?: boolean): Buffer; /** * Encodes a 32 bit unsigned integer to a Buffer. * @param value a 32 bit integer * @param useLittleEndian a boolean value, if not given, the value is serialized in big endian. * @returns big endian serialization of the input */ export declare function encodeWord32(value: number, useLittleEndian?: boolean): Buffer; /** * Encodes a 16 bit signed integer to a Buffer. * @param value a 16 bit integer * @param useLittleEndian a boolean value, if not given, the value is serialized in big endian. * @returns big endian serialization of the input */ export declare function encodeInt16(value: number, useLittleEndian?: boolean): Buffer; /** * Encodes a 16 bit unsigned integer to a Buffer using big endian. * @param value a 16 bit integer * @param useLittleEndian a boolean value, if not given, the value is serialized in big endian. * @returns big endian serialization of the input */ export declare function encodeWord16(value: number, useLittleEndian?: boolean): Buffer; /** * Encodes a 8 bit signed integer to a Buffer using big endian. * @param value a 8 bit integer * @returns big endian serialization of the input */ export declare function encodeInt8(value: number): Buffer; /** * Encodes a 8 bit unsigned integer to a Buffer using big endian. * @param value a 8 bit integer * @returns big endian serialization of the input */ export declare function encodeWord8(value: number): Buffer; export declare function encodeWord8FromString(value: string): Buffer; export declare function encodeWord16FromString(value: string, useLittleEndian?: boolean): Buffer; /** * Encodes a Datablob. * @param blob Datablob containing data bytes. * @returns Buffer containing the length of the data and the data bytes. */ export declare function encodeDataBlob(blob: DataBlob): Buffer; /** * Packing a buffer along with its length in 32 bits * @param buffer * @param useLittleEndian a boolean value, if not given, the value is serialized in big endian. * @returns Buffer containing the 32 bit length of buffer and buffer. */ export declare function packBufferWithWord32Length(buffer: Uint8Array, useLittleEndian?: boolean): Buffer; /** * Packing a buffer along the with offset of 16 bit length * @param buffer containing the buffer * @returns Buffer containing the length of the buffer of 16 bit and buffer. */ export declare function packBufferWithWord16Length(buffer: Uint8Array, useLittleEndian?: boolean): Buffer; /** * Packing a buffer along the with offset of 8 bit length * @param buffer containing the buffer * @returns Buffer containing the length of the buffer of 8 bit and buffer. */ export declare function packBufferWithWord8Length(buffer: Uint8Array): Buffer; /** * Convert a hex string to a Buffer * @param str hex-encoded string * @returns Buffer */ export declare function encodeHexString(s: string): Buffer; export declare enum SchemeId { Ed25519 = 0 } /** * Serializes a public key. The serialization includes the * scheme used for the key/ * @param key the key to serialize * @returns the serialization of the key */ export declare function serializeVerifyKey(key: VerifyKey): Buffer; /** * Serializes a year and month string. * @param yearMonth year and month formatted as "YYYYMM" * @returns the serialization of the year and month string */ export declare function serializeYearMonth(yearMonth: string): Buffer; /** * Makes a bitmap for types with optional fields, where each bit indicates whether a value is included or not. * * @param value the value to generate the bitmap for * @param fieldOrder the order the value fields are serialized in. The order is represented in the bitmap from right to left, i.e index 0 of the order translates to the least significant bit. * * @example * getBitmap<{test?: string; test2?: string}>({test2: 'yes'}, ['test', 'test2']) // returns 2 (00000010 as bits of UInt8) * getBitmap<{test?: string; test2?: string; test3?: number}>({test: 'yes', test3: 100}, ['test', 'test2', 'test3']) // returns 5 (00000101 as bits of UInt8) */ export declare function getBitmap(value: T, fieldOrder: Array): number; /** * Makes a type with keys from Object and values being functions that take values with types of respective original values, returning a Buffer or undefined. */ export type SerializationSpec = Required<{ [P in keyof T]: (v: T[P]) => Uint8Array | undefined; }>; /** * Given a specification describing how to serialize the fields of a value of type T, this function produces a function * that serializes values of type T, returning a buffer of the serialized fields by order of occurance in serialization spec. */ export declare const serializeFromSpec: (spec: Required<{ [P in keyof T]: (v: T[P]) => Uint8Array | undefined; }>) => (value: T) => Buffer; export declare const configureDelegationSerializationSpec: SerializationSpec; export declare const getSerializedConfigureDelegationBitmap: (payload: ConfigureDelegationPayload) => Buffer; export declare function serializeConfigureDelegationPayload(payload: ConfigureDelegationPayload): Buffer; export declare function serializeConfigureBakerPayload(payload: ConfigureBakerPayload): Buffer; /** * Takes a function which serializes a value, and returns a function that serializes an optional value * Prefixed with a byte indicating if a value follows or not. */ export declare const makeSerializeOptional: (fun: (value: T) => Uint8Array) => (value: T | undefined) => Uint8Array; export declare const makeSerializeList: (serialize: (input: T) => Uint8Array) => (input: T[]) => Buffer;