Remove function Reader.query_query_unverified_contract/4

We don't need to have this function since we have `query_contract/4`
that does the same thing.
pull/1078/head
Felipe Renan 6 years ago
parent 477de645fb
commit 5f9c700e73
  1. 18
      apps/explorer/lib/explorer/smart_contract/reader.ex
  2. 30
      apps/explorer/test/explorer/smart_contract/reader_test.exs

@ -77,26 +77,16 @@ defmodule Explorer.SmartContract.Reader do
end
@doc """
Runs contract functions on a given address for an unverified contract with an expected ABI.
Runs contract functions on a given address for smart contract with an expected ABI and functions.
This function can be used to read data from smart contracts that are not verified (like token contracts)
since it receives the ABI as an argument.
## Options
* `:json_rpc_named_arguments` - Options to forward for calling the Ethereum JSON RPC. See
`t:EthereumJSONRPC.json_rpc_named_arguments.t/0` for full list of options.
"""
@spec query_unverified_contract(Hash.Address.t(), [map()], functions(), contract_call_options()) ::
functions_results()
def query_unverified_contract(
%Hash{byte_count: unquote(Hash.Address.byte_count())} = address,
abi,
functions,
opts \\ []
) do
contract_address = Hash.to_string(address)
query_contract(contract_address, abi, functions, opts)
end
@spec query_contract(
String.t(),
term(),

@ -115,36 +115,6 @@ defmodule Explorer.SmartContract.ReaderTest do
end
end
test "query_unverified_contract/3" do
address = insert(:address)
abi = [
%{
"constant" => true,
"inputs" => [],
"name" => "decimals",
"outputs" => [
%{
"name" => "",
"type" => "uint8"
}
],
"payable" => false,
"type" => "function"
}
]
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn [%{id: id, method: _, params: [%{data: _, to: _}, _]}], _options ->
{:ok, [%{id: id, jsonrpc: "2.0", result: "0x0000000000000000000000000000000000000000000000000000000000000012"}]}
end
)
assert Reader.query_unverified_contract(address.hash, abi, %{"decimals" => []}) == %{"decimals" => {:ok, [18]}}
end
describe "setup_call_payload/2" do
test "returns the expected payload" do
function_name = "get"

Loading…
Cancel
Save