typings icon indicating copy to clipboard operation
typings copied to clipboard

Invalid Rust bindings are generated

Open Wodann opened this issue 3 years ago • 0 comments

I tried generating Rust bindings for this openrpc.json: https://raw.githubusercontent.com/ethereum/execution-apis/v1.0.0-beta.1/refs-openrpc.json; but it resulted in invalid Rust code.

The problems I'm seeing:

  • [ ] duplicate Rust types (https://github.com/open-rpc/typings/issues/42 mentions this having been resolved for Rust)
  • [ ] cyclic type definitions
    {
    	"name": "rewardPercentiles",
    	"description": "A monotonically increasing list of percentile values. For each block in the requested range, the transactions will be sorted in ascending order by effective tip per gas and the coresponding effective tip for the percentile will be determined, accounting for gas consumed.",
    	"required": true,
    	"schema": {
    		"title": "rewardPercentiles",
    		"type": "array",
    		"items": {
    			"title": "rewardPercentile",
    			"description": "Floating point value between 0 and 100.",
    			"type": "number"
    		}
    	}
    }
    
    results in this Rust code:
    pub type RewardPercentiles = Vec<RewardPercentile>;
    
    where I would have expected something like:
    pub type RewardPercentiles = Vec<u32>;
    
  • [ ] functions are generated without a body. E.g.
    pub fn EthGetBlockByHash(&mut self, Block hash: 2ByteHexValue, Hydrated transactions: Hydrated) -> RpcRequest<BlockObject>;
    

Wodann avatar Sep 24 '22 13:09 Wodann