Trait pallet_contracts::chain_extension::Ext [−][src]
pub trait Ext: Sealed { type T: Config;}Show methods
fn call(
&mut self,
gas_limit: Weight,
to: <Self::T as Config>::AccountId,
value: <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance,
input_data: Vec<u8>,
allows_reentry: bool
) -> Result<ExecReturnValue, ExecError>; fn instantiate(
&mut self,
gas_limit: Weight,
code: <Self::T as Config>::Hash,
value: <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance,
input_data: Vec<u8>,
salt: &[u8]
) -> Result<(<Self::T as Config>::AccountId, ExecReturnValue), ExecError>; fn terminate(
&mut self,
beneficiary: &<Self::T as Config>::AccountId
) -> Result<(), DispatchError>; fn restore_to(
&mut self,
dest: <Self::T as Config>::AccountId,
code_hash: <Self::T as Config>::Hash,
rent_allowance: <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance,
delta: Vec<[u8; 32]>
) -> Result<(), DispatchError>; fn transfer(
&mut self,
to: &<Self::T as Config>::AccountId,
value: <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance
) -> DispatchResult; fn get_storage(&mut self, key: &[u8; 32]) -> Option<Vec<u8>>; fn set_storage(
&mut self,
key: [u8; 32],
value: Option<Vec<u8>>
) -> DispatchResult; fn caller(&self) -> &<Self::T as Config>::AccountId; fn address(&self) -> &<Self::T as Config>::AccountId; fn balance(
&self
) -> <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance; fn value_transferred(
&self
) -> <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance; fn now(&self) -> &<<Self::T as Config>::Time as Time>::Moment; fn minimum_balance(
&self
) -> <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance; fn tombstone_deposit(
&self
) -> <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance; fn random(
&self,
subject: &[u8]
) -> (<Self::T as Config>::Hash, <Self::T as Config>::BlockNumber); fn deposit_event(
&mut self,
topics: Vec<<Self::T as Config>::Hash>,
data: Vec<u8>
); fn set_rent_allowance(
&mut self,
rent_allowance: <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance
); fn rent_allowance(
&mut self
) -> <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance; fn block_number(&self) -> <Self::T as Config>::BlockNumber; fn max_value_size(&self) -> u32; fn get_weight_price(
&self,
weight: Weight
) -> <<Self::T as Config>::Currency as Currency<<Self::T as Config>::AccountId>>::Balance; fn schedule(&self) -> &Schedule<Self::T>; fn rent_params(&self) -> &RentParams<Self::T>; fn rent_status(&mut self, at_refcount: u32) -> RentStatus<Self::T>; fn gas_meter(&mut self) -> &mut GasMeter<Self::T>; fn append_debug_buffer(&mut self, msg: &str) -> bool; fn call_runtime(
&self,
call: <Self::T as Config>::Call
) -> DispatchResultWithPostInfo;
Expand description
An interface that provides access to the external environment in which the smart-contract is executed.
This interface is specialized to an account of the executing code, so all operations are implicitly performed on that account.
Note
This trait is sealed and cannot be implemented by downstream crates.
Associated Types
Required methods
Call (possibly transferring some amount of funds) into the specified account.
Returns the original code size of the called contract.
Return Value
Result<(ExecReturnValue, CodeSize), (ExecError, CodeSize)>
Instantiate a contract from the given code.
Returns the original code size of the called contract.
The newly created account will be associated with code
. value
specifies the amount of value
transferred from this to the newly created account (also known as endowment).
Return Value
Result<(AccountId, ExecReturnValue, CodeSize), (ExecError, CodeSize)>
Transfer all funds to beneficiary
and delete the contract.
Since this function removes the self contract eagerly, if succeeded, no further actions should
be performed on this Ext
instance.
This function will fail if the same contract is present on the contract call stack.
Restores the given destination contract sacrificing the current one.
Since this function removes the self contract eagerly, if succeeded, no further actions should
be performed on this Ext
instance.
This function will fail if the same contract is present on the contract call stack.
Return Value
Result<(CallerCodeSize, DestCodeSize), (DispatchError, CallerCodeSize, DestCodesize)>
Transfer some amount of funds into the specified account.
Returns the storage entry of the executing account by the given key
.
Returns None
if the key
wasn’t previously set by set_storage
or
was deleted.
fn set_storage(
&mut self,
key: [u8; 32],
value: Option<Vec<u8>>
) -> DispatchResult
fn set_storage(
&mut self,
key: [u8; 32],
value: Option<Vec<u8>>
) -> DispatchResult
Sets the storage entry by the given key to the specified value. If value
is None
then
the storage entry is deleted.
Returns a reference to the account id of the caller.
Returns a reference to the account id of the current contract.
Returns the balance of the current contract.
The value_transferred
is already added.
Returns the value transferred along with this call or as endowment.
Returns a reference to the timestamp of the current block
Returns the minimum balance that is required for creating an account.
Returns the deposit required to create a tombstone upon contract eviction.
Returns a random number for the current block with the given subject.
Deposit an event with the given topics.
There should not be any duplicates in topics
.
Set rent allowance of the contract
Rent allowance of the contract
fn block_number(&self) -> <Self::T as Config>::BlockNumber
fn block_number(&self) -> <Self::T as Config>::BlockNumber
Returns the current block number.
fn max_value_size(&self) -> u32
fn max_value_size(&self) -> u32
Returns the maximum allowed size of a storage item.
Returns the price for the specified amount of weight.
Get a reference to the schedule used by the current call.
fn rent_params(&self) -> &RentParams<Self::T>
fn rent_params(&self) -> &RentParams<Self::T>
Information needed for rent calculations.
fn rent_status(&mut self, at_refcount: u32) -> RentStatus<Self::T>
fn rent_status(&mut self, at_refcount: u32) -> RentStatus<Self::T>
Information about the required deposit and resulting rent.
Get a mutable reference to the nested gas meter.
fn append_debug_buffer(&mut self, msg: &str) -> bool
fn append_debug_buffer(&mut self, msg: &str) -> bool
Append a string to the debug buffer.
It is added as-is without any additional new line.
This is a no-op if debug message recording is disabled which is always the case when the code is executing on-chain.
Returns true
if debug message recording is enabled. Otherwise false
is returned.
fn call_runtime(
&self,
call: <Self::T as Config>::Call
) -> DispatchResultWithPostInfo
fn call_runtime(
&self,
call: <Self::T as Config>::Call
) -> DispatchResultWithPostInfo
Call some dispatchable and return the result.