coinrpc 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 511115419e22de77e3e403d430842b068a0bce24323fe451c60213c541f8c091
4
- data.tar.gz: 7b873ab8036363f5f7296d0bf655f3d56367a1ed89769feda55fcdde629c499e
3
+ metadata.gz: 3f56b954d8a797f018a8451556d8b11cb4a84b62fcb91cc171aca6d542a5c3b8
4
+ data.tar.gz: 5f7d5e0b3cdfa3eebfaacc8cea3e287dd5087115e0a5587bb2a76a3345e32586
5
5
  SHA512:
6
- metadata.gz: 2c394040405ba6b9bc6f0dfa5e207351482110a3b1a9c482e5c1a8eabea3f9dc59a9b5e5beb0ffa6eeb393e66ed29d2dce098686443f006749b5a36a22024ea8
7
- data.tar.gz: f6ae9b9bd572a5b2c5858e3b9f5535856bab7b83c86b036379d2691f95f0403aea760b5c8e272f2015cb45eb612585e11a8642a4b69c433f7f791802c674eaea
6
+ metadata.gz: ffa84d42cc2dec647fdac362285d4238c1d8541e4bf224f27a2e8b1b32ea971ee5e6b929bf0ed7af049eaa4e42a5b42d5721fb02be41c49f8284c22e43892791
7
+ data.tar.gz: 9c78993f178ea81eadc004bd489e507856caa7de4c598001a950d4c76e2d2b55afab3d36473d7aba5cf5d5cbdc9dd88dff9345d98a886ec1cf4b14be7f76a25b
@@ -1,3 +1,3 @@
1
1
  module CoinRPC
2
- VERSION = "3.0.1".freeze
2
+ VERSION = "3.0.2".freeze
3
3
  end
data/lib/coinrpc.rb CHANGED
@@ -4,6 +4,7 @@ require "oj"
4
4
  require "json"
5
5
  require "securerandom"
6
6
  require "coinrpc/version"
7
+ require "set"
7
8
 
8
9
  # let OJ mimic JSON
9
10
  Oj.mimic_JSON
@@ -19,12 +20,13 @@ module CoinRPC
19
20
  JSONRPC_V1_1 = "1.1".freeze
20
21
  JSONRPC_V2_0 = "2.0".freeze
21
22
  TIMEOUT = 60.freeze
23
+ ENDPOINTS_WITH_ARRAY_ARGS = ['testmempoolaccept'].to_set
22
24
 
23
25
  def initialize(url)
24
26
 
25
27
  urinfo = URI.parse(url)
26
28
 
27
- @options = {:timeout => TIMEOUT, :userpwd => "#{urinfo.user}:#{urinfo.password}", :headers => {"User-Agent" => "CoinRPC/#{CoinRPC::VERSION}"}}.freeze
29
+ @options = {:timeout => TIMEOUT, :userpwd => "#{urinfo.user}:#{urinfo.password}", :headers => {'User-Agent' => "CoinRPC/#{CoinRPC::VERSION}"}}.freeze
28
30
  @url = "http://#{urinfo.host}:#{urinfo.port}/".freeze
29
31
 
30
32
  end
@@ -35,10 +37,10 @@ module CoinRPC
35
37
 
36
38
  def method_missing(method, *args)
37
39
 
38
- fixed_method = method.to_s.gsub(/\_/,"").freeze
40
+ fixed_method = method.to_s.gsub(/\_/, '').freeze
39
41
  post_data = nil
40
42
 
41
- if args[0].is_a?(Array) and args[0].size > 0 then
43
+ if args[0].is_a?(Array) and args[0].size > 0 and !ENDPOINTS_WITH_ARRAY_ARGS.member?(fixed_method) then
42
44
  # batch request
43
45
  post_data = args.map{|arg| {:jsonrpc => JSONRPC_V2_0, :method => fixed_method, :params => arg, :id => random_id} }
44
46
  else
@@ -61,13 +63,13 @@ module CoinRPC
61
63
  # this won't work without Oj.mimic_JSON
62
64
  result = Oj.strict_load(response.body, :decimal_class => BigDecimal)
63
65
 
64
- raise result["error"]["message"] if result.is_a?(Hash) and !result["error"].nil?
66
+ raise result['error']['message'] if result.is_a?(Hash) and !result['error'].nil?
65
67
 
66
68
  if result.is_a?(Hash) then
67
- result["result"]
69
+ result['result']
68
70
  else
69
71
  # batch call
70
- result.map{|r| r["result"] || r["error"]}
72
+ result.map!{|r| r['result'] || r['error']}
71
73
  end
72
74
 
73
75
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coinrpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Atif Nazir
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-25 00:00:00.000000000 Z
11
+ date: 2023-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler