diff --git a/prdoc/pr_2839.prdoc b/prdoc/pr_2839.prdoc new file mode 100644 index 000000000000..d1f16cb11b0d --- /dev/null +++ b/prdoc/pr_2839.prdoc @@ -0,0 +1,8 @@ +title: "Refactors `OnStakingUpdate` trait" + +doc: + - audience: Runtime Dev + description: Refactors the `sp_staking:OnStakingUpdate` to make event inputs more explicit. + +crates: + - name: "sp-staking" diff --git a/substrate/primitives/staking/src/lib.rs b/substrate/primitives/staking/src/lib.rs index c2ac5ae004b1..f7e9f11a961f 100644 --- a/substrate/primitives/staking/src/lib.rs +++ b/substrate/primitives/staking/src/lib.rs @@ -100,19 +100,29 @@ pub trait OnStakingUpdate { /// /// This is effectively any changes to the bond amount, such as bonding more funds, and /// unbonding. - fn on_stake_update(_who: &AccountId, _prev_stake: Option>) {} + fn on_stake_update( + _who: &AccountId, + _prev_stake: Option>, + _stake: Stake, + ) { + } /// Fired when someone sets their intention to nominate. /// /// This should never be fired for existing nominators. - fn on_nominator_add(_who: &AccountId) {} + fn on_nominator_add(_who: &AccountId, _nominations: Vec) {} /// Fired when an existing nominator updates their nominations. /// /// Note that this is not fired when a nominator changes their stake. For that, /// `on_stake_update` should be used, followed by querying whether `who` was a validator or a /// nominator. - fn on_nominator_update(_who: &AccountId, _prev_nominations: Vec) {} + fn on_nominator_update( + _who: &AccountId, + _prev_nominations: Vec, + _nominations: Vec, + ) { + } /// Fired when someone removes their intention to nominate, either due to chill or validating. /// @@ -123,7 +133,7 @@ pub trait OnStakingUpdate { /// Fired when someone sets their intention to validate. /// /// Note validator preference changes are not communicated, but could be added if needed. - fn on_validator_add(_who: &AccountId) {} + fn on_validator_add(_who: &AccountId, _self_stake: Option>) {} /// Fired when an existing validator updates their preferences. /// @@ -131,7 +141,7 @@ pub trait OnStakingUpdate { fn on_validator_update(_who: &AccountId) {} /// Fired when someone removes their intention to validate, either due to chill or nominating. - fn on_validator_remove(_who: &AccountId) {} + fn on_validator_remove(_who: &AccountId, _self_stake: Option>) {} /// Fired when someone is fully unstaked. fn on_unstake(_who: &AccountId) {}