nis-ruby 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/README.md +12 -9
  4. data/examples/transactions/importance_transfer.rb +1 -4
  5. data/examples/transactions/mosaic_definition_creation.rb +1 -4
  6. data/examples/transactions/mosaic_supply_change.rb +1 -4
  7. data/examples/transactions/multisig.rb +1 -6
  8. data/examples/transactions/multisig_add_cosignatory.rb +1 -4
  9. data/examples/transactions/multisig_aggregate_modification.rb +1 -4
  10. data/examples/transactions/multisig_signature.rb +2 -5
  11. data/examples/transactions/provision_namespace.rb +1 -4
  12. data/examples/transactions/transfer.rb +1 -4
  13. data/examples/transactions/transfer_remote.rb +19 -0
  14. data/lib/nis/endpoint/account/generate.rb +1 -1
  15. data/lib/nis/endpoint/account/get.rb +4 -4
  16. data/lib/nis/endpoint/account/harvests.rb +1 -1
  17. data/lib/nis/endpoint/account/historical.rb +1 -1
  18. data/lib/nis/endpoint/account/importances.rb +1 -1
  19. data/lib/nis/endpoint/account/lock.rb +1 -1
  20. data/lib/nis/endpoint/account/mosaic.rb +2 -2
  21. data/lib/nis/endpoint/account/namespace.rb +1 -1
  22. data/lib/nis/endpoint/account/status.rb +1 -1
  23. data/lib/nis/endpoint/account/transfers.rb +3 -3
  24. data/lib/nis/endpoint/account/unconfirmed_transactions.rb +1 -1
  25. data/lib/nis/endpoint/account/unlock.rb +1 -1
  26. data/lib/nis/endpoint/account/unlocked.rb +1 -1
  27. data/lib/nis/endpoint/block/at.rb +1 -1
  28. data/lib/nis/endpoint/block/get.rb +1 -1
  29. data/lib/nis/endpoint/chain/height.rb +1 -1
  30. data/lib/nis/endpoint/chain/last_block.rb +1 -1
  31. data/lib/nis/endpoint/chain/score.rb +1 -1
  32. data/lib/nis/endpoint/debug/connections.rb +3 -3
  33. data/lib/nis/endpoint/debug/time_synchronization.rb +1 -1
  34. data/lib/nis/endpoint/heartbeat.rb +1 -1
  35. data/lib/nis/endpoint/local/account/transfers.rb +3 -3
  36. data/lib/nis/endpoint/local/chain.rb +1 -1
  37. data/lib/nis/endpoint/namespace.rb +1 -1
  38. data/lib/nis/endpoint/namespace/mosaic.rb +1 -1
  39. data/lib/nis/endpoint/namespace/root.rb +1 -1
  40. data/lib/nis/endpoint/node/active_peers.rb +1 -1
  41. data/lib/nis/endpoint/node/boot.rb +1 -1
  42. data/lib/nis/endpoint/node/experiences.rb +1 -1
  43. data/lib/nis/endpoint/node/extended_info.rb +1 -1
  44. data/lib/nis/endpoint/node/info.rb +1 -1
  45. data/lib/nis/endpoint/node/peer_list.rb +3 -3
  46. data/lib/nis/endpoint/status.rb +1 -1
  47. data/lib/nis/endpoint/transaction/announce.rb +4 -4
  48. data/lib/nis/endpoint/transaction/prepareAnnounce.rb +4 -4
  49. data/lib/nis/keypair.rb +13 -3
  50. data/lib/nis/request/announce.rb +47 -2
  51. data/lib/nis/request/prepare_announce.rb +1 -1
  52. data/lib/nis/struct/account_importance_view_model.rb +1 -1
  53. data/lib/nis/struct/account_info.rb +1 -1
  54. data/lib/nis/struct/account_meta_data.rb +1 -1
  55. data/lib/nis/struct/account_meta_data_pair.rb +1 -1
  56. data/lib/nis/struct/account_private_key_transactions_page.rb +1 -1
  57. data/lib/nis/struct/application_meta_data.rb +1 -1
  58. data/lib/nis/struct/audit_collection.rb +1 -1
  59. data/lib/nis/struct/audit_info.rb +1 -1
  60. data/lib/nis/struct/block.rb +1 -1
  61. data/lib/nis/struct/block_height.rb +1 -1
  62. data/lib/nis/struct/block_score.rb +1 -1
  63. data/lib/nis/struct/boot_node_request.rb +1 -1
  64. data/lib/nis/struct/error.rb +1 -1
  65. data/lib/nis/struct/explorer_block_view_model.rb +1 -1
  66. data/lib/nis/struct/explorer_transfer_view_model.rb +1 -1
  67. data/lib/nis/struct/explorer_view_model_transaction.rb +1 -1
  68. data/lib/nis/struct/extended_node_experience_pair.rb +1 -1
  69. data/lib/nis/struct/harvest_info.rb +1 -1
  70. data/lib/nis/struct/key_pair_view_model.rb +1 -1
  71. data/lib/nis/struct/mosaic.rb +1 -1
  72. data/lib/nis/struct/mosaic_definition.rb +1 -1
  73. data/lib/nis/struct/mosaic_definition_meta_data.rb +1 -1
  74. data/lib/nis/struct/mosaic_definition_meta_data_pair.rb +1 -1
  75. data/lib/nis/struct/mosaic_id.rb +1 -1
  76. data/lib/nis/struct/mosaic_levy.rb +1 -1
  77. data/lib/nis/struct/mosaic_properties.rb +1 -1
  78. data/lib/nis/struct/multisig_cosignatory_modification.rb +1 -1
  79. data/lib/nis/struct/namespace.rb +1 -1
  80. data/lib/nis/struct/namespace_meta_data.rb +1 -1
  81. data/lib/nis/struct/namespace_meta_data_pair.rb +1 -1
  82. data/lib/nis/struct/nem_announce_result.rb +1 -1
  83. data/lib/nis/struct/nem_async_timer_visitor.rb +1 -1
  84. data/lib/nis/struct/nem_request_result.rb +1 -1
  85. data/lib/nis/struct/nis_node_info.rb +1 -1
  86. data/lib/nis/struct/node.rb +1 -1
  87. data/lib/nis/struct/node_collection.rb +1 -1
  88. data/lib/nis/struct/node_experience.rb +1 -1
  89. data/lib/nis/struct/request_announce.rb +1 -1
  90. data/lib/nis/struct/request_prepare_announce.rb +1 -1
  91. data/lib/nis/struct/time_synchronization_result.rb +1 -1
  92. data/lib/nis/struct/transaction.rb +4 -4
  93. data/lib/nis/struct/transaction_meta_data.rb +1 -1
  94. data/lib/nis/struct/transaction_meta_data_pair.rb +1 -1
  95. data/lib/nis/struct/unconfirmed_transaction_meta_data.rb +1 -1
  96. data/lib/nis/struct/unconfirmed_transaction_meta_data_pair.rb +1 -1
  97. data/lib/nis/transaction/importance_transfer.rb +1 -1
  98. data/lib/nis/transaction/mosaic_definition_creation.rb +1 -1
  99. data/lib/nis/transaction/mosaic_supply_change.rb +1 -1
  100. data/lib/nis/transaction/multisig.rb +1 -1
  101. data/lib/nis/transaction/multisig_aggregate_modification.rb +1 -1
  102. data/lib/nis/transaction/multisig_signature.rb +1 -1
  103. data/lib/nis/transaction/provision_namespace.rb +1 -1
  104. data/lib/nis/transaction/transfer.rb +4 -4
  105. data/lib/nis/unit/address.rb +19 -0
  106. data/lib/nis/util/convert.rb +125 -0
  107. data/lib/nis/util/ed25519.rb +263 -0
  108. data/lib/nis/util/serializer.rb +273 -0
  109. data/lib/nis/version.rb +1 -1
  110. data/nis.gemspec +1 -1
  111. metadata +9 -5
@@ -1,7 +1,7 @@
1
1
  module Nis::Endpoint
2
2
  module Account::Unlocked
3
3
  # @return [Hash <Symbol: num-unlocked>, <Symbol: max-unlocked>]
4
- # @see http://bob.nem.ninja/docs/#retrieving-the-unlock-info
4
+ # @see https://nemproject.github.io/#retrieving-the-unlock-info
5
5
  def account_unlocked_info
6
6
  request!(:post, '/account/unlocked/info')
7
7
  end
@@ -2,7 +2,7 @@ module Nis::Endpoint
2
2
  module Block::At
3
3
  # @param [Integer] block_height
4
4
  # @return [Nis::Struct::Block]
5
- # @see http://bob.nem.ninja/docs/#getting-a-block-with-a-given-height
5
+ # @see https://nemproject.github.io/#getting-a-block-with-a-given-height
6
6
  def block_at_public(block_height:)
7
7
  Nis::Struct::Block.build request!(:post, '/block/at/public', height: block_height)
8
8
  end
@@ -2,7 +2,7 @@ module Nis::Endpoint
2
2
  module Block::Get
3
3
  # @param [String] block_hash
4
4
  # @return [Nis::Struct::Block]
5
- # @see http://bob.nem.ninja/docs/#requesting-parts-of-the-block-chain
5
+ # @see https://nemproject.github.io/#requesting-parts-of-the-block-chain
6
6
  def block_get(block_hash:)
7
7
  Nis::Struct::Block.build request!(:get, '/block/get', blockHash: block_hash)
8
8
  end
@@ -2,7 +2,7 @@ module Nis::Endpoint
2
2
  module Chain
3
3
  module Height
4
4
  # @return [Nis::Struct::BlockHeight]
5
- # @see http://bob.nem.ninja/docs/#block-chain-height
5
+ # @see https://nemproject.github.io/#block-chain-height
6
6
  def chain_height
7
7
  Nis::Struct::BlockHeight.build request!(:get, '/chain/height')
8
8
  end
@@ -2,7 +2,7 @@ module Nis::Endpoint
2
2
  module Chain
3
3
  module LastBlock
4
4
  # @return [Nis::Struct::Block]
5
- # @see http://bob.nem.ninja/docs/#last-block-of-the-block-chain-score
5
+ # @see https://nemproject.github.io/#last-block-of-the-block-chain-score
6
6
  def chain_last_block
7
7
  request!(:get, '/chain/last-block') do |res|
8
8
  res[:transactions] = res[:transactions].map { |t| Nis::Struct::Transaction.new(t) }
@@ -2,7 +2,7 @@ module Nis::Endpoint
2
2
  module Chain
3
3
  module Score
4
4
  # @return [Nis::Struct::BlockScore]
5
- # @see http://bob.nem.ninja/docs/#block-chain-score
5
+ # @see https://nemproject.github.io/#block-chain-score
6
6
  def chain_score
7
7
  Nis::Struct::BlockScore.build request!(:get, '/chain/score')
8
8
  end
@@ -1,7 +1,7 @@
1
1
  module Nis::Endpoint
2
2
  module Debug::Connections
3
3
  # @return [Nis::Struct::AuditCollection]
4
- # @see http://bob.nem.ninja/docs/#monitoring-incoming-and-outgoing-calls
4
+ # @see https://nemproject.github.io/#monitoring-incoming-and-outgoing-calls
5
5
  def debug_connections_incoming
6
6
  request!(:get, '/debug/connections/incoming') do |res|
7
7
  Nis::Struct::AuditCollection.build(
@@ -12,7 +12,7 @@ module Nis::Endpoint
12
12
  end
13
13
 
14
14
  # @return [Nis::Struct::AuditCollection]
15
- # @see http://bob.nem.ninja/docs/#monitoring-incoming-and-outgoing-calls
15
+ # @see https://nemproject.github.io/#monitoring-incoming-and-outgoing-calls
16
16
  def debug_connections_outgoing
17
17
  request!(:get, '/debug/connections/outgoing') do |res|
18
18
  Nis::Struct::AuditCollection.build(
@@ -23,7 +23,7 @@ module Nis::Endpoint
23
23
  end
24
24
 
25
25
  # @return [Array <Nis::Struct::NemAsyncTimerVisitor>]
26
- # @see http://bob.nem.ninja/docs/#monitoring-timers
26
+ # @see https://nemproject.github.io/#monitoring-timers
27
27
  def debug_connections_timers
28
28
  request!(:get, '/debug/timers') do |res|
29
29
  res[:data].map { |natv| Nis::Struct::NemAsyncTimerVisitor.build(natv) }
@@ -1,7 +1,7 @@
1
1
  module Nis::Endpoint
2
2
  module Debug::TimeSynchronization
3
3
  # @return [TimeSynchronizationResult]
4
- # @see http://bob.nem.ninja/docs/#monitoring-the-network-time
4
+ # @see https://nemproject.github.io/#monitoring-the-network-time
5
5
  def debug_time_synchronization
6
6
  request!(:get, '/debug/time-synchronization') do |res|
7
7
  res[:data].map { |tsr| Nis::Struct::TimeSynchronizationResult.build(tsr) }
@@ -2,7 +2,7 @@ module Nis::Endpoint
2
2
  module Heartbeat
3
3
  # Determines if NIS is up and responsive.
4
4
  # @return [Nis::Struct::NemRequestResult] NIS Heartbeat
5
- # @see http://bob.nem.ninja/docs/#heart-beat-request
5
+ # @see https://nemproject.github.io/#heart-beat-request
6
6
  def heartbeat
7
7
  Nis::Struct::NemRequestResult.build request(:get, '/heartbeat')
8
8
  end
@@ -4,7 +4,7 @@ module Nis::Endpoint
4
4
  module Transfers
5
5
  # @param [Nis::Struct::AccountPrivateKeyTransactionsPage] page
6
6
  # @return [Array <Nis::Struct::TransactionMetaDataPair>]
7
- # @see http://bob.nem.ninja/docs/#transaction-data-with-decoded-messages
7
+ # @see https://nemproject.github.io/#transaction-data-with-decoded-messages
8
8
  def local_account_transfers_incoming(page:)
9
9
  request!(:post, '/local/account/transfers/incoming', page) do |res|
10
10
  res[:data].map { |tmdp| Nis::Struct::TransactionMetaDataPair.build(tmdp) }
@@ -13,7 +13,7 @@ module Nis::Endpoint
13
13
 
14
14
  # @param [Nis::Struct::AccountPrivateKeyTransactionsPage] page
15
15
  # @return [Array <Nis::Struct::TransactionMetaDataPair>]
16
- # @see http://bob.nem.ninja/docs/#transaction-data-with-decoded-messages
16
+ # @see https://nemproject.github.io/#transaction-data-with-decoded-messages
17
17
  def local_account_transfers_outgoing(page:)
18
18
  request!(:post, '/local/account/transfers/outgoing', page) do |res|
19
19
  res[:data].map { |tmdp| Nis::Struct::TransactionMetaDataPair.build(tmdp) }
@@ -22,7 +22,7 @@ module Nis::Endpoint
22
22
 
23
23
  # @param [Nis::Struct::AccountPrivateKeyTransactionsPage] page
24
24
  # @return [Array <Nis::Struct::TransactionMetaDataPair>]
25
- # @see http://bob.nem.ninja/docs/#transaction-data-with-decoded-messages
25
+ # @see https://nemproject.github.io/#transaction-data-with-decoded-messages
26
26
  def local_account_transfers_all(page:)
27
27
  request!(:post, '/local/account/transfers/all', page) do |res|
28
28
  res[:data].map { |tmdp| Nis::Struct::TransactionMetaDataPair.build(tmdp) }
@@ -3,7 +3,7 @@ module Nis::Endpoint
3
3
  module Chain
4
4
  # @param [String] block_height
5
5
  # @return [Array <Nis::Struct::Block>]
6
- # @see http://bob.nem.ninja/docs/#getting-part-of-a-chain
6
+ # @see https://nemproject.github.io/#getting-part-of-a-chain
7
7
  def local_chain_blocks_after(block_height:)
8
8
  request!(:post, '/local/chain/blocks-after',
9
9
  height: block_height
@@ -2,7 +2,7 @@ module Nis::Endpoint
2
2
  module Namespace
3
3
  # @param [String] namespace
4
4
  # @return [Nis::Struct::Namespace]
5
- # @see http://bob.nem.ninja/docs/#retrieving-a-specific-namespace
5
+ # @see https://nemproject.github.io/#retrieving-a-specific-namespace
6
6
  def namespace(namespace:)
7
7
  Nis::Struct::Namespace.build request!(:get, '/namespace', namespace: namespace)
8
8
  end
@@ -1,7 +1,7 @@
1
1
  module Nis::Endpoint
2
2
  module Namespace::Mosaic
3
3
  # @return [Array <Nis::Struct::MosaicDefinitionMetaDataPair>]
4
- # @see http://bob.nem.ninja/docs/#retrieving-mosaic-definitions
4
+ # @see https://nemproject.github.io/#retrieving-mosaic-definitions
5
5
  def namespace_mosaic_definition_page(namespace:, id: nil, page_size: nil)
6
6
  request!(:get, '/namespace/mosaic/definition/page',
7
7
  namespace: namespace,
@@ -1,7 +1,7 @@
1
1
  module Nis::Endpoint
2
2
  module Namespace::Root
3
3
  # @return [Array <Nis::Struct::NamespaceMetaDataPair>]
4
- # @see http://bob.nem.ninja/docs/#retrieving-root-namespaces
4
+ # @see https://nemproject.github.io/#retrieving-root-namespaces
5
5
  def namespace_root_page(id: nil, page_size: nil)
6
6
  request!(:get, '/namespace/root/page',
7
7
  id: id,
@@ -1,7 +1,7 @@
1
1
  module Nis::Endpoint
2
2
  module Node::ActivePeers
3
3
  # @return [Nis::Struct::Node]
4
- # @see http://bob.nem.ninja/docs/#maximum-chain-height-in-the-active-neighborhood
4
+ # @see https://nemproject.github.io/#maximum-chain-height-in-the-active-neighborhood
5
5
  def node_active_peers_max_chain_height
6
6
  request!(:get, '/node/active-peers/max-chain-height') do |res|
7
7
  Nis::Struct::BlockHeight.build res
@@ -2,7 +2,7 @@ module Nis::Endpoint
2
2
  module Node::Boot
3
3
  # @param boot_node_request [Nis::Struct::BootNodeRequest]
4
4
  # @return [nil]
5
- # @see http://bob.nem.ninja/docs/#booting-the-local-node
5
+ # @see https://nemproject.github.io/#booting-the-local-node
6
6
  def node_boot(boot_node_request:)
7
7
  request!(:post, '/node/boot', boot_node_request)
8
8
  end
@@ -1,7 +1,7 @@
1
1
  module Nis::Endpoint
2
2
  module Node::Experiences
3
3
  # @return [Nis::Struct::ExtendedNodeExperiencePair]
4
- # @see http://bob.nem.ninja/docs/#requesting-node-experiences
4
+ # @see https://nemproject.github.io/#requesting-node-experiences
5
5
  def node_experiences
6
6
  request!(:get, '/node/experiences') do |res|
7
7
  res[:data].map { |enep| Nis::Struct::ExtendedNodeExperiencePair.build(enep) }
@@ -1,7 +1,7 @@
1
1
  module Nis::Endpoint
2
2
  module Node::ExtendedInfo
3
3
  # @return [Nis::Struct::Node]
4
- # @see http://bob.nem.ninja/docs/#extended-node-information
4
+ # @see https://nemproject.github.io/#extended-node-information
5
5
  def node_extended_info
6
6
  Nis::Struct::NisNodeInfo.build request!(:get, '/node/extended-info')
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module Nis::Endpoint
2
2
  module Node::Info
3
3
  # @return [Nis::Struct::Node]
4
- # @see http://bob.nem.ninja/docs/#basic-node-information
4
+ # @see https://nemproject.github.io/#basic-node-information
5
5
  def node_info
6
6
  Nis::Struct::Node.build request!(:get, '/node/info')
7
7
  end
@@ -1,13 +1,13 @@
1
1
  module Nis::Endpoint
2
2
  module Node::PeerList
3
3
  # @return [Nis::Struct::NodeCollection]
4
- # @see http://bob.nem.ninja/docs/#complete-neighborhood
4
+ # @see https://nemproject.github.io/#complete-neighborhood
5
5
  def node_peerlist_all
6
6
  Nis::Struct::NodeCollection.build request!(:get, '/node/peer-list/all')
7
7
  end
8
8
 
9
9
  # @return [Array <Nis::Struct::Node>]
10
- # @see http://bob.nem.ninja/docs/#reachable-neighborhood
10
+ # @see https://nemproject.github.io/#reachable-neighborhood
11
11
  def node_peerlist_reachable
12
12
  request!(:get, '/node/peer-list/reachable') do |res|
13
13
  res[:data].map { |n| Nis::Struct::Node.build(n) }
@@ -15,7 +15,7 @@ module Nis::Endpoint
15
15
  end
16
16
 
17
17
  # @return [Array <Nis::Struct::Node>]
18
- # @see http://bob.nem.ninja/docs/#active-neighborhood
18
+ # @see https://nemproject.github.io/#active-neighborhood
19
19
  def node_peerlist_active
20
20
  request!(:get, '/node/peer-list/active') do |res|
21
21
  res[:data].map { |n| Nis::Struct::Node.build(n) }
@@ -2,7 +2,7 @@ module Nis::Endpoint
2
2
  module Status
3
3
  # Determines the status of NIS.
4
4
  # @return [Nis::Struct::NemRequestResult] NIS status
5
- # @see http://bob.nem.ninja/docs/#status-request
5
+ # @see https://nemproject.github.io/#status-request
6
6
  def status
7
7
  Nis::Struct::NemRequestResult.build request(:get, '/status')
8
8
  end
@@ -1,12 +1,12 @@
1
1
  module Nis::Endpoint
2
2
  module Transaction::Announce
3
- # @param [Nis::Struct::RequestAnnounce] request_announce
3
+ # @param [Nis::Struct::RequestAnnounce] request
4
4
  # @return [Nis::Struct::Node]
5
- # @see http://bob.nem.ninja/docs/#sending-the-data-to-NIS
6
- def transaction_announce(request_announce)
5
+ # @see https://nemproject.github.io/#sending-the-data-to-NIS
6
+ def transaction_announce(request)
7
7
  Nis::Struct::NemAnnounceResult.build request!(:post,
8
8
  '/transaction/announce',
9
- request_announce
9
+ request
10
10
  )
11
11
  end
12
12
  end
@@ -1,12 +1,12 @@
1
1
  module Nis::Endpoint
2
2
  module Transaction::PrepareAnnounce
3
- # @param [Nis::Struct::RequestPrepareAnnounce] request_prepare_announce
3
+ # @param [Nis::Struct::RequestPrepareAnnounce] request
4
4
  # @return [Nis::Struct::Node]
5
- # @see http://bob.nem.ninja/docs/#initiating-a-transaction
6
- def transaction_prepare_announce(request_prepare_announce)
5
+ # @see https://nemproject.github.io/#initiating-a-transaction
6
+ def transaction_prepare_announce(request)
7
7
  Nis::Struct::NemAnnounceResult.build request!(:post,
8
8
  '/transaction/prepare-announce',
9
- request_prepare_announce
9
+ request
10
10
  )
11
11
  end
12
12
  end
data/lib/nis/keypair.rb CHANGED
@@ -4,15 +4,25 @@ class Nis
4
4
 
5
5
  def initialize(private_key, public_key: nil)
6
6
  @private = private_key
7
- @public = public_key
7
+ @public = public_key || calc_public_key
8
8
  end
9
9
 
10
+ def sign(data)
11
+ bin_data = data.scan(/../).map(&:hex).pack('C*')
12
+ bin_signed = Nis::Util::Ed25519.signature_hash_unsafe(bin_data, @bin_secret, @bin_public)
13
+ bin_signed.unpack('H*').first
14
+ end
15
+
16
+ private
17
+
10
18
  def fix_private_key(key)
11
19
  "#{'0' * 64}#{key.sub(/^00/i, '')}"[-64, 64]
12
20
  end
13
21
 
14
- def calc_pubkey
15
- # TODO: calculate pubkey from privkey
22
+ def calc_public_key
23
+ @bin_secret = fix_private_key(@private).scan(/../).map(&:hex).reverse.pack('C*')
24
+ @bin_public = Nis::Util::Ed25519.publickey_hash_unsafe(@bin_secret)
25
+ @bin_public.unpack('H*').first
16
26
  end
17
27
  end
18
28
  end
@@ -1,10 +1,55 @@
1
1
  class Nis::Request
2
2
  # @attr [String] data
3
3
  # @attr [String] signature
4
- # @see http://bob.nem.ninja/docs/#requestAnnounce
4
+ # @see https://nemproject.github.io/#requestAnnounce
5
5
  class Announce
6
6
  include Nis::Mixin::Struct
7
7
 
8
- attr_accessor :data, :signature
8
+ attr_accessor :transaction, :keypair, :data, :signature
9
+
10
+ DEADLINE = 3600
11
+
12
+ def initialize(transaction, keypair)
13
+ @keypair = keypair
14
+ @transaction = transaction
15
+ end
16
+
17
+ def to_hash
18
+ if @transaction.respond_to?(:other_trans)
19
+ other_trans(@transaction)
20
+ end
21
+
22
+ @transaction.tap do |tx|
23
+ tx.timeStamp = Nis::Util.timestamp
24
+ tx.deadline = Nis::Util.deadline(DEADLINE)
25
+ tx.version = Nis::Util.parse_version(tx.network, 1)
26
+ tx.signer = @keypair.public
27
+ end
28
+
29
+ serialized = serialize(@transaction)
30
+ hex_serialized = Nis::Util::Convert.ua2hex(serialized)
31
+
32
+ { data: Nis::Util::Convert.ua2hex(serialized),
33
+ signature: signature(hex_serialized) }
34
+ end
35
+
36
+ private
37
+
38
+ def serialize(transaction)
39
+ Nis::Util::Serializer.serialize_transaction(transaction.to_hash)
40
+ end
41
+
42
+ def signature(serialized)
43
+ @keypair.sign(serialized)
44
+ end
45
+
46
+ def other_trans(transaction)
47
+ transaction.other_trans.tap do |tx|
48
+ tx.timeStamp = Nis::Util.timestamp
49
+ tx.deadline = Nis::Util.deadline(DEADLINE)
50
+ tx.version = Nis::Util.parse_version(tx.network, 1)
51
+ tx.signer = transaction.signer
52
+ end
53
+ end
9
54
  end
10
55
  end
@@ -1,7 +1,7 @@
1
1
  class Nis::Request
2
2
  # @attr [Nis::Struct::Transaction] transaction
3
3
  # @attr [Nis::Keypair] keypair
4
- # @see http://bob.nem.ninja/docs/#requestPrepareAnnounce
4
+ # @see https://nemproject.github.io/#requestPrepareAnnounce
5
5
  class PrepareAnnounce
6
6
  include Nis::Mixin::Struct
7
7
 
@@ -5,7 +5,7 @@ class Nis::Struct
5
5
  # @attr [Integer] score
6
6
  # @attr [Integer] ev
7
7
  # @attr [Integer] height
8
- # @see http://bob.nem.ninja/docs/#accountImportanceViewModel
8
+ # @see https://nemproject.github.io/#accountImportanceViewModel
9
9
  class AccountImportanceViewModel
10
10
  include Nis::Util::Assignable
11
11
  attr_accessor :address, :importance, :isSet, :score, :ev, :height
@@ -6,7 +6,7 @@ class Nis::Struct
6
6
  # @attr [String] publicKey
7
7
  # @attr [String] label
8
8
  # @attr [Array] harvestedBlocks
9
- # @see http://bob.nem.ninja/docs/#accountInfo
9
+ # @see https://nemproject.github.io/#accountInfo
10
10
  class AccountInfo
11
11
  include Nis::Util::Assignable
12
12
  attr_accessor :address, :balance, :vestedBalance, :importance, :publicKey, :label, :harvestedBlocks
@@ -3,7 +3,7 @@ class Nis::Struct
3
3
  # @attr [String] remoteStatus
4
4
  # @attr [Array <Nis::Struct::AccountInfo>] cosignatoryOf
5
5
  # @attr [Array <Nis::Struct::AccountInfo>] cosignatories
6
- # @see http://bob.nem.ninja/docs/#accountMetaData
6
+ # @see https://nemproject.github.io/#accountMetaData
7
7
  class AccountMetaData
8
8
  include Nis::Util::Assignable
9
9
  attr_accessor :status, :remoteStatus, :cosignatoryOf, :cosignatories
@@ -1,7 +1,7 @@
1
1
  class Nis::Struct
2
2
  # @attr [AccountInfo] account
3
3
  # @attr [AccountMetaData] meta
4
- # @see http://bob.nem.ninja/docs/#accountMetaDataPair
4
+ # @see https://nemproject.github.io/#accountMetaDataPair
5
5
  class AccountMetaDataPair
6
6
  include Nis::Util::Assignable
7
7
  attr_accessor :account, :meta
@@ -2,7 +2,7 @@ class Nis::Struct
2
2
  # @attr [String] value
3
3
  # @attr [String] hash
4
4
  # @attr [Integer] id
5
- # @see http://bob.nem.ninja/docs/#accountPrivateKeyTransactionsPage
5
+ # @see https://nemproject.github.io/#accountPrivateKeyTransactionsPage
6
6
  class AccountPrivateKeyTransactionsPage
7
7
  include Nis::Util::Assignable
8
8
  attr_accessor :value, :hash, :id