52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/web3/eth/contract.rb', line 52
def parse_event_args log
log_data = remove_0x_head log.raw_data['data']
indexed_types = abi['inputs'].select{|a| a['indexed']}.collect{|a| parse_component_type a }
not_indexed_types = abi['inputs'].select{|a| !a['indexed']}.collect{|a| parse_component_type a }
indexed_args = log.indexed_args
if indexed_args.size==indexed_types.size
indexed_values = [indexed_types, indexed_args].transpose.collect{|arg|
decode_typed_data( arg.first, [arg.second].pack('H*') )
}
not_indexed_values = not_indexed_types.empty? ? [] :
decode_abi(not_indexed_types, [log_data].pack('H*') )
i = j = 0
abi['inputs'].collect{|input|
input['indexed'] ? (i+=1; indexed_values[i-1]) : (j+=1;not_indexed_values[j-1])
}
elsif !indexed_args.empty? || !log_data.empty?
all_types = abi['inputs'].collect{|a| parse_component_type a }
[all_types[0...indexed_args.size], indexed_args].transpose.collect{|arg|
decode_typed_data( arg.first, [arg.second].pack('H*') )
} + decode_abi(all_types[indexed_args.size..-1], [log_data].pack('H*') )
else
[]
end
end
|