Module: Etherlite::Api::Node
Instance Method Summary collapse
- #account_from_pk(_pk) ⇒ Object
- #accounts ⇒ Object
- #anonymous_account ⇒ Object
- #default_account ⇒ Object
- #get_block_number ⇒ Object
- #get_gas_price ⇒ Object
- #get_logs(events: nil, address: nil, from_block: :earliest, to_block: :latest) ⇒ Object
- #get_transaction(*_args) ⇒ Object
- #load_account(from_pk: nil) ⇒ Object
- #load_address(_address) ⇒ Object
- #load_transaction(_hash) ⇒ Object
- #register_account(_passphrase) ⇒ Object
Methods included from Address
Instance Method Details
#account_from_pk(_pk) ⇒ Object
63 64 65 66 67 68 69 70 |
# 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 ⇒ Object
49 50 51 52 53 |
# 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 ⇒ Object
59 60 61 |
# File 'lib/etherlite/api/node.rb', line 59 def anonymous_account @anonymous_account ||= Etherlite::Account::Anonymous.new(connection) end |
#default_account ⇒ Object
55 56 57 |
# File 'lib/etherlite/api/node.rb', line 55 def default_account @default_account ||= (accounts.first || anonymous_account) end |
#get_block_number ⇒ Object
7 8 9 |
# File 'lib/etherlite/api/node.rb', line 7 def get_block_number connection.eth_block_number end |
#get_gas_price ⇒ Object
11 12 13 |
# 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) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# 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) ⇒ Object
15 16 17 |
# File 'lib/etherlite/api/node.rb', line 15 def get_transaction(*_args) load_transaction(*_args).refresh end |
#load_account(from_pk: nil) ⇒ Object
36 37 38 |
# 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) ⇒ Object
40 41 42 |
# 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) ⇒ Object
32 33 34 |
# File 'lib/etherlite/api/node.rb', line 32 def load_transaction(_hash) Transaction.new(connection, _hash) end |