Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.

Commit d6078fd

Browse files
authored
Migrate tron-backing to Attribute Macro (#610)
1 parent 4d19fdf commit d6078fd

File tree

7 files changed

+90
-108
lines changed

7 files changed

+90
-108
lines changed

bin/node/cli/src/chain_spec.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ fn pangolin_build_spec_genesis() -> pangolin_runtime::GenesisConfig {
328328
darwinia_claims: Default::default(),
329329
darwinia_vesting: Default::default(),
330330
pallet_sudo: pangolin_runtime::SudoConfig { key: root.clone() },
331-
darwinia_crab_issuing: pangolin_runtime::DarwiniaCrabIssuingConfig { total_mapped_ring: BUNCH_OF_COINS },
332-
darwinia_crab_backing: pangolin_runtime::DarwiniaCrabBackingConfig { backed_ring: BUNCH_OF_COINS },
331+
darwinia_crab_issuing: pangolin_runtime::CrabIssuingConfig { total_mapped_ring: BUNCH_OF_COINS },
332+
darwinia_crab_backing: pangolin_runtime::CrabBackingConfig { backed_ring: BUNCH_OF_COINS },
333333
darwinia_ethereum_relay: pangolin_runtime::EthereumRelayConfig {
334334
genesis_header_info: (
335335
vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 232, 31, 23, 27, 204, 85, 166, 255, 131, 69, 230, 146, 192, 248, 110, 91, 72, 224, 27, 153, 108, 173, 192, 1, 98, 47, 181, 227, 99, 180, 33, 29, 204, 77, 232, 222, 199, 93, 122, 171, 133, 181, 103, 182, 204, 212, 26, 211, 18, 69, 27, 148, 138, 116, 19, 240, 161, 66, 253, 64, 212, 147, 71, 128, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 33, 123, 11, 188, 251, 114, 226, 213, 126, 40, 243, 60, 179, 97, 185, 152, 53, 19, 23, 119, 85, 220, 63, 51, 206, 62, 112, 34, 237, 98, 183, 123, 86, 232, 31, 23, 27, 204, 85, 166, 255, 131, 69, 230, 146, 192, 248, 110, 91, 72, 224, 27, 153, 108, 173, 192, 1, 98, 47, 181, 227, 99, 180, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 132, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 136, 0, 0, 0, 0, 0, 0, 0, 66, 1, 65, 148, 16, 35, 104, 9, 35, 224, 254, 77, 116, 163, 75, 218, 200, 20, 31, 37, 64, 227, 174, 144, 98, 55, 24, 228, 125, 102, 209, 202, 74, 45],
@@ -485,8 +485,8 @@ fn pangolin_development_genesis() -> pangolin_runtime::GenesisConfig {
485485
},
486486
darwinia_vesting: Default::default(),
487487
pallet_sudo: pangolin_runtime::SudoConfig { key: root.clone() },
488-
darwinia_crab_issuing: pangolin_runtime::DarwiniaCrabIssuingConfig { total_mapped_ring: BUNCH_OF_COINS },
489-
darwinia_crab_backing: pangolin_runtime::DarwiniaCrabBackingConfig { backed_ring: BUNCH_OF_COINS },
488+
darwinia_crab_issuing: pangolin_runtime::CrabIssuingConfig { total_mapped_ring: BUNCH_OF_COINS },
489+
darwinia_crab_backing: pangolin_runtime::CrabBackingConfig { backed_ring: BUNCH_OF_COINS },
490490
darwinia_ethereum_relay: pangolin_runtime::EthereumRelayConfig {
491491
genesis_header_info: (
492492
vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 232, 31, 23, 27, 204, 85, 166, 255, 131, 69, 230, 146, 192, 248, 110, 91, 72, 224, 27, 153, 108, 173, 192, 1, 98, 47, 181, 227, 99, 180, 33, 29, 204, 77, 232, 222, 199, 93, 122, 171, 133, 181, 103, 182, 204, 212, 26, 211, 18, 69, 27, 148, 138, 116, 19, 240, 161, 66, 253, 64, 212, 147, 71, 128, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 33, 123, 11, 188, 251, 114, 226, 213, 126, 40, 243, 60, 179, 97, 185, 152, 53, 19, 23, 119, 85, 220, 63, 51, 206, 62, 112, 34, 237, 98, 183, 123, 86, 232, 31, 23, 27, 204, 85, 166, 255, 131, 69, 230, 146, 192, 248, 110, 91, 72, 224, 27, 153, 108, 173, 192, 1, 98, 47, 181, 227, 99, 180, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 132, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 136, 0, 0, 0, 0, 0, 0, 0, 66, 1, 65, 148, 16, 35, 104, 9, 35, 224, 254, 77, 116, 163, 75, 218, 200, 20, 31, 37, 64, 227, 174, 144, 98, 55, 24, 228, 125, 102, 209, 202, 74, 45],

bin/node/runtime/pangolin/src/lib.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
289289
impl_name: create_runtime_str!("Pangolin"),
290290
authoring_version: 1,
291291
// crate version ~2.2.0 := >=2.2.0, <2.3.0
292-
spec_version: 222,
292+
spec_version: 223,
293293
impl_version: 1,
294294
apis: RUNTIME_API_VERSIONS,
295295
transaction_version: 1,
@@ -378,16 +378,16 @@ frame_support::construct_runtime! {
378378
// Multisig module. Late addition.
379379
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 32,
380380

381-
DarwiniaCrabIssuing: darwinia_crab_issuing::{Pallet, Call, Storage, Config, Event<T>} = 33,
382-
DarwiniaCrabBacking: darwinia_crab_backing::{Pallet, Storage, Config<T>} = 34,
381+
CrabIssuing: darwinia_crab_issuing::{Pallet, Call, Storage, Config} = 33,
382+
CrabBacking: darwinia_crab_backing::{Pallet, Storage, Config<T>} = 34,
383383

384384
EthereumRelay: darwinia_ethereum_relay::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,
385385
EthereumBacking: darwinia_ethereum_backing::{Pallet, Call, Storage, Config<T>, Event<T>} = 36,
386386
EthereumIssuing: darwinia_ethereum_issuing::{Pallet, Call, Storage, Config, Event<T>} = 42,
387387
EthereumRelayerGame: darwinia_relayer_game::<Instance0>::{Pallet, Storage} = 37,
388388
EthereumRelayAuthorities: darwinia_relay_authorities::<Instance0>::{Pallet, Call, Storage, Config<T>, Event<T>} = 38,
389389

390-
TronBacking: darwinia_tron_backing::{Pallet, Storage, Config<T>} = 39,
390+
TronBacking: darwinia_tron_backing::{Pallet, Config<T>} = 39,
391391

392392
EVM: darwinia_evm::{Pallet, Call, Storage, Config, Event<T>} = 40,
393393
Ethereum: dvm_ethereum::{Pallet, Call, Storage, Config, Event, ValidateUnsigned} = 41,
@@ -804,12 +804,11 @@ pub struct CustomOnRuntimeUpgrade;
804804
impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
805805
#[cfg(feature = "try-runtime")]
806806
fn pre_upgrade() -> Result<(), &'static str> {
807-
darwinia_balances::migration::try_runtime::pre_migrate()
807+
darwinia_crab_issuing::migration::try_runtime::pre_migrate::<Runtime>()
808808
}
809809

810810
fn on_runtime_upgrade() -> Weight {
811-
darwinia_balances::migration::migrate(b"Instance0DarwiniaBalances", b"Balances");
812-
darwinia_balances::migration::migrate(b"Instance1DarwiniaBalances", b"Kton");
811+
darwinia_crab_issuing::migration::migrate(b"CrabIssuing");
813812

814813
RuntimeBlockWeights::get().max_block
815814
}

bin/node/runtime/pangolin/src/pallets/crab_issuing.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ frame_support::parameter_types! {
88
pub const CrabIssuingModuleId: ModuleId = ModuleId(*b"da/crais");
99
}
1010
impl Config for Runtime {
11-
type Event = Event;
11+
type WeightInfo = ();
1212
type ModuleId = CrabIssuingModuleId;
1313
type RingCurrency = Ring;
14-
type WeightInfo = ();
1514
}

frame/bridge/crab/backing/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub use weights::WeightInfo;
2929
pub mod pallet {
3030
pub mod types {
3131
// --- darwinia ---
32-
use super::*;
32+
use crate::pallet::*;
3333

3434
// Generic types
3535
pub type AccountId<T> = <T as frame_system::Config>::AccountId;

frame/bridge/crab/issuing/src/lib.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
#![cfg_attr(not(feature = "std"), no_std)]
2222

2323
pub mod weights;
24-
25-
pub use pallet::*;
2624
pub use weights::WeightInfo;
2725

2826
#[cfg(test)]
@@ -34,7 +32,7 @@ mod tests;
3432
pub mod pallet {
3533
pub mod types {
3634
// --- darwinia ---
37-
use super::*;
35+
use crate::pallet::*;
3836

3937
// Generic type
4038
pub type AccountId<T> = <T as frame_system::Config>::AccountId;
@@ -58,23 +56,13 @@ pub mod pallet {
5856
#[pallet::config]
5957
pub trait Config: frame_system::Config {
6058
// --- substrate ---
61-
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
6259
type WeightInfo: WeightInfo;
6360
// --- darwinia ---
6461
#[pallet::constant]
6562
type ModuleId: Get<ModuleId>;
6663
type RingCurrency: Currency<AccountId<Self>>;
6764
}
6865

69-
#[pallet::event]
70-
pub enum Event<T: Config> {
71-
/// Dummy Event. \[who, swapped *CRING*, burned Mapped *RING*\]
72-
DummyEvent(AccountId<T>, RingBalance<T>, MappedRing),
73-
}
74-
75-
#[pallet::error]
76-
pub enum Error<T> {}
77-
7866
#[pallet::storage]
7967
#[pallet::getter(fn total_mapped_ring)]
8068
pub type TotalMappedRing<T: Config> = StorageValue<_, MappedRing>;
@@ -88,7 +76,7 @@ pub mod pallet {
8876
impl<T: Config> GenesisBuild<T> for GenesisConfig {
8977
fn build(&self) {
9078
let _ = T::RingCurrency::make_free_balance_be(
91-
&T::ModuleId::get().into_account(),
79+
&<Pallet<T>>::account_id(),
9280
T::RingCurrency::minimum_balance(),
9381
);
9482

@@ -102,7 +90,13 @@ pub mod pallet {
10290
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
10391
#[pallet::call]
10492
impl<T: Config> Pallet<T> {}
93+
impl<T: Config> Pallet<T> {
94+
pub fn account_id() -> T::AccountId {
95+
T::ModuleId::get().into_account()
96+
}
97+
}
10598
}
99+
pub use pallet::*;
106100

107101
pub mod migration {
108102
const OLD_PALLET_NAME: &[u8] = b"DarwiniaCrabIssuing";

frame/bridge/crab/issuing/src/mock.rs

+2-23
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ pub type Block = MockBlock<Test>;
3838
pub type UncheckedExtrinsic = MockUncheckedExtrinsic<Test>;
3939
pub type AccountId = u64;
4040
pub type Balance = u128;
41-
// Pallet primitives
42-
pub type CrabIssuingError = Error<Test>;
4341

4442
darwinia_support::impl_test_account_data! {}
4543

@@ -87,10 +85,9 @@ frame_support::parameter_types! {
8785
pub const CrabIssuingModuleId: ModuleId = ModuleId(*b"da/crabi");
8886
}
8987
impl Config for Test {
90-
type Event = Event;
88+
type WeightInfo = ();
9189
type ModuleId = CrabIssuingModuleId;
9290
type RingCurrency = Ring;
93-
type WeightInfo = ();
9491
}
9592

9693
frame_support::construct_runtime! {
@@ -102,7 +99,7 @@ frame_support::construct_runtime! {
10299
{
103100
System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
104101
Ring: darwinia_balances::<Instance0>::{Pallet, Call, Storage, Config<T>, Event<T>},
105-
DarwiniaCrabIssuing: darwinia_crab_issuing::{Pallet, Call, Storage, Config, Event<T>},
102+
CrabIssuing: darwinia_crab_issuing::{Pallet, Call, Storage, Config},
106103
}
107104
}
108105

@@ -129,21 +126,3 @@ pub fn new_test_ext() -> TestExternalities {
129126

130127
t.into()
131128
}
132-
133-
pub fn events() -> Vec<Event> {
134-
let events = System::events()
135-
.into_iter()
136-
.map(|evt| evt.event)
137-
.collect::<Vec<_>>();
138-
139-
System::reset_events();
140-
141-
events
142-
}
143-
144-
pub fn crab_issuing_events() -> Vec<Event> {
145-
events()
146-
.into_iter()
147-
.filter(|e| matches!(e, Event::darwinia_crab_issuing(_)))
148-
.collect()
149-
}

frame/bridge/tron/backing/src/lib.rs

+68-57
Original file line numberDiff line numberDiff line change
@@ -21,76 +21,87 @@
2121
#![cfg_attr(not(feature = "std"), no_std)]
2222

2323
pub mod weights;
24-
// --- darwinia ---
2524
pub use weights::WeightInfo;
2625

27-
mod types {
28-
// --- darwinia ---
29-
#[cfg(feature = "std")]
30-
use crate::*;
26+
#[frame_support::pallet]
27+
pub mod pallet {
28+
pub mod types {
29+
// --- darwinia ---
30+
#[cfg(feature = "std")]
31+
use crate::pallet::*;
3132

32-
pub type AccountId<T> = <T as frame_system::Config>::AccountId;
33+
pub type AccountId<T> = <T as frame_system::Config>::AccountId;
3334

34-
#[cfg(feature = "std")]
35-
pub type RingBalance<T> = <RingCurrency<T> as Currency<AccountId<T>>>::Balance;
36-
#[cfg(feature = "std")]
37-
pub type KtonBalance<T> = <KtonCurrency<T> as Currency<AccountId<T>>>::Balance;
35+
#[cfg(feature = "std")]
36+
pub type RingBalance<T> = <RingCurrency<T> as Currency<AccountId<T>>>::Balance;
37+
#[cfg(feature = "std")]
38+
pub type KtonBalance<T> = <KtonCurrency<T> as Currency<AccountId<T>>>::Balance;
3839

39-
#[cfg(feature = "std")]
40-
type RingCurrency<T> = <T as Config>::RingCurrency;
41-
#[cfg(feature = "std")]
42-
type KtonCurrency<T> = <T as Config>::KtonCurrency;
43-
}
44-
45-
// --- substrate ---
46-
use frame_support::{
47-
decl_module, decl_storage,
48-
traits::{Currency, Get},
49-
};
50-
use sp_runtime::{traits::AccountIdConversion, ModuleId};
51-
// --- darwinia ---
52-
use types::*;
53-
54-
pub trait Config: frame_system::Config {
55-
type ModuleId: Get<ModuleId>;
40+
#[cfg(feature = "std")]
41+
type RingCurrency<T> = <T as Config>::RingCurrency;
42+
#[cfg(feature = "std")]
43+
type KtonCurrency<T> = <T as Config>::KtonCurrency;
44+
}
45+
pub use types::*;
5646

57-
type RingCurrency: Currency<AccountId<Self>>;
58-
type KtonCurrency: Currency<AccountId<Self>>;
47+
// --- substrate ---
48+
use frame_support::{
49+
pallet_prelude::*,
50+
traits::{Currency, Get},
51+
};
52+
use frame_system::pallet_prelude::*;
53+
use sp_runtime::{traits::AccountIdConversion, ModuleId};
54+
// --- darwinia ---
55+
use crate::weights::WeightInfo;
5956

60-
type WeightInfo: WeightInfo;
61-
}
57+
#[pallet::config]
58+
pub trait Config: frame_system::Config {
59+
// --- substrate ---
60+
type WeightInfo: WeightInfo;
61+
// --- darwinia ---
62+
#[pallet::constant]
63+
type ModuleId: Get<ModuleId>;
64+
type RingCurrency: Currency<AccountId<Self>>;
65+
type KtonCurrency: Currency<AccountId<Self>>;
66+
}
6267

63-
decl_storage! {
64-
trait Store for Module<T: Config> as DarwiniaTronBacking {}
68+
#[pallet::genesis_config]
69+
pub struct GenesisConfig<T: Config> {
70+
pub backed_ring: RingBalance<T>,
71+
pub backed_kton: KtonBalance<T>,
72+
}
73+
#[cfg(feature = "std")]
74+
impl<T: Config> Default for GenesisConfig<T> {
75+
fn default() -> Self {
76+
GenesisConfig {
77+
backed_ring: Default::default(),
78+
backed_kton: Default::default(),
79+
}
80+
}
81+
}
82+
#[pallet::genesis_build]
83+
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
84+
fn build(&self) {
85+
let module_account = <Pallet<T>>::account_id();
6586

66-
add_extra_genesis {
67-
config(backed_ring): RingBalance<T>;
68-
config(backed_kton): KtonBalance<T>;
69-
build(|config| {
70-
let module_account = <Module<T>>::account_id();
7187
let _ = T::RingCurrency::make_free_balance_be(
7288
&module_account,
73-
T::RingCurrency::minimum_balance() + config.backed_ring
89+
T::RingCurrency::minimum_balance() + self.backed_ring,
7490
);
75-
let _ = T::KtonCurrency::make_free_balance_be(
76-
&module_account,
77-
config.backed_kton
78-
);
79-
});
91+
let _ = T::KtonCurrency::make_free_balance_be(&module_account, self.backed_kton);
92+
}
8093
}
81-
}
82-
83-
decl_module! {
84-
pub struct Module<T: Config> for enum Call
85-
where
86-
origin: T::Origin
87-
{
88-
const ModuleId: ModuleId = T::ModuleId::get();
89-
}
90-
}
9194

92-
impl<T: Config> Module<T> {
93-
pub fn account_id() -> T::AccountId {
94-
T::ModuleId::get().into_account()
95+
#[pallet::pallet]
96+
pub struct Pallet<T>(_);
97+
#[pallet::hooks]
98+
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
99+
#[pallet::call]
100+
impl<T: Config> Pallet<T> {}
101+
impl<T: Config> Pallet<T> {
102+
pub fn account_id() -> T::AccountId {
103+
T::ModuleId::get().into_account()
104+
}
95105
}
96106
}
107+
pub use pallet::*;

0 commit comments

Comments
 (0)