AndesApiImpl

Struct AndesApiImpl 

Source
pub struct AndesApiImpl {}
Expand description

The reference to the API implementation based on Andes hooks. It continas no data, can be embedded at no cost. Cloning it is a no-op.

Trait Implementations§

Source§

impl BigIntApi for AndesApiImpl

Source§

fn bi_new(&self, value: i64) -> Handle

Source§

fn bi_unsigned_byte_length(&self, x: Handle) -> usize

Source§

fn bi_get_unsigned_bytes(&self, handle: Handle) -> BoxedBytes

Source§

fn bi_set_unsigned_bytes(&self, destination: Handle, bytes: &[u8])

Source§

fn bi_signed_byte_length(&self, x: Handle) -> usize

Source§

fn bi_get_signed_bytes(&self, handle: Handle) -> BoxedBytes

Source§

fn bi_set_signed_bytes(&self, destination: Handle, bytes: &[u8])

Source§

fn bi_to_i64(&self, reference: Handle) -> Option<i64>

Source§

fn bi_add(&self, dest: Handle, x: Handle, y: Handle)

Source§

fn bi_sub(&self, dest: Handle, x: Handle, y: Handle)

Source§

fn bi_sub_unsigned(&self, dest: Handle, x: Handle, y: Handle)

Source§

fn bi_mul(&self, dest: Handle, x: Handle, y: Handle)

Source§

fn bi_t_div(&self, dest: Handle, x: Handle, y: Handle)

Source§

fn bi_t_mod(&self, dest: Handle, x: Handle, y: Handle)

Source§

fn bi_abs(&self, dest: Handle, x: Handle)

Source§

fn bi_neg(&self, dest: Handle, x: Handle)

Source§

fn bi_sign(&self, x: Handle) -> Sign

Source§

fn bi_cmp(&self, x: Handle, y: Handle) -> Ordering

Source§

fn bi_sqrt(&self, dest: Handle, x: Handle)

Source§

fn bi_pow(&self, dest: Handle, x: Handle, y: Handle)

Source§

fn bi_log2(&self, x: Handle) -> u32

Source§

fn bi_and(&self, dest: Handle, x: Handle, y: Handle)

Source§

fn bi_or(&self, dest: Handle, x: Handle, y: Handle)

Source§

fn bi_xor(&self, dest: Handle, x: Handle, y: Handle)

Source§

fn bi_shr(&self, dest: Handle, x: Handle, bits: usize)

Source§

fn bi_shl(&self, dest: Handle, x: Handle, bits: usize)

Source§

fn bi_new_zero(&self) -> i32

Source§

impl BlockchainApi for AndesApiImpl

Source§

fn get_sc_address_legacy(&self) -> Address

Source§

fn get_sc_address(&self) -> ManagedAddress<Self>

Source§

fn get_owner_address_legacy(&self) -> Address

Source§

fn get_owner_address(&self) -> ManagedAddress<Self>

Source§

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

Source§

fn get_shard_of_address(&self, address: &ManagedAddress<Self>) -> u32

Source§

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

Source§

fn is_smart_contract(&self, address: &ManagedAddress<Self>) -> bool

Source§

fn get_caller_legacy(&self) -> Address

Source§

fn get_caller(&self) -> ManagedAddress<Self>

Source§

fn get_balance_legacy(&self, address: &Address) -> BigUint<Self>

Source§

fn get_balance(&self, address: &ManagedAddress<Self>) -> BigUint<Self>

Source§

fn get_state_root_hash_legacy(&self) -> H256

Source§

fn get_state_root_hash(&self) -> ManagedByteArray<Self, 32>

Source§

fn get_tx_hash_legacy(&self) -> H256

Source§

fn get_tx_hash(&self) -> ManagedByteArray<Self, 32>

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_legacy(&self) -> Box<[u8; 48]>

Source§

fn get_block_random_seed(&self) -> ManagedByteArray<Self, 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_legacy(&self) -> Box<[u8; 48]>

Source§

fn get_prev_block_random_seed(&self) -> ManagedByteArray<Self, 48>

Source§

fn get_current_dcdt_nft_nonce( &self, address: &Address, token: &TokenIdentifier<Self>, ) -> u64

Source§

fn get_dcdt_balance( &self, m_address: &ManagedAddress<Self>, token: &TokenIdentifier<Self>, nonce: u64, ) -> BigUint<Self>

Source§

fn get_dcdt_token_data( &self, address: &ManagedAddress<Self>, token: &TokenIdentifier<Self>, nonce: u64, ) -> DcdtTokenData<Self>

Source§

impl CallValueApi for AndesApiImpl

Source§

fn check_not_payable(&self)

Source§

fn rewa_value(&self) -> BigUint<Self>

Retrieves the REWA call value from the VM. Will return 0 in case of an DCDT transfer (cannot have both REWA and DCDT transfer simultaneously).
Source§

fn dcdt_value(&self) -> BigUint<Self>

Retrieves the DCDT call value from the VM. Will return 0 in case of an REWA transfer (cannot have both REWA and DCDT transfer simultaneously).
Source§

fn token(&self) -> TokenIdentifier<Self>

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 dcdt_token_nonce(&self) -> u64

Returns the nonce of the received DCDT token. Will return 0 in case of REWA or fungible DCDT transfer.
Source§

fn dcdt_token_type(&self) -> DcdtTokenType

Returns the DCDT token type. Will return “Fungible” for REWA.
Source§

fn dcdt_num_transfers(&self) -> usize

Source§

fn dcdt_value_by_index(&self, index: usize) -> BigUint<Self>

Source§

fn token_by_index(&self, index: usize) -> TokenIdentifier<Self>

Source§

fn dcdt_token_nonce_by_index(&self, index: usize) -> u64

Source§

fn dcdt_token_type_by_index(&self, index: usize) -> DcdtTokenType

Source§

fn get_all_dcdt_transfers(&self) -> ManagedVec<Self, DcdtTokenPayment<Self>>

Source§

fn require_rewa(&self) -> BigUint<Self>

Will return the REWA call value, but also fail with an error if DCDT is sent. Especially used in the auto-generated call value processing.
Source§

fn require_dcdt(&self, token: &[u8]) -> BigUint<Self>

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

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

Returns both the call value (either REWA or DCDT) and the token identifier. Especially used in the `#[payable(“*”)] auto-generated snippets. The method might seem redundant, but there is such a hook in Andes that might be used in this scenario in the future.
Source§

impl Clone for AndesApiImpl

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

Source§

fn clone(&self) -> Self

Returns a duplicate 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 CryptoApi for AndesApiImpl

Source§

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

Source§

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

Source§

fn ripemd160(&self, data: &[u8]) -> Box<[u8; 20]>

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§

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

Source§

fn encode_secp256k1_der_signature(&self, r: &[u8], s: &[u8]) -> BoxedBytes

Source§

impl EllipticCurveApi for AndesApiImpl

Source§

fn ec_create(&self, name: &[u8]) -> Handle

Source§

fn ec_get_values( &self, ec_handle: Handle, field_order_handle: Handle, base_point_order_handle: Handle, eq_constant_handle: Handle, x_base_point_handle: Handle, y_base_point_handle: Handle, )

Source§

fn ec_curve_length(&self, ec_handle: Handle) -> u32

Source§

fn ec_private_key_byte_length(&self, ec_handle: Handle) -> u32

Source§

fn ec_add( &self, x_result_handle: Handle, y_result_handle: Handle, ec_handle: Handle, x_first_point: Handle, y_first_point: Handle, x_second_point: Handle, y_second_point: Handle, )

Source§

fn ec_double( &self, x_result_handle: Handle, y_result_handle: Handle, ec_handle: Handle, x_point_handle: Handle, y_point_handle: Handle, )

Source§

fn ec_is_on_curve( &self, ec_handle: Handle, x_point_handle: Handle, y_point_handle: Handle, ) -> bool

Source§

fn ec_scalar_mult( &self, x_result_handle: Handle, y_result_handle: Handle, ec_handle: Handle, x_point_handle: Handle, y_point_handle: Handle, data: &[u8], )

Source§

fn ec_scalar_base_mult( &self, x_result_handle: Handle, y_result_handle: Handle, ec_handle: Handle, data: &[u8], )

Source§

fn ec_marshal( &self, ec_handle: Handle, x_pair_handle: Handle, y_pair_handle: Handle, ) -> BoxedBytes

Source§

fn ec_marshal_compressed( &self, ec_handle: Handle, x_pair_handle: Handle, y_pair_handle: Handle, ) -> BoxedBytes

Source§

fn ec_unmarshal( &self, x_result_handle: Handle, y_result_handle: Handle, ec_handle: Handle, data: &[u8], )

Source§

fn ec_unmarshal_compressed( &self, x_result_handle: Handle, y_result_handle: Handle, ec_handle: Handle, data: &[u8], )

Source§

fn ec_generate_key( &self, x_pub_key_handle: Handle, y_pub_key_handle: Handle, ec_handle: Handle, ) -> BoxedBytes

Source§

impl EndpointArgumentApi for AndesApiImpl

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_managed_buffer_raw(&self, arg_id: i32) -> Handle

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 AndesApiImpl

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_managed_buffer_raw(&self, handle: Handle)

Source§

fn finish_u64(&self, value: u64)

Source§

fn finish_i64(&self, value: i64)

Source§

impl ErrorApi for AndesApiImpl

Source§

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

Source§

fn signal_error_from_buffer(&self, message_handle: Handle) -> !

Source§

impl LogApi for AndesApiImpl

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 Andes hook for saving event logs. It does the same, but only accepts 32-byte topics. Only kept for backwards compatibility.
Source§

fn managed_write_log(&self, topics_handle: Handle, data_handle: Handle)

Source§

impl ManagedBufferApi for AndesApiImpl

Source§

fn mb_new_empty(&self) -> Handle

Source§

fn mb_new_from_bytes(&self, bytes: &[u8]) -> Handle

Source§

fn mb_len(&self, handle: Handle) -> usize

Source§

fn mb_to_boxed_bytes(&self, handle: Handle) -> BoxedBytes

Source§

fn mb_load_slice( &self, source_handle: Handle, starting_position: usize, dest_slice: &mut [u8], ) -> Result<(), InvalidSliceError>

TODO: investigate the impact of using Result<(), ()> on the wasm output.
Source§

fn mb_copy_slice( &self, source_handle: Handle, starting_pos: usize, slice_len: usize, dest_handle: Handle, ) -> Result<(), InvalidSliceError>

TODO: investigate the impact of using Result<(), ()> on the wasm output.
Source§

fn mb_copy_to_slice_pad_right(&self, handle: Handle, destination: &mut [u8])

Source§

fn mb_overwrite(&self, handle: Handle, bytes: &[u8])

Source§

fn mb_append(&self, accumulator_handle: Handle, data_handle: Handle)

Source§

fn mb_append_bytes(&self, accumulator_handle: Handle, bytes: &[u8])

Source§

fn mb_eq(&self, handle1: Handle, handle2: Handle) -> bool

Source§

impl ManagedTypeApi for AndesApiImpl

Source§

fn mb_to_big_int_unsigned(&self, buffer_handle: Handle) -> Handle

Source§

fn mb_to_big_int_signed(&self, buffer_handle: Handle) -> Handle

Source§

fn mb_from_big_int_unsigned(&self, big_int_handle: Handle) -> Handle

Source§

fn mb_from_big_int_signed(&self, big_int_handle: Handle) -> Handle

Source§

impl SendApi for AndesApiImpl

Source§

fn direct_rewa<D>( &self, to: &ManagedAddress<Self>, amount: &BigUint<Self>, data: D, )
where D: ManagedInto<Self, ManagedBuffer<Self>>,

Sends REWA to a given address, directly. Used especially for sending REWA to regular accounts.
Source§

fn direct_rewa_execute( &self, to: &ManagedAddress<Self>, amount: &BigUint<Self>, gas_limit: u64, endpoint_name: &ManagedBuffer<Self>, arg_buffer: &ManagedArgBuffer<Self>, ) -> Result<(), &'static [u8]>

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

fn direct_dcdt_execute( &self, to: &ManagedAddress<Self>, token: &TokenIdentifier<Self>, amount: &BigUint<Self>, gas_limit: u64, endpoint_name: &ManagedBuffer<Self>, arg_buffer: &ManagedArgBuffer<Self>, ) -> Result<(), &'static [u8]>

Sends DCDT to an address and executes like an async call, but without callback.
Source§

fn direct_dcdt_nft_execute( &self, to: &ManagedAddress<Self>, token: &TokenIdentifier<Self>, nonce: u64, amount: &BigUint<Self>, gas_limit: u64, endpoint_name: &ManagedBuffer<Self>, arg_buffer: &ManagedArgBuffer<Self>, ) -> Result<(), &'static [u8]>

Sends DCDT NFT to an address and executes like an async call, but without callback.
Source§

fn direct_multi_dcdt_transfer_execute( &self, to: &ManagedAddress<Self>, payments: &ManagedVec<Self, DcdtTokenPayment<Self>>, gas_limit: u64, endpoint_name: &ManagedBuffer<Self>, arg_buffer: &ManagedArgBuffer<Self>, ) -> Result<(), &'static [u8]>

Source§

fn async_call_raw( &self, to: &ManagedAddress<Self>, amount: &BigUint<Self>, endpoint_name: &ManagedBuffer<Self>, arg_buffer: &ManagedArgBuffer<Self>, ) -> !

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: &BigUint<Self>, code: &ManagedBuffer<Self>, code_metadata: CodeMetadata, arg_buffer: &ManagedArgBuffer<Self>, ) -> (ManagedAddress<Self>, ManagedVec<Self, ManagedBuffer<Self>>)

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: &BigUint<Self>, source_contract_address: &ManagedAddress<Self>, code_metadata: CodeMetadata, arg_buffer: &ManagedArgBuffer<Self>, ) -> (ManagedAddress<Self>, ManagedVec<Self, ManagedBuffer<Self>>)

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: &ManagedAddress<Self>, gas: u64, amount: &BigUint<Self>, code: &ManagedBuffer<Self>, code_metadata: CodeMetadata, arg_buffer: &ManagedArgBuffer<Self>, )

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, to: &ManagedAddress<Self>, amount: &BigUint<Self>, endpoint_name: &ManagedBuffer<Self>, arg_buffer: &ManagedArgBuffer<Self>, ) -> ManagedVec<Self, ManagedBuffer<Self>>

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

fn execute_on_dest_context_raw_custom_result_range<F>( &self, gas: u64, to: &ManagedAddress<Self>, amount: &BigUint<Self>, endpoint_name: &ManagedBuffer<Self>, arg_buffer: &ManagedArgBuffer<Self>, range_closure: F, ) -> ManagedVec<Self, ManagedBuffer<Self>>
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 Andes 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, to: &ManagedAddress<Self>, amount: &BigUint<Self>, endpoint_name: &ManagedBuffer<Self>, arg_buffer: &ManagedArgBuffer<Self>, ) -> ManagedVec<Self, ManagedBuffer<Self>>

Source§

fn execute_on_same_context_raw( &self, gas: u64, to: &ManagedAddress<Self>, amount: &BigUint<Self>, endpoint_name: &ManagedBuffer<Self>, arg_buffer: &ManagedArgBuffer<Self>, ) -> ManagedVec<Self, ManagedBuffer<Self>>

Source§

fn execute_on_dest_context_readonly_raw( &self, gas: u64, to: &ManagedAddress<Self>, endpoint_name: &ManagedBuffer<Self>, arg_buffer: &ManagedArgBuffer<Self>, ) -> ManagedVec<Self, ManagedBuffer<Self>>

Source§

fn storage_store_tx_hash_key(&self, data: &ManagedBuffer<Self>)

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

fn storage_load_tx_hash_key(&self) -> ManagedBuffer<Self>

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

fn call_local_dcdt_built_in_function( &self, gas: u64, function_name: &ManagedBuffer<Self>, arg_buffer: &ManagedArgBuffer<Self>, ) -> ManagedVec<Self, ManagedBuffer<Self>>

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§

impl StorageReadApi for AndesApiImpl

Source§

impl StorageWriteApi for AndesApiImpl

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_managed_buffer_raw( &self, key_handle: Handle, value_handle: Handle, )

Source§

fn storage_store_managed_buffer_clear(&self, key_handle: Handle)

Source§

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

Source§

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

Source§

impl TryStaticCast for AndesApiImpl

Source§

fn type_eq<U>() -> bool
where U: TryStaticCast,

Source§

fn try_cast<U>(self) -> Option<U>
where U: TryStaticCast,

Source§

fn try_cast_ref<U>(&self) -> Option<&U>
where U: TryStaticCast,

Source§

impl VMApi for AndesApiImpl

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<M, F> ManagedFrom<M, F> for F
where M: ManagedTypeApi,

Source§

fn managed_from(_: M, t: F) -> F

Source§

impl<M, F, T> ManagedInto<M, T> for F
where T: ManagedFrom<M, F>, M: ManagedTypeApi,

Source§

fn managed_into(self, api: M) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

Source§

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

Source§

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.