You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/language/core-events.md
+21-12Lines changed: 21 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,10 +3,9 @@ title: Core Events
3
3
sidebar_position: 22
4
4
---
5
5
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).
8
7
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.
|`name`|`String`| The name associated with the published value |
149
148
|`type`|`Type`| The type of the published value |
150
149
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.
|`provider`|`Address`| The address of the publishing account |
169
170
|`name`|`String`| The name associated with the published value |
170
171
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.
|`recipient`|`Address`| The address of the claiming recipient |
190
193
|`name`|`String`| The name associated with the published value |
191
194
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 -->
Copy file name to clipboardExpand all lines: docs/language/events.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,23 +5,17 @@ sidebar_position: 21
5
5
6
6
Events are special values that can be emitted during the execution of a program.
7
7
8
-
An event type can be declared with the `event` keyword.
8
+
An event type can be declared with the `event` keyword:
9
9
10
10
```cadence
11
11
event FooEvent(x: Int, y: Int)
12
12
```
13
13
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.
17
15
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.
22
17
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.
25
19
26
20
```cadence
27
21
// Invalid: An event cannot be declared globally
@@ -39,10 +33,9 @@ contract Events {
39
33
//
40
34
event ResourceEvent(resourceField: @Vault)
41
35
}
42
-
43
36
```
44
37
45
-
###Emitting events
38
+
## Emitting events
46
39
47
40
To emit an event from a program, use the `emit` statement:
48
41
@@ -65,10 +58,17 @@ contract Events {
65
58
}
66
59
```
67
60
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
69
67
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.
71
69
72
-
This means events cannot be assigned to variables or used as function parameters.
70
+
<!-- Relative links. Will not render on the page -->
73
71
74
-
- Events can only be emitted from the location in which they are declared.
0 commit comments