From f5ab1ac0da6be98acdd0dc92449e4eebcc01bdc6 Mon Sep 17 00:00:00 2001 From: steffenix <87598469+steffenix@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:28:49 +0200 Subject: [PATCH] Fix return value is the function signature (#174) * fix return value matching the function signature * fix removed tool version --- lib/abi/type_decoder.ex | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/abi/type_decoder.ex b/lib/abi/type_decoder.ex index c78974a..5fbbcd0 100644 --- a/lib/abi/type_decoder.ex +++ b/lib/abi/type_decoder.ex @@ -151,9 +151,16 @@ defmodule ABI.TypeDecoder do def decode(encoded_data, %FunctionSelector{returns: types, method_id: method_id}, :output) when is_binary(method_id) do - case ABI.Util.split_method_id(encoded_data) do - {:ok, ^method_id, rest} -> decode_raw(rest, types) - _ -> decode_raw(encoded_data, types) + if rem(byte_size(encoded_data), 32) == 0 do + decode_raw(encoded_data, types) + else + case ABI.Util.split_method_id(encoded_data) do + {:ok, ^method_id, rest} -> + decode_raw(rest, types) + + _ -> + decode_raw(encoded_data, types) + end end end