nis-ruby 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +43 -33
  3. data/examples/account/generate.rb +29 -0
  4. data/examples/account/get.rb +26 -0
  5. data/examples/account/harvests.rb +8 -0
  6. data/examples/account/historical.rb +13 -0
  7. data/examples/account/importances.rb +8 -0
  8. data/examples/account/lock.rb +8 -0
  9. data/examples/account/mosaic.rb +9 -0
  10. data/examples/account/namespace.rb +8 -0
  11. data/examples/account/status.rb +8 -0
  12. data/examples/account/transfers.rb +16 -0
  13. data/examples/account/unconfirmed_transactions.rb +8 -0
  14. data/examples/account/unlock.rb +8 -0
  15. data/examples/account/unlocked.rb +8 -0
  16. data/examples/block/at_public.rb +4 -0
  17. data/examples/block/get.rb +4 -0
  18. data/examples/debug/connections.rb +13 -0
  19. data/examples/debug/time_synchronization.rb +6 -0
  20. data/examples/local/account_transfers.rb +20 -0
  21. data/examples/local/chain_blocks_after.rb +8 -0
  22. data/examples/namespace/mosaic_definition.rb +6 -0
  23. data/examples/namespace/root.rb +6 -0
  24. data/examples/nis.rb +11 -7
  25. data/examples/node/active_peers.rb +6 -0
  26. data/examples/node/boot.rb +25 -0
  27. data/examples/node/info.rb +8 -0
  28. data/examples/node/peerlist.rb +14 -0
  29. data/examples/time_sync/network_time.rb +6 -0
  30. data/examples/transactions/get.rb +42 -0
  31. data/examples/transactions/importance_transfer.rb +6 -4
  32. data/examples/transactions/mosaic_definition_creation.rb +6 -4
  33. data/examples/transactions/mosaic_supply_change.rb +6 -4
  34. data/examples/transactions/multisig.rb +6 -4
  35. data/examples/transactions/multisig_add_cosignatory.rb +3 -1
  36. data/examples/transactions/multisig_aggregate_modification.rb +6 -4
  37. data/examples/transactions/multisig_signature.rb +6 -3
  38. data/examples/transactions/provision_namespace.rb +6 -4
  39. data/examples/transactions/transfer.rb +14 -7
  40. data/examples/transactions/transfer_mosaic.rb +5 -3
  41. data/examples/transactions/transfer_remote.rb +6 -4
  42. data/lib/nis.rb +6 -0
  43. data/lib/nis/client.rb +11 -0
  44. data/lib/nis/configuration.rb +23 -0
  45. data/lib/nis/endpoint/account/transfers.rb +24 -0
  46. data/lib/nis/endpoint/debug/connections.rb +17 -0
  47. data/lib/nis/endpoint/local/account/transfers.rb +14 -0
  48. data/lib/nis/endpoint/node/peer_list.rb +20 -0
  49. data/lib/nis/endpoint/time_sync.rb +4 -0
  50. data/lib/nis/endpoint/time_sync/network_time.rb +10 -0
  51. data/lib/nis/endpoint/transaction/get.rb +12 -0
  52. data/lib/nis/keypair.rb +13 -7
  53. data/lib/nis/struct.rb +1 -0
  54. data/lib/nis/struct/importance_transfer_transaction.rb +10 -0
  55. data/lib/nis/struct/message.rb +9 -2
  56. data/lib/nis/struct/mosaic_definition_creation_transaction.rb +15 -0
  57. data/lib/nis/struct/mosaic_supply_change_transaction.rb +12 -0
  58. data/lib/nis/struct/multisig_aggregate_modification_transaction.rb +10 -0
  59. data/lib/nis/struct/multisig_signature_transaction.rb +12 -0
  60. data/lib/nis/struct/multisig_transaction.rb +15 -0
  61. data/lib/nis/struct/network_time.rb +17 -0
  62. data/lib/nis/struct/provision_namespace_transaction.rb +16 -0
  63. data/lib/nis/struct/transaction.rb +4 -81
  64. data/lib/nis/struct/transaction_meta_data_pair.rb +17 -1
  65. data/lib/nis/struct/transfer_transaction.rb +11 -0
  66. data/lib/nis/unit/address.rb +11 -4
  67. data/lib/nis/util.rb +3 -1
  68. data/lib/nis/util/convert.rb +44 -51
  69. data/lib/nis/util/deserializer.rb +62 -77
  70. data/lib/nis/util/ed25519.rb +10 -12
  71. data/lib/nis/util/serializer.rb +117 -185
  72. data/lib/nis/version.rb +1 -1
  73. data/nis.gemspec +0 -3
  74. metadata +43 -26
  75. data/bin/nis +0 -60
  76. data/examples/account.rb +0 -44
  77. data/examples/block.rb +0 -9
  78. data/examples/debug.rb +0 -33
  79. data/examples/local.rb +0 -19
  80. data/examples/namespace.rb +0 -9
  81. data/examples/node.rb +0 -44
  82. data/examples/shutdown.rb +0 -6
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nis-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshiyuki Ieyama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-24 00:00:00.000000000 Z
11
+ date: 2017-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -164,25 +164,10 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0.11'
167
- - !ruby/object:Gem::Dependency
168
- name: thor
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: '0.19'
174
- type: :runtime
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: '0.19'
181
167
  description: Ruby client library for the NEM Infrastructure Server API
182
168
  email:
183
169
  - yukku0423@gmail.com
184
- executables:
185
- - nis
170
+ executables: []
186
171
  extensions: []
187
172
  extra_rdoc_files: []
188
173
  files:
@@ -195,15 +180,34 @@ files:
195
180
  - LICENSE
196
181
  - README.md
197
182
  - Rakefile
198
- - bin/nis
199
- - examples/account.rb
200
- - examples/block.rb
201
- - examples/debug.rb
202
- - examples/local.rb
203
- - examples/namespace.rb
183
+ - examples/account/generate.rb
184
+ - examples/account/get.rb
185
+ - examples/account/harvests.rb
186
+ - examples/account/historical.rb
187
+ - examples/account/importances.rb
188
+ - examples/account/lock.rb
189
+ - examples/account/mosaic.rb
190
+ - examples/account/namespace.rb
191
+ - examples/account/status.rb
192
+ - examples/account/transfers.rb
193
+ - examples/account/unconfirmed_transactions.rb
194
+ - examples/account/unlock.rb
195
+ - examples/account/unlocked.rb
196
+ - examples/block/at_public.rb
197
+ - examples/block/get.rb
198
+ - examples/debug/connections.rb
199
+ - examples/debug/time_synchronization.rb
200
+ - examples/local/account_transfers.rb
201
+ - examples/local/chain_blocks_after.rb
202
+ - examples/namespace/mosaic_definition.rb
203
+ - examples/namespace/root.rb
204
204
  - examples/nis.rb
205
- - examples/node.rb
206
- - examples/shutdown.rb
205
+ - examples/node/active_peers.rb
206
+ - examples/node/boot.rb
207
+ - examples/node/info.rb
208
+ - examples/node/peerlist.rb
209
+ - examples/time_sync/network_time.rb
210
+ - examples/transactions/get.rb
207
211
  - examples/transactions/importance_transfer.rb
208
212
  - examples/transactions/mosaic_definition_creation.rb
209
213
  - examples/transactions/mosaic_supply_change.rb
@@ -218,6 +222,7 @@ files:
218
222
  - examples/util/deserialize.rb
219
223
  - lib/nis.rb
220
224
  - lib/nis/client.rb
225
+ - lib/nis/configuration.rb
221
226
  - lib/nis/endpoint.rb
222
227
  - lib/nis/endpoint/account.rb
223
228
  - lib/nis/endpoint/account/generate.rb
@@ -257,8 +262,11 @@ files:
257
262
  - lib/nis/endpoint/node/peer_list.rb
258
263
  - lib/nis/endpoint/shutdown.rb
259
264
  - lib/nis/endpoint/status.rb
265
+ - lib/nis/endpoint/time_sync.rb
266
+ - lib/nis/endpoint/time_sync/network_time.rb
260
267
  - lib/nis/endpoint/transaction.rb
261
268
  - lib/nis/endpoint/transaction/announce.rb
269
+ - lib/nis/endpoint/transaction/get.rb
262
270
  - lib/nis/endpoint/transaction/prepareAnnounce.rb
263
271
  - lib/nis/error.rb
264
272
  - lib/nis/fee.rb
@@ -294,33 +302,42 @@ files:
294
302
  - lib/nis/struct/explorer_view_model_transaction.rb
295
303
  - lib/nis/struct/extended_node_experience_pair.rb
296
304
  - lib/nis/struct/harvest_info.rb
305
+ - lib/nis/struct/importance_transfer_transaction.rb
297
306
  - lib/nis/struct/key_pair_view_model.rb
298
307
  - lib/nis/struct/message.rb
299
308
  - lib/nis/struct/mosaic.rb
300
309
  - lib/nis/struct/mosaic_attachment.rb
301
310
  - lib/nis/struct/mosaic_definition.rb
311
+ - lib/nis/struct/mosaic_definition_creation_transaction.rb
302
312
  - lib/nis/struct/mosaic_definition_meta_data.rb
303
313
  - lib/nis/struct/mosaic_definition_meta_data_pair.rb
304
314
  - lib/nis/struct/mosaic_id.rb
305
315
  - lib/nis/struct/mosaic_levy.rb
306
316
  - lib/nis/struct/mosaic_properties.rb
317
+ - lib/nis/struct/mosaic_supply_change_transaction.rb
318
+ - lib/nis/struct/multisig_aggregate_modification_transaction.rb
307
319
  - lib/nis/struct/multisig_cosignatory_modification.rb
320
+ - lib/nis/struct/multisig_signature_transaction.rb
321
+ - lib/nis/struct/multisig_transaction.rb
308
322
  - lib/nis/struct/namespace.rb
309
323
  - lib/nis/struct/namespace_meta_data.rb
310
324
  - lib/nis/struct/namespace_meta_data_pair.rb
311
325
  - lib/nis/struct/nem_announce_result.rb
312
326
  - lib/nis/struct/nem_async_timer_visitor.rb
313
327
  - lib/nis/struct/nem_request_result.rb
328
+ - lib/nis/struct/network_time.rb
314
329
  - lib/nis/struct/nis_node_info.rb
315
330
  - lib/nis/struct/node.rb
316
331
  - lib/nis/struct/node_collection.rb
317
332
  - lib/nis/struct/node_experience.rb
333
+ - lib/nis/struct/provision_namespace_transaction.rb
318
334
  - lib/nis/struct/request_announce.rb
319
335
  - lib/nis/struct/request_prepare_announce.rb
320
336
  - lib/nis/struct/time_synchronization_result.rb
321
337
  - lib/nis/struct/transaction.rb
322
338
  - lib/nis/struct/transaction_meta_data.rb
323
339
  - lib/nis/struct/transaction_meta_data_pair.rb
340
+ - lib/nis/struct/transfer_transaction.rb
324
341
  - lib/nis/struct/unconfirmed_transaction_meta_data.rb
325
342
  - lib/nis/struct/unconfirmed_transaction_meta_data_pair.rb
326
343
  - lib/nis/transaction.rb
data/bin/nis DELETED
@@ -1,60 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
-
4
- require 'thor'
5
- require 'nis'
6
- require 'nis/version'
7
-
8
- class Nis
9
- class CLI < Thor
10
- class_option :help, type: :boolean, aliases: '-h', desc: 'help message.'
11
- class_option :version, type: :boolean, desc: 'version'
12
- class_option :debug, type: :boolean, aliases: '-d', desc: 'debug mode'
13
-
14
- desc 'heartbeat', 'Get NIS heartbeat'
15
- def heartbeat
16
- puts Nis.new.heartbeat.to_json
17
- setting_debug_mode
18
- rescue => e
19
- output_error_if_debug_mode(e)
20
- exit(false)
21
- end
22
-
23
- desc 'status', 'Get NIS status'
24
- def status
25
- puts Nis.new.status.to_json
26
- setting_debug_mode
27
- rescue => e
28
- output_error_if_debug_mode(e)
29
- exit(false)
30
- end
31
-
32
- desc 'request', 'Send request to NIS'
33
- option :params, type: :hash
34
- def request(method, path)
35
- puts Nis.new.request(method, path, options['params'])
36
- setting_debug_mode
37
- rescue => e
38
- output_error_if_debug_mode(e)
39
- exit(false)
40
- end
41
-
42
- desc 'version', 'version'
43
- def version
44
- puts Nis::VERSION
45
- end
46
-
47
- private
48
-
49
- def setting_debug_mode
50
- $DEBUG = options[:debug]
51
- end
52
-
53
- def output_error_if_debug_mode(e)
54
- return unless options[:debug]
55
- STDERR.puts(e.backtrace)
56
- end
57
- end
58
- end
59
-
60
- Nis::CLI.start(ARGV)
@@ -1,44 +0,0 @@
1
- require 'nis'
2
-
3
- # create NIS instance
4
- nis = Nis.new
5
-
6
- # "/account/generate"
7
- # -> account_generate
8
- # Each endpoint mapped into method name.
9
- # It returns Nis::Struct object which mapped API response.
10
- keypair = nis.account_generate
11
-
12
- # Access properties.
13
- # Names are same API response.
14
- puts keypair.address
15
- puts keypair.privateKey
16
- puts keypair.publicKey
17
-
18
- # Ruby style access.
19
- # Also can be access property by snakecase.
20
- puts keypair.private_key
21
- puts keypair.public_key
22
-
23
- # hash like access.
24
- # Also can be access property like hash.
25
- puts keypair[:privateKey]
26
- puts keypair[:private_key]
27
-
28
- # Address object
29
- # Some property wrapped by value object.
30
- puts address = keypair.address
31
- puts address.testnet?
32
-
33
- # /account/get?address={address}
34
- # -> account_get address: {address}
35
- # Passing parameters by keyword arguments.
36
- account_meta_pair = nis.account_get(address: keypair.address)
37
- account = account_meta_pair[:account]
38
- puts account.balance
39
-
40
- # /account/get/from-public-key?public-key={key}
41
- # -> account_get_public_key public_key: {key}
42
- account_meta_pair = nis.account_get_from_public_key(public_key: keypair.public_key)
43
- account = account_meta_pair.account
44
- puts account.address
@@ -1,9 +0,0 @@
1
- require 'nis'
2
-
3
- nis = Nis.new
4
-
5
- block = nis.block_at_public(block_height: 890_761)
6
-
7
- puts block.to_hash
8
-
9
- puts nis.block_get(block_hash: 'fb5e76bf137eb27451926d29fd2b308e672e5d9ec405d9cbcd47cc0f83492cd0')
@@ -1,33 +0,0 @@
1
- require 'nis'
2
-
3
- nis = Nis.new
4
-
5
- incoming = nis.debug_connections_incoming
6
-
7
- incoming[:outstanding].each do |ai|
8
- puts ai.to_hash
9
- end
10
-
11
- incoming[:most_recent].each do |ai|
12
- puts ai.to_hash
13
- end
14
-
15
- outgoing = nis.debug_connections_outgoing
16
-
17
- outgoing[:outstanding].each do |ai|
18
- puts ai.to_hash
19
- end
20
-
21
- outgoing[:most_recent].each do |ai|
22
- puts ai.to_hash
23
- end
24
-
25
- timers = nis.debug_connections_timers
26
- timers.each do |t|
27
- puts t.to_hash
28
- end
29
-
30
- syncs = nis.debug_time_synchronization
31
- syncs.each do |sync|
32
- puts sync.to_hash
33
- end
@@ -1,19 +0,0 @@
1
- require 'nis'
2
-
3
- nis = Nis.new
4
-
5
- page = Nis::Struct::AccountPrivateKeyTransactionsPage.new(
6
- value: '00b4a68d16dc505302e9631b860664ba43a8183f0903bc5782a2403b2f9eb3c8a1'
7
- )
8
-
9
- incoming = nis.local_account_transfers_incoming(page: page)
10
- puts incoming.last.to_hash
11
-
12
- outgoing = nis.local_account_transfers_outgoing(page: page)
13
- puts outgoing.last.to_hash
14
-
15
- all = nis.local_account_transfers_all(page: page)
16
- puts all.last.to_hash
17
-
18
- blocks = nis.local_chain_blocks_after(block_height: 2_649)
19
- puts blocks.last
@@ -1,9 +0,0 @@
1
- require 'nis'
2
-
3
- nis = Nis.new
4
-
5
- ns_mosaics = nis.namespace_mosaic_definition_page(namespace: 'alice.misc')
6
- puts ns_mosaics.first.to_hash
7
-
8
- ns_root = nis.namespace_root_page
9
- puts ns_root.first.to_hash
@@ -1,44 +0,0 @@
1
- require 'nis'
2
-
3
- nis = Nis.new
4
-
5
- node_info = nis.node_info
6
- puts node_info.to_hash
7
-
8
- ext_node_info = nis.node_extended_info
9
- puts ext_node_info.to_hash
10
-
11
- node_exp = nis.node_experiences
12
- puts node_exp.first.to_hash
13
-
14
- peer_all = nis.node_peerlist_all
15
- puts peer_all.to_hash
16
-
17
- reachables = nis.node_peerlist_reachable
18
- puts reachables.first.to_hash
19
-
20
- actives = nis.node_peerlist_active
21
- puts actives.first.to_hash
22
-
23
- puts nis.node_active_peers_max_chain_height
24
-
25
- bnr = Nis::Struct::BootNodeRequest.new(
26
- metaData: {
27
- application: 'NIS'
28
- },
29
- endpoint: {
30
- protocol: 'http',
31
- port: 7890,
32
- host: 'localhost'
33
- },
34
- identity: {
35
- 'private-key': 'a6cbd01d04edecfaef51df9486c111abb6299c764a00206eb1d01f4587491b3f',
36
- name: 'Alice'
37
- }
38
- )
39
-
40
- begin
41
- puts nis.node_boot(boot_node_request: bnr)
42
- rescue => ex
43
- puts ex
44
- end
@@ -1,6 +0,0 @@
1
- require 'nis'
2
-
3
- nis = Nis.new(host: 'localhost')
4
-
5
- # only accept local node
6
- nis.shutdown