Add field names to pallet Event variants (#9993)

* convert pallet-assets events to struct types

* updated events of a couple pallets

* updated pallet event field names

* update pallet event field names

* updated events in test files

* cargo fmt

* minorfixes

* fix assertion error

* minor fix

* formatting fix

* fmt
This commit is contained in:
David Salami
2021-11-16 02:56:00 +01:00
committed by GitHub
parent fb3c7326c2
commit 120894fdb7
48 changed files with 1181 additions and 681 deletions
+33 -8
View File
@@ -275,7 +275,11 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
details.supply = details.supply.saturating_add(amount);
Ok(())
})?;
Self::deposit_event(Event::Issued(id, beneficiary.clone(), amount));
Self::deposit_event(Event::Issued {
asset_id: id,
owner: beneficiary.clone(),
total_supply: amount,
});
Ok(())
}
@@ -342,7 +346,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
Ok(())
})?;
Self::deposit_event(Event::Burned(id, target.clone(), actual));
Self::deposit_event(Event::Burned { asset_id: id, owner: target.clone(), balance: actual });
Ok(actual)
}
@@ -415,7 +419,12 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
) -> Result<T::Balance, DispatchError> {
// Early exist if no-op.
if amount.is_zero() {
Self::deposit_event(Event::Transferred(id, source.clone(), dest.clone(), amount));
Self::deposit_event(Event::Transferred {
asset_id: id,
from: source.clone(),
to: dest.clone(),
amount,
});
return Ok(amount)
}
@@ -476,7 +485,12 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
Ok(())
})?;
Self::deposit_event(Event::Transferred(id, source.clone(), dest.clone(), credit));
Self::deposit_event(Event::Transferred {
asset_id: id,
from: source.clone(),
to: dest.clone(),
amount: credit,
});
Ok(credit)
}
@@ -514,7 +528,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
is_frozen: false,
},
);
Self::deposit_event(Event::ForceCreated(id, owner));
Self::deposit_event(Event::ForceCreated { asset_id: id, owner });
Ok(())
}
@@ -554,7 +568,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
for ((owner, _), approval) in Approvals::<T, I>::drain_prefix((&id,)) {
T::Currency::unreserve(&owner, approval.deposit);
}
Self::deposit_event(Event::Destroyed(id));
Self::deposit_event(Event::Destroyed { asset_id: id });
Ok(DestroyWitness {
accounts: details.accounts,
@@ -599,7 +613,12 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
},
)?;
Asset::<T, I>::insert(id, d);
Self::deposit_event(Event::ApprovedTransfer(id, owner.clone(), delegate.clone(), amount));
Self::deposit_event(Event::ApprovedTransfer {
asset_id: id,
source: owner.clone(),
delegate: delegate.clone(),
amount,
});
Ok(())
}
@@ -683,7 +702,13 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
is_frozen: false,
});
Self::deposit_event(Event::MetadataSet(id, name, symbol, decimals, false));
Self::deposit_event(Event::MetadataSet {
asset_id: id,
name,
symbol,
decimals,
is_frozen: false,
});
Ok(())
})
}