Class: Etherlite::Account::Base
- Inherits:
-
Object
- Object
- Etherlite::Account::Base
- Includes:
- Etherlite::Api::Address
- Defined in:
- lib/etherlite/account/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#normalized_address ⇒ Object
readonly
Returns the value of attribute normalized_address.
Instance Method Summary collapse
- #call(_target, _function, *_params) ⇒ Object
-
#initialize(_connection, _normalized_address = nil) ⇒ Base
constructor
A new instance of Base.
- #send_transaction(_options = {}) ⇒ Object
- #transfer_to(_target, _options = {}) ⇒ Object
Methods included from Etherlite::Api::Address
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 (readonly)
Returns the value of attribute connection.
5 6 7 |
# File 'lib/etherlite/account/base.rb', line 5 def connection @connection end |
#normalized_address ⇒ Object (readonly)
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
#call(_target, _function, *_params) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/etherlite/account/base.rb', line 16 def call(_target, _function, *_params) _function = parse_function(_function) if _function.is_a? String = _params.last.is_a?(Hash) ? _params.pop.clone : {} if _function.constant? call_constant _target, _function, _params, else value = .fetch(:pay, 0) raise 'function is not payable' if value > 0 && !_function.payable? send_transaction .merge( to: _target, data: _function.encode(_params), value: value ) end end |
#send_transaction(_options = {}) ⇒ Object
32 33 34 |
# File 'lib/etherlite/account/base.rb', line 32 def send_transaction( = {}) raise NotSupportedError, 'transactions are not supported by this kind of account' end |
#transfer_to(_target, _options = {}) ⇒ Object
12 13 14 |
# File 'lib/etherlite/account/base.rb', line 12 def transfer_to(_target, = {}) send_transaction .merge(to: _target, value: .fetch(:amount, 0)) end |