Class: EvmClient::Transaction
- Inherits:
-
Object
- Object
- EvmClient::Transaction
- Defined in:
- lib/evm_client/transaction.rb
Constant Summary collapse
- DEFAULT_TIMEOUT =
300.seconds
- DEFAULT_STEP =
5.seconds
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#id ⇒ Object
Returns the value of attribute id.
-
#input ⇒ Object
Returns the value of attribute input.
-
#input_parameters ⇒ Object
Returns the value of attribute input_parameters.
-
#mined ⇒ Object
Returns the value of attribute mined.
Class Method Summary collapse
Instance Method Summary collapse
- #address ⇒ Object
-
#initialize(id, connection, data, input_parameters = []) ⇒ Transaction
constructor
A new instance of Transaction.
- #mined? ⇒ Boolean
- #wait_for_miner(timeout: DEFAULT_TIMEOUT, step: DEFAULT_STEP) ⇒ Object
Constructor Details
#initialize(id, connection, data, input_parameters = []) ⇒ Transaction
Returns a new instance of Transaction.
10 11 12 13 14 15 16 |
# File 'lib/evm_client/transaction.rb', line 10 def initialize(id, connection, data, input_parameters = []) @mined = false @connection = connection @id = id @input = data @input_parameters = input_parameters end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
8 9 10 |
# File 'lib/evm_client/transaction.rb', line 8 def connection @connection end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/evm_client/transaction.rb', line 8 def id @id end |
#input ⇒ Object
Returns the value of attribute input.
8 9 10 |
# File 'lib/evm_client/transaction.rb', line 8 def input @input end |
#input_parameters ⇒ Object
Returns the value of attribute input_parameters.
8 9 10 |
# File 'lib/evm_client/transaction.rb', line 8 def input_parameters @input_parameters end |
#mined ⇒ Object
Returns the value of attribute mined.
8 9 10 |
# File 'lib/evm_client/transaction.rb', line 8 def mined @mined end |
Class Method Details
.from_blockchain(address, connection = IpcClient.new) ⇒ Object
37 38 39 |
# File 'lib/evm_client/transaction.rb', line 37 def self.from_blockchain(address, connection = IpcClient.new) Transaction.new(address, connection, nil, nil) end |
Instance Method Details
#address ⇒ Object
18 19 20 |
# File 'lib/evm_client/transaction.rb', line 18 def address @id end |
#mined? ⇒ Boolean
22 23 24 25 26 |
# File 'lib/evm_client/transaction.rb', line 22 def mined? return true if @mined tx = @connection.eth_get_transaction_by_hash(@id) @mined = !tx.nil? && !tx["result"].nil? && tx["result"]["blockNumber"].present? end |
#wait_for_miner(timeout: DEFAULT_TIMEOUT, step: DEFAULT_STEP) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/evm_client/transaction.rb', line 28 def wait_for_miner(timeout: DEFAULT_TIMEOUT, step: DEFAULT_STEP) start_time = Time.now loop do raise Timeout::Error if ((Time.now - start_time) > timeout) return true if self.mined? sleep step end end |