Optional
value: null | TOptional
Readonly
valuePrivate
vecSerialize an argument to BCS-serialized bytes.
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.
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.
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.
Static
BoolFactory method to generate a MoveOptionboolean
or undefined
.
Optional
value: null | booleana MoveOptionvalue
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.
Static
MoveFactory method to generate a MoveOptionstring
or undefined
.
Optional
value: null | stringa MoveOptionvalue
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.
Static
U128Factory method to generate a MoveOptionnumber
or a bigint
or undefined
.
Optional
value: null | AnyNumbera MoveOptionvalue
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.
Static
U16Factory method to generate a MoveOptionnumber
or undefined
.
Optional
value: null | numbera MoveOptionvalue
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.
Static
U256Factory method to generate a MoveOptionnumber
or a bigint
or undefined
.
Optional
value: null | AnyNumbera MoveOptionvalue
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.
Static
U32Factory method to generate a MoveOptionnumber
or undefined
.
Optional
value: null | numbera MoveOptionvalue
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.
Static
U64Factory method to generate a MoveOptionnumber
or a bigint
or undefined
.
Optional
value: null | AnyNumbera MoveOptionvalue
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.
Static
U8Factory method to generate a MoveOptionnumber
or undefined
.
Optional
value: null | numbera MoveOptionvalue
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.
Static
deserialize
Serializes a
Serializable
value to its BCS representation. This function is the Typescript SDK equivalent ofbcs::to_bytes
in Move.