Class: TEALrb::Algod

Inherits:
Object
  • Object
show all
Defined in:
lib/tealrb/algod.rb

Instance Method Summary collapse

Constructor Details

#initialize(url: 'http://localhost:4001', token: 'a' * 64) ⇒ Algod

Returns a new instance of Algod.



5
6
7
8
9
# File 'lib/tealrb/algod.rb', line 5

def initialize(url: 'http://localhost:4001', token: 'a' * 64)
  @conn = Faraday.new(url) do |conn|
    conn.headers = { 'X-Algo-API-Token' => token }
  end
end

Instance Method Details

#compile(source, source_map: true) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/tealrb/algod.rb', line 11

def compile(source, source_map: true)
  @conn.post('/v2/teal/compile') do |req|
    req.params['sourcemap'] = source_map
    req.body = source
    req.headers['Content-Type'] = 'text/plain'
  end
end