nem-ruby 0.0.1

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.
Files changed (136) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +119 -0
  5. data/.travis.yml +23 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +6 -0
  8. data/README.md +81 -0
  9. data/Rakefile +6 -0
  10. data/examples/apostille_audit.rb +22 -0
  11. data/examples/apostille_create.rb +31 -0
  12. data/examples/endpoint/account.rb +73 -0
  13. data/examples/endpoint/account_local.rb +21 -0
  14. data/examples/endpoint/block.rb +14 -0
  15. data/examples/endpoint/chain.rb +15 -0
  16. data/examples/endpoint/debug.rb +17 -0
  17. data/examples/endpoint/local.rb +17 -0
  18. data/examples/endpoint/mosaic.rb +9 -0
  19. data/examples/endpoint/namespace.rb +13 -0
  20. data/examples/endpoint/node.rb +24 -0
  21. data/examples/endpoint/timesync.rb +9 -0
  22. data/examples/endpoint/transaction.rb +42 -0
  23. data/examples/localnode.rb +0 -0
  24. data/examples/nis.rb +34 -0
  25. data/examples/node_pool.rb +23 -0
  26. data/examples/transaction/importance_transfer.rb +23 -0
  27. data/examples/transaction/mosaic_definition_creation.rb +52 -0
  28. data/examples/transaction/mosaic_supply_change.rb +25 -0
  29. data/examples/transaction/multisig_add_cosignatory.rb +31 -0
  30. data/examples/transaction/multisig_aggregate_modification.rb +29 -0
  31. data/examples/transaction/multisig_signature.rb +41 -0
  32. data/examples/transaction/multisig_transfer.rb +35 -0
  33. data/examples/transaction/provision_namespace.rb +20 -0
  34. data/examples/transaction/transfer.rb +32 -0
  35. data/examples/transaction/transfer_mosaic.rb +72 -0
  36. data/examples/transaction/transfer_with_encrypted_message.rb +40 -0
  37. data/examples/transaction/transfer_with_local.rb +34 -0
  38. data/lib/nem.rb +21 -0
  39. data/lib/nem/apostille.rb +104 -0
  40. data/lib/nem/apostille_audit.rb +47 -0
  41. data/lib/nem/client.rb +170 -0
  42. data/lib/nem/configuration.rb +29 -0
  43. data/lib/nem/endpoint.rb +4 -0
  44. data/lib/nem/endpoint/account.rb +264 -0
  45. data/lib/nem/endpoint/base.rb +45 -0
  46. data/lib/nem/endpoint/block.rb +15 -0
  47. data/lib/nem/endpoint/chain.rb +17 -0
  48. data/lib/nem/endpoint/debug.rb +54 -0
  49. data/lib/nem/endpoint/local/account.rb +54 -0
  50. data/lib/nem/endpoint/local/chain.rb +15 -0
  51. data/lib/nem/endpoint/mosaic.rb +13 -0
  52. data/lib/nem/endpoint/namespace.rb +37 -0
  53. data/lib/nem/endpoint/node.rb +83 -0
  54. data/lib/nem/endpoint/timesync.rb +9 -0
  55. data/lib/nem/endpoint/transaction.rb +34 -0
  56. data/lib/nem/error.rb +6 -0
  57. data/lib/nem/fee.rb +2 -0
  58. data/lib/nem/fee/importance_transfer.rb +24 -0
  59. data/lib/nem/fee/mosaic_definition_creation.rb +24 -0
  60. data/lib/nem/fee/mosaic_supply_change_transfer.rb +24 -0
  61. data/lib/nem/fee/multisig.rb +24 -0
  62. data/lib/nem/fee/multisig_aggregation_modification.rb +28 -0
  63. data/lib/nem/fee/provision_namespace.rb +34 -0
  64. data/lib/nem/fee/transfer.rb +66 -0
  65. data/lib/nem/keypair.rb +44 -0
  66. data/lib/nem/mixin.rb +2 -0
  67. data/lib/nem/mixin/assignable.rb +12 -0
  68. data/lib/nem/model.rb +3 -0
  69. data/lib/nem/model/account.rb +67 -0
  70. data/lib/nem/model/account_historical.rb +19 -0
  71. data/lib/nem/model/block.rb +33 -0
  72. data/lib/nem/model/chain.rb +14 -0
  73. data/lib/nem/model/connection.rb +23 -0
  74. data/lib/nem/model/experience.rb +20 -0
  75. data/lib/nem/model/explorer_block.rb +21 -0
  76. data/lib/nem/model/harvest.rb +23 -0
  77. data/lib/nem/model/heartbeat.rb +21 -0
  78. data/lib/nem/model/importance.rb +29 -0
  79. data/lib/nem/model/importance_transfer_transaction.rb +16 -0
  80. data/lib/nem/model/keypair.rb +19 -0
  81. data/lib/nem/model/message.rb +91 -0
  82. data/lib/nem/model/mosaic.rb +21 -0
  83. data/lib/nem/model/mosaic_attachment.rb +22 -0
  84. data/lib/nem/model/mosaic_definition.rb +65 -0
  85. data/lib/nem/model/mosaic_definition_creation_transaction.rb +18 -0
  86. data/lib/nem/model/mosaic_id.rb +27 -0
  87. data/lib/nem/model/mosaic_levy.rb +32 -0
  88. data/lib/nem/model/mosaic_owned.rb +22 -0
  89. data/lib/nem/model/mosaic_properties.rb +44 -0
  90. data/lib/nem/model/mosaic_supply.rb +21 -0
  91. data/lib/nem/model/mosaic_supply_change_transaction.rb +18 -0
  92. data/lib/nem/model/multisig_aggregate_modification_transaction.rb +21 -0
  93. data/lib/nem/model/multisig_info.rb +16 -0
  94. data/lib/nem/model/multisig_signature_transaction.rb +17 -0
  95. data/lib/nem/model/multisig_transaction.rb +21 -0
  96. data/lib/nem/model/namespace.rb +24 -0
  97. data/lib/nem/model/nem_announce_result.rb +19 -0
  98. data/lib/nem/model/network_time.rb +16 -0
  99. data/lib/nem/model/nis_node_info.rb +26 -0
  100. data/lib/nem/model/node.rb +41 -0
  101. data/lib/nem/model/provision_namespace_transaction.rb +18 -0
  102. data/lib/nem/model/status.rb +21 -0
  103. data/lib/nem/model/timer.rb +31 -0
  104. data/lib/nem/model/timesync.rb +19 -0
  105. data/lib/nem/model/transaction.rb +71 -0
  106. data/lib/nem/model/transfer_transaction.rb +24 -0
  107. data/lib/nem/model/unlocked_info.rb +24 -0
  108. data/lib/nem/mosaic.rb +2 -0
  109. data/lib/nem/mosaic/dim_coin.rb +21 -0
  110. data/lib/nem/mosaic/dim_token.rb +21 -0
  111. data/lib/nem/mosaic/ecobit_eco.rb +21 -0
  112. data/lib/nem/mosaic/xem.rb +21 -0
  113. data/lib/nem/node.rb +29 -0
  114. data/lib/nem/node_pool.rb +31 -0
  115. data/lib/nem/request.rb +2 -0
  116. data/lib/nem/request/announce.rb +76 -0
  117. data/lib/nem/transaction.rb +3 -0
  118. data/lib/nem/transaction/base.rb +45 -0
  119. data/lib/nem/transaction/importance_transfer.rb +42 -0
  120. data/lib/nem/transaction/mosaic_definition_creation.rb +45 -0
  121. data/lib/nem/transaction/mosaic_supply_change.rb +45 -0
  122. data/lib/nem/transaction/multisig.rb +29 -0
  123. data/lib/nem/transaction/multisig_aggregate_modification.rb +30 -0
  124. data/lib/nem/transaction/multisig_cosignatory_modification.rb +33 -0
  125. data/lib/nem/transaction/multisig_signature.rb +31 -0
  126. data/lib/nem/transaction/provision_namespace.rb +65 -0
  127. data/lib/nem/transaction/transfer.rb +63 -0
  128. data/lib/nem/util.rb +44 -0
  129. data/lib/nem/util/assignable.rb +51 -0
  130. data/lib/nem/util/convert.rb +112 -0
  131. data/lib/nem/util/deserializer.rb +158 -0
  132. data/lib/nem/util/ed25519.rb +316 -0
  133. data/lib/nem/util/serializer.rb +260 -0
  134. data/lib/nem/version.rb +3 -0
  135. data/nem-ruby.gemspec +46 -0
  136. metadata +350 -0
@@ -0,0 +1,29 @@
1
+ require 'logger'
2
+
3
+ module Nem
4
+ module Configuration
5
+ DEADLINE = 3600
6
+
7
+ # Logger for {#debug}, default is `Nem::Logger.new(STDOUT)`
8
+ # @return [Logger]
9
+ attr_accessor :logger, :deadline, :default_network
10
+
11
+ def self.extended(base)
12
+ base.logger = Logger.new($stdout).tap { |l| l.level = Logger::INFO }
13
+ base.deadline = DEADLINE
14
+ base.default_network = :testnet
15
+ end
16
+
17
+ # @yield [self]
18
+ # @example
19
+ # Nem.configure do |conf|
20
+ # conf.logger = Logger.new('path/to/nem-ruby.log')
21
+ # conf.logger.level = Logger::DEBUG
22
+ # conf.deadline = 7200
23
+ # conf.default_network = :mainnet
24
+ # end
25
+ def configure
26
+ yield self
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ require File.expand_path('endpoint/base.rb', __dir__)
3
+ Dir.glob(File.expand_path('endpoint/*.rb', __dir__)).each { |f| require f }
4
+ Dir.glob(File.expand_path('endpoint/**/*.rb', __dir__)).each { |f| require f }
@@ -0,0 +1,264 @@
1
+ module Nem
2
+ module Endpoint
3
+ class Account < Nem::Endpoint::Base
4
+ # @return [Nem::Model::Keypair]
5
+ # @see https://nemproject.github.io/#generating-new-account-data
6
+ def generate
7
+ request!(:get, '/account/generate') do |res|
8
+ Nem::Model::Keypair.new_from_key_pair_view_model(res)
9
+ end
10
+ end
11
+
12
+ # @param [String] address
13
+ # @return [Nem::Model::Account]
14
+ # @see https://nemproject.github.io/#requesting-the-account-data
15
+ def find(address)
16
+ request!(:get, '/account/get',
17
+ address: address
18
+ ) do |res|
19
+ Nem::Model::Account.new_from_account_meta_data_pair(res)
20
+ end
21
+ end
22
+
23
+ alias get find
24
+
25
+ # @param [String] public_key
26
+ # @return [Nem::Model::Account]
27
+ # @see https://nemproject.github.io/#requesting-the-account-data
28
+ def find_by_public_key(public_key)
29
+ request!(:get, '/account/get/from-public-key',
30
+ publicKey: public_key
31
+ ) do |res|
32
+ Nem::Model::Account.new_from_account_meta_data_pair(res)
33
+ end
34
+ end
35
+
36
+ # @param [String] address
37
+ # @return [Nem::Model::Account]
38
+ # @see https://nemproject.github.io/#requesting-the-original-account-data-for-a-delegate-account
39
+ def find_forwarded(address)
40
+ request!(:get, '/account/get/forwarded',
41
+ address: address
42
+ ) do |res|
43
+ Nem::Model::Account.new_from_account_meta_data_pair(res)
44
+ end
45
+ end
46
+
47
+ # @param [String] public_key
48
+ # @return [Nem::Model::Account]
49
+ # @see https://nemproject.github.io/#requesting-the-original-account-data-for-a-delegate-account
50
+ def find_forwarded_by_public_key(public_key)
51
+ request!(:get, '/account/get/forwarded/from-public-key',
52
+ publicKey: public_key
53
+ ) do |res|
54
+ Nem::Model::Account.new_from_account_meta_data_pair(res)
55
+ end
56
+ end
57
+
58
+ # @param [String] address
59
+ # @param [String] hash
60
+ # @return [Array <Nem::Model::Harvest>]
61
+ # @see https://nemproject.github.io/#requesting-harvest-info-data-for-an-account
62
+ def harvests(address, hash: nil)
63
+ request!(:get, '/account/harvests',
64
+ address: address,
65
+ hash: hash
66
+ ) do |res|
67
+ res[:data].map do |harvest|
68
+ Nem::Model::Harvest.new_from_harvest(harvest)
69
+ end
70
+ end
71
+ end
72
+
73
+ # @return [Array <Nem::Model::Importance>]
74
+ # @see https://nemproject.github.io/#retrieving-account-importances-for-accounts
75
+ def importances
76
+ request!(:get, '/account/importances') do |res|
77
+ res[:data].map do |aivm|
78
+ Nem::Model::Importance.new_from_account_importance_view_model(aivm)
79
+ end
80
+ end
81
+ end
82
+
83
+ # @param [String] address
84
+ # @param [Integer] start_height
85
+ # @param [Integer] end_height
86
+ # @param [Integer] increment
87
+ # @return [Array <Nem::Model::AccountHistorical>]
88
+ # @see https://nemproject.github.io/#retrieving-historical-account-data
89
+ def historical(address, start_height: nil, end_height: nil, increment: nil)
90
+ request!(:get, '/account/historical/get',
91
+ address: address,
92
+ startHeight: start_height,
93
+ endHeight: end_height,
94
+ increment: increment
95
+ ) do |res|
96
+ res[:data].map do |ah|
97
+ Nem::Model::AccountHistorical.new_from_account_historical(ah)
98
+ end
99
+ end
100
+ end
101
+
102
+ # @param [String] address
103
+ # @param [String] parent
104
+ # @param [String] id
105
+ # @return [Array <Nem::Model::MosaicDefinition>]
106
+ # @see https://nemproject.github.io/##retrieving-mosaic-definitions-that-an-account-has-created
107
+ def mosaic_definition(address, parent: nil, id: nil)
108
+ request!(:get, '/account/mosaic/definition/page',
109
+ address: address,
110
+ parent: parent,
111
+ id: id,
112
+ ) do |res|
113
+ res[:data].map do |modef|
114
+ Nem::Model::MosaicDefinition.new_from_mosaic_definition(modef)
115
+ end
116
+ end
117
+ end
118
+
119
+ # @param [String] address
120
+ # @return [Array <Nem::Model::AccountMetaDataPair>]
121
+ # @see https://nemproject.github.io/#retrieving-mosaics-that-an-account-owns
122
+ def mosaic_owned(address)
123
+ request!(:get, '/account/mosaic/owned', address: address) do |res|
124
+ res[:data].map do |moa|
125
+ Nem::Model::Mosaic.new_from_mosaic(moa)
126
+ end
127
+ end
128
+ end
129
+
130
+ # @param [String] address
131
+ # @param [String] parent
132
+ # @param [String] id
133
+ # @param [Integer] page_size
134
+ # @return [Array <Nem::Model::Namespace>]
135
+ # @see https://nemproject.github.io/#retrieving-namespaces-that-an-account-owns
136
+ def namespace(address, parent: nil)
137
+ request!(:get, '/account/namespace/page', address: address, parent: parent) do |res|
138
+ res[:data].map do |ns|
139
+ Nem::Model::Namespace.new_from_namespace(ns)
140
+ end
141
+ end
142
+ end
143
+
144
+ # @param [String] address
145
+ # @return [Nem::Model::Account]
146
+ # @see https://nemproject.github.io/#requesting-the-account-status
147
+ def status(address)
148
+ request!(:get, '/account/status', address: address) do |res|
149
+ Nem::Model::Account.new_from_account_meta_data(res)
150
+ end
151
+ end
152
+
153
+ # @param private_key [String]
154
+ # @return [nil]
155
+ # @see https://nemproject.github.io/#locking-and-unlocking-accounts
156
+ def lock(private_key)
157
+ request!(:post, '/account/lock', value: private_key)
158
+ end
159
+
160
+ # @param [String] private_key
161
+ # @return [nil]
162
+ # @see https://nemproject.github.io/#locking-and-unlocking-accounts
163
+ def unlock(private_key)
164
+ request!(:post, '/account/unlock', value: private_key)
165
+ end
166
+
167
+ # @return [Nem::Model::UnlockedInfo]
168
+ # @see https://nemproject.github.io/#retrieving-the-unlock-info
169
+ def unlocked_info
170
+ request!(:post, '/account/unlocked/info') do |res|
171
+ Nem::Model::UnlockedInfo.new_from_unlocked_info(res)
172
+ end
173
+ end
174
+
175
+ # @param [String] address
176
+ # @param [String] hash
177
+ # @param [String] id
178
+ # @param [Integer] page_size
179
+ # @return [Array <Nem::Model::Transaction>]
180
+ # @see https://nemproject.github.io/#requesting-transaction-data-for-an-account
181
+ def transfers_incoming(address, hash: nil, id: nil, page_size: nil)
182
+ request!(:get, '/account/transfers/incoming',
183
+ address: address,
184
+ hash: hash,
185
+ id: id,
186
+ pageSize: page_size
187
+ ) do |res|
188
+ res[:data].map do |tx|
189
+ Nem::Model::Transaction.new_from_account_transaction_meta_data_pair(tx)
190
+ end
191
+ end
192
+ end
193
+
194
+ # @param [String] address
195
+ # @param [String] hash
196
+ # @param [String] id
197
+ # @param [Integer] page_size
198
+ # @return [Array <Nem::Model::Transaction>]
199
+ # @see https://nemproject.github.io/#requesting-transaction-data-for-an-account
200
+ def transfers_outgoing(address, hash: nil, id: nil, page_size: nil)
201
+ request!(:get, '/account/transfers/outgoing',
202
+ address: address,
203
+ hash: hash,
204
+ id: id,
205
+ pageSize: page_size
206
+ ) do |res|
207
+ res[:data].map do |tx|
208
+ Nem::Model::Transaction.new_from_account_transaction_meta_data_pair(tx)
209
+ end
210
+ end
211
+ end
212
+
213
+ # @param [String] address
214
+ # @param [String] hash
215
+ # @param [String] id
216
+ # @param [Integer] page_size
217
+ # @return [Array <Nem::Model::Transaction>]
218
+ # @see https://nemproject.github.io/#requesting-transaction-data-for-an-account
219
+ def transfers_all(address, hash: nil, id: nil, page_size: nil)
220
+ request!(:get, '/account/transfers/all',
221
+ address: address,
222
+ hash: hash,
223
+ id: id,
224
+ pageSize: page_size
225
+ ) do |res|
226
+ res[:data].map do |tx|
227
+ Nem::Model::Transaction.new_from_account_transaction_meta_data_pair(tx)
228
+ end
229
+ end
230
+ end
231
+
232
+ # @param [String] address
233
+ # @return [Array <Nem::Model::Transaction>]
234
+ # @see https://nemproject.github.io/#requesting-transaction-data-for-an-account
235
+ def unconfirmed_transactions(address)
236
+ request!(:get, '/account/unconfirmedTransactions',
237
+ address: address
238
+ ) do |res|
239
+ res[:data].map do |tx|
240
+ Nem::Model::Transaction.new_from_account_transaction_meta_data_pair(tx)
241
+ end
242
+ end
243
+ end
244
+
245
+ alias transfers_unconfirmed unconfirmed_transactions
246
+
247
+ # @param [String] address
248
+ # @param [String] hash
249
+ # @param [String] id
250
+ # @param [Symbol] dir direction(:in, :out, :unconfirmed, :all)
251
+ # @param [Integer] page_size
252
+ # @return [Array <Nem::Model::TransactionMetaDataPair>]
253
+ # @see https://nemproject.github.io/#requesting-transaction-data-for-an-account
254
+ def transfers(address, hash: nil, id: nil, page_size: nil, dir: :all)
255
+ case dir.to_s
256
+ when /\Ain/ then transfers_incoming(address, hash, id, page_size)
257
+ when /\Aout/ then transfers_outgoing(address, hash, id, page_size)
258
+ when /\Aunconfirmed/ then transfers_unconfirmed(address)
259
+ else transfers_all(address, hash, id, page_size)
260
+ end
261
+ end
262
+ end
263
+ end
264
+ end
@@ -0,0 +1,45 @@
1
+ module Nem
2
+ module Endpoint
3
+ class Base
4
+ def initialize(node)
5
+ @node = if node.is_a?(Nem::NodePool)
6
+ node
7
+ else
8
+ Nem::NodePool.new([node])
9
+ end
10
+ end
11
+
12
+ def current_node
13
+ @node.first
14
+ end
15
+
16
+ def next_node!
17
+ @node.next!
18
+ end
19
+
20
+ def request(method, path, params = {})
21
+ begin
22
+ res = current_node.request(method, path, params)
23
+ block_given? ? yield(res) : res
24
+ rescue Faraday::ConnectionFailed => err
25
+ Nem.logger.error err.message
26
+ next_node!
27
+ retry
28
+ end
29
+ end
30
+
31
+ def request!(method, path, params = {})
32
+ begin
33
+ res = current_node.request!(method, path, params)
34
+ block_given? ? yield(res) : res
35
+ rescue Faraday::ConnectionFailed => err
36
+ Nem.logger.error err.message
37
+ next_node!
38
+ retry
39
+ rescue => err
40
+ raise err
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,15 @@
1
+ module Nem
2
+ module Endpoint
3
+ class Block < Nem::Endpoint::Base
4
+ def find(hash)
5
+ Nem::Model::Block.new_from_block request!(:get, '/block/get', blockHash: hash)
6
+ end
7
+
8
+ alias get find
9
+
10
+ def at_public(height)
11
+ Nem::Model::Block.new_from_block request!(:post, '/block/at/public', height: height)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ module Nem
2
+ module Endpoint
3
+ class Chain < Nem::Endpoint::Base
4
+ def last_block
5
+ Nem::Model::Block.new_from_block request!(:get, '/chain/last-block')
6
+ end
7
+
8
+ def height
9
+ request!(:get, '/chain/height')[:height]
10
+ end
11
+
12
+ def score
13
+ request!(:get, '/chain/score')[:score]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,54 @@
1
+ module Nem
2
+ module Endpoint
3
+ class Debug < Nem::Endpoint::Base
4
+ def time_syncronization
5
+ request!(:get, '/debug/time-synchronization') do |res|
6
+ res[:data].map do |sync|
7
+ Nem::Model::Timesync.new_from_timer(sync)
8
+ end
9
+ end
10
+ end
11
+
12
+ def timers
13
+ request!(:get, '/debug/timers') do |res|
14
+ res[:data].map do |timer|
15
+ Nem::Model::Timer.new_from_timer(timer)
16
+ end
17
+ end
18
+ end
19
+
20
+ Connection = Struct.new(:outstanding, :most_recent)
21
+ def connections_incoming
22
+ request!(:get, '/debug/connections/incoming') do |res|
23
+ outstanding = res[:outstanding].map do |con|
24
+ Nem::Model::Connection.new_from_connection(con)
25
+ end
26
+ most_recent = res[:'most-recent'].map do |con|
27
+ Nem::Model::Connection.new_from_connection(con)
28
+ end
29
+ Connection.new(outstanding, most_recent)
30
+ end
31
+ end
32
+
33
+ def connections_outgoing
34
+ request!(:get, '/debug/connections/outgoing') do |res|
35
+ outstanding = res[:outstanding].map do |con|
36
+ Nem::Model::Connection.new_from_connection(con)
37
+ end
38
+ most_recent = res[:'most-recent'].map do |con|
39
+ Nem::Model::Connection.new_from_connection(con)
40
+ end
41
+ Connection.new(outstanding, most_recent)
42
+ end
43
+ end
44
+
45
+ def connections(dir)
46
+ case dir.to_s
47
+ when /\Ain/ then connections_incoming
48
+ when /\Aout/ then connections_outgoing
49
+ else raise "direction should be :incoming or :outgoing. dir: #{dir}"
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,54 @@
1
+ module Nem
2
+ module Endpoint
3
+ module Local
4
+ class Account < Nem::Endpoint::Base
5
+ def transfers_incoming(value, hash: nil, id: nil, page_size: nil)
6
+ request!(:post, '/local/account/transfers/incoming',
7
+ value: value,
8
+ hash: hash,
9
+ id: id,
10
+ pageSize: page_size
11
+ ) do |res|
12
+ res[:data].map do |tx|
13
+ Nem::Model::Transaction.new_from_account_transaction_meta_data_pair(tx)
14
+ end
15
+ end
16
+ end
17
+
18
+ def transfers_outgoing(value, hash: nil, id: nil, page_size: nil)
19
+ request!(:post, '/local/account/transfers/outgoing',
20
+ value: value,
21
+ hash: hash,
22
+ id: id,
23
+ pageSize: page_size
24
+ ) do |res|
25
+ res[:data].map do |tx|
26
+ Nem::Model::Transaction.new_from_account_transaction_meta_data_pair(tx)
27
+ end
28
+ end
29
+ end
30
+
31
+ def transfers_all(value, hash: nil, id: nil, page_size: nil)
32
+ request!(:post, '/local/account/transfers/all',
33
+ value: value,
34
+ hash: hash,
35
+ id: id,
36
+ pageSize: page_size
37
+ ) do |res|
38
+ res[:data].map do |tx|
39
+ Nem::Model::Transaction.new_from_account_transaction_meta_data_pair(tx)
40
+ end
41
+ end
42
+ end
43
+
44
+ def transfers(value, hash: nil, id: nil, page_size: nil, dir: :all)
45
+ case dir.to_s
46
+ when /\Ain/ then transfers_incoming(value, hash: hash, id: id, page_size: page_size)
47
+ when /\Aout/ then transfers_outgoing(value, hash: hash, id: id, page_size: page_size)
48
+ else transfers_all(value, hash: hash, id: id, page_size: page_size)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end