Class: Ethereum::Log
- Includes:
- RLP::Sedes::Serializable
- Defined in:
- lib/ethereum/log.rb
Instance Method Summary collapse
- #bloomables ⇒ Object
-
#initialize(*args) ⇒ Log
constructor
A new instance of Log.
- #to_h ⇒ Object
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(*args) ⇒ Log
Returns a new instance of Log.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ethereum/log.rb', line 13 def initialize(*args) h = parse_field_args args address = h[:address] raise ArgumentError, "invalid address: #{address}" unless address.size == 20 || address.size == 40 address = Utils.decode_hex(address) if address.size == 40 h[:address] = address super(h) end |
Instance Method Details
#bloomables ⇒ Object
25 26 27 |
# File 'lib/ethereum/log.rb', line 25 def bloomables topics.map {|t| Sedes.int32.serialize(t) }.unshift(address) end |
#to_h ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/ethereum/log.rb', line 29 def to_h { bloom: Utils.encode_hex(Bloom.b256(Bloom.from_array(bloomables))), address: Utils.encode_hex(address), data: "0x#{Utils.encode_hex(data)}", topics: topics.map {|t| Utils.encode_hex(Sedes.int32.serialize(t)) } } end |
#to_s ⇒ Object Also known as: inspect
37 38 39 |
# File 'lib/ethereum/log.rb', line 37 def to_s "#<#{self.class.name}:#{object_id} address=#{Utils.encode_hex(address)} topics=#{topics} data=#{data}>" end |