Class: Ethereum::Initializer

Inherits:
Object
  • Object
show all
Defined in:
lib/ethereum/initializer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, client = Ethereum::IpcClient.new) ⇒ Initializer


6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ethereum/initializer.rb', line 6

def initialize(file, client = Ethereum::IpcClient.new)
  @file = File.read(file)
  @client = client
  sol_output = @client.compile_solidity(@file)
  contracts = sol_output["result"].keys
  @contracts = []
  contracts.each do |contract|
    abi = sol_output["result"][contract]["info"]["abiDefinition"] 
    name = contract
    code = sol_output["result"][contract]["code"]
    @contracts << Ethereum::Contract.new(name, code, abi)
  end
end

Instance Attribute Details

#clientObject

Returns the value of attribute client


4
5
6
# File 'lib/ethereum/initializer.rb', line 4

def client
  @client
end

#contractsObject

Returns the value of attribute contracts


4
5
6
# File 'lib/ethereum/initializer.rb', line 4

def contracts
  @contracts
end

#fileObject

Returns the value of attribute file


4
5
6
# File 'lib/ethereum/initializer.rb', line 4

def file
  @file
end

Instance Method Details

#build_allObject


20
21
22
23
24
# File 'lib/ethereum/initializer.rb', line 20

def build_all
  @contracts.each do |contract|
    contract.build(@client)
  end
end