0xaa::transaction
Function
MoveCall
Transaction
new_function
new_function_from_bcs
new_move_call
new_move_call_from_bcs
new_transaction
new_transaction_from_bcs
package_id
peel_type
use 0x1::ascii;
use 0x1::option;
use 0x1::type_name;
use 0x2::address;
use 0x2::bcs;
use 0x2::hex;
Function
Structs ——-
struct Function has copy, drop, store
package_id: address
module_name: ascii::String
name: ascii::String
MoveCall
Arguments are prefixed with:
0x06: &mut Clock = 0x0006,
0x810a8b960cf54ceb7ce5b796d25fc2207017785bbc952562d1e4d10f2a4b8836: &mut
Singleton =
0x00810a8b960cf54ceb7ce5b796d25fc2207017785bbc952562d1e4d10f2a4b8836,
30: u64 = 0x011e00000000000000,
"Name": ascii::String = 0x01044e616d65,
approved_call: ApprovedMessage = 0x02,
payload: vector<u8> = 0x03
previous_return: Return (returned as the second argument of the first call)
= 0x40001,
struct MoveCall has copy, drop, store
function: transaction::Function
arguments: vector<vector<u8>>
type_arguments: vector<ascii::String>
Transaction
struct Transaction has copy, drop, store
is_final: bool
move_calls: vector<transaction::MoveCall>
Errors ——
#[error]
const EInvalidString: vector<u8> = b"Type argument was not a valid string";
new_function
Public Functions —————-
public fun new_function(package_id: address, module_name: ascii::String, name: ascii::String): transaction::Function
public fun new_function(
package_id: address,
module_name: String,
name: String,
): Function {
Function {
package_id,
module_name,
name,
}
}
new_function_from_bcs
public fun new_function_from_bcs(bcs: &mut bcs::BCS): transaction::Function
public fun new_function_from_bcs(bcs: &mut BCS): Function {
Function {
package_id: bcs::peel_address(bcs),
module_name: ascii::string(bcs::peel_vec_u8(bcs)),
name: ascii::string(bcs::peel_vec_u8(bcs)),
}
}
new_move_call
public fun new_move_call(function: transaction::Function, arguments: vector<vector<u8>>, type_arguments: vector<ascii::String>): transaction::MoveCall
public fun new_move_call(
function: Function,
arguments: vector<vector<u8>>,
type_arguments: vector<String>,
): MoveCall {
MoveCall {
function,
arguments,
type_arguments,
}
}
new_move_call_from_bcs
public fun new_move_call_from_bcs(bcs: &mut bcs::BCS): transaction::MoveCall
public fun new_move_call_from_bcs(bcs: &mut BCS): MoveCall {
MoveCall {
function: new_function_from_bcs(bcs),
arguments: bcs.peel_vec_vec_u8(),
type_arguments: vector::tabulate!(
bcs.peel_vec_length(),
|_| peel_type(bcs),
),
}
}
new_transaction
public fun new_transaction(is_final: bool, move_calls: vector<transaction::MoveCall>): transaction::Transaction
public fun new_transaction(
is_final: bool,
move_calls: vector<MoveCall>,
): Transaction {
Transaction {
is_final,
move_calls,
}
}
new_transaction_from_bcs
public fun new_transaction_from_bcs(bcs: &mut bcs::BCS): transaction::Transaction
public fun new_transaction_from_bcs(bcs: &mut BCS): Transaction {
Transaction {
is_final: bcs.peel_bool(),
move_calls: vector::tabulate!(
bcs.peel_vec_length(),
|_| new_move_call_from_bcs(bcs),
),
}
}
package_id
Helper function which returns the package id of a type.
public fun package_id<T>(): address
public fun package_id<T>(): address {
address::from_bytes(
hex::decode(
*ascii::as_bytes(
&type_name::get_address(&type_name::get<T>()),
),
),
)
}
peel_type
fun peel_type(bcs: &mut bcs::BCS): ascii::String
fun peel_type(bcs: &mut BCS): ascii::String {
let mut type_argument = ascii::try_string(bcs.peel_vec_u8());
assert!(type_argument.is_some(), EInvalidString);
type_argument.extract()
}