Skip to content

Commit

Permalink
Merge pull request #50 from izelnakri/jason-refactor
Browse files Browse the repository at this point in the history
[dependency upgrades] Poison replaced with jason and httpoison upgrade
  • Loading branch information
izelnakri authored Nov 4, 2018
2 parents f8e18f8 + 22db40f commit 3981a52
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.5.1
* Replaced poison with jason
* Upgraded httpoison to v1.4

# 0.5.0
* Remove tunneling requests (https://github.com/exthereum/ethereumex/pull/46)
* Use poolboy for IpcClient (https://github.com/exthereum/ethereumex/pull/47)
Expand Down
2 changes: 1 addition & 1 deletion lib/ethereumex/client/base_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ defmodule Ethereumex.Client.BaseClient do

@spec encode_payload(map()) :: binary()
defp encode_payload(payload) do
payload |> Poison.encode!()
payload |> Jason.encode!()
end

@spec format_batch([map()]) :: [map() | nil | binary()]
Expand Down
2 changes: 1 addition & 1 deletion lib/ethereumex/http_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defmodule Ethereumex.HttpClient do

@spec decode_body(binary(), integer()) :: {:ok | :error, any()}
defp decode_body(body, code) do
with {:ok, decoded_body} <- Poison.decode(body) do
with {:ok, decoded_body} <- Jason.decode(body) do
case {code, decoded_body} do
{200, %{"error" => error}} -> {:error, error}
{200, result = [%{} | _]} -> {:ok, format_batch(result)}
Expand Down
2 changes: 1 addition & 1 deletion lib/ethereumex/ipc_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule Ethereumex.IpcClient do
@spec post_request(binary(), []) :: {:ok | :error, any()}
def post_request(payload, _opts) do
with {:ok, response} <- call_ipc(payload) do
with {:ok, decoded_body} <- Poison.decode(response) do
with {:ok, decoded_body} <- Jason.decode(response) do
case decoded_body do
%{"error" => error} -> {:error, error}
result = [%{} | _] -> {:ok, format_batch(result)}
Expand Down
8 changes: 4 additions & 4 deletions 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.5.0",
version: "0.5.1",
elixir: "~> 1.7",
description: "Elixir JSON-RPC client for the Ethereum blockchain",
package: [
Expand All @@ -17,7 +17,7 @@ defmodule Ethereumex.Mixfile do
deps: deps(),
dialyzer: [
flags: [:underspecs, :unknown, :unmatched_returns],
plt_add_apps: [:mix, :poison, :iex, :logger],
plt_add_apps: [:mix, :jason, :iex, :logger],
plt_add_deps: :transitive
]
]
Expand All @@ -33,8 +33,8 @@ defmodule Ethereumex.Mixfile do

defp deps do
[
{:httpoison, "~> 1.3.1"},
{:poison, "~> 4.0.1"},
{:httpoison, "~> 1.4.0"},
{:jason, "~> 1.1"},
{:credo, "~> 0.10.2", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.19", only: :dev, runtime: false},
{:dialyxir, "~> 1.0.0-rc.3", only: [:dev], runtime: false},
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"exjsx": {:hex, :exjsx, "3.2.1", "1bc5bf1e4fd249104178f0885030bcd75a4526f4d2a1e976f4b428d347614f0f", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm"},
"exvcr": {:hex, :exvcr, "0.8.9", "e01a4e7c288e964efd0b444136a4388ad1b21a1f00e2e571427bc7a602e29a76", [:mix], [{:exactor, "~> 2.2", [hex: :exactor, repo: "hexpm", optional: false]}, {:exjsx, "~> 3.2", [hex: :exjsx, repo: "hexpm", optional: false]}, {:httpoison, "~> 0.11", [hex: :httpoison, repo: "hexpm", optional: true]}, {:httpotion, "~> 3.0", [hex: :httpotion, repo: "hexpm", optional: true]}, {:ibrowse, "~> 4.2.2", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:meck, "~> 0.8.3", [hex: :meck, repo: "hexpm", optional: false]}], "hexpm"},
"hackney": {:hex, :hackney, "1.14.3", "b5f6f5dcc4f1fba340762738759209e21914516df6be440d85772542d4a5e412", [:rebar3], [{:certifi, "2.4.2", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"httpoison": {:hex, :httpoison, "1.3.1", "7ac607311f5f706b44e8b3fab736d0737f2f62a31910ccd9afe7227b43edb7f0", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
"httpoison": {:hex, :httpoison, "1.4.0", "e0b3c2ad6fa573134e42194d13e925acfa8f89d138bc621ffb7b1989e6d22e73", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
"jason": {:hex, :jason, "1.1.1", "d3ccb840dfb06f2f90a6d335b536dd074db748b3e7f5b11ab61d239506585eb2", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"jsx": {:hex, :jsx, "2.8.2", "7acc7d785b5abe8a6e9adbde926a24e481f29956dd8b4df49e3e4e7bcc92a018", [:mix, :rebar3], [], "hexpm"},
Expand Down
2 changes: 1 addition & 1 deletion test/ethereumex/client/base_client_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Ethereumex.Client.BaseClientTest do
use Ethereumex.Client.BaseClient

def post_request(payload, opts) do
%{"method" => method, "jsonrpc" => "2.0", "params" => params} = Poison.decode!(payload)
%{"method" => method, "jsonrpc" => "2.0", "params" => params} = Jason.decode!(payload)

{method, params, opts}
end
Expand Down

0 comments on commit 3981a52

Please sign in to comment.