Trait ContractBinaryInterface

Source
pub trait ContractBinaryInterface<T>
where T: WasmerEnv + 'static,
{
Show 28 methods // Required methods fn set( env: &T, key_ptr: u32, key_len: u32, value_ptr: u32, value_len: u32, ) -> Result<(), FuncError>; fn get( env: &T, key_ptr: u32, key_len: u32, value_ptr_ptr: u32, ) -> Result<i64, FuncError>; fn get_network_storage( env: &T, key_ptr: u32, key_len: u32, value_ptr_ptr: u32, ) -> Result<i64, FuncError>; fn balance(env: &T) -> Result<u64, FuncError>; fn block_height(env: &T) -> Result<u64, FuncError>; fn block_timestamp(env: &T) -> Result<u32, FuncError>; fn prev_block_hash(env: &T, hash_ptr_ptr: u32) -> Result<(), FuncError>; fn calling_account(env: &T, address_ptr_ptr: u32) -> Result<(), FuncError>; fn current_account(env: &T, address_ptr_ptr: u32) -> Result<(), FuncError>; fn method(env: &T, method_ptr_ptr: u32) -> Result<u32, FuncError>; fn arguments(env: &T, arguments_ptr_ptr: u32) -> Result<u32, FuncError>; fn amount(env: &T) -> Result<u64, FuncError>; fn is_internal_call(env: &T) -> Result<i32, FuncError>; fn transaction_hash(env: &T, hash_ptr_ptr: u32) -> Result<(), FuncError>; fn call( env: &T, call_input_ptr: u32, call_input_len: u32, rval_ptr_ptr: u32, ) -> Result<u32, FuncError>; fn return_value( env: &T, value_ptr: u32, value_len: u32, ) -> Result<(), FuncError>; fn transfer(env: &T, transfer_input_ptr: u32) -> Result<(), FuncError>; fn defer_create_deposit( env: &T, create_deposit_input_ptr: u32, create_deposit_input_len: u32, ) -> Result<(), FuncError>; fn defer_set_deposit_settings( env: &T, set_deposit_settings_input_ptr: u32, set_deposit_settings_input_len: u32, ) -> Result<(), FuncError>; fn defer_topup_deposit( env: &T, top_up_deposit_input_ptr: u32, top_up_deposit_input_len: u32, ) -> Result<(), FuncError>; fn defer_withdraw_deposit( env: &T, withdraw_deposit_input_ptr: u32, withdraw_deposit_input_len: u32, ) -> Result<(), FuncError>; fn defer_stake_deposit( env: &T, stake_deposit_input_ptr: u32, stake_deposit_input_len: u32, ) -> Result<(), FuncError>; fn defer_unstake_deposit( env: &T, unstake_deposit_input_ptr: u32, unstake_deposit_input_len: u32, ) -> Result<(), FuncError>; fn log(env: &T, log_ptr: u32, log_len: u32) -> Result<(), FuncError>; fn sha256( env: &T, msg_ptr: u32, msg_len: u32, digest_ptr_ptr: u32, ) -> Result<(), FuncError>; fn keccak256( env: &T, msg_ptr: u32, msg_len: u32, digest_ptr_ptr: u32, ) -> Result<(), FuncError>; fn ripemd( env: &T, msg_ptr: u32, msg_len: u32, digest_ptr_ptr: u32, ) -> Result<(), FuncError>; fn verify_ed25519_signature( env: &T, msg_ptr: u32, msg_len: u32, signature_ptr: u32, address_ptr: u32, ) -> Result<i32, FuncError>;
}
Expand description

Definition of host functions with wasmer::WasmerEnv. Implement this trait for creation of importable that can be used in instantiation of contract module.

Host function arguments with suffix _ptr_ptr are namely pointer-to-pointer variable that is considered as mutable reference to memory as an output value. Method wasmer_memory::MemoryContext::set_return_values_to_memory can be used to set output value into this variable.

Host functions arguments with suffix _ptr are namely pointer-to variable that is considers as immutable reference to memory as an input value. Method wasmer_memory::MemoryContext::read_bytes can be used to read the value from this variable.

Required Methods§

Source

fn set( env: &T, key_ptr: u32, key_len: u32, value_ptr: u32, value_len: u32, ) -> Result<(), FuncError>

Sets a key to a value in the current Contract Account’s Storage.

Source

fn get( env: &T, key_ptr: u32, key_len: u32, value_ptr_ptr: u32, ) -> Result<i64, FuncError>

Gets the value corresponding to a key in the current Contract Account’s Storage. It returns the length of the value.

Source

fn get_network_storage( env: &T, key_ptr: u32, key_len: u32, value_ptr_ptr: u32, ) -> Result<i64, FuncError>

Gets the value corresponding to a key in the Network Account’s Storage. It returns the length of the value.

Source

fn balance(env: &T) -> Result<u64, FuncError>

Get the balance of current account

Source

fn block_height(env: &T) -> Result<u64, FuncError>

Gets the Height of the Block which the Transaction at the start of the current Call Chain is included in.

Source

fn block_timestamp(env: &T) -> Result<u32, FuncError>

Gets the Timestamp of the Block which the Transaction at the start of the current Call Chain is included in.

Source

fn prev_block_hash(env: &T, hash_ptr_ptr: u32) -> Result<(), FuncError>

Get the Hash field of the previous Block.

  • hash_ptr_ptr points to memory of 32 bytes address.
Source

fn calling_account(env: &T, address_ptr_ptr: u32) -> Result<(), FuncError>

Gets the Address of the Account that triggered the current Call. This could either be an External Account (if the Call is directly triggered by a Call Transaction), or a Contract Account (if the Call is an Internal Call).

  • address_ptr_ptr points to memory of 32 bytes address.
  • returns the length of the value.
Source

fn current_account(env: &T, address_ptr_ptr: u32) -> Result<(), FuncError>

Gets the Address of the current Account.

  • address_ptr_ptr points to memory of 32 bytes address.
  • returns the length of the value.
Source

fn method(env: &T, method_ptr_ptr: u32) -> Result<u32, FuncError>

Gets the Method of the current Call.

  • method_ptr_ptr points to memory of bytes.
  • returns the length of the value.
Source

fn arguments(env: &T, arguments_ptr_ptr: u32) -> Result<u32, FuncError>

Gets the Arguments of the current Call.

  • arguments_ptr_ptr points to memory of bytes.
  • returns the length of the value.
Source

fn amount(env: &T) -> Result<u64, FuncError>

get transaction value of this transaction.

  • returns the amount.
Source

fn is_internal_call(env: &T) -> Result<i32, FuncError>

Returns whether the current Call is an Internal Call.

Source

fn transaction_hash(env: &T, hash_ptr_ptr: u32) -> Result<(), FuncError>

get transaction hash of this transaction. -hash_ptr_ptr points to memory of 32 bytes data.

Source

fn call( env: &T, call_input_ptr: u32, call_input_len: u32, rval_ptr_ptr: u32, ) -> Result<u32, FuncError>

call methods of another contract.

Source

fn return_value( env: &T, value_ptr: u32, value_len: u32, ) -> Result<(), FuncError>

Set return value of contract execution, which is also a field in resulting receipt.

  • value_ptr points to memory of bytes of arbitary input.
Source

fn transfer(env: &T, transfer_input_ptr: u32) -> Result<(), FuncError>

Transfers the specified number of Grays to a specified Address

  • transfer_input_ptr points to memory of 40 bytes address: 32-byte address and 8-byte little endian integer.
Source

fn defer_create_deposit( env: &T, create_deposit_input_ptr: u32, create_deposit_input_len: u32, ) -> Result<(), FuncError>

Insert command execution after success of this contract call.

Source

fn defer_set_deposit_settings( env: &T, set_deposit_settings_input_ptr: u32, set_deposit_settings_input_len: u32, ) -> Result<(), FuncError>

Insert command execution after success of this contract call.

Source

fn defer_topup_deposit( env: &T, top_up_deposit_input_ptr: u32, top_up_deposit_input_len: u32, ) -> Result<(), FuncError>

Insert command execution after success of this contract call.

Source

fn defer_withdraw_deposit( env: &T, withdraw_deposit_input_ptr: u32, withdraw_deposit_input_len: u32, ) -> Result<(), FuncError>

Insert command execution after success of this contract call.

Source

fn defer_stake_deposit( env: &T, stake_deposit_input_ptr: u32, stake_deposit_input_len: u32, ) -> Result<(), FuncError>

Insert command execution after success of this contract call.

Source

fn defer_unstake_deposit( env: &T, unstake_deposit_input_ptr: u32, unstake_deposit_input_len: u32, ) -> Result<(), FuncError>

Insert command execution after success of this contract call.

Source

fn log(env: &T, log_ptr: u32, log_len: u32) -> Result<(), FuncError>

Add a log to the Transaction’s Receipt.

Source

fn sha256( env: &T, msg_ptr: u32, msg_len: u32, digest_ptr_ptr: u32, ) -> Result<(), FuncError>

Computes the SHA256 digest of arbitrary input.

  • returns 32 bytes digest.
Source

fn keccak256( env: &T, msg_ptr: u32, msg_len: u32, digest_ptr_ptr: u32, ) -> Result<(), FuncError>

Computes the Keccak256 digest of arbitrary input.

  • returns 32 bytes digest.
Source

fn ripemd( env: &T, msg_ptr: u32, msg_len: u32, digest_ptr_ptr: u32, ) -> Result<(), FuncError>

Computes the RIPEMD160 digest of arbitrary input.

  • returns 20 bytes digest.
Source

fn verify_ed25519_signature( env: &T, msg_ptr: u32, msg_len: u32, signature_ptr: u32, address_ptr: u32, ) -> Result<i32, FuncError>

Returns whether an Ed25519 signature was produced by a specified by a specified address over some specified message.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§