soroban_env_host

Struct Host

Source
pub struct Host(/* private fields */);

Implementations§

Source§

impl Host

Source§

impl Host

Source§

impl Host

Source

pub fn with_mut_storage<F, U>(&self, f: F) -> Result<U, HostError>
where F: FnOnce(&mut Storage) -> Result<U, HostError>,

Source§

impl Host

Source

pub fn add_ledger_entry( &self, key: &Rc<LedgerKey>, val: &Rc<LedgerEntry>, live_until_ledger: Option<u32>, ) -> Result<(), HostError>

Source

pub fn setup_storage_entry( &self, key: Rc<LedgerKey>, val: Option<(Rc<LedgerEntry>, Option<u32>)>, access_type: AccessType, ) -> Result<(), HostError>

Source

pub fn setup_storage_footprint( &self, footprint: Footprint, ) -> Result<(), HostError>

Source§

impl Host

Source

pub fn has_frame(&self) -> Result<bool, HostError>

Returns if the host currently has a frame on the stack.

A frame being on the stack usually indicates that a contract is currently executing, or is in a state just-before or just-after executing.

Source

pub fn with_test_contract_frame<F>( &self, id: Hash, func: Symbol, f: F, ) -> Result<Val, HostError>
where F: FnOnce() -> Result<Val, HostError>,

Pushes a test contract [Frame], runs a closure, and then pops the frame, rolling back if the closure returned an error. Returns the result that the closure returned (or any error caused during the frame push/pop). Used for testing.

Source

pub fn invoke_function(&self, hf: HostFunction) -> Result<ScVal, HostError>

Source§

impl Host

Source

pub fn enable_invocation_metering(&self)

Enables invocation metering (it’s disabled by default).

Source§

impl Host

Source

pub fn register_test_contract( &self, contract_address: AddressObject, contract_fns: Rc<dyn ContractFunctionSet>, ) -> Result<(), HostError>

Source

pub fn register_test_contract_with_constructor( &self, contract_address: AddressObject, contract_fns: Rc<dyn ContractFunctionSet>, constructor_args: VecObject, ) -> Result<(), HostError>

Source

pub fn call_constructor_for_stored_contract_unsafe( &self, contract_id: &Hash, constructor_args: VecObject, ) -> Result<(), HostError>

Source§

impl Host

Source

pub fn metered_hash_xdr( &self, obj: &impl WriteXdr, ) -> Result<[u8; 32], HostError>

Source

pub fn metered_from_xdr<T: ReadXdr>(&self, bytes: &[u8]) -> Result<T, HostError>

Source§

impl Host

Source

pub fn with_storage_and_budget(storage: Storage, budget: Budget) -> Self

Constructs a new Host that will use the provided Storage for contract-data access functions such as [Env::get_contract_data].

Source

pub fn build_module_cache_if_needed(&self) -> Result<(), HostError>

Source

pub fn in_storage_recording_mode(&self) -> Result<bool, HostError>

Source

pub fn clear_module_cache(&self) -> Result<(), HostError>

Source

pub fn rebuild_module_cache(&self) -> Result<(), HostError>

Source

pub fn set_source_account( &self, source_account: AccountId, ) -> Result<(), HostError>

Source

pub fn remove_source_account(&self) -> Result<(), HostError>

Source

pub fn source_account_address(&self) -> Result<Option<AddressObject>, HostError>

Source

pub fn switch_to_enforcing_storage(&self) -> Result<(), HostError>

Source

pub fn switch_to_recording_auth( &self, disable_non_root_auth: bool, ) -> Result<(), HostError>

Source

pub fn set_authorization_entries( &self, auth_entries: Vec<SorobanAuthorizationEntry>, ) -> Result<(), HostError>

Source

pub fn set_base_prng_seed(&self, seed: Seed) -> Result<(), HostError>

Source

pub fn set_ledger_info(&self, info: LedgerInfo) -> Result<(), HostError>

Source

pub fn with_ledger_info<F, T>(&self, f: F) -> Result<T, HostError>
where F: FnOnce(&LedgerInfo) -> Result<T, HostError>,

Source

pub fn with_mut_ledger_info<F>(&self, f: F) -> Result<(), HostError>
where F: FnMut(&mut LedgerInfo),

Source

pub fn get_ledger_protocol_version(&self) -> Result<u32, HostError>

Source

pub fn budget_cloned(&self) -> Budget

Source

pub fn charge_budget( &self, ty: ContractCostType, input: Option<u64>, ) -> Result<(), HostError>

Source

pub fn set_shadow_budget_limits( &self, cpu: u64, mem: u64, ) -> Result<(), HostError>

Source

pub fn set_diagnostic_level( &self, diagnostic_level: DiagnosticLevel, ) -> Result<(), HostError>

Source

pub fn enable_debug(&self) -> Result<(), HostError>

Source

pub fn can_finish(&self) -> bool

Returns whether the Host can be finished by calling Host::try_finish.

Returns true if the host reference is unique, refcount = 1.

Source

pub fn try_finish(self) -> Result<(Storage, Events), HostError>

Accept a unique (refcount = 1) host reference and destroy the underlying [HostImpl], returning its finalized components containing processing side effects to the caller as a tuple wrapped in Ok(...).

Use Host::can_finish to determine before calling the function if it will succeed.

Source§

impl Host

Source

pub fn set_top_contract_invocation_hook( &self, hook: Option<Rc<dyn for<'a> Fn(&'a Host, ContractInvocationEvent)>>, ) -> Result<(), HostError>

Sets a hook to track top-level contract invocations. The hook triggers right before the top-level contract invocation starts and right after it ends. ‘Top-level contract invocation’ happens when the host creates the first context frame that belongs to a contract, which includes both direct host function calls (call/try_call), and test utilities such as with_test_contract_frame or call_account_contract_check_auth.

Source

pub fn with_budget<T, F>(&self, f: F) -> Result<T, HostError>
where F: FnOnce(Budget) -> Result<T, HostError>,

Helper for mutating the Budget held in this Host, either to allocate it on contract creation or to deplete it on callbacks from the VM or host functions.

Source

pub fn get_contract_instance_live_until_ledger( &self, contract: AddressObject, ) -> Result<u32, HostError>

Returns the ledger number until a contract with given address lives (inclusive).

Source

pub fn get_contract_code_live_until_ledger( &self, contract: AddressObject, ) -> Result<u32, HostError>

Returns the ledger number until contract code entry for contract with given address lives (inclusive).

Source

pub fn get_contract_data_live_until_ledger( &self, key: Val, storage_type: StorageType, ) -> Result<u32, HostError>

Returns the ledger number until a current contract’s data entry with given key and storage type lives (inclusive). Instance storage type is not supported by this function, use get_contract_instance_live_until_ledger instead.

Source

pub fn get_last_invocation_resources(&self) -> Option<InvocationResources>

Returns the resources metered during the last logical contract invocation.

Logical invocations include the direct invoke_host_function calls, call/try_call functions, contract lifecycle management operations.

Take the return value with a grain of salt. The returned resources mostly correspond only to the operations that have happened during the host invocation, i.e. this won’t try to simulate the work that happens in production scenarios (e.g. certain XDR rountrips). This also doesn’t try to model resources related to the transaction size.

The returned value is as useful as the preceding setup, e.g. if a test contract is used instead of a Wasm contract, all the costs related to VM instantiation and execution, as well as Wasm reads/rent bumps will be missed.

Source§

impl Host

Source§

impl Host

Source

pub fn call_account_contract_check_auth( &self, contract: AddressObject, args: VecObject, ) -> Result<Val, HostError>

Invokes the reserved __check_auth function on a provided contract.

This is useful for testing the custom account contracts. Otherwise, the host prohibits calling __check_auth outside of internal implementation of require_auth[_for_args] calls.

Source

pub fn snapshot_auth_manager(&self) -> Result<AuthorizationManager, HostError>

Returns the current state of the authorization manager.

Use this in conjunction with set_auth_manager to do authorized operations without breaking the current authorization state (useful for preserving the auth state while doing the generic test setup).

Source

pub fn switch_to_recording_auth_inherited_from_snapshot( &self, auth_manager_snapshot: &AuthorizationManager, ) -> Result<(), HostError>

Switches host to the recording authorization mode and inherits the recording mode settings from the provided authorization manager settings in case if it used the recording mode.

This is similar to switch_to_recording_auth, but should be preferred to use in conjunction with snapshot_auth_manager, such that the recording mode settings are not overridden.

Source

pub fn set_auth_manager( &self, auth_manager: AuthorizationManager, ) -> Result<(), HostError>

Replaces authorization manager with the provided new instance.

Use this in conjunction with snapshot_auth_manager to do authorized operations without breaking the current authorization state (useful for preserving the auth state while doing the generic test setup).

Source

pub fn get_authenticated_authorizations( &self, ) -> Result<Vec<(ScAddress, SorobanAuthorizedInvocation)>, HostError>

Source§

impl Host

Source

pub const TEST_PRNG_SEED: &'static [u8; 32] = b"12345678901234567890123456789012"

Source

pub fn set_test_prng(&self)

Source

pub fn current_test_protocol() -> u32

Source

pub fn set_test_ledger_info_with_current_test_protocol(&self)

Source

pub fn test_host() -> Self

Source

pub fn test_host_with_prng() -> Self

Source

pub fn test_host_with_recording_footprint() -> Self

Source

pub fn test_budget(self, cpu: u64, mem: u64) -> Self

Source

pub fn enable_model( self, ty: ContractCostType, const_cpu: u64, lin_cpu: u64, const_mem: u64, lin_mem: u64, ) -> Self

Source

pub fn test_scvec<T: AsScVal>(&self, vals: &[T]) -> Result<ScVec, HostError>

Source

pub fn test_vec_obj<T: AsScVal>( &self, vals: &[T], ) -> Result<VecObject, HostError>

Source

pub fn test_vec_val<T: AsScVal>(&self, vals: &[T]) -> Result<Val, HostError>

Source

pub fn test_bin_scobj(&self, vals: &[u8]) -> Result<ScVal, HostError>

Source

pub fn test_bin_obj(&self, vals: &[u8]) -> Result<BytesObject, HostError>

Source

pub fn register_test_contract_wasm_from_source_account( &self, contract_wasm: &[u8], account: AccountId, salt: [u8; 32], ) -> Result<AddressObject, HostError>

Source

pub fn register_test_contract_wasm(&self, contract_wasm: &[u8]) -> AddressObject

Source

pub fn new_recording_fuzz_host( contract_wasms: &[&[u8]], data_keys: &BTreeMap<ScVal, (StorageType, bool)>, n_signers: usize, ) -> (Host, Vec<AddressObject>, Vec<SigningKey>)

Source

pub fn switch_fuzz_host_to_enforcing( &self, data_keys: &BTreeMap<ScVal, (StorageType, bool)>, signing_keys: &[SigningKey], )

Trait Implementations§

Source§

impl AsBudget for &Host

Source§

impl AsBudget for Host

Source§

impl Clone for Host

Source§

fn clone(&self) -> Host

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Compare<AccountId> for Host

Source§

impl Compare<ContractDataDurability> for Host

Source§

impl Compare<ContractExecutable> for Host

Source§

impl Compare<CreateContractArgs> for Host

Source§

impl Compare<CreateContractArgsV2> for Host

Source§

impl Compare<Duration> for Host

Source§

impl Compare<Hash> for Host

Source§

type Error = HostError

Source§

fn compare(&self, a: &Hash, b: &Hash) -> Result<Ordering, Self::Error>

Source§

impl Compare<I256> for Host

Source§

type Error = HostError

Source§

fn compare(&self, a: &I256, b: &I256) -> Result<Ordering, Self::Error>

Source§

impl Compare<Int128Parts> for Host

Source§

impl Compare<Int256Parts> for Host

Source§

impl Compare<LedgerKeyAccount> for Host

Source§

impl Compare<LedgerKeyContractCode> for Host

Source§

impl Compare<LedgerKeyTrustLine> for Host

Source§

impl<K, V> Compare<MeteredOrdMap<K, V, Host>> for Host
where K: DeclaredSizeForMetering, V: DeclaredSizeForMetering, Host: Compare<K, Error = HostError> + Compare<V, Error = HostError>,

Source§

type Error = HostError

Source§

fn compare( &self, a: &MeteredOrdMap<K, V, Host>, b: &MeteredOrdMap<K, V, Host>, ) -> Result<Ordering, Self::Error>

Source§

impl<Elt: MeteredClone> Compare<MeteredVector<Elt>> for Host
where Host: Compare<Elt, Error = HostError>,

Source§

type Error = HostError

Source§

fn compare( &self, a: &MeteredVector<Elt>, b: &MeteredVector<Elt>, ) -> Result<Ordering, Self::Error>

Source§

impl Compare<PublicKey> for Host

Source§

impl Compare<ScAddress> for Host

Source§

impl Compare<ScError> for Host

Source§

impl Compare<ScNonceKey> for Host

Source§

impl Compare<TimePoint> for Host

Source§

impl Compare<TrustLineAsset> for Host

Source§

impl Compare<U256> for Host

Source§

type Error = HostError

Source§

fn compare(&self, a: &U256, b: &U256) -> Result<Ordering, Self::Error>

Source§

impl Compare<UInt128Parts> for Host

Source§

impl Compare<UInt256Parts> for Host

Source§

impl Compare<Uint256> for Host

Source§

impl Compare<bool> for Host

Source§

type Error = HostError

Source§

fn compare(&self, a: &bool, b: &bool) -> Result<Ordering, Self::Error>

Source§

impl Compare<i128> for Host

Source§

type Error = HostError

Source§

fn compare(&self, a: &i128, b: &i128) -> Result<Ordering, Self::Error>

Source§

impl Compare<i32> for Host

Source§

type Error = HostError

Source§

fn compare(&self, a: &i32, b: &i32) -> Result<Ordering, Self::Error>

Source§

impl Compare<i64> for Host

Source§

type Error = HostError

Source§

fn compare(&self, a: &i64, b: &i64) -> Result<Ordering, Self::Error>

Source§

impl Compare<u128> for Host

Source§

type Error = HostError

Source§

fn compare(&self, a: &u128, b: &u128) -> Result<Ordering, Self::Error>

Source§

impl Compare<u32> for Host

Source§

type Error = HostError

Source§

fn compare(&self, a: &u32, b: &u32) -> Result<Ordering, Self::Error>

Source§

impl Compare<u64> for Host

Source§

type Error = HostError

Source§

fn compare(&self, a: &u64, b: &u64) -> Result<Ordering, Self::Error>

Source§

impl Convert<&Object, ScValObject> for Host

Source§

impl<'a> Convert<&ScValObjRef<'a>, Object> for Host

Source§

impl Convert<Object, ScValObject> for Host

Source§

impl<'a> Convert<ScValObjRef<'a>, Object> for Host

Source§

impl Debug for Host

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Host

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl EnvBase for Host

Source§

type Error = HostError

The type of error returned from the environment when the environment itself fails “unrecoverably”, or at least in a way that the user is not expected to be able to recover from, such as an internal logic error, exceeding the execution budget, or being passed malformed input in a way that the user-facing API does not anticipate or allow for. This type is returned from all environment-interface methods, and will only ever take on two possible concrete types: either Infallible (in the Guest) or HostError (in the Host). Read more
Source§

fn error_from_error_val(&self, e: Error) -> Self::Error

Convert a crate::Error into EnvBase::Error. This is similar to adding + From<crate::Error> to the associated type bound for EnvBase::Error but it allows us to restrict that conversion in downstream crates, which is desirable to keep “conversions that panic” (as the guest definition of EnvBase::Error does) out of the common crate and avoid accidentally triggering them in the host. It also gives the Env an opportunity to log or enrich the error with context (both of which happen in Host).
Source§

fn check_obj_integrity(&self, obj: Object) -> Result<(), HostError>

Check that an Object handle is good according to the current Env. For general Val-validity checking one should use Val::good().
Source§

fn escalate_error_to_panic(&self, e: Self::Error) -> !

Reject an error from the environment, turning it into a panic but on terms that the environment controls (eg. enriching or logging it). This should only ever be called by client-side / SDK local-testing code, never in the Host.
Source§

fn augment_err_result<T>( &self, x: Result<T, Self::Error>, ) -> Result<T, Self::Error>

If x is Err(...), ensure as much debug information as possible is attached to that error; in any case return “essentially the same” x – either Ok(...) or Err(...) – just with extra error context. Read more
Source§

fn tracing_enabled(&self) -> bool

Return true if the environment wants to receive trace calls and and returns using Self::trace_env_call and Self::trace_env_ret.
Source§

fn trace_env_call( &self, fname: &'static str, args: &[&dyn Debug], ) -> Result<(), HostError>

A general interface for tracing all env-method calls, intended to be called from macros that do dispatch on all such methods.
Source§

fn trace_env_ret( &self, fname: &'static str, res: &Result<&dyn Debug, &HostError>, ) -> Result<(), HostError>

A general interface for tracing all env-method returns, intended to be called from macros that do dispatch on all such methods.
Source§

fn check_same_env(&self, other: &Self) -> Result<(), Self::Error>

Used to check two environments are the same, returning Error if not.
Source§

fn bytes_copy_from_slice( &self, b: BytesObject, b_pos: U32Val, slice: &[u8], ) -> Result<BytesObject, HostError>

Clone an existing Bytes object in the host, replacing the portion of its memory with bytes supplied by slice, returning the new object. The replaced portion of the original object’s memory begins at b_pos and extends for the same length as the new slice.
Source§

fn bytes_copy_to_slice( &self, b: BytesObject, b_pos: U32Val, slice: &mut [u8], ) -> Result<(), HostError>

Copy a slice of bytes from a Bytes object in the host into a slice in the caller’s memory.
Source§

fn string_copy_to_slice( &self, b: StringObject, b_pos: U32Val, slice: &mut [u8], ) -> Result<(), HostError>

Copy a slice of bytes from a String object in the host into a slice in the caller’s memory.
Source§

fn symbol_copy_to_slice( &self, s: SymbolObject, b_pos: U32Val, slice: &mut [u8], ) -> Result<(), HostError>

Copy a slice of bytes from a Symbol object in the host into the caller’s memory.
Source§

fn bytes_new_from_slice(&self, mem: &[u8]) -> Result<BytesObject, HostError>

Form a new Bytes host object from a slice of client memory.
Source§

fn string_new_from_slice(&self, s: &[u8]) -> Result<StringObject, HostError>

Form a new String host object from a slice of client memory.
Source§

fn symbol_new_from_slice(&self, s: &[u8]) -> Result<SymbolObject, HostError>

Form a new Symbol host object from a slice of client memory.
Source§

fn map_new_from_slices( &self, keys: &[&str], vals: &[Val], ) -> Result<MapObject, HostError>

Form a new Map host object from a slice of symbol-names and a slice of values. Keys must be in sorted order.
Source§

fn map_unpack_to_slice( &self, map: MapObject, keys: &[&str], vals: &mut [Val], ) -> Result<Void, HostError>

Unpack a Map host object with a specified set of keys to a slice of Vals. Keys must be in sorted order and must match the key set of the unpacked object exactly.
Source§

fn vec_new_from_slice(&self, vals: &[Val]) -> Result<VecObject, Self::Error>

Form a new Vec host object from a slice of values.
Source§

fn vec_unpack_to_slice( &self, vec: VecObject, vals: &mut [Val], ) -> Result<Void, Self::Error>

Form a new Vec host object from a slice of values. The values slice must be the same length as the host object.
Source§

fn symbol_index_in_strs( &self, sym: Symbol, slices: &[&str], ) -> Result<U32Val, Self::Error>

Return the index of a Symbol in an array of &strs, or error if not found.
Source§

fn log_from_slice(&self, msg: &str, vals: &[Val]) -> Result<Void, HostError>

Log a string and set of values as a diagnostic event, if diagnostic events are enabled. When running on host, logs directly; when running on guest, redirects through log_from_linear_memory.
Source§

fn check_protocol_version_lower_bound( &self, lower: u32, ) -> Result<(), Self::Error>

Check the current ledger protocol version against a provided lower bound, error if protocol version is out-of-bound.
Source§

fn check_protocol_version_upper_bound( &self, upper: u32, ) -> Result<(), Self::Error>

Check the current ledger protocol version against a provided upper bound, error if protocol version is out-of-bound.
Source§

fn check_val_integrity(&self, val: Val) -> Result<(), Self::Error>

Check that a Val is good according to the current Env. This is a superset of calling Val::good as it also checks that if the Val is an Object, that the Object is good according to Self::check_obj_integrity.
Source§

fn env_call_hook( &self, _fname: &'static str, _args: &[String], ) -> Result<(), Self::Error>

👎Deprecated: replaced by trace_env_call
Source§

fn env_ret_hook( &self, _fname: &'static str, _res: &Result<String, &Self::Error>, ) -> Result<(), Self::Error>

👎Deprecated: replaced by trace_env_ret
Source§

impl ResourceLimiter for Host

Source§

fn memory_growing( &mut self, current: usize, desired: usize, maximum: Option<usize>, ) -> Result<bool, MemoryError>

Notifies the resource limiter that an instance’s linear memory has been requested to grow. Read more
Source§

fn table_growing( &mut self, current: u32, desired: u32, maximum: Option<u32>, ) -> Result<bool, TableError>

Notifies the resource limiter that an instance’s table has been requested to grow. Read more
Source§

fn instances(&self) -> usize

The maximum number of instances that can be created for a Store. Read more
Source§

fn tables(&self) -> usize

The maximum number of tables that can be created for a Store. Read more
Source§

fn memories(&self) -> usize

The maximum number of linear memories that can be created for a Store Read more
Source§

fn memory_grow_failed(&mut self, _error: &MemoryError)

Notifies the resource limiter that growing a linear memory, permitted by the memory_growing method, has failed.
Source§

fn table_grow_failed(&mut self, _error: &TableError)

Notifies the resource limiter that growing a linear memory, permitted by the table_growing method, has failed.
Source§

impl VmCallerEnv for Host

Source§

type VmUserState = Host

Source§

fn log_from_linear_memory( &self, vmcaller: &mut VmCaller<'_, Host>, msg_pos: U32Val, msg_len: U32Val, vals_pos: U32Val, vals_len: U32Val, ) -> Result<Void, HostError>

Emit a diagnostic event containing a message and sequence of Vals.
Source§

fn obj_cmp( &self, _vmcaller: &mut VmCaller<'_, Host>, a: Val, b: Val, ) -> Result<i64, HostError>

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<'_, Host>, topics: VecObject, data: Val, ) -> Result<Void, HostError>

Records a contract event. topics is expected to be a SCVec with length <= 4 that cannot contain Vec, Map, or Bytes with length > 32.
Source§

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

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

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

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

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

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

fn fail_with_error( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, error: Error, ) -> Result<Void, Self::Error>

Causes the currently executing contract to fail immediately with a provided error code, which must be of error-type ScErrorType::Contract. Does not actually return.
Source§

fn get_ledger_network_id( &self, _vmcaller: &mut VmCaller<'_, Host>, ) -> 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<'_, Host>, ) -> Result<AddressObject, HostError>

Get the Address object for the current contract.
Source§

fn get_max_live_until_ledger( &self, _vmcaller: &mut VmCaller<'_, Host>, ) -> Result<U32Val, Self::Error>

Returns the max ledger sequence that an entry can live to (inclusive).
Source§

fn obj_from_u64( &self, _vmcaller: &mut VmCaller<'_, Host>, u: u64, ) -> Result<U64Object, HostError>

Convert a u64 to an object containing a u64.
Source§

fn obj_to_u64( &self, _vmcaller: &mut VmCaller<'_, Host>, obj: U64Object, ) -> Result<u64, HostError>

Convert an object containing a u64 to a u64.
Source§

fn obj_from_i64( &self, _vmcaller: &mut VmCaller<'_, Host>, u: i64, ) -> Result<I64Object, HostError>

Convert an i64 to an object containing an i64.
Source§

fn obj_to_i64( &self, _vmcaller: &mut VmCaller<'_, Host>, obj: I64Object, ) -> Result<i64, HostError>

Convert an object containing an i64 to an i64.
Source§

fn timepoint_obj_from_u64( &self, _vmcaller: &mut VmCaller<'_, Host>, u: u64, ) -> Result<TimepointObject, HostError>

Convert a u64 to a Timepoint object.
Source§

fn timepoint_obj_to_u64( &self, _vmcaller: &mut VmCaller<'_, Host>, obj: TimepointObject, ) -> Result<u64, HostError>

Convert a Timepoint object to a u64.
Source§

fn duration_obj_from_u64( &self, _vmcaller: &mut VmCaller<'_, Host>, u: u64, ) -> Result<DurationObject, HostError>

Convert a u64 to a Duration object.
Source§

fn duration_obj_to_u64( &self, _vmcaller: &mut VmCaller<'_, Host>, obj: DurationObject, ) -> Result<u64, HostError>

Convert a Duration object a u64.
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 a u256 (big-endian) to an object containing a u256.
Source§

fn u256_val_from_be_bytes( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, bytes: BytesObject, ) -> Result<U256Val, HostError>

Create a U256 Val from its representation as a byte array in big endian.
Source§

fn u256_val_to_be_bytes( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, val: U256Val, ) -> Result<BytesObject, HostError>

Return the memory representation of this U256 Val as a byte array in big endian byte order.
Source§

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

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

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

Extract bits 128-191 from an object containing a u256.
Source§

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

Extract bits 64-127 from an object containing a u256.
Source§

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

Extract the lowest 64-bits (bits 0-63) from an object containing a 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 i256_val_from_be_bytes( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, bytes: BytesObject, ) -> Result<I256Val, HostError>

Create a I256 Val from its representation as a byte array in big endian.
Source§

fn i256_val_to_be_bytes( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, val: I256Val, ) -> Result<BytesObject, HostError>

Return the memory representation of this I256 Val as a byte array in big endian byte order.
Source§

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

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, HostError>

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, HostError>

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, HostError>

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

fn u256_add( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: U256Val, rhs_val: U256Val, ) -> Result<U256Val, Self::Error>

Performs checked integer addition. Computes lhs + rhs, returning ScError if overflow occurred.
Source§

fn u256_sub( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: U256Val, rhs_val: U256Val, ) -> Result<U256Val, Self::Error>

Performs checked integer subtraction. Computes lhs - rhs, returning ScError if overflow occurred.
Source§

fn u256_mul( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: U256Val, rhs_val: U256Val, ) -> Result<U256Val, Self::Error>

Performs checked integer multiplication. Computes lhs * rhs, returning ScError if overflow occurred.
Source§

fn u256_div( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: U256Val, rhs_val: U256Val, ) -> Result<U256Val, Self::Error>

Performs checked integer division. Computes lhs / rhs, returning ScError if rhs == 0 or overflow occurred.
Source§

fn u256_rem_euclid( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: U256Val, rhs_val: U256Val, ) -> Result<U256Val, Self::Error>

Performs checked Euclidean modulo. Computes lhs % rhs, returning ScError if rhs == 0 or overflow occurred.
Source§

fn u256_pow( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: U256Val, rhs_val: U32Val, ) -> Result<U256Val, Self::Error>

Performs checked exponentiation. Computes lhs.exp(rhs), returning ScError if overflow occurred.
Source§

fn u256_shl( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: U256Val, rhs_val: U32Val, ) -> Result<U256Val, Self::Error>

Performs checked shift left. Computes lhs << rhs, returning ScError if rhs is larger than or equal to the number of bits in lhs.
Source§

fn u256_shr( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: U256Val, rhs_val: U32Val, ) -> Result<U256Val, Self::Error>

Performs checked shift right. Computes lhs >> rhs, returning ScError if rhs is larger than or equal to the number of bits in lhs.
Source§

fn i256_add( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: I256Val, rhs_val: I256Val, ) -> Result<I256Val, Self::Error>

Performs checked integer addition. Computes lhs + rhs, returning ScError if overflow occurred.
Source§

fn i256_sub( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: I256Val, rhs_val: I256Val, ) -> Result<I256Val, Self::Error>

Performs checked integer subtraction. Computes lhs - rhs, returning ScError if overflow occurred.
Source§

fn i256_mul( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: I256Val, rhs_val: I256Val, ) -> Result<I256Val, Self::Error>

Performs checked integer multiplication. Computes lhs * rhs, returning ScError if overflow occurred.
Source§

fn i256_div( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: I256Val, rhs_val: I256Val, ) -> Result<I256Val, Self::Error>

Performs checked integer division. Computes lhs / rhs, returning ScError if rhs == 0 or overflow occurred.
Source§

fn i256_rem_euclid( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: I256Val, rhs_val: I256Val, ) -> Result<I256Val, Self::Error>

Performs checked Euclidean modulo. Computes lhs % rhs, returning ScError if rhs == 0 or overflow occurred.
Source§

fn i256_pow( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: I256Val, rhs_val: U32Val, ) -> Result<I256Val, Self::Error>

Performs checked exponentiation. Computes lhs.exp(rhs), returning ScError if overflow occurred.
Source§

fn i256_shl( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: I256Val, rhs_val: U32Val, ) -> Result<I256Val, Self::Error>

Performs checked shift left. Computes lhs << rhs, returning ScError if rhs is larger than or equal to the number of bits in lhs.
Source§

fn i256_shr( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs_val: I256Val, rhs_val: U32Val, ) -> Result<I256Val, Self::Error>

Performs checked shift right. Computes lhs >> rhs, returning ScError if rhs is larger than or equal to the number of bits in lhs.
Source§

fn map_new( &self, _vmcaller: &mut VmCaller<'_, Host>, ) -> Result<MapObject, HostError>

Create an empty new map.
Source§

fn map_put( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject, k: Val, v: Val, ) -> Result<MapObject, HostError>

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<'_, Host>, m: MapObject, k: Val, ) -> Result<Val, HostError>

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

fn map_del( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject, k: Val, ) -> Result<MapObject, HostError>

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

fn map_len( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject, ) -> Result<U32Val, HostError>

Get the size of a map.
Source§

fn map_has( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject, k: Val, ) -> Result<Bool, HostError>

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

fn map_key_by_pos( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject, i: U32Val, ) -> Result<Val, HostError>

Get the key from a map at position i. If i is an invalid position, return ScError.
Source§

fn map_val_by_pos( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject, i: U32Val, ) -> Result<Val, HostError>

Get the value from a map at position i. If i is an invalid position, return ScError.
Source§

fn map_keys( &self, _vmcaller: &mut VmCaller<'_, Host>, m: MapObject, ) -> Result<VecObject, HostError>

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<'_, Host>, m: MapObject, ) -> Result<VecObject, HostError>

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<'_, Host>, keys_pos: U32Val, vals_pos: U32Val, len: U32Val, ) -> Result<MapObject, HostError>

Return a new map initialized from a pair of equal-length arrays, one for keys and one for values, given by a pair of linear-memory addresses and a length in Vals.
Source§

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

Copy Vals from map to the array vals_pos, selecting only the keys identified by the array keys_pos. Both arrays have len elements and are identified by linear-memory addresses.
Source§

fn vec_new( &self, _vmcaller: &mut VmCaller<'_, Host>, ) -> Result<VecObject, HostError>

Creates an empty new vector.
Source§

fn vec_put( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, i: U32Val, x: Val, ) -> Result<VecObject, HostError>

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<'_, Host>, v: VecObject, i: U32Val, ) -> Result<Val, HostError>

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<'_, Host>, v: VecObject, i: U32Val, ) -> Result<VecObject, HostError>

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<'_, Host>, v: VecObject, ) -> Result<U32Val, HostError>

Returns length of the vector.
Source§

fn vec_push_front( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, x: Val, ) -> Result<VecObject, HostError>

Push a value to the front of a vector.
Source§

fn vec_pop_front( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, ) -> Result<VecObject, HostError>

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<'_, Host>, v: VecObject, x: Val, ) -> Result<VecObject, HostError>

Appends an element to the back of the vector.
Source§

fn vec_pop_back( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, ) -> Result<VecObject, HostError>

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<'_, Host>, v: VecObject, ) -> Result<Val, HostError>

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

fn vec_back( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, ) -> Result<Val, HostError>

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

fn vec_insert( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, i: U32Val, x: Val, ) -> Result<VecObject, HostError>

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<'_, Host>, v1: VecObject, v2: VecObject, ) -> Result<VecObject, HostError>

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<'_, Host>, v: VecObject, start: U32Val, end: U32Val, ) -> Result<VecObject, HostError>

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<'_, Host>, v: VecObject, x: Val, ) -> Result<Val, 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 Void.
Source§

fn vec_last_index_of( &self, _vmcaller: &mut VmCaller<'_, Host>, v: VecObject, x: Val, ) -> Result<Val, 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 Void.
Binary search a sorted vector for a given element. If it exists, the high 32 bits of the return value is 0x0000_0001 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_0000 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<'_, Host>, vals_pos: U32Val, len: U32Val, ) -> Result<VecObject, HostError>

Return a new vec initialized from an input slice of Vals given by a linear-memory address and length in Vals.
Source§

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

Copy the Vals of a vec into an array at a given linear-memory address and length in Vals.
Source§

fn put_contract_data( &self, _vmcaller: &mut VmCaller<'_, Host>, k: Val, v: Val, t: StorageType, ) -> Result<Void, HostError>

Source§

fn has_contract_data( &self, _vmcaller: &mut VmCaller<'_, Host>, k: Val, t: StorageType, ) -> Result<Bool, HostError>

Source§

fn get_contract_data( &self, _vmcaller: &mut VmCaller<'_, Host>, k: Val, t: StorageType, ) -> Result<Val, HostError>

Source§

fn del_contract_data( &self, _vmcaller: &mut VmCaller<'_, Host>, k: Val, t: StorageType, ) -> Result<Void, HostError>

Source§

fn extend_contract_data_ttl( &self, _vmcaller: &mut VmCaller<'_, Host>, k: Val, t: StorageType, threshold: U32Val, extend_to: U32Val, ) -> Result<Void, HostError>

If the entry’s TTL is below threshold ledgers, extend live_until_ledger_seq such that TTL == extend_to, where TTL is defined as live_until_ledger_seq - current ledger. If attempting to extend the entry past the maximum allowed value (defined as the current ledger + max_entry_ttl - 1), and the entry is Persistent, its new live_until_ledger_seq will be clamped to the max; if the entry is Temporary, the function traps.
Source§

fn extend_current_contract_instance_and_code_ttl( &self, _vmcaller: &mut VmCaller<'_, Host>, threshold: U32Val, extend_to: U32Val, ) -> Result<Void, HostError>

If the TTL for the current contract instance and code (if applicable) is below threshold ledgers, extend live_until_ledger_seq such that TTL == extend_to, where TTL is defined as live_until_ledger_seq - current ledger. If attempting to extend past the maximum allowed value (defined as the current ledger + max_entry_ttl - 1), the new live_until_ledger_seq will be clamped to the max.
Source§

fn extend_contract_instance_ttl( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, contract: AddressObject, threshold: U32Val, extend_to: U32Val, ) -> Result<Void, Self::Error>

If the TTL for the provided contract instance is below threshold ledgers, extend live_until_ledger_seq such that TTL == extend_to, where TTL is defined as live_until_ledger_seq - current ledger. If attempting to extend past the maximum allowed value (defined as the current ledger + max_entry_ttl - 1), the new live_until_ledger_seq will be clamped to the max.
Source§

fn extend_contract_instance_and_code_ttl( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, contract: AddressObject, threshold: U32Val, extend_to: U32Val, ) -> Result<Void, Self::Error>

If the TTL for the provided contract instance and code (if applicable) is below threshold ledgers, extend live_until_ledger_seq such that TTL == extend_to, where TTL is defined as live_until_ledger_seq - current ledger. If attempting to extend past the maximum allowed value (defined as the current ledger + max_entry_ttl - 1), the new live_until_ledger_seq will be clamped to the max.
Source§

fn extend_contract_code_ttl( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, contract: AddressObject, threshold: U32Val, extend_to: U32Val, ) -> Result<Void, Self::Error>

If the TTL for the provided contract’s code (if applicable) is below threshold ledgers, extend live_until_ledger_seq such that TTL == extend_to, where TTL is defined as live_until_ledger_seq - current ledger. If attempting to extend past the maximum allowed value (defined as the current ledger + max_entry_ttl - 1), the new live_until_ledger_seq will be clamped to the max.
Source§

fn create_contract( &self, _vmcaller: &mut VmCaller<'_, Host>, deployer: AddressObject, wasm_hash: BytesObject, salt: BytesObject, ) -> Result<AddressObject, HostError>

Creates the contract instance on behalf of deployer. deployer must authorize this call via Soroban auth framework, i.e. this calls deployer.require_auth with respective arguments. wasm_hash must be a hash of the contract code that has already been uploaded on this network. salt is used to create a unique contract id. Returns the address of the created contract.
Source§

fn create_contract_with_constructor( &self, _vmcaller: &mut VmCaller<'_, Host>, deployer: AddressObject, wasm_hash: BytesObject, salt: BytesObject, constructor_args: VecObject, ) -> Result<AddressObject, HostError>

Creates the contract instance on behalf of deployer. Created contract must be created from a Wasm that has a constructor. deployer must authorize this call via Soroban auth framework, i.e. this calls deployer.require_auth with respective arguments. wasm_hash must be a hash of the contract code that has already been uploaded on this network. salt is used to create a unique contract id. constructor_args are forwarded into created contract’s constructor (__constructor) function. Returns the address of the created contract.
Source§

fn create_asset_contract( &self, _vmcaller: &mut VmCaller<'_, Host>, serialized_asset: BytesObject, ) -> Result<AddressObject, HostError>

Creates the instance of Stellar Asset contract corresponding to the provided asset. serialized_asset is stellar::Asset XDR serialized to bytes format. Returns the address of the created contract.
Source§

fn get_contract_id( &self, _vmcaller: &mut VmCaller<'_, Host>, deployer: AddressObject, salt: BytesObject, ) -> Result<AddressObject, HostError>

Get the id of a contract without creating it. deployer is address of the contract deployer. salt is used to create a unique contract id. Returns the address of the would-be contract.
Source§

fn get_asset_contract_id( &self, _vmcaller: &mut VmCaller<'_, Host>, serialized_asset: BytesObject, ) -> Result<AddressObject, HostError>

Get the id of the Stellar Asset contract corresponding to the provided asset without creating the instance. serialized_asset is stellar::Asset XDR serialized to bytes format. Returns the address of the would-be asset contract.
Source§

fn upload_wasm( &self, _vmcaller: &mut VmCaller<'_, Host>, wasm: BytesObject, ) -> Result<BytesObject, HostError>

Uploads provided wasm bytecode to the network and returns its identifier (SHA-256 hash). No-op in case if the same Wasm object already exists.
Source§

fn update_current_contract_wasm( &self, _vmcaller: &mut VmCaller<'_, Host>, hash: BytesObject, ) -> Result<Void, HostError>

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<'_, Host>, contract_address: AddressObject, func: Symbol, args: VecObject, ) -> Result<Val, HostError>

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

fn try_call( &self, _vmcaller: &mut VmCaller<'_, Host>, contract_address: AddressObject, func: Symbol, args: VecObject, ) -> Result<Val, HostError>

Calls a function in another contract with arguments contained in vector args, returning either the result of the called function or an Error if the called function failed. The returned error is either a custom ContractError that the called contract returns explicitly, or an error with type Context and code InvalidAction in case of any other error in the called contract (such as a host function failure that caused a trap). try_call might trap in a few scenarios where the error can’t be meaningfully recovered from, such as running out of budget.
Source§

fn serialize_to_bytes( &self, _vmcaller: &mut VmCaller<'_, Host>, v: Val, ) -> Result<BytesObject, HostError>

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

fn deserialize_from_bytes( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject, ) -> Result<Val, HostError>

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

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

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<'_, Host>, s: SymbolObject, s_pos: U32Val, lm_pos: U32Val, len: U32Val, ) -> Result<Void, HostError>

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 bytes_copy_to_linear_memory( &self, vmcaller: &mut VmCaller<'_, Host>, b: BytesObject, b_pos: U32Val, lm_pos: U32Val, len: U32Val, ) -> Result<Void, HostError>

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<'_, Host>, b: BytesObject, b_pos: U32Val, lm_pos: U32Val, len: U32Val, ) -> Result<BytesObject, HostError>

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<'_, Host>, lm_pos: U32Val, len: U32Val, ) -> Result<BytesObject, HostError>

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

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

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<'_, Host>, lm_pos: U32Val, len: U32Val, ) -> Result<SymbolObject, HostError>

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

fn symbol_index_in_linear_memory( &self, vmcaller: &mut VmCaller<'_, Host>, sym: Symbol, lm_pos: U32Val, len: U32Val, ) -> Result<U32Val, HostError>

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

fn bytes_new( &self, _vmcaller: &mut VmCaller<'_, Host>, ) -> Result<BytesObject, HostError>

Create an empty new Bytes object.
Source§

fn bytes_put( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject, iv: U32Val, u: U32Val, ) -> Result<BytesObject, HostError>

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<'_, Host>, b: BytesObject, iv: U32Val, ) -> Result<U32Val, HostError>

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<'_, Host>, b: BytesObject, i: U32Val, ) -> Result<BytesObject, HostError>

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<'_, Host>, b: BytesObject, ) -> Result<U32Val, HostError>

Returns length of the Bytes object.
Source§

fn string_len( &self, _vmcaller: &mut VmCaller<'_, Host>, b: StringObject, ) -> Result<U32Val, HostError>

Returns length of the String object.
Source§

fn symbol_len( &self, _vmcaller: &mut VmCaller<'_, Host>, b: SymbolObject, ) -> Result<U32Val, HostError>

Returns length of the Symbol object.
Source§

fn bytes_push( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject, u: U32Val, ) -> Result<BytesObject, HostError>

Appends an element to the back of the Bytes object.
Source§

fn bytes_pop( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject, ) -> Result<BytesObject, HostError>

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<'_, Host>, b: BytesObject, ) -> Result<U32Val, HostError>

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

fn bytes_back( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject, ) -> Result<U32Val, HostError>

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

fn bytes_insert( &self, _vmcaller: &mut VmCaller<'_, Host>, b: BytesObject, i: U32Val, u: U32Val, ) -> Result<BytesObject, HostError>

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<'_, Host>, b1: BytesObject, b2: BytesObject, ) -> Result<BytesObject, HostError>

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<'_, Host>, b: BytesObject, start: U32Val, end: U32Val, ) -> Result<BytesObject, HostError>

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 compute_hash_sha256( &self, _vmcaller: &mut VmCaller<'_, Host>, x: BytesObject, ) -> Result<BytesObject, HostError>

Source§

fn compute_hash_keccak256( &self, _vmcaller: &mut VmCaller<'_, Host>, x: BytesObject, ) -> Result<BytesObject, HostError>

Returns the keccak256 hash of given input bytes.
Source§

fn verify_sig_ed25519( &self, _vmcaller: &mut VmCaller<'_, Host>, k: BytesObject, x: BytesObject, s: BytesObject, ) -> Result<Void, HostError>

Source§

fn recover_key_ecdsa_secp256k1( &self, _vmcaller: &mut VmCaller<'_, Host>, msg_digest: BytesObject, signature: BytesObject, recovery_id: U32Val, ) -> Result<BytesObject, HostError>

Recovers the SEC-1-encoded ECDSA secp256k1 public key that produced a given 64-byte signature over a given 32-byte msg_digest for a given recovery_id byte. Warning: The msg_digest must be produced by a secure cryptographic hash function on the message, otherwise the attacker can potentially forge signatures. The signature is the ECDSA signature (r, s) serialized as fixed-size big endian scalar values, both r, s must be non-zero and s must be in the lower range. Returns a BytesObject containing 65-bytes representing SEC-1 encoded point in uncompressed format. The recovery_id is an integer value 0, 1, 2, or 3, the low bit (0/1) indicates the parity of the y-coordinate of the public_key (even/odd) and the high bit (3/4) indicate if the r (x-coordinate of k x G) has overflown during its computation.
Source§

fn verify_sig_ecdsa_secp256r1( &self, _vmcaller: &mut VmCaller<'_, Host>, public_key: BytesObject, msg_digest: BytesObject, signature: BytesObject, ) -> Result<Void, HostError>

Verifies the signature using an ECDSA secp256r1 public_key on a 32-byte msg_digest. Warning: The msg_digest must be produced by a secure cryptographic hash function on the message, otherwise the attacker can potentially forge signatures. The public_key is expected to be 65 bytes in length, representing a SEC-1 encoded point in uncompressed format. The signature is the ECDSA signature (r, s) serialized as fixed-size big endian scalar values, both r, s must be non-zero and s must be in the lower range.
Source§

fn bls12_381_check_g1_is_in_subgroup( &self, _vmcaller: &mut VmCaller<'_, Host>, pt: BytesObject, ) -> Result<Bool, HostError>

Checks if the input G1 point is in the correct subgroup.
Source§

fn bls12_381_g1_add( &self, _vmcaller: &mut VmCaller<'_, Host>, p0: BytesObject, p1: BytesObject, ) -> Result<BytesObject, HostError>

Adds two BLS12-381 G1 points given in bytes format and returns the resulting G1 point in bytes format. G1 serialization format: concat(be_bytes(X), be_bytes(Y)) and the most significant three bits of X encodes flags, i.e. bits(X) = [compression_flag, infinity_flag, sort_flag, bit_3, .. bit_383]. This function does NOT perform subgroup check on the inputs.
Source§

fn bls12_381_g1_mul( &self, _vmcaller: &mut VmCaller<'_, Host>, p0: BytesObject, scalar: U256Val, ) -> Result<BytesObject, HostError>

Multiplies a BLS12-381 G1 point by a scalar (Fr), and returns the resulting G1 point in bytes format.
Source§

fn bls12_381_g1_msm( &self, _vmcaller: &mut VmCaller<'_, Host>, vp: VecObject, vs: VecObject, ) -> Result<BytesObject, HostError>

Performs multi-scalar-multiplication (inner product) on a vector of BLS12-381 G1 points (Vec<BytesObject>) by a vector of scalars (Vec<U256Val>), and returns the resulting G1 point in bytes format.
Source§

fn bls12_381_map_fp_to_g1( &self, _vmcaller: &mut VmCaller<'_, Host>, fp: BytesObject, ) -> Result<BytesObject, HostError>

Maps a BLS12-381 field element (Fp) to G1 point. The input is a BytesObject containing Fp serialized in big-endian order
Source§

fn bls12_381_hash_to_g1( &self, _vmcaller: &mut VmCaller<'_, Host>, mo: BytesObject, dst: BytesObject, ) -> Result<BytesObject, HostError>

Hashes a message to a BLS12-381 G1 point, with implementation following the specification in Hashing to Elliptic Curves (ciphersuite ‘BLS12381G1_XMD:SHA-256_SSWU_RO_’). dst is the domain separation tag that will be concatenated with the msg during hashing, it is intended to keep hashing inputs of different applications separate. It is required 0 < len(dst_bytes) < 256. DST must be chosen with care to avoid compromising the application’s security properties. Refer to section 3.1 in the RFC on requirements of DST.
Source§

fn bls12_381_check_g2_is_in_subgroup( &self, _vmcaller: &mut VmCaller<'_, Host>, pt: BytesObject, ) -> Result<Bool, HostError>

Checks if the input G2 point is in the correct subgroup.
Source§

fn bls12_381_g2_add( &self, _vmcaller: &mut VmCaller<'_, Host>, p0: BytesObject, p1: BytesObject, ) -> Result<BytesObject, HostError>

Adds two BLS12-381 G2 points given in bytes format and returns the resulting G2 point in bytes format. G2 serialization format: concat(be_bytes(X_c1), be_bytes(X_c0), be_bytes(Y_c1), be_bytes(Y_c0)), and the most significant three bits of X_c1 are flags i.e. bits(X_c1) = [compression_flag, infinity_flag, sort_flag, bit_3, .. bit_383]. This function does NOT perform subgroup check on the inputs.
Source§

fn bls12_381_g2_mul( &self, _vmcaller: &mut VmCaller<'_, Host>, p0: BytesObject, scalar_le_bytes: U256Val, ) -> Result<BytesObject, HostError>

Multiplies a BLS12-381 G2 point by a scalar (Fr), and returns the resulting G2 point in bytes format.
Source§

fn bls12_381_g2_msm( &self, _vmcaller: &mut VmCaller<'_, Host>, vp: VecObject, vs: VecObject, ) -> Result<BytesObject, HostError>

Performs multi-scalar-multiplication (inner product) on a vector of BLS12-381 G2 points (Vec<BytesObject>) by a vector of scalars (Vec<U256Val>) , and returns the resulting G2 point in bytes format.
Source§

fn bls12_381_map_fp2_to_g2( &self, _vmcaller: &mut VmCaller<'_, Host>, fp2: BytesObject, ) -> Result<BytesObject, HostError>

Maps a BLS12-381 quadratic extension field element (Fp2) to G2 point. Fp2 serialization format: concat(be_bytes(c1), be_bytes(c0))
Source§

fn bls12_381_hash_to_g2( &self, _vmcaller: &mut VmCaller<'_, Host>, msg: BytesObject, dst: BytesObject, ) -> Result<BytesObject, HostError>

Hashes a message to a BLS12-381 G2 point, with implementation following the specification in Hashing to Elliptic Curves (ciphersuite ‘BLS12381G2_XMD:SHA-256_SSWU_RO_’). dst is the domain separation tag that will be concatenated with the msg during hashing, it is intended to keep hashing inputs of different applications separate. It is required 0 < len(dst_bytes) < 256. DST must be chosen with care to avoid compromising the application’s security properties. Refer to section 3.1 in the RFC on requirements of DST.
Source§

fn bls12_381_multi_pairing_check( &self, vmcaller: &mut VmCaller<'_, Host>, vp1: VecObject, vp2: VecObject, ) -> Result<Bool, HostError>

performs pairing operation on a vector of G1 (Vec<BytesObject>) and a vector of G2 points (Vec<BytesObject>) , return true if the result equals 1_fp12
Source§

fn bls12_381_fr_add( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs: U256Val, rhs: U256Val, ) -> Result<U256Val, Self::Error>

performs addition (lhs + rhs) mod r between two BLS12-381 scalar elements (Fr), where r is the subgroup order
Source§

fn bls12_381_fr_sub( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs: U256Val, rhs: U256Val, ) -> Result<U256Val, Self::Error>

performs subtraction (lhs - rhs) mod r between two BLS12-381 scalar elements (Fr), where r is the subgroup order
Source§

fn bls12_381_fr_mul( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs: U256Val, rhs: U256Val, ) -> Result<U256Val, Self::Error>

performs multiplication (lhs * rhs) mod r between two BLS12-381 scalar elements (Fr), where r is the subgroup order
Source§

fn bls12_381_fr_pow( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs: U256Val, rhs: U64Val, ) -> Result<U256Val, Self::Error>

performs exponentiation of a BLS12-381 scalar element (Fr) with a u64 exponent i.e. lhs.exp(rhs) mod r, where r is the subgroup order
Source§

fn bls12_381_fr_inv( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, lhs: U256Val, ) -> Result<U256Val, Self::Error>

performs inversion of a BLS12-381 scalar element (Fr) modulo r (the subgroup order)
Source§

fn dummy0( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, ) -> Result<Val, 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.
Source§

fn protocol_gated_dummy( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, ) -> Result<Val, Self::Error>

A dummy function for testing the protocol gating. Takes 0 arguments and performs no-op. Essentially this function is always protocol-gated out since it has min_supported_protocol == max_supported_protocol == 19, thus having no effect on any protocol (Soroban starts at protocol 20). This is required for testing the scenario where ledger protocol version > host function max supported version, and the ledger protocol version must be <= the env version (which starts at 20, and is a compile-time, non-overridable constant).
Source§

fn require_auth_for_args( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, address: AddressObject, args: VecObject, ) -> Result<Void, 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<Void, 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 authorize_as_curr_contract( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, auth_entries: VecObject, ) -> Result<Void, HostError>

Authorizes sub-contract calls for the next contract call on behalf of the current contract. Every entry in the argument vector corresponds to InvokerContractAuthEntry contract type that authorizes a tree of require_auth calls on behalf of the current contract. The entries must not contain any authorizations for the direct contract call, i.e. if current contract needs to call contract function F1 that calls function F2 both of which require auth, only F2 should be present in auth_entries.
Source§

fn address_to_strkey( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, address: AddressObject, ) -> Result<StringObject, Self::Error>

Converts a provided address to Stellar strkey format (‘G…’ for account or ‘C…’ for contract). Prefer directly using the Address objects whenever possible. This is only useful in the context of custom messaging protocols (e.g. cross-chain).
Source§

fn strkey_to_address( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, strkey_obj: Val, ) -> Result<AddressObject, Self::Error>

Converts a provided Stellar strkey address of an account or a contract (‘G…’ or ‘C…’ respectively) to an address object. strkey can be either BytesObject or StringObject (the contents should represent the G.../C... string in both cases). Any other valid or invalid strkey (e.g. ‘S…’) will trigger an error. Prefer directly using the Address objects whenever possible. This is only useful in the context of custom messaging protocols (e.g. cross-chain).
Source§

fn prng_reseed( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, seed: BytesObject, ) -> Result<Void, Self::Error>

Reseed the frame-local PRNG with a given BytesObject, which should be 32 bytes long.
Source§

fn prng_bytes_new( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, length: U32Val, ) -> Result<BytesObject, Self::Error>

Construct a new BytesObject of the given length filled with bytes drawn from the frame-local PRNG.
Source§

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

Return a u64 uniformly sampled from the inclusive range [lo,hi] by the frame-local PRNG.
Source§

fn prng_vec_shuffle( &self, _vmcaller: &mut VmCaller<'_, Self::VmUserState>, vec: VecObject, ) -> Result<VecObject, Self::Error>

Return a (Fisher-Yates) shuffled clone of a given vector, using the frame-local PRNG.

Auto Trait Implementations§

§

impl Freeze for Host

§

impl !RefUnwindSafe for Host

§

impl !Send for Host

§

impl !Sync for Host

§

impl Unpin for Host

§

impl !UnwindSafe for Host

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T, C> Compare<&T> for C
where C: Compare<T>,

Source§

type Error = <C as Compare<T>>::Error

Source§

fn compare(&self, a: &&T, b: &&T) -> Result<Ordering, <C as Compare<&T>>::Error>

Source§

impl<T, U, E, C> Compare<(T, U)> for C
where C: Compare<T, Error = E, Error = E> + Compare<U>,

Source§

type Error = E

Source§

fn compare( &self, a: &(T, U), b: &(T, U), ) -> Result<Ordering, <C as Compare<(T, U)>>::Error>

Source§

impl<T, U, V, E, C> Compare<(T, U, V)> for C
where C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,

Source§

impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
where C: Compare<T, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W>,

Source§

impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
where C: Compare<T, Error = E, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W> + Compare<X>,

Source§

impl<E> Compare<AddressObject> for E
where E: Env,

Source§

impl<E> Compare<Bool> for E
where E: Env,

Source§

type Error = <E as EnvBase>::Error

Source§

fn compare( &self, a: &Bool, b: &Bool, ) -> Result<Ordering, <E as Compare<Bool>>::Error>

Source§

impl<T, C> Compare<Box<T>> for C
where C: Compare<T>,

Source§

type Error = <C as Compare<T>>::Error

Source§

fn compare( &self, a: &Box<T>, b: &Box<T>, ) -> Result<Ordering, <C as Compare<Box<T>>>::Error>

Source§

impl<E> Compare<BytesObject> for E
where E: Env,

Source§

impl<E> Compare<DurationObject> for E
where E: Env,

Source§

impl<E> Compare<DurationSmall> for E
where E: Env,

Source§

impl<E> Compare<Error> for E
where E: Env,

Source§

type Error = <E as EnvBase>::Error

Source§

fn compare( &self, a: &Error, b: &Error, ) -> Result<Ordering, <E as Compare<Error>>::Error>

Source§

impl<E> Compare<I128Object> for E
where E: Env,

Source§

impl<E> Compare<I128Small> for E
where E: Env,

Source§

impl<E> Compare<I256Object> for E
where E: Env,

Source§

impl<E> Compare<I256Small> for E
where E: Env,

Source§

impl<E> Compare<I32Val> for E
where E: Env,

Source§

type Error = <E as EnvBase>::Error

Source§

fn compare( &self, a: &I32Val, b: &I32Val, ) -> Result<Ordering, <E as Compare<I32Val>>::Error>

Source§

impl<E> Compare<I64Object> for E
where E: Env,

Source§

impl<E> Compare<I64Small> for E
where E: Env,

Source§

type Error = <E as EnvBase>::Error

Source§

fn compare( &self, a: &I64Small, b: &I64Small, ) -> Result<Ordering, <E as Compare<I64Small>>::Error>

Source§

impl<E> Compare<MapObject> for E
where E: Env,

Source§

impl<E> Compare<Object> for E
where E: Env,

Source§

type Error = <E as EnvBase>::Error

Source§

fn compare( &self, a: &Object, b: &Object, ) -> Result<Ordering, <E as Compare<Object>>::Error>

Source§

impl<T, C> Compare<Option<T>> for C
where C: Compare<T>,

Source§

type Error = <C as Compare<T>>::Error

Source§

fn compare( &self, a: &Option<T>, b: &Option<T>, ) -> Result<Ordering, <C as Compare<Option<T>>>::Error>

Source§

impl<T, C> Compare<Rc<T>> for C
where C: Compare<T>,

Source§

type Error = <C as Compare<T>>::Error

Source§

fn compare( &self, a: &Rc<T>, b: &Rc<T>, ) -> Result<Ordering, <C as Compare<Rc<T>>>::Error>

Source§

impl<E> Compare<StringObject> for E
where E: Env,

Source§

impl<E> Compare<Symbol> for E
where E: Env,

Source§

type Error = <E as EnvBase>::Error

Source§

fn compare( &self, a: &Symbol, b: &Symbol, ) -> Result<Ordering, <E as Compare<Symbol>>::Error>

Source§

impl<E> Compare<SymbolObject> for E
where E: Env,

Source§

impl<E> Compare<SymbolSmall> for E
where E: Env,

Source§

impl<E> Compare<TimepointObject> for E
where E: Env,

Source§

impl<E> Compare<TimepointSmall> for E
where E: Env,

Source§

impl<E> Compare<U128Object> for E
where E: Env,

Source§

impl<E> Compare<U128Small> for E
where E: Env,

Source§

impl<E> Compare<U256Object> for E
where E: Env,

Source§

impl<E> Compare<U256Small> for E
where E: Env,

Source§

impl<E> Compare<U32Val> for E
where E: Env,

Source§

type Error = <E as EnvBase>::Error

Source§

fn compare( &self, a: &U32Val, b: &U32Val, ) -> Result<Ordering, <E as Compare<U32Val>>::Error>

Source§

impl<E> Compare<U64Object> for E
where E: Env,

Source§

impl<E> Compare<U64Small> for E
where E: Env,

Source§

type Error = <E as EnvBase>::Error

Source§

fn compare( &self, a: &U64Small, b: &U64Small, ) -> Result<Ordering, <E as Compare<U64Small>>::Error>

Source§

impl<E> Compare<Val> for E
where E: Env,

Source§

type Error = <E as EnvBase>::Error

Source§

fn compare( &self, a: &Val, b: &Val, ) -> Result<Ordering, <E as Compare<Val>>::Error>

Source§

impl<T, C> Compare<Vec<T>> for C
where C: Compare<T>,

Source§

type Error = <C as Compare<T>>::Error

Source§

fn compare( &self, a: &Vec<T>, b: &Vec<T>, ) -> Result<Ordering, <C as Compare<Vec<T>>>::Error>

Source§

impl<E> Compare<VecObject> for E
where E: Env,

Source§

impl<E> Compare<Void> for E
where E: Env,

Source§

type Error = <E as EnvBase>::Error

Source§

fn compare( &self, _a: &Void, _b: &Void, ) -> Result<Ordering, <E as Compare<Void>>::Error>

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Env for T
where T: VmCallerEnv,

Source§

fn log_from_linear_memory( &self, msg_pos: U32Val, msg_len: U32Val, vals_pos: U32Val, vals_len: U32Val, ) -> Result<Void, <T as EnvBase>::Error>

Emit a diagnostic event containing a message and sequence of Vals.
Source§

fn obj_cmp(&self, a: Val, b: Val) -> Result<i64, <T as EnvBase>::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, topics: VecObject, data: Val, ) -> Result<Void, <T as EnvBase>::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.
Source§

fn get_ledger_version(&self) -> Result<U32Val, <T as EnvBase>::Error>

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

fn get_ledger_sequence(&self) -> Result<U32Val, <T as EnvBase>::Error>

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

fn get_ledger_timestamp(&self) -> Result<U64Val, <T as EnvBase>::Error>

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

fn fail_with_error(&self, error: Error) -> Result<Void, <T as EnvBase>::Error>

Causes the currently executing contract to fail immediately with a provided error code, which must be of error-type ScErrorType::Contract. Does not actually return.
Source§

fn get_ledger_network_id(&self) -> Result<BytesObject, <T as EnvBase>::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, ) -> Result<AddressObject, <T as EnvBase>::Error>

Get the Address object for the current contract.
Source§

fn get_max_live_until_ledger(&self) -> Result<U32Val, <T as EnvBase>::Error>

Returns the max ledger sequence that an entry can live to (inclusive).
Source§

fn obj_from_u64(&self, v: u64) -> Result<U64Object, <T as EnvBase>::Error>

Convert a u64 to an object containing a u64.
Source§

fn obj_to_u64(&self, obj: U64Object) -> Result<u64, <T as EnvBase>::Error>

Convert an object containing a u64 to a u64.
Source§

fn obj_from_i64(&self, v: i64) -> Result<I64Object, <T as EnvBase>::Error>

Convert an i64 to an object containing an i64.
Source§

fn obj_to_i64(&self, obj: I64Object) -> Result<i64, <T as EnvBase>::Error>

Convert an object containing an i64 to an i64.
Source§

fn obj_from_u128_pieces( &self, hi: u64, lo: u64, ) -> Result<U128Object, <T as EnvBase>::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, obj: U128Object, ) -> Result<u64, <T as EnvBase>::Error>

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

fn obj_to_u128_hi64( &self, obj: U128Object, ) -> Result<u64, <T as EnvBase>::Error>

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

fn obj_from_i128_pieces( &self, hi: i64, lo: u64, ) -> Result<I128Object, <T as EnvBase>::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, obj: I128Object, ) -> Result<u64, <T as EnvBase>::Error>

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

fn obj_to_i128_hi64( &self, obj: I128Object, ) -> Result<i64, <T as EnvBase>::Error>

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

fn obj_from_u256_pieces( &self, hi_hi: u64, hi_lo: u64, lo_hi: u64, lo_lo: u64, ) -> Result<U256Object, <T as EnvBase>::Error>

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

fn u256_val_from_be_bytes( &self, bytes: BytesObject, ) -> Result<U256Val, <T as EnvBase>::Error>

Create a U256 Val from its representation as a byte array in big endian.
Source§

fn u256_val_to_be_bytes( &self, val: U256Val, ) -> Result<BytesObject, <T as EnvBase>::Error>

Return the memory representation of this U256 Val as a byte array in big endian byte order.
Source§

fn obj_to_u256_hi_hi( &self, obj: U256Object, ) -> Result<u64, <T as EnvBase>::Error>

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

fn obj_to_u256_hi_lo( &self, obj: U256Object, ) -> Result<u64, <T as EnvBase>::Error>

Extract bits 128-191 from an object containing a u256.
Source§

fn obj_to_u256_lo_hi( &self, obj: U256Object, ) -> Result<u64, <T as EnvBase>::Error>

Extract bits 64-127 from an object containing a u256.
Source§

fn obj_to_u256_lo_lo( &self, obj: U256Object, ) -> Result<u64, <T as EnvBase>::Error>

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

fn obj_from_i256_pieces( &self, hi_hi: i64, hi_lo: u64, lo_hi: u64, lo_lo: u64, ) -> Result<I256Object, <T as EnvBase>::Error>

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

fn i256_val_from_be_bytes( &self, bytes: BytesObject, ) -> Result<I256Val, <T as EnvBase>::Error>

Create a I256 Val from its representation as a byte array in big endian.
Source§

fn i256_val_to_be_bytes( &self, val: I256Val, ) -> Result<BytesObject, <T as EnvBase>::Error>

Return the memory representation of this I256 Val as a byte array in big endian byte order.
Source§

fn obj_to_i256_hi_hi( &self, obj: I256Object, ) -> Result<i64, <T as EnvBase>::Error>

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

fn obj_to_i256_hi_lo( &self, obj: I256Object, ) -> Result<u64, <T as EnvBase>::Error>

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

fn obj_to_i256_lo_hi( &self, obj: I256Object, ) -> Result<u64, <T as EnvBase>::Error>

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

fn obj_to_i256_lo_lo( &self, obj: I256Object, ) -> Result<u64, <T as EnvBase>::Error>

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

fn u256_add( &self, lhs: U256Val, rhs: U256Val, ) -> Result<U256Val, <T as EnvBase>::Error>

Performs checked integer addition. Computes lhs + rhs, returning ScError if overflow occurred.
Source§

fn u256_sub( &self, lhs: U256Val, rhs: U256Val, ) -> Result<U256Val, <T as EnvBase>::Error>

Performs checked integer subtraction. Computes lhs - rhs, returning ScError if overflow occurred.
Source§

fn u256_mul( &self, lhs: U256Val, rhs: U256Val, ) -> Result<U256Val, <T as EnvBase>::Error>

Performs checked integer multiplication. Computes lhs * rhs, returning ScError if overflow occurred.
Source§

fn u256_div( &self, lhs: U256Val, rhs: U256Val, ) -> Result<U256Val, <T as EnvBase>::Error>

Performs checked integer division. Computes lhs / rhs, returning ScError if rhs == 0 or overflow occurred.
Source§

fn u256_rem_euclid( &self, lhs: U256Val, rhs: U256Val, ) -> Result<U256Val, <T as EnvBase>::Error>

Performs checked Euclidean modulo. Computes lhs % rhs, returning ScError if rhs == 0 or overflow occurred.
Source§

fn u256_pow( &self, lhs: U256Val, rhs: U32Val, ) -> Result<U256Val, <T as EnvBase>::Error>

Performs checked exponentiation. Computes lhs.exp(rhs), returning ScError if overflow occurred.
Source§

fn u256_shl( &self, lhs: U256Val, rhs: U32Val, ) -> Result<U256Val, <T as EnvBase>::Error>

Performs checked shift left. Computes lhs << rhs, returning ScError if rhs is larger than or equal to the number of bits in lhs.
Source§

fn u256_shr( &self, lhs: U256Val, rhs: U32Val, ) -> Result<U256Val, <T as EnvBase>::Error>

Performs checked shift right. Computes lhs >> rhs, returning ScError if rhs is larger than or equal to the number of bits in lhs.
Source§

fn i256_add( &self, lhs: I256Val, rhs: I256Val, ) -> Result<I256Val, <T as EnvBase>::Error>

Performs checked integer addition. Computes lhs + rhs, returning ScError if overflow occurred.
Source§

fn i256_sub( &self, lhs: I256Val, rhs: I256Val, ) -> Result<I256Val, <T as EnvBase>::Error>

Performs checked integer subtraction. Computes lhs - rhs, returning ScError if overflow occurred.
Source§

fn i256_mul( &self, lhs: I256Val, rhs: I256Val, ) -> Result<I256Val, <T as EnvBase>::Error>

Performs checked integer multiplication. Computes lhs * rhs, returning ScError if overflow occurred.
Source§

fn i256_div( &self, lhs: I256Val, rhs: I256Val, ) -> Result<I256Val, <T as EnvBase>::Error>

Performs checked integer division. Computes lhs / rhs, returning ScError if rhs == 0 or overflow occurred.
Source§

fn i256_rem_euclid( &self, lhs: I256Val, rhs: I256Val, ) -> Result<I256Val, <T as EnvBase>::Error>

Performs checked Euclidean modulo. Computes lhs % rhs, returning ScError if rhs == 0 or overflow occurred.
Source§

fn i256_pow( &self, lhs: I256Val, rhs: U32Val, ) -> Result<I256Val, <T as EnvBase>::Error>

Performs checked exponentiation. Computes lhs.exp(rhs), returning ScError if overflow occurred.
Source§

fn i256_shl( &self, lhs: I256Val, rhs: U32Val, ) -> Result<I256Val, <T as EnvBase>::Error>

Performs checked shift left. Computes lhs << rhs, returning ScError if rhs is larger than or equal to the number of bits in lhs.
Source§

fn i256_shr( &self, lhs: I256Val, rhs: U32Val, ) -> Result<I256Val, <T as EnvBase>::Error>

Performs checked shift right. Computes lhs >> rhs, returning ScError if rhs is larger than or equal to the number of bits in lhs.
Source§

fn timepoint_obj_from_u64( &self, v: u64, ) -> Result<TimepointObject, <T as EnvBase>::Error>

Convert a u64 to a Timepoint object.
Source§

fn timepoint_obj_to_u64( &self, obj: TimepointObject, ) -> Result<u64, <T as EnvBase>::Error>

Convert a Timepoint object to a u64.
Source§

fn duration_obj_from_u64( &self, v: u64, ) -> Result<DurationObject, <T as EnvBase>::Error>

Convert a u64 to a Duration object.
Source§

fn duration_obj_to_u64( &self, obj: DurationObject, ) -> Result<u64, <T as EnvBase>::Error>

Convert a Duration object a u64.
Source§

fn map_new(&self) -> Result<MapObject, <T as EnvBase>::Error>

Create an empty new map.
Source§

fn map_put( &self, m: MapObject, k: Val, v: Val, ) -> Result<MapObject, <T as EnvBase>::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, m: MapObject, k: Val) -> Result<Val, <T as EnvBase>::Error>

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

fn map_del( &self, m: MapObject, k: Val, ) -> Result<MapObject, <T as EnvBase>::Error>

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

fn map_len(&self, m: MapObject) -> Result<U32Val, <T as EnvBase>::Error>

Get the size of a map.
Source§

fn map_has(&self, m: MapObject, k: Val) -> Result<Bool, <T as EnvBase>::Error>

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

fn map_key_by_pos( &self, m: MapObject, i: U32Val, ) -> Result<Val, <T as EnvBase>::Error>

Get the key from a map at position i. If i is an invalid position, return ScError.
Source§

fn map_val_by_pos( &self, m: MapObject, i: U32Val, ) -> Result<Val, <T as EnvBase>::Error>

Get the value from a map at position i. If i is an invalid position, return ScError.
Source§

fn map_keys(&self, m: MapObject) -> Result<VecObject, <T as EnvBase>::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, m: MapObject) -> Result<VecObject, <T as EnvBase>::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, keys_pos: U32Val, vals_pos: U32Val, len: U32Val, ) -> Result<MapObject, <T as EnvBase>::Error>

Return a new map initialized from a pair of equal-length arrays, one for keys and one for values, given by a pair of linear-memory addresses and a length in Vals.
Source§

fn map_unpack_to_linear_memory( &self, map: MapObject, keys_pos: U32Val, vals_pos: U32Val, len: U32Val, ) -> Result<Void, <T as EnvBase>::Error>

Copy Vals from map to the array vals_pos, selecting only the keys identified by the array keys_pos. Both arrays have len elements and are identified by linear-memory addresses.
Source§

fn vec_new(&self) -> Result<VecObject, <T as EnvBase>::Error>

Creates an empty new vector.
Source§

fn vec_put( &self, v: VecObject, i: U32Val, x: Val, ) -> Result<VecObject, <T as EnvBase>::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, v: VecObject, i: U32Val) -> Result<Val, <T as EnvBase>::Error>

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

fn vec_del( &self, v: VecObject, i: U32Val, ) -> Result<VecObject, <T as EnvBase>::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, v: VecObject) -> Result<U32Val, <T as EnvBase>::Error>

Returns length of the vector.
Source§

fn vec_push_front( &self, v: VecObject, x: Val, ) -> Result<VecObject, <T as EnvBase>::Error>

Push a value to the front of a vector.
Source§

fn vec_pop_front( &self, v: VecObject, ) -> Result<VecObject, <T as EnvBase>::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, v: VecObject, x: Val, ) -> Result<VecObject, <T as EnvBase>::Error>

Appends an element to the back of the vector.
Source§

fn vec_pop_back(&self, v: VecObject) -> Result<VecObject, <T as EnvBase>::Error>

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

fn vec_front(&self, v: VecObject) -> Result<Val, <T as EnvBase>::Error>

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

fn vec_back(&self, v: VecObject) -> Result<Val, <T as EnvBase>::Error>

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

fn vec_insert( &self, v: VecObject, i: U32Val, x: Val, ) -> Result<VecObject, <T as EnvBase>::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, v1: VecObject, v2: VecObject, ) -> Result<VecObject, <T as EnvBase>::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, v: VecObject, start: U32Val, end: U32Val, ) -> Result<VecObject, <T as EnvBase>::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, v: VecObject, x: Val, ) -> Result<Val, <T as EnvBase>::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 Void.
Source§

fn vec_last_index_of( &self, v: VecObject, x: Val, ) -> Result<Val, <T as EnvBase>::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 Void.
Source§

fn vec_binary_search( &self, v: VecObject, x: Val, ) -> Result<u64, <T as EnvBase>::Error>

Binary search a sorted vector for a given element. If it exists, the high 32 bits of the return value is 0x0000_0001 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_0000 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, vals_pos: U32Val, len: U32Val, ) -> Result<VecObject, <T as EnvBase>::Error>

Return a new vec initialized from an input slice of Vals given by a linear-memory address and length in Vals.
Source§

fn vec_unpack_to_linear_memory( &self, vec: VecObject, vals_pos: U32Val, len: U32Val, ) -> Result<Void, <T as EnvBase>::Error>

Copy the Vals of a vec into an array at a given linear-memory address and length in Vals.
Source§

fn put_contract_data( &self, k: Val, v: Val, t: StorageType, ) -> Result<Void, <T as EnvBase>::Error>

Source§

fn has_contract_data( &self, k: Val, t: StorageType, ) -> Result<Bool, <T as EnvBase>::Error>

Source§

fn get_contract_data( &self, k: Val, t: StorageType, ) -> Result<Val, <T as EnvBase>::Error>

Source§

fn del_contract_data( &self, k: Val, t: StorageType, ) -> Result<Void, <T as EnvBase>::Error>

Source§

fn create_contract( &self, deployer: AddressObject, wasm_hash: BytesObject, salt: BytesObject, ) -> Result<AddressObject, <T as EnvBase>::Error>

Creates the contract instance on behalf of deployer. deployer must authorize this call via Soroban auth framework, i.e. this calls deployer.require_auth with respective arguments. wasm_hash must be a hash of the contract code that has already been uploaded on this network. salt is used to create a unique contract id. Returns the address of the created contract.
Source§

fn create_asset_contract( &self, serialized_asset: BytesObject, ) -> Result<AddressObject, <T as EnvBase>::Error>

Creates the instance of Stellar Asset contract corresponding to the provided asset. serialized_asset is stellar::Asset XDR serialized to bytes format. Returns the address of the created contract.
Source§

fn upload_wasm( &self, wasm: BytesObject, ) -> Result<BytesObject, <T as EnvBase>::Error>

Uploads provided wasm bytecode to the network and returns its identifier (SHA-256 hash). No-op in case if the same Wasm object already exists.
Source§

fn update_current_contract_wasm( &self, hash: BytesObject, ) -> Result<Void, <T as EnvBase>::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 extend_contract_data_ttl( &self, k: Val, t: StorageType, threshold: U32Val, extend_to: U32Val, ) -> Result<Void, <T as EnvBase>::Error>

If the entry’s TTL is below threshold ledgers, extend live_until_ledger_seq such that TTL == extend_to, where TTL is defined as live_until_ledger_seq - current ledger. If attempting to extend the entry past the maximum allowed value (defined as the current ledger + max_entry_ttl - 1), and the entry is Persistent, its new live_until_ledger_seq will be clamped to the max; if the entry is Temporary, the function traps.
Source§

fn extend_current_contract_instance_and_code_ttl( &self, threshold: U32Val, extend_to: U32Val, ) -> Result<Void, <T as EnvBase>::Error>

If the TTL for the current contract instance and code (if applicable) is below threshold ledgers, extend live_until_ledger_seq such that TTL == extend_to, where TTL is defined as live_until_ledger_seq - current ledger. If attempting to extend past the maximum allowed value (defined as the current ledger + max_entry_ttl - 1), the new live_until_ledger_seq will be clamped to the max.
Source§

fn extend_contract_instance_and_code_ttl( &self, contract: AddressObject, threshold: U32Val, extend_to: U32Val, ) -> Result<Void, <T as EnvBase>::Error>

If the TTL for the provided contract instance and code (if applicable) is below threshold ledgers, extend live_until_ledger_seq such that TTL == extend_to, where TTL is defined as live_until_ledger_seq - current ledger. If attempting to extend past the maximum allowed value (defined as the current ledger + max_entry_ttl - 1), the new live_until_ledger_seq will be clamped to the max.
Source§

fn get_contract_id( &self, deployer: AddressObject, salt: BytesObject, ) -> Result<AddressObject, <T as EnvBase>::Error>

Get the id of a contract without creating it. deployer is address of the contract deployer. salt is used to create a unique contract id. Returns the address of the would-be contract.
Source§

fn get_asset_contract_id( &self, serialized_asset: BytesObject, ) -> Result<AddressObject, <T as EnvBase>::Error>

Get the id of the Stellar Asset contract corresponding to the provided asset without creating the instance. serialized_asset is stellar::Asset XDR serialized to bytes format. Returns the address of the would-be asset contract.
Source§

fn extend_contract_instance_ttl( &self, contract: AddressObject, threshold: U32Val, extend_to: U32Val, ) -> Result<Void, <T as EnvBase>::Error>

If the TTL for the provided contract instance is below threshold ledgers, extend live_until_ledger_seq such that TTL == extend_to, where TTL is defined as live_until_ledger_seq - current ledger. If attempting to extend past the maximum allowed value (defined as the current ledger + max_entry_ttl - 1), the new live_until_ledger_seq will be clamped to the max.
Source§

fn extend_contract_code_ttl( &self, contract: AddressObject, threshold: U32Val, extend_to: U32Val, ) -> Result<Void, <T as EnvBase>::Error>

If the TTL for the provided contract’s code (if applicable) is below threshold ledgers, extend live_until_ledger_seq such that TTL == extend_to, where TTL is defined as live_until_ledger_seq - current ledger. If attempting to extend past the maximum allowed value (defined as the current ledger + max_entry_ttl - 1), the new live_until_ledger_seq will be clamped to the max.
Source§

fn create_contract_with_constructor( &self, deployer: AddressObject, wasm_hash: BytesObject, salt: BytesObject, constructor_args: VecObject, ) -> Result<AddressObject, <T as EnvBase>::Error>

Creates the contract instance on behalf of deployer. Created contract must be created from a Wasm that has a constructor. deployer must authorize this call via Soroban auth framework, i.e. this calls deployer.require_auth with respective arguments. wasm_hash must be a hash of the contract code that has already been uploaded on this network. salt is used to create a unique contract id. constructor_args are forwarded into created contract’s constructor (__constructor) function. Returns the address of the created contract.
Source§

fn call( &self, contract: AddressObject, func: Symbol, args: VecObject, ) -> Result<Val, <T as EnvBase>::Error>

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

fn try_call( &self, contract: AddressObject, func: Symbol, args: VecObject, ) -> Result<Val, <T as EnvBase>::Error>

Calls a function in another contract with arguments contained in vector args, returning either the result of the called function or an Error if the called function failed. The returned error is either a custom ContractError that the called contract returns explicitly, or an error with type Context and code InvalidAction in case of any other error in the called contract (such as a host function failure that caused a trap). try_call might trap in a few scenarios where the error can’t be meaningfully recovered from, such as running out of budget.
Source§

fn serialize_to_bytes( &self, v: Val, ) -> Result<BytesObject, <T as EnvBase>::Error>

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

fn deserialize_from_bytes( &self, b: BytesObject, ) -> Result<Val, <T as EnvBase>::Error>

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

fn bytes_copy_to_linear_memory( &self, b: BytesObject, b_pos: U32Val, lm_pos: U32Val, len: U32Val, ) -> Result<Void, <T as EnvBase>::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, b: BytesObject, b_pos: U32Val, lm_pos: U32Val, len: U32Val, ) -> Result<BytesObject, <T as EnvBase>::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, lm_pos: U32Val, len: U32Val, ) -> Result<BytesObject, <T as EnvBase>::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) -> Result<BytesObject, <T as EnvBase>::Error>

Create an empty new Bytes object.
Source§

fn bytes_put( &self, b: BytesObject, i: U32Val, u: U32Val, ) -> Result<BytesObject, <T as EnvBase>::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, b: BytesObject, i: U32Val, ) -> Result<U32Val, <T as EnvBase>::Error>

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

fn bytes_del( &self, b: BytesObject, i: U32Val, ) -> Result<BytesObject, <T as EnvBase>::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, b: BytesObject) -> Result<U32Val, <T as EnvBase>::Error>

Returns length of the Bytes object.
Source§

fn bytes_push( &self, b: BytesObject, u: U32Val, ) -> Result<BytesObject, <T as EnvBase>::Error>

Appends an element to the back of the Bytes object.
Source§

fn bytes_pop( &self, b: BytesObject, ) -> Result<BytesObject, <T as EnvBase>::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, b: BytesObject) -> Result<U32Val, <T as EnvBase>::Error>

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

fn bytes_back(&self, b: BytesObject) -> Result<U32Val, <T as EnvBase>::Error>

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

fn bytes_insert( &self, b: BytesObject, i: U32Val, u: U32Val, ) -> Result<BytesObject, <T as EnvBase>::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, b1: BytesObject, b2: BytesObject, ) -> Result<BytesObject, <T as EnvBase>::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, b: BytesObject, start: U32Val, end: U32Val, ) -> Result<BytesObject, <T as EnvBase>::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, s: StringObject, s_pos: U32Val, lm_pos: U32Val, len: U32Val, ) -> Result<Void, <T as EnvBase>::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, s: SymbolObject, s_pos: U32Val, lm_pos: U32Val, len: U32Val, ) -> Result<Void, <T as EnvBase>::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, lm_pos: U32Val, len: U32Val, ) -> Result<StringObject, <T as EnvBase>::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, lm_pos: U32Val, len: U32Val, ) -> Result<SymbolObject, <T as EnvBase>::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, s: StringObject) -> Result<U32Val, <T as EnvBase>::Error>

Returns length of the String object.
Source§

fn symbol_len(&self, s: SymbolObject) -> Result<U32Val, <T as EnvBase>::Error>

Returns length of the Symbol object.
Source§

fn symbol_index_in_linear_memory( &self, sym: Symbol, slices_pos: U32Val, len: U32Val, ) -> Result<U32Val, <T as EnvBase>::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, x: BytesObject, ) -> Result<BytesObject, <T as EnvBase>::Error>

Source§

fn verify_sig_ed25519( &self, k: BytesObject, x: BytesObject, s: BytesObject, ) -> Result<Void, <T as EnvBase>::Error>

Source§

fn compute_hash_keccak256( &self, x: BytesObject, ) -> Result<BytesObject, <T as EnvBase>::Error>

Returns the keccak256 hash of given input bytes.
Source§

fn recover_key_ecdsa_secp256k1( &self, msg_digest: BytesObject, signature: BytesObject, recovery_id: U32Val, ) -> Result<BytesObject, <T as EnvBase>::Error>

Recovers the SEC-1-encoded ECDSA secp256k1 public key that produced a given 64-byte signature over a given 32-byte msg_digest for a given recovery_id byte. Warning: The msg_digest must be produced by a secure cryptographic hash function on the message, otherwise the attacker can potentially forge signatures. The signature is the ECDSA signature (r, s) serialized as fixed-size big endian scalar values, both r, s must be non-zero and s must be in the lower range. Returns a BytesObject containing 65-bytes representing SEC-1 encoded point in uncompressed format. The recovery_id is an integer value 0, 1, 2, or 3, the low bit (0/1) indicates the parity of the y-coordinate of the public_key (even/odd) and the high bit (3/4) indicate if the r (x-coordinate of k x G) has overflown during its computation.
Source§

fn verify_sig_ecdsa_secp256r1( &self, public_key: BytesObject, msg_digest: BytesObject, signature: BytesObject, ) -> Result<Void, <T as EnvBase>::Error>

Verifies the signature using an ECDSA secp256r1 public_key on a 32-byte msg_digest. Warning: The msg_digest must be produced by a secure cryptographic hash function on the message, otherwise the attacker can potentially forge signatures. The public_key is expected to be 65 bytes in length, representing a SEC-1 encoded point in uncompressed format. The signature is the ECDSA signature (r, s) serialized as fixed-size big endian scalar values, both r, s must be non-zero and s must be in the lower range.
Source§

fn bls12_381_check_g1_is_in_subgroup( &self, point: BytesObject, ) -> Result<Bool, <T as EnvBase>::Error>

Checks if the input G1 point is in the correct subgroup.
Source§

fn bls12_381_g1_add( &self, point1: BytesObject, point2: BytesObject, ) -> Result<BytesObject, <T as EnvBase>::Error>

Adds two BLS12-381 G1 points given in bytes format and returns the resulting G1 point in bytes format. G1 serialization format: concat(be_bytes(X), be_bytes(Y)) and the most significant three bits of X encodes flags, i.e. bits(X) = [compression_flag, infinity_flag, sort_flag, bit_3, .. bit_383]. This function does NOT perform subgroup check on the inputs.
Source§

fn bls12_381_g1_mul( &self, point: BytesObject, scalar: U256Val, ) -> Result<BytesObject, <T as EnvBase>::Error>

Multiplies a BLS12-381 G1 point by a scalar (Fr), and returns the resulting G1 point in bytes format.
Source§

fn bls12_381_g1_msm( &self, vp: VecObject, vs: VecObject, ) -> Result<BytesObject, <T as EnvBase>::Error>

Performs multi-scalar-multiplication (inner product) on a vector of BLS12-381 G1 points (Vec<BytesObject>) by a vector of scalars (Vec<U256Val>), and returns the resulting G1 point in bytes format.
Source§

fn bls12_381_map_fp_to_g1( &self, fp: BytesObject, ) -> Result<BytesObject, <T as EnvBase>::Error>

Maps a BLS12-381 field element (Fp) to G1 point. The input is a BytesObject containing Fp serialized in big-endian order
Source§

fn bls12_381_hash_to_g1( &self, msg: BytesObject, dst: BytesObject, ) -> Result<BytesObject, <T as EnvBase>::Error>

Hashes a message to a BLS12-381 G1 point, with implementation following the specification in Hashing to Elliptic Curves (ciphersuite ‘BLS12381G1_XMD:SHA-256_SSWU_RO_’). dst is the domain separation tag that will be concatenated with the msg during hashing, it is intended to keep hashing inputs of different applications separate. It is required 0 < len(dst_bytes) < 256. DST must be chosen with care to avoid compromising the application’s security properties. Refer to section 3.1 in the RFC on requirements of DST.
Source§

fn bls12_381_check_g2_is_in_subgroup( &self, point: BytesObject, ) -> Result<Bool, <T as EnvBase>::Error>

Checks if the input G2 point is in the correct subgroup.
Source§

fn bls12_381_g2_add( &self, point1: BytesObject, point2: BytesObject, ) -> Result<BytesObject, <T as EnvBase>::Error>

Adds two BLS12-381 G2 points given in bytes format and returns the resulting G2 point in bytes format. G2 serialization format: concat(be_bytes(X_c1), be_bytes(X_c0), be_bytes(Y_c1), be_bytes(Y_c0)), and the most significant three bits of X_c1 are flags i.e. bits(X_c1) = [compression_flag, infinity_flag, sort_flag, bit_3, .. bit_383]. This function does NOT perform subgroup check on the inputs.
Source§

fn bls12_381_g2_mul( &self, point: BytesObject, scalar: U256Val, ) -> Result<BytesObject, <T as EnvBase>::Error>

Multiplies a BLS12-381 G2 point by a scalar (Fr), and returns the resulting G2 point in bytes format.
Source§

fn bls12_381_g2_msm( &self, vp: VecObject, vs: VecObject, ) -> Result<BytesObject, <T as EnvBase>::Error>

Performs multi-scalar-multiplication (inner product) on a vector of BLS12-381 G2 points (Vec<BytesObject>) by a vector of scalars (Vec<U256Val>) , and returns the resulting G2 point in bytes format.
Source§

fn bls12_381_map_fp2_to_g2( &self, fp2: BytesObject, ) -> Result<BytesObject, <T as EnvBase>::Error>

Maps a BLS12-381 quadratic extension field element (Fp2) to G2 point. Fp2 serialization format: concat(be_bytes(c1), be_bytes(c0))
Source§

fn bls12_381_hash_to_g2( &self, msg: BytesObject, dst: BytesObject, ) -> Result<BytesObject, <T as EnvBase>::Error>

Hashes a message to a BLS12-381 G2 point, with implementation following the specification in Hashing to Elliptic Curves (ciphersuite ‘BLS12381G2_XMD:SHA-256_SSWU_RO_’). dst is the domain separation tag that will be concatenated with the msg during hashing, it is intended to keep hashing inputs of different applications separate. It is required 0 < len(dst_bytes) < 256. DST must be chosen with care to avoid compromising the application’s security properties. Refer to section 3.1 in the RFC on requirements of DST.
Source§

fn bls12_381_multi_pairing_check( &self, vp1: VecObject, vp2: VecObject, ) -> Result<Bool, <T as EnvBase>::Error>

performs pairing operation on a vector of G1 (Vec<BytesObject>) and a vector of G2 points (Vec<BytesObject>) , return true if the result equals 1_fp12
Source§

fn bls12_381_fr_add( &self, lhs: U256Val, rhs: U256Val, ) -> Result<U256Val, <T as EnvBase>::Error>

performs addition (lhs + rhs) mod r between two BLS12-381 scalar elements (Fr), where r is the subgroup order
Source§

fn bls12_381_fr_sub( &self, lhs: U256Val, rhs: U256Val, ) -> Result<U256Val, <T as EnvBase>::Error>

performs subtraction (lhs - rhs) mod r between two BLS12-381 scalar elements (Fr), where r is the subgroup order
Source§

fn bls12_381_fr_mul( &self, lhs: U256Val, rhs: U256Val, ) -> Result<U256Val, <T as EnvBase>::Error>

performs multiplication (lhs * rhs) mod r between two BLS12-381 scalar elements (Fr), where r is the subgroup order
Source§

fn bls12_381_fr_pow( &self, lhs: U256Val, rhs: U64Val, ) -> Result<U256Val, <T as EnvBase>::Error>

performs exponentiation of a BLS12-381 scalar element (Fr) with a u64 exponent i.e. lhs.exp(rhs) mod r, where r is the subgroup order
Source§

fn bls12_381_fr_inv( &self, lhs: U256Val, ) -> Result<U256Val, <T as EnvBase>::Error>

performs inversion of a BLS12-381 scalar element (Fr) modulo r (the subgroup order)
Source§

fn require_auth_for_args( &self, address: AddressObject, args: VecObject, ) -> Result<Void, <T as EnvBase>::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, address: AddressObject, ) -> Result<Void, <T as EnvBase>::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 strkey_to_address( &self, strkey: Val, ) -> Result<AddressObject, <T as EnvBase>::Error>

Converts a provided Stellar strkey address of an account or a contract (‘G…’ or ‘C…’ respectively) to an address object. strkey can be either BytesObject or StringObject (the contents should represent the G.../C... string in both cases). Any other valid or invalid strkey (e.g. ‘S…’) will trigger an error. Prefer directly using the Address objects whenever possible. This is only useful in the context of custom messaging protocols (e.g. cross-chain).
Source§

fn address_to_strkey( &self, address: AddressObject, ) -> Result<StringObject, <T as EnvBase>::Error>

Converts a provided address to Stellar strkey format (‘G…’ for account or ‘C…’ for contract). Prefer directly using the Address objects whenever possible. This is only useful in the context of custom messaging protocols (e.g. cross-chain).
Source§

fn authorize_as_curr_contract( &self, auth_entires: VecObject, ) -> Result<Void, <T as EnvBase>::Error>

Authorizes sub-contract calls for the next contract call on behalf of the current contract. Every entry in the argument vector corresponds to InvokerContractAuthEntry contract type that authorizes a tree of require_auth calls on behalf of the current contract. The entries must not contain any authorizations for the direct contract call, i.e. if current contract needs to call contract function F1 that calls function F2 both of which require auth, only F2 should be present in auth_entries.
Source§

fn dummy0(&self) -> Result<Val, <T as EnvBase>::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.
Source§

fn protocol_gated_dummy(&self) -> Result<Val, <T as EnvBase>::Error>

A dummy function for testing the protocol gating. Takes 0 arguments and performs no-op. Essentially this function is always protocol-gated out since it has min_supported_protocol == max_supported_protocol == 19, thus having no effect on any protocol (Soroban starts at protocol 20). This is required for testing the scenario where ledger protocol version > host function max supported version, and the ledger protocol version must be <= the env version (which starts at 20, and is a compile-time, non-overridable constant).
Source§

fn prng_reseed(&self, seed: BytesObject) -> Result<Void, <T as EnvBase>::Error>

Reseed the frame-local PRNG with a given BytesObject, which should be 32 bytes long.
Source§

fn prng_bytes_new( &self, length: U32Val, ) -> Result<BytesObject, <T as EnvBase>::Error>

Construct a new BytesObject of the given length filled with bytes drawn from the frame-local PRNG.
Source§

fn prng_u64_in_inclusive_range( &self, lo: u64, hi: u64, ) -> Result<u64, <T as EnvBase>::Error>

Return a u64 uniformly sampled from the inclusive range [lo,hi] by the frame-local PRNG.
Source§

fn prng_vec_shuffle( &self, vec: VecObject, ) -> Result<VecObject, <T as EnvBase>::Error>

Return a (Fisher-Yates) shuffled clone of a given vector, using the frame-local PRNG.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<E, T, U> TryIntoVal<E, T> for U
where E: Env, T: TryFromVal<E, U>,

Source§

type Error = <T as TryFromVal<E, U>>::Error

Source§

fn try_into_val(&self, env: &E) -> Result<T, <U as TryIntoVal<E, T>>::Error>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V