Skip to content

Commit

Permalink
Merge pull request mana-ethereum#77 from mana-ethereum/inomurko/batch…
Browse files Browse the repository at this point in the history
…_requests_url

support url opts for batch requests
  • Loading branch information
Ino Murko authored Jun 26, 2020
2 parents a7319f2 + cee2bc2 commit 0427574
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.6.3
* Make batch requests support configurable url via opts argument (https://github.com/mana-ethereum/ethereumex/pull/77)

# 0.6.2
* Make `telemetry` required dependency (https://github.com/mana-ethereum/ethereumex/pull/73)

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Add Ethereumex to your `mix.exs` dependencies:
1. Add `ethereumex` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:ethereumex, "~> 0.6.1"}]
[{:ethereumex, "~> 0.6.3"}]
end
```

Expand Down Expand Up @@ -179,7 +179,7 @@ In order to call a smart contract using the JSON-RPC interface you need to prope
defp deps do
[
...
{:ethereumex, "~> 0.6.2"},
{:ethereumex, "~> 0.6.3"},
{:ex_abi, "~> 0.4.0"}
...
]
Expand Down Expand Up @@ -228,7 +228,7 @@ iex> Ethereumex.HttpClient.request("personal_listAccounts", [], [])

### Batch requests

To send batch requests use Ethereumex.HttpClient.batch_request/1 method.
To send batch requests use Ethereumex.HttpClient.batch_request/1 or batch_request/2 method.

```elixir
requests = [
Expand Down
4 changes: 2 additions & 2 deletions lib/ethereumex/client/base_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -438,15 +438,15 @@ defmodule Ethereumex.Client.BaseClient do
end

@impl true
def batch_request(methods) do
def batch_request(methods, opts \\ []) do
methods
|> Enum.map(fn {method, params} ->
opts = [batch: true]
params = params ++ [opts]

apply(__MODULE__, method, params)
end)
|> server_request
|> server_request(opts)
end

@impl true
Expand Down
3 changes: 2 additions & 1 deletion lib/ethereumex/client/behaviour.ex
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@ defmodule Ethereumex.Client.Behaviour do
@callback request(binary(), list(boolean() | binary()), keyword()) ::
{:ok, any() | [any()]} | error
@callback single_request(map(), keyword()) :: {:ok, any() | [any()]} | error
@callback batch_request([{atom(), list(boolean() | binary())}]) :: {:ok, [any()]} | error
@callback batch_request([{atom(), list(boolean() | binary())}], keyword()) ::
{:ok, [any()]} | error
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Ethereumex.Mixfile do
def project do
[
app: :ethereumex,
version: "0.6.2",
version: "0.6.3",
elixir: "~> 1.7",
description: "Elixir JSON-RPC client for the Ethereum blockchain",
package: [
Expand Down

0 comments on commit 0427574

Please sign in to comment.