diff --git a/frame/contracts/src/chain_extension.rs b/frame/contracts/src/chain_extension.rs index 662cfb2053e6e..fdbb6ed4c429a 100644 --- a/frame/contracts/src/chain_extension.rs +++ b/frame/contracts/src/chain_extension.rs @@ -63,7 +63,7 @@ use sp_std::{ pub use frame_system::Config as SysConfig; pub use pallet_contracts_primitives::ReturnFlags; pub use sp_core::crypto::UncheckedFrom; -pub use crate::exec::Ext; +pub use crate::{Config, exec::Ext}; pub use state::Init as InitState; /// Result that returns a [`DispatchError`] on error. @@ -74,7 +74,7 @@ pub type Result = sp_std::result::Result; /// In order to create a custom chain extension this trait must be implemented and supplied /// to the pallet contracts configuration trait as the associated type of the same name. /// Consult the [module documentation](self) for a general explanation of chain extensions. -pub trait ChainExtension { +pub trait ChainExtension { /// Call the chain extension logic. /// /// This is the only function that needs to be implemented in order to write a @@ -91,8 +91,9 @@ pub trait ChainExtension { /// In case of `Err` the contract execution is immediatly suspended and the passed error /// is returned to the caller. Otherwise the value of [`RetVal`] determines the exit /// behaviour. - fn call(func_id: u32, env: Environment) -> Result + fn call(func_id: u32, env: Environment) -> Result where + E: Ext, ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>; /// Determines whether chain extensions are enabled for this chain. @@ -108,9 +109,10 @@ pub trait ChainExtension { } /// Implementation that indicates that no chain extension is available. -impl ChainExtension for () { - fn call(_func_id: u32, mut _env: Environment) -> Result +impl ChainExtension for () { + fn call(_func_id: u32, mut _env: Environment) -> Result where + E: Ext, ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, { // Never called since [`Self::enabled()`] is set to `false`. Because we want to diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index d585ac4f7fab6..629770ed918d7 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -337,7 +337,7 @@ pub trait Config: frame_system::Config { type WeightInfo: WeightInfo; /// Type that allows the runtime authors to add new host functions for a contract to call. - type ChainExtension: chain_extension::ChainExtension; + type ChainExtension: chain_extension::ChainExtension; /// The maximum number of tries that can be queued for deletion. type DeletionQueueDepth: Get; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 96bcf99bf8e81..59ec911a70544 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -143,9 +143,10 @@ impl Default for TestExtension { } } -impl ChainExtension for TestExtension { - fn call(func_id: u32, env: Environment) -> ExtensionResult +impl ChainExtension for TestExtension { + fn call(func_id: u32, env: Environment) -> ExtensionResult where + E: Ext, ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, { match func_id {