Class: Receipt
- Inherits:
-
Object
- Object
- Receipt
- Defined in:
- lib/universum/receipt.rb
Overview
transaction receipt
Constant Summary collapse
- @@directory =
{}
Instance Attribute Summary collapse
-
#block_number ⇒ Object
readonly
required attributes / fields.
-
#contract_address ⇒ Object
readonly
optional.
-
#from ⇒ Object
readonly
required attributes / fields.
-
#nonce ⇒ Object
readonly
required attributes / fields.
-
#to ⇒ Object
readonly
required attributes / fields.
-
#value ⇒ Object
readonly
required attributes / fields.
Class Method Summary collapse
Instance Method Summary collapse
-
#contract ⇒ Object
convenience helper (quick contract lookup).
-
#initialize(tx:, block:, contract: nil) ⇒ Receipt
constructor
A new instance of Receipt.
Constructor Details
#initialize(tx:, block:, contract: nil) ⇒ Receipt
Returns a new instance of Receipt.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/universum/receipt.rb', line 25 def initialize( tx:, block:, contract: nil ) @nonce = tx.nonce @from = tx.from @to = tx.to @value = tx.value ## todo/fix: add data too!!! @block_number = block.number ## todo/fix: add block_hash if contract ## note: for easier debugging add class name in () to address (needs to get stripped away in lookup) @contract_address = "#{contract.address.hex} (#{contract.class.name})" else @contract_address = nil end end |
Instance Attribute Details
#block_number ⇒ Object (readonly)
required attributes / fields
20 21 22 |
# File 'lib/universum/receipt.rb', line 20 def block_number @block_number end |
#contract_address ⇒ Object (readonly)
optional
23 24 25 |
# File 'lib/universum/receipt.rb', line 23 def contract_address @contract_address end |
#from ⇒ Object (readonly)
required attributes / fields
20 21 22 |
# File 'lib/universum/receipt.rb', line 20 def from @from end |
#nonce ⇒ Object (readonly)
required attributes / fields
20 21 22 |
# File 'lib/universum/receipt.rb', line 20 def nonce @nonce end |
#to ⇒ Object (readonly)
required attributes / fields
20 21 22 |
# File 'lib/universum/receipt.rb', line 20 def to @to end |
#value ⇒ Object (readonly)
required attributes / fields
20 21 22 |
# File 'lib/universum/receipt.rb', line 20 def value @value end |
Class Method Details
.[](tx) ⇒ Object
11 |
# File 'lib/universum/receipt.rb', line 11 def self.[]( tx ) find( tx ); end |
.all ⇒ Object
16 |
# File 'lib/universum/receipt.rb', line 16 def self.all() @@directory.values; end |
.find(tx) ⇒ Object
7 8 9 10 |
# File 'lib/universum/receipt.rb', line 7 def self.find( tx ) key = "#{tx.from}/#{tx.nonce}" @@directory[ key ]; end |
.store(o) ⇒ Object
13 14 15 |
# File 'lib/universum/receipt.rb', line 13 def self.store( o ) key = "#{o.from}/#{o.nonce}" @@directory.store( key, o ); end |