Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy fixes #810

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
62 changes: 61 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions pallets/farming/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn asset_owner<T: Config>() -> T::AccountId {
}

fn signed_origin<T: Config>(account_id: T::AccountId) -> OriginFor<T> {
RawOrigin::Signed(account_id.clone()).into()
RawOrigin::Signed(account_id).into()
}

fn prepare_pools<T: Config>(count: u32) -> (Vec<T::AccountId>, Vec<T::AssetId>) {
Expand All @@ -76,17 +76,17 @@ fn prepare_pools<T: Config>(count: u32) -> (Vec<T::AccountId>, Vec<T::AssetId>)
assert_ok!(trading_pair::Pallet::<T>::register(
signed_origin::<T>(asset_owner::<T>()),
Default::default(),
xor_asset.clone(),
other_asset.clone(),
xor_asset,
other_asset,
));

assert_ok!(pool_xyk::Pallet::<T>::initialize_pool(
signed_origin::<T>(asset_owner::<T>()),
Default::default(),
xor_asset.clone(),
other_asset.clone(),
xor_asset,
other_asset,
));
let pool = pool_xyk::Properties::<T>::get(xor_asset, other_asset.clone())
let pool = pool_xyk::Properties::<T>::get(xor_asset, other_asset)
.unwrap()
.0;
pools.push(pool);
Expand All @@ -97,7 +97,7 @@ fn prepare_pools<T: Config>(count: u32) -> (Vec<T::AccountId>, Vec<T::AssetId>)

fn prepare_good_accounts<T: Config>(count: u32, assets: &[T::AssetId]) {
let xor_asset: T::AssetId = XOR.into();
let xor_owner = assets::Pallet::<T>::asset_owner(&xor_asset).unwrap();
let xor_owner = assets::Pallet::<T>::asset_owner(xor_asset).unwrap();
for other_asset in assets {
for j in 0..count {
let account_id = utils::account::<T>(j);
Expand All @@ -109,7 +109,7 @@ fn prepare_good_accounts<T: Config>(count: u32, assets: &[T::AssetId]) {
));

assert_ok!(assets::Pallet::<T>::mint_to(
&other_asset,
other_asset,
&asset_owner::<T>(),
&account_id,
balance!(50000),
Expand All @@ -119,7 +119,7 @@ fn prepare_good_accounts<T: Config>(count: u32, assets: &[T::AssetId]) {
signed_origin::<T>(account_id),
Default::default(),
XOR.into(),
other_asset.clone(),
*other_asset,
balance!(1.1),
balance!(2.2),
balance!(1.1),
Expand Down Expand Up @@ -155,7 +155,7 @@ benchmarks! {
prepare_good_accounts::<T>(a, &assets);
Pallet::<T>::refresh_pools(T::VESTING_FREQUENCY);
let pool = pools.remove(0);
let farmers = PoolFarmers::<T>::get(&pool);
let farmers = PoolFarmers::<T>::get(pool);
let mut accounts = BTreeMap::new();
Pallet::<T>::prepare_accounts_for_vesting(T::VESTING_FREQUENCY, &mut accounts);
}: {
Expand Down
6 changes: 2 additions & 4 deletions pallets/farming/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#![cfg_attr(not(feature = "std"), no_std)]
// TODO #167: fix clippy warnings
#![allow(clippy::all)]

#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
Expand Down Expand Up @@ -173,7 +171,7 @@ impl<T: Config> Pallet<T> {
) -> Balance {
let base_asset_amt = pool_xyk::Pallet::<T>::get_base_asset_part_from_pool_account(
pool,
&trading_pair,
trading_pair,
pool_tokens,
)
.unwrap_or(0);
Expand Down Expand Up @@ -235,7 +233,7 @@ impl<T: Config> Pallet<T> {
// Vi(t)
let now_u128: u128 = now.unique_saturated_into();
let coeff = (FixedWrapper::from(balance!(1))
+ farmer_farming_time.clone() / FixedWrapper::from(balance!(now_u128)))
+ farmer_farming_time / FixedWrapper::from(balance!(now_u128)))
.pow(T::VESTING_COEFF);

coeff * farmer_weight
Expand Down
16 changes: 8 additions & 8 deletions pallets/farming/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ parameter_types! {
pub GetPswapDistributionAccountId: AccountId = AccountId32::from([3; 32]);
pub const GetDefaultSubscriptionFrequency: BlockNumber = 10;
pub const GetBurnUpdateFrequency: BlockNumber = 14400;
pub GetIncentiveAssetId: AssetId = common::PSWAP.into();
pub GetIncentiveAssetId: AssetId = common::PSWAP;
pub GetParliamentAccountId: AccountId = AccountId32::from([8; 32]);
pub RewardDoublingAssets: Vec<AssetId> = vec![VAL.into(), PSWAP.into()];
pub RewardDoublingAssets: Vec<AssetId> = vec![VAL, PSWAP];
pub GetXykFee: Fixed = fixed!(0.003);
pub GetMarketMakerRewardsAccountId: AccountId = AccountId32::from([12; 32]);
pub GetBondingCurveRewardsAccountId: AccountId = AccountId32::from([13; 32]);
Expand Down Expand Up @@ -451,7 +451,7 @@ impl Default for ExtBuilder {
(CHARLIE(), Scope::Unlimited, preset01.clone()),
(DAVE(), Scope::Unlimited, preset01.clone()),
(EVE(), Scope::Unlimited, preset01.clone()),
(FERDIE(), Scope::Unlimited, preset01.clone()),
(FERDIE(), Scope::Unlimited, preset01),
],
}
}
Expand Down Expand Up @@ -492,7 +492,7 @@ impl ExtBuilder {
assets::GenesisConfig::<Runtime> {
endowed_assets: vec![
(
XOR.into(),
XOR,
ALICE(),
AssetSymbol(b"XOR".to_vec()),
AssetName(b"SORA".to_vec()),
Expand All @@ -503,7 +503,7 @@ impl ExtBuilder {
None,
),
(
DOT.into(),
DOT,
ALICE(),
AssetSymbol(b"DOT".to_vec()),
AssetName(b"DOT".to_vec()),
Expand All @@ -514,7 +514,7 @@ impl ExtBuilder {
None,
),
(
PSWAP.into(),
PSWAP,
ALICE(),
AssetSymbol(b"PSWAP".to_vec()),
AssetName(b"PSWAP".to_vec()),
Expand All @@ -525,7 +525,7 @@ impl ExtBuilder {
None,
),
(
VAL.into(),
VAL,
ALICE(),
AssetSymbol(b"VAL".to_vec()),
AssetName(b"VAL".to_vec()),
Expand All @@ -536,7 +536,7 @@ impl ExtBuilder {
None,
),
(
XSTUSD.into(),
XSTUSD,
ALICE(),
AssetSymbol(b"XSTUSD".to_vec()),
AssetName(b"XSTUSD".to_vec()),
Expand Down
20 changes: 10 additions & 10 deletions pallets/farming/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,31 +305,31 @@ fn test() {

mock::run_to_block(VESTING_FREQUENCY);

let alice_reward = *Rewards::<Runtime>::get(&ALICE())
let alice_reward = *Rewards::<Runtime>::get(ALICE())
.rewards
.get(&RewardReason::LiquidityProvisionFarming)
.unwrap();
assert_eq!(alice_reward, balance!(147095.556665051128722662));

let bob_reward = *Rewards::<Runtime>::get(&BOB())
let bob_reward = *Rewards::<Runtime>::get(BOB())
.rewards
.get(&RewardReason::LiquidityProvisionFarming)
.unwrap();
assert_eq!(bob_reward, balance!(20230.033841899841271451));

let charlie_reward = *Rewards::<Runtime>::get(&CHARLIE())
let charlie_reward = *Rewards::<Runtime>::get(CHARLIE())
.rewards
.get(&RewardReason::LiquidityProvisionFarming)
.unwrap();
assert_eq!(charlie_reward, balance!(188323.224128231249527342));

let dave_reward = *Rewards::<Runtime>::get(&DAVE())
let dave_reward = *Rewards::<Runtime>::get(DAVE())
.rewards
.get(&RewardReason::LiquidityProvisionFarming)
.unwrap();
assert_eq!(dave_reward, balance!(41855.242431516907913566));

let eve_reward = *Rewards::<Runtime>::get(&EVE())
let eve_reward = *Rewards::<Runtime>::get(EVE())
.rewards
.get(&RewardReason::LiquidityProvisionFarming)
.unwrap();
Expand Down Expand Up @@ -372,7 +372,7 @@ fn test() {

run_to_block(VESTING_FREQUENCY + VESTING_FREQUENCY);

let info = Rewards::<Runtime>::get(&ALICE());
let info = Rewards::<Runtime>::get(ALICE());
assert_eq!(
*info
.rewards
Expand All @@ -381,7 +381,7 @@ fn test() {
balance!(362281.956723538535819602)
);

let info = Rewards::<Runtime>::get(&BOB());
let info = Rewards::<Runtime>::get(BOB());
// BOB's rewards didn't change
assert_eq!(
*info
Expand All @@ -391,7 +391,7 @@ fn test() {
balance!(20230.033841899841271451)
);

let info = Rewards::<Runtime>::get(&CHARLIE());
let info = Rewards::<Runtime>::get(CHARLIE());
assert_eq!(
*info
.rewards
Expand All @@ -400,7 +400,7 @@ fn test() {
balance!(395638.161949291391006768)
);

let info = Rewards::<Runtime>::get(&DAVE());
let info = Rewards::<Runtime>::get(DAVE());
assert_eq!(
*info
.rewards
Expand All @@ -409,7 +409,7 @@ fn test() {
balance!(73254.876962256299307236)
);

let info = Rewards::<Runtime>::get(&EVE());
let info = Rewards::<Runtime>::get(EVE());
assert_eq!(
*info
.rewards
Expand Down
5 changes: 2 additions & 3 deletions pallets/faucet/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ fn alice<T: Config>() -> T::AccountId {
fn add_assets<T: Config>(n: u32) -> Result<(), &'static str> {
let owner = alice::<T>();
frame_system::Pallet::<T>::inc_providers(&owner);
let owner_origin: <T as frame_system::Config>::RuntimeOrigin =
RawOrigin::Signed(owner.clone()).into();
let owner_origin: <T as frame_system::Config>::RuntimeOrigin = RawOrigin::Signed(owner).into();
for _i in 0..n {
Assets::<T>::register(
owner_origin.clone(),
Expand Down Expand Up @@ -99,7 +98,7 @@ benchmarks! {
reset_rewards {
add_assets::<T>(100)?;
let caller = alice::<T>();
let caller_origin: <T as frame_system::Config>::RuntimeOrigin = RawOrigin::Signed(caller.clone()).into();
let caller_origin: <T as frame_system::Config>::RuntimeOrigin = RawOrigin::Signed(caller).into();
}: {
Pallet::<T>::reset_rewards(caller_origin)?;
}
Expand Down
2 changes: 0 additions & 2 deletions pallets/faucet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#![cfg_attr(not(feature = "std"), no_std)]
// TODO #167: fix clippy warnings
#![allow(clippy::all)]

use common::{balance, AssetInfoProvider, Balance, HERMES_ASSET_ID, PSWAP, VAL, XOR};
use frame_support::ensure;
Expand Down
Loading