nanook 1.0.0 → 1.0.1

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
  SHA1:
3
- metadata.gz: 3d14b10331b3dab85b1375935f14fdcaf55a0b88
4
- data.tar.gz: e61770ece8ad4e6e7026fbfe8dea6e037dcb01c3
3
+ metadata.gz: 925ab6dd5294f31528ae7e0e8ce816dd8eaf625a
4
+ data.tar.gz: a2812f58217a0b5dd8e81f0b0db3df52ac2d04d1
5
5
  SHA512:
6
- metadata.gz: 1c146f1f0e070da7e3c36bb76d9b2a312f9b8a9dc857bb786ed4425739bcc5bc59a5db6c81d7c7c6601c861039d758b254351ba82cc165f844de27c2b8822b31
7
- data.tar.gz: 07d753729b387fec8974c9dc9014acea9966945aa00638346391e65fff1feb640e746d01f23450b34db8c7b8c22af2f5efab86c3dd7c0a3c25d277100918aeef
6
+ metadata.gz: df9564eb317b84945330e49390aacdf2a55fd631e4fdad266c55c04124a3fd0f2999ff1625aad23f314a45a33be2eb74008ce282a755a545471c67f455735de7
7
+ data.tar.gz: 36989a8853937febd8ad14c9b5bb3dff179725383dbf3305d6627c2af45a8fb1bbd5ba7a2882b6b5a168dd8b2a876063b380b314ba0a7beaaa369c633ba33a37
data/CHANGELOG.md CHANGED
@@ -4,7 +4,17 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [Unreleased]
7
+ ## 1.0.1
8
+
9
+ ### Fixed
10
+
11
+ - `Nanook::Wallet#balance(account_break_down: true)` always returning 0 `pending` balance.
12
+
13
+ ### Changed
14
+
15
+ - Use `block.publish` in `README.md` and not the alias `block.process`.
16
+
17
+ ## 1.0.0
8
18
 
9
19
  ### Added
10
20
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nanook (1.0.0)
4
+ nanook (1.0.1)
5
5
  symbolized (~> 0.0.1)
6
6
 
7
7
  GEM
@@ -20,6 +20,7 @@ GEM
20
20
  method_source (~> 0.9.0)
21
21
  public_suffix (3.0.2)
22
22
  rake (10.5.0)
23
+ rdoc (6.0.1)
23
24
  rspec (3.7.0)
24
25
  rspec-core (~> 3.7.0)
25
26
  rspec-expectations (~> 3.7.0)
@@ -38,6 +39,8 @@ GEM
38
39
  rspec_junit_formatter (0.3.0)
39
40
  rspec-core (>= 2, < 4, != 2.12.0)
40
41
  safe_yaml (1.0.4)
42
+ sdoc (1.0.0)
43
+ rdoc (>= 5.0)
41
44
  symbolized (0.0.1)
42
45
  webmock (3.3.0)
43
46
  addressable (>= 2.3.6)
@@ -55,6 +58,7 @@ DEPENDENCIES
55
58
  rspec (~> 3.2)
56
59
  rspec-collection_matchers (~> 1.1)
57
60
  rspec_junit_formatter (~> 0.3)
61
+ sdoc (~> 1.0)
58
62
  webmock (~> 3.3)
59
63
 
60
64
  BUNDLED WITH
data/README.md CHANGED
@@ -62,7 +62,7 @@ Nanook.new.wallet(wallet_id).accounts
62
62
 
63
63
  ### Sending a payment
64
64
 
65
- You can send a payment from an account in a wallet:
65
+ To send a payment from an account in a wallet:
66
66
 
67
67
  ```ruby
68
68
  account = Nanook.new.wallet(wallet_id).account(account_id)
@@ -80,7 +80,11 @@ The `id` can be any string and needs to be unique per payment. It serves an impo
80
80
 
81
81
  > You can (and should) specify a unique id for each spend to provide idempotency. That means that if you [make the payment call] two times with the same id, the second request won't send any additional Nano.
82
82
 
83
- The unit of the `amount` is NANO (which is currently technically 1Mnano &mdash; see [What are Nano's Units](https://nano.org/en/faq#what-are-nano-units-)).
83
+ The unit of the `amount` is NANO (which is currently technically Mnano &mdash; see [What are Nano's Units](https://nano.org/en/faq#what-are-nano-units-)). You can pass an amount of raw instead by adding the `unit: :raw` argument:
84
+
85
+ ```ruby
86
+ account.pay(to: recipient_account_id, amount: 999, unit: :raw, id: unique_id)
87
+ ```
84
88
 
85
89
  Note, there may be a delay in receiving a response due to Proof of Work being done. From the [Nano RPC](https://github.com/nanocurrency/raiblocks/wiki/RPC-protocol#account-create):
86
90
 
@@ -116,6 +120,8 @@ wallet.receive(block_id, into: account_id)
116
120
 
117
121
  ## All commands
118
122
 
123
+ Below is a quick reference list of commands. See the [full Nanook documentation](https://lukes.github.io/nanook/1.0.0/) for a searchable detailed description of every class and method, what the arguments mean, and example responses (Tip: expand the "**Nanook** < Object" item in the sidebar).
124
+
119
125
  ### Wallets
120
126
 
121
127
  See the [full documentation for Nanook::Wallet](https://lukes.github.io/nanook/1.0.0/classes/Nanook/Wallet.html) for a detailed description of each method and example responses.
@@ -131,11 +137,6 @@ Nanook.new.wallet.create
131
137
  ```ruby
132
138
  wallet = Nanook.new.wallet(wallet_id)
133
139
 
134
- wallet.export
135
- wallet.locked?
136
- wallet.unlock(password)
137
- wallet.change_password(password)
138
-
139
140
  wallet.balance
140
141
  wallet.balance(account_break_down: true)
141
142
  wallet.balance(unit: :raw)
@@ -148,6 +149,11 @@ wallet.account.create
148
149
  wallet.accounts
149
150
  wallet.contains?(account_id)
150
151
 
152
+ wallet.export
153
+ wallet.locked?
154
+ wallet.unlock(password)
155
+ wallet.change_password(password)
156
+
151
157
  wallet.destroy
152
158
  ```
153
159
  ### Accounts
@@ -163,6 +169,15 @@ Nanook.new.wallet(wallet_id).account.create
163
169
  ```ruby
164
170
  account = Nanook.new.wallet(wallet_id).account(account_id)
165
171
 
172
+ account.balance
173
+ account.balance(unit: :raw)
174
+ account.pay(to: recipient_account_id, amount: 2, id: unique_id)
175
+ account.pay(to: recipient_account_id, amount: 2, unit: :raw, id: unique_id)
176
+ account.pending
177
+ account.pending(limit: 1)
178
+ account.receive
179
+ account.receive(pending_block_id)
180
+
166
181
  account.exists?
167
182
  account.info
168
183
  account.info(detailed: true)
@@ -175,15 +190,6 @@ account.delegators
175
190
  account.representative
176
191
  account.weight
177
192
 
178
- account.balance
179
- account.balance(unit: :raw)
180
- account.pay(to: recipient_account_id, amount: 2, id: unique_id)
181
- account.pay(to: recipient_account_id, amount: 2, unit: :raw, id: unique_id)
182
- account.pending
183
- account.pending(limit: 1)
184
- account.receive
185
- account.receive(pending_block_id)
186
-
187
193
  account.destroy
188
194
  ```
189
195
 
@@ -194,6 +200,11 @@ See the [full documentation for Nanook::Account](https://lukes.github.io/nanook/
194
200
  ```ruby
195
201
  account = Nanook.new.account(account_id)
196
202
 
203
+ account.balance
204
+ account.balance(unit: :raw)
205
+ account.pending
206
+ account.pending(limit: 1)
207
+
197
208
  account.exists?
198
209
  account.info
199
210
  account.info(detailed: true)
@@ -205,15 +216,12 @@ account.public_key
205
216
  account.delegators
206
217
  account.representative
207
218
  account.weight
208
-
209
- account.balance
210
- account.balance(unit: :raw)
211
- account.pending
212
- account.pending(limit: 1)
213
219
  ```
214
220
 
215
221
  ### Blocks
216
222
 
223
+ See the [full documentation for Nanook::Block](https://lukes.github.io/nanook/1.0.0/classes/Nanook/Block.html) for a detailed description of each method and example responses.
224
+
217
225
  ```ruby
218
226
  block = Nanook.new.block(block_id)
219
227
 
@@ -228,7 +236,7 @@ block.republish
228
236
  block.republish(sources: 2)
229
237
  block.republish(destinations: 2)
230
238
  block.pending?
231
- block.process
239
+ block.publish
232
240
  block.successors
233
241
  block.successors(limit: 10)
234
242
 
@@ -302,6 +310,10 @@ To run the test suite:
302
310
 
303
311
  bundle exec rspec spec
304
312
 
313
+ To update rdoc documentation:
314
+
315
+ bundle exec rake rerdoc
316
+
305
317
  ## License
306
318
 
307
319
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/bin/console CHANGED
@@ -6,9 +6,5 @@ require "nanook"
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
9
+ require "pry"
10
+ Pry.start
@@ -294,21 +294,24 @@ account = Nanook::Account.new(rpc_conn, &quot;xrb_...&quot;)
294
294
  <div class="description">
295
295
  <p>Returns a Hash containing the account&#39;s balance. Units are in <a
296
296
  href="https://nano.org/en/faq#what-are-nano-units-">raw</a>.</p>
297
- <table class="rdoc-list label-list"><tbody><tr><td class='label'><code>:balance</code></td><td>
297
+ <dl class="rdoc-list label-list"><dt><code>:balance</code>
298
+ <dd>
298
299
  <p><a href="Account.html">Account</a> balance</p>
299
- </td></tr><tr><td class='label'><code>:pending</code></td><td>
300
+ </dd><dt><code>:pending</code>
301
+ <dd>
300
302
  <p>Amount pending and not yet received by the account</p>
301
- </td></tr></tbody></table>
303
+ </dd></dl>
302
304
 
303
305
  <h4 id="method-i-balance-label-Arguments">Arguments</h4>
304
- <table class="rdoc-list label-list"><tbody><tr><td class='label'><code>unit:</code></td><td>
306
+ <dl class="rdoc-list label-list"><dt><code>unit:</code>
307
+ <dd>
305
308
  <p>Symbol (default is <code>:nano</code>) Represents the unit that the
306
309
  balances will be returned in. Must be either <code>:nano</code> or
307
310
  <code>:raw</code>. (Note: this method interprets <code>:nano</code> as
308
311
  NANO, which is technically Mnano See <a
309
312
  href="https://nano.org/en/faq#what-are-nano-units-">What are Nano’s
310
313
  Units</a>)</p>
311
- </td></tr></tbody></table>
314
+ </dd></dl>
312
315
 
313
316
  <h5 id="method-i-balance-label-Example+response">Example response</h5>
314
317
 
@@ -461,10 +464,11 @@ href="Node.html#method-i-sync_progress">Nanook::Node#sync_progress</a>.</p>
461
464
  in <a href="https://nano.org/en/faq#what-are-nano-units-">raw</a>.</p>
462
465
 
463
466
  <h4 id="method-i-history-label-Arguments">Arguments</h4>
464
- <table class="rdoc-list label-list"><tbody><tr><td class='label'><code>limit:</code></td><td>
467
+ <dl class="rdoc-list label-list"><dt><code>limit:</code>
468
+ <dd>
465
469
  <p>Integer representing the maximum number of history items to return (default
466
470
  is 1000)</p>
467
- </td></tr></tbody></table>
471
+ </dd></dl>
468
472
 
469
473
  <h4 id="method-i-history-label-Example">Example</h4>
470
474
 
@@ -526,7 +530,7 @@ account.history(limit: 1)
526
530
 
527
531
 
528
532
  <div class="description">
529
-
533
+ <p>Returns the id of the account</p>
530
534
  </div>
531
535
 
532
536
 
@@ -544,7 +548,7 @@ account.history(limit: 1)
544
548
 
545
549
  </p>
546
550
  <div id="method-i-id_source" class="dyn-source">
547
- <pre><span class="ruby-comment"># File lib/nanook/account.rb, line 136</span>
551
+ <pre><span class="ruby-comment"># File lib/nanook/account.rb, line 137</span>
548
552
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">id</span>
549
553
  <span class="ruby-ivar">@block</span>
550
554
  <span class="ruby-keyword">end</span></pre>
@@ -564,39 +568,50 @@ account.history(limit: 1)
564
568
 
565
569
  <div class="description">
566
570
  <p>Returns a Hash containing the following information about an account:</p>
567
- <table class="rdoc-list label-list"><tbody><tr><td class='label'><code>:frontier</code></td><td>
571
+ <dl class="rdoc-list label-list"><dt><code>:frontier</code>
572
+ <dd>
568
573
  <p>The latest block hash</p>
569
- </td></tr><tr><td class='label'><code>:open_block</code></td><td>
574
+ </dd><dt><code>:open_block</code>
575
+ <dd>
570
576
  <p>The first block in every account&#39;s blockchain. When this block was
571
577
  published the account was officially open</p>
572
- </td></tr><tr><td class='label'><code>:representative_block</code></td><td>
578
+ </dd><dt><code>:representative_block</code>
579
+ <dd>
573
580
  <p>The block that named the representative for the account</p>
574
- </td></tr><tr><td class='label'><code>:balance</code></td><td>
581
+ </dd><dt><code>:balance</code>
582
+ <dd>
575
583
  <p>Amount in <a href="https://nano.org/en/faq#what-are-nano-units-">NANO</a></p>
576
- </td></tr><tr><td class='label'><code>:last_modified</code></td><td>
584
+ </dd><dt><code>:last_modified</code>
585
+ <dd>
577
586
  <p>Unix timestamp</p>
578
- </td></tr><tr><td class='label'><code>:block_count</code></td><td>
587
+ </dd><dt><code>:block_count</code>
588
+ <dd>
579
589
  <p>Number of blocks in the account&#39;s blockchain</p>
580
- </td></tr></tbody></table>
590
+ </dd></dl>
581
591
 
582
592
  <p>When <code>detailed: true</code> is passed as an argument, this method
583
593
  makes four additional calls to the RPC to return more information about an
584
594
  account:</p>
585
- <table class="rdoc-list label-list"><tbody><tr><td class='label'><code>:weight</code></td><td>
595
+ <dl class="rdoc-list label-list"><dt><code>:weight</code>
596
+ <dd>
586
597
  <p>See <a href="Account.html#method-i-weight">weight</a></p>
587
- </td></tr><tr><td class='label'><code>:pending</code></td><td>
598
+ </dd><dt><code>:pending</code>
599
+ <dd>
588
600
  <p>See <a href="Account.html#method-i-balance">balance</a></p>
589
- </td></tr><tr><td class='label'><code>:representative</code></td><td>
601
+ </dd><dt><code>:representative</code>
602
+ <dd>
590
603
  <p>See <a href="Account.html#method-i-representative">representative</a></p>
591
- </td></tr><tr><td class='label'><code>:public_key</code></td><td>
604
+ </dd><dt><code>:public_key</code>
605
+ <dd>
592
606
  <p>See <a href="Account.html#method-i-public_key">public_key</a></p>
593
- </td></tr></tbody></table>
607
+ </dd></dl>
594
608
 
595
609
  <h4 id="method-i-info-label-Arguments">Arguments</h4>
596
- <table class="rdoc-list label-list"><tbody><tr><td class='label'><code>detailed:</code></td><td>
610
+ <dl class="rdoc-list label-list"><dt><code>detailed:</code>
611
+ <dd>
597
612
  <p>Boolean (default is false). When <code>true</code>, four additional calls
598
613
  are made to the RPC to return more information</p>
599
- </td></tr></tbody></table>
614
+ </dd></dl>
600
615
 
601
616
  <h4 id="method-i-info-label-Example+1">Example 1</h4>
602
617
 
@@ -652,7 +667,7 @@ are made to the RPC to return more information</p>
652
667
 
653
668
  </p>
654
669
  <div id="method-i-info_source" class="dyn-source">
655
- <pre><span class="ruby-comment"># File lib/nanook/account.rb, line 196</span>
670
+ <pre><span class="ruby-comment"># File lib/nanook/account.rb, line 197</span>
656
671
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">info</span>(<span class="ruby-value">detailed:</span> <span class="ruby-keyword">false</span>)
657
672
  <span class="ruby-identifier">account_required!</span>
658
673
 
@@ -695,9 +710,10 @@ the ledger. The number of accounts returned is determined by the
695
710
  href="Account.html#method-i-info">info</a>(detailed: false) method returns.</p>
696
711
 
697
712
  <h4 id="method-i-ledger-label-Arguments">Arguments</h4>
698
- <table class="rdoc-list label-list"><tbody><tr><td class='label'><code>limit:</code></td><td>
713
+ <dl class="rdoc-list label-list"><dt><code>limit:</code>
714
+ <dd>
699
715
  <p>Number of accounts to return in the ledger (default is 1)</p>
700
- </td></tr></tbody></table>
716
+ </dd></dl>
701
717
 
702
718
  <h4 id="method-i-ledger-label-Example">Example</h4>
703
719
 
@@ -735,7 +751,7 @@ href="Account.html#method-i-info">info</a>(detailed: false) method returns.</p>
735
751
 
736
752
  </p>
737
753
  <div id="method-i-ledger_source" class="dyn-source">
738
- <pre><span class="ruby-comment"># File lib/nanook/account.rb, line 247</span>
754
+ <pre><span class="ruby-comment"># File lib/nanook/account.rb, line 248</span>
739
755
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">ledger</span>(<span class="ruby-value">limit:</span> <span class="ruby-value">1</span>)
740
756
  <span class="ruby-identifier">account_required!</span>
741
757
  <span class="ruby-identifier">rpc</span>(<span class="ruby-value">:ledger</span>, <span class="ruby-value">count:</span> <span class="ruby-identifier">limit</span>)[<span class="ruby-value">:accounts</span>]
@@ -765,12 +781,14 @@ href="https://nano.org/en/faq#what-are-nano-units-">raw</a> of the pending
765
781
  block and the source account that sent it.</p>
766
782
 
767
783
  <h4 id="method-i-pending-label-Arguments">Arguments</h4>
768
- <table class="rdoc-list label-list"><tbody><tr><td class='label'><code>limit:</code></td><td>
784
+ <dl class="rdoc-list label-list"><dt><code>limit:</code>
785
+ <dd>
769
786
  <p>Number of pending blocks to return (default is 1000)</p>
770
- </td></tr><tr><td class='label'><code>detailed:</code></td><td>
787
+ </dd><dt><code>detailed:</code>
788
+ <dd>
771
789
  <p>Boolean to have this method return a more complex Hash of pending block
772
790
  information (default is <code>false</code>)</p>
773
- </td></tr></tbody></table>
791
+ </dd></dl>
774
792
 
775
793
  <h4 id="method-i-pending-label-Example+1">Example 1</h4>
776
794
 
@@ -813,7 +831,7 @@ information (default is <code>false</code>)</p>
813
831
 
814
832
  </p>
815
833
  <div id="method-i-pending_source" class="dyn-source">
816
- <pre><span class="ruby-comment"># File lib/nanook/account.rb, line 288</span>
834
+ <pre><span class="ruby-comment"># File lib/nanook/account.rb, line 289</span>
817
835
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">pending</span>(<span class="ruby-value">limit:</span> <span class="ruby-value">1000</span>, <span class="ruby-value">detailed:</span> <span class="ruby-keyword">false</span>)
818
836
  <span class="ruby-identifier">account_required!</span>
819
837
 
@@ -951,7 +969,7 @@ if it is a representative.</p>
951
969
 
952
970
  </p>
953
971
  <div id="method-i-weight_source" class="dyn-source">
954
- <pre><span class="ruby-comment"># File lib/nanook/account.rb, line 304</span>
972
+ <pre><span class="ruby-comment"># File lib/nanook/account.rb, line 305</span>
955
973
  <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">weight</span>
956
974
  <span class="ruby-identifier">account_required!</span>
957
975
  <span class="ruby-identifier">rpc</span>(<span class="ruby-value">:account_weight</span>)[<span class="ruby-value">:weight</span>]