Top Level Namespace

Defined Under Namespace

Modules: Crypto, Scale Classes: Address, Array, Hash, Integer, Key, String, SubstrateClient

Instance Method Summary collapse

Instance Method Details

#green(text) ⇒ Object



64
65
66
# File 'lib/scale.rb', line 64

def green(text)
  "\033[32m#{text}\033[0m"
end

#ws_request(url, payload) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/substrate_client.rb', line 4

def ws_request(url, payload)
  result = nil

  EM.run do
    ws = Faye::WebSocket::Client.new(url)

    ws.on :open do |event|
      ws.send(payload.to_json)
    end

    ws.on :message do |event|
      if event.data.include?("jsonrpc")
        result = JSON.parse event.data
        ws.close(3001, "data received")
        EM.stop
      end
    end

    ws.on :close do |event|
      ws = nil
    end
  end

  result
end

#yellow(text) ⇒ Object



68
69
70
# File 'lib/scale.rb', line 68

def yellow(text)
  "\033[33m#{text}\033[0m"
end