Skip to content

Commit e1b9f8b

Browse files
authored
Merge pull request #243 from onflow/events
Edit Events and Core Events articles
2 parents 4e5e66d + fc8799f commit e1b9f8b

2 files changed

Lines changed: 37 additions & 28 deletions

File tree

docs/language/core-events.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ title: Core Events
33
sidebar_position: 22
44
---
55

6-
Core events are events emitted directly from the FVM (Flow Virtual Machine).
7-
The events have the same name on all networks and do not follow the standard naming (they have no address).
6+
Core events are events emitted directly from the Flow Virtual Machine (FVM). The events have the same name on all networks and do not follow the standard naming (they have no address).
87

9-
Refer to the [public key section](./crypto.mdx#public-keys) for more details on the information provided for account key events.
8+
Refer to the [public key section] for more details on the information provided for account key events.
109

1110
### Account Created
1211

@@ -148,9 +147,11 @@ event InboxValuePublished(provider: Address, recipient: Address, name: String, t
148147
| `name` | `String` | The name associated with the published value |
149148
| `type` | `Type` | The type of the published value |
150149

151-
To reduce the potential for spam,
152-
we recommend that user agents that display events do not display this event as-is to their users,
153-
and allow users to restrict whom they see events from.
150+
:::tip
151+
152+
To reduce the potential for spam, we recommend that user agents that display events do not display this event as-is to their users, and allow users to restrict whom they see events from.
153+
154+
:::
154155

155156
### Inbox Value Unpublished
156157

@@ -168,9 +169,11 @@ event InboxValueUnpublished(provider: Address, name: String)
168169
| `provider` | `Address` | The address of the publishing account |
169170
| `name` | `String` | The name associated with the published value |
170171

171-
To reduce the potential for spam,
172-
we recommend that user agents that display events do not display this event as-is to their users,
173-
and allow users to restrict whom they see events from.
172+
:::tip
173+
174+
To reduce the potential for spam, we recommend that user agents that display events do not display this event as-is to their users, and allow users to restrict whom they see events from.
175+
176+
:::
174177

175178
### Inbox Value Claimed
176179

@@ -189,6 +192,12 @@ event InboxValueClaimed(provider: Address, recipient: Address, name: String)
189192
| `recipient` | `Address` | The address of the claiming recipient |
190193
| `name` | `String` | The name associated with the published value |
191194

192-
To reduce the potential for spam,
193-
we recommend that user agents that display events do not display this event as-is to their users,
194-
and allow users to restrict whom they see events from.
195+
:::tip
196+
197+
To reduce the potential for spam, we recommend that user agents that display events do not display this event as-is to their users, and allow users to restrict whom they see events from.
198+
199+
:::
200+
201+
<!-- Relative links. Will not render on the page -->
202+
203+
[public key section]: ./crypto.mdx#public-keys

docs/language/events.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,17 @@ sidebar_position: 21
55

66
Events are special values that can be emitted during the execution of a program.
77

8-
An event type can be declared with the `event` keyword.
8+
An event type can be declared with the `event` keyword:
99

1010
```cadence
1111
event FooEvent(x: Int, y: Int)
1212
```
1313

14-
The syntax of an event declaration is similar to that of
15-
a [function declaration](./functions.mdx#function-declarations);
16-
events contain named parameters, each of which has an optional argument label.
14+
The syntax of an event declaration is similar to that of a [function declaration]; events contain named parameters, each of which has an optional argument label.
1715

18-
Event parameters may only have a valid event parameter type.
19-
Valid types are boolean, string, integer, arrays and dictionaries of these types,
20-
and structures where all fields have a valid event parameter type.
21-
Resource types are not allowed, because when a resource is used as an argument, it is moved.
16+
Event parameters may only have a valid event parameter type. Valid types are boolean, string, integer, arrays, and dictionaries of these types, and structures where all fields have a valid event parameter type. Resource types are not allowed, because when a resource is used as an argument, it is moved.
2217

23-
Events can only be declared within a [contract](./contracts.mdx) body.
24-
Events cannot be declared globally or within resource or struct types.
18+
Events can only be declared within a [contract] body. Events cannot be declared globally or within resource or struct types.
2519

2620
```cadence
2721
// Invalid: An event cannot be declared globally
@@ -39,10 +33,9 @@ contract Events {
3933
//
4034
event ResourceEvent(resourceField: @Vault)
4135
}
42-
4336
```
4437

45-
### Emitting events
38+
## Emitting events
4639

4740
To emit an event from a program, use the `emit` statement:
4841

@@ -65,10 +58,17 @@ contract Events {
6558
}
6659
```
6760

68-
Emitting events has the following restrictions:
61+
Please note the following restrictions when emitting events:
62+
63+
- Events can only be invoked in an `emit` statement. This means events cannot be assigned to variables or used as function parameters.
64+
- Events can only be emitted from the location in which they are declared. You can not emit an event from an imported contract from a contract that imports it.
65+
66+
### Destroy events
6967

70-
- Events can only be invoked in an `emit` statement.
68+
It's possible to specify a special event to be automatically emitted when a resource is destroyed. See [destroying events] for more information.
7169

72-
This means events cannot be assigned to variables or used as function parameters.
70+
<!-- Relative links. Will not render on the page -->
7371

74-
- Events can only be emitted from the location in which they are declared.
72+
[function declaration]: ./functions.mdx#function-declarations
73+
[contract]: ./contracts.mdx
74+
[destroying events]: ./resources.mdx#destroy-events

0 commit comments

Comments
 (0)