Feat/generate contract interfaces#51
Open
allenday wants to merge 8 commits intodatachainlab:masterfrom
Open
Conversation
- Add _decode_float and _encode_float functions for 32-bit float support - Add _decode_double and _encode_double functions for 64-bit double support - Include GoogleProtobufDuration.sol runtime library - Include GoogleProtobufTimestamp.sol runtime library - Include GoogleProtobufFieldDescriptorProto.sol runtime library - Update documentation with runtime enhancements section
- Add comprehensive Solidity reserved keywords detection and mangling - Implement automatic field name mangling with _field suffix for conflicts - Fix boolean parameter parsing to support flag-style options (gen_runtime=true) - Update parameter processing to handle both boolean flags and value parameters - Add file path normalization for cross-platform compatibility - Update documentation with Solidity compatibility features
- Implement automatic detection of circular dependencies in buf/validate types - Add CIRCULAR_DEPENDENCY_MAP for FieldRules, MapRules, and RepeatedRules - Use bytes fields with encode/decode helpers to break circular references - Apply field name mangling consistently across encoder/decoder/struct generation - Add comprehensive circular dependency handling in gen_decoder.py - Add struct generation support for circular fields with descriptive comments - Update encoder to handle circular dependencies as simple byte assignments - Extend runtime type mappings to support float/double validation constraints - Update documentation with circular dependency resolution examples
- Add buf.plugin.yaml for Buf Schema Registry distribution - Include plugin metadata, dependencies, and runtime requirements - Add comprehensive BSR integration documentation - Provide buf.gen.yaml examples for local development - Document plugin options and configuration parameters - Respect original datachainlab project attribution
- Add service-to-interface code generation capability - Generate interface functions for each RPC method in proto services - Support proto field type mapping to Solidity types - Use generic library naming instead of hardcoded prefixes - Enable 1:1 mapping between proto services and contract interfaces - Add comprehensive README documentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add Contract Interface Generation from Proto Services
Overview
This PR adds the ability to generate Solidity contract interfaces directly from Protocol Buffer service definitions, enabling true proto-first blockchain development.
What This Adds
Service-to-Interface Generation
interfacedeclarations from protoservicedefinitionsType System Integration
Development Workflow
Example
Proto Service Definition:
Generated Solidity Interface:
Contract Implementation:
Benefits
Files Changed
src/protoc/plugin/gen_sol.py: Addedgen_contract_interface()function and service processingREADME.md: Added comprehensive documentation with examplesTesting
This feature has been validated with a real-world attestor contract implementation, demonstrating:
Backward Compatibility
This change is fully backward compatible. Existing proto files that only contain messages will continue to work exactly as before. The new interface generation only activates when proto services are present.