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 BlockchainApi for ArwenApiImpl

§

type BalanceType = ArwenBigUint

The type of the token balances. Not named BigUint to avoid name collisions in types that implement multiple API traits.
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: &TokenIdentifier ) -> u64

source§

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

source§

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

source§

fn check_caller_is_owner(&self)

source§

fn get_sc_balance( &self, token: &TokenIdentifier, nonce: u64 ) -> Self::BalanceType

source§

fn get_cumulated_validator_rewards(&self) -> Self::BalanceType

Retrieves validator rewards, as set by the protocol. TODO: move to the storage API, once BigUint gets refactored
source§

fn get_dct_local_roles(&self, token_id: &TokenIdentifier) -> Vec<DctLocalRole>

Retrieves local roles for the token, by reading protected storage.
source§

impl CallValueApi for ArwenApiImpl

§

type AmountType = ArwenBigUint

The type of the payment arguments. Not named BigUint to avoid name collisions in types that implement multiple API traits.
source§

fn check_not_payable(&self)

source§

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

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

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 MOAX or fungible DCT transfer.
source§

fn dct_token_type(&self) -> DctTokenType

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

fn require_moax(&self) -> Self::AmountType

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]) -> Self::AmountType

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) -> (Self::AmountType, 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

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 ContractBase for ArwenApiImpl

§

type EllipticCurve = ArwenEllipticCurve

§

type BigUint = ArwenBigUint

§

type BigInt = ArwenBigInt

§

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 MOAX & DCT transactions, as well as async calls.
§

type BlockchainApi = ArwenApiImpl

§

type CryptoApi = ArwenApiImpl

§

type LogApi = ArwenApiImpl

§

type ErrorApi = ArwenApiImpl

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 blockchain(&self) -> Self::BlockchainApi

Gateway blockchain info related to the current transaction and to accounts.
source§

fn crypto(&self) -> Self::CryptoApi

Stateless crypto functions provided by the Arwen VM.
source§

fn log_api_raw(&self) -> Self::LogApi

Gateway into the lower-level event log functionality. Gets called in auto-generated Using it directly is not recommended. TODO: consider moving to ContractPrivateApi.
source§

fn error_api(&self) -> Self::ErrorApi

Currently for some auto-generated code involving callbacks. Please avoid using it directly. TODO: find a way to hide this API.
source§

fn proxy<P>(&self, address: Address) -> P
where P: ProxyObjApi<SendApi = Self::SendApi>,

source§

impl CryptoApi for ArwenApiImpl

§

type BigUint = ArwenBigUint

Numeric type used in some of the Arwen hooks.
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 for ArwenApiImpl

§

type AmountType = ArwenBigUint

The type of the payment arguments. Not named BigUint to avoid name collisions in types that implement multiple API traits.
§

type ProxyBigInt = ArwenBigInt

Not used by SendApi, but forwarded to the proxy traits.
§

type ProxyEllipticCurve = ArwenEllipticCurve

§

type ProxyStorage = ArwenApiImpl

Not used by SendApi, but forwarded to the proxy traits.
source§

fn get_sc_address(&self) -> Address

Required for DCTNFTTransfer. Same as the implementation from BlockchainApi.
source§

fn get_gas_left(&self) -> u64

To be used internally by the SendApi implementation. Do not use directly from contracts. It might be removed from this trait at some point or reworked.
source§

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

Used internally for sell_nft. Do not use directly from contracts.
source§

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 ) -> Result<(), &'static [u8]>

Sends MOAX to an address (optionally) and executes like an async call, but without callback.
source§

fn direct_dct_execute( &self, to: &Address, token: &TokenIdentifier, amount: &ArwenBigUint, gas_limit: u64, function: &[u8], arg_buffer: &ArgBuffer ) -> Result<(), &'static [u8]>

Sends DCT to an address and executes like an async call, but without callback.
source§

fn direct_dct_nft_execute( &self, to: &Address, token: &TokenIdentifier, nonce: u64, amount: &ArwenBigUint, gas_limit: u64, function: &[u8], arg_buffer: &ArgBuffer ) -> Result<(), &'static [u8]>

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 ) -> Option<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 If the deployment fails, Option::None is returned
source§

fn deploy_from_source_contract( &self, gas: u64, amount: &ArwenBigUint, source_contract_address: &Address, code_metadata: CodeMetadata, arg_buffer: &ArgBuffer ) -> Option<Address>

Deploys a new contract in the same shard by re-using the code of an already deployed source contract. The deployment is done synchronously and the new contract’s address is returned. If the deployment fails, Option::None is returned
source§

fn upgrade_contract( &self, sc_address: &Address, gas: u64, amount: &ArwenBigUint, code: &BoxedBytes, code_metadata: CodeMetadata, arg_buffer: &ArgBuffer )

Upgrades a child contract of the currently executing contract. The upgrade is synchronous, and the current transaction will fail if the upgrade fails. The child contract’s new init function will be called with the provided arguments
source§

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

Same shard, in-line execution of another contract.
source§

fn execute_on_dest_context_raw_custom_result_range<F>( &self, gas: u64, address: &Address, amount: &ArwenBigUint, function: &[u8], arg_buffer: &ArgBuffer, range_closure: F ) -> Vec<BoxedBytes>
where F: FnOnce(usize, usize) -> (usize, usize),

Same shard, in-line execution of another contract. Allows the contract to specify which result range to extract as sync call result. This is a workaround to handle nested sync calls. Please do not use this method unless there is absolutely no other option. Will be eliminated after some future Arwen hook redesign. range_closure takes the number of results before, the number of results after, and is expected to return the start index (inclusive) and end index (exclusive).
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 ) -> Vec<BoxedBytes>

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( &self, to: &Address, token: &TokenIdentifier, nonce: u64, amount: &Self::AmountType, data: &[u8] )

Sends either MOAX, DCT or NFT to the target address, depending on the token identifier and nonce
source§

fn async_call(&self, async_call: AsyncCall<Self>) -> !

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 transfer_dct_via_async_call( &self, to: &Address, token: &TokenIdentifier, nonce: u64, amount: &Self::AmountType, data: &[u8] ) -> !

Performs a simple DCT/NFT transfer, but via async call.
As with any async call, this immediately terminates the execution of the current call.
So only use as the last call in your endpoint.
If you want to perform multiple transfers, use self.send().direct() instead.
Note that MOAX can NOT be transfered with this function.
source§

fn change_owner_address(&self, child_sc_address: &Address, new_owner: &Address)

source§

fn dct_local_mint( &self, token: &TokenIdentifier, nonce: u64, amount: &Self::AmountType )

Allows synchronous minting of DCT/SFT (depending on nonce). Execution is resumed afterwards. Note that the SC must have the DCTLocalMint or DCTNftAddQuantity roles set, or this will fail with “action is not allowed” For SFTs, you must use self.send().dct_nft_create() before adding additional quantity. This function cannot be used for NFTs.
source§

fn dct_local_burn( &self, token: &TokenIdentifier, nonce: u64, amount: &Self::AmountType )

Allows synchronous burning of DCT/SFT/NFT (depending on nonce). Execution is resumed afterwards. Note that the SC must have the DCTLocalBurn or DCTNftBurn roles set, or this will fail with “action is not allowed”
source§

fn dct_nft_create<T>( &self, token: &TokenIdentifier, amount: &Self::AmountType, name: &BoxedBytes, royalties: &Self::AmountType, hash: &BoxedBytes, attributes: &T, uris: &[BoxedBytes] ) -> u64
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. Must have DCTNftCreate role set, or this will fail with “action is not allowed”. Returns the nonce of the newly created NFT.
source§

fn sell_nft( &self, nft_id: &TokenIdentifier, nft_nonce: u64, nft_amount: &Self::AmountType, buyer: &Address, payment_token: &TokenIdentifier, payment_nonce: u64, payment_amount: &Self::AmountType ) -> Self::AmountType

Sends thr NFTs to the buyer address and calculates and sends the required royalties to the NFT creator. Returns the payment amount left after sending royalties.
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.