nis-ruby 0.0.18.1 → 0.0.19
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/.travis.yml +7 -0
- data/README.md +4 -4
- data/examples/account/get.rb +5 -14
- data/examples/account/harvests.rb +1 -1
- data/examples/account/historical.rb +1 -1
- data/examples/account/importances.rb +1 -1
- data/examples/account/lock.rb +1 -1
- data/examples/account/mosaic.rb +1 -1
- data/examples/account/namespace.rb +1 -1
- data/examples/account/status.rb +1 -1
- data/examples/account/transfers.rb +1 -1
- data/examples/account/unconfirmed_transactions.rb +1 -1
- data/examples/account/unlock.rb +1 -1
- data/examples/account/unlocked.rb +1 -1
- data/examples/apostille_audit.rb +1 -1
- data/examples/apostille_create.rb +1 -1
- data/examples/block/at_public.rb +2 -0
- data/examples/block/get.rb +2 -0
- data/examples/debug/connections.rb +1 -1
- data/examples/debug/time_synchronization.rb +1 -1
- data/examples/mosaic/supply.rb +6 -0
- data/examples/namespace/mosaic_definition.rb +1 -1
- data/examples/namespace/root.rb +1 -1
- data/examples/nis.rb +1 -1
- data/examples/node/active_peers.rb +1 -1
- data/examples/node/info.rb +1 -1
- data/examples/node/peerlist.rb +1 -1
- data/examples/time_sync/network_time.rb +1 -1
- data/examples/transactions/get.rb +1 -1
- data/examples/transactions/mosaic_definition_creation.rb +1 -0
- data/examples/transactions/multisig.rb +1 -1
- data/examples/transactions/multisig_signature.rb +1 -0
- data/examples/transactions/transfer_remote.rb +1 -1
- data/lib/nis.rb +2 -0
- data/lib/nis/endpoint/account/lock.rb +1 -4
- data/lib/nis/endpoint/account/transfers.rb +16 -8
- data/lib/nis/endpoint/account/unlock.rb +1 -3
- data/lib/nis/endpoint/mosaic.rb +4 -0
- data/lib/nis/endpoint/mosaic/supply.rb +13 -0
- data/lib/nis/struct/message.rb +1 -1
- data/lib/nis/struct/mosaic_supply.rb +14 -0
- data/lib/nis/struct/node.rb +1 -1
- data/lib/nis/util/convert.rb +7 -7
- data/lib/nis/util/deserializer.rb +1 -1
- data/lib/nis/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aff51b55f969bf2101a414a7fc60b831da425458
|
4
|
+
data.tar.gz: b21347efa3caa04f3efb36b7224b40f935bf7eb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87384f3657b1644ea67a0b7f5416087e0037a7c22d45c062147b3d95f5bbdaaa82a254774afc6d9f9547162aff27b50beabc39b394c6d044266df2c5267955cc
|
7
|
+
data.tar.gz: 47d4ba8eb4ed63600015bebe621d1eea5066d46b0d0dde69da59fa0064ea8cfb2db5b50890fd4039a2edf133d1479d82b7de151afb518fab112657c1740a737c
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# /!\ Information /!\
|
2
|
+
|
3
|
+
**Refactored and New gem for nem => [44uk/nem-ruby](https://github.com/44uk/nem-ruby/)**
|
4
|
+
|
1
5
|
# nis-ruby
|
2
6
|
|
3
7
|
[](https://badge.fury.io/rb/nis-ruby)
|
@@ -9,10 +13,6 @@
|
|
9
13
|
|
10
14
|
Ruby client library for the NEM Infrastructure Server(NIS) API.
|
11
15
|
|
12
|
-
*The gem is under development. Incompatible changes can be made.*
|
13
|
-
|
14
|
-
*Not recommended for production use because of lack of testing, needed more improvement.*
|
15
|
-
|
16
16
|
For further development of nem with ruby, [feel free to send me your feedback!](#feedback-and-contact)
|
17
17
|
|
18
18
|
* [NEM \- Distributed Ledger Technology \(Blockchain\)](https://www.nem.io/)
|
data/examples/account/get.rb
CHANGED
@@ -4,23 +4,14 @@ Nis.logger.level = Logger::DEBUG
|
|
4
4
|
A_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'
|
5
5
|
A_PUBLIC_KEY = 'cc63b4dcdec745417043c3fa0992ec3a1695461a26d90264744648abbd5caa0d'
|
6
6
|
|
7
|
-
nis = Nis.new(host: '
|
8
|
-
|
9
|
-
p nis.account_get(address: A_ADDRESS)
|
10
|
-
p nis.account_get_from_public_key(public_key: A_PUBLIC_KEY)
|
11
|
-
|
12
|
-
p nis.account_get_forwarded(address: A_ADDRESS)
|
13
|
-
p nis.account_get_forwarded_from_public_key(public_key: A_PUBLIC_KEY)
|
7
|
+
nis = Nis.new(host: '104.128.226.60')
|
14
8
|
|
15
9
|
# /account/get?address={address}
|
16
10
|
# -> account_get address: {address}
|
17
|
-
|
18
|
-
|
19
|
-
account = account_meta_pair[:account]
|
20
|
-
p account.balance
|
11
|
+
p nis.account_get(address: A_ADDRESS)
|
12
|
+
p nis.account_get_from_public_key(public_key: A_PUBLIC_KEY)
|
21
13
|
|
22
14
|
# /account/get/from-public-key?public-key={key}
|
23
15
|
# -> account_get_public_key public_key: {key}
|
24
|
-
|
25
|
-
|
26
|
-
p account.address
|
16
|
+
p nis.account_get_forwarded(address: A_ADDRESS)
|
17
|
+
p nis.account_get_forwarded_from_public_key(public_key: A_PUBLIC_KEY)
|
data/examples/account/lock.rb
CHANGED
data/examples/account/mosaic.rb
CHANGED
@@ -3,7 +3,7 @@ Nis.logger.level = Logger::DEBUG
|
|
3
3
|
|
4
4
|
A_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'
|
5
5
|
|
6
|
-
nis = Nis.new(host: '
|
6
|
+
nis = Nis.new(host: '104.128.226.60')
|
7
7
|
|
8
8
|
p nis.account_mosaic_definition_page(address: A_ADDRESS)
|
9
9
|
p nis.account_mosaic_owned(address: A_ADDRESS)
|
data/examples/account/status.rb
CHANGED
data/examples/account/unlock.rb
CHANGED
data/examples/apostille_audit.rb
CHANGED
data/examples/block/at_public.rb
CHANGED
data/examples/block/get.rb
CHANGED
data/examples/namespace/root.rb
CHANGED
data/examples/nis.rb
CHANGED
@@ -4,7 +4,7 @@ Nis.logger.level = Logger::DEBUG
|
|
4
4
|
# Create NIS instance.
|
5
5
|
# By default, connect to local NIS.
|
6
6
|
# You also can connect to remote.
|
7
|
-
nis = Nis.new(host: '
|
7
|
+
nis = Nis.new(host: '104.128.226.60')
|
8
8
|
|
9
9
|
# API path /heartbeat, /status are mapped into methods.
|
10
10
|
# It returns Nis::Struct::NemRequestResult object.
|
data/examples/node/info.rb
CHANGED
data/examples/node/peerlist.rb
CHANGED
@@ -5,6 +5,7 @@ nis = Nis.new
|
|
5
5
|
|
6
6
|
# mosaic creator
|
7
7
|
A_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'
|
8
|
+
A_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'
|
8
9
|
A_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'
|
9
10
|
|
10
11
|
kp = Nis::Keypair.new(A_PRIVATE_KEY)
|
@@ -4,7 +4,7 @@ Nis.logger.level = Logger::DEBUG
|
|
4
4
|
nis = Nis.new
|
5
5
|
|
6
6
|
# multisig
|
7
|
-
M_PUBLIC_KEY = '
|
7
|
+
M_PUBLIC_KEY = '6d72b57d2bc199d328e7ea3e24775f7f614760bc18f3f8501cd3daa9870cc40c'
|
8
8
|
|
9
9
|
# cosignatory
|
10
10
|
A_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'
|
@@ -14,6 +14,7 @@ M_ADDRESS = 'TDJNDAQ7F7AQRXKP2YVTH67QYCWWKE6QLSJFWN64'
|
|
14
14
|
|
15
15
|
# cosignatory2
|
16
16
|
B_PRIVATE_KEY = '1d13af2c31ee6fb0c3c7aaaea818d9b305dcadba130ba663fc42d9f25b24ded1'
|
17
|
+
B_PUBLIC_KEY = '9e7ab2924cd1a3482df784db190614cfc8a33671f5d80a5b15a9c9e8b4d13933'
|
17
18
|
B_ADDRESS = 'TA4TX6U5HG2MROAESH2JE5524T4ZOY2EQKQ6ELHF'
|
18
19
|
|
19
20
|
kp = Nis::Keypair.new(B_PRIVATE_KEY)
|
data/lib/nis.rb
CHANGED
@@ -4,10 +4,7 @@ module Nis::Endpoint
|
|
4
4
|
# @return [nil]
|
5
5
|
# @see https://nemproject.github.io/#locking-and-unlocking-accounts
|
6
6
|
def account_lock(private_key:)
|
7
|
-
request!(:post, '/account/lock',
|
8
|
-
privateKey: private_key
|
9
|
-
)
|
10
|
-
nil
|
7
|
+
request!(:post, '/account/lock', value: private_key)
|
11
8
|
end
|
12
9
|
end
|
13
10
|
end
|
@@ -3,13 +3,15 @@ module Nis::Endpoint
|
|
3
3
|
# @param [String] address
|
4
4
|
# @param [String] hash
|
5
5
|
# @param [String] id
|
6
|
+
# @param [Integer] page_size
|
6
7
|
# @return [Array <Nis::Struct::TransactionMetaDataPair>]
|
7
8
|
# @see https://nemproject.github.io/#requesting-transaction-data-for-an-account
|
8
|
-
def account_transfers_incoming(address:, hash: nil, id: nil)
|
9
|
+
def account_transfers_incoming(address:, hash: nil, id: nil, page_size: nil)
|
9
10
|
request!(:get, '/account/transfers/incoming',
|
10
11
|
address: address,
|
11
12
|
hash: hash,
|
12
|
-
id: id
|
13
|
+
id: id,
|
14
|
+
pageSize: page_size
|
13
15
|
) do |res|
|
14
16
|
res[:data].map { |tmdp| Nis::Struct::TransactionMetaDataPair.build(tmdp) }
|
15
17
|
end
|
@@ -18,13 +20,15 @@ module Nis::Endpoint
|
|
18
20
|
# @param [String] address
|
19
21
|
# @param [String] hash
|
20
22
|
# @param [String] id
|
23
|
+
# @param [Integer] page_size
|
21
24
|
# @return [Array <Nis::Struct::TransactionMetaDataPair>]
|
22
25
|
# @see https://nemproject.github.io/#requesting-transaction-data-for-an-account
|
23
|
-
def account_transfers_outgoing(address:, hash: nil, id: nil)
|
26
|
+
def account_transfers_outgoing(address:, hash: nil, id: nil, page_size: nil)
|
24
27
|
request!(:get, '/account/transfers/outgoing',
|
25
28
|
address: address,
|
26
29
|
hash: hash,
|
27
|
-
id: id
|
30
|
+
id: id,
|
31
|
+
pageSize: page_size
|
28
32
|
) do |res|
|
29
33
|
res[:data].map { |tmdp| Nis::Struct::TransactionMetaDataPair.build(tmdp) }
|
30
34
|
end
|
@@ -33,13 +37,15 @@ module Nis::Endpoint
|
|
33
37
|
# @param [String] address
|
34
38
|
# @param [String] hash
|
35
39
|
# @param [String] id
|
40
|
+
# @param [Integer] page_size
|
36
41
|
# @return [Array <Nis::Struct::TransactionMetaDataPair>]
|
37
42
|
# @see https://nemproject.github.io/#requesting-transaction-data-for-an-account
|
38
|
-
def account_transfers_all(address:, hash: nil, id: nil)
|
43
|
+
def account_transfers_all(address:, hash: nil, id: nil, page_size: nil)
|
39
44
|
request!(:get, '/account/transfers/all',
|
40
45
|
address: address,
|
41
46
|
hash: hash,
|
42
|
-
id: id
|
47
|
+
id: id,
|
48
|
+
pageSize: page_size
|
43
49
|
) do |res|
|
44
50
|
res[:data].map { |tmdp| Nis::Struct::TransactionMetaDataPair.build(tmdp) }
|
45
51
|
end
|
@@ -49,13 +55,15 @@ module Nis::Endpoint
|
|
49
55
|
# @param [String] address
|
50
56
|
# @param [String] hash
|
51
57
|
# @param [String] id
|
58
|
+
# @param [Integer] page_size
|
52
59
|
# @return [Array <Nis::Struct::TransactionMetaDataPair>]
|
53
60
|
# @see https://nemproject.github.io/#requesting-transaction-data-for-an-account
|
54
|
-
def account_transfers(dir = :all, address:, hash: nil, id: nil)
|
61
|
+
def account_transfers(dir = :all, address:, hash: nil, id: nil, page_size: nil)
|
55
62
|
request!(:get, "/account/transfers/#{account_transfers_direction(dir)}",
|
56
63
|
address: address,
|
57
64
|
hash: hash,
|
58
|
-
id: id
|
65
|
+
id: id,
|
66
|
+
pageSize: page_size
|
59
67
|
) do |res|
|
60
68
|
res[:data].map { |tmdp| Nis::Struct::TransactionMetaDataPair.build(tmdp) }
|
61
69
|
end
|
@@ -4,9 +4,7 @@ module Nis::Endpoint
|
|
4
4
|
# @return [nil]
|
5
5
|
# @see https://nemproject.github.io/#locking-and-unlocking-accounts
|
6
6
|
def account_unlock(private_key:)
|
7
|
-
request!(:post, '/account/
|
8
|
-
privateKey: private_key
|
9
|
-
)
|
7
|
+
request!(:post, '/account/unlock', value: private_key)
|
10
8
|
end
|
11
9
|
end
|
12
10
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Nis::Endpoint
|
2
|
+
module Mosaic::Supply
|
3
|
+
# @return <Nis::Struct::MosaicSupply
|
4
|
+
# @see https://nemproject.github.io/#
|
5
|
+
def mosaic_supply(mosaic_id:)
|
6
|
+
request!(:get, '/mosaic/supply',
|
7
|
+
mosaicId: mosaic_id,
|
8
|
+
) do |res|
|
9
|
+
Nis::Struct::MosaicSupply.build(res)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/nis/struct/message.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
class Nis::Struct
|
2
|
+
# @attr [Nis::Struct::MosaicId] id
|
3
|
+
# @attr [Integer] supply
|
4
|
+
# @see https://nemproject.github.io/#
|
5
|
+
class MosaicSupply
|
6
|
+
include Nis::Util::Assignable
|
7
|
+
attr_accessor :mosaicId, :supply
|
8
|
+
|
9
|
+
def self.build(attrs)
|
10
|
+
attrs[:mosaicId] = MosaicId.build(attrs[:mosaicId])
|
11
|
+
new(attrs)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/nis/struct/node.rb
CHANGED
data/lib/nis/util/convert.rb
CHANGED
@@ -48,6 +48,13 @@ module Nis::Util
|
|
48
48
|
rstr2utf8(str).bytes.inject('') { |memo, b| memo << b.to_s(16) }
|
49
49
|
end
|
50
50
|
|
51
|
+
# Convert hex to UTF-8
|
52
|
+
# @param [string] str
|
53
|
+
# @return [string]
|
54
|
+
def self.hex_to_utf8(hex_str)
|
55
|
+
[hex_str].pack('H*').force_encoding('UTF-8')
|
56
|
+
end
|
57
|
+
|
51
58
|
# Convert an Array to hex
|
52
59
|
# @param [Array] ua - An Uint8Array
|
53
60
|
# @return [string]
|
@@ -85,8 +92,6 @@ module Nis::Util
|
|
85
92
|
end
|
86
93
|
end
|
87
94
|
|
88
|
-
# Converts a raw javascript string into a string of single byte characters using utf8 encoding.
|
89
|
-
# This makes it easier to perform other encoding operations on the string.
|
90
95
|
# @param [String] str
|
91
96
|
# @return [String]
|
92
97
|
def self.rstr2utf8(str)
|
@@ -101,10 +106,5 @@ module Nis::Util
|
|
101
106
|
end
|
102
107
|
end
|
103
108
|
end
|
104
|
-
|
105
|
-
# Does the reverse of rstr2utf8.
|
106
|
-
def utf82rstr(input)
|
107
|
-
raise 'Not implemented.'
|
108
|
-
end
|
109
109
|
end
|
110
110
|
end
|
@@ -37,7 +37,7 @@ module Nis::Util
|
|
37
37
|
# s[60, 4] # length of payload
|
38
38
|
tx[:message] = {
|
39
39
|
type: deserialize_int(s[56, 4]),
|
40
|
-
payload: deserialize_hex(s[64, s.size])
|
40
|
+
payload: Nis::Util::Convert.hex_to_utf8(deserialize_hex(s[64, s.size]))
|
41
41
|
}
|
42
42
|
else
|
43
43
|
tx[:message] = { type: 1, payload: '' }
|
data/lib/nis/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.19
|
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-
|
11
|
+
date: 2017-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- examples/debug/time_synchronization.rb
|
202
202
|
- examples/local/account_transfers.rb
|
203
203
|
- examples/local/chain_blocks_after.rb
|
204
|
+
- examples/mosaic/supply.rb
|
204
205
|
- examples/namespace/mosaic_definition.rb
|
205
206
|
- examples/namespace/root.rb
|
206
207
|
- examples/nis.rb
|
@@ -254,6 +255,8 @@ files:
|
|
254
255
|
- lib/nis/endpoint/heartbeat.rb
|
255
256
|
- lib/nis/endpoint/local/account/transfers.rb
|
256
257
|
- lib/nis/endpoint/local/chain.rb
|
258
|
+
- lib/nis/endpoint/mosaic.rb
|
259
|
+
- lib/nis/endpoint/mosaic/supply.rb
|
257
260
|
- lib/nis/endpoint/namespace.rb
|
258
261
|
- lib/nis/endpoint/namespace/mosaic.rb
|
259
262
|
- lib/nis/endpoint/namespace/root.rb
|
@@ -318,6 +321,7 @@ files:
|
|
318
321
|
- lib/nis/struct/mosaic_id.rb
|
319
322
|
- lib/nis/struct/mosaic_levy.rb
|
320
323
|
- lib/nis/struct/mosaic_properties.rb
|
324
|
+
- lib/nis/struct/mosaic_supply.rb
|
321
325
|
- lib/nis/struct/mosaic_supply_change_transaction.rb
|
322
326
|
- lib/nis/struct/multisig_aggregate_modification_transaction.rb
|
323
327
|
- lib/nis/struct/multisig_cosignatory_modification.rb
|
@@ -393,7 +397,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
393
397
|
version: '0'
|
394
398
|
requirements: []
|
395
399
|
rubyforge_project:
|
396
|
-
rubygems_version: 2.6.
|
400
|
+
rubygems_version: 2.6.8
|
397
401
|
signing_key:
|
398
402
|
specification_version: 4
|
399
403
|
summary: Ruby client library for the NEM Infrastructure Server API
|