git.delta.rocks / unique-network / refs/commits / fb505f1dbf88

difftreelog

feat(pallet common) added GenesisConfig

PraetorP2023-04-19parent: #2c040b3.patch.diff
in: master

2 files changed

modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
167 .map(|k| (k, 1 << 100))167 .map(|k| (k, 1 << 100))
168 .collect(),168 .collect(),
169 },169 },
170 common: Default::default(),
170 treasury: Default::default(),171 treasury: Default::default(),
171 tokens: TokensConfig { balances: vec![] },172 tokens: TokensConfig { balances: vec![] },
172 sudo: SudoConfig {173 sudo: SudoConfig {
225 .expect("WASM binary was not build, please build it!")226 .expect("WASM binary was not build, please build it!")
226 .to_vec(),227 .to_vec(),
227 },228 },
229 common: Default::default(),
228 balances: BalancesConfig {230 balances: BalancesConfig {
229 balances: $endowed_accounts231 balances: $endowed_accounts
230 .iter()232 .iter()
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -420,10 +420,11 @@
 
 #[frame_support::pallet]
 pub mod pallet {
+	use core::marker::PhantomData;
+
 	use super::*;
 	use dispatch::CollectionDispatch;
 	use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key, traits::StorageVersion};
-	use frame_system::pallet_prelude::*;
 	use frame_support::traits::Currency;
 	use up_data_structs::{TokenId, mapping::TokenAddressMapping};
 	use scale_info::TypeInfo;
@@ -479,6 +480,22 @@
 		}
 	}
 
+	#[pallet::genesis_config]
+	pub struct GenesisConfig<T>(PhantomData<T>);
+
+	#[cfg(feature = "std")]
+	impl<T: Config> Default for GenesisConfig<T> {
+		fn default() -> Self {
+			Self(Default::default())
+		}
+	}
+
+	#[pallet::genesis_build]
+	impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
+		fn build(&self) {
+			StorageVersion::new(1).put::<Pallet<T>>();
+		}
+	}
 	impl<T: Config> Pallet<T> {
 		/// Helper function that handles deposit events
 		pub fn deposit_event(event: Event<T>) {