Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Questions that relate to pallets and disptachables that emit specific events, including decoding events.
4
votes
error[E0599]: no function or associated item named `events` found for struct `frame_system::...
We have specifically removed access to the Events storage item in frame_system because it could cause the user to read a huge amount of storage, and the events storage is only meant to be read offline. … /// Get the current events deposited by the runtime.
///
/// NOTE: This should only be used in tests. …
3
votes
How can a recoverable account get notified when someone is initiated a recovery for it?
You would basically need an active node or block explorer listening for these events, and some way to actively push a notification to the user. …
2
votes
Accepted
How to assert deposited event in pallet call?
(Self::events().iter().any(|record| record.event == event))
}
/// Assert the last event equal to the given `event`. … (Self::events().last().expect("events expected").event, event);
}
You can see a lot of examples of these functions being used by searching the Substrate codebase, but here is one simple example:
System …
11
votes
Accepted
Should events only be emitted in extrinsics?
The most common example of this pattern can be found in the Balances pallet, where Balances events are emitted every time the Currency trait is called from another pallet. …
3
votes
Accepted
How can I access custom pallet Event data in a test?
Here is a working example of a test using the pallet-template from the substrate-node-template:
#[test]
fn stackexchange_question() {
new_test_ext().execute_with(|| {
// To emit events, we … TemplateModule::do_something(Origin::signed(1), 42));
System::assert_last_event(crate::Event::SomethingStored(42, 1).into());
let event_record: frame_system::EventRecord<_, _> = System::events …
4
votes
Accepted
Problem running assert_last_event in tests.rs
Substrate chains do not emit events when the block number is 0. This is to avoid hundreds or even thousands of events being generated in the genesis block of a Substrate chain. … So if you want to do any Runtime tests where you check events, make sure you first do:
frame_system::Pallet::<T>::set_block_number(1);
You can also automate this for all of your tests via with:
pub fn …
5
votes
Accepted
Event type & Call type
, and is generating an "outer enum" which collects all the events and calls from all the other pallets and puts it together into a single overall type which is then transferred back into the pallet. …
4
votes
Event encoding in substrate pallet
Pallet events are encoded such that the first byte represents the pallet index, and the second byte represents the event index. … Thus, these two pallet instances will have all of the exact same events, parameters, and even functions. …
5
votes
Accepted
Correlate events with extrinsics in a utility.batch call in Polkadot
The utility.batch call emits events which allow you to organize which extrinsic events are coming from each extrinsic. … So it is just a matter of using these as delimiters, and organizing the events to the appropriate sub-batch call. …