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.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,
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.rsdiffbeforeafterboth81 /// * **Key** - contract address.81 /// * **Key** - contract address.82 /// * **Value** - sponsorship state.82 /// * **Value** - sponsorship state.83 #[pallet::storage]83 #[pallet::storage]84 pub type Sponsoring<T: Config> = StorageMap<84 pub(super) type Sponsoring<T: Config> = StorageMap<85 Hasher = Twox64Concat,85 Hasher = Twox64Concat,86 Key = H160,86 Key = H160,87 Value = SponsorshipState<T::CrossAccountId>,87 Value = SponsorshipState<T::CrossAccountId>,