Skip to content

Commit

Permalink
refactor: abstract CfgCurrencyId
Browse files Browse the repository at this point in the history
  • Loading branch information
wischli committed Mar 28, 2023
1 parent 5be160c commit ecd49de
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
25 changes: 18 additions & 7 deletions pallets/block-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ use cfg_traits::{
ops::{EnsureAdd, EnsureMul, EnsureSub},
rewards::{AccountRewards, CurrencyGroupChange, GroupRewards},
};
use cfg_types::tokens::CurrencyId as CfgCurrencyId;
use frame_support::{
pallet_prelude::*,
storage::transactional,
Expand Down Expand Up @@ -141,16 +140,28 @@ pub mod pallet {
+ AccountRewards<
Self::AccountId,
Balance = Self::Balance,
CurrencyId = (DomainIdOf<Self>, CfgCurrencyId),
> + CurrencyGroupChange<GroupId = u32, CurrencyId = (DomainIdOf<Self>, CfgCurrencyId)>;

/// Type used to handle currency minting and burning for collators.
type Currency: Mutate<Self::AccountId, AssetId = CfgCurrencyId, Balance = Self::Balance>
CurrencyId = (DomainIdOf<Self>, <Self as Config>::CurrencyId),
> + CurrencyGroupChange<
GroupId = u32,
CurrencyId = (DomainIdOf<Self>, <Self as Config>::CurrencyId),
>;

/// The type used to handle currency minting and burning for collators.
type Currency: Mutate<Self::AccountId, AssetId = <Self as Config>::CurrencyId, Balance = Self::Balance>
+ CurrencyT<Self::AccountId>;

/// The currency type of the artificial block rewards currency.
type CurrencyId: Parameter
+ Member
+ Copy
+ MaybeSerializeDeserialize
+ Ord
+ TypeInfo
+ MaxEncodedLen;

/// The identifier of the artificial block rewards currency which is minted and burned for collators.
#[pallet::constant]
type StakeCurrencyId: Get<CfgCurrencyId>;
type StakeCurrencyId: Get<<Self as Config>::CurrencyId>;

/// The amount of the artificial block rewards currency which is minted and burned for collators.
#[pallet::constant]
Expand Down
1 change: 1 addition & 0 deletions pallets/block-rewards/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ impl pallet_block_rewards::Config for Test {
type Balance = Balance;
type Beneficiary = RewardRemainderMock;
type Currency = Tokens;
type CurrencyId = CurrencyId;
type Domain = BlockRewardsDomain;
type MaxChangesPerSession = MaxChangesPerSession;
type MaxCollators = MaxCollators;
Expand Down
1 change: 1 addition & 0 deletions runtime/development/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,7 @@ impl pallet_block_rewards::Config for Runtime {
type Balance = Balance;
type Beneficiary = Treasury;
type Currency = Tokens;
type CurrencyId = CurrencyId;
type Domain = BlockRewardsDomain;
type MaxChangesPerSession = MaxChangesPerEpoch;
type MaxCollators = MaxAuthorities;
Expand Down

0 comments on commit ecd49de

Please sign in to comment.