Skip to content

Commit

Permalink
more interesting naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Aug 27, 2024
1 parent cca90bb commit 50776aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions pallets/rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub mod pallet {
},
};
use frame_system::pallet_prelude::*;
use types::RewardDetails;
use types::PrizePoolDetails;

/// The module configuration trait.
#[pallet::config]
Expand Down Expand Up @@ -79,8 +79,8 @@ pub mod pallet {
/// fulfilled on time.
#[pallet::storage]
#[pallet::getter(fn order_rewards)]
pub type RewardPools<T: Config> =
StorageMap<_, Blake2_128Concat, OrderId, RewardDetails<T::AssetId, BalanceOf<T>>>;
pub type PrizePools<T: Config> =
StorageMap<_, Blake2_128Concat, OrderId, PrizePoolDetails<T::AssetId, BalanceOf<T>>>;

#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
Expand All @@ -99,7 +99,7 @@ pub mod pallet {
/// are not yet set and are currently zero.
CantConfigure,
/// The reward pool of an order was not found.
RewardPoolNotFound,
PrizePoolNotFound,
}

#[pallet::call]
Expand All @@ -119,13 +119,13 @@ pub mod pallet {
ensure!(!T::Orders::order_expired(&order), Error::<T>::OrderExpired);
ensure!(order.creator == caller, Error::<T>::Unallowed);

let maybe_pool = RewardPools::<T>::get(order_id);
let maybe_pool = PrizePools::<T>::get(order_id);
// Rewards can be reconfigured if the amount is still zero.
if let Some(pool) = maybe_pool {
ensure!(pool.amount == Zero::zero(), Error::<T>::CantConfigure);
}

RewardPools::<T>::insert(order_id, RewardDetails { asset_id, amount: Zero::zero() });
PrizePools::<T>::insert(order_id, PrizePoolDetails { asset_id, amount: Zero::zero() });

// TODO: deposit event
Ok(())
Expand All @@ -150,8 +150,8 @@ pub mod pallet {
) -> DispatchResult {
let _caller = ensure_signed(origin)?;

let Some(pool) = RewardPools::<T>::get(order_id) else {
return Err(Error::<T>::RewardPoolNotFound.into())
let Some(pool) = PrizePools::<T>::get(order_id) else {
return Err(Error::<T>::PrizePoolNotFound.into())
};

// TODO: check if user has enough tokens
Expand Down
2 changes: 1 addition & 1 deletion pallets/rewards/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use scale_info::TypeInfo;

/// Contains reward details of an order.
#[derive(Encode, Decode, Debug, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)]
pub struct RewardDetails<AssetId, Balance> {
pub struct PrizePoolDetails<AssetId, Balance> {
/// The asset which the contributors will receive,
pub asset_id: AssetId,
/// Amount of tokens that will be distributed to contributors.
Expand Down

0 comments on commit 50776aa

Please sign in to comment.