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

Commit

Permalink
* Adjusted toolchain
Browse files Browse the repository at this point in the history
* Adjusted worklfow
  • Loading branch information
DidacSF committed Feb 15, 2024
1 parent 13dbcaf commit bd48133
Show file tree
Hide file tree
Showing 14 changed files with 221 additions and 213 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ jobs:
matrix:
runtime: [ajuna]
env:
SUBWASM_VERSION: v0.19.1
SUBWASM_VERSION: v0.20.0
steps:
- uses: actions/checkout@v3
- id: srtool_build
uses: chevdor/srtool-actions@v0.7.0
uses: chevdor/srtool-actions@v0.9.2
with:
image: paritytech/srtool
chain: ${{ matrix.runtime }}
tag: 1.74.0
tag: 1.74.0-0.13.0
- name: Install subwasm {{ env.SUBWASM_VERSION }}
run: |
wget https://github.com/chevdor/subwasm/releases/download/${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_${{ env.SUBWASM_VERSION }}.deb -O subwasm.deb
Expand Down
28 changes: 14 additions & 14 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ ARG bin
COPY . /ajuna
WORKDIR /ajuna

RUN rustup component add rust-src

RUN apt update && apt install -y git clang curl libssl-dev llvm libudev-dev cmake protobuf-compiler
RUN cargo build --locked --release --no-default-features --features ${features} --bin ${bin}

Expand Down
25 changes: 13 additions & 12 deletions 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 Expand Up @@ -611,8 +610,8 @@ pub mod pallet {
let avatar = Self::ensure_ownership(&seller, &avatar_id)?;
let (current_season_id, Season { fee, .. }) = Self::current_season_with_id()?;
let trade_fee = fee.buy_minimum.max(
price.saturating_mul(fee.buy_percent.unique_saturated_into()) /
MAX_PERCENTAGE.unique_saturated_into(),
price.saturating_mul(fee.buy_percent.unique_saturated_into())
/ MAX_PERCENTAGE.unique_saturated_into(),
);
T::Currency::withdraw(&buyer, trade_fee, WithdrawReasons::FEE, AllowDeath)?;
Self::deposit_into_treasury(&avatar.season_id, trade_fee);
Expand Down Expand Up @@ -713,9 +712,9 @@ pub mod pallet {

let (current_season_id, season) = Self::current_season_with_id()?;
ensure!(
season_id < current_season_id ||
(season_id == current_season_id &&
<frame_system::Pallet<T>>::block_number() > season.end),
season_id < current_season_id
|| (season_id == current_season_id
&& <frame_system::Pallet<T>>::block_number() > season.end),
Error::<T>::CannotClaimDuringSeason
);

Expand Down Expand Up @@ -1168,8 +1167,8 @@ pub mod pallet {
.try_push(*avatar_id)
.map_err(|_| Error::<T>::MaxOwnershipReached)?;
ensure!(
to_avatar_ids.len() <=
PlayerSeasonConfigs::<T>::get(to, season_id).storage_tier as usize,
to_avatar_ids.len()
<= PlayerSeasonConfigs::<T>::get(to, season_id).storage_tier as usize,
Error::<T>::MaxOwnershipReached
);

Expand Down Expand Up @@ -1331,8 +1330,9 @@ pub mod pallet {
avatar_ids: vec![(leader_id, upgraded_components)],
});
},
LeaderForgeOutput::Consumed(leader_id) =>
Self::remove_avatar_from(player, season_id, &leader_id),
LeaderForgeOutput::Consumed(leader_id) => {
Self::remove_avatar_from(player, season_id, &leader_id)
},
}

Ok(())
Expand All @@ -1358,8 +1358,9 @@ pub mod pallet {
Self::try_add_avatar_to(player, season_id, avatar_id, avatar)?;
minted_avatars.push(avatar_id);
},
ForgeOutput::Consumed(avatar_id) =>
Self::remove_avatar_from(player, season_id, &avatar_id),
ForgeOutput::Consumed(avatar_id) => {
Self::remove_avatar_from(player, season_id, &avatar_id)
},
}
}

Expand Down
17 changes: 9 additions & 8 deletions pallets/ajuna-awesome-avatars/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,8 +969,9 @@ mod minting {

// initial checks
match payment {
MintPayment::Normal =>
assert_eq!(Balances::total_balance(&ALICE), initial_balance),
MintPayment::Normal => {
assert_eq!(Balances::total_balance(&ALICE), initial_balance)
},
MintPayment::Free => assert_eq!(
PlayerConfigs::<Test>::get(ALICE).free_mints,
initial_free_mints
Expand Down Expand Up @@ -1180,9 +1181,9 @@ mod minting {
.map(|avatar_id| Avatars::<Test>::get(avatar_id).unwrap())
.collect::<Vec<_>>();
assert!(minted.iter().all(|(owner, avatar)| {
owner == &ALICE &&
(avatar.souls >= 1 && avatar.souls <= 100) &&
avatar.season_id == 1
owner == &ALICE
&& (avatar.souls >= 1 && avatar.souls <= 100)
&& avatar.season_id == 1
}));
}
});
Expand Down Expand Up @@ -1844,8 +1845,8 @@ mod forging {
// check for souls accumulation
assert_eq!(
forged_leader.souls,
original_leader.souls +
original_sacrifices.iter().map(|x| x.souls).sum::<SoulCount>(),
original_leader.souls
+ original_sacrifices.iter().map(|x| x.souls).sum::<SoulCount>(),
);

// check for the upgraded DNA
Expand Down Expand Up @@ -2938,7 +2939,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_u8;
let forces = 7_u8;

let (leader_id, mut leader) = input_leader;
let mut leader_consumed = false;
Expand All @@ -20,19 +20,19 @@ impl<T: Config> AvatarCombinator<T> {
// If we consumed the leader in a previous step, we collect all
// sacrifices and skip all future loops
other_output.push(ForgeOutput::Forged((sacrifice_id, sacrifice), 0));
continue
continue;
}

let leader_quantity = AvatarUtils::read_attribute(&leader, &AvatarAttributes::Quantity);
let sacrifice_quantity =
AvatarUtils::read_attribute(&sacrifice, &AvatarAttributes::Quantity);

if leader_quantity < GLIMMER_FORGE_GLIMMER_USE ||
sacrifice_quantity < GLIMMER_FORGE_MATERIAL_USE
if leader_quantity < GLIMMER_FORGE_GLIMMER_USE
|| sacrifice_quantity < GLIMMER_FORGE_MATERIAL_USE
{
// If we skip the loop then the sacrifice remains unused
other_output.push(ForgeOutput::Forged((sacrifice_id, sacrifice), 0));
continue
continue;
}

let (_, consumed, out_leader_souls) =
Expand Down Expand Up @@ -69,8 +69,8 @@ impl<T: Config> AvatarCombinator<T> {
);
gen_avatar =
gen_avatar.into_egg(&RarityTier::Rare, 0x00, soul_points, progress_array);
} else if rand_1 ==
(AvatarUtils::high_nibble_of(rand_1) + AvatarUtils::low_nibble_of(rand_2))
} else if rand_1
== (AvatarUtils::high_nibble_of(rand_1) + AvatarUtils::low_nibble_of(rand_2))
{
let color_pair = (
ColorType::from_byte(rand_1 % (color_types + 1)),
Expand Down Expand Up @@ -102,9 +102,9 @@ impl<T: Config> AvatarCombinator<T> {
);
gen_avatar = gen_avatar.into_glow_spark(&force, soul_points, progress_array);
}
} else if (rand_0 as u32 * SCALING_FACTOR_PERC <
(GLIMMER_PROB_PERC * TOOLBOX_PERC) * MAX_BYTE) &&
AvatarUtils::can_use_avatar(&leader, GLIMMER_FORGE_TOOLBOX_USE)
} else if (rand_0 as u32 * SCALING_FACTOR_PERC
< (GLIMMER_PROB_PERC * TOOLBOX_PERC) * MAX_BYTE)
&& AvatarUtils::can_use_avatar(&leader, GLIMMER_FORGE_TOOLBOX_USE)
{
let (_, consumed, out_leader_souls) =
AvatarUtils::use_avatar(&mut leader, GLIMMER_FORGE_TOOLBOX_USE);
Expand Down Expand Up @@ -265,10 +265,11 @@ mod test {
let sacrifice_3 = create_random_material(&ALICE, &MaterialItemType::Ceramics, 20);
let sacrifice_4 = create_random_material(&ALICE, &MaterialItemType::Metals, 20);

let total_soul_points =
leader.1.souls +
sacrifice_1.1.souls + sacrifice_2.1.souls +
sacrifice_3.1.souls + sacrifice_4.1.souls;
let total_soul_points = leader.1.souls
+ sacrifice_1.1.souls
+ sacrifice_2.1.souls
+ sacrifice_3.1.souls
+ sacrifice_4.1.souls;

let (leader_output, sacrifice_output) = AvatarCombinator::<Test>::glimmer_avatars(
leader,
Expand Down Expand Up @@ -362,8 +363,8 @@ mod test {
let qty = AvatarUtils::read_attribute(avatar, &AvatarAttributes::Quantity);

assert!(
(item_sub_type == SpecialItemType::Dust && qty == 5) ||
(item_sub_type == SpecialItemType::ToolBox && qty == 1)
(item_sub_type == SpecialItemType::Dust && qty == 5)
|| (item_sub_type == SpecialItemType::ToolBox && qty == 1)
);
} else {
panic!("ForgeOutput should have been Minted!")
Expand Down Expand Up @@ -392,10 +393,11 @@ mod test {
let sacrifice_3 = create_random_material(&ALICE, &MaterialItemType::Ceramics, 20);
let sacrifice_4 = create_random_material(&ALICE, &MaterialItemType::Metals, 20);

let total_soul_points =
leader.1.souls +
sacrifice_1.1.souls + sacrifice_2.1.souls +
sacrifice_3.1.souls + sacrifice_4.1.souls;
let total_soul_points = leader.1.souls
+ sacrifice_1.1.souls
+ sacrifice_2.1.souls
+ sacrifice_3.1.souls
+ sacrifice_4.1.souls;

let (leader_output, sacrifice_output) = AvatarCombinator::<Test>::glimmer_avatars(
leader,
Expand Down Expand Up @@ -489,8 +491,8 @@ mod test {
let qty = AvatarUtils::read_attribute(avatar, &AvatarAttributes::Quantity);

assert!(
(item_sub_type == SpecialItemType::Dust && qty == 5) ||
(item_sub_type == SpecialItemType::ToolBox && qty == 1)
(item_sub_type == SpecialItemType::Dust && qty == 5)
|| (item_sub_type == SpecialItemType::ToolBox && qty == 1)
);
} else {
panic!("ForgeOutput should have been Minted!")
Expand Down Expand Up @@ -838,16 +840,17 @@ mod test {
&AvatarAttributes::ItemType,
) {
ItemType::Pet => probability_array[1] += 1,
ItemType::Essence =>
ItemType::Essence => {
match AvatarUtils::read_attribute_as::<EssenceItemType>(
avatar,
&AvatarAttributes::ItemSubType,
) {
EssenceItemType::ColorSpark => probability_array[2] += 1,
EssenceItemType::GlowSpark => probability_array[3] += 1,
_ => panic!("Generated avatar EssenceItemType not valid!"),
},
ItemType::Special =>
}
},
ItemType::Special => {
match AvatarUtils::read_attribute_as::<SpecialItemType>(
avatar,
&AvatarAttributes::ItemSubType,
Expand All @@ -856,7 +859,8 @@ mod test {
SpecialItemType::Unidentified => probability_array[5] += 1,
SpecialItemType::Fragment => probability_array[6] += 1,
SpecialItemType::ToolBox => probability_array[7] += 1,
},
}
},
_ => panic!("Generated avatar ItemType not valid!"),
}
} else {
Expand Down
Loading

0 comments on commit bd48133

Please sign in to comment.