refactor: consolidate WormholeContract into single impl block #2779
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactor WormholeContract to use single impl block
Summary
This PR refactors the Wormhole contract in the Stylus implementation to improve code clarity and structure by consolidating multiple impl blocks into a single impl block, as requested in the code review feedback.
Changes Made
impl WormholeContract
andimpl IWormhole for WormholeContract
blocks into a single unified impl blockinitialize
function by usingU256::from(0)
instead of0
main.rs
by wrapping withunsafe(...)
Technical Investigation: Individual Function
#[public]
AnnotationsOriginal Request: Use a single impl block WITHOUT
#[public]
on the impl block itself, but WITH individual functions marked#[public]
.Investigation Results: ❌ Not supported by current Stylus SDK
Attempted Approach
Compilation Errors
Root Cause
The current Stylus SDK requires
#[public]
to be applied to the entire impl block, not individual functions. Without#[public]
on the impl block, the#[entrypoint]
macro cannot find the required traits (Router
,__stylus_assert_overrides
).Current Working Solution
#[public]
on entire impl block (Stylus SDK requirement)cargo build
Testing
cargo build
#[public]
)Link to Devin run
https://app.devin.ai/sessions/9561fe072961457792deaa66c8e561a7
Requested by: ayush.suresh@dourolabs.xyz