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

source§

fn check_not_payable(&self)

source§

fn moa_value(&self) -> ArwenBigUint

Retrieves the MOA call value from the VM. Will return 0 in case of an DCT transfer (cannot have both MOA and DCT transfer simultaneously).
source§

fn dct_value(&self) -> ArwenBigUint

Retrieves the DCT call value from the VM. Will return 0 in case of an MOA transfer (cannot have both MOA and DCT transfer simultaneously).
source§

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

Returns the nonce of the received DCT token. Will return 0 in case of MOA or fungible DCT transfer.
source§

fn dct_token_type(&self) -> DctTokenType

Returns the DCT token type. Will return “Fungible” for MOA.
source§

fn require_moa(&self) -> BigUint

Will return the MOA 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

Will return the DCT call value, but also fail with an error if MOA or the wrong DCT token is sent. Especially used in the auto-generated call value processing.
source§

fn payment_token_pair(&self) -> (BigUint, TokenIdentifier)

Returns both the call value (either MOA 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

Should be no-op. The API implementation is zero-sized.

source§

fn clone(&self) -> Self

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 ContractHookApi<ArwenBigInt, ArwenBigUint> for ArwenApiImpl

§

type Storage = ArwenApiImpl

Abstracts the lower-level storage functionality.
§

type CallValue = ArwenApiImpl

Abstracts the call value handling at the beginning of a function call.
§

type SendApi = ArwenApiImpl

Abstracts the sending of MOA & DCT transactions, as well as async calls.
source§

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

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

Gateway to the functionality related to sending transactions from the current contract.
source§

fn get_sc_address(&self) -> Address

source§

fn get_owner_address(&self) -> Address

source§

fn get_shard_of_address(&self, address: &Address) -> u32

source§

fn is_smart_contract(&self, address: &Address) -> bool

source§

fn get_caller(&self) -> Address

source§

fn get_balance(&self, address: &Address) -> ArwenBigUint

source§

fn get_tx_hash(&self) -> H256

source§

fn get_gas_left(&self) -> u64

source§

fn get_block_timestamp(&self) -> u64

source§

fn get_block_nonce(&self) -> u64

source§

fn get_block_round(&self) -> u64

source§

fn get_block_epoch(&self) -> u64

source§

fn get_block_random_seed(&self) -> Box<[u8; 48]>

source§

fn get_prev_block_timestamp(&self) -> u64

source§

fn get_prev_block_nonce(&self) -> u64

source§

fn get_prev_block_round(&self) -> u64

source§

fn get_prev_block_epoch(&self) -> u64

source§

fn get_prev_block_random_seed(&self) -> Box<[u8; 48]>

source§

fn get_current_dct_nft_nonce(&self, address: &Address, token: &[u8]) -> u64

source§

fn get_dct_balance( &self, address: &Address, token: &[u8], nonce: u64 ) -> ArwenBigUint

source§

fn get_dct_token_data( &self, address: &Address, token: &[u8], nonce: u64 ) -> DctTokenData<ArwenBigUint>

source§

fn get_sc_balance(&self) -> BigUint

source§

fn storage_load_cumulated_validator_reward(&self) -> BigUint

source§

impl CryptoApi for ArwenApiImpl

source§

fn sha256(&self, data: &[u8]) -> H256

source§

fn keccak256(&self, data: &[u8]) -> H256

source§

fn verify_bls(&self, key: &[u8], message: &[u8], signature: &[u8]) -> bool

source§

fn verify_ed25519(&self, key: &[u8], message: &[u8], signature: &[u8]) -> bool

source§

fn verify_secp256k1(&self, key: &[u8], message: &[u8], signature: &[u8]) -> bool

Note: the signature is minimum 2 bytes in length, the second byte encodes the length of the remaining signature bytes.
source§

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.

source§

fn get_num_arguments(&self) -> i32

source§

fn get_argument_len(&self, arg_index: i32) -> usize

source§

fn copy_argument_to_slice(&self, arg_index: i32, slice: &mut [u8])

source§

fn get_argument_vec_u8(&self, arg_index: i32) -> Vec<u8>

source§

fn get_argument_boxed_bytes(&self, arg_index: i32) -> BoxedBytes

source§

fn get_argument_big_uint_raw(&self, arg_id: i32) -> i32

source§

fn get_argument_big_int_raw(&self, arg_id: i32) -> i32

source§

fn get_argument_u64(&self, arg_id: i32) -> u64

source§

fn get_argument_i64(&self, arg_id: i32) -> i64

source§

fn check_num_arguments(&self, expected: i32)

source§

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.

source§

fn finish_slice_u8(&self, slice: &[u8])

source§

fn finish_big_int_raw(&self, handle: i32)

source§

fn finish_big_uint_raw(&self, handle: i32)

source§

fn finish_u64(&self, value: u64)

source§

fn finish_i64(&self, value: i64)

source§

impl ErrorApi for ArwenApiImpl

source§

fn signal_error(&self, message: &[u8]) -> !

source§

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§

fn write_event_log(&self, topics_buffer: &ArgBuffer, data: &[u8])

Saves an event log.
source§

fn write_legacy_log(&self, topics: &[[u8; 32]], data: &[u8])

The legacy Arwen hook for saving event logs. It does the same, but only accepts 32-byte topics. Only kept for backwards compatibility.
source§

impl SendApi<ArwenBigUint> for ArwenApiImpl

source§

fn direct_moa(&self, to: &Address, amount: &ArwenBigUint, data: &[u8])

Sends MOA to a given address, directly. Used especially for sending MOA to regular accounts.
source§

fn direct_moa_execute( &self, to: &Address, amount: &ArwenBigUint, gas_limit: u64, function: &[u8], arg_buffer: &ArgBuffer )

Sends MOA 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 )

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 )

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]) -> !

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

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 arguments
source§

fn execute_on_dest_context_raw( &self, gas: u64, address: &Address, amount: &ArwenBigUint, function: &[u8], arg_buffer: &ArgBuffer ) -> Vec<BoxedBytes>

source§

fn execute_on_dest_context_by_caller_raw( &self, gas: u64, address: &Address, amount: &ArwenBigUint, function: &[u8], arg_buffer: &ArgBuffer ) -> Vec<BoxedBytes>

source§

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])

Used to store data between async call and callback.
source§

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 )

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] )

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] )

Sends either MOA 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] ) -> !

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] )

Sends either MOA 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>) -> !

Sends an asynchronous call to another contract, with either MOA 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)

Allows synchronous minting of DCT tokens. Execution is resumed afterwards.
source§

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,

Creates a new NFT token of a certain type (determined by 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 )

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.
source§

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] )

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 address
source§

fn direct_dct_nft_via_transfer_exec( &self, to: &Address, token: &[u8], nonce: u64, amount: &BigUint, data: &[u8] )

Sends an DCT NFT to a given address, directly. Used especially for sending DCT to regular accounts. Read more
source§

impl StorageReadApi for ArwenApiImpl

source§

fn storage_load_len(&self, key: &[u8]) -> usize

source§

fn storage_load_vec_u8(&self, key: &[u8]) -> Vec<u8>

source§

fn storage_load_boxed_bytes(&self, key: &[u8]) -> BoxedBytes

source§

fn storage_load_big_uint_raw(&self, key: &[u8]) -> i32

source§

fn storage_load_u64(&self, key: &[u8]) -> u64

source§

fn storage_load_i64(&self, key: &[u8]) -> i64

source§

impl StorageWriteApi for ArwenApiImpl

source§

fn storage_store_slice_u8(&self, key: &[u8], value: &[u8])

source§

fn storage_store_big_uint_raw(&self, key: &[u8], handle: i32)

source§

fn storage_store_u64(&self, key: &[u8], value: u64)

source§

fn storage_store_i64(&self, key: &[u8], value: i64)

Auto Trait Implementations§

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> 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> ToOwned for T
where T: Clone,

§

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

§

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

§

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.