refactor: split contract_interface.rs into logical modules #44
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.
Summary
Addresses file bloat in
freenet-stdlibby splitting the 1992-linecontract_interface.rsinto 12 focused modules with clear separation of concerns.Motivation
This file has been a pain point for navigation and maintenance. While it interfaces with WASM code (making API changes non-trivial), we can safely reorganize the internal structure without breaking the public API.
What Changed
Split
rust/src/contract_interface.rs(1992 lines) into a module directory:Core Type Modules:
error.rs- ContractError type (19 lines)state.rs- State, StateDelta, StateSummary (225 lines)key.rs- ContractInstanceId, ContractKey, helper functions (249 lines)code.rs- ContractCode (138 lines)update.rs- UpdateModification, RelatedContracts, UpdateData, etc. (330 lines)contract.rs- Contract type (89 lines)wrapped.rs- WrappedState, WrappedContract (183 lines)trait_def.rs- ContractInterface trait (88 lines)Special Modules:
wasm_interface.rs- WASM FFI boundary, pub(crate) (199 lines)encoding.rs- Typed contract helpers, pub (384 lines)tests.rs- Unit tests (51 lines)mod.rs- Re-exports preserving public API (33 lines)API Compatibility
✅ No breaking changes - All public types re-exported from
mod.rs✅ Same imports work -
use freenet_stdlib::prelude::*;unchanged✅ All feature flags preserved - #[cfg(feature = "testing")], etc.
✅ All tests pass - 6/6 tests green, builds with --all-features
Benefits
Test Plan
Review Notes
This is a mechanical refactoring - code was moved but not modified. The only changes are:
use super::*;instead ofuse crate::contract_interface::*;)mod.rsRequesting @iduartgomez review - This touches the WASM interface boundary, and while the API is preserved, I want sign-off that the module structure makes sense.
🤖 Generated with Claude Code
[AI-assisted debugging and comment]