Summary
When building a forge-based contract for WASM without specifying either contract or data-driver feature, the build fails with cryptic errors about missing allocator and ABI types. Users must currently add a manual compile_error! guard in each contract to get a helpful error message. (As is done in the test-bridge example) This guard should be part of the macro's generated code to eliminate boilerplate and ensure consistent developer experience across all forge-based contracts.
Possible solution design or implementation
The #[contract] macro should emit the following guard as part of its code generation:
#[cfg(all(target_family = "wasm", not(any(feature = "contract", feature = "data-driver"))))]
compile_error!("Enable either 'contract' or 'data-driver' feature for WASM builds");
This could be added in generate.rs alongside the existing #[cfg(target_family = "wasm")] blocks.
Summary
When building a forge-based contract for WASM without specifying either contract or data-driver feature, the build fails with cryptic errors about missing allocator and ABI types. Users must currently add a manual compile_error! guard in each contract to get a helpful error message. (As is done in the test-bridge example) This guard should be part of the macro's generated code to eliminate boilerplate and ensure consistent developer experience across all forge-based contracts.
Possible solution design or implementation
The #[contract] macro should emit the following guard as part of its code generation:
This could be added in generate.rs alongside the existing
#[cfg(target_family = "wasm")]blocks.