Class: BlockGiven::Event
- Inherits:
-
Object
- Object
- BlockGiven::Event
- Defined in:
- lib/block_given/event.rb
Overview
A decoded event log.
event.name # => "Transfer"
event.args # => { from: "0x...", to: "0x...", value: 1000000 }
event[:value] # => 1000000
event.block_number # => 12345
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#log ⇒ Object
readonly
Returns the value of attribute log.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #address ⇒ Object
- #block_hash ⇒ Object
- #block_number ⇒ Object
-
#initialize(name:, signature:, args:, log:) ⇒ Event
constructor
A new instance of Event.
- #inspect ⇒ Object
- #log_index ⇒ Object
- #removed? ⇒ Boolean
- #to_h ⇒ Object
- #transaction_hash ⇒ Object
- #transaction_index ⇒ Object
Constructor Details
#initialize(name:, signature:, args:, log:) ⇒ Event
Returns a new instance of Event.
13 14 15 16 17 18 |
# File 'lib/block_given/event.rb', line 13 def initialize(name:, signature:, args:, log:) @name = name @signature = signature @args = args @log = log end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
11 12 13 |
# File 'lib/block_given/event.rb', line 11 def args @args end |
#log ⇒ Object (readonly)
Returns the value of attribute log.
11 12 13 |
# File 'lib/block_given/event.rb', line 11 def log @log end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/block_given/event.rb', line 11 def name @name end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
11 12 13 |
# File 'lib/block_given/event.rb', line 11 def signature @signature end |
Instance Method Details
#[](key) ⇒ Object
20 |
# File 'lib/block_given/event.rb', line 20 def [](key) = args[Utils.snake_case(key).to_sym] |
#address ⇒ Object
21 |
# File 'lib/block_given/event.rb', line 21 def address = log[:address] && Utils.checksum_address(log[:address]) |
#block_hash ⇒ Object
23 |
# File 'lib/block_given/event.rb', line 23 def block_hash = log[:block_hash] |
#block_number ⇒ Object
22 |
# File 'lib/block_given/event.rb', line 22 def block_number = log[:block_number] |
#inspect ⇒ Object
34 |
# File 'lib/block_given/event.rb', line 34 def inspect = "#<BlockGiven::Event #{name} #{args.inspect} block=#{block_number}>" |
#log_index ⇒ Object
26 |
# File 'lib/block_given/event.rb', line 26 def log_index = log[:log_index] |
#removed? ⇒ Boolean
27 |
# File 'lib/block_given/event.rb', line 27 def removed? = !!log[:removed] |
#to_h ⇒ Object
29 30 31 32 |
# File 'lib/block_given/event.rb', line 29 def to_h { name: name, args: args, address: address, block_number: block_number, transaction_hash: transaction_hash, log_index: log_index } end |
#transaction_hash ⇒ Object
24 |
# File 'lib/block_given/event.rb', line 24 def transaction_hash = log[:transaction_hash] |
#transaction_index ⇒ Object
25 |
# File 'lib/block_given/event.rb', line 25 def transaction_index = log[:transaction_index] |