Reputation: 857
Hi all I am trying to access the values passed in the event .
I have extract the event with this - not this is substrate 0.9.12 so I have not been able to use some of the examples I find online that use substrate 2.0.0
let e = &frame_system::Pallet::<Test>::events()[0];
let EventRecord { event, .. } = e;
And this is the structure of event
Event::MosaicVault(
Event::VaultCreated {
sender: 1,
asset_id: A,
vault_id: 1,
reserved: Perquintill(
1000000000000000000,
),
},
)
How do I access vault_id value , a sample would be helpful , thanks
Upvotes: 0
Views: 81
Reputation: 516
This is called destructuring of enum (if you want to search online for more example).
Basically you can use some match
or if let
to get the inner fields of some variants of enums.
something a bit like this:
if let Event::MosaicVault(Event::VaultCreated { vault_id, .. }) = event {
// here you have access to vault_id
}
Upvotes: 1