Class: Etherlite::Abi::LoadFunction

Inherits:
Object
  • Object
show all
Defined in:
lib/etherlite/commands/abi/load_function.rb

Constant Summary collapse

MATCHER =
/^(payable|onchain|\w[\w\d]*) (\w[\w\d]*)\((.*?)\)$/

Instance Method Summary collapse

Instance Method Details

#performObject

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/etherlite/commands/abi/load_function.rb', line 5

def perform
  parts = MATCHER.match @signature
  raise ArgumentError, 'invalid method signature' if parts.nil?

  inputs = parts[3].split(',').map do |a|
    Etherlite::Contract::FunctionInput.new nil, LoadType.for(signature: a.strip)
  end

  case parts[1]
  when 'payable'
    build parts[2], inputs, [], true, false
  when 'onchain'
    build parts[2], inputs, [], false, false
  else
    ouputs = parts[1] == 'void' ? [] : [LoadType.for(signature: parts[1])]
    build parts[2], inputs, ouputs, false, true
  end
end