pub struct Pallet<T>(/* private fields */);
Expand description
The Pallet
struct, the main type that implements traits and standalone
functions within the pallet.
Implementations§
Source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
Sourcepub fn get_callback(
owner: &T::AccountId,
callback_name: Vec<u8>,
) -> Option<T::AccountId>
pub fn get_callback( owner: &T::AccountId, callback_name: Vec<u8>, ) -> Option<T::AccountId>
Retrieves the callback registered by a given owner for a specific callback name.
This function first checks for a specific callback registered by the owner and, if not found, falls back to the global callback registered by the owner.
§Arguments
owner
- The account id of the owner of the registered callback.callback_name
- The name of the callback to be fetched.
Sourcepub fn execute<R>(
hook_point: HookPoint<T::AccountId>,
) -> Result<R, DispatchError>where
R: Decode,
pub fn execute<R>(
hook_point: HookPoint<T::AccountId>,
) -> Result<R, DispatchError>where
R: Decode,
Executes the logic associated with a given hook point.
This function is responsible for invoking the callback logic registered for a hook point.
§Arguments
hook_point
- A struct containing details about the hook point to be executed.
Sourcepub fn install(
contract_deployment: ContractDeployment<T::AccountId>,
) -> Result<T::AccountId, DispatchError>
pub fn install( contract_deployment: ContractDeployment<T::AccountId>, ) -> Result<T::AccountId, DispatchError>
Deploys an ink! contract into the runtime.
This function handles the instantiation of an ink! contract, making it available for interaction.
§Arguments
contract_deployment
: An instance of theContractDeployment
struct containing all the necessary details for deployment.
Sourcepub fn create(
callback: &str,
owner: T::AccountId,
origin: T::AccountId,
) -> HookPoint<T::AccountId>
pub fn create( callback: &str, owner: T::AccountId, origin: T::AccountId, ) -> HookPoint<T::AccountId>
Initializes and returns a new hook point.
This function creates a new hook point, which can be further customized and then executed.
§Arguments
callback
- The fully qualified name of the callback to be associated with the hook point.owner
- The account id of the owner of the hook point.origin
- The account id initiating the creation of the hook point.
Sourcepub fn prepare_deployment(
constructor: &str,
creator: T::AccountId,
code: Vec<u8>,
salt: Vec<u8>,
) -> ContractDeployment<T::AccountId>
pub fn prepare_deployment( constructor: &str, creator: T::AccountId, code: Vec<u8>, salt: Vec<u8>, ) -> ContractDeployment<T::AccountId>
Prepares the details for a new contract deployment.
This function assists in creating a ContractDeployment
instance by setting up the necessary data,
such as the selector derived from the given constructor. The created instance can then be further customized
with initial arguments using the add_init_arg
method.
§Arguments
constructor
- A string representing the constructor identifier.creator
- The account ID of the entity deploying the contract.code
- The compiled wasm code of the ink! contract.salt
- A unique salt to ensure the resulting contract address is unique.
§Returns
A new ContractDeployment
instance.
Source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
Sourcepub fn register_global_callback(
origin: OriginFor<T>,
contract: T::AccountId,
) -> DispatchResult
pub fn register_global_callback( origin: OriginFor<T>, contract: T::AccountId, ) -> DispatchResult
Register a global ink! callback for an address.
This contract is used for each callback within the substrate system. It allows a user to set a default callback contract that will be triggered for any hook point unless a specific callback is set.
contract
: The contract address to use as the endpoint for all callbacks.
Sourcepub fn register_specific_callback(
origin: OriginFor<T>,
contract: T::AccountId,
id: Vec<u8>,
) -> DispatchResult
pub fn register_specific_callback( origin: OriginFor<T>, contract: T::AccountId, id: Vec<u8>, ) -> DispatchResult
Register a specific ink! callback for an address.
Allows a user to set a callback for a specific hook point. This will take precedence over the global callback for the given hook point.
contract
: Contract address to use as the endpoint for this specific callback.id
: Identifier for this registration.
Source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
Sourcepub fn callbacks<KArg>(k: KArg) -> Option<T::AccountId>where
KArg: EncodeLike<T::AccountId>,
pub fn callbacks<KArg>(k: KArg) -> Option<T::AccountId>where
KArg: EncodeLike<T::AccountId>,
An auto-generated getter for GlobalCallbacks
.
Source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
Sourcepub fn specific_callbacks<KArg1, KArg2>(
k1: KArg1,
k2: KArg2,
) -> Option<T::AccountId>
pub fn specific_callbacks<KArg1, KArg2>( k1: KArg1, k2: KArg2, ) -> Option<T::AccountId>
An auto-generated getter for SpecificCallbacks
.
Trait Implementations§
Source§impl<T: Config> GetStorageVersion for Pallet<T>
impl<T: Config> GetStorageVersion for Pallet<T>
Source§fn current_storage_version() -> Self::CurrentStorageVersion
fn current_storage_version() -> Self::CurrentStorageVersion
Source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
Source§impl<T: Config> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
Source§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
Source§fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumber, _remaining_weight: Weight) -> Weight
on_finalize
). Read moreSource§fn on_initialize(_n: BlockNumber) -> Weight
fn on_initialize(_n: BlockNumber) -> Weight
Source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Source§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
Source§fn integrity_test()
fn integrity_test()
Source§impl<T: Config> IntegrityTest for Pallet<T>
impl<T: Config> IntegrityTest for Pallet<T>
Source§fn integrity_test()
fn integrity_test()
Source§impl<T: Config> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
Source§fn offchain_worker(n: BlockNumberFor<T>)
fn offchain_worker(n: BlockNumberFor<T>)
Source§impl<T: Config> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
Source§fn on_finalize(n: BlockNumberFor<T>)
fn on_finalize(n: BlockNumberFor<T>)
Source§impl<T: Config> OnGenesis for Pallet<T>
impl<T: Config> OnGenesis for Pallet<T>
Source§fn on_genesis()
fn on_genesis()
Source§impl<T: Config> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
Source§impl<T: Config> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
impl<T: Config> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
Source§fn on_initialize(n: BlockNumberFor<T>) -> Weight
fn on_initialize(n: BlockNumberFor<T>) -> Weight
Source§impl<T: Config> OnRuntimeUpgrade for Pallet<T>
impl<T: Config> OnRuntimeUpgrade for Pallet<T>
Source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Source§impl<T: Config> PalletInfoAccess for Pallet<T>
impl<T: Config> PalletInfoAccess for Pallet<T>
Source§fn module_name() -> &'static str
fn module_name() -> &'static str
Source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
Source§impl<T: Config> PalletsInfoAccess for Pallet<T>
impl<T: Config> PalletsInfoAccess for Pallet<T>
Source§impl<T: Config> StorageInfoTrait for Pallet<T>
impl<T: Config> StorageInfoTrait for Pallet<T>
fn storage_info() -> Vec<StorageInfo>
Source§impl<T: Config> WhitelistedStorageKeys for Pallet<T>
impl<T: Config> WhitelistedStorageKeys for Pallet<T>
Source§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
Vec<TrackedStorageKey>
indicating the storage keys that
should be whitelisted during benchmarking. This means that those keys
will be excluded from the benchmarking performance calculation.impl<T> Eq for Pallet<T>
Auto Trait Implementations§
impl<T> Freeze for Pallet<T>
impl<T> RefUnwindSafe for Pallet<T>where
T: RefUnwindSafe,
impl<T> Send for Pallet<T>where
T: Send,
impl<T> Sync for Pallet<T>where
T: Sync,
impl<T> Unpin for Pallet<T>where
T: Unpin,
impl<T> UnwindSafe for Pallet<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read moreSource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.