mirror of
https://github.com/FuelLabs/sway.git
synced 2025-12-23 10:11:56 +00:00
|
Some checks are pending
CI / pre-publish-check (push) Waiting to run
Codspeed Benchmarks / benchmarks (push) Waiting to run
CI / verifications-complete (push) Blocked by required conditions
CI / check-dependency-version-formats (push) Waiting to run
CI / check-forc-manifest-version (push) Waiting to run
CI / get-fuel-core-version (push) Waiting to run
CI / build-sway-lib-std (push) Waiting to run
CI / build-sway-examples (push) Waiting to run
CI / build-reference-examples (push) Waiting to run
CI / forc-fmt-check-sway-lib-std (push) Waiting to run
CI / forc-fmt-check-sway-examples (push) Waiting to run
CI / forc-fmt-check-panic (push) Waiting to run
CI / check-sdk-harness-test-suite-compatibility (push) Waiting to run
CI / build-mdbook (push) Waiting to run
CI / build-forc-doc-sway-lib-std (push) Waiting to run
CI / build-forc-test-project (push) Waiting to run
CI / cargo-build-workspace (push) Waiting to run
CI / cargo-clippy (push) Waiting to run
CI / cargo-toml-fmt-check (push) Waiting to run
CI / cargo-fmt-check (push) Waiting to run
CI / cargo-run-e2e-test (push) Blocked by required conditions
CI / cargo-run-e2e-test-release (push) Blocked by required conditions
CI / cargo-test-lib-std (push) Waiting to run
CI / forc-run-benchmarks (push) Waiting to run
CI / forc-unit-tests (push) Waiting to run
CI / forc-pkg-fuels-deps-check (push) Waiting to run
CI / Build and test various forc tools (push) Blocked by required conditions
CI / cargo-unused-deps-check (push) Waiting to run
CI / notify-slack-on-failure (push) Blocked by required conditions
CI / publish (push) Blocked by required conditions
CI / publish-sway-lib-std (push) Blocked by required conditions
CI / Build and upload forc binaries to release (push) Blocked by required conditions
github pages / deploy (push) Waiting to run
This PR 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 and emits an `offset` for indexed
fields.
```sway
#[event]
struct MyEventStruct {
#[indexed]
id: u64,
sender: Identity,
}
```
|
||
|---|---|---|
| .. | ||
| book | ||
| reference | ||
| slides | ||
| breaking-release-checklist.md | ||
| internals.md | ||