import { Codec, Constructor, InterfaceTypes } from '../types'; import Base from './Base'; /** * @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 default class Option extends Base { private _Type; constructor(Type: Constructor | InterfaceTypes, value?: any); static decodeOption(Type: Constructor, value?: any): Codec; private static decodeOptionU8a; static with(Type: Constructor | InterfaceTypes): Constructor>; /** * @description The length of the value when encoded as a Uint8Array */ readonly encodedLength: number; /** * @description Checks if the Option has no value */ readonly isEmpty: boolean; /** * @description Checks if the Option has no value */ readonly isNone: boolean; /** * @description Checks if the Option has a value */ readonly isSome: boolean; /** * @description The actual value for the Option */ readonly value: Codec; /** * @description Compares the value of the input to see if there is a match */ eq(other?: any): boolean; /** * @description Returns a hex string representation of the value */ toHex(): string; /** * @description Returns the base runtime type name for this instance */ toRawType(isBare?: boolean): 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; }