git.delta.rocks / unique-network / refs/commits / 95510b917c06

difftreelog

code refactor

PraetorP2022-09-07parent: #8c250ff.patch.diff
in: master

4 files changed

modifiedpallets/app-promotion/Cargo.tomldiffbeforeafterboth
before · pallets/app-promotion/Cargo.toml
1################################################################################2# Package34[package]5authors = ['Unique Network <support@uniquenetwork.io>']6description = 'Unique App Promotion Pallet'7edition = '2021'8homepage = 'https://unique.network'9license = 'GPLv3'10name = 'pallet-app-promotion'11repository = 'https://github.com/UniqueNetwork/unique-chain'12version = '0.1.0'1314[package.metadata.docs.rs]15targets = ['x86_64-unknown-linux-gnu']1617[features]18default = ['std',]19runtime-benchmarks = [20    'frame-benchmarking',21    'frame-support/runtime-benchmarks',22    'frame-system/runtime-benchmarks',23    # 'pallet-unique/runtime-benchmarks',24]25std = [26    'codec/std',27    'frame-benchmarking/std',28    'frame-support/std',29    'frame-system/std',30    'pallet-balances/std',31    'pallet-timestamp/std',32    'pallet-randomness-collective-flip/std',33    'pallet-evm/std',34    'sp-io/std',35    'sp-std/std',36    'sp-runtime/std',37    'sp-core/std',38    'serde/std',3940]4142################################################################################43# Substrate Dependencies4445[dependencies.codec]46default-features = false47features = ['derive']48package = 'parity-scale-codec'49version = '3.1.2'5051[dependencies.frame-benchmarking]52default-features = false53optional = true54git = "https://github.com/paritytech/substrate"55branch = "polkadot-v0.9.27"5657[dependencies.frame-support]58default-features = false59git = "https://github.com/paritytech/substrate"60branch = "polkadot-v0.9.27"6162[dependencies.frame-system]63default-features = false64git = "https://github.com/paritytech/substrate"65branch = "polkadot-v0.9.27"6667[dependencies.pallet-balances]68default-features = false69git = "https://github.com/paritytech/substrate"70branch = "polkadot-v0.9.27"7172[dependencies.pallet-timestamp]73default-features = false74git = "https://github.com/paritytech/substrate"75branch = "polkadot-v0.9.27"7677[dependencies.pallet-randomness-collective-flip]78default-features = false79git = "https://github.com/paritytech/substrate"80branch = "polkadot-v0.9.27"8182[dependencies.sp-std]83default-features = false84git = "https://github.com/paritytech/substrate"85branch = "polkadot-v0.9.27"8687[dependencies.serde]88default-features = false89features = ['derive']90version = '1.0.130'9192[dependencies.sp-runtime]93default-features = false94git = "https://github.com/paritytech/substrate"95branch = "polkadot-v0.9.27"9697[dependencies.sp-core]98default-features = false99git = "https://github.com/paritytech/substrate"100branch = "polkadot-v0.9.27"101102[dependencies.sp-io]103default-features = false104git = "https://github.com/paritytech/substrate"105branch = "polkadot-v0.9.27"106107[dependencies.pallet-evm]108default-features = false109git = "https://github.com/uniquenetwork/frontier"110branch = "unique-polkadot-v0.9.27"111112################################################################################113# local dependencies114[dependencies.up-data-structs]115default-features = false116path = "../../primitives/data-structs"117118[dependencies.pallet-common]119default-features = false120path = "../common"121122[dependencies.pallet-unique]123default-features = false124path = "../unique"125126[dependencies.pallet-evm-contract-helpers]127default-features = false128path = "../evm-contract-helpers"129130[dev-dependencies]131[dependencies.pallet-evm-migration]132default-features = false133path = "../evm-migration"134135136################################################################################137138[dependencies]139scale-info = { version = "2.0.1", default-features = false, features = [140    "derive",141] }
modifiedpallets/app-promotion/src/lib.rsdiffbeforeafterboth
--- a/pallets/app-promotion/src/lib.rs
+++ b/pallets/app-promotion/src/lib.rs
@@ -110,10 +110,6 @@
 		#[pallet::constant]
 		type PendingInterval: Get<Self::BlockNumber>;
 
-		// /// In chain blocks.
-		// #[pallet::constant]
-		// type Day: Get<Self::BlockNumber>; // useless
-
 		#[pallet::constant]
 		type Nominal: Get<BalanceOf<Self>>;
 
@@ -160,7 +156,7 @@
 		NotSufficientFunds,
 		PendingForBlockOverflow,
 		/// An error related to the fact that an invalid argument was passed to perform an action
-		InvalidArgument,
+		SponsorNotSet,
 	}
 
 	#[pallet::storage]
@@ -184,16 +180,6 @@
 	pub type StakesPerAccount<T: Config> =
 		StorageMap<_, Blake2_128Concat, T::AccountId, u8, ValueQuery>;
 
-	/// Amount of tokens pending unstake per user per block.
-	// #[pallet::storage]
-	// pub type PendingUnstake<T: Config> = StorageNMap<
-	// 	Key = (
-	// 		Key<Blake2_128Concat, T::AccountId>,
-	// 		Key<Twox64Concat, T::BlockNumber>,
-	// 	),
-	// 	Value = BalanceOf<T>,
-	// 	QueryKind = ValueQuery,
-	// >;
 	#[pallet::storage]
 	pub type PendingUnstake<T: Config> = StorageMap<
 		_,
@@ -202,16 +188,6 @@
 		BoundedVec<(T::AccountId, BalanceOf<T>), ConstU32<PENDING_LIMIT_PER_BLOCK>>,
 		ValueQuery,
 	>;
-
-	// /// A block when app-promotion has started .I think this is redundant, because we only need `NextInterestBlock`.
-	// #[pallet::storage]
-	// pub type StartBlock<T: Config> = StorageValue<Value = T::BlockNumber, QueryKind = ValueQuery>;
-
-	// /// Next target block when interest is recalculated
-	// #[pallet::storage]
-	// #[pallet::getter(fn get_interest_block)]
-	// pub type NextInterestBlock<T: Config> =
-	// 	StorageValue<Value = T::BlockNumber, QueryKind = ValueQuery>;
 
 	/// Stores hash a record for which the last revenue recalculation was performed.
 	/// If `None`, then recalculation has not yet been performed or calculations have been completed for all stakers.
@@ -228,7 +204,6 @@
 		{
 			let block_pending = PendingUnstake::<T>::take(current_block_number);
 			let counter = block_pending.len() as u32;
-			// add_weight(0, 1, 0);
 
 			if !block_pending.is_empty() {
 				block_pending.into_iter().for_each(|(staker, amount)| {
@@ -393,7 +368,7 @@
 			);
 
 			ensure!(
-				T::CollectionHandler::sponsor(collection_id)?.ok_or(<Error<T>>::InvalidArgument)?
+				T::CollectionHandler::sponsor(collection_id)?.ok_or(<Error<T>>::SponsorNotSet)?
 					== Self::account_id(),
 				<Error<T>>::NoPermission
 			);
@@ -425,7 +400,7 @@
 			);
 
 			ensure!(
-				T::ContractHandler::sponsor(contract_id)?.ok_or(<Error<T>>::InvalidArgument)?
+				T::ContractHandler::sponsor(contract_id)?.ok_or(<Error<T>>::SponsorNotSet)?
 					== T::CrossAccountId::from_sub(Self::account_id()),
 				<Error<T>>::NoPermission
 			);
@@ -712,14 +687,13 @@
 		staker.map_or(Some(<TotalStaked<T>>::get()), |s| {
 			Self::total_staked_by_id(s.as_sub())
 		})
-		// Self::total_staked_by_id(staker.as_sub())
 	}
 
-	pub fn cross_id_locked_balance(staker: T::CrossAccountId) -> BalanceOf<T> {
-		Self::get_locked_balance(staker.as_sub())
-			.map(|l| l.amount)
-			.unwrap_or_default()
-	}
+	// pub fn cross_id_locked_balance(staker: T::CrossAccountId) -> BalanceOf<T> {
+	// 	Self::get_locked_balance(staker.as_sub())
+	// 		.map(|l| l.amount)
+	// 		.unwrap_or_default()
+	// }
 
 	pub fn cross_id_total_staked_per_block(
 		staker: T::CrossAccountId,
modifiedpallets/app-promotion/src/types.rsdiffbeforeafterboth
--- a/pallets/app-promotion/src/types.rs
+++ b/pallets/app-promotion/src/types.rs
@@ -5,9 +5,9 @@
 use pallet_common::CollectionHandle;
 
 use sp_runtime::DispatchError;
-use up_data_structs::{CollectionId, SponsorshipState};
+use up_data_structs::{CollectionId};
 use sp_std::borrow::ToOwned;
-use pallet_evm_contract_helpers::{Pallet as EvmHelpersPallet, Config as EvmHelpersConfig, Sponsoring};
+use pallet_evm_contract_helpers::{Pallet as EvmHelpersPallet, Config as EvmHelpersConfig};
 
 pub trait ExtendedLockableCurrency<AccountId: Parameter>: LockableCurrency<AccountId> {
 	fn locks<KArg>(who: KArg) -> WeakBoundedVec<BalanceLock<Self::Balance>, Self::MaxLocks>
modifiedpallets/evm-contract-helpers/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/lib.rs
+++ b/pallets/evm-contract-helpers/src/lib.rs
@@ -81,7 +81,7 @@
 	/// * **Key** - contract address.
 	/// * **Value** - sponsorship state.
 	#[pallet::storage]
-	pub type Sponsoring<T: Config> = StorageMap<
+	pub(super) type Sponsoring<T: Config> = StorageMap<
 		Hasher = Twox64Concat,
 		Key = H160,
 		Value = SponsorshipState<T::CrossAccountId>,