diff --git a/frame/bridge/crab/backing/src/lib.rs b/frame/bridge/crab/backing/src/lib.rs index ad0a951d6c..3087c18ac3 100644 --- a/frame/bridge/crab/backing/src/lib.rs +++ b/frame/bridge/crab/backing/src/lib.rs @@ -20,66 +20,79 @@ #![cfg_attr(not(feature = "std"), no_std)] +pub use pallet::*; + pub mod weights; // --- darwinia --- pub use weights::WeightInfo; +use frame_support::traits::Currency; + mod types { // --- darwinia --- - #[cfg(feature = "std")] use crate::*; pub type AccountId = ::AccountId; - #[cfg(feature = "std")] - pub type RingBalance = as Currency>>::Balance; - - #[cfg(feature = "std")] type RingCurrency = ::RingCurrency; + + pub type RingBalance = as Currency>>::Balance; } -// --- substrate --- -use frame_support::{ - decl_module, decl_storage, - traits::{Currency, Get}, -}; -use sp_runtime::{traits::AccountIdConversion, ModuleId}; -// --- darwinia --- -use types::*; +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_support::traits::{Currency, Get}; + use frame_system::pallet_prelude::*; + use sp_runtime::{traits::AccountIdConversion, ModuleId}; + use types::*; -pub trait Config: frame_system::Config { - type ModuleId: Get; + /// Configure the pallet by specifying the parameters and types on which it depends. + #[pallet::config] + pub trait Config: frame_system::Config { + #[pallet::constant] + type ModuleId: Get; - type RingCurrency: Currency>; + // type RingCurrency: Currency<::AccountId>; + type RingCurrency: Currency>; - type WeightInfo: WeightInfo; -} + type WeightInfo: WeightInfo; -decl_storage! { - trait Store for Module as DarwiniaCrabBacking {} + // no event for this pallet + } - add_extra_genesis { - config(backed_ring): RingBalance; - build(|config| { - let _ = T::RingCurrency::make_free_balance_be( - &>::account_id(), - T::RingCurrency::minimum_balance() + config.backed_ring - ); - }); + // Define the pallet struct placeholder, various pallet function are implemented on it. + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::hooks] + impl Hooks> for Pallet {} + + #[pallet::call] + impl Pallet {} + + #[pallet::genesis_config] + pub struct GenesisConfig { + pub backed_ring: RingBalance, } -} -decl_module! { - pub struct Module for enum Call - where - origin: T::Origin - { - const ModuleId: ModuleId = T::ModuleId::get(); + #[cfg(feature = "std")] + impl Default for GenesisConfig { + fn default() -> Self { + Self { + backed_ring: Default::default(), + } + } } -} -impl Module { - pub fn account_id() -> T::AccountId { - T::ModuleId::get().into_account() + #[pallet::genesis_build] + impl GenesisBuild for GenesisConfig { + fn build(&self) { + let _ = T::RingCurrency::make_free_balance_be( + &T::ModuleId::get().into_account(), + T::RingCurrency::minimum_balance() + self.backed_ring, + ); + } } }