nis-ruby 0.0.5 → 0.0.6.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.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/demo/request_account.rb +52 -0
- data/demo/request_debug.rb +49 -0
- data/demo/request_nis.rb +24 -0
- data/demo/request_transaction.rb +49 -0
- data/lib/nis/client.rb +5 -2
- data/lib/nis/endpoint/account/generate.rb +9 -0
- data/lib/nis/endpoint/account/get.rb +47 -0
- data/lib/nis/endpoint/account/harvests.rb +16 -0
- data/lib/nis/endpoint/account/historical.rb +20 -0
- data/lib/nis/endpoint/account/importances.rb +11 -0
- data/lib/nis/endpoint/account/lock.rb +13 -0
- data/lib/nis/endpoint/account/mosaic.rb +27 -0
- data/lib/nis/endpoint/account/namespace.rb +20 -0
- data/lib/nis/endpoint/account/status.rb +14 -0
- data/lib/nis/endpoint/account/transfers.rb +48 -0
- data/lib/nis/endpoint/account/unconfirmed_transactions.rb +12 -0
- data/lib/nis/endpoint/account/unlock.rb +12 -0
- data/lib/nis/endpoint/account/unlocked.rb +9 -0
- data/lib/nis/endpoint/account.rb +4 -0
- data/lib/nis/endpoint/debug/connections.rb +33 -0
- data/lib/nis/endpoint/debug/time_synchronization.rb +11 -0
- data/lib/nis/endpoint/debug.rb +4 -0
- data/lib/nis/endpoint/transaction/announce.rb +13 -0
- data/lib/nis/endpoint/transaction/prepareAnnounce.rb +13 -0
- data/lib/nis/endpoint/transaction.rb +4 -0
- data/lib/nis/struct/account_importance_view_model.rb +26 -0
- data/lib/nis/struct/account_info.rb +28 -0
- data/lib/nis/struct/account_meta_data.rb +39 -0
- data/lib/nis/struct/account_meta_data_pair.rb +16 -0
- data/lib/nis/struct/audit_collection.rb +19 -0
- data/lib/nis/struct/audit_info.rb +23 -0
- data/lib/nis/struct/harvest_info.rb +21 -0
- data/lib/nis/struct/key_pair_view_model.rb +20 -0
- data/lib/nis/struct/mosaic.rb +17 -0
- data/lib/nis/struct/mosaic_definition.rb +17 -0
- data/lib/nis/struct/mosaic_id.rb +16 -0
- data/lib/nis/struct/mosaic_properties.rb +26 -0
- data/lib/nis/struct/namespace.rb +14 -0
- data/lib/nis/struct/nem_announce_result.rb +19 -0
- data/lib/nis/struct/nem_async_timer_visitor.rb +30 -0
- data/lib/nis/struct/request_prepare_announce.rb +16 -0
- data/lib/nis/struct/time_synchronization_result.rb +20 -0
- data/lib/nis/struct/transaction.rb +65 -0
- data/lib/nis/struct/transaction_meta_data.rb +17 -0
- data/lib/nis/struct/transaction_meta_data_pair.rb +19 -0
- data/lib/nis/struct/unconfirmed_transaction_meta_data.rb +12 -0
- data/lib/nis/struct/unconfirmed_transaction_meta_data_pair.rb +16 -0
- data/lib/nis/util/assignable.rb +24 -3
- data/lib/nis/util.rb +6 -0
- data/lib/nis/version.rb +1 -1
- data/lib/nis.rb +20 -0
- metadata +48 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46d4e1ecc31936813e70872ae8b78baeb7d71586
|
4
|
+
data.tar.gz: dfff3b5f9f8823ba28249f0b7bdd16a07d8e0046
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 240fe29c16e64b9ba77de96e6695faabeebcf740719668dbd3f5ec65f43557f86383d49e0a848ff7d547b29ee5543053fce360d97face0582e1da1b9fb6b59aa
|
7
|
+
data.tar.gz: 6a13e62bc27b7250b382e586fcdc53b4978bbe192102af759027485d6638472b69e3f41b143230cf0d0b6257f04e194afa620546dc9ff380362e227cf2f30de0
|
data/README.md
CHANGED
@@ -11,6 +11,7 @@ Ruby client library for the NEM Infrastructure Server API
|
|
11
11
|
|
12
12
|
- [NEM \- Distributed Ledger Technology \(Blockchain\)](https://www.nem.io/)
|
13
13
|
- [NEM NIS API Documentation](http://bob.nem.ninja/docs/)
|
14
|
+
- [NEM Forum](https://forum.nem.io/)
|
14
15
|
|
15
16
|
|
16
17
|
## Installation
|
@@ -73,6 +74,8 @@ puts nis.request! :post, 'transaction/prepare-announce', {
|
|
73
74
|
# See http://bob.nem.ninja/docs/#initiating-a-transfer-transaction
|
74
75
|
```
|
75
76
|
|
77
|
+
More specific demonstrations are in demo/ directory.
|
78
|
+
|
76
79
|
|
77
80
|
## Commandline
|
78
81
|
|
@@ -88,8 +91,6 @@ $ nis request get account/get --params=address:TALICELCD3XPH4FFI5STGGNSNSWPOTG5E
|
|
88
91
|
|
89
92
|
$ nis request get account/harvests --params=address:TALICELCD3XPH4FFI5STGGNSNSWPOTG5E4DS2TOS hash:81d52a7df4abba8bb1613bcc42b6b93cf3114524939035d88ae8e864cd2c34c8
|
90
93
|
# => [Array <HervestInfo structure>]
|
91
|
-
|
92
|
-
|
93
94
|
```
|
94
95
|
|
95
96
|
|
@@ -131,3 +132,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
|
|
131
132
|
## License
|
132
133
|
|
133
134
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
135
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'nis'
|
2
|
+
_hr = '-' * 64
|
3
|
+
|
4
|
+
# create NIS instance
|
5
|
+
nis = Nis.new
|
6
|
+
|
7
|
+
# "/account/generate"
|
8
|
+
# -> account_generate
|
9
|
+
# Each endpoint mapped into method name.
|
10
|
+
# It returns Nis::Struct object which mapped API response.
|
11
|
+
keypair = nis.account_generate
|
12
|
+
puts _hr
|
13
|
+
|
14
|
+
# Access properties.
|
15
|
+
# Names are same API response.
|
16
|
+
puts keypair.address
|
17
|
+
puts keypair.privateKey
|
18
|
+
puts keypair.publicKey
|
19
|
+
puts _hr
|
20
|
+
|
21
|
+
# Ruby style access.
|
22
|
+
# Also can be access property by snakecase.
|
23
|
+
puts keypair.private_key
|
24
|
+
puts keypair.public_key
|
25
|
+
puts _hr
|
26
|
+
|
27
|
+
# hash like access.
|
28
|
+
# Also can be access property like hash.
|
29
|
+
puts keypair[:privateKey]
|
30
|
+
puts keypair[:private_key]
|
31
|
+
puts _hr
|
32
|
+
|
33
|
+
# Address object
|
34
|
+
# Some property wrapped by value object.
|
35
|
+
puts address = keypair.address
|
36
|
+
puts address.testnet?
|
37
|
+
puts _hr
|
38
|
+
|
39
|
+
# /account/get?address={address}
|
40
|
+
# -> account_get address: {address}
|
41
|
+
# Passing parameters by keyword arguments.
|
42
|
+
account_meta_pair = nis.account_get address: keypair.address
|
43
|
+
account = account_meta_pair[:account]
|
44
|
+
puts account.balance
|
45
|
+
puts _hr
|
46
|
+
|
47
|
+
# /account/get/from-public-key?public-key={key}
|
48
|
+
# -> account_get_public_key public_key: {key}
|
49
|
+
account_meta_pair = nis.account_get_from_public_key public_key: keypair.public_key
|
50
|
+
account = account_meta_pair.account
|
51
|
+
puts account.address
|
52
|
+
puts _hr
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nis'
|
3
|
+
_hr = '-' * 64
|
4
|
+
|
5
|
+
# create NIS instance
|
6
|
+
nis = Nis.new
|
7
|
+
|
8
|
+
incoming = nis.debug_connections_incoming
|
9
|
+
|
10
|
+
incoming[:outstanding].each do |ai|
|
11
|
+
puts ai.to_hash
|
12
|
+
end
|
13
|
+
puts _hr
|
14
|
+
|
15
|
+
incoming[:most_recent].each do |ai|
|
16
|
+
puts ai.to_hash
|
17
|
+
end
|
18
|
+
puts _hr
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
outgoing = nis.debug_connections_outgoing
|
23
|
+
|
24
|
+
outgoing[:outstanding].each do |ai|
|
25
|
+
puts ai.to_hash
|
26
|
+
end
|
27
|
+
puts _hr
|
28
|
+
|
29
|
+
outgoing[:most_recent].each do |ai|
|
30
|
+
puts ai.to_hash
|
31
|
+
end
|
32
|
+
puts _hr
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
timers = nis.debug_connections_timers
|
37
|
+
timers.each do |t|
|
38
|
+
puts t.to_hash
|
39
|
+
end
|
40
|
+
puts _hr
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
syncs = nis.debug_time_synchronization
|
45
|
+
syncs.each do |sync|
|
46
|
+
puts sync.to_hash
|
47
|
+
end
|
48
|
+
puts _hr
|
49
|
+
|
data/demo/request_nis.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'nis'
|
2
|
+
|
3
|
+
# Create NIS instance.
|
4
|
+
# By default, connect to local NIS.
|
5
|
+
# You also can connect to remote.
|
6
|
+
# Nis.new(host: '50.3.87.123')
|
7
|
+
nis = Nis.new
|
8
|
+
|
9
|
+
# API path /heartbeat, /status are mapped into methods.
|
10
|
+
# It returns Nis::Struct::NemRequestResult object.
|
11
|
+
puts nis.heartbeat.inspect
|
12
|
+
puts nis.status.inspect
|
13
|
+
|
14
|
+
# Also call Nis#request method.
|
15
|
+
# The method receive [HTTP Method], [API Path], [Parameters]
|
16
|
+
# It returns hash which converted API JSON response.
|
17
|
+
|
18
|
+
# Nis#request returns hash,
|
19
|
+
puts nis.request :get, 'heartbeat'
|
20
|
+
puts nis.request :get, 'status'
|
21
|
+
|
22
|
+
# Nis#request! can raise Error when NIS returns error.
|
23
|
+
puts nis.request! :get, 'account/get', address: 'INVALID_ADDRESS'
|
24
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'nis'
|
2
|
+
require 'pry'
|
3
|
+
_hr = '-' * 64
|
4
|
+
|
5
|
+
# Account A (Source)
|
6
|
+
A_ADDRESS = 'TAH4MBR6MNLZKJAVW5ZJCMFAL7RS5U2YODUQKLCT'.freeze
|
7
|
+
A_PRIVATE_KEY = '00b4a68d16dc505302e9631b860664ba43a8183f0903bc5782a2403b2f9eb3c8a1'.freeze
|
8
|
+
A_PUBLIC_KEY = '5aff2e991f85d44eed8f449ede365a920abbefc22f1a2f731d4a002258673519'.freeze
|
9
|
+
|
10
|
+
# Account B (Dist)
|
11
|
+
B_ADDRESS = 'TAFPFQOTRYEKMKWWKLLLMYA3I5SCFDGYFACCOFWS'.freeze
|
12
|
+
|
13
|
+
# build Transaction Object
|
14
|
+
t = Nis::Struct::Transaction.new(
|
15
|
+
amount: 1_000_000,
|
16
|
+
fee: 1_000_000,
|
17
|
+
recipient: B_ADDRESS,
|
18
|
+
signer: A_PUBLIC_KEY,
|
19
|
+
message: {
|
20
|
+
payload: '',
|
21
|
+
type: 1
|
22
|
+
},
|
23
|
+
type: Nis::Struct::Transaction::TRANSFER,
|
24
|
+
timeStamp: Nis::Util.timestamp,
|
25
|
+
deadline: Nis::Util.timestamp + 43_200,
|
26
|
+
version: Nis::Struct::Transaction::TESTNET_VERSION_1
|
27
|
+
)
|
28
|
+
|
29
|
+
# build RequestPrepareAnnounce Object
|
30
|
+
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
31
|
+
transaction: t,
|
32
|
+
privateKey: A_PRIVATE_KEY
|
33
|
+
)
|
34
|
+
|
35
|
+
# Create NIS instance
|
36
|
+
nis = Nis.new
|
37
|
+
|
38
|
+
# check banalces before sending XEM.
|
39
|
+
puts "Account A => balance: %d" %
|
40
|
+
(nis.account_get address: A_ADDRESS)[:account][:balance]
|
41
|
+
puts "Account B => balance: %d" %
|
42
|
+
(nis.account_get address: B_ADDRESS)[:account][:balance]
|
43
|
+
puts _hr
|
44
|
+
|
45
|
+
# Send XEM request.
|
46
|
+
# res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
47
|
+
# puts res.message
|
48
|
+
|
49
|
+
# After several minutes, check to see Account B received XEM.
|
data/lib/nis/client.rb
CHANGED
@@ -2,6 +2,7 @@ require 'faraday'
|
|
2
2
|
require 'faraday_middleware'
|
3
3
|
require 'json'
|
4
4
|
require 'uri'
|
5
|
+
require 'time'
|
5
6
|
|
6
7
|
# @attr [Hash] options connection options
|
7
8
|
class Nis::Client
|
@@ -30,7 +31,9 @@ class Nis::Client
|
|
30
31
|
# @param [Hash] params API Parameters
|
31
32
|
# @return [Hash] Hash converted API Response
|
32
33
|
def request(method, path, params = {})
|
33
|
-
params.
|
34
|
+
if params.is_a?(Hash) and !params.empty?
|
35
|
+
params.reject! { |_, value| value.nil? }
|
36
|
+
end
|
34
37
|
res = connection.send(method, path, params)
|
35
38
|
body = res.body
|
36
39
|
hash = parse_body(body) unless body.empty?
|
@@ -44,7 +47,7 @@ class Nis::Client
|
|
44
47
|
# @raise [Nis::Error] NIS error
|
45
48
|
def request!(method, path, params = {})
|
46
49
|
hash = request(method, path, params)
|
47
|
-
raise Nis::Util.error_handling(hash) if hash.key?(:error)
|
50
|
+
raise Nis::Util.error_handling(hash) if hash && hash.key?(:error)
|
48
51
|
block_given? ? yield(hash) : hash
|
49
52
|
end
|
50
53
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Account::Generate
|
3
|
+
# @return [Nis::Struct::KeyPairViewModel]
|
4
|
+
# @see http://bob.nem.ninja/docs/#generating-new-account-data
|
5
|
+
def account_generate
|
6
|
+
Nis::Struct::KeyPairViewModel.build request!(:get, '/account/generate')
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Account::Get
|
3
|
+
# @option options [String] address
|
4
|
+
# @return [Nis::Struct::AccountMetaDataPair]
|
5
|
+
# @see http://bob.nem.ninja/docs/#requesting-the-account-data
|
6
|
+
def account_get(address:)
|
7
|
+
request!(:get, '/account/get',
|
8
|
+
address: address
|
9
|
+
) do |res|
|
10
|
+
Nis::Struct::AccountMetaDataPair.build(res)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# @option options [String] public_key
|
15
|
+
# @return [Nis::Struct::AccountMetaDataPair]
|
16
|
+
# @see http://bob.nem.ninja/docs/#requesting-the-account-data
|
17
|
+
def account_get_from_public_key(public_key:)
|
18
|
+
request!(:get, '/account/get/from-public-key',
|
19
|
+
publicKey: public_key
|
20
|
+
) do |res|
|
21
|
+
Nis::Struct::AccountMetaDataPair.build(res)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @option options [String] address
|
26
|
+
# @return [Nis::Struct::AccountMetaDataPair]
|
27
|
+
# @see http://bob.nem.ninja/docs/#requesting-the-original-account-data-for-a-delegate-account
|
28
|
+
def account_get_forwarded(address:)
|
29
|
+
request!(:get, '/account/get/forwarded',
|
30
|
+
address: address
|
31
|
+
) do |res|
|
32
|
+
Nis::Struct::AccountMetaDataPair.build(res)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# @option options [String] public_key
|
37
|
+
# @return [Nis::Struct::AccountMetaDataPair] delegate account
|
38
|
+
# @see http://bob.nem.ninja/docs/#requesting-the-original-account-data-for-a-delegate-account
|
39
|
+
def account_get_forwarded_from_public_key(public_key:)
|
40
|
+
request!(:get, '/account/get/forwarded/from-public-key',
|
41
|
+
publicKey: public_key
|
42
|
+
) do |res|
|
43
|
+
Nis::Struct::AccountMetaDataPair.build(res)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Account::Harvests
|
3
|
+
# @option options [String] address
|
4
|
+
# @option options [String] hash
|
5
|
+
# @return [Array <Nis::Struct::HarvestInfo>]
|
6
|
+
# @see http://bob.nem.ninja/docs/#requesting-harvest-info-data-for-an-account
|
7
|
+
def account_harvests(address:, hash: nil)
|
8
|
+
request!(:get, '/account/harvests',
|
9
|
+
address: address,
|
10
|
+
hash: hash
|
11
|
+
) do |res|
|
12
|
+
res[:data].map{|hvst| Nis::Struct::HarvestInfo.build(hvst) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Account::Historical
|
3
|
+
# @option options [String] address
|
4
|
+
# @option options [Integer] start_height
|
5
|
+
# @option options [Integer] end_height
|
6
|
+
# @option options [Integer] increment
|
7
|
+
# @return [Array <Nis::Struct::AccountHistoricalDataViewModel>]
|
8
|
+
# @see http://bob.nem.ninja/docs/#retrieving-historical-account-data
|
9
|
+
def account_historical_get(address:, start_height:, end_height:, increment:)
|
10
|
+
request!(:get, '/account/historical/get',
|
11
|
+
address: address,
|
12
|
+
startHeight: start_height,
|
13
|
+
endHeight: end_height,
|
14
|
+
increment: increment
|
15
|
+
) do |res|
|
16
|
+
res[:data].map{|ahdvm| Nis::Struct::AccountHistoricalDataViewModel(ahdvm) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Account::Importances
|
3
|
+
# @return [Array <Nis::Struct::AccountImportanceViewModel>]
|
4
|
+
# @see http://bob.nem.ninja/docs/#retrieving-account-importances-for-accounts
|
5
|
+
def account_importances
|
6
|
+
request!(:get, '/account/importances') do |res|
|
7
|
+
res[:data].map { |aivm| Nis::Struct::AccountImportanceViewModel.build(aivm) }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Account::Lock
|
3
|
+
# @option options [String] private_key
|
4
|
+
# @return [nil]
|
5
|
+
# @see http://bob.nem.ninja/docs/#locking-and-unlocking-accounts
|
6
|
+
def account_lock(private_key:)
|
7
|
+
request!(:post, '/account/lock',
|
8
|
+
privateKey: private_key
|
9
|
+
)
|
10
|
+
nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Account::Mosaic
|
3
|
+
# @option options [String] address
|
4
|
+
# @option options [String] parent
|
5
|
+
# @option options [String] id
|
6
|
+
# @return [Array <Nis::Struct::MosaicDefinition>]
|
7
|
+
# @see http://bob.nem.ninja/docs/##retrieving-mosaic-definitions-that-an-account-has-created
|
8
|
+
def account_mosaic_definition_page(address:, parent: nil, id: nil)
|
9
|
+
request!(:get, '/account/mosaic/definition/page',
|
10
|
+
address: address,
|
11
|
+
parent: parent,
|
12
|
+
id: id,
|
13
|
+
) do |res|
|
14
|
+
res[:data].map { |md| Nis::Struct::MosaicDefinition.build(md) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# @option options [String] address
|
19
|
+
# @return [Array <Nis::Struct::AccountMetaDataPair>]
|
20
|
+
# @see http://bob.nem.ninja/docs/#retrieving-mosaics-that-an-account-owns
|
21
|
+
def account_mosaic_owned(address:)
|
22
|
+
request!(:get, '/account/mosaic/owned', address: address) do |res|
|
23
|
+
res[:data].map { |mo| Nis::Struct::Mosaic.build(mo) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Account::Namespace
|
3
|
+
# @option options [String] :address
|
4
|
+
# @option options [String] :parent
|
5
|
+
# @option options [String] :id
|
6
|
+
# @option options [Integer] :page_size
|
7
|
+
# @return [Array <Nis::Struct::Namespace>]
|
8
|
+
# @see http://bob.nem.ninja/docs/#retrieving-namespaces-that-an-account-owns
|
9
|
+
def account_namespace_page(address:, parent: nil, id: nil, page_size: nil)
|
10
|
+
request!(:get, '/account/namespace/page',
|
11
|
+
address: address,
|
12
|
+
parent: parent,
|
13
|
+
id: id,
|
14
|
+
pageSize: page_size
|
15
|
+
) do |res|
|
16
|
+
res[:data].map{|ns| Nis::Struct::Namespace.build(ns) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Account::Status
|
3
|
+
# @option options [String] :address
|
4
|
+
# @return [AccountMetaData]
|
5
|
+
# @see http://bob.nem.ninja/docs/#requesting-the-account-status
|
6
|
+
def account_status(address:)
|
7
|
+
request!(:get, '/account/status',
|
8
|
+
address: address
|
9
|
+
) do |res|
|
10
|
+
Nis::Struct::AccountMetaData.build(res)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Account::Transfers
|
3
|
+
# @option options [String] :address
|
4
|
+
# @option options [String] :hash
|
5
|
+
# @option options [String] :id
|
6
|
+
# @return [Array <Nis::Struct::TransactionMetaDataPair>]
|
7
|
+
# @see http://bob.nem.ninja/docs/#requesting-transaction-data-for-an-account
|
8
|
+
def account_transfers_incoming(address:, hash: nil, id: nil)
|
9
|
+
request!(:get, '/account/transfers/incoming',
|
10
|
+
address: address,
|
11
|
+
hash: hash,
|
12
|
+
id: id
|
13
|
+
) do |res|
|
14
|
+
res[:data].map{|tmdp| Nis::Struct::TransactionMetaDataPair.build(tmdp) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# @option options [String] :address
|
19
|
+
# @option options [String] :hash
|
20
|
+
# @option options [String] :id
|
21
|
+
# @return [Array <Nis::Struct::TransactionMetaDataPair>]
|
22
|
+
# @see http://bob.nem.ninja/docs/#requesting-transaction-data-for-an-account
|
23
|
+
def account_transfers_outgoing(address:, hash: nil, id: nil)
|
24
|
+
request!(:get, '/account/transfers/outgoing',
|
25
|
+
address: address,
|
26
|
+
hash: hash,
|
27
|
+
id: id
|
28
|
+
) do |res|
|
29
|
+
res[:data].map{|tmdp| Nis::Struct::TransactionMetaDataPair.build(tmdp) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# @option options [String] :address
|
34
|
+
# @option options [String] :hash
|
35
|
+
# @option options [String] :id
|
36
|
+
# @return [Array <Nis::Struct::TransactionMetaDataPair>]
|
37
|
+
# @see http://bob.nem.ninja/docs/#requesting-transaction-data-for-an-account
|
38
|
+
def account_transfers_all(address:, hash: nil, id: nil)
|
39
|
+
request!(:get, '/account/transfers/all',
|
40
|
+
address: address,
|
41
|
+
hash: hash,
|
42
|
+
id: id
|
43
|
+
) do |res|
|
44
|
+
res[:data].map{|tmdp| Nis::Struct::TransactionMetaDataPair.build(tmdp) }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Account::UnconfirmedTransactions
|
3
|
+
# @option options [String] address
|
4
|
+
# @return [Array <Nis::Struct::UnconfirmedTransactionMetaDataPair>]
|
5
|
+
# @see http://bob.nem.ninja/docs/#requesting-transaction-data-for-an-account
|
6
|
+
def account_unconfirmed_transactions(address:)
|
7
|
+
request!(:get, '/account/unconfirmedTransactions', address: address) do |res|
|
8
|
+
res[:data].map { |utmdp| Nis::Struct::UnconfirmedTransactionMetaDataPair.build(utmdp) }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Account::Unlock
|
3
|
+
# @option options [String] private_key
|
4
|
+
# @return [nil]
|
5
|
+
# @see http://bob.nem.ninja/docs/#locking-and-unlocking-accounts
|
6
|
+
def account_unlock(private_key:)
|
7
|
+
request!(:post, '/account/lock',
|
8
|
+
privateKey: private_key
|
9
|
+
)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Account::Unlocked
|
3
|
+
# @return [Hash <Symbol: num-unlocked>, <Symbol: max-unlocked>]
|
4
|
+
# @see http://bob.nem.ninja/docs/#retrieving-the-unlock-info
|
5
|
+
def account_unlocked_info
|
6
|
+
request!(:post, '/account/unlocked/info')
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Debug::Connections
|
3
|
+
# @return [Nis::Struct::AuditCollection]
|
4
|
+
# @see http://bob.nem.ninja/docs/#monitoring-incoming-and-outgoing-calls
|
5
|
+
def debug_connections_incoming
|
6
|
+
request!(:get, '/debug/connections/incoming') do |res|
|
7
|
+
Nis::Struct::AuditCollection.build(
|
8
|
+
outstanding: res[:outstanding],
|
9
|
+
most_recent: res[:'most-recent']
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Nis::Struct::AuditCollection]
|
15
|
+
# @see http://bob.nem.ninja/docs/#monitoring-incoming-and-outgoing-calls
|
16
|
+
def debug_connections_outgoing
|
17
|
+
request!(:get, '/debug/connections/outgoing') do |res|
|
18
|
+
Nis::Struct::AuditCollection.build(
|
19
|
+
outstanding: res[:outstanding],
|
20
|
+
most_recent: res[:'most-recent']
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [Array <Nis::Struct::NemAsyncTimerVisitor>]
|
26
|
+
# @see http://bob.nem.ninja/docs/#monitoring-timers
|
27
|
+
def debug_connections_timers
|
28
|
+
request!(:get, '/debug/timers') do |res|
|
29
|
+
res[:data].map { |natv| Nis::Struct::NemAsyncTimerVisitor.build(natv) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Debug::TimeSynchronization
|
3
|
+
# @return [TimeSynchronizationResult]
|
4
|
+
# @see http://bob.nem.ninja/docs/#monitoring-the-network-time
|
5
|
+
def debug_time_synchronization
|
6
|
+
request!(:get, '/debug/time-synchronization') do |res|
|
7
|
+
res[:data].map { |tsr| Nis::Struct::TimeSynchronizationResult.build(tsr) }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Transaction::Announce
|
3
|
+
# @option options [Nis::Struct::RequestAnnounce]
|
4
|
+
# @return [Nis::Struct::NodeInfo]
|
5
|
+
# @see http://bob.nem.ninja/docs/#sending-the-data-to-NIS
|
6
|
+
def transaction_announce(request_announce:)
|
7
|
+
Nis::Struct::NemAnnounceResult.build request!(:post,
|
8
|
+
'/transaction/announce',
|
9
|
+
request_announce
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Transaction::PrepareAnnounce
|
3
|
+
# @option options [Nis::Struct::RequestPrepareAnnounce]
|
4
|
+
# @return [Nis::Struct::NodeInfo]
|
5
|
+
# @see http://bob.nem.ninja/docs/#initiating-a-transaction
|
6
|
+
def transaction_prepare_announce(request_prepare_announce:)
|
7
|
+
Nis::Struct::NemAnnounceResult.build request!(:post,
|
8
|
+
'/transaction/prepare-announce',
|
9
|
+
request_prepare_announce
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Nis::Struct
|
2
|
+
# @attr [Nis::Unit::Address] address
|
3
|
+
# @attr [Float] importance
|
4
|
+
# @attr [Integer] isSet
|
5
|
+
# @attr [Integer] score
|
6
|
+
# @attr [Integer] ev
|
7
|
+
# @attr [Integer] height
|
8
|
+
# @see http://bob.nem.ninja/docs/#accountImportanceViewModel
|
9
|
+
class AccountImportanceViewModel
|
10
|
+
include Nis::Util::Assignable
|
11
|
+
attr_accessor :address, :importance, :isSet, :score, :ev, :height
|
12
|
+
|
13
|
+
alias :is_set :isSet
|
14
|
+
alias :is_set= :isSet=
|
15
|
+
|
16
|
+
def self.build(attrs)
|
17
|
+
attrs[:address] = Nis::Unit::Address.new(attrs[:address])
|
18
|
+
new(attrs)
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Boolean]
|
22
|
+
def set?
|
23
|
+
@is_set == 1
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Nis::Struct
|
2
|
+
# @attr [Nis::Unit::Address] address
|
3
|
+
# @attr [Nis::Unit::Balance] balance
|
4
|
+
# @attr [Nis::Unit::Balance] vestedBalance
|
5
|
+
# @attr [Float] importance
|
6
|
+
# @attr [String] publicKey
|
7
|
+
# @attr [String] label
|
8
|
+
# @attr [Array] harvestedBlocks
|
9
|
+
# @see http://bob.nem.ninja/docs/#accountInfo
|
10
|
+
class AccountInfo
|
11
|
+
include Nis::Util::Assignable
|
12
|
+
attr_accessor :address, :balance, :vestedBalance, :importance, :publicKey, :label, :harvestedBlocks
|
13
|
+
|
14
|
+
alias :vested_balance :vestedBalance
|
15
|
+
alias :vested_balance= :vestedBalance=
|
16
|
+
alias :public_key :publicKey
|
17
|
+
alias :public_key= :publicKey=
|
18
|
+
alias :harvested_blocks :harvestedBlocks
|
19
|
+
alias :harvested_blocks= :harvestedBlocks=
|
20
|
+
|
21
|
+
def self.build(attrs)
|
22
|
+
attrs[:address] = Nis::Unit::Address.new(attrs[:address])
|
23
|
+
attrs[:balance] = Nis::Unit::Balance.new(attrs[:balance])
|
24
|
+
attrs[:vestedBalance] = Nis::Unit::Balance.new(attrs[:vestedBalance])
|
25
|
+
new(attrs)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|