HostContext

Trait HostContext 

Source
pub trait HostContext {
Show 27 methods // Required methods fn set_caller(&self, caller: Address); fn set_gas(&self, gas: u64); fn caller(&self) -> Address; fn get_account(&self, index: usize) -> Address; fn get_validator(&self, index: usize) -> PublicKey; fn remove_validator(&self, index: usize); fn balance_of(&self, address: &Address) -> U512; fn advance_block_time(&self, time_diff: u64); fn advance_with_auctions(&self, time_diff: u64); fn auction_delay(&self) -> u64; fn unbonding_delay(&self) -> u64; fn delegated_amount(&self, delegator: Address, validator: PublicKey) -> U512; fn block_time(&self) -> u64; fn get_event( &self, contract_address: &Address, index: u32, ) -> Result<Bytes, EventError>; fn get_native_event( &self, contract_address: &Address, index: u32, ) -> Result<Bytes, EventError>; fn get_events_count( &self, contract_address: &Address, ) -> Result<u32, EventError>; fn get_native_events_count( &self, contract_address: &Address, ) -> Result<u32, EventError>; fn call_contract( &self, address: &Address, call_def: CallDef, use_proxy: bool, ) -> OdraResult<Bytes>; fn new_contract( &self, name: &str, init_args: RuntimeArgs, entry_points_caller: EntryPointsCaller, ) -> OdraResult<Address>; fn upgrade_contract( &self, name: &str, contract_to_upgrade: Address, upgrade_args: RuntimeArgs, entry_points_caller: EntryPointsCaller, ) -> OdraResult<Address>; fn register_contract( &self, address: Address, contract_name: String, entry_points_caller: EntryPointsCaller, ); fn contract_env(&self) -> ContractEnv; fn gas_report(&self) -> GasReport; fn last_call_gas_cost(&self) -> u64; fn sign_message(&self, message: &Bytes, address: &Address) -> Bytes; fn public_key(&self, address: &Address) -> PublicKey; fn transfer(&self, to: Address, amount: U512) -> OdraResult<()>;
}
Expand description

The HostContext trait defines the interface for interacting with the host environment.

Required Methods§

Source

fn set_caller(&self, caller: Address)

Sets the caller address for the current contract execution.

Source

fn set_gas(&self, gas: u64)

Sets the gas limit for the current contract execution.

Source

fn caller(&self) -> Address

Returns the caller address for the current contract execution.

Source

fn get_account(&self, index: usize) -> Address

Returns the account address at the specified index.

Source

fn get_validator(&self, index: usize) -> PublicKey

Returns the validator public key.

Source

fn remove_validator(&self, index: usize)

The validator at the given index will withdraw all funds and be removed from the validator set.

Source

fn balance_of(&self, address: &Address) -> U512

Returns the CSPR balance of the specified address.

Source

fn advance_block_time(&self, time_diff: u64)

Advances the block time by the specified time difference.

Source

fn advance_with_auctions(&self, time_diff: u64)

Advances the block time by the specified time difference and processes auctions.

Source

fn auction_delay(&self) -> u64

Time between auctions in milliseconds.

Source

fn unbonding_delay(&self) -> u64

Time for the funds to be transferred back to the delegator after undelegation in milliseconds.

Source

fn delegated_amount(&self, delegator: Address, validator: PublicKey) -> U512

Returns the delegated amount for the specified delegator and validator.

Source

fn block_time(&self) -> u64

Returns the current block time.

Source

fn get_event( &self, contract_address: &Address, index: u32, ) -> Result<Bytes, EventError>

Returns the event bytes for the specified contract address and index.

Source

fn get_native_event( &self, contract_address: &Address, index: u32, ) -> Result<Bytes, EventError>

Returns the native event bytes for the specified contract address and index.

Source

fn get_events_count( &self, contract_address: &Address, ) -> Result<u32, EventError>

Returns the number of emitted events for the specified contract address.

Source

fn get_native_events_count( &self, contract_address: &Address, ) -> Result<u32, EventError>

Returns the number of emitted native events for the specified contract address.

Source

fn call_contract( &self, address: &Address, call_def: CallDef, use_proxy: bool, ) -> OdraResult<Bytes>

Calls a contract at the specified address with the given call definition.

Source

fn new_contract( &self, name: &str, init_args: RuntimeArgs, entry_points_caller: EntryPointsCaller, ) -> OdraResult<Address>

Creates a new contract with the specified name, initialization arguments, and entry points caller.

Source

fn upgrade_contract( &self, name: &str, contract_to_upgrade: Address, upgrade_args: RuntimeArgs, entry_points_caller: EntryPointsCaller, ) -> OdraResult<Address>

Upgrades an existing contract with a new one with given upgrade arguments and new entry points caller.

Source

fn register_contract( &self, address: Address, contract_name: String, entry_points_caller: EntryPointsCaller, )

Registers an existing contract with the specified address, name, and entry points caller.

Source

fn contract_env(&self) -> ContractEnv

Returns the contract environment.

Source

fn gas_report(&self) -> GasReport

Returns the gas report for the current contract execution.

Source

fn last_call_gas_cost(&self) -> u64

Returns the gas cost of the last contract call.

Source

fn sign_message(&self, message: &Bytes, address: &Address) -> Bytes

Signs the specified message with the given address and returns the signature.

Source

fn public_key(&self, address: &Address) -> PublicKey

Returns the public key associated with the specified address.

Source

fn transfer(&self, to: Address, amount: U512) -> OdraResult<()>

Transfers the specified amount of CSPR from the current caller to the specified address.

Implementors§