nem-ruby 0.0.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.
Files changed (136) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +119 -0
  5. data/.travis.yml +23 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +6 -0
  8. data/README.md +81 -0
  9. data/Rakefile +6 -0
  10. data/examples/apostille_audit.rb +22 -0
  11. data/examples/apostille_create.rb +31 -0
  12. data/examples/endpoint/account.rb +73 -0
  13. data/examples/endpoint/account_local.rb +21 -0
  14. data/examples/endpoint/block.rb +14 -0
  15. data/examples/endpoint/chain.rb +15 -0
  16. data/examples/endpoint/debug.rb +17 -0
  17. data/examples/endpoint/local.rb +17 -0
  18. data/examples/endpoint/mosaic.rb +9 -0
  19. data/examples/endpoint/namespace.rb +13 -0
  20. data/examples/endpoint/node.rb +24 -0
  21. data/examples/endpoint/timesync.rb +9 -0
  22. data/examples/endpoint/transaction.rb +42 -0
  23. data/examples/localnode.rb +0 -0
  24. data/examples/nis.rb +34 -0
  25. data/examples/node_pool.rb +23 -0
  26. data/examples/transaction/importance_transfer.rb +23 -0
  27. data/examples/transaction/mosaic_definition_creation.rb +52 -0
  28. data/examples/transaction/mosaic_supply_change.rb +25 -0
  29. data/examples/transaction/multisig_add_cosignatory.rb +31 -0
  30. data/examples/transaction/multisig_aggregate_modification.rb +29 -0
  31. data/examples/transaction/multisig_signature.rb +41 -0
  32. data/examples/transaction/multisig_transfer.rb +35 -0
  33. data/examples/transaction/provision_namespace.rb +20 -0
  34. data/examples/transaction/transfer.rb +32 -0
  35. data/examples/transaction/transfer_mosaic.rb +72 -0
  36. data/examples/transaction/transfer_with_encrypted_message.rb +40 -0
  37. data/examples/transaction/transfer_with_local.rb +34 -0
  38. data/lib/nem.rb +21 -0
  39. data/lib/nem/apostille.rb +104 -0
  40. data/lib/nem/apostille_audit.rb +47 -0
  41. data/lib/nem/client.rb +170 -0
  42. data/lib/nem/configuration.rb +29 -0
  43. data/lib/nem/endpoint.rb +4 -0
  44. data/lib/nem/endpoint/account.rb +264 -0
  45. data/lib/nem/endpoint/base.rb +45 -0
  46. data/lib/nem/endpoint/block.rb +15 -0
  47. data/lib/nem/endpoint/chain.rb +17 -0
  48. data/lib/nem/endpoint/debug.rb +54 -0
  49. data/lib/nem/endpoint/local/account.rb +54 -0
  50. data/lib/nem/endpoint/local/chain.rb +15 -0
  51. data/lib/nem/endpoint/mosaic.rb +13 -0
  52. data/lib/nem/endpoint/namespace.rb +37 -0
  53. data/lib/nem/endpoint/node.rb +83 -0
  54. data/lib/nem/endpoint/timesync.rb +9 -0
  55. data/lib/nem/endpoint/transaction.rb +34 -0
  56. data/lib/nem/error.rb +6 -0
  57. data/lib/nem/fee.rb +2 -0
  58. data/lib/nem/fee/importance_transfer.rb +24 -0
  59. data/lib/nem/fee/mosaic_definition_creation.rb +24 -0
  60. data/lib/nem/fee/mosaic_supply_change_transfer.rb +24 -0
  61. data/lib/nem/fee/multisig.rb +24 -0
  62. data/lib/nem/fee/multisig_aggregation_modification.rb +28 -0
  63. data/lib/nem/fee/provision_namespace.rb +34 -0
  64. data/lib/nem/fee/transfer.rb +66 -0
  65. data/lib/nem/keypair.rb +44 -0
  66. data/lib/nem/mixin.rb +2 -0
  67. data/lib/nem/mixin/assignable.rb +12 -0
  68. data/lib/nem/model.rb +3 -0
  69. data/lib/nem/model/account.rb +67 -0
  70. data/lib/nem/model/account_historical.rb +19 -0
  71. data/lib/nem/model/block.rb +33 -0
  72. data/lib/nem/model/chain.rb +14 -0
  73. data/lib/nem/model/connection.rb +23 -0
  74. data/lib/nem/model/experience.rb +20 -0
  75. data/lib/nem/model/explorer_block.rb +21 -0
  76. data/lib/nem/model/harvest.rb +23 -0
  77. data/lib/nem/model/heartbeat.rb +21 -0
  78. data/lib/nem/model/importance.rb +29 -0
  79. data/lib/nem/model/importance_transfer_transaction.rb +16 -0
  80. data/lib/nem/model/keypair.rb +19 -0
  81. data/lib/nem/model/message.rb +91 -0
  82. data/lib/nem/model/mosaic.rb +21 -0
  83. data/lib/nem/model/mosaic_attachment.rb +22 -0
  84. data/lib/nem/model/mosaic_definition.rb +65 -0
  85. data/lib/nem/model/mosaic_definition_creation_transaction.rb +18 -0
  86. data/lib/nem/model/mosaic_id.rb +27 -0
  87. data/lib/nem/model/mosaic_levy.rb +32 -0
  88. data/lib/nem/model/mosaic_owned.rb +22 -0
  89. data/lib/nem/model/mosaic_properties.rb +44 -0
  90. data/lib/nem/model/mosaic_supply.rb +21 -0
  91. data/lib/nem/model/mosaic_supply_change_transaction.rb +18 -0
  92. data/lib/nem/model/multisig_aggregate_modification_transaction.rb +21 -0
  93. data/lib/nem/model/multisig_info.rb +16 -0
  94. data/lib/nem/model/multisig_signature_transaction.rb +17 -0
  95. data/lib/nem/model/multisig_transaction.rb +21 -0
  96. data/lib/nem/model/namespace.rb +24 -0
  97. data/lib/nem/model/nem_announce_result.rb +19 -0
  98. data/lib/nem/model/network_time.rb +16 -0
  99. data/lib/nem/model/nis_node_info.rb +26 -0
  100. data/lib/nem/model/node.rb +41 -0
  101. data/lib/nem/model/provision_namespace_transaction.rb +18 -0
  102. data/lib/nem/model/status.rb +21 -0
  103. data/lib/nem/model/timer.rb +31 -0
  104. data/lib/nem/model/timesync.rb +19 -0
  105. data/lib/nem/model/transaction.rb +71 -0
  106. data/lib/nem/model/transfer_transaction.rb +24 -0
  107. data/lib/nem/model/unlocked_info.rb +24 -0
  108. data/lib/nem/mosaic.rb +2 -0
  109. data/lib/nem/mosaic/dim_coin.rb +21 -0
  110. data/lib/nem/mosaic/dim_token.rb +21 -0
  111. data/lib/nem/mosaic/ecobit_eco.rb +21 -0
  112. data/lib/nem/mosaic/xem.rb +21 -0
  113. data/lib/nem/node.rb +29 -0
  114. data/lib/nem/node_pool.rb +31 -0
  115. data/lib/nem/request.rb +2 -0
  116. data/lib/nem/request/announce.rb +76 -0
  117. data/lib/nem/transaction.rb +3 -0
  118. data/lib/nem/transaction/base.rb +45 -0
  119. data/lib/nem/transaction/importance_transfer.rb +42 -0
  120. data/lib/nem/transaction/mosaic_definition_creation.rb +45 -0
  121. data/lib/nem/transaction/mosaic_supply_change.rb +45 -0
  122. data/lib/nem/transaction/multisig.rb +29 -0
  123. data/lib/nem/transaction/multisig_aggregate_modification.rb +30 -0
  124. data/lib/nem/transaction/multisig_cosignatory_modification.rb +33 -0
  125. data/lib/nem/transaction/multisig_signature.rb +31 -0
  126. data/lib/nem/transaction/provision_namespace.rb +65 -0
  127. data/lib/nem/transaction/transfer.rb +63 -0
  128. data/lib/nem/util.rb +44 -0
  129. data/lib/nem/util/assignable.rb +51 -0
  130. data/lib/nem/util/convert.rb +112 -0
  131. data/lib/nem/util/deserializer.rb +158 -0
  132. data/lib/nem/util/ed25519.rb +316 -0
  133. data/lib/nem/util/serializer.rb +260 -0
  134. data/lib/nem/version.rb +3 -0
  135. data/nem-ruby.gemspec +46 -0
  136. metadata +350 -0
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+ require File.expand_path('transaction/base.rb', __dir__)
3
+ Dir.glob(File.expand_path('transaction/*.rb', __dir__)).each { |f| require f }
@@ -0,0 +1,45 @@
1
+ module Nem
2
+ module Transaction
3
+ class Base
4
+ attr_reader :type, :fee,
5
+ :timestamp, :deadline, :signer, :signature
6
+ # :version, :network
7
+
8
+ {
9
+ transfer: 0x0101,
10
+ importance_transfer: 0x0801,
11
+ multisig_aggregate_modification: 0x1001,
12
+ multisig_signature: 0x1002,
13
+ multisig: 0x1004,
14
+ provision_namespace: 0x2001,
15
+ mosaic_definition_creation: 0x4001,
16
+ mosaic_supply_change: 0x4002,
17
+ }.each do |k, v|
18
+ define_method("#{k}?") { @type == v }
19
+ end
20
+
21
+ NETWORK = {
22
+ testnet: 0x98 << 24,
23
+ mainnet: 0x68 << 24,
24
+ mijin: 0x60 << 24
25
+ }
26
+
27
+ NETWORK.each do |k, _|
28
+ define_method("#{k}?") { @network == k }
29
+ end
30
+
31
+ def network(hex: false)
32
+ hex ? NETWORK[@network] : @network
33
+ end
34
+
35
+ # it can be override by child class
36
+ def version
37
+ network(hex: true) + 1
38
+ end
39
+
40
+ def to_hash
41
+ raise 'it must be implemented by child class.'
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,42 @@
1
+ module Nem
2
+ module Transaction
3
+ # @attr [String] remote_account
4
+ # @attr [Symbol] mode
5
+ # @see https://nemproject.github.io/#importanceTransferTransaction
6
+ class ImportanceTransfer < Nem::Transaction::Base
7
+ TYPE = 0x0801 # 2049 (importance transfer transaction)
8
+
9
+ ACTIVATE = 0x0001
10
+ DEACTIVATE = 0x0002
11
+
12
+ attr_reader :mode, :remote_account
13
+
14
+ def initialize(remote_account, mode, network: nil)
15
+ @remote_account = remote_account
16
+ @mode = mode
17
+
18
+ @network = network || Nem.default_network
19
+ @type = TYPE
20
+ @fee = Nem::Fee::ImportanceTransfer.new(self)
21
+ end
22
+
23
+ # attributes must be CAMEL CASE for NIS params
24
+ def to_hash
25
+ {
26
+ mode: parse_mode,
27
+ remoteAccount: remote_account
28
+ }
29
+ end
30
+
31
+ private
32
+
33
+ def parse_mode
34
+ case mode
35
+ when :activate then ACTIVATE
36
+ when :deactivate then DEACTIVATE
37
+ else raise "Not implemented mode: #{mode}"
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,45 @@
1
+ module Nem
2
+ module Transaction
3
+ # @attr [Nem::Model::MosaicDefinition] mosaic_definition
4
+ # @attr [Integer] creation_fee
5
+ # @attr [Integer] creation_fee_sink
6
+ # @see https://nemproject.github.io/#mosaicDefinitionCreationTransaction
7
+ class MosaicDefinitionCreation < Nem::Transaction::Base
8
+ TYPE = 0x4001 # 16385 (mosaic definition creation transaction)
9
+
10
+ attr_reader :mosaic_definition, :creation_fee, :creation_fee_sink
11
+
12
+ def initialize(mosaic_definition, network: nil)
13
+ @mosaic_definition = mosaic_definition
14
+ @creation_fee = creation[:fee]
15
+ @creation_fee_sink = creation[:sink]
16
+
17
+ @network = network || Nem.default_network
18
+ @type = TYPE
19
+ @fee = Nem::Fee::MosaicDefinitionCreation.new(self)
20
+ end
21
+
22
+ # attributes must be CAMEL CASE for NIS params
23
+ def to_hash
24
+ {
25
+ mosaicDefinition: mosaic_definition.to_hash,
26
+ creationFee: creation_fee,
27
+ creationFeeSink: creation_fee_sink,
28
+ }
29
+ end
30
+
31
+ private
32
+
33
+ # @see http://www.nem.ninja/docs/#mosaics
34
+ def creation
35
+ if @network == :mainnet
36
+ { sink: 'NBMOSAICOD4F54EE5CDMR23CCBGOAM2XSIUX6TRS',
37
+ fee: 20 * 1_000_000 }
38
+ else
39
+ { sink: 'TBMOSAICOD4F54EE5CDMR23CCBGOAM2XSJBR5OLC',
40
+ fee: 20 * 1_000_000 }
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,45 @@
1
+ module Nem
2
+ module Transaction
3
+ # @attr [Nem::Model::MosaicId] mosaic_id
4
+ # @attr [Symbol] supply_type
5
+ # @attr [Integer] delta
6
+ # @see https://nemproject.github.io/#mosaicSupplyChangeTransaction
7
+ class MosaicSupplyChange < Nem::Transaction::Base
8
+ TYPE = 0x4002 # 16386 (mosaic supply change transaction)
9
+
10
+ INCREASE = 0x0001
11
+ DECREASE = 0x0002
12
+
13
+ attr_accessor :mosaic_id, :supply_type, :delta
14
+
15
+ def initialize(mosaic_id, type, delta, network: nil)
16
+ @mosaic_id = mosaic_id
17
+ @supply_type = type
18
+ @delta = delta
19
+
20
+ @network = network || Nem.default_network
21
+ @type = TYPE
22
+ @fee = Nem::Fee::MosaicSupplyChangeTransfer.new(self)
23
+ end
24
+
25
+ # attributes must be CAMEL CASE for NIS params
26
+ def to_hash
27
+ {
28
+ mosaicId: mosaic_id.to_hash,
29
+ supplyType: parse_type,
30
+ delta: delta,
31
+ }
32
+ end
33
+
34
+ private
35
+
36
+ def parse_type
37
+ case type
38
+ when :increase then INCREASE
39
+ when :descrease then DECREASE
40
+ else raise "Not implemented type: #{type}"
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,29 @@
1
+ module Nem
2
+ module Transaction
3
+ # @attr [Nem::Transaction::*] other_trans
4
+ # @attr [String] signer
5
+ # @see https://nemproject.github.io/#multisigTransaction
6
+ class Multisig < Nem::Transaction::Base
7
+ TYPE = 0x1004 # 4100 (multisig transaction)
8
+
9
+ attr_reader :other_trans, :signer
10
+
11
+ def initialize(trans, signer, network: nil)
12
+ @other_trans = trans
13
+ @signer = signer
14
+
15
+ @network = network || Nem.default_network
16
+ @type = TYPE
17
+ @fee = Nem::Fee::Multisig.new(self)
18
+ end
19
+
20
+ # attributes must be CAMEL CASE for NIS params
21
+ def to_hash
22
+ {
23
+ otherTrans: other_trans.to_hash,
24
+ signer: signer
25
+ }
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,30 @@
1
+ module Nem
2
+ module Transaction
3
+ # @attr [Array <Nem::Model::MultisigCosignatoryModification>] modifications
4
+ # @attr [Interger] relative_change
5
+ class MultisigAggregateModification < Nem::Transaction::Base
6
+ TYPE = 0x1001 # 4097 (multisig aggregate modification transfer transaction)
7
+
8
+ attr_reader :modifications, :relative_change, :min_cosignatories
9
+
10
+ def initialize(modifications, relative_change, network: nil)
11
+ @modifications = modifications
12
+ @relative_change = relative_change
13
+
14
+ @network = network || Nem.default_network
15
+ @type = TYPE
16
+ @fee = Nem::Fee::MultisigAggregateModification.new(self)
17
+ end
18
+
19
+ # attributes must be CAMEL CASE for NIS params
20
+ def to_hash
21
+ {
22
+ modifications: modifications.map(&:to_hash),
23
+ minCosignatories: {
24
+ relativeChange: relative_change
25
+ }
26
+ }
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,33 @@
1
+ module Nem
2
+ module Transaction
3
+ class MultisigCosignatoryModification
4
+ attr_reader :modification_type, :cosignatory_account
5
+
6
+ TYPE_ADD = 0x001
7
+ TYPE_REMOVE = 0x002
8
+
9
+ def initialize(type, public_key)
10
+ @modification_type = type
11
+ @cosignatory_account = public_key
12
+ end
13
+
14
+ # attributes must be CAMEL CASE for NIS params
15
+ def to_hash
16
+ {
17
+ modificationType: parse_type,
18
+ cosignatoryAccount: cosignatory_account
19
+ }
20
+ end
21
+
22
+ private
23
+
24
+ def parse_type
25
+ case modification_type
26
+ when :add then TYPE_ADD
27
+ when :remove then TYPE_REMOVE
28
+ else raise "Not implemented mode: #{modification_type}"
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,31 @@
1
+ module Nem
2
+ module Transaction
3
+ # @attr [String] other_hash
4
+ # @attr [String] other_account
5
+ # @attr [String] signer
6
+ class MultisigSignature < Nem::Transaction::Base
7
+ TYPE = 0x1002 # 4098 (multisig signature transaction)
8
+
9
+ attr_reader :other_hash, :other_account, :signer
10
+
11
+ def initialize(other_hash, other_account, signer, network: nil)
12
+ @other_hash = other_hash
13
+ @other_account = other_account
14
+ @signer = signer
15
+
16
+ @network = network || Nem.default_network
17
+ @type = TYPE
18
+ @fee = Nem::Fee::Multisig.new(self)
19
+ end
20
+
21
+ # attributes must be CAMEL CASE for NIS params
22
+ def to_hash
23
+ {
24
+ otherHash: { data: other_hash },
25
+ otherAccount: other_account,
26
+ signer: signer
27
+ }
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,65 @@
1
+ module Nem
2
+ module Transaction
3
+ class ProvisionNamespace < Nem::Transaction::Base
4
+ TYPE = 0x2001 # 8193 (provision namespace transaction)
5
+
6
+ attr_reader :new_part, :parent, :rental_fee_sink, :rental_fee
7
+
8
+ # @attr [String] new_part
9
+ # @attr [String] parent
10
+ # @attr [String] rental_fee_sink
11
+ # @attr [Integer] rental_fee
12
+ def initialize(new_part, parent = nil, network: nil)
13
+ @new_part = new_part
14
+ @parent = parent
15
+ @rental_fee = rental[:fee]
16
+ @rental_fee_sink = rental[:sink]
17
+
18
+ @network = network || Nem.default_network
19
+ @type = TYPE
20
+ @fee = Nem::Fee::ProvisionNamespace.new(self)
21
+ end
22
+
23
+ def root?
24
+ !!(@parent == nil)
25
+ end
26
+
27
+ def sub?
28
+ !!(@parent && @new_part)
29
+ end
30
+
31
+ # attributes must be CAMEL CASE for NIS params
32
+ def to_hash
33
+ {
34
+ newPart: new_part,
35
+ parent: parent,
36
+ rentalFeeSink: rental_fee_sink,
37
+ rentalFee: rental_fee
38
+ }
39
+ end
40
+
41
+ private
42
+
43
+ # @see http://www.nem.ninja/docs/#namespaces
44
+ def rental
45
+ if @network == :mainnet
46
+ if root?
47
+ { fee: 100 * 1_000_000,
48
+ sink: 'NAMESPACEWH4MKFMBCVFERDPOOP4FK7MTBXDPZZA' }
49
+ else
50
+ { fee: 10 * 1_000_000,
51
+ sink: 'NAMESPACEWH4MKFMBCVFERDPOOP4FK7MTBXDPZZA' }
52
+ end
53
+ else
54
+ if root?
55
+ { fee: 100 * 1_000_000,
56
+ sink: 'TAMESPACEWH4MKFMBCVFERDPOOP4FK7MTDJEYP35' }
57
+ else
58
+ { fee: 10 * 1_000_000,
59
+ sink: 'TAMESPACEWH4MKFMBCVFERDPOOP4FK7MTDJEYP35' }
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,63 @@
1
+ module Nem
2
+ module Transaction
3
+ # @attr [Integer] amount
4
+ # @attr [String] recipient
5
+ # @attr [Nem::Model::Message] message
6
+ # @attr [Array <Nem::Model::MosaicId>] mosaics
7
+ # @see https://nemproject.github.io/#transferTransaction
8
+ # @see https://nemproject.github.io/#initiating-a-transfer-transaction
9
+ # @see https://nemproject.github.io/#version-1-transfer-transactions
10
+ # @see https://nemproject.github.io/#version-2-transfer-transactions
11
+ class Transfer < Nem::Transaction::Base
12
+ TYPE = 0x0101 # 257 (transfer transaction)
13
+
14
+ attr_reader :amount, :recipient, :message, :mosaics
15
+
16
+ def initialize(recipient, amount, message = '', mosaics: [], network: nil)
17
+ @amount = amount
18
+ @recipient = recipient
19
+ @message = message.is_a?(Nem::Model::Message) ?
20
+ message :
21
+ Nem::Model::Message.new(message.to_s)
22
+ @mosaics = mosaics
23
+
24
+ @network = network || Nem.default_network
25
+ @type = TYPE
26
+ @fee = Nem::Fee::Transfer.new(self)
27
+ end
28
+
29
+ def has_message?
30
+ @message.bytesize > 0
31
+ end
32
+
33
+ def has_mosaics?
34
+ @mosaics.size > 0
35
+ end
36
+
37
+ def version
38
+ network(hex: true) + (has_mosaics? ? 2 : 1)
39
+ end
40
+
41
+ # attributes must be CAMEL CASE for NIS params
42
+ def to_hash
43
+ tmp = {
44
+ amount: amount * 1_000_000,
45
+ recipient: recipient,
46
+ message: message.to_hash
47
+ }
48
+ unless mosaics.empty?
49
+ tmp[:mosaics] = mosaics.map do |moa|
50
+ {
51
+ mosaicId: {
52
+ namespaceId: moa.mosaic_id.namespace_id,
53
+ name: moa.mosaic_id.name,
54
+ },
55
+ quantity: moa.amount
56
+ }
57
+ end
58
+ end
59
+ tmp
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+ module Nem::Util
3
+ NEM_EPOCH = Time.utc(2015, 3, 29, 0, 6, 25, 0)
4
+
5
+ TESTNET = 0x98000000 # -1744830464
6
+ MAINNET = 0x68000000 # 1744830464
7
+ MIJIN = 0x60000000
8
+
9
+ VERSION_1 = 0x00000001 # 1
10
+ VERSION_2 = 0x00000002 # 2
11
+
12
+ TESTNET_VERSION_1 = TESTNET | VERSION_1 # 0x98000001 = -1744830463
13
+ TESTNET_VERSION_2 = TESTNET | VERSION_2 # 0x98000002 = -1744830462
14
+ MAINNET_VERSION_1 = MAINNET | VERSION_1 # 0x68000001 = 1744830465
15
+ MAINNET_VERSION_2 = MAINNET | VERSION_2 # 0x68000002 = 1744830466
16
+
17
+ def self.parse_version(network, version)
18
+ parse_network(network) | version
19
+ end
20
+
21
+ def self.parse_network(network)
22
+ case network
23
+ when :testnet then TESTNET
24
+ when :mainnet then MAINNET
25
+ when :mijin then MIJIN
26
+ else TESTNET
27
+ end
28
+ end
29
+
30
+ def self.parse_nemtime(nemtime)
31
+ NEM_EPOCH + nemtime
32
+ end
33
+
34
+ def self.deadline(seconds = 3600)
35
+ timestamp + seconds
36
+ end
37
+
38
+ def self.timestamp
39
+ # escape FAILURE_TIMESTAMP_TOO_FAR_IN_FUTURE
40
+ (Time.now.utc - NEM_EPOCH).to_i - 30
41
+ end
42
+ end
43
+
44
+ Dir.glob(File.expand_path('util/*.rb', __dir__)).each { |f| require f }