pallet_assets : Remove event for no_op (#11023)

* remove no_op event

* ensure no transferred event emitted

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
stanly-johnson
2022-04-14 23:41:42 +04:00
committed by GitHub
parent c56e8f684f
commit 7dca0e467c
2 changed files with 3 additions and 13 deletions
+1 -7
View File
@@ -529,14 +529,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
maybe_need_admin: Option<T::AccountId>,
f: TransferFlags,
) -> Result<(T::Balance, Option<DeadConsequence>), DispatchError> {
// Early exist if no-op.
// Early exit if no-op.
if amount.is_zero() {
Self::deposit_event(Event::Transferred {
asset_id: id,
from: source.clone(),
to: dest.clone(),
amount,
});
return Ok((amount, None))
}
+2 -6
View File
@@ -620,12 +620,8 @@ fn transferring_less_than_one_unit_is_fine() {
assert_ok!(Assets::mint(Origin::signed(1), 0, 1, 100));
assert_eq!(Assets::balance(0, 1), 100);
assert_ok!(Assets::transfer(Origin::signed(1), 0, 2, 0));
System::assert_last_event(mock::Event::Assets(crate::Event::Transferred {
asset_id: 0,
from: 1,
to: 2,
amount: 0,
}));
// `ForceCreated` and `Issued` but no `Transferred` event.
assert_eq!(System::events().len(), 2);
});
}