Skip to content
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

[FRAME] fix: Do not emit Issued { amount: 0 } event #5946

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

ShoyuVanilla
Copy link
Contributor

@ShoyuVanilla ShoyuVanilla commented Oct 7, 2024

closes #5942

Couldn't find any emissions of Event::Issued without amount check other than in this PR.

Currently, we have;

impl<T: Config<I>, I: 'static> Drop for PositiveImbalance<T, I> {
/// Basic drop handler will just square up the total issuance.
fn drop(&mut self) {
if !self.0.is_zero() {
<super::TotalIssuance<T, I>>::mutate(|v| *v = v.saturating_add(self.0));
Pallet::<T, I>::deposit_event(Event::<T, I>::Issued { amount: self.0 });
}
}
}

and

fn issue(mut amount: Self::Balance) -> Self::NegativeImbalance {
if amount.is_zero() {
return NegativeImbalance::zero()
}
<TotalIssuance<T, I>>::mutate(|issued| {
*issued = issued.checked_add(&amount).unwrap_or_else(|| {
amount = Self::Balance::max_value() - *issued;
Self::Balance::max_value()
})
});
Pallet::<T, I>::deposit_event(Event::<T, I>::Issued { amount });
NegativeImbalance::new(amount)
}

@ShoyuVanilla ShoyuVanilla requested a review from a team as a code owner October 7, 2024 05:26
@ggwpez
Copy link
Member

ggwpez commented Oct 7, 2024

Looks good, thanks! Please add a minimal prdoc so that it shows up correctly in the CHANGELOG: https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/prdoc.md

@ShoyuVanilla
Copy link
Contributor Author

Looks good, thanks! Please add a minimal prdoc so that it shows up correctly in the CHANGELOG: https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/prdoc.md

Thanks! I'll add it soon

Copy link

github-actions bot commented Oct 7, 2024

Review required! Latest push from author must always be reviewed

@ggwpez ggwpez added the T2-pallets This PR/Issue is related to a particular pallet. label Oct 7, 2024
@ggwpez ggwpez enabled auto-merge October 7, 2024 14:20
@ggwpez ggwpez added this pull request to the merge queue Oct 7, 2024
Merged via the queue into paritytech:master with commit 215252e Oct 7, 2024
239 of 241 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T2-pallets This PR/Issue is related to a particular pallet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FRAME] Dont emit Issued event with 0 balance
5 participants