diff --git a/Gemfile.lock b/Gemfile.lock index 07318a6..a69c3f9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,35 +1,47 @@ PATH remote: . specs: - scale.rb (0.2.19) + scale.rb (0.2.38) base58 - blake2b_rs (~> 0.1.2) + blake2b faye-websocket json (~> 2.3.0) - thor (~> 1.0) + rest-client + thor (~> 0.19) xxhash GEM remote: https://rubygems.org/ specs: base58 (0.2.3) - blake2b_rs (0.1.2) - ffi (= 1.15.0) - thermite (~> 0) + blake2b (0.10.0) coderay (1.1.3) diff-lcs (1.4.4) + domain_name (0.5.20190701) + unf (>= 0.0.5, < 1.0.0) eventmachine (1.2.7) - faye-websocket (0.11.0) + faye-websocket (0.11.1) eventmachine (>= 0.12.0) websocket-driver (>= 0.5.1) ffi (1.15.0) + http-accept (1.7.0) + http-cookie (1.0.4) + domain_name (~> 0.5) json (2.3.1) method_source (1.0.0) - minitar (0.9) + mime-types (3.4.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2022.0105) + netrc (0.11.0) pry (0.14.0) coderay (~> 1.1) method_source (~> 1.0) rake (13.0.3) + rest-client (2.1.0) + http-accept (>= 1.7.0, < 2.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) rspec (3.10.0) rspec-core (~> 3.10.0) rspec-expectations (~> 3.10.0) @@ -43,13 +55,11 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.2) - thermite (0.13.0) - minitar (~> 0.5) - rake (>= 10) - tomlrb (~> 1.2) - thor (1.1.0) - tomlrb (1.3.0) - websocket-driver (0.7.3) + thor (0.20.3) + unf (0.1.4) + unf_ext + unf_ext (0.0.8.1) + websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xxhash (0.4.0) diff --git a/lib/substrate_client.rb b/lib/substrate_client.rb index 02d9645..6ae33b6 100644 --- a/lib/substrate_client.rb +++ b/lib/substrate_client.rb @@ -28,9 +28,17 @@ def ws_request(url, payload) end end + result = http_request(url, payload) if result.nil? result end +def http_request(url, payload) + r = RestClient.post(url, payload.to_json, { content_type: :json, accept: :json }) + JSON.parse(r.body) +rescue => ex + { "error": ex.message } +end + class SubstrateClient class WebsocketError < StandardError; end class RpcError < StandardError; end diff --git a/scale.gemspec b/scale.gemspec index bc156e9..387e101 100644 --- a/scale.gemspec +++ b/scale.gemspec @@ -39,6 +39,7 @@ Gem::Specification.new do |spec| spec.add_dependency "json", "~> 2.3.0" spec.add_dependency "faye-websocket" spec.add_dependency "thor", '~> 0.19' + spec.add_dependency "rest-client" spec.add_development_dependency "bundler" spec.add_development_dependency "pry"