module Etherlite::Api::Node

Public Instance Methods

account_from_pk(_pk) click to toggle source
# File lib/etherlite/api/node.rb, line 63
      def account_from_pk(_pk)
        Etherlite.logger.warn(
          "use of 'account_from_pk' is deprecated and will be removed in next version, \
use 'load_account' instead"
        )

        load_account(from_pk: _pk)
      end
accounts() click to toggle source
# File lib/etherlite/api/node.rb, line 49
def accounts
  connection.ipc_call(:eth_accounts).map do |address|
    Etherlite::Account::Local.new @connection, Etherlite::Utils.normalize_address(address)
  end
end
anonymous_account() click to toggle source
# File lib/etherlite/api/node.rb, line 59
def anonymous_account
  @anonymous_account ||= Etherlite::Account::Anonymous.new(connection)
end
default_account() click to toggle source
# File lib/etherlite/api/node.rb, line 55
def default_account
  @default_account ||= (accounts.first || anonymous_account)
end
get_block_number() click to toggle source
# File lib/etherlite/api/node.rb, line 7
def get_block_number
  connection.eth_block_number
end
get_gas_price() click to toggle source
# File lib/etherlite/api/node.rb, line 11
def get_gas_price
  connection.eth_gas_price
end
get_logs(events: nil, address: nil, from_block: :earliest, to_block: :latest) click to toggle source
# File lib/etherlite/api/node.rb, line 19
def get_logs(events: nil, address: nil, from_block: :earliest, to_block: :latest)
  params = {
    fromBlock: Etherlite::Utils.encode_block_param(from_block),
    toBlock: Etherlite::Utils.encode_block_param(to_block)
  }

  params[:topics] = [Array(events).map(&:topic)] unless events.nil?
  params[:address] = Etherlite::Utils.encode_address_param(address) unless address.nil?

  logs = connection.ipc_call(:eth_getLogs, params)
  ::Etherlite::EventProvider.parse_raw_logs(connection, logs)
end
get_transaction(*_args) click to toggle source
# File lib/etherlite/api/node.rb, line 15
def get_transaction(*_args)
  load_transaction(*_args).refresh
end
load_account(from_pk: nil) click to toggle source
# File lib/etherlite/api/node.rb, line 36
def load_account(from_pk: nil)
  Etherlite::Account::PrivateKey.new connection, from_pk
end
load_address(_address) click to toggle source
# File lib/etherlite/api/node.rb, line 40
def load_address(_address)
  Etherlite::Address.new(connection, Etherlite::Utils.normalize_address_param(_address))
end
load_transaction(_hash) click to toggle source
# File lib/etherlite/api/node.rb, line 32
def load_transaction(_hash)
  Transaction.new(connection, _hash)
end
register_account(_passphrase) click to toggle source
# File lib/etherlite/api/node.rb, line 44
def register_account(_passphrase)
  address = connection.ipc_call(:personal_newAccount, _passphrase)
  Etherlite::Account::Local.new @connection, Etherlite::Utils.normalize_address(address)
end