Skip to content

Commit

Permalink
eth/client: always return hash even if transaction didn't succeed (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
q9f authored Jul 2, 2024
1 parent 8547bd1 commit fd5b6b5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
3 changes: 1 addition & 2 deletions lib/eth/abi/decoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,18 @@ def type(type, arg)
elsif type.base_type == "tuple"
offset = 0
data = {}
raise DecodingError, "Cannot decode tuples without known components" if type.components.nil?
type.components.each do |c|
if c.dynamic?
pointer = Util.deserialize_big_endian_to_int arg[offset, 32] # Pointer to the size of the array's element
data_len = Util.deserialize_big_endian_to_int arg[pointer, 32] # length of the element

data[c.name] = type(c, arg[pointer, Util.ceil32(data_len) + 32])
# puts data
offset += 32
else
size = c.size
data[c.name] = type(c, arg[offset, size])
offset += size
# puts data
end
end
data
Expand Down
4 changes: 2 additions & 2 deletions lib/eth/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,11 @@ def transact(contract, function, *args, **kwargs)
# See {#transact} for params and overloads.
#
# @raise [Client::ContractExecutionError] if the execution fails.
# @return [Object] returns the result of the transaction.
# @return [Object, Boolean] returns the result of the transaction (hash and execution status).
def transact_and_wait(contract, function, *args, **kwargs)
begin
hash = wait_for_tx(transact(contract, function, *args, **kwargs))
return hash if tx_succeeded? hash
return hash, tx_succeeded?(hash)
rescue IOError => e
raise ContractExecutionError, e
end
Expand Down
Loading

0 comments on commit fd5b6b5

Please sign in to comment.