nem-ruby 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e104168b1b964bfe7781e60bd856c8c47810d49f58620423c297298f7bcd0155
4
- data.tar.gz: 25a00eaf0970adb06568c3334a94be759983113ff9cc02d43503eac8a593e954
3
+ metadata.gz: ecc626aa901b8ebab5b35db375fb920ac1a66a9feb2193d79ff34d35eef37904
4
+ data.tar.gz: 6aa07a4ba05b0757c8e78a25abecbbb3169a726eecabeeb86ac047c8a4de7d75
5
5
  SHA512:
6
- metadata.gz: 229d81f04786aa310945ffd53a503786d7bf4f02b2551055ed24f751b64a923ede6377a092fcfe7508347ccff8c23e349fc92f8ff786bb42539c1851c174ba98
7
- data.tar.gz: e3fb15751022dd9a99eeb3288544b91607711653b57a57487b6fab6f6de9dfa618e1d640b99dd872ca0340a89de0256dbc6ae89b7ac666d1d739f902cd0ed1da
6
+ metadata.gz: a051321b5579cee745c6922530f07e0fb30431401e6957a7f56bf598403aa6f9131652d1d04d8cd37172980ed1c416f337b77654b6a36795224a1d66b0811568
7
+ data.tar.gz: 7946079fc07bb27eaa1631562fb3a444fd94423a35ba9a3e9e1655f23583bf482a4f819c28240f5f55bfde39b6128492384e52a74e8e07be7231922b01c30ec2
data/.gitignore CHANGED
@@ -5,6 +5,7 @@
5
5
  /coverage/
6
6
  /doc/
7
7
  /pkg/
8
+ /site/
8
9
  /spec/reports/
9
10
  /tmp/
10
11
 
data/docs/about.md ADDED
@@ -0,0 +1,30 @@
1
+ ## Feedback and Contact
2
+
3
+ For further development of nem with ruby, feel free to send me your feedback, feature requests, bug reports!
4
+
5
+ * [44uk/nem-ruby - gitter](https://gitter.im/44uk/nem-ruby)
6
+ * [@44uk_i3 - Twitter](https://twitter.com/44uk_i3)
7
+
8
+ and I would be glad if you could let me know any project using the gem!
9
+
10
+ ## Donation
11
+
12
+ The project gratefully accepts donations via nem:xem.
13
+
14
+ ```text
15
+ NCPBJTNKHODIGPDMPKPETJK6YLMUPAW7ISBIQGUP
16
+ ```
17
+
18
+ ## Thanks
19
+
20
+ - [NEM \- Distributed Ledger Technology \(Blockchain\)](https://www.nem.io/)
21
+ - [NEM NIS API Documentation](https://nemproject.github.io/)
22
+ - [NEM Forum](https://forum.nem.io/)
23
+
24
+ ## Contributing
25
+
26
+ Bug reports and pull requests are welcome on GitHub at [44uk/nem-ruby](https://github.com/44uk/nem-ruby). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
27
+
28
+ ## License
29
+
30
+ The gem is available as open source under the terms of the [MIT License](https://github.com/44uk/nem-ruby/blob/master/LICENSE).
data/docs/custom.css ADDED
@@ -0,0 +1,3 @@
1
+ .wy-side-nav-search, .wy-nav-top {
2
+ background-color: #cc342d;
3
+ }
@@ -0,0 +1,104 @@
1
+ ## Endpoint
2
+
3
+ ```ruby
4
+ node = Nem::Node.new(host: 'bigalice2.nem.ninja')
5
+ endpoint = Nem::Endpoint::Account.new(node)
6
+ ```
7
+
8
+ ## Find Address
9
+
10
+ ```ruby
11
+ # find by address
12
+ pp endpoint.find('TBULEAUG2CZQISUR442HWA6UAKGWIXHDABJVIPS4')
13
+
14
+ # alias
15
+ pp endpoint.get('TBULEAUG2CZQISUR442HWA6UAKGWIXHDABJVIPS4')
16
+
17
+ # find by public key
18
+ pp endpoint.find_by_public_key('e59ef184a612d4c3c4d89b5950eb57262c69862b2f96e59c5043bf41765c482f')
19
+
20
+ # find forwarded by address
21
+ pp endpoint.find_forwarded('TBULEAUG2CZQISUR442HWA6UAKGWIXHDABJVIPS4')
22
+
23
+ # find forwarded by public key
24
+ pp endpoint.find_forwarded_by_public_key('e59ef184a612d4c3c4d89b5950eb57262c69862b2f96e59c5043bf41765c482f')
25
+ ```
26
+
27
+ ## Hervests
28
+
29
+ ```ruby
30
+ pp endpoint.harvests('TBULEAUG2CZQISUR442HWA6UAKGWIXHDABJVIPS4')
31
+ ```
32
+
33
+ ## Namespace / Mosaics
34
+
35
+ ```ruby
36
+ # namespace
37
+ pp endpoint.namespace('TDPICOQ7GIEMIDJOOMIQSOYIJKG3C7V7OP2DUFIR')
38
+
39
+ # fetch mosaic definition of account
40
+ pp endpoint.mosaic_definition('TDPICOQ7GIEMIDJOOMIQSOYIJKG3C7V7OP2DUFIR')
41
+
42
+ # fetch owned mosaics of account
43
+ mosaics = account_endpoint.mosaic_owned('TDPICOQ7GIEMIDJOOMIQSOYIJKG3C7V7OP2DUFIR')
44
+ pp mosaics
45
+
46
+ ## can find by namespace
47
+ pp mosaics.find_by_namespace_id('tpico')
48
+
49
+ ## can find by fqn
50
+ pp mosaics.find_by_fqn('tpico:test')
51
+ ```
52
+
53
+ ## Transactions
54
+
55
+ ```ruby
56
+ ## incomings
57
+ pp endpoint.transfers_incoming('TBULEAUG2CZQISUR442HWA6UAKGWIXHDABJVIPS4')
58
+
59
+ ## outgoings
60
+ pp endpoint.transfers_outgoing('TBULEAUG2CZQISUR442HWA6UAKGWIXHDABJVIPS4')
61
+
62
+ ## all
63
+ pp endpoint.transfers_all('TBULEAUG2CZQISUR442HWA6UAKGWIXHDABJVIPS4')
64
+
65
+ ## unconfirmed
66
+ pp endpoint.transfers_unconfirmed('TBULEAUG2CZQISUR442HWA6UAKGWIXHDABJVIPS4')
67
+ ```
68
+
69
+ ## Status
70
+
71
+ ```ruby
72
+ pp endpoint.status('TDJNDAQ7F7AQRXKP2YVTH67QYCWWKE6QLSJFWN64')
73
+ ```
74
+
75
+ ## Unlocked
76
+
77
+ ```ruby
78
+ pp endpoint.unlocked_info
79
+ ```
80
+
81
+ ## Historical
82
+
83
+ ```ruby
84
+ pp endpoint.historical('TDWWYDGQNBKSAJBSHZX7QWVX7WNVAWWB7HGPWRB2',
85
+ start_height: 1245390,
86
+ end_height: 1245400,
87
+ increment: 1
88
+ )
89
+ ```
90
+
91
+ ## Generate Account / Lock, Unlock
92
+
93
+ The APIs allowed only Local NIS.
94
+
95
+ ```ruby
96
+ ## generate account
97
+ pp endpoint.generate
98
+
99
+ ## lock account
100
+ pp endpoint.lock('__private_key__')
101
+
102
+ ## unlock account
103
+ pp endpoint.unlock('__private_key__')
104
+ ```
@@ -0,0 +1,58 @@
1
+ ## Public Apostille
2
+
3
+ ### Create
4
+
5
+ ```ruby
6
+ require 'pp'
7
+ require 'nem'
8
+
9
+ FIXTURES_PATH = File.expand_path('../../spec/fixtures', __FILE__)
10
+
11
+ # sender
12
+ A_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'
13
+
14
+ kp = Nem::Keypair.new(A_PRIVATE_KEY)
15
+ node = Nem::Node.new(host: 'bigalice2.nem.ninja')
16
+ tx_endpoint = Nem::Endpoint::Transaction.new(node)
17
+
18
+ file = File.open("#{FIXTURES_PATH}/nemLogoV2.png")
19
+ apo = Nem::Apostille.new(kp, file, :sha1,
20
+ multisig: false,
21
+ signed: false,
22
+ network: :testnet
23
+ )
24
+ tx = apo.transaction
25
+ pp "Fee: #{tx.fee.to_i}"
26
+
27
+ req = Nem::Request::Announce.new(tx, kp)
28
+ res = tx_endpoint.announce(req)
29
+
30
+ pp "Message: #{res.message}"
31
+ pp "TransactionHash: #{res.transaction_hash}"
32
+ pp "ApostilleFormat: #{apo.apostille_format(res.transaction_hash)}"
33
+
34
+ FileUtils.cp(file.path, apo.apostille_format(res.transaction_hash))
35
+ ```
36
+
37
+ ### Audit
38
+
39
+ ```ruby
40
+ require 'pp'
41
+ require 'nem'
42
+
43
+ node = Nem::Node.new(host: 'bigalice2.nem.ninja')
44
+ tx_endpoint = Nem::Endpoint::Transaction.new(node)
45
+
46
+ # transaction hash from Filename
47
+ tx_hash = 'c035c2603356852687c4730fbc6f8d21da3af7c4c0eb8b3619bc9ecdc833255a'
48
+ tx = tx_endpoint.find(tx_hash)
49
+
50
+ # NOTE: it may return "Hash was not found in cache"
51
+ # because of NIS not supporting caching transactions.
52
+ # 'fe4e545902cde315617a435ebfd5fe8875d699e2f2363262f5'
53
+ apostille_hash = tx.message.payload
54
+ file = File.open("#{FIXTURES_PATH}/nemLogoV2 -- Apostille TX c035c2603356852687c4730fbc6f8d21da3af7c4c0eb8b3619bc9ecdc833255a -- Date 2017-12-18.png")
55
+
56
+ apa = Nem::ApostilleAudit.new(file, apostille_hash)
57
+ pp apa.valid? ? 'OK, Valid Apostille!' : 'Bad, Invalid Apostille!'
58
+ ```
@@ -0,0 +1,12 @@
1
+ ## Endpoint
2
+
3
+ ```ruby
4
+ node = Nem::Node.new(host: 'bigalice2.nem.ninja')
5
+ endpoint = Nem::Endpoint::Account.new(node)
6
+ ```
7
+
8
+ ## at public
9
+
10
+ ```ruby
11
+ pp endpoint.at_public(1_223_559)
12
+ ```
@@ -0,0 +1,24 @@
1
+ ## Endpoint
2
+
3
+ ```ruby
4
+ node = Nem::Node.new(host: 'bigalice2.nem.ninja')
5
+ endpoint = Nem::Endpoint::Chain.new(node)
6
+ ```
7
+
8
+ ## height
9
+
10
+ ```ruby
11
+ pp endpoint.height
12
+ ```
13
+
14
+ ## score
15
+
16
+ ```ruby
17
+ pp endpoint.score
18
+ ```
19
+
20
+ ## last block
21
+
22
+ ```ruby
23
+ pp endpoint.last_block
24
+ ```
@@ -0,0 +1,20 @@
1
+ ## Configuration
2
+
3
+ ```ruby
4
+ Nem.configure do |conf|
5
+ # output path
6
+ conf.logger = Logger.new('./nem-ruby.log')
7
+
8
+ # logger level
9
+ conf.logger.level = Logger::DEBUG
10
+
11
+ # output debug log
12
+ conf.debug = true
13
+
14
+ # deadline(sec)
15
+ conf.default_deadline = 7200
16
+
17
+ # :mainnet if you'd like to use on mainnet!
18
+ conf.default_network = :mainnet
19
+ end
20
+ ```
@@ -0,0 +1,25 @@
1
+ ## Endpoint
2
+
3
+ ```ruby
4
+ node = Nem::Node.new(host: 'bigalice2.nem.ninja')
5
+ endpoint = Nem::Endpoint::Debug.new(node)
6
+ ```
7
+
8
+ ## connections
9
+
10
+ ```ruby
11
+ # mapped methods
12
+ pp endpoint.connections_incoming
13
+ pp endpoint.connections_outgoing
14
+ pp endpoint.connections_timers
15
+
16
+ # another way
17
+ pp endpoint.debug_connections(:in)
18
+ pp endpoint.debug_connections(:out)
19
+ ```
20
+
21
+ ## time synchronization
22
+
23
+ ```ruby
24
+ pp endpoint.time_synchronization
25
+ ```
@@ -0,0 +1,10 @@
1
+ ## Mosaic attachment definition
2
+
3
+ ```ruby
4
+ class MyMosaic < Nem::Mosaic::Base
5
+ namespace_id 'my'
6
+ name 'moz'
7
+ divisibility 3
8
+ initial_supply 1_234_567_890
9
+ end
10
+ ```
@@ -0,0 +1,28 @@
1
+ ## Endpoint
2
+
3
+ ```ruby
4
+ node = Nem::Node.new
5
+ endpoint = Nem::Endpoint::Local.new(node)
6
+ ```
7
+
8
+ ## account transfers
9
+
10
+ ```ruby
11
+ value = '00b4a68d16dc505302e9631b860664ba43a8183f0903bc5782a2403b2f9eb3c8a1'
12
+
13
+ # mapped methods
14
+ pp endpoint.transfers_incoming(value)
15
+ pp endpoint.transfers_outgoing(value)
16
+ pp endpoint.transfers_all(value)
17
+
18
+ # another way
19
+ pp endpoint.transfers(value, :in)
20
+ pp endpoint.transfers(value, :out)
21
+ pp endpoint.transfers(value, :all)
22
+ ```
23
+
24
+ ##chain blocks after
25
+
26
+ ```ruby
27
+ pp endpoint.blocks_after(1_223_559)
28
+ ```
@@ -0,0 +1,12 @@
1
+ ## Endpoint
2
+
3
+ ```ruby
4
+ node = Nem::Node.new
5
+ endpoint = Nem::Endpoint::Mosaic.new(node)
6
+ ```
7
+
8
+ ## supply
9
+
10
+ ```ruby
11
+ pp mo_endpoint.supply('nembar:vip')
12
+ ```
@@ -0,0 +1,25 @@
1
+ ## Endpoint
2
+
3
+ ```ruby
4
+ node = Nem::Node.new(host: 'bigalice2.nem.ninja')
5
+ endpoint = Nem::Endpoint::Namespace.new(node)
6
+ ```
7
+
8
+ ## find
9
+
10
+ ```ruby
11
+ pp ns_endpoint.find('alice')
12
+ ```
13
+
14
+
15
+ ## root
16
+
17
+ ```ruby
18
+ pp ns_endpoint.root(882, page_size: 1)
19
+ ```
20
+
21
+ ## mosaic definition page
22
+
23
+ ```ruby
24
+ pp ns_endpoint.mosaic_definition('tpico')
25
+ ```
@@ -0,0 +1,23 @@
1
+ ## Node
2
+
3
+ ```ruby
4
+ node = Nem::Node.new(host: 'bigalice2.nem.ninja')
5
+ ```
6
+
7
+ ## heartbeat
8
+
9
+ ```ruby
10
+ pp node.heartbeat
11
+
12
+ # passing API Path
13
+ pp node.request :get, 'heartbeat'
14
+ ```
15
+
16
+ ## status
17
+
18
+ ```ruby
19
+ pp node.status
20
+
21
+ # passing API Path
22
+ pp node.request :get, 'status'
23
+ ```
@@ -0,0 +1,61 @@
1
+ ## Endpoint
2
+
3
+ ```ruby
4
+ node = Nem::Node.new(host: 'bigalice2.nem.ninja')
5
+ endpoint = Nem::Endpoint::Node.new(node)
6
+ ```
7
+
8
+ ## Info
9
+
10
+ ```ruby
11
+ pp endpoint.node_info
12
+ pp endpoint.node_extended_info
13
+ pp endpoint.node_experiences
14
+ ```
15
+
16
+ ## Peerlist
17
+
18
+ ```ruby
19
+ # mapped methods
20
+ pp endpoint.node_peerlist_all
21
+ pp endpoint.node_peerlist_reachable
22
+ pp endpoint.node_peerlist_active
23
+
24
+ # another way
25
+ pp endpoint.node_peerlist(:all)
26
+ pp endpoint.node_peerlist(:reachable)
27
+ pp endpoint.node_peerlist(:active)
28
+ ```
29
+
30
+ ## Active peers max chain height
31
+
32
+ ```ruby
33
+ endpoint = node_endpoint = Nem::Endpoint::Node.new(Nem::Node.new)
34
+
35
+ pp endpoint.node_active_peers_max_chain_height
36
+ ```
37
+
38
+ ## Boot node request
39
+
40
+ ```ruby
41
+ bnr = Nis::Struct::BootNodeRequest.new(
42
+ metaData: {
43
+ application: 'NIS'
44
+ },
45
+ endpoint: {
46
+ protocol: 'http',
47
+ port: 7890,
48
+ host: 'localhost'
49
+ },
50
+ identity: {
51
+ 'private-key': 'a6cbd01d04edecfaef51df9486c111abb6299c764a00206eb1d01f4587491b3f',
52
+ name: 'Alice'
53
+ }
54
+ )
55
+
56
+ begin
57
+ pp endpoint.node_boot(boot_node_request: bnr)
58
+ rescue => ex
59
+ pp ex
60
+ end
61
+ ```