Assessment reports>Initia>Threat Model>Module from_bcs.move

Module from_bcs.move

Function: to_bool

This function converts a vector of bytes to a boolean value.

Inputs

Full prototype: public fun to_bool(v: vector<u8>): bool

  • v: vector<u8>

    • Validation: Must pass validation checks done by Value::simple_deserialize — must be a BCS-encoded boolean.

    • Impact: Converts a BCS-encoded vector of bytes to the desired target type.

Function: to_u8

This function converts a vector of bytes to a u8 value.

Inputs

Full prototype: public fun to_u8(v: vector<u8>): u8

  • v: vector<u8>

    • Validation: Must pass validation checks done by Value::simple_deserialize — must be a BCS-encoded u8.

    • Impact: Converts a BCS-encoded vector of bytes to the desired target type.

Function: to_u16

This function converts a vector of bytes to a u16 value.

Inputs

Full prototype: public fun to_u16(v: vector<u8>): u16

  • v: vector<u8>

    • Validation: Must pass validation checks done by Value::simple_deserialize — must be a BCS-encoded u16.

    • Impact: Converts a BCS-encoded vector of bytes to the desired target type.

Function: to_u32

This function converts a vector of bytes to a u32 value.

Inputs

Full prototype: public fun to_u32(v: vector<u8>): u32

  • v: vector<u8>

    • Validation: Must pass validation checks done by Value::simple_deserialize — must be a BCS-encoded u32.

    • Impact: Converts a BCS-encoded vector of bytes to the desired target type.

Function: to_u64

This function converts a vector of bytes to a u64 value.

Inputs

Full prototype: public fun to_u64(v: vector<u8>): u64

  • v: vector<u8>

    • Validation: Must pass validation checks done by Value::simple_deserialize — must be a BCS-encoded u64.

    • Impact: Converts a BCS-encoded vector of bytes to the desired target type.

Function: to_u128

This function converts a vector of bytes to a u128 value.

Inputs

Full prototype: public fun to_u128(v: vector<u8>): u128

  • v: vector<u8>

    • Validation: Must pass validation checks done by Value::simple_deserialize — must be a BCS-encoded u128.

    • Impact: Converts a BCS-encoded vector of bytes to the desired target type.

Function: to_u256

This function converts a vector of bytes to a u256 value.

Inputs

Full prototype: public fun to_u256(v: vector<u8>): u256

  • v: vector<u8>

    • Validation: Must pass validation checks done by Value::simple_deserialize — must be a BCS-encoded u256.

    • Impact: Converts a BCS-encoded vector of bytes to the desired target type.

Function: to_address

This function converts a vector of bytes to an address value.

Inputs

Full prototype: public fun to_address(v: vector<u8>): address

  • v: vector<u8>

    • Validation: Must pass validation checks done by Value::simple_deserialize — must be a BCS-encoded address.

    • Impact: Converts a BCS-encoded vector of bytes to the desired target type.

Function: to_bytes

This function converts a vector of bytes to a vector of bytes.

Inputs

Full prototype: public fun to_bytes(v: vector<u8>): vector<u8>

  • v: vector<u8>

    • Validation: Must pass validation checks done by Value::simple_deserialize — must be a BCS-encoded vector of bytes.

    • Impact: Converts a BCS-encoded vector of bytes to the desired target type.

Function: to_vector_bytes

This function converts a vector of bytes to a vector of vectors of bytes.

Inputs

Full prototype: public fun to_vector_bytes(v: vector<u8>): vector<vector<u8>>

  • v: vector<u8>

    • Validation: Must pass validation checks done by Value::simple_deserialize — must be a BCS-encoded vector of vectors of bytes.

    • Impact: Converts a BCS-encoded vector of bytes to the desired target type.

Function: to_vector_string

This function can be used by the user to convert a vector of bytes to a vector of strings.

Inputs

Full prototype: public fun to_vector_string(v: vector<u8>): vector<String>

  • v: vector<u8>

    • Validation: Must pass validation checks done by Value::simple_deserialize — must be a BCS-encoded vector of strings. Note that we documented a finding for the lack of UTF-8 validation in this function in Finding ref.

    • Impact: Converts a BCS-encoded vector of bytes to the desired target type.

Function: to_string

This function converts a vector of bytes to a string.

Inputs

Full prototype: public fun to_string(v: vector<u8>): String

  • v: vector<u8>

    • Validation: Must pass validation checks done by Value::simple_deserialize — must be a BCS-encoded string. Must be a well-formed UTF-8 string.

    • Impact: Converts a BCS-encoded vector of bytes to the desired target type.

Zellic © 2024Back to top ↑