|
250 | 250 | // of event is probably not the best.
|
251 | 251 | //!
|
252 | 252 | //! With the explanation out of the way, let's see how these components can be added. Both follow a
|
253 |
| -//! fairly familiar syntax: normal Rust enums, with an extra `#[frame::event/error]` attribute |
254 |
| -//! attached. |
| 253 | +//! fairly familiar syntax: normal Rust enums, with extra |
| 254 | +//! [`#[frame::event]`](frame::pallet_macros::event) and |
| 255 | +//! [`#[frame::error]`](frame::pallet_macros::error) attributes attached. |
255 | 256 | #![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", Event)]
|
256 | 257 | #![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", Error)]
|
257 | 258 | //!
|
258 |
| -//! One slightly custom part of this is the `#[pallet::generate_deposit(pub(super) fn |
259 |
| -//! deposit_event)]` part. Without going into too much detail, in order for a pallet to emit events |
260 |
| -//! to the rest of the system, it needs to do two things: |
| 259 | +//! One slightly custom part of this is the [`#[pallet::generate_deposit(pub(super) fn |
| 260 | +//! deposit_event)]`](frame::pallet_macros::generate_deposit) part. Without going into too |
| 261 | +//! much detail, in order for a pallet to emit events to the rest of the system, it needs to do two |
| 262 | +//! things: |
261 | 263 | //!
|
262 | 264 | //! 1. Declare a type in its `Config` that refers to the overarching event type of the runtime. In
|
263 | 265 | //! short, by doing this, the pallet is expressing an important bound: `type RuntimeEvent:
|
|
266 | 268 | //! store it where needed.
|
267 | 269 | //!
|
268 | 270 | //! 2. But, doing this conversion and storing is too much to expect each pallet to define. FRAME
|
269 |
| -//! provides a default way of storing events, and this is what `pallet::generate_deposit` is doing. |
| 271 | +//! provides a default way of storing events, and this is what |
| 272 | +//! [`pallet::generate_deposit`](frame::pallet_macros::generate_deposit) is doing. |
270 | 273 | #![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", config_v2)]
|
271 | 274 | //!
|
272 | 275 | //! > These `Runtime*` types are better explained in
|
|
280 | 283 | #![doc = docify::embed!("./src/guides/your_first_pallet/mod.rs", runtime_v2)]
|
281 | 284 | //!
|
282 | 285 | //! In this snippet, the actual `RuntimeEvent` type (right hand side of `type RuntimeEvent =
|
283 |
| -//! RuntimeEvent`) is generated by `construct_runtime`. An interesting way to inspect this type is |
284 |
| -//! to see its definition in rust-docs: |
| 286 | +//! RuntimeEvent`) is generated by |
| 287 | +//! [`construct_runtime`](frame::runtime::prelude::construct_runtime). An interesting way to inspect |
| 288 | +//! this type is to see its definition in rust-docs: |
285 | 289 | //! [`crate::guides::your_first_pallet::pallet_v2::tests::runtime_v2::RuntimeEvent`].
|
286 | 290 | //!
|
287 | 291 | //!
|
|
0 commit comments