Crate pallet_gear_program
source ·Expand description
§Gear Program Pallet
The Gear Program Pallet provides functionality for storing programs and binary codes.
§Overview
The Gear Program Pallet’s main aim is to separate programs and binary codes storages out of Gear’s execution logic and provide soft functionality to manage them.
The Gear Program Pallet provides functions for:
- Add/remove/check existence for binary codes;
- Get original binary code, instrumented binary code and associated metadata;
- Update instrumented binary code in the storage;
- Add/remove/check existence for programs;
- Get program data;
- Update program in the storage;
- Work with program memory pages and messages for uninitialized programs.
§Interface
The Gear Program Pallet implements gear_common::{CodeStorage, ProgramStorage}
traits
and shouldn’t contain any other functionality, except this trait declares.
§Usage
How to use the functionality from the Gear Program Pallet:
- Implement the pallet
Config
for your runtime.
ⓘ
// `runtime/src/lib.rs`
// ... //
impl pallet_gear_program::Config for Runtime {}
// ... //
- Provide associated type for your pallet’s
Config
, which implementsgear_common::{CodeStorage, ProgramStorage}
traits, specifying associated types if needed.
ⓘ
// `some_pallet/src/lib.rs`
// ... //
use gear_common::{CodeStorage, ProgramStorage};
#[pallet::config]
pub trait Config: frame_system::Config {
// .. //
type CodeStorage: CodeStorage;
type ProgramStorage: ProgramStorage;
// .. //
}
- Declare Gear Program Pallet in your
construct_runtime!
macro.
ⓘ
// `runtime/src/lib.rs`
// ... //
construct_runtime!(
pub enum Runtime
where // ... //
{
// ... //
GearProgram: pallet_gear_program,
// ... //
}
);
// ... //
- Set
GearProgram
as your palletConfig
’s{CodeStorage, ProgramStorage}
types.
ⓘ
// `runtime/src/lib.rs`
// ... //
impl some_pallet::Config for Runtime {
// ... //
type CodeStorage = GearProgram;
type ProgramStorage = GearProgram;
// ... //
}
// ... //
- Work with Gear Program Pallet in your pallet with provided associated type interface.
§Genesis config
The Gear Program Pallet doesn’t depend on the GenesisConfig
.
Re-exports§
pub use pallet::*;
Modules§
- The
pallet
module in each FRAME pallet hosts the most important items needed to construct this pallet.