mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 11:41:02 +00:00
Assets Events for Deposited and Withdrawn (#4312)
Closes #4308 Polkadot address: 12gMhxHw8QjEwLQvnqsmMVY1z5gFa54vND74aMUbhhwN6mJR --------- Co-authored-by: command-bot <> Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com>
This commit is contained in:
committed by
GitHub
parent
4875ea11ae
commit
1fb058b791
@@ -118,6 +118,22 @@ impl<T: Config<I>, I: 'static> fungibles::Balanced<<T as SystemConfig>::AccountI
|
||||
{
|
||||
type OnDropCredit = fungibles::DecreaseIssuance<T::AccountId, Self>;
|
||||
type OnDropDebt = fungibles::IncreaseIssuance<T::AccountId, Self>;
|
||||
|
||||
fn done_deposit(
|
||||
asset_id: Self::AssetId,
|
||||
who: &<T as SystemConfig>::AccountId,
|
||||
amount: Self::Balance,
|
||||
) {
|
||||
Self::deposit_event(Event::Deposited { asset_id, who: who.clone(), amount })
|
||||
}
|
||||
|
||||
fn done_withdraw(
|
||||
asset_id: Self::AssetId,
|
||||
who: &<T as SystemConfig>::AccountId,
|
||||
amount: Self::Balance,
|
||||
) {
|
||||
Self::deposit_event(Event::Withdrawn { asset_id, who: who.clone(), amount })
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config<I>, I: 'static> fungibles::Unbalanced<T::AccountId> for Pallet<T, I> {
|
||||
|
||||
@@ -571,6 +571,10 @@ pub mod pallet {
|
||||
Touched { asset_id: T::AssetId, who: T::AccountId, depositor: T::AccountId },
|
||||
/// Some account `who` was blocked.
|
||||
Blocked { asset_id: T::AssetId, who: T::AccountId },
|
||||
/// Some assets were deposited (e.g. for transaction fees).
|
||||
Deposited { asset_id: T::AssetId, who: T::AccountId, amount: T::Balance },
|
||||
/// Some assets were withdrawn from the account (e.g. for transaction fees).
|
||||
Withdrawn { asset_id: T::AssetId, who: T::AccountId, amount: T::Balance },
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
|
||||
@@ -90,6 +90,12 @@ fn deposit_from_set_types_works() {
|
||||
assert_eq!(First::<Assets>::balance((), &account2), 50);
|
||||
assert_eq!(First::<Assets>::total_issuance(()), 100);
|
||||
|
||||
System::assert_has_event(RuntimeEvent::Assets(crate::Event::Deposited {
|
||||
asset_id: asset1,
|
||||
who: account2,
|
||||
amount: 50,
|
||||
}));
|
||||
|
||||
assert_eq!(imb.peek(), 50);
|
||||
|
||||
let (imb1, imb2) = imb.split(30);
|
||||
@@ -336,6 +342,12 @@ fn withdraw_from_set_types_works() {
|
||||
assert_eq!(First::<Assets>::balance((), &account2), 50);
|
||||
assert_eq!(First::<Assets>::total_issuance(()), 200);
|
||||
|
||||
System::assert_has_event(RuntimeEvent::Assets(crate::Event::Withdrawn {
|
||||
asset_id: asset1,
|
||||
who: account2,
|
||||
amount: 50,
|
||||
}));
|
||||
|
||||
assert_eq!(imb.peek(), 50);
|
||||
drop(imb);
|
||||
assert_eq!(First::<Assets>::total_issuance(()), 150);
|
||||
|
||||
Reference in New Issue
Block a user