import { ByteInput as ByteInput$1, blake2b256, Coder } from '@fleet-sdk/crypto'; import { Box, Amount, BoxCandidate, UnsignedTransaction, SignedTransaction } from '@fleet-sdk/common'; declare class SigmaByteReader { #private; get isEmpty(): boolean; get bytes(): Uint8Array; get cursor(): number; constructor(bytes: ByteInput$1); readArray(readFn: (reader: SigmaByteReader, index: number) => T): Array; readBool(): boolean; readBits(length: number): ArrayLike; readByte(): number; readBytes(length: number): Uint8Array; readUInt(): number; readBigUInt(): bigint; readI8(): number; readI16(): number; readI32(): number; readI64(): bigint; readI256(): bigint; readRemainingBytes(): Uint8Array; readOption(processor: (r: SigmaByteReader) => T): T | undefined; /** * Returns bytes without advancing the cursor. */ peek(count: number, offset?: number): Uint8Array; /** * Checks if the current position in the byte array starts with the given bytes. */ match(bytes: Uint8Array, offset?: number): boolean; } declare class SigmaByteWriter { #private; get length(): number; constructor(length: number); writeBool(value: boolean): SigmaByteWriter; writeUInt(value: number): SigmaByteWriter; writeBigUInt(value: bigint): SigmaByteWriter; writeI16(value: number): SigmaByteWriter; writeI32(value: number): SigmaByteWriter; writeI64(value: bigint): SigmaByteWriter; writeI256(value: bigint): SigmaByteWriter; write(byte: number): SigmaByteWriter; writeBytes(bytes: ArrayLike): SigmaByteWriter; writeHex(bytesHex: string): SigmaByteWriter; writeBits(bits: ArrayLike): SigmaByteWriter; writeOption(value: T | undefined, processor: (w: SigmaByteWriter) => void): SigmaByteWriter; writeChecksum(length?: number, hashFn?: typeof blake2b256): SigmaByteWriter; /** * Writes a length-delimited array of items to the byte stream using a provided * serializer function. * * @typeParam T - The type of items in the array. * @param items - The array of items to serialize and write. * @param serializer - A function that serializes each item and writes it using the provided SigmaByteWriter. * @returns The current instance of SigmaByteWriter for method chaining. */ writeArray(items: T[], serializer: (writer: SigmaByteWriter, item: T) => void): SigmaByteWriter; encode(coder: Coder): T; toBytes(): Uint8Array; } /** * Estimates the byte size of a given unsigned integer. * @param value: the value to be evaluated. * @returns the byte size of the value. */ declare function estimateVLQSize(value: number | bigint | string): number; declare abstract class SType { abstract get code(): number; abstract get embeddable(): boolean; coerce(data: I): O; abstract toString(): string; } declare abstract class SMonomorphicType extends SType { abstract get code(): number; get embeddable(): boolean; } declare abstract class SPrimitiveType extends SMonomorphicType { abstract get code(): number; get embeddable(): boolean; } declare abstract class SGenericType extends SType { #private; constructor(type: T); abstract get code(): number; get elementsType(): T; get embeddable(): boolean; } interface AvlTreeFlags { insertAllowed: boolean; updateAllowed: boolean; removeAllowed: boolean; } interface AvlTreeData extends AvlTreeFlags { digest: string; keyLength: number; valueLengthOpt?: number; } declare class SCollType extends SGenericType { get code(): number; coerce(elements: I[]): O[] | Uint8Array; toString(): string; } declare class STupleType extends SGenericType { get code(): number; coerce(elements: I[]): O[]; toString(): string; } declare class SUnitType extends SMonomorphicType { get code(): 0x62; toString(): string; } declare class SBoxType extends SMonomorphicType>> { get code(): 0x63; toString(): string; } declare class SAvlTreeType extends SMonomorphicType { get code(): 0x64; toString(): string; } type BigIntInput = string | bigint; type ByteInput = Uint8Array | string; type SConstructor> = (arg?: T) => S; type SProxy = { (value: I): SConstant; (value?: I): T; }; declare const SByte: SProxy; declare const SBool: SProxy; declare const SShort: SProxy; declare const SInt: SProxy; declare const SLong: SProxy; declare const SBigInt: SProxy; declare const SGroupElement: SProxy>; declare const SSigmaProp: SProxy, SType>, SConstant, SType>>; type SUnit = () => SConstant; declare const SUnit: SUnit; type SBox = (value?: Box) => SConstant, SBoxType>; declare const SBox: SBox; type SAvlTree = (value?: AvlTreeData) => SConstant; declare const SAvlTree: SAvlTree; type SColl = { (type: SConstructor, elements: ByteInput | D[]): SConstant; (type: SConstructor, elements: ByteInput[]): SConstant; (type: SConstructor): SConstructor; (type: SConstructor, elements: D[]): SConstant; }; declare const SColl: SColl; type ByteInputOr = T extends SByteType ? ByteInput | D : D; type SPair = { (left: SConstant, right: SConstant): SConstant<[L, R], STupleType>; (left: SConstructor, right: SConstructor): SConstructor<[ByteInputOr, ByteInputOr]>; }; declare const SPair: SPair; declare class SBoolType extends SPrimitiveType { get code(): 0x01; toString(): string; } declare class SByteType extends SPrimitiveType { get code(): 0x02; toString(): string; } declare class SShortType extends SPrimitiveType { get code(): 0x03; toString(): string; } declare class SIntType extends SPrimitiveType { get code(): 0x04; toString(): string; } declare class SLongType extends SPrimitiveType { get code(): 0x05; coerce(data: BigIntInput): bigint; toString(): string; } declare class SBigIntType extends SPrimitiveType { get code(): number; coerce(data: BigIntInput): bigint; toString(): string; } declare class SGroupElementType extends SPrimitiveType { get code(): 0x07; coerce(data: ByteInput): Uint8Array; toString(): string; } declare class SSigmaPropType extends SPrimitiveType> { get code(): 0x08; toString(): string; } declare function isColl(type: SType): type is SCollType; declare function isTuple(type: SType): type is STupleType; declare class SConstant { #private; constructor(type: T, data: D); static from(bytes: ByteInput$1 | SigmaByteReader): SConstant; get type(): T; get data(): D; /** * Returns the serialized representation of the current instance as a `Uint8Array`. * If the bytes have already been computed and cached, returns the cached value. * Otherwise, serializes the instance and returns the resulting bytes. */ get bytes(): Uint8Array; /** * Serializes the current object into a `Uint8Array`. */ serialize(): Uint8Array; /** * @deprecated use `serialize` instead */ toBytes(): Uint8Array; toHex(): string; } /** * Decodes a byte input into a Sigma constant of type `SConstant`. * * @template D - The data type of the constant. * @template T - The type of the constant. * @param value - The value to decode. * @returns The decoded constant or `undefined` if the value is `undefined` or decoding fails. */ declare function decode(value?: ByteInput$1): SConstant | undefined; /** * Returns the `SType` of the given value. * * @param value - The value to check the SType of. * @returns The SType of the value, or `undefined` if the value is `undefined` or * deserialization fails. */ declare function stypeof(value?: ByteInput$1): SType | undefined; /** @deprecated use `decode` instead */ declare function parse(constant: ByteInput$1): T; /** @deprecated use `decode` instead */ declare function parse(constant: ByteInput$1, mode: "strict"): T; /** @deprecated use `decode` instead */ declare function parse(constant: ByteInput$1 | undefined, mode: "safe"): T | undefined; declare function serializeBox(box: Box | BoxCandidate, writer?: SigmaByteWriter, distinctTokenIds?: string[]): SigmaByteWriter; /** * Estimates the byte size a box. * @returns byte size of the box. */ declare function estimateBoxSize(box: Box | BoxCandidate, withValue?: Amount): number; /** * Deserializes a box embedded in a transaction. * * It efficiently calculates the box ID by accumulating the serialized data during * deserialization and applying blake2b256 hashing, avoiding redundant serialization * operations. * * @param reader - SigmaByteReader containing the serialized box data * @param distinctTokenIds - Array of TokenIDs referenced in the parent transaction * @param transactionId - ID of the transaction containing this box * @param index - Index position of the box in the transaction outputs * @returns A fully deserialized Box with all properties including boxId */ declare function deserializeEmbeddedBox(reader: SigmaByteReader, distinctTokenIds: string[], transactionId: string, index: number): Box; declare function deserializeBox(input: ByteInput | SigmaByteReader): BoxCandidate | Box; type Transaction = UnsignedTransaction | SignedTransaction; declare function serializeTransaction(transaction: Transaction): SigmaByteWriter; declare function deserializeTransaction(input: ByteInput): T; declare const dataSerializer: { serialize(data: unknown, type: SType, writer: SigmaByteWriter): SigmaByteWriter; deserialize(type: SType, reader: SigmaByteReader): unknown; }; declare const typeSerializer: { serialize(type: SType, writer: SigmaByteWriter): void; deserialize(r: SigmaByteReader): SType; }; export { SAvlTree, SAvlTreeType, SBigInt, SBigIntType, SBool, SBoolType, SBox, SBoxType, SByte, SByteType, SColl, SCollType, SConstant, SGenericType, SGroupElement, SGroupElementType, SInt, SIntType, SLong, SLongType, SMonomorphicType, SPair, SPrimitiveType, SShort, SShortType, SSigmaProp, SSigmaPropType, STupleType, SType, SUnit, SUnitType, SigmaByteReader, SigmaByteWriter, dataSerializer, decode, deserializeBox, deserializeEmbeddedBox, deserializeTransaction, estimateBoxSize, estimateVLQSize, isColl, isTuple, parse, serializeBox, serializeTransaction, stypeof, typeSerializer };