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

Fix batch JSON-RPC request support #38

Merged
merged 4 commits into from
Aug 30, 2019
Merged

Fix batch JSON-RPC request support #38

merged 4 commits into from
Aug 30, 2019

Conversation

unnawut
Copy link
Contributor

@unnawut unnawut commented Aug 30, 2019

Issue/Task Number: -

Overview

This PR fixes the error when Potterhat receives a JSON-RPC batch request.

This bug was found while integrating Potterhat with omisego/ewallet's eth-blockchain branch.

Changes

  • Updated PotterhatRPC.Router

Implementation Details

When Phoenix receives a JSON array as body params, it wraps those params in a %{"_json" => _} map before passing it to the router. So an extra condition is added to support this quirk.

Usage

Try send a batch request to Potterhat. E.g.

curl -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
--data '[
  {
    "id" => 1001,
    "jsonrpc" => "2.0",
    "method" => "eth_getBalance",
    "params" => ["0x0000000000000000000000000000000000000001", "latest"]
  },
  {
    "id" => 1002,
    "jsonrpc" => "2.0",
    "method" => "eth_getBalance",
    "params" => ["0x0000000000000000000000000000000000000002", "latest"]
  }
]'

A successful response should be returned instead of an internal server error.

Impact

No changes to API or DB.

@unnawut unnawut self-assigned this Aug 30, 2019
Unnawut Leepaisalsuwanna added 2 commits August 30, 2019 15:17
@unnawut unnawut merged commit 47635e5 into master Aug 30, 2019
@unnawut unnawut deleted the fix-batch-requests branch August 30, 2019 09:34
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

Successfully merging this pull request may close these issues.

None yet

3 participants