Type Parameters

Hierarchy (view full)

Implements

Constructors

Properties

value?: T

Methods

  • Serializes a Serializable value to its BCS representation. This function is the Typescript SDK equivalent of bcs::to_bytes in Move.

    Returns Uint8Array

    the BCS representation of the Serializable instance as a byte buffer

  • Helper function to get a value's BCS-serialized bytes as a Hex instance.

    Returns Hex

    a Hex instance with the BCS-serialized bytes loaded into its underlying Uint8Array

  • Returns boolean

  • Serialize an argument to BCS-serialized bytes.

    Parameters

    Returns void

  • Serialize an argument as a type-agnostic, fixed byte sequence. The byte sequence contains the number of the following bytes followed by the BCS-serialized bytes for a typed argument.

    Parameters

    Returns void

  • Retrieves the inner value of the MoveOption.

    This method is inspired by Rust's Option<T>.unwrap(). In Rust, attempting to unwrap a None value results in a panic.

    Similarly, this method will throw an error if the value is not present.

    Returns T

    The contained value if present.

    const option = new MoveOption<Bool>(new Bool(true));
    const value = option.unwrap(); // Returns the Bool instance

    Throws an error if the MoveOption does not contain a value.

  • Factory method to generate a MoveOption from a boolean or undefined.

    Parameters

    • Optionalvalue: null | boolean

    Returns MoveOption<Bool>

    a MoveOption with an inner value value

    MoveOption.Bool(true).isSome() === true;
    MoveOption.Bool().isSome() === false;
    MoveOption.Bool(undefined).isSome() === false;

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

  • Factory method to generate a MoveOption from a string or undefined.

    Parameters

    • Optionalvalue: null | string

    Returns MoveOption<MoveString>

    a MoveOption with an inner value value

    MoveOption.MoveString("hello").isSome() === true;
    MoveOption.MoveString("").isSome() === true;
    MoveOption.MoveString().isSome() === false;
    MoveOption.MoveString(undefined).isSome() === false;

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

  • Factory method to generate a MoveOption from a number or a bigint or undefined.

    Parameters

    Returns MoveOption<U128>

    a MoveOption with an inner value value

    MoveOption.U128(1).isSome() === true;
    MoveOption.U128().isSome() === false;
    MoveOption.U128(undefined).isSome() === false;

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

  • Factory method to generate a MoveOption from a number or undefined.

    Parameters

    • Optionalvalue: null | number

    Returns MoveOption<U16>

    a MoveOption with an inner value value

    MoveOption.U16(1).isSome() === true;
    MoveOption.U16().isSome() === false;
    MoveOption.U16(undefined).isSome() === false;

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

  • Factory method to generate a MoveOption from a number or a bigint or undefined.

    Parameters

    Returns MoveOption<U256>

    a MoveOption with an inner value value

    MoveOption.U256(1).isSome() === true;
    MoveOption.U256().isSome() === false;
    MoveOption.U256(undefined).isSome() === false;

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

  • Factory method to generate a MoveOption from a number or undefined.

    Parameters

    • Optionalvalue: null | number

    Returns MoveOption<U32>

    a MoveOption with an inner value value

    MoveOption.U32(1).isSome() === true;
    MoveOption.U32().isSome() === false;
    MoveOption.U32(undefined).isSome() === false;

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

  • Factory method to generate a MoveOption from a number or a bigint or undefined.

    Parameters

    Returns MoveOption<U64>

    a MoveOption with an inner value value

    MoveOption.U64(1).isSome() === true;
    MoveOption.U64().isSome() === false;
    MoveOption.U64(undefined).isSome() === false;

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.

  • Factory method to generate a MoveOption from a number or undefined.

    Parameters

    • Optionalvalue: null | number

    Returns MoveOption<U8>

    a MoveOption with an inner value value

    MoveOption.U8(1).isSome() === true;
    MoveOption.U8().isSome() === false;
    MoveOption.U8(undefined).isSome() === false;

    value: the value used to fill the MoveOption. If value is undefined the resulting MoveOption's .isSome() method will return false.