pub trait VmCallerEnv: EnvBase {
    type VmUserState;

Show 111 methods // Required methods fn log_value( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: RawVal ) -> Result<Void, Self::Error>; fn get_invoking_contract( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<Object, Self::Error>; fn obj_cmp( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, a: RawVal, b: RawVal ) -> Result<i64, Self::Error>; fn contract_event( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, topics: VecObject, data: RawVal ) -> Result<Void, Self::Error>; fn get_current_contract_id( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<BytesObject, Self::Error>; fn get_ledger_version( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<U32Val, Self::Error>; fn get_ledger_sequence( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<U32Val, Self::Error>; fn get_ledger_timestamp( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<U64Val, Self::Error>; fn get_current_call_stack( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<VecObject, Self::Error>; fn fail_with_status( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, status: Status ) -> Result<Void, Self::Error>; fn log_fmt_values( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, fmt: StringObject, args: VecObject ) -> Result<Void, Self::Error>; fn get_ledger_network_id( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<BytesObject, Self::Error>; fn get_current_contract_address( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<AddressObject, Self::Error>; fn obj_from_u64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: u64 ) -> Result<U64Object, Self::Error>; fn obj_to_u64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U64Object ) -> Result<u64, Self::Error>; fn obj_from_i64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: i64 ) -> Result<I64Object, Self::Error>; fn obj_to_i64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I64Object ) -> Result<i64, Self::Error>; fn obj_from_u128_pieces( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, hi: u64, lo: u64 ) -> Result<U128Object, Self::Error>; fn obj_to_u128_lo64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U128Object ) -> Result<u64, Self::Error>; fn obj_to_u128_hi64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U128Object ) -> Result<u64, Self::Error>; fn obj_from_i128_pieces( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, hi: i64, lo: u64 ) -> Result<I128Object, Self::Error>; fn obj_to_i128_lo64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I128Object ) -> Result<u64, Self::Error>; fn obj_to_i128_hi64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I128Object ) -> Result<i64, Self::Error>; fn obj_from_u256_pieces( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, hi_hi: u64, hi_lo: u64, lo_hi: u64, lo_lo: u64 ) -> Result<U256Object, Self::Error>; fn obj_to_u256_hi_hi( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U256Object ) -> Result<u64, Self::Error>; fn obj_to_u256_hi_lo( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U256Object ) -> Result<u64, Self::Error>; fn obj_to_u256_lo_hi( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U256Object ) -> Result<u64, Self::Error>; fn obj_to_u256_lo_lo( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U256Object ) -> Result<u64, Self::Error>; fn obj_from_i256_pieces( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, hi_hi: i64, hi_lo: u64, lo_hi: u64, lo_lo: u64 ) -> Result<I256Object, Self::Error>; fn obj_to_i256_hi_hi( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I256Object ) -> Result<i64, Self::Error>; fn obj_to_i256_hi_lo( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I256Object ) -> Result<u64, Self::Error>; fn obj_to_i256_lo_hi( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I256Object ) -> Result<u64, Self::Error>; fn obj_to_i256_lo_lo( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I256Object ) -> Result<u64, Self::Error>; fn map_new( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<MapObject, Self::Error>; fn map_put( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject, k: RawVal, v: RawVal ) -> Result<MapObject, Self::Error>; fn map_get( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject, k: RawVal ) -> Result<RawVal, Self::Error>; fn map_del( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject, k: RawVal ) -> Result<MapObject, Self::Error>; fn map_len( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject ) -> Result<U32Val, Self::Error>; fn map_has( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject, k: RawVal ) -> Result<Bool, Self::Error>; fn map_prev_key( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject, k: RawVal ) -> Result<RawVal, Self::Error>; fn map_next_key( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject, k: RawVal ) -> Result<RawVal, Self::Error>; fn map_min_key( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject ) -> Result<RawVal, Self::Error>; fn map_max_key( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject ) -> Result<RawVal, Self::Error>; fn map_keys( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject ) -> Result<VecObject, Self::Error>; fn map_values( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject ) -> Result<VecObject, Self::Error>; fn map_new_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, keys_pos: U32Val, vals_pos: U32Val, len: U32Val ) -> Result<MapObject, Self::Error>; fn map_unpack_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, map: MapObject, keys_pos: U32Val, vals_pos: U32Val, len: U32Val ) -> Result<Void, Self::Error>; fn vec_new( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, c: RawVal ) -> Result<VecObject, Self::Error>; fn vec_put( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, i: U32Val, x: RawVal ) -> Result<VecObject, Self::Error>; fn vec_get( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, i: U32Val ) -> Result<RawVal, Self::Error>; fn vec_del( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, i: U32Val ) -> Result<VecObject, Self::Error>; fn vec_len( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject ) -> Result<U32Val, Self::Error>; fn vec_push_front( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, x: RawVal ) -> Result<VecObject, Self::Error>; fn vec_pop_front( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject ) -> Result<VecObject, Self::Error>; fn vec_push_back( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, x: RawVal ) -> Result<VecObject, Self::Error>; fn vec_pop_back( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject ) -> Result<VecObject, Self::Error>; fn vec_front( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject ) -> Result<RawVal, Self::Error>; fn vec_back( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject ) -> Result<RawVal, Self::Error>; fn vec_insert( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, i: U32Val, x: RawVal ) -> Result<VecObject, Self::Error>; fn vec_append( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v1: VecObject, v2: VecObject ) -> Result<VecObject, Self::Error>; fn vec_slice( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, start: U32Val, end: U32Val ) -> Result<VecObject, Self::Error>; fn vec_first_index_of( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, x: RawVal ) -> Result<RawVal, Self::Error>; fn vec_last_index_of( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, x: RawVal ) -> Result<RawVal, Self::Error>; fn vec_binary_search( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, x: RawVal ) -> Result<u64, Self::Error>; fn vec_new_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, vals_pos: U32Val, len: U32Val ) -> Result<VecObject, Self::Error>; fn vec_unpack_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, vec: VecObject, vals_pos: U32Val, len: U32Val ) -> Result<Void, Self::Error>; fn put_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal, v: RawVal ) -> Result<Void, Self::Error>; fn has_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal ) -> Result<Bool, Self::Error>; fn get_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal ) -> Result<RawVal, Self::Error>; fn del_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal ) -> Result<Void, Self::Error>; fn create_contract_from_contract( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, wasm_hash: BytesObject, salt: BytesObject ) -> Result<BytesObject, Self::Error>; fn put_tmp_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal, v: RawVal ) -> Result<Void, Self::Error>; fn has_tmp_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal ) -> Result<Bool, Self::Error>; fn get_tmp_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal ) -> Result<RawVal, Self::Error>; fn del_tmp_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal ) -> Result<Void, Self::Error>; fn update_current_contract_wasm( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, hash: BytesObject ) -> Result<Void, Self::Error>; fn call( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, contract: BytesObject, func: Symbol, args: VecObject ) -> Result<RawVal, Self::Error>; fn try_call( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, contract: BytesObject, func: Symbol, args: VecObject ) -> Result<RawVal, Self::Error>; fn serialize_to_bytes( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: RawVal ) -> Result<BytesObject, Self::Error>; fn deserialize_from_bytes( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject ) -> Result<RawVal, Self::Error>; fn bytes_copy_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, b_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<Void, Self::Error>; fn bytes_copy_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, b_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<BytesObject, Self::Error>; fn bytes_new_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, lm_pos: U32Val, len: U32Val ) -> Result<BytesObject, Self::Error>; fn bytes_new( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<BytesObject, Self::Error>; fn bytes_put( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, i: U32Val, u: U32Val ) -> Result<BytesObject, Self::Error>; fn bytes_get( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, i: U32Val ) -> Result<U32Val, Self::Error>; fn bytes_del( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, i: U32Val ) -> Result<BytesObject, Self::Error>; fn bytes_len( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject ) -> Result<U32Val, Self::Error>; fn bytes_push( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, u: U32Val ) -> Result<BytesObject, Self::Error>; fn bytes_pop( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject ) -> Result<BytesObject, Self::Error>; fn bytes_front( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject ) -> Result<U32Val, Self::Error>; fn bytes_back( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject ) -> Result<U32Val, Self::Error>; fn bytes_insert( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, i: U32Val, u: U32Val ) -> Result<BytesObject, Self::Error>; fn bytes_append( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b1: BytesObject, b2: BytesObject ) -> Result<BytesObject, Self::Error>; fn bytes_slice( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, start: U32Val, end: U32Val ) -> Result<BytesObject, Self::Error>; fn string_copy_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, s: StringObject, s_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<Void, Self::Error>; fn symbol_copy_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, s: SymbolObject, s_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<Void, Self::Error>; fn string_new_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, lm_pos: U32Val, len: U32Val ) -> Result<StringObject, Self::Error>; fn symbol_new_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, lm_pos: U32Val, len: U32Val ) -> Result<SymbolObject, Self::Error>; fn string_len( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, s: StringObject ) -> Result<U32Val, Self::Error>; fn symbol_len( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, s: SymbolObject ) -> Result<U32Val, Self::Error>; fn symbol_index_in_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, sym: Symbol, slices_pos: U32Val, len: U32Val ) -> Result<U32Val, Self::Error>; fn compute_hash_sha256( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, x: BytesObject ) -> Result<BytesObject, Self::Error>; fn verify_sig_ed25519( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: BytesObject, x: BytesObject, s: BytesObject ) -> Result<Void, Self::Error>; fn require_auth_for_args( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, address: AddressObject, args: VecObject ) -> Result<RawVal, Self::Error>; fn require_auth( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, address: AddressObject ) -> Result<RawVal, Self::Error>; fn account_public_key_to_address( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, pk_bytes: BytesObject ) -> Result<AddressObject, Self::Error>; fn contract_id_to_address( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, contract_id_bytes: BytesObject ) -> Result<AddressObject, Self::Error>; fn address_to_account_public_key( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, address: AddressObject ) -> Result<RawVal, Self::Error>; fn address_to_contract_id( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, address: AddressObject ) -> Result<RawVal, Self::Error>; fn dummy0( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<RawVal, Self::Error>;
}
Expand description

This trait is a variant of the Env trait used to define the interface implemented by Host. The wasmi VM dispatch functions call methods on VmCallerEnv, passing a VmCaller that wraps the wasmi Caller context, and then convert any Result::Err(...) return value into a VM trap, halting VM execution.

There is also a blanket impl<T:VmCallerEnv> Env for T that implements the Env for any VmCallerEnv by passing VmCaller::none() for the first argument, allowing user code such as the native contract to avoid writing VmCaller::none() everywhere.

Required Associated Types§

Required Methods§

source

fn log_value( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: RawVal ) -> Result<Void, Self::Error>

This one variant of logging does not take a format string and is live in both Env=Guest and Env=Host configurations.

source

fn get_invoking_contract( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<Object, Self::Error>

Get the contractID Bytes of the contract which invoked the running contract. Traps if the running contract was not invoked by a contract.

source

fn obj_cmp( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, a: RawVal, b: RawVal ) -> Result<i64, Self::Error>

Compare two objects, or at least one object to a non-object, structurally. Returns -1 if a<b, 1 if a>b, or 0 if a==b.

source

fn contract_event( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, topics: VecObject, data: RawVal ) -> Result<Void, Self::Error>

Records a contract event. topics is expected to be a SCVec with length <= 4 that cannot contain Vec, Map, or Bytes with length > 32 On success, returns an SCStatus::Ok.

source

fn get_current_contract_id( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<BytesObject, Self::Error>

Gets the 32-byte identifer of the current contract. Traps if the running contract was not invoked by a contract.

source

fn get_ledger_version( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<U32Val, Self::Error>

Return the protocol version of the current ledger as a u32.

source

fn get_ledger_sequence( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<U32Val, Self::Error>

Return the sequence number of the current ledger as a u32.

source

fn get_ledger_timestamp( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<U64Val, Self::Error>

Return the timestamp number of the current ledger as a u64.

source

fn get_current_call_stack( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<VecObject, Self::Error>

Returns the full call stack from the first contract call to the current one as a vector of vectors, where the inside vector contains the contract id as Hash, and a function as a Symbol.

source

fn fail_with_status( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, status: Status ) -> Result<Void, Self::Error>

Causes the currently executing contract to fail immediately with a provided status code, which must be of error-type ScStatusType::ContractError. Does not actually return.

source

fn log_fmt_values( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, fmt: StringObject, args: VecObject ) -> Result<Void, Self::Error>

Record a debug event. Fmt must be a Bytes. Args must be a Vec. Void is returned.

source

fn get_ledger_network_id( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<BytesObject, Self::Error>

Return the network id (sha256 hash of network passphrase) of the current ledger as Bytes. The value is always 32 bytes in length.

source

fn get_current_contract_address( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<AddressObject, Self::Error>

Get the Address object for the current contract.

source

fn obj_from_u64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: u64 ) -> Result<U64Object, Self::Error>

Convert a u64 to an object containing a u64.

source

fn obj_to_u64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U64Object ) -> Result<u64, Self::Error>

Convert an object containing a i64 to a u64.

source

fn obj_from_i64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: i64 ) -> Result<I64Object, Self::Error>

Convert an i64 to an object containing an i64.

source

fn obj_to_i64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I64Object ) -> Result<i64, Self::Error>

Convert an object containing an i64 to an i64.

source

fn obj_from_u128_pieces( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, hi: u64, lo: u64 ) -> Result<U128Object, Self::Error>

Convert the high and low 64-bit words of a u128 to an object containing a u128.

source

fn obj_to_u128_lo64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U128Object ) -> Result<u64, Self::Error>

Extract the low 64 bits from an object containing a u128.

source

fn obj_to_u128_hi64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U128Object ) -> Result<u64, Self::Error>

Extract the high 64 bits from an object containing a u128.

source

fn obj_from_i128_pieces( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, hi: i64, lo: u64 ) -> Result<I128Object, Self::Error>

Convert the high and low 64-bit words of an i128 to an object containing an i128.

source

fn obj_to_i128_lo64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I128Object ) -> Result<u64, Self::Error>

Extract the low 64 bits from an object containing an i128.

source

fn obj_to_i128_hi64( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I128Object ) -> Result<i64, Self::Error>

Extract the high 64 bits from an object containing an i128.

source

fn obj_from_u256_pieces( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, hi_hi: u64, hi_lo: u64, lo_hi: u64, lo_lo: u64 ) -> Result<U256Object, Self::Error>

Convert the four 64-bit words of an u256 (big-endian) to an object containing an u256.

source

fn obj_to_u256_hi_hi( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U256Object ) -> Result<u64, Self::Error>

Extract the highest 64-bits (bits 192-255) from an object containing an u256.

source

fn obj_to_u256_hi_lo( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U256Object ) -> Result<u64, Self::Error>

Extract bits 128-191 from an object containing an u256.

source

fn obj_to_u256_lo_hi( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U256Object ) -> Result<u64, Self::Error>

Extract bits 64-127 from an object containing an u256.

source

fn obj_to_u256_lo_lo( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: U256Object ) -> Result<u64, Self::Error>

Extract the lowest 64-bits (bits 0-63) from an object containing an u256.

source

fn obj_from_i256_pieces( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, hi_hi: i64, hi_lo: u64, lo_hi: u64, lo_lo: u64 ) -> Result<I256Object, Self::Error>

Convert the four 64-bit words of an i256 (big-endian) to an object containing an i256.

source

fn obj_to_i256_hi_hi( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I256Object ) -> Result<i64, Self::Error>

Extract the highest 64-bits (bits 192-255) from an object containing an i256.

source

fn obj_to_i256_hi_lo( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I256Object ) -> Result<u64, Self::Error>

Extract bits 128-191 from an object containing an i256.

source

fn obj_to_i256_lo_hi( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I256Object ) -> Result<u64, Self::Error>

Extract bits 64-127 from an object containing an i256.

source

fn obj_to_i256_lo_lo( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, obj: I256Object ) -> Result<u64, Self::Error>

Extract the lowest 64-bits (bits 0-63) from an object containing an i256.

source

fn map_new( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<MapObject, Self::Error>

Create an empty new map.

source

fn map_put( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject, k: RawVal, v: RawVal ) -> Result<MapObject, Self::Error>

Insert a key/value mapping into an existing map, and return the map object handle. If the map already has a mapping for the given key, the previous value is overwritten.

source

fn map_get( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject, k: RawVal ) -> Result<RawVal, Self::Error>

Get the value for a key from a map. Traps if key is not found.

source

fn map_del( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject, k: RawVal ) -> Result<MapObject, Self::Error>

Remove a key/value mapping from a map if it exists, traps if doesn’t.

source

fn map_len( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject ) -> Result<U32Val, Self::Error>

Get the size of a map.

source

fn map_has( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject, k: RawVal ) -> Result<Bool, Self::Error>

Test for the presence of a key in a map. Returns Bool.

source

fn map_prev_key( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject, k: RawVal ) -> Result<RawVal, Self::Error>

Given a key, find the first key less than itself in the map’s sorted order. If such a key does not exist, return an SCStatus containing the error code (TBD).

source

fn map_next_key( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject, k: RawVal ) -> Result<RawVal, Self::Error>

Given a key, find the first key greater than itself in the map’s sorted order. If such a key does not exist, return an SCStatus containing the error code (TBD).

source

fn map_min_key( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject ) -> Result<RawVal, Self::Error>

Find the minimum key from a map. If the map is empty, return an SCStatus containing the error code (TBD).

source

fn map_max_key( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject ) -> Result<RawVal, Self::Error>

Find the maximum key from a map. If the map is empty, return an SCStatus containing the error code (TBD).

source

fn map_keys( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject ) -> Result<VecObject, Self::Error>

Return a new vector containing all the keys in a map. The new vector is ordered in the original map’s key-sorted order.

source

fn map_values( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, m: MapObject ) -> Result<VecObject, Self::Error>

Return a new vector containing all the values in a map. The new vector is ordered in the original map’s key-sorted order.

source

fn map_new_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, keys_pos: U32Val, vals_pos: U32Val, len: U32Val ) -> Result<MapObject, Self::Error>

Return a new map initialized from a set of input slices given by linear-memory addresses and lengths.

source

fn map_unpack_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, map: MapObject, keys_pos: U32Val, vals_pos: U32Val, len: U32Val ) -> Result<Void, Self::Error>

Copy the RawVal values of a map, as described by set of input keys, into an array at a given linear-memory address.

source

fn vec_new( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, c: RawVal ) -> Result<VecObject, Self::Error>

Creates a new vector with an optional capacity hint c. If c is ScStatic::Void, no hint is assumed and the new vector is empty. Otherwise, c is parsed as an u32 that represents the initial capacity of the new vector.

source

fn vec_put( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, i: U32Val, x: RawVal ) -> Result<VecObject, Self::Error>

Update the value at index i in the vector. Return the new vector. Trap if the index is out of bounds.

source

fn vec_get( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, i: U32Val ) -> Result<RawVal, Self::Error>

Returns the element at index i of the vector. Traps if the index is out of bound.

source

fn vec_del( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, i: U32Val ) -> Result<VecObject, Self::Error>

Delete an element in a vector at index i, shifting all elements after it to the left. Return the new vector. Traps if the index is out of bound.

source

fn vec_len( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject ) -> Result<U32Val, Self::Error>

Returns length of the vector.

source

fn vec_push_front( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, x: RawVal ) -> Result<VecObject, Self::Error>

Push a value to the front of a vector.

source

fn vec_pop_front( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject ) -> Result<VecObject, Self::Error>

Removes the first element from the vector and returns the new vector. Traps if original vector is empty.

source

fn vec_push_back( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, x: RawVal ) -> Result<VecObject, Self::Error>

Appends an element to the back of the vector.

source

fn vec_pop_back( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject ) -> Result<VecObject, Self::Error>

Removes the last element from the vector and returns the new vector. Traps if original vector is empty.

source

fn vec_front( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject ) -> Result<RawVal, Self::Error>

Return the first element in the vector. Traps if the vector is empty

source

fn vec_back( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject ) -> Result<RawVal, Self::Error>

Return the last element in the vector. Traps if the vector is empty

source

fn vec_insert( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, i: U32Val, x: RawVal ) -> Result<VecObject, Self::Error>

Inserts an element at index i within the vector, shifting all elements after it to the right. Traps if the index is out of bound

source

fn vec_append( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v1: VecObject, v2: VecObject ) -> Result<VecObject, Self::Error>

Clone the vector v1, then moves all the elements of vector v2 into it. Return the new vector. Traps if number of elements in the vector overflows a u32.

source

fn vec_slice( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, start: U32Val, end: U32Val ) -> Result<VecObject, Self::Error>

Copy the elements from start index until end index, exclusive, in the vector and create a new vector from it. Return the new vector. Traps if the index is out of bound.

source

fn vec_first_index_of( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, x: RawVal ) -> Result<RawVal, Self::Error>

Get the index of the first occurrence of a given element in the vector. Returns the u32 index of the value if it’s there. Otherwise, it returns ScStatic::Void.

source

fn vec_last_index_of( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: VecObject, x: RawVal ) -> Result<RawVal, Self::Error>

Get the index of the last occurrence of a given element in the vector. Returns the u32 index of the value if it’s there. Otherwise, it returns ScStatic::Void.

Binary search a sorted vector for a given element. If it exists, the high-32 bits of the return value is 0x0001 and the low-32 bits contain the u32 index of the element. If it does not exist, the high-32 bits of the return value is 0x0000 and the low-32 bits contain the u32 index at which the element would need to be inserted into the vector to maintain sorted order.

source

fn vec_new_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, vals_pos: U32Val, len: U32Val ) -> Result<VecObject, Self::Error>

Return a new vec initialized from an input slice of RawVals given by a linear-memory address and length.

source

fn vec_unpack_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, vec: VecObject, vals_pos: U32Val, len: U32Val ) -> Result<Void, Self::Error>

Copy the RawVals of a vec into an array at a given linear-memory address.

source

fn put_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal, v: RawVal ) -> Result<Void, Self::Error>

source

fn has_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal ) -> Result<Bool, Self::Error>

source

fn get_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal ) -> Result<RawVal, Self::Error>

source

fn del_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal ) -> Result<Void, Self::Error>

source

fn create_contract_from_contract( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, wasm_hash: BytesObject, salt: BytesObject ) -> Result<BytesObject, Self::Error>

Deploys a contract from the current contract. wasm_hash must be a hash of the contract code that has already been installed on this network. salt is used to create a unique contract id.

source

fn put_tmp_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal, v: RawVal ) -> Result<Void, Self::Error>

source

fn has_tmp_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal ) -> Result<Bool, Self::Error>

source

fn get_tmp_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal ) -> Result<RawVal, Self::Error>

source

fn del_tmp_contract_data( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: RawVal ) -> Result<Void, Self::Error>

source

fn update_current_contract_wasm( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, hash: BytesObject ) -> Result<Void, Self::Error>

Replaces the executable of the current contract with the provided Wasm code identified by a hash. Wasm entry corresponding to the hash has to already be present in the ledger. The update happens only after the current contract invocation has successfully finished, so this can be safely called in the middle of a function.

source

fn call( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, contract: BytesObject, func: Symbol, args: VecObject ) -> Result<RawVal, Self::Error>

Calls a function in another contract with arguments contained in vector args. If the call is successful, forwards the result of the called function. Traps otherwise.

source

fn try_call( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, contract: BytesObject, func: Symbol, args: VecObject ) -> Result<RawVal, Self::Error>

Calls a function in another contract with arguments contained in vector args. Returns: - if successful, result of the called function. - otherwise, an SCStatus containing the error status code.

source

fn serialize_to_bytes( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, v: RawVal ) -> Result<BytesObject, Self::Error>

Serializes an (SC)Val into XDR opaque Bytes object.

source

fn deserialize_from_bytes( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject ) -> Result<RawVal, Self::Error>

Deserialize a Bytes object to get back the (SC)Val.

source

fn bytes_copy_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, b_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<Void, Self::Error>

Copies a slice of bytes from a Bytes object specified at offset b_pos with length len into the linear memory at position lm_pos. Traps if either the Bytes object or the linear memory doesn’t have enough bytes.

source

fn bytes_copy_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, b_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<BytesObject, Self::Error>

Copies a segment of the linear memory specified at position lm_pos with length len, into a Bytes object at offset b_pos. The Bytes object may grow in size to accommodate the new bytes. Traps if the linear memory doesn’t have enough bytes.

source

fn bytes_new_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, lm_pos: U32Val, len: U32Val ) -> Result<BytesObject, Self::Error>

Constructs a new Bytes object initialized with bytes copied from a linear memory slice specified at position lm_pos with length len.

source

fn bytes_new( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<BytesObject, Self::Error>

Create an empty new Bytes object.

source

fn bytes_put( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, i: U32Val, u: U32Val ) -> Result<BytesObject, Self::Error>

Update the value at index i in the Bytes object. Return the new Bytes. Trap if the index is out of bounds.

source

fn bytes_get( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, i: U32Val ) -> Result<U32Val, Self::Error>

Returns the element at index i of the Bytes object. Traps if the index is out of bound.

source

fn bytes_del( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, i: U32Val ) -> Result<BytesObject, Self::Error>

Delete an element in a Bytes object at index i, shifting all elements after it to the left. Return the new Bytes. Traps if the index is out of bound.

source

fn bytes_len( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject ) -> Result<U32Val, Self::Error>

Returns length of the Bytes object.

source

fn bytes_push( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, u: U32Val ) -> Result<BytesObject, Self::Error>

Appends an element to the back of the Bytes object.

source

fn bytes_pop( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject ) -> Result<BytesObject, Self::Error>

Removes the last element from the Bytes object and returns the new Bytes. Traps if original Bytes is empty.

source

fn bytes_front( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject ) -> Result<U32Val, Self::Error>

Return the first element in the Bytes object. Traps if the Bytes is empty

source

fn bytes_back( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject ) -> Result<U32Val, Self::Error>

Return the last element in the Bytes object. Traps if the Bytes is empty

source

fn bytes_insert( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, i: U32Val, u: U32Val ) -> Result<BytesObject, Self::Error>

Inserts an element at index i within the Bytes object, shifting all elements after it to the right. Traps if the index is out of bound

source

fn bytes_append( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b1: BytesObject, b2: BytesObject ) -> Result<BytesObject, Self::Error>

Clone the Bytes object b1, then moves all the elements of Bytes object b2 into it. Return the new Bytes. Traps if its length overflows a u32.

source

fn bytes_slice( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, b: BytesObject, start: U32Val, end: U32Val ) -> Result<BytesObject, Self::Error>

Copies the elements from start index until end index, exclusive, in the Bytes object and creates a new Bytes from it. Returns the new Bytes. Traps if the index is out of bound.

source

fn string_copy_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, s: StringObject, s_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<Void, Self::Error>

Copies a slice of bytes from a String object specified at offset s_pos with length len into the linear memory at position lm_pos. Traps if either the String object or the linear memory doesn’t have enough bytes.

source

fn symbol_copy_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, s: SymbolObject, s_pos: U32Val, lm_pos: U32Val, len: U32Val ) -> Result<Void, Self::Error>

Copies a slice of bytes from a Symbol object specified at offset s_pos with length len into the linear memory at position lm_pos. Traps if either the String object or the linear memory doesn’t have enough bytes.

source

fn string_new_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, lm_pos: U32Val, len: U32Val ) -> Result<StringObject, Self::Error>

Constructs a new String object initialized with bytes copied from a linear memory slice specified at position lm_pos with length len.

source

fn symbol_new_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, lm_pos: U32Val, len: U32Val ) -> Result<SymbolObject, Self::Error>

Constructs a new Symbol object initialized with bytes copied from a linear memory slice specified at position lm_pos with length len.

source

fn string_len( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, s: StringObject ) -> Result<U32Val, Self::Error>

Returns length of the String object.

source

fn symbol_len( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, s: SymbolObject ) -> Result<U32Val, Self::Error>

Returns length of the Symbol object.

source

fn symbol_index_in_linear_memory( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, sym: Symbol, slices_pos: U32Val, len: U32Val ) -> Result<U32Val, Self::Error>

Return the index of a Symbol in an array of linear-memory byte-slices, or trap if not found.

source

fn compute_hash_sha256( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, x: BytesObject ) -> Result<BytesObject, Self::Error>

source

fn verify_sig_ed25519( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, k: BytesObject, x: BytesObject, s: BytesObject ) -> Result<Void, Self::Error>

source

fn require_auth_for_args( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, address: AddressObject, args: VecObject ) -> Result<RawVal, Self::Error>

Checks if the address has authorized the invocation of the current contract function with the provided arguments. Traps if the invocation hasn’t been authorized.

source

fn require_auth( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, address: AddressObject ) -> Result<RawVal, Self::Error>

Checks if the address has authorized the invocation of the current contract function with all the arguments of the invocation. Traps if the invocation hasn’t been authorized.

source

fn account_public_key_to_address( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, pk_bytes: BytesObject ) -> Result<AddressObject, Self::Error>

Converts a provided 32-byte Stellar account public key to the corresponding address. This is only useful in the context of cross-chain interoperability. Prefer directly using the Address objects whenever possible.

source

fn contract_id_to_address( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, contract_id_bytes: BytesObject ) -> Result<AddressObject, Self::Error>

Converts a provided 32-byte contract identifier to a corresponding Address object.

source

fn address_to_account_public_key( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, address: AddressObject ) -> Result<RawVal, Self::Error>

Returns the 32-byte public key of the Stellar account corresponding to the provided Address object. If the Address doesn’t belong to an account, returns RawVal corresponding to the unit type (()).

source

fn address_to_contract_id( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState>, address: AddressObject ) -> Result<RawVal, Self::Error>

Returns the 32-byte contract identifier corresponding to the provided Address object. If the Address doesn’t belong to an account, returns RawVal corresponding to the unit type (()).

source

fn dummy0( &self, vmcaller: &mut VmCaller<'_, Self::VmUserState> ) -> Result<RawVal, Self::Error>

A dummy function taking 0 arguments and performs no-op. This function is for test purpose only, for measuring the roundtrip cost of invoking a host function, i.e. host->Vm->host.

Implementors§