nanook 0.6.3 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38e4a248c6ea62d44a35964f3f06287cfead6987
4
- data.tar.gz: 02eadb7cf364bcadddceec3983af2fce00ff669b
3
+ metadata.gz: 6e6170431fd02cf9172ba555460af6fdecfefe79
4
+ data.tar.gz: 93049e6146081de1a0019bff1ef9a2c7796114fe
5
5
  SHA512:
6
- metadata.gz: 89a7f7be437584c723f121440d4c771805466a1d1447e1368d83a79e39d9048317dbf0f3d83b75121ec664a995ba19f8f331135322564bd146804b408a88d13b
7
- data.tar.gz: 41d112321008ed82fb4c4be00cb1fe343c7bc385b25b240d1eb2ca7103fa1fc9496aa4a28548fde665dd239a4df4746e85410b31e609c83ea0379378529501a7
6
+ metadata.gz: ce1761786956bf8111289d74cd042d72fdbc23d0e623dbaee4e85a80f704b5fb22b1db6dc5666ddb9057166f5713d6194438fbd915c5b9e5c3bac6cbbce29f3e
7
+ data.tar.gz: 0ebe5795c0a2af3a71483b7b43fe41d091b41f726bfa2fa16959f326656af77b9a3b52c367115a33e91f784699f10777fa12f52a20d8027aae4f145d60eb9dcb
@@ -1,24 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nanook (0.6.3)
5
- symbolized
4
+ nanook (0.7.0)
5
+ symbolized (~> 0.0.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  addressable (2.5.2)
11
11
  public_suffix (>= 2.0.2, < 4.0)
12
+ coderay (1.1.2)
12
13
  crack (0.4.3)
13
14
  safe_yaml (~> 1.0.0)
14
15
  diff-lcs (1.3)
15
16
  hashdiff (0.3.7)
17
+ method_source (0.9.0)
18
+ pry (0.11.3)
19
+ coderay (~> 1.1.0)
20
+ method_source (~> 0.9.0)
16
21
  public_suffix (3.0.2)
17
22
  rake (10.5.0)
18
23
  rspec (3.7.0)
19
24
  rspec-core (~> 3.7.0)
20
25
  rspec-expectations (~> 3.7.0)
21
26
  rspec-mocks (~> 3.7.0)
27
+ rspec-collection_matchers (1.1.3)
28
+ rspec-expectations (>= 2.99.0.beta1)
22
29
  rspec-core (3.7.1)
23
30
  rspec-support (~> 3.7.0)
24
31
  rspec-expectations (3.7.0)
@@ -43,9 +50,11 @@ PLATFORMS
43
50
  DEPENDENCIES
44
51
  bundler (~> 1.16)
45
52
  nanook!
53
+ pry
46
54
  rake (~> 10.0)
47
55
  rspec (~> 3.2)
48
- rspec_junit_formatter
56
+ rspec-collection_matchers (~> 1.1)
57
+ rspec_junit_formatter (~> 0.3)
49
58
  webmock (~> 3.3)
50
59
 
51
60
  BUNDLED WITH
@@ -8,7 +8,7 @@ class Nanook
8
8
 
9
9
  def delegators
10
10
  account_required!
11
- rpc(:delegators)
11
+ rpc(:delegators)[:delegators]
12
12
  end
13
13
 
14
14
  def exists?
@@ -19,17 +19,17 @@ class Nanook
19
19
 
20
20
  def history(limit: 1000)
21
21
  account_required!
22
- rpc(:account_history, count: limit)
22
+ rpc(:account_history, count: limit)[:history]
23
23
  end
24
24
 
25
25
  def public_key
26
26
  account_required!
27
- rpc(:account_key)
27
+ rpc(:account_key)[:key]
28
28
  end
29
29
 
30
30
  def representative
31
31
  account_required!
32
- rpc(:account_representative)
32
+ rpc(:account_representative)[:representative]
33
33
  end
34
34
 
35
35
  def balance
@@ -44,17 +44,24 @@ class Nanook
44
44
 
45
45
  def ledger(limit: 1)
46
46
  account_required!
47
- rpc(:ledger, count: limit)
47
+ rpc(:ledger, count: limit)[:accounts]
48
48
  end
49
49
 
50
- def pending(limit: 1000)
50
+ # Returns Array of block hashes
51
+ # Or, with detailed: true, returns Hashes
52
+ def pending(limit: 1000, detailed: false)
51
53
  account_required!
52
- rpc(:pending, count: limit)
54
+
55
+ args = { count: limit }
56
+ args[:source] = true if detailed
57
+
58
+ response = rpc(:pending, args)[:blocks]
59
+ Nanook::Util.coerce_empty_string_to_type(response, (detailed ? Hash : Array))
53
60
  end
54
61
 
55
62
  def weight
56
63
  account_required!
57
- rpc(:account_weight)
64
+ rpc(:account_weight)[:weight]
58
65
  end
59
66
 
60
67
  private
@@ -8,23 +8,24 @@ class Nanook
8
8
  end
9
9
 
10
10
  def account
11
- rpc(:block_account, :hash)
11
+ rpc(:block_account, :hash)[:account]
12
12
  end
13
13
 
14
14
  def cancel_work
15
- rpc(:work_cancel, :hash)
15
+ rpc(:work_cancel, :hash).empty?
16
16
  end
17
17
 
18
18
  def chain(limit: 1000)
19
- rpc(:chain, :block, count: limit)
19
+ response = rpc(:chain, :block, count: limit)[:blocks]
20
+ Nanook::Util.coerce_empty_string_to_type(response, Array)
20
21
  end
21
22
 
22
23
  def generate_work
23
- rpc(:work_generate, :hash)
24
+ rpc(:work_generate, :hash)[:work]
24
25
  end
25
26
 
26
27
  def history(limit: 1000)
27
- rpc(:history, :hash, count: limit)
28
+ rpc(:history, :hash, count: limit)[:history]
28
29
  end
29
30
 
30
31
  def info(allow_unchecked: false)
@@ -57,7 +58,7 @@ class Nanook
57
58
  params[:sources] = sources unless sources.nil?
58
59
  params[:count] = 1 unless params.empty?
59
60
 
60
- rpc(:republish, :hash, params)
61
+ rpc(:republish, :hash, params)[:blocks]
61
62
  end
62
63
 
63
64
  def pending?
@@ -66,11 +67,12 @@ class Nanook
66
67
  end
67
68
 
68
69
  def process
69
- rpc(:process, :block)
70
+ rpc(:process, :block)[:hash]
70
71
  end
71
72
 
72
73
  def successors(limit: 1000)
73
- rpc(:successors, :block, count: limit)
74
+ response = rpc(:successors, :block, count: limit)[:blocks]
75
+ Nanook::Util.coerce_empty_string_to_type(response, Array)
74
76
  end
75
77
 
76
78
  private
@@ -92,8 +94,9 @@ class Nanook
92
94
  def _parse_info_response(response)
93
95
  # The contents is a stringified JSON
94
96
  if response[:contents]
95
- response[:contents] = JSON.parse(response[:contents])
97
+ return JSON.parse(response[:contents]).to_symbolized_hash
96
98
  end
99
+
97
100
  response
98
101
  end
99
102
 
@@ -14,27 +14,27 @@ class Nanook
14
14
  end
15
15
 
16
16
  def bootstrap(address:, port:)
17
- rpc(:bootstrap, address: address, port: port)
17
+ rpc(:bootstrap, address: address, port: port).has_key?(:success)
18
18
  end
19
19
 
20
20
  def bootstrap_any
21
- rpc(:bootstrap_any)
21
+ rpc(:bootstrap_any).has_key?(:success)
22
22
  end
23
23
 
24
24
  def frontier_count
25
- rpc(:frontier_count)
25
+ rpc(:frontier_count)[:count]
26
26
  end
27
27
 
28
28
  def peers
29
- rpc(:peers)
29
+ rpc(:peers)[:peers]
30
30
  end
31
31
 
32
32
  def representatives
33
- rpc(:representatives)
33
+ rpc(:representatives)[:representatives]
34
34
  end
35
35
 
36
36
  def stop
37
- rpc(:stop)
37
+ rpc(:stop).has_key?(:success)
38
38
  end
39
39
 
40
40
  def sync_progress
@@ -5,5 +5,13 @@ class Nanook
5
5
  nano * (10**30)
6
6
  end
7
7
 
8
+ def self.coerce_empty_string_to_type(response, type)
9
+ if response == ""
10
+ return type.new
11
+ end
12
+
13
+ response
14
+ end
15
+
8
16
  end
9
17
  end
@@ -1,3 +1,3 @@
1
1
  class Nanook
2
- VERSION = "0.6.3"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -12,30 +12,32 @@ class Nanook
12
12
 
13
13
  def accounts
14
14
  wallet_required!
15
- rpc(:account_list)
15
+ response = rpc(:account_list)[:accounts]
16
+ Nanook::Util.coerce_empty_string_to_type(response, Array)
16
17
  end
17
18
 
18
19
  def balance(account_break_down: false)
19
20
  wallet_required!
20
21
  if account_break_down
21
- rpc(:wallet_balances)
22
+ rpc(:wallet_balances)[:balances]
22
23
  else
23
24
  rpc(:wallet_balance_total)
24
25
  end
25
26
  end
26
27
 
27
28
  def create
28
- rpc(:wallet_create)
29
+ rpc(:wallet_create)[:wallet]
29
30
  end
30
31
 
31
32
  def destroy
32
33
  wallet_required!
33
34
  rpc(:wallet_destroy)
35
+ true
34
36
  end
35
37
 
36
38
  def export
37
39
  wallet_required!
38
- rpc(:wallet_export)
40
+ rpc(:wallet_export)[:json]
39
41
  end
40
42
 
41
43
  def contains?(account)
@@ -62,17 +64,17 @@ class Nanook
62
64
 
63
65
  def unlock(password)
64
66
  wallet_required!
65
- rpc(:password_enter, password: password)
67
+ rpc(:password_enter, password: password)[:valid] == 1
66
68
  end
67
69
 
68
70
  def change_password(password)
69
71
  wallet_required!
70
- rpc(:password_change, password: password)
72
+ rpc(:password_change, password: password)[:changed] == 1
71
73
  end
72
74
 
73
75
  def all
74
76
  wallet_required!
75
- rpc(:account_list)
77
+ rpc(:account_list)[:accounts]
76
78
  end
77
79
 
78
80
  private
@@ -14,13 +14,13 @@ class Nanook
14
14
 
15
15
  def create
16
16
  wallet_required!
17
- rpc(:account_create)
17
+ rpc(:account_create)[:account]
18
18
  end
19
19
 
20
20
  def destroy
21
21
  wallet_required!
22
22
  account_required!
23
- rpc(:account_remove)
23
+ rpc(:account_remove)[:removed] == 1
24
24
  end
25
25
 
26
26
  def pay(to:, amount:, id:)
@@ -38,9 +38,10 @@ class Nanook
38
38
  id: id
39
39
  }
40
40
 
41
- @rpc.call(:send, p)
41
+ @rpc.call(:send, p)[:block]
42
42
  end
43
43
 
44
+ # Returns false if no block to receive
44
45
  def receive(block=nil)
45
46
  wallet_required!
46
47
  account_required!
@@ -76,8 +77,10 @@ class Nanook
76
77
  _receive_with_block(block)
77
78
  end
78
79
 
80
+ # Returns block if successful, otherwise false
79
81
  def _receive_with_block(block)
80
- rpc(:receive, block: block)
82
+ response = rpc(:receive, block: block)[:block]
83
+ response.nil? ? false : response
81
84
  end
82
85
 
83
86
  def rpc(action, params={})
@@ -6,15 +6,15 @@ class Nanook
6
6
  end
7
7
 
8
8
  def add(address:, port:)
9
- rpc(:work_peer_add, address: address, port: port)
9
+ rpc(:work_peer_add, address: address, port: port).has_key?(:success)
10
10
  end
11
11
 
12
12
  def clear
13
- rpc(:work_peers_clear)
13
+ rpc(:work_peers_clear).has_key?(:success)
14
14
  end
15
15
 
16
16
  def list
17
- rpc(:work_peers)
17
+ rpc(:work_peers)[:work_peers]
18
18
  end
19
19
 
20
20
  private
@@ -22,10 +22,12 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ["lib"]
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "pry"
25
26
  spec.add_development_dependency "rake", "~> 10.0"
26
27
  spec.add_development_dependency "rspec", "~> 3.2"
27
- spec.add_development_dependency "rspec_junit_formatter"
28
+ spec.add_development_dependency "rspec-collection_matchers", "~> 1.1"
29
+ spec.add_development_dependency "rspec_junit_formatter", "~> 0.3"
28
30
  spec.add_development_dependency "webmock", "~> 3.3"
29
31
 
30
- spec.add_dependency "symbolized"
32
+ spec.add_dependency "symbolized", "~> 0.0.1"
31
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Duncalfe
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,20 +66,34 @@ dependencies:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: '3.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-collection_matchers
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.1'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: rspec_junit_formatter
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
- - - ">="
87
+ - - "~>"
60
88
  - !ruby/object:Gem::Version
61
- version: '0'
89
+ version: '0.3'
62
90
  type: :development
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
66
- - - ">="
94
+ - - "~>"
67
95
  - !ruby/object:Gem::Version
68
- version: '0'
96
+ version: '0.3'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: webmock
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -84,16 +112,16 @@ dependencies:
84
112
  name: symbolized
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
- - - ">="
115
+ - - "~>"
88
116
  - !ruby/object:Gem::Version
89
- version: '0'
117
+ version: 0.0.1
90
118
  type: :runtime
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
- - - ">="
122
+ - - "~>"
95
123
  - !ruby/object:Gem::Version
96
- version: '0'
124
+ version: 0.0.1
97
125
  description: Ruby library for managing a nano currency node, including making and
98
126
  receiving payments, using the nano RPC protocol
99
127
  email: