Struct noble_contracts::Module [−][src]
Contracts module.
Implementations
impl<T: Config> Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
Can also be called using Call
.
pub fn update_schedule(
origin: T::Origin,
schedule: Schedule<T>
) -> DispatchResult
[src]
origin: T::Origin,
schedule: Schedule<T>
) -> DispatchResult
Updates the schedule for metering contracts.
The schedule must have a greater version than the stored schedule.
NOTE: Calling this function will bypass origin filters.
pub fn put_code(origin: T::Origin, code: Vec<u8>) -> DispatchResult
[src]
Stores the given binary Wasm code into the chain’s storage and returns its codehash
.
You can instantiate contracts only with stored code.
NOTE: Calling this function will bypass origin filters.
pub fn call(
origin: T::Origin,
dest: <T::Lookup as StaticLookup>::Source,
value: BalanceOf<T>,
gas_limit: Gas,
data: Vec<u8>
) -> DispatchResultWithPostInfo
[src]
origin: T::Origin,
dest: <T::Lookup as StaticLookup>::Source,
value: BalanceOf<T>,
gas_limit: Gas,
data: Vec<u8>
) -> DispatchResultWithPostInfo
Makes a call to an account, optionally transferring some balance.
- If the account is a smart-contract account, the associated code will be executed and any value will be transferred.
- If the account is a regular account, any value will be transferred.
- If no account exists and the call value is not less than
existential_deposit
, a regular account will be created and any value will be transferred.
NOTE: Calling this function will bypass origin filters.
pub fn instantiate(
origin: T::Origin,
endowment: BalanceOf<T>,
gas_limit: Gas,
code_hash: CodeHash<T>,
data: Vec<u8>,
salt: Vec<u8>
) -> DispatchResultWithPostInfo
[src]
origin: T::Origin,
endowment: BalanceOf<T>,
gas_limit: Gas,
code_hash: CodeHash<T>,
data: Vec<u8>,
salt: Vec<u8>
) -> DispatchResultWithPostInfo
Instantiates a new contract from the code_hash
generated by put_code
,
optionally transferring some balance.
The supplied salt
is used for contract address deriviation. See fn contract_address
.
Instantiation is executed as follows:
- The destination address is computed based on the sender, code_hash and the salt.
- The smart-contract account is created at the computed address.
- The
ctor_code
is executed in the context of the newly-created account. Buffer returned after the execution is saved as thecode
of the account. That code will be invoked upon any call received by this account. - The contract is initialized.
NOTE: Calling this function will bypass origin filters.
pub fn claim_surcharge(
origin: T::Origin,
dest: T::AccountId,
aux_sender: Option<T::AccountId>
) -> DispatchResultWithPostInfo
[src]
origin: T::Origin,
dest: T::AccountId,
aux_sender: Option<T::AccountId>
) -> DispatchResultWithPostInfo
Allows block producers to claim a small reward for evicting a contract. If a block producer fails to do so, a regular users will be allowed to claim the reward.
In case of a successful eviction no fees are charged from the sender. However, the reward is capped by the total amount of rent that was payed by the contract while it was alive.
If contract is not evicted as a result of this call, Error::ContractNotEvictable
is returned and the sender is not eligible for the reward.
NOTE: Calling this function will bypass origin filters.
impl<T: Config> Module<T> where
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>,
Public APIs provided by the contracts module.
pub fn bare_call(
origin: T::AccountId,
dest: T::AccountId,
value: BalanceOf<T>,
gas_limit: Gas,
input_data: Vec<u8>
) -> ContractExecResult
[src]
origin: T::AccountId,
dest: T::AccountId,
value: BalanceOf<T>,
gas_limit: Gas,
input_data: Vec<u8>
) -> ContractExecResult
Perform a call to a specified contract.
This function is similar to Self::call
, but doesn’t perform any address lookups and better
suitable for calling directly from Rust.
It returns the exection result and the amount of used weight.
pub fn get_storage(address: T::AccountId, key: [u8; 32]) -> GetStorageResult
[src]
Query storage of a specified contract under a specified key.
pub fn rent_projection(
address: T::AccountId
) -> RentProjectionResult<T::BlockNumber>
[src]
address: T::AccountId
) -> RentProjectionResult<T::BlockNumber>
pub fn contract_address(
deploying_address: &T::AccountId,
code_hash: &CodeHash<T>,
salt: &[u8]
) -> T::AccountId
[src]
deploying_address: &T::AccountId,
code_hash: &CodeHash<T>,
salt: &[u8]
) -> T::AccountId
Determine the address of a contract,
This is the address generation function used by contract instantation. Its result is only dependend on its inputs. It can therefore be used to reliably predict the address of a contract. This is akin to the formular of eth’s CRATE2 opcode. There is no CREATE equivalent because CREATE2 is strictly more powerful.
Formula: hash(deploying_address ++ code_hash ++ salt)
impl<T: Config + 'static> Module<T> where
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash> + AsRef<[u8]>,
pub fn current_schedule() -> Schedule<T>
[src]
Current cost schedule for contracts.
Trait Implementations
impl<T: Config> Callable<T> for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
impl<T: Clone + Config> Clone for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
impl<T: Copy + Config> Copy for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
impl<T: Config> Debug for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
T: Debug,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
T: Debug,
impl<T: Eq + Config> Eq for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
impl<T: Config> GetNobleVersion for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
fn current_version() -> NobleVersion
[src]
fn storage_version() -> Option<NobleVersion>
[src]
impl<T: Config> IntegrityTest for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
pub fn integrity_test()
[src]
impl<T: Config> ModuleErrorMetadata for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
fn metadata() -> &'static [ErrorMetadata]
[src]
impl<T: Config + Config> OffchainWorker<<T as Config>::BlockNumber> for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
pub fn offchain_worker(_n: BlockNumber)
[src]
impl<T: Config + Config> OnFinalize<<T as Config>::BlockNumber> for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
pub fn on_finalize(_n: BlockNumber)
[src]
impl<T: Config> OnGenesis for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
fn on_genesis()
[src]
impl<T: Config + Config> OnInitialize<<T as Config>::BlockNumber> for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
fn on_initialize(_block_number_not_used: <T as Config>::BlockNumber) -> Weight
[src]
impl<T: Config> OnRuntimeUpgrade for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
fn on_runtime_upgrade() -> Weight
[src]
impl<T: PartialEq + Config> PartialEq<Module<T>> for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
impl<T: Config> StructuralEq for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
impl<T: Config> StructuralPartialEq for Module<T> where
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
[src]
T::AccountId: UncheckedFrom<T::Hash>,
T::AccountId: AsRef<[u8]>,
Auto Trait Implementations
impl<T> RefUnwindSafe for Module<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Module<T> where
T: Send,
T: Send,
impl<T> Sync for Module<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Module<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Module<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CheckedConversion for T
[src]
pub fn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
[src]
Self: TryFrom<T>,
pub fn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
[src]
Self: TryInto<T>,
impl<T> Downcast for T where
T: Any,
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
impl<T> DowncastSync for T where
T: Any + Send + Sync,
T: Any + Send + Sync,
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
pub fn __clone_box(&self, Private) -> *mut ()
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IsType<T> for T
[src]
pub fn from_ref(t: &T) -> &T
[src]
pub fn into_ref(&self) -> &T
[src]
pub fn from_mut(t: &mut T) -> &mut T
[src]
pub fn into_mut(&mut self) -> &mut T
[src]
impl<T, Outer> IsWrappedBy<Outer> for T where
T: From<Outer>,
Outer: AsRef<T> + AsMut<T> + From<T>,
[src]
T: From<Outer>,
Outer: AsRef<T> + AsMut<T> + From<T>,
pub fn from_ref(outer: &Outer) -> &T
[src]
Get a reference to the inner from the outer.
pub fn from_mut(outer: &mut Outer) -> &mut T
[src]
Get a mutable reference to the inner from the outer.
impl<T> MaybeDebug for T where
T: Debug,
T: Debug,
impl<T> MaybeDebug for T where
T: Debug,
T: Debug,
impl<T> MaybeRefUnwindSafe for T where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Member for T where
T: 'static + Send + Sync + Debug + Eq + PartialEq<T> + Clone,
[src]
T: 'static + Send + Sync + Debug + Eq + PartialEq<T> + Clone,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> SaturatedConversion for T
pub fn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
Self: UniqueSaturatedFrom<T>,
pub fn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
Self: UniqueSaturatedInto<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
[src]
T: UncheckedFrom<S>,
pub fn unchecked_into(self) -> T
[src]
impl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
T: Bounded,
S: TryInto<T>,
pub fn unique_saturated_into(self) -> T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,