Sha256: fbdad133ce6fc59f387a24b92f327260d01649c4fb50784add927d58340b3072

Contents?: true

Size: 775 Bytes

Versions: 5

Compression:

Stored size: 775 Bytes

Contents

module Etherlite
  class Transaction
    attr_reader :tx_hash, :receipt

    def initialize(_connection, _tx_hash)
      @connection = _connection
      @tx_hash = _tx_hash
      @receipt = {}
    end

    def refresh
      @receipt = @connection.eth_get_transaction_receipt(@tx_hash) || {}
      mined?
    end

    def mined?
      @receipt.key? 'blockNumber'
    end

    def gas_used
      Utils.hex_to_uint @receipt['gasUsed']
    end

    def block_number
      Utils.hex_to_uint @receipt['blockNumber']
    end

    def contract_address
      @receipt['contractAddress']
    end

    def wait_for_block(timeout: 120)
      start = Time.now
      while !refresh
        return false if Time.now - start > timeout
        sleep 1
      end

      true
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
etherlite-0.2.0 lib/etherlite/transaction.rb
etherlite-0.1.8 lib/etherlite/transaction.rb
etherlite-0.1.7 lib/etherlite/transaction.rb
etherlite-0.1.6 lib/etherlite/transaction.rb
etherlite-0.1.5 lib/etherlite/transaction.rb