import type { CodecHash, Hash } from '../interfaces'; import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types'; /** * @name Option * @description * An Option is an optional field. Basically the first byte indicates that there is * is value to follow. If the byte is `1` there is an actual value. So the Option * implements that - decodes, checks for optionality and wraps the required structure * with a value if/as required/found. */ export declare class Option implements Codec { #private; readonly registry: Registry; createdAtHash?: Hash; constructor(registry: Registry, typeName: Constructor | keyof InterfaceTypes, value?: unknown); static with(Type: Constructor | keyof InterfaceTypes): Constructor>; /** * @description The length of the value when encoded as a Uint8Array */ get encodedLength(): number; /** * @description returns a hash of the contents */ get hash(): CodecHash; /** * @description Checks if the Option has no value */ get isEmpty(): boolean; /** * @description Checks if the Option has no value */ get isNone(): boolean; /** * @description Checks if the Option has a value */ get isSome(): boolean; /** * @description The actual value for the Option */ get value(): Codec; /** * @description Compares the value of the input to see if there is a match */ eq(other?: unknown): boolean; /** * @description Returns a hex string representation of the value */ toHex(): string; /** * @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information */ toHuman(isExtended?: boolean): AnyJson; /** * @description Converts the Object to JSON, typically used for RPC transfers */ toJSON(): AnyJson; /** * @description Returns the base runtime type name for this instance */ toRawType(isBare?: boolean): string; /** * @description Returns the string representation of the value */ toString(): string; /** * @description Encodes the value as a Uint8Array as per the SCALE specifications * @param isBare true when the value has none of the type-specific prefixes (internal) */ toU8a(isBare?: boolean): Uint8Array; /** * @description Returns the value that the Option represents (if available), throws if null */ unwrap(): T; /** * @description Returns the value that the Option represents (if available) or defaultValue if none * @param defaultValue The value to return if the option isNone */ unwrapOr(defaultValue: O): T | O; /** * @description Returns the value that the Option represents (if available) or defaultValue if none * @param defaultValue The value to return if the option isNone */ unwrapOrDefault(): T; }