-
Notifications
You must be signed in to change notification settings - Fork 710
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
Pallet Elections Phragment migrates to use Fungibles trait #2011
base: master
Are you sure you want to change the base?
Pallet Elections Phragment migrates to use Fungibles trait #2011
Conversation
#[pallet::config] | ||
pub trait Config: frame_system::Config { | ||
pub trait Config: frame_system::Config | ||
where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double check whether we need this constraints.
@@ -196,17 +206,59 @@ pub mod pallet { | |||
#[pallet::without_storage_info] | |||
pub struct Pallet<T>(_); | |||
|
|||
#[pallet::composite_enum] | |||
pub enum HoldReason<I: 'static = ()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub enum HoldReason<I: 'static = ()> { | |
pub enum HoldReason<I: 'static = ()> { | |
/// Hold deposit for phragmen pallet. | |
Phragmen, | |
} |
|
||
/// A reason for freezing funds. | ||
#[pallet::composite_enum] | ||
pub enum FreezeReason<I: 'static = ()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar as as HoldReason
.
let _remainder = T::Currency::unreserve(&who, to_unreserve); | ||
debug_assert!(_remainder.is_zero()); | ||
// Must unreserve a bit. | ||
let released = T::Currency::release_all( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be release(to_unreserve)
and not release_all
}, | ||
}; | ||
|
||
// Amount to be locked up. | ||
let locked_stake = value.min(T::Currency::free_balance(&who)); | ||
T::Currency::set_lock(T::PalletId::get(), &who, locked_stake, WithdrawReasons::all()); | ||
let locked_stake = value.min(T::Currency::balance(&who)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let locked_stake = value.min(T::Currency::balance(&who)); | |
let locked_stake = value.min(T::Currency::reducible_balance(&who, ....)); |
Probably?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, why do we need to lock and reserve in the same action?
debug_assert!(_remainder.is_zero()); | ||
|
||
let released = T::Currency::release_all( | ||
&HoldReason::ReleaseForRunnerUp.into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&HoldReason::ReleaseForRunnerUp.into(), | |
&HoldReason::Candidacy.into() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -529,8 +596,12 @@ pub mod pallet { | |||
.binary_search_by(|(c, _)| c.cmp(&who)) | |||
.map_err(|_| Error::<T>::InvalidRenouncing)?; | |||
let (_removed, deposit) = candidates.remove(index); | |||
let _remainder = T::Currency::unreserve(&who, deposit); | |||
debug_assert!(_remainder.is_zero()); | |||
let _released = T::Currency::release( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not release here again, maybe thaw
?
@@ -737,7 +808,7 @@ pub mod pallet { | |||
.map(|(ref member, ref stake)| { | |||
// make sure they have enough stake. | |||
assert!( | |||
T::Currency::free_balance(member) >= *stake, | |||
T::Currency::balance(member) >= *stake, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reducible_balance
maybe?
The CI pipeline was cancelled due to failure one of the required jobs. |
…polkadot-sdk into elections-phragment-fungibles
This PR updates the Elections Phragment pallet to use the fungible traits instead of the Currency trait (More information appear on #226);