difftreelog
code refactor
in: master
4 files changed
pallets/app-promotion/Cargo.tomldiffbeforeafterboth--- a/pallets/app-promotion/Cargo.toml
+++ b/pallets/app-promotion/Cargo.toml
@@ -15,7 +15,7 @@
targets = ['x86_64-unknown-linux-gnu']
[features]
-default = ['std',]
+default = ['std']
runtime-benchmarks = [
'frame-benchmarking',
'frame-support/runtime-benchmarks',
@@ -38,104 +38,36 @@
'serde/std',
]
-
+[dependencies]
+scale-info = { version = "2.0.1", default-features = false, features = [
+ "derive",
+] }
################################################################################
# Substrate Dependencies
-
-[dependencies.codec]
-default-features = false
-features = ['derive']
-package = 'parity-scale-codec'
-version = '3.1.2'
-
-[dependencies.frame-benchmarking]
-default-features = false
-optional = true
-git = "https://github.com/paritytech/substrate"
-branch = "polkadot-v0.9.27"
-
-[dependencies.frame-support]
-default-features = false
-git = "https://github.com/paritytech/substrate"
-branch = "polkadot-v0.9.27"
-
-[dependencies.frame-system]
-default-features = false
-git = "https://github.com/paritytech/substrate"
-branch = "polkadot-v0.9.27"
-[dependencies.pallet-balances]
-default-features = false
-git = "https://github.com/paritytech/substrate"
-branch = "polkadot-v0.9.27"
-
-[dependencies.pallet-timestamp]
-default-features = false
-git = "https://github.com/paritytech/substrate"
-branch = "polkadot-v0.9.27"
-
-[dependencies.pallet-randomness-collective-flip]
-default-features = false
-git = "https://github.com/paritytech/substrate"
-branch = "polkadot-v0.9.27"
-
-[dependencies.sp-std]
-default-features = false
-git = "https://github.com/paritytech/substrate"
-branch = "polkadot-v0.9.27"
-
-[dependencies.serde]
-default-features = false
-features = ['derive']
-version = '1.0.130'
-
-[dependencies.sp-runtime]
-default-features = false
-git = "https://github.com/paritytech/substrate"
-branch = "polkadot-v0.9.27"
-
-[dependencies.sp-core]
-default-features = false
-git = "https://github.com/paritytech/substrate"
-branch = "polkadot-v0.9.27"
-
-[dependencies.sp-io]
-default-features = false
-git = "https://github.com/paritytech/substrate"
-branch = "polkadot-v0.9.27"
-
-[dependencies.pallet-evm]
-default-features = false
-git = "https://github.com/uniquenetwork/frontier"
-branch = "unique-polkadot-v0.9.27"
+codec = { default-features = false, features = ['derive'], package = 'parity-scale-codec', version = '3.1.2' }
+frame-benchmarking = {default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+frame-system ={ default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+pallet-balances ={ default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+pallet-timestamp ={ default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+pallet-randomness-collective-flip ={ default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+pallet-evm ={ default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.27" }
+sp-std ={ default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+sp-io ={ default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
+serde = { default-features = false, features = ['derive'], version = '1.0.130' }
################################################################################
# local dependencies
-[dependencies.up-data-structs]
-default-features = false
-path = "../../primitives/data-structs"
-[dependencies.pallet-common]
-default-features = false
-path = "../common"
-
-[dependencies.pallet-unique]
-default-features = false
-path = "../unique"
+up-data-structs ={ default-features = false, path = "../../primitives/data-structs" }
+pallet-common ={ default-features = false, path = "../common" }
+pallet-unique ={ default-features = false, path = "../unique" }
+pallet-evm-contract-helpers ={ default-features = false, path = "../evm-contract-helpers" }
-[dependencies.pallet-evm-contract-helpers]
-default-features = false
-path = "../evm-contract-helpers"
-
[dev-dependencies]
-[dependencies.pallet-evm-migration]
-default-features = false
-path = "../evm-migration"
-
+pallet-evm-migration ={ default-features = false, path = "../evm-migration" }
################################################################################
-
-[dependencies]
-scale-info = { version = "2.0.1", default-features = false, features = [
- "derive",
-] }
pallets/app-promotion/src/lib.rsdiffbeforeafterboth110 #[pallet::constant]110 #[pallet::constant]111 type PendingInterval: Get<Self::BlockNumber>;111 type PendingInterval: Get<Self::BlockNumber>;112113 // /// In chain blocks.114 // #[pallet::constant]115 // type Day: Get<Self::BlockNumber>; // useless116112117 #[pallet::constant]113 #[pallet::constant]118 type Nominal: Get<BalanceOf<Self>>;114 type Nominal: Get<BalanceOf<Self>>;160 NotSufficientFunds,156 NotSufficientFunds,161 PendingForBlockOverflow,157 PendingForBlockOverflow,162 /// An error related to the fact that an invalid argument was passed to perform an action158 /// An error related to the fact that an invalid argument was passed to perform an action163 InvalidArgument,159 SponsorNotSet,164 }160 }165161166 #[pallet::storage]162 #[pallet::storage]184 pub type StakesPerAccount<T: Config> =180 pub type StakesPerAccount<T: Config> =185 StorageMap<_, Blake2_128Concat, T::AccountId, u8, ValueQuery>;181 StorageMap<_, Blake2_128Concat, T::AccountId, u8, ValueQuery>;186182187 /// Amount of tokens pending unstake per user per block.188 // #[pallet::storage]189 // pub type PendingUnstake<T: Config> = StorageNMap<190 // Key = (191 // Key<Blake2_128Concat, T::AccountId>,192 // Key<Twox64Concat, T::BlockNumber>,193 // ),194 // Value = BalanceOf<T>,195 // QueryKind = ValueQuery,196 // >;197 #[pallet::storage]183 #[pallet::storage]198 pub type PendingUnstake<T: Config> = StorageMap<184 pub type PendingUnstake<T: Config> = StorageMap<199 _,185 _,203 ValueQuery,189 ValueQuery,204 >;190 >;205206 // /// A block when app-promotion has started .I think this is redundant, because we only need `NextInterestBlock`.207 // #[pallet::storage]208 // pub type StartBlock<T: Config> = StorageValue<Value = T::BlockNumber, QueryKind = ValueQuery>;209210 // /// Next target block when interest is recalculated211 // #[pallet::storage]212 // #[pallet::getter(fn get_interest_block)]213 // pub type NextInterestBlock<T: Config> =214 // StorageValue<Value = T::BlockNumber, QueryKind = ValueQuery>;215191216 /// Stores hash a record for which the last revenue recalculation was performed.192 /// Stores hash a record for which the last revenue recalculation was performed.217 /// If `None`, then recalculation has not yet been performed or calculations have been completed for all stakers.193 /// If `None`, then recalculation has not yet been performed or calculations have been completed for all stakers.228 {204 {229 let block_pending = PendingUnstake::<T>::take(current_block_number);205 let block_pending = PendingUnstake::<T>::take(current_block_number);230 let counter = block_pending.len() as u32;206 let counter = block_pending.len() as u32;231 // add_weight(0, 1, 0);232207233 if !block_pending.is_empty() {208 if !block_pending.is_empty() {234 block_pending.into_iter().for_each(|(staker, amount)| {209 block_pending.into_iter().for_each(|(staker, amount)| {393 );368 );394369395 ensure!(370 ensure!(396 T::CollectionHandler::sponsor(collection_id)?.ok_or(<Error<T>>::InvalidArgument)?371 T::CollectionHandler::sponsor(collection_id)?.ok_or(<Error<T>>::SponsorNotSet)?397 == Self::account_id(),372 == Self::account_id(),398 <Error<T>>::NoPermission373 <Error<T>>::NoPermission399 );374 );425 );400 );426401427 ensure!(402 ensure!(428 T::ContractHandler::sponsor(contract_id)?.ok_or(<Error<T>>::InvalidArgument)?403 T::ContractHandler::sponsor(contract_id)?.ok_or(<Error<T>>::SponsorNotSet)?429 == T::CrossAccountId::from_sub(Self::account_id()),404 == T::CrossAccountId::from_sub(Self::account_id()),430 <Error<T>>::NoPermission405 <Error<T>>::NoPermission431 );406 );712 staker.map_or(Some(<TotalStaked<T>>::get()), |s| {687 staker.map_or(Some(<TotalStaked<T>>::get()), |s| {713 Self::total_staked_by_id(s.as_sub())688 Self::total_staked_by_id(s.as_sub())714 })689 })715 // Self::total_staked_by_id(staker.as_sub())716 }690 }717691718 pub fn cross_id_locked_balance(staker: T::CrossAccountId) -> BalanceOf<T> {692 // pub fn cross_id_locked_balance(staker: T::CrossAccountId) -> BalanceOf<T> {719 Self::get_locked_balance(staker.as_sub())693 // Self::get_locked_balance(staker.as_sub())720 .map(|l| l.amount)694 // .map(|l| l.amount)721 .unwrap_or_default()695 // .unwrap_or_default()722 }696 // }723697724 pub fn cross_id_total_staked_per_block(698 pub fn cross_id_total_staked_per_block(725 staker: T::CrossAccountId,699 staker: T::CrossAccountId,pallets/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>
pallets/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>,