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

Convert UltralightProvider into a pure EIP-1193 JSON-RPC Provider #687

Open
acolytec3 opened this issue Dec 8, 2024 · 3 comments
Open

Comments

@acolytec3
Copy link
Collaborator

The current implementation of the UltralightProvider extends the ethers.JsonRpcProvider class from ethers v5 and is basically useless at this point. We should convert it into a pure EIP-1193 provider so it can be used independent of a specific implementation of a web3 library. Updates do not need to implement the complete spec (as that isn't currently possible since Portal Network doesn't have any way to realistically support subscriptions right now), but focus on just implementing the request method as specified in the EIP and return appropriate error messages.

@cjustinobi
Copy link

Hello @acolytec, I'd like to work on this issue. I'll start implementing the request method

@acolytec3
Copy link
Collaborator Author

@cjustinobi great! So the basic idea is to take this implementation and replace it with something that just exposes the request method from the EIP-1193 documentation.

Then, under the hood, this provider should check the method name when a call to request is received and should return a 4200 error if one of the below is not supported:
eth_getBlockByHash
eth_getBlockByNumber
eth_getTransactionCount
eth_getCode
eth_getBalance
eth_getStorageAt
eth_call

If one of these methods is called, you can use the client.eth that's exposed here to retrieve the data from the Portal Network and then return it in a manner specified by the EIP.

Other notes:
All references to ethers should be removed as this is not intended to be an ethers specific provider implementation. You can also remove the getBlock and getBlockWithTransactions methods that are in the current implementation as those are legacy and only pertained to the ethers specific API.

Lemme know if this makes sense! Also, feel free to drop by our Discord with specific questions

@cjustinobi
Copy link

This helps a lot

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

No branches or pull requests

2 participants