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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +12 -9
- data/examples/transactions/importance_transfer.rb +1 -4
- data/examples/transactions/mosaic_definition_creation.rb +1 -4
- data/examples/transactions/mosaic_supply_change.rb +1 -4
- data/examples/transactions/multisig.rb +1 -6
- data/examples/transactions/multisig_add_cosignatory.rb +1 -4
- data/examples/transactions/multisig_aggregate_modification.rb +1 -4
- data/examples/transactions/multisig_signature.rb +2 -5
- data/examples/transactions/provision_namespace.rb +1 -4
- data/examples/transactions/transfer.rb +1 -4
- data/examples/transactions/transfer_remote.rb +19 -0
- data/lib/nis/endpoint/account/generate.rb +1 -1
- data/lib/nis/endpoint/account/get.rb +4 -4
- data/lib/nis/endpoint/account/harvests.rb +1 -1
- data/lib/nis/endpoint/account/historical.rb +1 -1
- data/lib/nis/endpoint/account/importances.rb +1 -1
- data/lib/nis/endpoint/account/lock.rb +1 -1
- data/lib/nis/endpoint/account/mosaic.rb +2 -2
- data/lib/nis/endpoint/account/namespace.rb +1 -1
- data/lib/nis/endpoint/account/status.rb +1 -1
- data/lib/nis/endpoint/account/transfers.rb +3 -3
- data/lib/nis/endpoint/account/unconfirmed_transactions.rb +1 -1
- data/lib/nis/endpoint/account/unlock.rb +1 -1
- data/lib/nis/endpoint/account/unlocked.rb +1 -1
- data/lib/nis/endpoint/block/at.rb +1 -1
- data/lib/nis/endpoint/block/get.rb +1 -1
- data/lib/nis/endpoint/chain/height.rb +1 -1
- data/lib/nis/endpoint/chain/last_block.rb +1 -1
- data/lib/nis/endpoint/chain/score.rb +1 -1
- data/lib/nis/endpoint/debug/connections.rb +3 -3
- data/lib/nis/endpoint/debug/time_synchronization.rb +1 -1
- data/lib/nis/endpoint/heartbeat.rb +1 -1
- data/lib/nis/endpoint/local/account/transfers.rb +3 -3
- data/lib/nis/endpoint/local/chain.rb +1 -1
- data/lib/nis/endpoint/namespace.rb +1 -1
- data/lib/nis/endpoint/namespace/mosaic.rb +1 -1
- data/lib/nis/endpoint/namespace/root.rb +1 -1
- data/lib/nis/endpoint/node/active_peers.rb +1 -1
- data/lib/nis/endpoint/node/boot.rb +1 -1
- data/lib/nis/endpoint/node/experiences.rb +1 -1
- data/lib/nis/endpoint/node/extended_info.rb +1 -1
- data/lib/nis/endpoint/node/info.rb +1 -1
- data/lib/nis/endpoint/node/peer_list.rb +3 -3
- data/lib/nis/endpoint/status.rb +1 -1
- data/lib/nis/endpoint/transaction/announce.rb +4 -4
- data/lib/nis/endpoint/transaction/prepareAnnounce.rb +4 -4
- data/lib/nis/keypair.rb +13 -3
- data/lib/nis/request/announce.rb +47 -2
- data/lib/nis/request/prepare_announce.rb +1 -1
- data/lib/nis/struct/account_importance_view_model.rb +1 -1
- data/lib/nis/struct/account_info.rb +1 -1
- data/lib/nis/struct/account_meta_data.rb +1 -1
- data/lib/nis/struct/account_meta_data_pair.rb +1 -1
- data/lib/nis/struct/account_private_key_transactions_page.rb +1 -1
- data/lib/nis/struct/application_meta_data.rb +1 -1
- data/lib/nis/struct/audit_collection.rb +1 -1
- data/lib/nis/struct/audit_info.rb +1 -1
- data/lib/nis/struct/block.rb +1 -1
- data/lib/nis/struct/block_height.rb +1 -1
- data/lib/nis/struct/block_score.rb +1 -1
- data/lib/nis/struct/boot_node_request.rb +1 -1
- data/lib/nis/struct/error.rb +1 -1
- data/lib/nis/struct/explorer_block_view_model.rb +1 -1
- data/lib/nis/struct/explorer_transfer_view_model.rb +1 -1
- data/lib/nis/struct/explorer_view_model_transaction.rb +1 -1
- data/lib/nis/struct/extended_node_experience_pair.rb +1 -1
- data/lib/nis/struct/harvest_info.rb +1 -1
- data/lib/nis/struct/key_pair_view_model.rb +1 -1
- data/lib/nis/struct/mosaic.rb +1 -1
- data/lib/nis/struct/mosaic_definition.rb +1 -1
- data/lib/nis/struct/mosaic_definition_meta_data.rb +1 -1
- data/lib/nis/struct/mosaic_definition_meta_data_pair.rb +1 -1
- data/lib/nis/struct/mosaic_id.rb +1 -1
- data/lib/nis/struct/mosaic_levy.rb +1 -1
- data/lib/nis/struct/mosaic_properties.rb +1 -1
- data/lib/nis/struct/multisig_cosignatory_modification.rb +1 -1
- data/lib/nis/struct/namespace.rb +1 -1
- data/lib/nis/struct/namespace_meta_data.rb +1 -1
- data/lib/nis/struct/namespace_meta_data_pair.rb +1 -1
- data/lib/nis/struct/nem_announce_result.rb +1 -1
- data/lib/nis/struct/nem_async_timer_visitor.rb +1 -1
- data/lib/nis/struct/nem_request_result.rb +1 -1
- data/lib/nis/struct/nis_node_info.rb +1 -1
- data/lib/nis/struct/node.rb +1 -1
- data/lib/nis/struct/node_collection.rb +1 -1
- data/lib/nis/struct/node_experience.rb +1 -1
- data/lib/nis/struct/request_announce.rb +1 -1
- data/lib/nis/struct/request_prepare_announce.rb +1 -1
- data/lib/nis/struct/time_synchronization_result.rb +1 -1
- data/lib/nis/struct/transaction.rb +4 -4
- data/lib/nis/struct/transaction_meta_data.rb +1 -1
- data/lib/nis/struct/transaction_meta_data_pair.rb +1 -1
- data/lib/nis/struct/unconfirmed_transaction_meta_data.rb +1 -1
- data/lib/nis/struct/unconfirmed_transaction_meta_data_pair.rb +1 -1
- data/lib/nis/transaction/importance_transfer.rb +1 -1
- data/lib/nis/transaction/mosaic_definition_creation.rb +1 -1
- data/lib/nis/transaction/mosaic_supply_change.rb +1 -1
- data/lib/nis/transaction/multisig.rb +1 -1
- data/lib/nis/transaction/multisig_aggregate_modification.rb +1 -1
- data/lib/nis/transaction/multisig_signature.rb +1 -1
- data/lib/nis/transaction/provision_namespace.rb +1 -1
- data/lib/nis/transaction/transfer.rb +4 -4
- data/lib/nis/unit/address.rb +19 -0
- data/lib/nis/util/convert.rb +125 -0
- data/lib/nis/util/ed25519.rb +263 -0
- data/lib/nis/util/serializer.rb +273 -0
- data/lib/nis/version.rb +1 -1
- data/nis.gemspec +1 -1
- 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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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) }
|
data/lib/nis/endpoint/status.rb
CHANGED
@@ -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
|
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]
|
3
|
+
# @param [Nis::Struct::RequestAnnounce] request
|
4
4
|
# @return [Nis::Struct::Node]
|
5
|
-
# @see
|
6
|
-
def transaction_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
|
-
|
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]
|
3
|
+
# @param [Nis::Struct::RequestPrepareAnnounce] request
|
4
4
|
# @return [Nis::Struct::Node]
|
5
|
-
# @see
|
6
|
-
def transaction_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
|
-
|
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
|
15
|
-
|
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
|
data/lib/nis/request/announce.rb
CHANGED
@@ -1,10 +1,55 @@
|
|
1
1
|
class Nis::Request
|
2
2
|
# @attr [String] data
|
3
3
|
# @attr [String] signature
|
4
|
-
# @see
|
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
|
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
|
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
|
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
|
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
|
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
|
5
|
+
# @see https://nemproject.github.io/#accountPrivateKeyTransactionsPage
|
6
6
|
class AccountPrivateKeyTransactionsPage
|
7
7
|
include Nis::Util::Assignable
|
8
8
|
attr_accessor :value, :hash, :id
|