ethereum_client 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 87041530e64eeda02260b56560e9150fd120600e
4
+ data.tar.gz: 4212dcd6823040b8a70c7fefd362ff659c5e204a
5
+ SHA512:
6
+ metadata.gz: 1fa1417b4fe646cf16224ab60bcd6c8a7d4dc78f67efdb7f51b4b4df7f4ba4d186f2bb4c4bb92022eab532bf4617f31fe83b06f50e10ae094b3767700a2fbc69
7
+ data.tar.gz: 1ec1bf84023c41d0ef51a7073d403337fb160f5a62cec2b3f5a7914c49c7a80c06b8acd9ec11d677ca84174256e26e7b6f7c97b076417319941e5952483f2583
@@ -0,0 +1,33 @@
1
+ require 'json'
2
+ require 'httparty'
3
+
4
+ # Ethereum JSON RPC client
5
+ module EthereumClient
6
+ class << self
7
+ def web3_client_version
8
+ payload = {
9
+ method: 'web3_clientVersion'
10
+ }
11
+
12
+ post(payload)
13
+ end
14
+
15
+ private
16
+
17
+ def post(payload)
18
+ body = payload.to_json
19
+ headers = {
20
+ 'Content-Type' => 'application/json',
21
+ 'Accept' => 'application/json'
22
+ }
23
+
24
+ response = HTTParty.post(url, body: body, headers: headers)
25
+
26
+ JSON.parse(response.body)['result']
27
+ end
28
+
29
+ def url
30
+ 'http://localhost:8545'
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+ require 'ethereum_client'
3
+
4
+ RSpec.describe EthereumClient do
5
+ subject { EthereumClient }
6
+
7
+ describe '.web3_client_version' do
8
+ let(:web3_client_version) { 'Geth/v1.3.6-9e323d65/linux/go1.6' }
9
+
10
+ let(:request_body) do
11
+ {
12
+ method: 'web3_clientVersion'
13
+ }.to_json
14
+ end
15
+
16
+ let(:response_body) do
17
+ {
18
+ id: nil,
19
+ jsonrpc: '',
20
+ result: web3_client_version
21
+ }.to_json
22
+ end
23
+
24
+ before do
25
+ headers = {
26
+ 'Content-Type' => 'application/json',
27
+ 'Accept' => 'application/json'
28
+ }
29
+
30
+ stub_request(:post, 'http://localhost:8545')
31
+ .with(body: request_body, headers: headers)
32
+ .to_return(status: 200, body: response_body)
33
+ end
34
+
35
+ it 'makes proper json rpc request' do
36
+ expect(subject.web3_client_version).to eq(web3_client_version)
37
+ end
38
+ end
39
+ end
@@ -0,0 +1 @@
1
+ require 'webmock/rspec'
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ethereum_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Vlad D
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.13.7
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.13.7
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: webmock
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.24'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.24'
55
+ description: Simple ruby wrapper around Ethereum JSON RPC API
56
+ email: dmxhZGp1c2hh@yandex.ru
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - lib/ethereum_client.rb
62
+ - spec/ethereum_client_spec.rb
63
+ - spec/spec_helper.rb
64
+ homepage: https://github.com/dmxhZGp1c2hh/ethereum_client
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.5.1
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: Ethereum JSON RPC client
88
+ test_files: []