Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
* Clippy corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
DidacSF committed Oct 3, 2023
1 parent 9fa37ae commit 3ee9391
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 16 deletions.
1 change: 0 additions & 1 deletion pallets/ajuna-awesome-avatars/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
//! * `do_mint` - Mint avatar.
//! * `ensure_season` - Given a season id and a season, validate them.
#![feature(variant_count)]
#![cfg_attr(not(feature = "std"), no_std)]

extern crate core;
Expand Down
2 changes: 1 addition & 1 deletion pallets/ajuna-awesome-avatars/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2983,7 +2983,7 @@ mod account {
#[test]
fn upgrade_storage_should_work() {
let upgrade_fee = 12_345 as MockBalance;
let num_storage_tiers = sp_std::mem::variant_count::<StorageTier>();
let num_storage_tiers = 6;
let alice_balance = num_storage_tiers as MockBalance * upgrade_fee;
let mut treasury_balance = 0;
let total_supply = treasury_balance + alice_balance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ impl<T: Config> AvatarCombinator<T> {
season_id: SeasonId,
hash_provider: &mut HashProvider<T, 32>,
) -> Result<(LeaderForgeOutput<T>, Vec<ForgeOutput<T>>), DispatchError> {
let color_types = variant_count::<ColorType>() as u8;
let forces = variant_count::<Force>() as u8;
let color_types = 5;
let forces = 7;

let (leader_id, mut leader) = input_leader;
let mut leader_consumed = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ mod statue;
mod tinker;

use super::*;
use sp_std::mem::variant_count;

pub(super) type WrappedForgeItem<T> = (AvatarIdOf<T>, WrappedAvatar);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use crate::{
Config,
};
use sp_runtime::DispatchError;
use sp_std::{mem::variant_count, prelude::*};

pub(crate) struct AttributeMapperV2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl<T: Config> AvatarMutator<T> for EquippableItemType {
ColorType::from_byte(DnaUtils::high_nibble_of(hash_byte)),
ColorType::from_byte(DnaUtils::low_nibble_of(hash_byte)),
);
let force = Force::from_byte(hash_provider.next() % variant_count::<Force>() as u8);
let force = Force::from_byte(hash_provider.next() % 7);

AvatarBuilder::with_base_avatar(base_avatar).try_into_weapon(
&pet_type,
Expand Down Expand Up @@ -289,7 +289,7 @@ impl<T: Config> AvatarMutator<T> for SpecialItemType {
ColorType::from_byte(DnaUtils::high_nibble_of(hash_byte)),
ColorType::from_byte(DnaUtils::low_nibble_of(hash_byte)),
);
let force = Force::from_byte(hash_provider.next() % variant_count::<Force>() as u8);
let force = Force::from_byte(hash_provider.next() % 7);

AvatarBuilder::with_base_avatar(base_avatar)
.into_unidentified(color_pair, force, soul_count)
Expand Down
4 changes: 2 additions & 2 deletions pallets/ajuna-nft-staking/src/tests/ext/cancel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn works_with_token_reward() {
.build()
.execute_with(|| {
// Initial balances.
let initial_balance_bob = Balances::free_balance(&BOB);
let initial_balance_bob = Balances::free_balance(BOB);
assert_eq!(NftStake::account_balance(), reward);

// Cancel and check.
Expand Down Expand Up @@ -110,7 +110,7 @@ fn works_with_nft_reward() {
.build()
.execute_with(|| {
// Initial balances.
let initial_balance_bob = CurrencyOf::<Test>::free_balance(&BOB);
let initial_balance_bob = CurrencyOf::<Test>::free_balance(BOB);
assert_eq!(Nft::owner(reward_addr.0, reward_addr.1), Some(NftStake::account_id()));

// Cancel and check.
Expand Down
8 changes: 4 additions & 4 deletions pallets/ajuna-nft-staking/src/tests/ext/claim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ fn works_with_token_reward() {
.accept_contract(vec![(BOB, stakes)], vec![(BOB, fees)], contract_id, BOB)
.build()
.execute_with(|| {
let initial_balance = Balances::free_balance(&BOB);
let initial_balance = Balances::free_balance(BOB);
let technical_account_id = Pallet::<Test>::account_id();

assert_eq!(Balances::free_balance(&technical_account_id), reward_amount);
assert_eq!(Balances::free_balance(technical_account_id), reward_amount);

let accepted_at = ContractAccepted::<Test>::get(contract_id).unwrap();
run_to_block(accepted_at + stake_duration + claim_duration + 1);
Expand All @@ -65,7 +65,7 @@ fn works_with_token_reward() {
assert_eq!(Nft::owner(collection_id, item_id), Some(ALICE));
}
assert_eq!(Balances::free_balance(BOB), initial_balance + reward_amount);
assert_eq!(Balances::free_balance(&technical_account_id), 0);
assert_eq!(Balances::free_balance(technical_account_id), 0);

let contract_collection_id = ContractCollectionId::<Test>::get().unwrap();
assert_eq!(Nft::owner(contract_collection_id, contract_id), None);
Expand Down Expand Up @@ -171,7 +171,7 @@ fn rejects_if_token_reward_is_less_than_min_balance() {
.execute_with(|| {
let technical_account_id = Pallet::<Test>::account_id();

assert_eq!(Balances::free_balance(&technical_account_id), 0);
assert_eq!(Balances::free_balance(technical_account_id), 0);

let accepted_at = ContractAccepted::<Test>::get(contract_id).unwrap();
run_to_block(accepted_at + stake_duration);
Expand Down
2 changes: 1 addition & 1 deletion runtime/ajuna/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#![allow(clippy::items_after_test_module)]
#![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit = "256"]
Expand Down
2 changes: 1 addition & 1 deletion runtime/bajun/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#![allow(clippy::items_after_test_module)]
#![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit = "256"]
Expand Down

0 comments on commit 3ee9391

Please sign in to comment.