coinrpc 3.0.1 → 3.0.3

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: 95af138f59c104f545010b452b48de342ad8a345bb9170600aaaac0cbbf89128
4
+ data.tar.gz: c0e89071ba785dc63ca95490e0d610171bed26de98654545fa61997bd99aba12
5
5
  SHA512:
6
- metadata.gz: 2c394040405ba6b9bc6f0dfa5e207351482110a3b1a9c482e5c1a8eabea3f9dc59a9b5e5beb0ffa6eeb393e66ed29d2dce098686443f006749b5a36a22024ea8
7
- data.tar.gz: f6ae9b9bd572a5b2c5858e3b9f5535856bab7b83c86b036379d2691f95f0403aea760b5c8e272f2015cb45eb612585e11a8642a4b69c433f7f791802c674eaea
6
+ metadata.gz: 9a27886e3c092b7eb93a4fe0ab39d77b1390fc38feba042e2b56963739b9e3f1e0d7d2beff7de02c1213faae7f91809054d143ff92f29ffc6102d428df31490b
7
+ data.tar.gz: babb748fb3ff4b882008e5732fa94a81964f57c1a8065c0ecfc201324fd4058edcefca822bdf71053c3cf70e743d4eb6c4ff24c700725bdd0a73fe64d2a5cbf3
data/coinrpc.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.required_ruby_version = ">= 2.6", "< 3.3"
20
+ spec.required_ruby_version = ">= 2.6", "<= 3.3"
21
21
 
22
22
  spec.add_development_dependency "bundler", ">= 1.6", "< 3.0"
23
23
  spec.add_development_dependency "rake", ">= 13.0", "< 14.0"
@@ -1,3 +1,3 @@
1
1
  module CoinRPC
2
- VERSION = "3.0.1".freeze
2
+ VERSION = "3.0.3".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.3
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-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -146,7 +146,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
146
  - - ">="
147
147
  - !ruby/object:Gem::Version
148
148
  version: '2.6'
149
- - - "<"
149
+ - - "<="
150
150
  - !ruby/object:Gem::Version
151
151
  version: '3.3'
152
152
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  - !ruby/object:Gem::Version
156
156
  version: '0'
157
157
  requirements: []
158
- rubygems_version: 3.4.1
158
+ rubygems_version: 3.5.3
159
159
  signing_key:
160
160
  specification_version: 4
161
161
  summary: A fast RPC client for Bitcoin Core style software.