Struct dharitri_wasm_node::ArwenApiImpl
source · pub struct ArwenApiImpl {}Expand description
The reference to the API implementation based on Arwen hooks. It continas no data, can be embedded at no cost. Cloning it is a no-op.
Trait Implementations§
source§impl CallValueApi<ArwenBigUint> for ArwenApiImpl
impl CallValueApi<ArwenBigUint> for ArwenApiImpl
fn check_not_payable(&self)
source§fn moax_value(&self) -> ArwenBigUint
fn moax_value(&self) -> ArwenBigUint
Retrieves the MOAX call value from the VM.
Will return 0 in case of an DCT transfer (cannot have both MOAX and DCT transfer simultaneously).
source§fn dct_value(&self) -> ArwenBigUint
fn dct_value(&self) -> ArwenBigUint
Retrieves the DCT call value from the VM.
Will return 0 in case of an MOAX transfer (cannot have both MOAX and DCT transfer simultaneously).
source§fn token(&self) -> TokenIdentifier
fn token(&self) -> TokenIdentifier
Returns the call value token identifier of the current call.
The identifier is wrapped in a TokenIdentifier object, to hide underlying logic. Read more
source§fn dct_token_nonce(&self) -> u64
fn dct_token_nonce(&self) -> u64
Returns the nonce of the received DCT token.
Will return 0 in case of MOAX or fungible DCT transfer.
source§fn dct_token_type(&self) -> DctTokenType
fn dct_token_type(&self) -> DctTokenType
Returns the DCT token type.
Will return “Fungible” for MOAX.
source§fn require_moax(&self) -> BigUint
fn require_moax(&self) -> BigUint
Will return the MOAX call value,
but also fail with an error if DCT is sent.
Especially used in the auto-generated call value processing.
source§fn require_dct(&self, token: &[u8]) -> BigUint
fn require_dct(&self, token: &[u8]) -> BigUint
Will return the DCT call value,
but also fail with an error if MOAX or the wrong DCT token is sent.
Especially used in the auto-generated call value processing.
source§fn payment_token_pair(&self) -> (BigUint, TokenIdentifier)
fn payment_token_pair(&self) -> (BigUint, TokenIdentifier)
Returns both the call value (either MOAX or DCT) and the token identifier.
Especially used in the `#[payable(“*”)] auto-generated snippets.
The method might seem redundant, but there is such a hook in Arwen
that might be used in this scenario in the future.
source§impl Clone for ArwenApiImpl
impl Clone for ArwenApiImpl
Should be no-op. The API implementation is zero-sized.
source§impl ContractHookApi<ArwenBigInt, ArwenBigUint> for ArwenApiImpl
impl ContractHookApi<ArwenBigInt, ArwenBigUint> for ArwenApiImpl
§type Storage = ArwenApiImpl
type Storage = ArwenApiImpl
Abstracts the lower-level storage functionality.
§type CallValue = ArwenApiImpl
type CallValue = ArwenApiImpl
Abstracts the call value handling at the beginning of a function call.
§type SendApi = ArwenApiImpl
type SendApi = ArwenApiImpl
Abstracts the sending of MOAX & DCT transactions, as well as async calls.
source§fn get_storage_raw(&self) -> Self::Storage
fn get_storage_raw(&self) -> Self::Storage
Gateway into the lower-level storage functionality.
Storage related annotations make use of this.
Using it directly is not recommended.
source§fn call_value(&self) -> Self::CallValue
fn call_value(&self) -> Self::CallValue
Gateway into the call value retrieval functionality.
The payment annotations should normally be the ones to handle this,
but the developer is also given direct access to the API.
source§fn send(&self) -> Self::SendApi
fn send(&self) -> Self::SendApi
Gateway to the functionality related to sending transactions from the current contract.
fn get_sc_address(&self) -> Address
fn get_owner_address(&self) -> Address
fn get_shard_of_address(&self, address: &Address) -> u32
fn is_smart_contract(&self, address: &Address) -> bool
fn get_caller(&self) -> Address
fn get_balance(&self, address: &Address) -> ArwenBigUint
fn get_tx_hash(&self) -> H256
fn get_gas_left(&self) -> u64
fn get_block_timestamp(&self) -> u64
fn get_block_nonce(&self) -> u64
fn get_block_round(&self) -> u64
fn get_block_epoch(&self) -> u64
fn get_block_random_seed(&self) -> Box<[u8; 48]>
fn get_prev_block_timestamp(&self) -> u64
fn get_prev_block_nonce(&self) -> u64
fn get_prev_block_round(&self) -> u64
fn get_prev_block_epoch(&self) -> u64
fn get_prev_block_random_seed(&self) -> Box<[u8; 48]>
fn get_current_dct_nft_nonce(&self, address: &Address, token: &[u8]) -> u64
fn get_dct_balance( &self, address: &Address, token: &[u8], nonce: u64 ) -> ArwenBigUint
fn get_dct_token_data( &self, address: &Address, token: &[u8], nonce: u64 ) -> DctTokenData<ArwenBigUint>
fn get_sc_balance(&self) -> BigUint
fn storage_load_cumulated_validator_reward(&self) -> BigUint
source§impl CryptoApi for ArwenApiImpl
impl CryptoApi for ArwenApiImpl
source§impl EndpointArgumentApi for ArwenApiImpl
impl EndpointArgumentApi for ArwenApiImpl
Interface to only be used by code generated by the macros. The smart contract code doesn’t have access to these methods directly.
fn get_num_arguments(&self) -> i32
fn get_argument_len(&self, arg_index: i32) -> usize
fn copy_argument_to_slice(&self, arg_index: i32, slice: &mut [u8])
fn get_argument_vec_u8(&self, arg_index: i32) -> Vec<u8>
fn get_argument_boxed_bytes(&self, arg_index: i32) -> BoxedBytes
fn get_argument_big_uint_raw(&self, arg_id: i32) -> i32
fn get_argument_big_int_raw(&self, arg_id: i32) -> i32
fn get_argument_u64(&self, arg_id: i32) -> u64
fn get_argument_i64(&self, arg_id: i32) -> i64
fn check_num_arguments(&self, expected: i32)
source§impl EndpointFinishApi for ArwenApiImpl
impl EndpointFinishApi for ArwenApiImpl
Interface to only be used by code generated by the macros. The smart contract code doesn’t have access to these methods directly.
fn finish_slice_u8(&self, slice: &[u8])
fn finish_big_int_raw(&self, handle: i32)
fn finish_big_uint_raw(&self, handle: i32)
fn finish_u64(&self, value: u64)
fn finish_i64(&self, value: i64)
source§impl ErrorApi for ArwenApiImpl
impl ErrorApi for ArwenApiImpl
fn signal_error(&self, message: &[u8]) -> !
source§impl LogApi for ArwenApiImpl
impl LogApi for ArwenApiImpl
Interface to only be used by code generated by the macros. The smart contract code doesn’t have access to these methods directly.
source§impl SendApi<ArwenBigUint> for ArwenApiImpl
impl SendApi<ArwenBigUint> for ArwenApiImpl
source§fn direct_moax(&self, to: &Address, amount: &ArwenBigUint, data: &[u8])
fn direct_moax(&self, to: &Address, amount: &ArwenBigUint, data: &[u8])
Sends MOAX to a given address, directly.
Used especially for sending MOAX to regular accounts.
source§fn direct_moax_execute(
&self,
to: &Address,
amount: &ArwenBigUint,
gas_limit: u64,
function: &[u8],
arg_buffer: &ArgBuffer
)
fn direct_moax_execute( &self, to: &Address, amount: &ArwenBigUint, gas_limit: u64, function: &[u8], arg_buffer: &ArgBuffer )
Sends MOAX to an address (optionally) and executes like an async call, but without callback.
source§fn direct_dct_execute(
&self,
to: &Address,
token: &[u8],
amount: &ArwenBigUint,
gas_limit: u64,
function: &[u8],
arg_buffer: &ArgBuffer
)
fn direct_dct_execute( &self, to: &Address, token: &[u8], amount: &ArwenBigUint, gas_limit: u64, function: &[u8], arg_buffer: &ArgBuffer )
Sends DCT to an address and executes like an async call, but without callback.
source§fn direct_dct_nft_execute(
&self,
to: &Address,
token: &[u8],
nonce: u64,
amount: &ArwenBigUint,
gas_limit: u64,
function: &[u8],
arg_buffer: &ArgBuffer
)
fn direct_dct_nft_execute( &self, to: &Address, token: &[u8], nonce: u64, amount: &ArwenBigUint, gas_limit: u64, function: &[u8], arg_buffer: &ArgBuffer )
Sends DCT NFT to an address and executes like an async call, but without callback.
source§fn async_call_raw(&self, to: &Address, amount: &ArwenBigUint, data: &[u8]) -> !
fn async_call_raw(&self, to: &Address, amount: &ArwenBigUint, data: &[u8]) -> !
Sends an asynchronous call to another contract.
Calling this method immediately terminates tx execution.
Using it directly is generally discouraged. Read more
source§fn deploy_contract(
&self,
gas: u64,
amount: &ArwenBigUint,
code: &BoxedBytes,
code_metadata: CodeMetadata,
arg_buffer: &ArgBuffer
) -> Address
fn deploy_contract( &self, gas: u64, amount: &ArwenBigUint, code: &BoxedBytes, code_metadata: CodeMetadata, arg_buffer: &ArgBuffer ) -> Address
Deploys a new contract in the same shard.
Unlike
async_call_raw, the deployment is synchronous and tx execution continues afterwards.
Also unlike async_call_raw, it uses an argument buffer to pass argumentsfn execute_on_dest_context_raw( &self, gas: u64, address: &Address, amount: &ArwenBigUint, function: &[u8], arg_buffer: &ArgBuffer ) -> Vec<BoxedBytes>
fn execute_on_dest_context_by_caller_raw( &self, gas: u64, address: &Address, amount: &ArwenBigUint, function: &[u8], arg_buffer: &ArgBuffer ) -> Vec<BoxedBytes>
fn execute_on_same_context_raw( &self, gas: u64, address: &Address, amount: &ArwenBigUint, function: &[u8], arg_buffer: &ArgBuffer )
source§fn storage_store_tx_hash_key(&self, data: &[u8])
fn storage_store_tx_hash_key(&self, data: &[u8])
Used to store data between async call and callback.
source§fn storage_load_tx_hash_key(&self) -> BoxedBytes
fn storage_load_tx_hash_key(&self) -> BoxedBytes
Used to store data between async call and callback.
source§fn call_local_dct_built_in_function(
&self,
gas: u64,
function: &[u8],
arg_buffer: &ArgBuffer
)
fn call_local_dct_built_in_function( &self, gas: u64, function: &[u8], arg_buffer: &ArgBuffer )
Allows synchronously calling a local function by name. Execution is resumed afterwards.
You should never have to call this function directly.
Use the other specific methods instead.
source§fn direct_dct_via_transf_exec(
&self,
to: &Address,
token: &[u8],
amount: &BigUint,
data: &[u8]
)
fn direct_dct_via_transf_exec( &self, to: &Address, token: &[u8], amount: &BigUint, data: &[u8] )
Sends an DCT token to a given address, directly.
Used especially for sending DCT to regular accounts. Read more
source§fn direct(
&self,
to: &Address,
token: &TokenIdentifier,
amount: &BigUint,
data: &[u8]
)
fn direct( &self, to: &Address, token: &TokenIdentifier, amount: &BigUint, data: &[u8] )
Sends either MOAX or an DCT token to the target address,
depending on what token identifier was specified.
source§fn direct_dct_via_async_call(
&self,
to: &Address,
dct_token_name: &[u8],
amount: &BigUint,
data: &[u8]
) -> !
fn direct_dct_via_async_call( &self, to: &Address, dct_token_name: &[u8], amount: &BigUint, data: &[u8] ) -> !
Performs a simple DCT transfer, but via async call.
This is the preferred way to send DCT.
source§fn direct_via_async_call(
&self,
to: &Address,
token: &TokenIdentifier,
amount: &BigUint,
data: &[u8]
)
fn direct_via_async_call( &self, to: &Address, token: &TokenIdentifier, amount: &BigUint, data: &[u8] )
Sends either MOAX or an DCT token to the target address,
depending on what token identifier was specified.
In case of DCT it performs an async call.
source§fn async_call(&self, async_call: AsyncCall<BigUint>) -> !
fn async_call(&self, async_call: AsyncCall<BigUint>) -> !
Sends an asynchronous call to another contract, with either MOAX or DCT value.
The
token argument decides which one it will be.
Calling this method immediately terminates tx execution.source§fn dct_local_mint(&self, gas: u64, token: &[u8], amount: &BigUint)
fn dct_local_mint(&self, gas: u64, token: &[u8], amount: &BigUint)
Allows synchronous minting of DCT tokens. Execution is resumed afterwards.
source§fn dct_local_burn(&self, gas: u64, token: &[u8], amount: &BigUint)
fn dct_local_burn(&self, gas: u64, token: &[u8], amount: &BigUint)
Allows synchronous burning of DCT tokens. Execution is resumed afterwards.
source§fn dct_nft_create<T>(
&self,
gas: u64,
token: &[u8],
amount: &BigUint,
name: &BoxedBytes,
royalties: &BigUint,
hash: &H256,
attributes: &T,
uris: &[BoxedBytes]
)where
T: TopEncode,
fn dct_nft_create<T>(
&self,
gas: u64,
token: &[u8],
amount: &BigUint,
name: &BoxedBytes,
royalties: &BigUint,
hash: &H256,
attributes: &T,
uris: &[BoxedBytes]
)where
T: TopEncode,
Creates a new NFT token of a certain type (determined by
This is a built-in function, so the smart contract execution is resumed after.
token_identifier).attributes can be any serializable custom struct.This is a built-in function, so the smart contract execution is resumed after.
source§fn dct_nft_add_quantity(
&self,
gas: u64,
token: &[u8],
nonce: u64,
amount: &BigUint
)
fn dct_nft_add_quantity( &self, gas: u64, token: &[u8], nonce: u64, amount: &BigUint )
Adds quantity for an Non-Fungible Token. (which makes it a Semi-Fungible Token by definition)
This is a built-in function, so the smart contract execution is resumed after.
This is a built-in function, so the smart contract execution is resumed after.
source§fn dct_nft_burn(&self, gas: u64, token: &[u8], nonce: u64, amount: &BigUint)
fn dct_nft_burn(&self, gas: u64, token: &[u8], nonce: u64, amount: &BigUint)
The reverse operation of
dct_nft_add_quantity, this locally decreases
This is a built-in function, so the smart contract execution is resumed after.source§fn direct_dct_nft_via_async_call(
&self,
from: &Address,
to: &Address,
token: &[u8],
nonce: u64,
amount: &BigUint,
data: &[u8]
)
fn direct_dct_nft_via_async_call( &self, from: &Address, to: &Address, token: &[u8], nonce: u64, amount: &BigUint, data: &[u8] )
Performs a simple DCT NFT transfer, but via async call.
This is the preferred way to send DCT.
Note: call is done to the SC itself, so
from should be the SCs own addresssource§impl StorageReadApi for ArwenApiImpl
impl StorageReadApi for ArwenApiImpl
fn storage_load_len(&self, key: &[u8]) -> usize
fn storage_load_vec_u8(&self, key: &[u8]) -> Vec<u8>
fn storage_load_boxed_bytes(&self, key: &[u8]) -> BoxedBytes
fn storage_load_big_uint_raw(&self, key: &[u8]) -> i32
fn storage_load_u64(&self, key: &[u8]) -> u64
fn storage_load_i64(&self, key: &[u8]) -> i64
source§impl StorageWriteApi for ArwenApiImpl
impl StorageWriteApi for ArwenApiImpl
fn storage_store_slice_u8(&self, key: &[u8], value: &[u8])
fn storage_store_big_uint_raw(&self, key: &[u8], handle: i32)
fn storage_store_u64(&self, key: &[u8], value: u64)
fn storage_store_i64(&self, key: &[u8], value: i64)
Auto Trait Implementations§
impl RefUnwindSafe for ArwenApiImpl
impl Send for ArwenApiImpl
impl Sync for ArwenApiImpl
impl Unpin for ArwenApiImpl
impl UnwindSafe for ArwenApiImpl
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more