Skip to content

Commit f3875f2

Browse files
committed
Add support for events and indexed fields.
This adds two new attributes: `#[event]` and `#[indexed]`. The `#[event]` attribute marks a struct or enum as an event that can be emitted by a contract. The `#[indexed]` attribute can be applied to fields within structs that are attributed with `#[event]`. This is particularly useful for event structs, allowing for efficient filtering and searching of emitted events based on the values of these fields. When using this attribute, the indexed fields must be applied sequentially to the initial set of fields in a struct. This attribute can only be applied to fields whose type is an exact size ABI type. The exact size ABI types include: - `bool` - `u8`, `u16`, `u32`, `u64`, `u256` - `numeric` - `b256` - `str[N]` - Tuples containing only exact size types - Structs containing only exact size types - Arrays of exact size types with a literal length - Type aliases to exact size types Additionally it causes the event types to be included in the JSON ABI representation for the contract. ```sway struct MyEventStruct { #[indexed] id: u64, sender: Identity, } enum MyEventEnum { A: (), B: (), } ``` Additionally this updates the JSON ABI to emit an `offset` for indexed fields.
1 parent 6d6bb74 commit f3875f2

File tree

283 files changed

+1846
-1180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

283 files changed

+1846
-1180
lines changed

.github/workflows/scripts/check-dep-versions/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const REQUIRED_XYZ_DEP: &str = "fuel-core-client";
99

1010
// Dependency names allowed (but not required) to use x.y.z format
1111
// Add names of common dev-dependencies here if you want to allow x.y.z for them
12-
const ALLOWED_XYZ_DEPS: &[&str] = &["etk-asm", "etk-ops", "dap"];
12+
const ALLOWED_XYZ_DEPS: &[&str] = &["etk-asm", "etk-ops", "dap", "fuel-abi-types"];
1313

1414
// Regex to strictly match semantic version x.y.z (no prefixes like ^, ~)
1515
const XYZ_REGEX_STR: &str = r"^\d+\.\d+\.\d+([\w.-]*)$"; // Allow suffixes like -alpha, .1

0 commit comments

Comments
 (0)