Skip to content

Commit

Permalink
feat: comply with new Infura API (#1754)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgebal authored Oct 26, 2020
1 parent c6cb81f commit 34b9d54
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ jobs:
key: v3-plt-cache-{{ ".tool-versions" }}
paths:
- plts
- run: mix dialyzer --format short --halt-exit-status
- run: mix dialyzer --format short

test_docker_compose_release:
machine:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ check-credo:
$(ENV_TEST) mix credo 2>&1

check-dialyzer:
$(ENV_TEST) mix dialyzer --halt-exit-status 2>&1
$(ENV_TEST) mix dialyzer 2>&1

.PHONY: format check-format check-credo

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ defmodule Support.Conformance.MerkleProofs do
defp call_contract(contract, signature, args, return_types) do
data = ABI.encode(signature, args)

{:ok, return} = Ethereumex.HttpClient.eth_call(%{to: Encoding.to_hex(contract), data: Encoding.to_hex(data)})
{:ok, return} =
Ethereumex.HttpClient.eth_call(%{
from: Encoding.to_hex(contract),
to: Encoding.to_hex(contract),
data: Encoding.to_hex(data)
})

decode_answer(return, return_types)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@ defmodule Support.Conformance.SignaturesHashes do
defp call_contract(contract, signature, args, return_types) do
data = ABI.encode(signature, args)

{:ok, return} = Ethereumex.HttpClient.eth_call(%{to: Encoding.to_hex(contract), data: Encoding.to_hex(data)})
{:ok, return} =
Ethereumex.HttpClient.eth_call(%{
from: Encoding.to_hex(contract),
to: Encoding.to_hex(contract),
data: Encoding.to_hex(data)
})

decode_answer(return, return_types)
end

Expand Down
2 changes: 1 addition & 1 deletion apps/omg_eth/lib/omg_eth/root_chain/rpc.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defmodule OMG.Eth.RootChain.Rpc do

def call_contract(client \\ Ethereumex.HttpClient, contract, signature, args) do
data = signature |> ABI.encode(args) |> Encoding.to_hex()
client.eth_call(%{to: contract, data: data})
client.eth_call(%{from: contract, to: contract, data: data})
end

def get_ethereum_events(block_from, block_to, [_ | _] = signatures, [_ | _] = contracts) do
Expand Down
2 changes: 1 addition & 1 deletion apps/omg_eth/test/fixtures.exs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ defmodule OMG.Eth.Fixtures do

defp call_contract(contract, signature, args, return_types) do
data = ABI.encode(signature, args)
{:ok, return} = Ethereumex.HttpClient.eth_call(%{to: contract, data: Encoding.to_hex(data)})
{:ok, return} = Ethereumex.HttpClient.eth_call(%{from: contract, to: contract, data: Encoding.to_hex(data)})
decode_answer(return, return_types)
end

Expand Down
1 change: 1 addition & 0 deletions priv/perf/apps/load_test/lib/child_chain/exit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ defmodule LoadTest.ChildChain.Exit do

{:ok, receipt_enc} =
Ethereumex.HttpClient.eth_call(%{
from: Application.fetch_env!(:load_test, :contract_address_plasma_framework),
to: Application.fetch_env!(:load_test, :contract_address_plasma_framework),
data: Encoding.to_hex(data)
})
Expand Down
8 changes: 6 additions & 2 deletions priv/perf/apps/load_test/lib/ethereum/ethereum.ex
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ defmodule LoadTest.Ethereum do
defp do_root_chain_get_erc20_balance(address, currency) do
data = ABI.encode("balanceOf(address)", [Encoding.to_binary(address)])

case Ethereumex.HttpClient.eth_call(%{to: Encoding.to_hex(currency), data: Encoding.to_hex(data)}) do
case Ethereumex.HttpClient.eth_call(%{
from: Encoding.to_hex(currency),
to: Encoding.to_hex(currency),
data: Encoding.to_hex(data)
}) do
{:ok, result} ->
balance =
result
Expand All @@ -174,7 +178,7 @@ defmodule LoadTest.Ethereum do
defp get_external_data(address, signature, params) do
data = signature |> ABI.encode(params) |> Encoding.to_hex()

{:ok, data} = Ethereumex.HttpClient.eth_call(%{to: address, data: data})
{:ok, data} = Ethereumex.HttpClient.eth_call(%{from: address, to: address, data: data})

Abi.decode_function(data, signature)
end
Expand Down

0 comments on commit 34b9d54

Please sign in to comment.