Skip to content

Commit

Permalink
Fix Event Decoders
Browse files Browse the repository at this point in the history
This patch adds a fix to event decoders where they previously didn't properly handle "dynamic" data (e.g. strings). We wrap everything in a normal tuple and decode from that for this fix.

Bump to 1.0.0-alpha7
  • Loading branch information
hayesgm committed Mar 11, 2024
1 parent 0473903 commit ca0ca91
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 1.0.0-alpha7
* Bugfix for event decoding with dynamic parameters
# 1.0.0-alpha6
* Bugfix for is_dynamic
# 0.1.15
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ by adding `abi` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:abi, "~> 1.0.0-alpha6"}
{:abi, "~> 1.0.0-alpha7"}
]
end
```
Expand Down
10 changes: 6 additions & 4 deletions lib/abi/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ defmodule ABI.Event do
end)
|> Enum.into(%{})

non_indexed_data =
data
|> ABI.TypeDecoder.decode_raw(non_indexed_types)
[non_indexed_data] = ABI.TypeDecoder.decode_raw(data, [%{type: {:tuple, non_indexed_types}}])

non_indexed_data_map =
non_indexed_data
|> Tuple.to_list()
|> Enum.zip(non_indexed_types)
|> Enum.map(fn {res, %{name: name}} -> {name, res} end)
|> Enum.into(%{})

{function_selector.function, Map.merge(indexed_data, non_indexed_data)}
{function_selector.function, Map.merge(indexed_data, non_indexed_data_map)}
end

@doc ~S"""
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule ABI.Mixfile do
def project do
[
app: :abi,
version: "1.0.0-alpha6",
version: "1.0.0-alpha7",
elixir: "~> 1.14",
description: "Ethereum's ABI Interface",
package: [
Expand Down

0 comments on commit ca0ca91

Please sign in to comment.