Serialize 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.
NOTE: This function will only work when the inner values in the MoveVector
are U8
s.
Static
BoolFactory method to generate a MoveVector of Bools from an array of booleans.
a MoveVector<Bool>
const v = MoveVector.Bool([true, false, true, false]);
values: an array of bools
to convert to Bools
Static
MoveFactory method to generate a MoveVector of MoveStrings from an array of strings.
a MoveVector<MoveString>
const v = MoveVector.MoveString(["hello", "world"]);
values: an array of strings
to convert to MoveStrings
Static
U128Factory method to generate a MoveVector of U128s from an array of numbers or bigints.
a MoveVector<U128>
const v = MoveVector.U128([1, 2, 3, 4]);
values: an array of numbers of type number | bigint
to convert to U128s
Static
U16Factory method to generate a MoveVector of U16s from an array of numbers.
a MoveVector<U16>
const v = MoveVector.U16([1, 2, 3, 4]);
values: an array of numbers
to convert to U16s
Static
U256Factory method to generate a MoveVector of U256s from an array of numbers or bigints.
a MoveVector<U256>
const v = MoveVector.U256([1, 2, 3, 4]);
values: an array of numbers of type number | bigint
to convert to U256s
Static
U32Factory method to generate a MoveVector of U32s from an array of numbers.
a MoveVector<U32>
const v = MoveVector.U32([1, 2, 3, 4]);
values: an array of numbers
to convert to U32s
Static
U64Factory method to generate a MoveVector of U64s from an array of numbers or bigints.
a MoveVector<U64>
const v = MoveVector.U64([1, 2, 3, 4]);
values: an array of numbers of type number | bigint
to convert to U64s
Static
U8Factory method to generate a MoveVector of U8s from an array of numbers.
a MoveVector<U8>
const v = MoveVector.U8([1, 2, 3, 4]);
values: an array of numbers
to convert to U8s
Static
deserializeDeserialize a MoveVector of type T, specifically where T is a Serializable and Deserializable type.
NOTE: This only works with a depth of one. Generics will not work.
NOTE: This will not work with types that aren't of the Serializable class.
If you're looking for a more flexible deserialization function, you can use the deserializeVector function in the Deserializer class.
a MoveVector of the corresponding class T *
const vec = MoveVector.deserialize(deserializer, U64);
deserializer: the Deserializer instance to use, with bytes loaded into it already. cls: the class to typecast the input values to, must be a Serializable and Deserializable type.
This class is the Aptos Typescript SDK representation of a Move
vector<T>
, whereT
represents either a primitive type (bool
,u8
,u64
, ...) or a BCS-serializable struct itself.It is a BCS-serializable, array-like type that contains an array of values of type
T
, whereT
is a class that implementsSerializable
.The purpose of this class is to facilitate easy construction of BCS-serializable Move
vector<T>
types.Example
Params
values: an Array of values where T is a class that implements Serializable
Returns
a
MoveVector<T>
with the valuesvalues