feat: add ABI generation and improve pvm_contract macro #4
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
pvm-contract-macroscrate with proc macros for contract developmentpvm_contractruntime library crate.abi.jsonalongside.polkavm)New Crates
pvm-contract-macrosProc macros for defining PolkaVM contracts:
#[pvm_contract::contract]- Define a contract module#[pvm_contract::method]- Mark functions as contract methods (automatic selector generation)#[pvm_contract::constructor]- Mark constructor function#[pvm_contract::fallback]- Mark fallback functionpvm_contractRuntime library re-exporting the macros and types.
Key Features
Simplified Method Attributes
Before:
#[pvm_contract::method("transfer(address,uint256)")]After:
#[pvm_contract::method](signature inferred from Rust types)Optional rename:
#[pvm_contract::method(rename = "getBalance")]Automatic Type Mapping (Rust → Solidity)
AddressaddressU256uint256u128uint128u64uint64u32uint32boolbool[u8; 32]bytes32ABI Generation
The builder now parses contract source files and generates ABI JSON files alongside the compiled
.polkavmbinaries.Testing