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

abi parsing from json #46

Closed
InoMurko opened this issue Dec 7, 2020 · 0 comments · Fixed by #47
Closed

abi parsing from json #46

InoMurko opened this issue Dec 7, 2020 · 0 comments · Fixed by #47
Assignees

Comments

@InoMurko
Copy link
Contributor

InoMurko commented Dec 7, 2020

22:26:07.792 [warn]  couldn't parse! PaymentChallengeIFENotCanonical.json

 because of %MatchError{term: {:error, {1, :ethereum_abi_parser, ['syntax error before: ', ['"PlasmaFramework"']]}}}

22:26:07.823 [warn]  couldn't parse! PaymentPiggybackInFlightExit.json because of %MatchError{term: {:error, {1, :ethereum_abi_parser, ['syntax error before: ', ['"PlasmaFramework"']]}}}

22:26:07.888 [warn]  couldn't parse! PaymentStartStandardExit.json because of %MatchError{term: {:error, {1, :ethereum_abi_parser, ['syntax error before: ', ['"IExitProcessor"']]}}}

22:26:08.069 [warn]  couldn't parse! PaymentChallengeStandardExit.json because of %MatchError{term: {:error, {1, :ethereum_abi_parser, ['syntax error before: ', ['"PlasmaFramework"']]}}}

22:26:08.471 [warn]  couldn't parse! PaymentStartInFlightExit.json because of %MatchError{term: {:error, {1, :ethereum_abi_parser, ['syntax error before: ', ['"PlasmaFramework"']]}}}

22:26:08.543 [warn]  couldn't parse! PaymentInFlightExitRouterMock.json because of %RuntimeError{message: "Unsupported type: :tuple"}

22:26:08.651 [warn]  couldn't parse! PaymentChallengeIFEInputSpent.json
 because of %MatchError{term: {:error, {1, :ethereum_abi_parser, ['syntax error before: ', ['"PlasmaFramework"']]}}}

Code to reproduce:

defmodule AbiEvents do
  @moduledoc """
  Extract ABI event definitions from contract ABIs
  """
  require Logger

  def get(abi_path) do
    abi_path
    |> File.ls!()
    |> Enum.map(fn file ->
      try do
        [abi_path, file]
        |> Path.join()
        |> File.read!()
        |> Jason.decode!()
        |> Map.fetch!("abi")
        |> ABI.parse_specification(include_events?: true)
      rescue
        x in [MatchError, RuntimeError] ->
          _ = Logger.warn("couldn't parse! #{file} because of #{inspect(x)}")
          []
      end
    end)
    |> List.flatten()
    |> Enum.filter(fn fs -> fs.type == :event end)
  end
end

ABIS: Archive.zip

@ayrat555 ayrat555 self-assigned this Dec 8, 2020
ayrat555 added a commit that referenced this issue Dec 9, 2020
…ypes

### Changes:
- Function selector parsing fails on user-defined complex types (6ffcd54)
- Fix parsing of fixed tuple array (0b4aee7)

fixes #46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants