Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Types and Incorrect Typings in openrpc.json #3182

Open
blouflashdb opened this issue Dec 5, 2024 · 1 comment
Open

Missing Types and Incorrect Typings in openrpc.json #3182

blouflashdb opened this issue Dec 5, 2024 · 1 comment

Comments

@blouflashdb
Copy link

While working on creating TypeScript typings from the generated openrpc.json file, I noticed some issues:

1. Missing Types

Certain types that are defined in the source code are missing from the openrpc.json. For example, the following type is not included:
Type Definition

There may be other missing types as well.

2. Incorrect Typings for Subscribe Methods

The typings for all subscribe methods in the openrpc.json appear to be incorrect. For example:

{
  "name": "subscribeForHeadBlock",
  "description": "Subscribes to new block events (retrieves the full block).",
  "tags": [
    {
      "name": "blockchain"
    },
    {
      "name": "stream"
    }
  ],
  "params": [
    {
      "name": "includeBody",
      "schema": {
        "type": "boolean"
      },
      "required": true
    }
  ],
  "result": {
    "name": "BoxStream",
    "schema": {
      "type": "number"
    }
  }
}

The result states it returns a number, but that is not what the stream actually sends.

Impact

These issues make it difficult to rely on the openrpc.json as a source of truth for interacting with the RPC server. Developers are forced to figure out the actual behavior themselves, which leads to a poor developer experience.

Proposed Improvements

Ensure all relevant types from the source code are included in the openrpc.json.
Correct the typings for the subscribe methods to accurately represent the structure and type of the data they return.

Thank you for addressing this issue!

@sisou
Copy link
Member

sisou commented Dec 6, 2024

While I agree that certain types are wrong or missing, specifically the subscribe method is actually correct. It is an RPC call that returns a number, which is the subscription ID. This ID can be used to unsubscribe, and the actual subscription events are sent outside this call as "server-sent events", which contain the subscription ID in their body and are not documented anywhere unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants