difftreelog
code refactor
in: master
4 files changed
pallets/app-promotion/Cargo.tomldiffbeforeafterboth393940]40]4142################################################################################43# Substrate Dependencies4445[dependencies.codec]41[dependencies]46default-features = false42scale-info = { version = "2.0.1", default-features = false, features = [43 "derive",44] }45################################################################################46# Substrate Dependencies4747features = ['derive']48codec = { default-features = false, features = ['derive'], package = 'parity-scale-codec', version = '3.1.2' }48package = 'parity-scale-codec'49version = '3.1.2'5051[dependencies.frame-benchmarking]49frame-benchmarking = {default-features = false, optional = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }52default-features = false53optional = true54git = "https://github.com/paritytech/substrate"55branch = "polkadot-v0.9.27"5657[dependencies.frame-support]50frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }58default-features = false59git = "https://github.com/paritytech/substrate"60branch = "polkadot-v0.9.27"6162[dependencies.frame-system]51frame-system ={ default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }63default-features = false64git = "https://github.com/paritytech/substrate"65branch = "polkadot-v0.9.27"6667[dependencies.pallet-balances]52pallet-balances ={ default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }68default-features = false69git = "https://github.com/paritytech/substrate"70branch = "polkadot-v0.9.27"7172[dependencies.pallet-timestamp]53pallet-timestamp ={ default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }73default-features = false74git = "https://github.com/paritytech/substrate"75branch = "polkadot-v0.9.27"7677[dependencies.pallet-randomness-collective-flip]54pallet-randomness-collective-flip ={ default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }78default-features = false79git = "https://github.com/paritytech/substrate"80branch = "polkadot-v0.9.27"8182[dependencies.sp-std]83default-features = false55pallet-evm ={ default-features = false, git = "https://github.com/uniquenetwork/frontier", branch = "unique-polkadot-v0.9.27" }84git = "https://github.com/paritytech/substrate"85branch = "polkadot-v0.9.27"8687[dependencies.serde]88default-features = false56sp-std ={ default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }89features = ['derive']90version = '1.0.130'9192[dependencies.sp-runtime]57sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }93default-features = false94git = "https://github.com/paritytech/substrate"95branch = "polkadot-v0.9.27"9697[dependencies.sp-core]58sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }98default-features = false99git = "https://github.com/paritytech/substrate"100branch = "polkadot-v0.9.27"101102[dependencies.sp-io]59sp-io ={ default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }103default-features = false104git = "https://github.com/paritytech/substrate"105branch = "polkadot-v0.9.27"106107[dependencies.pallet-evm]108default-features = false60serde = { default-features = false, features = ['derive'], version = '1.0.130' }109git = "https://github.com/uniquenetwork/frontier"110branch = "unique-polkadot-v0.9.27"11161112################################################################################62################################################################################113# local dependencies63# local dependencies64114[dependencies.up-data-structs]65up-data-structs ={ default-features = false, path = "../../primitives/data-structs" }115default-features = false116path = "../../primitives/data-structs"117118[dependencies.pallet-common]66pallet-common ={ default-features = false, path = "../common" }119default-features = false120path = "../common"121122[dependencies.pallet-unique]67pallet-unique ={ default-features = false, path = "../unique" }123default-features = false124path = "../unique"125126[dependencies.pallet-evm-contract-helpers]68pallet-evm-contract-helpers ={ default-features = false, path = "../evm-contract-helpers" }127default-features = false128path = "../evm-contract-helpers"12969130[dev-dependencies]70[dev-dependencies]131[dependencies.pallet-evm-migration]71pallet-evm-migration ={ default-features = false, path = "../evm-migration" }132default-features = false133path = "../evm-migration"13413572136################################################################################73################################################################################137138[dependencies]139scale-info = { version = "2.0.1", default-features = false, features = [140 "derive",141] }14274pallets/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.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>,