Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Replace the four hand-rolled `#[contract(...)]` directive parsers with a single typed pass returning a `ContractDirectives` struct. Malformed inputs (typo'd keyword, wrong shape, unparseable feeds type, `expose = (...)` with parens, extra tokens after a `(topic, EventType)` tuple) now produce a `compile_error!` instead of being silently dropped. Duplicate directives (within one attribute or across multiple `#[contract(...)]` attributes on the same item) also error [#24].
- Move workspace to Rust edition 2024 on the stable toolchain (MSRV 1.85). Generated contract wrappers now use `#[unsafe(no_mangle)]`.
- Remove `-Z build-std=core,alloc` from contract builds (no longer needed on stable).
- Replace EVM-flavored test-bridge with a general-purpose test contract that exercises every `#[contract]` macro code path without domain-specific types.
Expand Down Expand Up @@ -83,6 +84,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<!-- Issues -->
[#3]: https://github.com/dusk-network/forge/issues/3
[#6]: https://github.com/dusk-network/forge/issues/6
[#24]: https://github.com/dusk-network/forge/issues/24

<!-- Releases -->
[Unreleased]: https://github.com/dusk-network/forge/compare/v0.2.1...HEAD
Expand Down
20 changes: 10 additions & 10 deletions contract-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,24 +207,24 @@ pub fn contract(_attr: TokenStream, item: TokenStream) -> TokenStream {
let mut events = Vec::new();

for impl_block in &impl_blocks {
match parse::public_methods(impl_block) {
Ok(methods) => functions.extend(methods),
let (methods, method_events) = match parse::public_methods(impl_block) {
Ok(result) => result,
Err(e) => return e.to_compile_error().into(),
}
};
functions.extend(methods);
events.extend(parse::emit_calls(impl_block));
// Include events from method-level #[contract(emits = [...])] attributes
events.extend(parse::inherent_method_emits(impl_block));
events.extend(method_events);
}

// Extract functions and events from trait impl blocks with expose lists
for trait_impl in &trait_impls {
match parse::trait_methods(trait_impl) {
Ok(trait_functions) => functions.extend(trait_functions),
let (trait_functions, method_events) = match parse::trait_methods(trait_impl) {
Ok(result) => result,
Err(e) => return e.to_compile_error().into(),
}
};
functions.extend(trait_functions);
events.extend(parse::emit_calls(trait_impl.impl_block));
// Include events from method-level #[contract(emits = [...])] attributes
events.extend(parse::trait_method_emits(trait_impl));
events.extend(method_events);
}

// Deduplicate events by topic — first-seen wins.
Expand Down
Loading