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

Add function to get ABI from non-etherscan addresses #50

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions eth_client/lib/eth_client/abi.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,27 @@ defmodule EthClient.ABI do
"""
alias EthClient.Context

# get whether it's an etherscan-linked bc
# if it is, use provided ABI
# elsewise, get ABI through invoking panoramix on rpc provider
def get("0x" <> _ = address), do: get_etherscan(address)



def get(abi_path), do: get_local(abi_path)

defp get_non_etherscan(address) do
# if it exists, use provided ABI (.bin -> .abi) (?)
# elsewise, get ABI through invoking panoramix on rpc provider (if possible)

{path, _} = System.cmd("command", ["-v", "python3"])

{:ok, python_pid} = :python.start(python: '/opt/homebrew/bin/python3')
:python.call(python_pid, :'panoramix.decompiler', :decompile_address, [<<address>>])
:python.stop(python_pid)

end
mfachal marked this conversation as resolved.
Show resolved Hide resolved

defp get_etherscan(address) do
api_key = Context.etherscan_api_key()

Expand Down
3 changes: 2 additions & 1 deletion eth_client/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ defmodule EthClient.MixProject do
{:ex_abi, "~> 0.5"},
{:rustler, "~> 0.25.0"},
{:ex_rlp, "~> 0.5.4"},
{:dialyxir, "~> 1.0", only: [:dev], runtime: false}
{:dialyxir, "~> 1.0", only: [:dev], runtime: false},
{:erlport, "~>0.10.1"}
]
end
end