Class: Etherlite::Account::Base
Instance Attribute Summary collapse
Instance Method Summary
collapse
#address, #get_balance
Constructor Details
#initialize(_connection, _normalized_address = nil) ⇒ Base
Returns a new instance of Base.
7
8
9
10
|
# File 'lib/etherlite/account/base.rb', line 7
def initialize(_connection, _normalized_address = nil)
@connection = _connection
@normalized_address = _normalized_address
end
|
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
5
6
7
|
# File 'lib/etherlite/account/base.rb', line 5
def connection
@connection
end
|
#normalized_address ⇒ Object
Returns the value of attribute normalized_address.
5
6
7
|
# File 'lib/etherlite/account/base.rb', line 5
def normalized_address
@normalized_address
end
|
Instance Method Details
#==(_other) ⇒ Object
45
46
47
|
# File 'lib/etherlite/account/base.rb', line 45
def ==(_other)
normalized_address == _other.normalized_address
end
|
#call(_target, _function, *_params) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/etherlite/account/base.rb', line 25
def call(_target, _function, *_params)
_function = parse_function(_function) if _function.is_a? String
options = _params.last.is_a?(Hash) ? _params.pop.clone : {}
if _function.constant?
call_constant _target, _function, _params, options
else
value = options.fetch(:pay, 0)
raise 'function is not payable' if value > 0 && !_function.payable?
send_transaction options.merge(
to: _target, data: _function.encode(_params), value: value
)
end
end
|
#next_nonce ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/etherlite/account/base.rb', line 12
def next_nonce
if @connection.use_parity
@connection.parity_next_nonce(address)
else
@connection.eth_get_transaction_count(address, 'pending')
end
end
|
#send_transaction(_options = {}) ⇒ Object
41
42
43
|
# File 'lib/etherlite/account/base.rb', line 41
def send_transaction(_options = {})
raise Etherlite::NotSupportedError, 'transactions are not supported by this kind of account'
end
|
#transfer_to(_target, _options = {}) ⇒ Object
21
22
23
|
# File 'lib/etherlite/account/base.rb', line 21
def transfer_to(_target, _options = {})
send_transaction _options.merge(to: _target, value: _options.fetch(:amount, 0))
end
|