Class: Etherlite::Contract::Function
- Inherits:
-
Object
- Object
- Etherlite::Contract::Function
- Defined in:
- lib/etherlite/contract/function.rb,
lib/etherlite/commands/contract/function/encode_arguments.rb
Defined Under Namespace
Classes: EncodeArguments
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #constant? ⇒ Boolean
- #decode(_connection, _values) ⇒ Object
- #encode(_values) ⇒ Object
-
#initialize(_name, _args, returns: nil, payable: false, constant: false) ⇒ Function
constructor
A new instance of Function.
- #payable? ⇒ Boolean
- #signature ⇒ Object
Constructor Details
#initialize(_name, _args, returns: nil, payable: false, constant: false) ⇒ Function
Returns a new instance of Function.
7 8 9 10 11 12 13 14 |
# File 'lib/etherlite/contract/function.rb', line 7 def initialize(_name, _args, returns: nil, payable: false, constant: false) @name = _name @args = _args @returns = returns @payable = payable @constant = constant end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/etherlite/contract/function.rb', line 5 def args @args end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/etherlite/contract/function.rb', line 5 def name @name end |
Instance Method Details
#constant? ⇒ Boolean
16 17 18 |
# File 'lib/etherlite/contract/function.rb', line 16 def constant? @constant end |
#decode(_connection, _values) ⇒ Object
38 39 40 41 |
# File 'lib/etherlite/contract/function.rb', line 38 def decode(_connection, _values) # TODO: decode return values _values end |
#encode(_values) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/etherlite/contract/function.rb', line 31 def encode(_values) signature_hash = Etherlite::Utils.sha3 signature encoded_args = EncodeArguments.for subtypes: @args, values: _values '0x' + signature_hash[0..7] + encoded_args end |
#payable? ⇒ Boolean
20 21 22 |
# File 'lib/etherlite/contract/function.rb', line 20 def payable? @payable end |
#signature ⇒ Object
24 25 26 27 28 29 |
# File 'lib/etherlite/contract/function.rb', line 24 def signature @signature ||= begin arg_signatures = @args.map &:signature "#{@name}(#{arg_signatures.join(',')})" end end |