nano_rpc 0.24.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -1
- data/README.md +2 -1
- data/lib/nano_rpc.rb +3 -3
- data/lib/nano_rpc/{proxies/account.rb → account.rb} +0 -0
- data/lib/nano_rpc/{proxies/accounts.rb → accounts.rb} +0 -0
- data/lib/nano_rpc/errors.rb +1 -1
- data/lib/nano_rpc/helpers/node_helper.rb +6 -2
- data/lib/nano_rpc/helpers/wallet_helper.rb +7 -3
- data/lib/nano_rpc/methods/node_methods.rb +17 -5
- data/lib/nano_rpc/methods/wallet_methods.rb +7 -2
- data/lib/nano_rpc/node.rb +15 -32
- data/lib/nano_rpc/version.rb +1 -1
- data/lib/nano_rpc/{proxies/wallet.rb → wallet.rb} +0 -0
- data/nano_rpc.gemspec +1 -1
- metadata +11 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab9b6be210c8fdb43aa96f222c19ad183399eaa2c90a8fc9f2eb2097c536ea73
|
4
|
+
data.tar.gz: 55d91925f916c4f6c1263c8fd3c20b6cf5f7f75ffdba0aff7190d88d35aac55b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72abd38cbfd8d95a25b44ac5125e9dab3572d2833898e2ca3f29f9cdb6a581232920108686c3b4f3c4f6084a8b7688e0929cbe0682bd4211c7c0b2f3658f7d6a
|
7
|
+
data.tar.gz: f10b7c61cf10d6e7d7b91646cbbfda600a8dab1e513a7f027dc0a9d93e12a7f45c5fbeeea3376ac1b7d50f58cb85134663dc580bf7682a90ffd9ca9d67aab8b2
|
data/.rubocop.yml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
require: rubocop-rspec
|
2
|
+
RSpec/ExampleLength:
|
3
|
+
Max: 8
|
4
|
+
RSpec/MultipleExpectations:
|
5
|
+
Enabled: false
|
6
|
+
RSpec/NestedGroups:
|
7
|
+
Max: 4
|
8
|
+
RSpec/SubjectStub:
|
9
|
+
Enabled: false
|
2
10
|
|
3
11
|
AllCops:
|
4
|
-
TargetRubyVersion: 2.
|
12
|
+
TargetRubyVersion: 2.6.1
|
5
13
|
Exclude:
|
6
14
|
- bin/*
|
7
15
|
- nano_rpc.gemspec
|
data/README.md
CHANGED
@@ -12,7 +12,8 @@ To run a Nano node locally, see [Nano Docker Docs](https://github.com/clemahieu/
|
|
12
12
|
|
13
13
|
| Gem version | Nanocurrency version |
|
14
14
|
|-------------|----------------------|
|
15
|
-
| 0.
|
15
|
+
| 0.25 | >= 18.0 |
|
16
|
+
| 0.24 | >= 17.0, < 18.0 |
|
16
17
|
| 0.23 | >= 16.0, < 17.0 |
|
17
18
|
| 0.20 | >= 15.0, < 16.0 |
|
18
19
|
| 0.19 | >= 14.2, < 15.0 |
|
data/lib/nano_rpc.rb
CHANGED
@@ -13,9 +13,9 @@ require 'nano_rpc/methods/node_methods'
|
|
13
13
|
require 'nano_rpc/methods/wallet_methods'
|
14
14
|
|
15
15
|
require 'nano_rpc/proxy'
|
16
|
-
require 'nano_rpc/
|
17
|
-
require 'nano_rpc/
|
18
|
-
require 'nano_rpc/
|
16
|
+
require 'nano_rpc/account'
|
17
|
+
require 'nano_rpc/accounts'
|
18
|
+
require 'nano_rpc/wallet'
|
19
19
|
|
20
20
|
require 'nano_rpc/node'
|
21
21
|
require 'nano_rpc/errors'
|
File without changes
|
File without changes
|
data/lib/nano_rpc/errors.rb
CHANGED
@@ -14,8 +14,12 @@ module NanoRpc::NodeHelper
|
|
14
14
|
NanoRpc::Accounts.new(addresses, node: self)
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
|
17
|
+
def clear_stats
|
18
|
+
stats_clear.success == ''
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_wallet(seed: nil)
|
22
|
+
NanoRpc::Wallet.new(wallet_create(seed: seed).wallet, node: self)
|
19
23
|
end
|
20
24
|
|
21
25
|
def knano_from_raw(amount:)
|
@@ -39,8 +39,8 @@ module NanoRpc::WalletHelper
|
|
39
39
|
password_change(password: new_password).changed == 1
|
40
40
|
end
|
41
41
|
|
42
|
-
def change_seed(new_seed:)
|
43
|
-
wallet_change_seed(seed: new_seed).success == ''
|
42
|
+
def change_seed(new_seed:, count: 0)
|
43
|
+
wallet_change_seed(seed: new_seed, count: count).success == ''
|
44
44
|
end
|
45
45
|
|
46
46
|
def contains?(account:)
|
@@ -58,7 +58,7 @@ module NanoRpc::WalletHelper
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def destroy
|
61
|
-
wallet_destroy ==
|
61
|
+
wallet_destroy.destroyed == 1
|
62
62
|
end
|
63
63
|
|
64
64
|
def enter_password(password:)
|
@@ -74,6 +74,10 @@ module NanoRpc::WalletHelper
|
|
74
74
|
wallet_frontiers.frontiers
|
75
75
|
end
|
76
76
|
|
77
|
+
def history(modified_since: 0)
|
78
|
+
wallet_history(modified_since: modified_since).history
|
79
|
+
end
|
80
|
+
|
77
81
|
def init_payment
|
78
82
|
payment_init.status == 'Ready'
|
79
83
|
end
|
@@ -39,7 +39,8 @@ module NanoRpc::NodeMethods
|
|
39
39
|
},
|
40
40
|
bootstrap_status: {},
|
41
41
|
chain: {
|
42
|
-
required: %i[block count]
|
42
|
+
required: %i[block count],
|
43
|
+
optional: %i[offset reverse]
|
43
44
|
},
|
44
45
|
confirmation_active: {},
|
45
46
|
confirmation_history: {},
|
@@ -81,12 +82,15 @@ module NanoRpc::NodeMethods
|
|
81
82
|
payment_wait: {
|
82
83
|
required: %i[account amount timeout]
|
83
84
|
},
|
84
|
-
peers: {
|
85
|
+
peers: {
|
86
|
+
optional: %i[peer_details]
|
87
|
+
},
|
85
88
|
pending_exists: {
|
86
89
|
required: %i[hash]
|
87
90
|
},
|
88
91
|
process: {
|
89
|
-
required: %i[block]
|
92
|
+
required: %i[block],
|
93
|
+
optional: %i[force subtype]
|
90
94
|
},
|
91
95
|
rai_from_raw: {
|
92
96
|
required: %i[amount]
|
@@ -108,12 +112,17 @@ module NanoRpc::NodeMethods
|
|
108
112
|
required: %i[wallet]
|
109
113
|
},
|
110
114
|
search_pending_all: {},
|
115
|
+
sign: {
|
116
|
+
optional: %i[account hash key wallet]
|
117
|
+
},
|
111
118
|
stats: {
|
112
119
|
required: %i[type]
|
113
120
|
},
|
121
|
+
stats_clear: {},
|
114
122
|
stop: {},
|
115
123
|
successors: {
|
116
|
-
required: %i[block count]
|
124
|
+
required: %i[block count],
|
125
|
+
optional: %i[offset reverse]
|
117
126
|
},
|
118
127
|
unchecked: {
|
119
128
|
required: %i[count]
|
@@ -125,8 +134,11 @@ module NanoRpc::NodeMethods
|
|
125
134
|
unchecked_keys: {
|
126
135
|
required: %i[key count]
|
127
136
|
},
|
137
|
+
uptime: {},
|
128
138
|
version: {},
|
129
|
-
wallet_create: {
|
139
|
+
wallet_create: {
|
140
|
+
optional: %i[seed]
|
141
|
+
},
|
130
142
|
work_cancel: {
|
131
143
|
required: %i[hash]
|
132
144
|
},
|
@@ -49,7 +49,8 @@ module NanoRpc::WalletMethods
|
|
49
49
|
optional: %i[threshold]
|
50
50
|
},
|
51
51
|
wallet_change_seed: {
|
52
|
-
required: %i[seed]
|
52
|
+
required: %i[seed],
|
53
|
+
optional: %i[count]
|
53
54
|
},
|
54
55
|
wallet_contains: {
|
55
56
|
required: %i[account]
|
@@ -57,6 +58,9 @@ module NanoRpc::WalletMethods
|
|
57
58
|
wallet_destroy: {},
|
58
59
|
wallet_export: {},
|
59
60
|
wallet_frontiers: {},
|
61
|
+
wallet_history: {
|
62
|
+
optional: %i[modified_since]
|
63
|
+
},
|
60
64
|
wallet_info: {},
|
61
65
|
wallet_ledger: {},
|
62
66
|
wallet_locked: {},
|
@@ -66,7 +70,8 @@ module NanoRpc::WalletMethods
|
|
66
70
|
},
|
67
71
|
wallet_representative: {},
|
68
72
|
wallet_representative_set: {
|
69
|
-
required: %i[representative]
|
73
|
+
required: %i[representative],
|
74
|
+
optional: %i[update_existing_accounts]
|
70
75
|
},
|
71
76
|
wallet_republish: {
|
72
77
|
required: %i[count]
|
data/lib/nano_rpc/node.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require '
|
2
|
+
require 'http'
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
module NanoRpc
|
@@ -13,7 +13,7 @@ class NanoRpc::Node
|
|
13
13
|
include NanoRpc::NodeMethods
|
14
14
|
include NanoRpc::Proxy
|
15
15
|
|
16
|
-
attr_reader :host, :port
|
16
|
+
attr_reader :host, :port
|
17
17
|
|
18
18
|
DEFAULT_TIMEOUT = 60
|
19
19
|
|
@@ -66,39 +66,29 @@ class NanoRpc::Node
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def rpc_post(params)
|
69
|
-
|
70
|
-
ensure_status_success(response)
|
71
|
-
data = NanoRpc::Response.new(JSON[response&.body])
|
69
|
+
data = NanoRpc::Response.new(node_response(params))
|
72
70
|
ensure_valid_response(data)
|
73
71
|
|
74
72
|
data
|
75
73
|
end
|
76
74
|
|
77
|
-
def
|
78
|
-
h = headers || {}
|
75
|
+
def headers
|
76
|
+
h = @headers || {}
|
79
77
|
h['Content-Type'] = 'json'
|
80
|
-
h['Authorization'] = auth
|
78
|
+
h['Authorization'] = @auth if @auth
|
81
79
|
h
|
82
80
|
end
|
83
81
|
|
84
|
-
def
|
85
|
-
|
86
|
-
rescue Errno::ECONNREFUSED
|
87
|
-
raise NanoRpc::NodeConnectionFailure,
|
88
|
-
"Node connection failure at #{url}"
|
89
|
-
rescue RestClient::Exceptions::OpenTimeout
|
90
|
-
raise NanoRpc::NodeOpenTimeout,
|
91
|
-
'Node failed to respond in time'
|
82
|
+
def node_response(params)
|
83
|
+
JSON[http_post(params).body.to_s]
|
92
84
|
end
|
93
85
|
|
94
|
-
def
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
timeout: timeout
|
101
|
-
)
|
86
|
+
def http_post(params)
|
87
|
+
HTTP.timeout(@timeout).post(url, headers: headers, body: params.to_json)
|
88
|
+
rescue HTTP::ConnectionError
|
89
|
+
raise NanoRpc::NodeConnectionFailure, "Node unreachable at #{url}"
|
90
|
+
rescue HTTP::TimeoutError
|
91
|
+
raise NanoRpc::NodeTimeout, "Node timeout after #{@timeout} seconds"
|
102
92
|
end
|
103
93
|
|
104
94
|
def url
|
@@ -109,15 +99,8 @@ class NanoRpc::Node
|
|
109
99
|
end
|
110
100
|
end
|
111
101
|
|
112
|
-
def ensure_status_success(response)
|
113
|
-
return if response&.code == 200
|
114
|
-
raise NanoRpc::BadRequest,
|
115
|
-
"Error response from node: #{JSON[response&.body]}"
|
116
|
-
end
|
117
|
-
|
118
102
|
def ensure_valid_response(data)
|
119
103
|
return unless data['error']
|
120
|
-
raise NanoRpc::InvalidRequest,
|
121
|
-
"Invalid request: #{data['error']}"
|
104
|
+
raise NanoRpc::InvalidRequest, "Invalid request: #{data['error']}"
|
122
105
|
end
|
123
106
|
end
|
data/lib/nano_rpc/version.rb
CHANGED
File without changes
|
data/nano_rpc.gemspec
CHANGED
@@ -34,5 +34,5 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency 'simplecov-rcov', '~> 0.2.3'
|
35
35
|
|
36
36
|
spec.add_runtime_dependency 'hashie', '~> 3.6', '>= 3.6.0'
|
37
|
-
spec.add_runtime_dependency '
|
37
|
+
spec.add_runtime_dependency 'http', '~> 4.0', '>= 4.0.5'
|
38
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nano_rpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Craig-Kuhn (JCK)
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -157,25 +157,25 @@ dependencies:
|
|
157
157
|
- !ruby/object:Gem::Version
|
158
158
|
version: '3.6'
|
159
159
|
- !ruby/object:Gem::Dependency
|
160
|
-
name:
|
160
|
+
name: http
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
162
162
|
requirements:
|
163
163
|
- - "~>"
|
164
164
|
- !ruby/object:Gem::Version
|
165
|
-
version: '
|
165
|
+
version: '4.0'
|
166
166
|
- - ">="
|
167
167
|
- !ruby/object:Gem::Version
|
168
|
-
version:
|
168
|
+
version: 4.0.5
|
169
169
|
type: :runtime
|
170
170
|
prerelease: false
|
171
171
|
version_requirements: !ruby/object:Gem::Requirement
|
172
172
|
requirements:
|
173
173
|
- - "~>"
|
174
174
|
- !ruby/object:Gem::Version
|
175
|
-
version: '
|
175
|
+
version: '4.0'
|
176
176
|
- - ">="
|
177
177
|
- !ruby/object:Gem::Version
|
178
|
-
version:
|
178
|
+
version: 4.0.5
|
179
179
|
description: An RPC wrapper for Nano digital currency nodes. Arbitrary RPC access
|
180
180
|
is provided along with proxy objects that expose helper methods.
|
181
181
|
email:
|
@@ -194,6 +194,8 @@ files:
|
|
194
194
|
- bin/console
|
195
195
|
- bin/setup
|
196
196
|
- lib/nano_rpc.rb
|
197
|
+
- lib/nano_rpc/account.rb
|
198
|
+
- lib/nano_rpc/accounts.rb
|
197
199
|
- lib/nano_rpc/errors.rb
|
198
200
|
- lib/nano_rpc/helpers/account_helper.rb
|
199
201
|
- lib/nano_rpc/helpers/accounts_helper.rb
|
@@ -206,12 +208,10 @@ files:
|
|
206
208
|
- lib/nano_rpc/methods/wallet_methods.rb
|
207
209
|
- lib/nano_rpc/node.rb
|
208
210
|
- lib/nano_rpc/numeric.rb
|
209
|
-
- lib/nano_rpc/proxies/account.rb
|
210
|
-
- lib/nano_rpc/proxies/accounts.rb
|
211
|
-
- lib/nano_rpc/proxies/wallet.rb
|
212
211
|
- lib/nano_rpc/proxy.rb
|
213
212
|
- lib/nano_rpc/response.rb
|
214
213
|
- lib/nano_rpc/version.rb
|
214
|
+
- lib/nano_rpc/wallet.rb
|
215
215
|
- nano_rpc.gemspec
|
216
216
|
homepage: https://github.com/jcraigk/ruby_nano_rpc
|
217
217
|
licenses:
|
@@ -232,8 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
232
|
- !ruby/object:Gem::Version
|
233
233
|
version: '0'
|
234
234
|
requirements: []
|
235
|
-
|
236
|
-
rubygems_version: 2.7.8
|
235
|
+
rubygems_version: 3.0.2
|
237
236
|
signing_key:
|
238
237
|
specification_version: 4
|
239
238
|
summary: RPC wrapper for Nano digital nodes written in Ruby
|