nis-ruby 0.0.10 → 0.0.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +27 -9
  3. data/lib/nis.rb +2 -0
  4. data/lib/nis/endpoint/node/experiences.rb +3 -1
  5. data/lib/nis/mixin.rb +1 -0
  6. data/lib/nis/mixin/network.rb +20 -0
  7. data/lib/nis/struct/block.rb +1 -0
  8. data/lib/nis/struct/extended_node_experience_pair.rb +1 -0
  9. data/lib/nis/struct/mosaic_properties.rb +3 -3
  10. data/lib/nis/transaction.rb +1 -0
  11. data/lib/nis/{struct/importance_transfer_transaction.rb → transaction/importance_transfer.rb} +18 -11
  12. data/lib/nis/{struct/mosaic_definition_creation_transaction.rb → transaction/mosaic_definition_creation.rb} +10 -21
  13. data/lib/nis/{struct/mosaic_supply_change_transaction.rb → transaction/mosaic_supply_change.rb} +11 -21
  14. data/lib/nis/{struct/multisig_transaction.rb → transaction/multisig.rb} +10 -21
  15. data/lib/nis/{struct/multisig_aggregate_modification_transaction.rb → transaction/multisig_aggregate_modification.rb} +11 -21
  16. data/lib/nis/{struct/multisig_signature_transaction.rb → transaction/multisig_signature.rb} +12 -12
  17. data/lib/nis/{struct/provision_namespace_transaction.rb → transaction/provision_namespace.rb} +10 -21
  18. data/lib/nis/{struct/transfer_transaction.rb → transaction/transfer.rb} +12 -17
  19. data/lib/nis/version.rb +1 -1
  20. data/samples/request_block.rb +3 -3
  21. data/samples/request_debug.rb +0 -1
  22. data/samples/request_importance_transfer_transaction.rb +5 -7
  23. data/samples/request_local.rb +8 -4
  24. data/samples/request_mosaic_definition_creation_transaction.rb +7 -8
  25. data/samples/request_mosaic_supply_change_transaction.rb +8 -11
  26. data/samples/request_multisig_add_cosignatory_transaction.rb +10 -12
  27. data/samples/request_multisig_aggregate_modification_transaction.rb +6 -7
  28. data/samples/request_multisig_signature_transaction.rb +5 -11
  29. data/samples/request_multisig_transaction.rb +8 -10
  30. data/samples/request_namespace.rb +4 -3
  31. data/samples/request_node.rb +18 -8
  32. data/samples/request_provision_namespace_transaction.rb +7 -10
  33. data/samples/request_transfer_transaction.rb +1 -2
  34. metadata +13 -11
  35. data/samples/request_transaction.rb +0 -48
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4287fd9c5da8d0d63e15449b9aaf58ff283040b8
4
- data.tar.gz: c0aeef4e827e1161a8868227dd48cde26ab131fb
3
+ metadata.gz: b71820d8d2ab72e1c4ddc2777939b2099a2ff716
4
+ data.tar.gz: 7bf8eef6eeed3ead69f68e40d3ffa1c63d8f3077
5
5
  SHA512:
6
- metadata.gz: 928f54fe0c8d1013df7efcecd068b386a189a973a5715b54d85057d406c3a04097bb642af3ab718985630587efac8bcde0d6d213b04eb539d2ad6ee4351a1b84
7
- data.tar.gz: d231b8271bfbb964fe205ade11e8fb9388224255ad1316ff63a3e56a309631d8c75a1facd2cd8e0551ce23a97cae47a364c960347894f0e47777154f5c81d5e7
6
+ metadata.gz: 891cdec923af05c61c85c9af8aa644cd2fb5ed5508bea4505ce5ebd5a93896706c91f502518079fd7da8494c02d8c4fb4819446c52e4d8b9115eafab84a3787f
7
+ data.tar.gz: af8eb1fa70b6d3e5b098b31e5969904598ff72956748d3f70e3e1dc496f8e49164a8bc3201839cbe38639a74b54a33f3d785f036e44ff6d405cdc1124219c21a
data/README.md CHANGED
@@ -29,7 +29,7 @@ gem 'nis-ruby'
29
29
 
30
30
  ## Usage
31
31
 
32
- More specific demonstrations are in samples/ directory.
32
+ More specific sample codes are in **samples/** directory.
33
33
 
34
34
  ### Methods
35
35
 
@@ -43,6 +43,23 @@ nis.heartbeat
43
43
  nis.status
44
44
  # => {code: 6, type: 4, message: "status"}
45
45
  # See http://bob.nem.ninja/docs/#status-request
46
+
47
+ tx = Nis::Transaction::Transfer.new(
48
+ amount: 10_000_000,
49
+ recipient: RECIPIENT_ADDRESS,
50
+ signer: SENDER_PUBLIC_KEY,
51
+ message: Nis::Struct::Message.new('Hello'),
52
+ timeStamp: Nis::Util.timestamp,
53
+ deadline: Nis::Util.timestamp + 43_200,
54
+ version: Nis::Util::TESTNET_VERSION_1
55
+ )
56
+
57
+ rpa = Nis::Struct::RequestPrepareAnnounce.new(
58
+ transaction: tx,
59
+ privateKey: SENDER_PRIVATE_KEY
60
+ )
61
+
62
+ nis.transaction_prepare_announce(request_prepare_announce: rpa)
46
63
  ```
47
64
 
48
65
  ### Requesting
@@ -64,7 +81,7 @@ nis.request(:post, '/account/unlock',
64
81
 
65
82
  tx = {
66
83
  amount: 10_000_000,
67
- fee: 3_000_000,
84
+ fee: 1_000_000,
68
85
  recipient: 'TALICELCD3XPH4FFI5STGGNSNSWPOTG5E4DS2TOS',
69
86
  signer: 'a1aaca6c17a24252e674d155713cdf55996ad00175be4af02a20c67b59f9fe8a',
70
87
  message: {
@@ -72,9 +89,9 @@ tx = {
72
89
  type: 1
73
90
  },
74
91
  type: 0x0101, # 257
75
- timeStamp: (Time.now.to_i - 1_427_587_585),
76
- deadline: (Time.now.to_i - 1_427_587_585) + 43_200,
77
- version: -1_744_830_463 # testnet version 1
92
+ timeStamp: Nis::Util.timestamp,
93
+ deadline: Nis::Util.timestamp + 43_200,
94
+ version: Nis::Util::TESTNET_VERSION_1
78
95
  }
79
96
  puts nis.request! :post, 'transaction/prepare-announce', {
80
97
  transaction: tx,
@@ -124,10 +141,11 @@ Nis.new(url: 'http://bigalice3.nem.ninja:7890')
124
141
 
125
142
  ## TODO
126
143
 
127
- * Do more improvements.
128
- * Implementation Apostille
129
- * Implementation Mosaic
130
- * Implementation Encryption
144
+ * Do more improvements
145
+ * Mosaic transferring
146
+ * Encryption message
147
+ * Remote transaction
148
+
131
149
 
132
150
  ## Documentation
133
151
 
data/lib/nis.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  require 'nis/version'
2
+ require 'nis/mixin'
2
3
  require 'nis/util'
3
4
  require 'nis/client'
4
5
  require 'nis/endpoint'
5
6
  require 'nis/struct'
7
+ require 'nis/transaction'
6
8
  require 'nis/unit'
7
9
  require 'nis/error'
8
10
 
@@ -3,7 +3,9 @@ module Nis::Endpoint
3
3
  # @return [Nis::Struct::ExtendedNodeExperiencePair]
4
4
  # @see http://bob.nem.ninja/docs/#requesting-node-experiences
5
5
  def node_experiences
6
- Nis::Struct::ExtendedNodeExperiencePair.build request!(:get, '/node/experiences')
6
+ request!(:get, '/node/experiences') do |res|
7
+ res[:data].map { |enep| Nis::Struct::ExtendedNodeExperiencePair.build(enep) }
8
+ end
7
9
  end
8
10
  end
9
11
  end
data/lib/nis/mixin.rb ADDED
@@ -0,0 +1 @@
1
+ Dir[File.expand_path('../mixin/*.rb', __FILE__)].each { |f| require f }
@@ -0,0 +1,20 @@
1
+ class Nis
2
+ module Mixin
3
+ module Network
4
+ # @return [Integer]
5
+ def version
6
+ (0x0000000F & @version)
7
+ end
8
+
9
+ # @return [Boolean]
10
+ def testnet?
11
+ (0xFFFFFFF0 & @version) == Nis::Util::TESTNET
12
+ end
13
+
14
+ # @return [Boolean]
15
+ def mainnet?
16
+ (0xFFFFFFF0 & @version) == Nis::Util::MAINNET
17
+ end
18
+ end
19
+ end
20
+ end
@@ -18,6 +18,7 @@ class Nis::Struct
18
18
  alias :prev_block_hash= :prevBlockHash=
19
19
 
20
20
  def self.build(attrs)
21
+ attrs[:transactions] = attrs[:transactions].map {|tx| Transaction.build(tx) }
21
22
  new(attrs)
22
23
  end
23
24
  end
@@ -8,6 +8,7 @@ class Nis::Struct
8
8
  attr_accessor :node, :syncs, :experiences
9
9
 
10
10
  def self.build(attrs)
11
+ attrs[:node] = Node.build(attrs[:node])
11
12
  new(attrs)
12
13
  end
13
14
  end
@@ -31,13 +31,13 @@ class Nis::Struct
31
31
  [{
32
32
  name: 'divisibility',
33
33
  value: divisibility.to_s
34
- },{
34
+ }, {
35
35
  name: 'initialSupply',
36
36
  value: initial_supply.to_s
37
- },{
37
+ }, {
38
38
  name: 'supplyMutable',
39
39
  value: supply_mutable ? 'true' : 'false'
40
- },{
40
+ }, {
41
41
  name: 'transferable',
42
42
  value: transferable ? 'true' : 'false'
43
43
  }]
@@ -0,0 +1 @@
1
+ Dir[File.expand_path('../transaction/*.rb', __FILE__)].each { |f| require f }
@@ -1,4 +1,4 @@
1
- class Nis::Struct
1
+ class Nis::Transaction
2
2
  # @attr [Integer] timeStamp
3
3
  # @attr [String] signature
4
4
  # @attr [Integer] fee
@@ -9,9 +9,12 @@ class Nis::Struct
9
9
  # @attr [Integer] version
10
10
  # @attr [String] signer
11
11
  # @see http://bob.nem.ninja/docs/#importanceTransferTransaction
12
- class ImportanceTransferTransaction
12
+ class ImportanceTransfer
13
+ include Nis::Mixin::Network
14
+ attr_writer :version, :fee
15
+
13
16
  include Nis::Util::Assignable
14
- attr_accessor :timeStamp, :signature, :fee, :mode, :remoteAccount, :type, :deadline, :version, :signer
17
+ attr_accessor :timeStamp, :signature, :mode, :remoteAccount, :type, :deadline, :signer
15
18
 
16
19
  alias timestamp timeStamp
17
20
  alias timestamp= timeStamp=
@@ -19,6 +22,7 @@ class Nis::Struct
19
22
  alias remote_account= remoteAccount=
20
23
 
21
24
  TYPE = 0x0801 # 2049 (importance transfer transaction)
25
+ FEE = 6_000_000
22
26
 
23
27
  ACTIVATE = 0x0001
24
28
  DEACTIVATE = 0x0002
@@ -28,18 +32,21 @@ class Nis::Struct
28
32
  end
29
33
 
30
34
  # @return [Integer]
31
- def _version
32
- (0xFFFFFFF0 & @version)
35
+ def type
36
+ @type ||= TYPE
33
37
  end
34
38
 
35
- # @return [Boolean]
36
- def testnet?
37
- (0x0000000F & @version) == Nis::Util::TESTNET
39
+ # @return [Integer]
40
+ def fee
41
+ @fee ||= FEE
38
42
  end
39
43
 
40
- # @return [Boolean]
41
- def mainnet?
42
- (0x0000000F & @version) == Nis::Util::MAINNET
44
+ alias to_hash_old to_hash
45
+
46
+ def to_hash
47
+ type
48
+ fee
49
+ to_hash_old
43
50
  end
44
51
  end
45
52
  end
@@ -1,4 +1,4 @@
1
- class Nis::Struct
1
+ class Nis::Transaction
2
2
  # @attr [Integer] timeStamp
3
3
  # @attr [Integer] signature
4
4
  # @attr [Integer] fee
@@ -10,9 +10,12 @@ class Nis::Struct
10
10
  # @attr [Integer] creationFeeSink
11
11
  # @attr [Nis::Struct::MosaicDefinition] mosaicDefinition
12
12
  # @see http://bob.nem.ninja/docs/#mosaicDefinitionCreationTransaction
13
- class MosaicDefinitionCreationTransaction
13
+ class MosaicDefinitionCreation
14
+ include Nis::Mixin::Network
15
+ attr_writer :version, :fee
16
+
14
17
  include Nis::Util::Assignable
15
- attr_accessor :timeStamp, :signature, :fee, :type, :deadline, :version, :signer,
18
+ attr_accessor :timeStamp, :signature, :type, :deadline, :signer,
16
19
  :creationFee, :creationFeeSink, :mosaicDefinition
17
20
 
18
21
  alias timestamp timeStamp
@@ -32,35 +35,21 @@ class Nis::Struct
32
35
  end
33
36
 
34
37
  # @return [Integer]
35
- def _version
36
- (0xFFFFFFF0 & @version)
37
- end
38
-
39
- # @return [Boolean]
40
- def testnet?
41
- (0x0000000F & @version) == TESTNET
42
- end
43
-
44
- # @return [Boolean]
45
- def mainnet?
46
- (0x0000000F & @version) == MAINNET
38
+ def type
39
+ @type ||= TYPE
47
40
  end
48
41
 
49
42
  # @return [Integer]
50
43
  def fee
51
- @fee ||= calculate_fee
44
+ @fee ||= FEE
52
45
  end
53
46
 
54
47
  alias to_hash_old to_hash
55
48
 
56
49
  def to_hash
50
+ type
57
51
  fee
58
52
  to_hash_old
59
53
  end
60
-
61
- # @return [Integer]
62
- def calculate_fee
63
- FEE
64
- end
65
54
  end
66
55
  end
@@ -1,4 +1,4 @@
1
- class Nis::Struct
1
+ class Nis::Transaction
2
2
  # @attr [Integer] timeStamp
3
3
  # @attr [Integer] signature
4
4
  # @attr [Integer] fee
@@ -7,9 +7,12 @@ class Nis::Struct
7
7
  # @attr [Integer] version
8
8
  # @attr [String] signer
9
9
  # @see http://bob.nem.ninja/docs/#mosaicSupplyChangeTransaction
10
- class MosaicSupplyChangeTransaction
10
+ class MosaicSupplyChange
11
+ include Nis::Mixin::Network
12
+ attr_writer :version, :fee
13
+
11
14
  include Nis::Util::Assignable
12
- attr_accessor :timeStamp, :signature, :fee, :type, :deadline, :version, :signer,
15
+ attr_accessor :timeStamp, :signature, :type, :deadline, :signer,
13
16
  :supplyType, :delta, :mosaicId
14
17
 
15
18
  alias timestamp timeStamp
@@ -21,6 +24,7 @@ class Nis::Struct
21
24
 
22
25
  TYPE = 0x4002 # 16386 (mosaic supply change transaction)
23
26
  FEE = 20_000_000
27
+
24
28
  INCREASE = 1
25
29
  DECREASE = 2
26
30
 
@@ -29,35 +33,21 @@ class Nis::Struct
29
33
  end
30
34
 
31
35
  # @return [Integer]
32
- def _version
33
- (0xFFFFFFF0 & @version)
34
- end
35
-
36
- # @return [Boolean]
37
- def testnet?
38
- (0x0000000F & @version) == TESTNET
39
- end
40
-
41
- # @return [Boolean]
42
- def mainnet?
43
- (0x0000000F & @version) == MAINNET
36
+ def type
37
+ @type ||= TYPE
44
38
  end
45
39
 
46
40
  # @return [Integer]
47
41
  def fee
48
- @fee ||= calculate_fee
42
+ @fee ||= FEE
49
43
  end
50
44
 
51
45
  alias to_hash_old to_hash
52
46
 
53
47
  def to_hash
48
+ type
54
49
  fee
55
50
  to_hash_old
56
51
  end
57
-
58
- # @return [Integer]
59
- def calculate_fee
60
- FEE
61
- end
62
52
  end
63
53
  end
@@ -1,4 +1,4 @@
1
- class Nis::Struct
1
+ class Nis::Transaction
2
2
  # @attr [Integer] timeStamp
3
3
  # @attr [Integer] fee
4
4
  # @attr [Integer] type
@@ -7,9 +7,12 @@ class Nis::Struct
7
7
  # @attr [String] signer
8
8
  # @attr [Nis::Struct::TransferTransaction] otherTrans
9
9
  # @see http://bob.nem.ninja/docs/#multisigTransaction
10
- class MultisigTransaction
10
+ class Multisig
11
+ include Nis::Mixin::Network
12
+ attr_writer :version, :fee
13
+
11
14
  include Nis::Util::Assignable
12
- attr_accessor :timeStamp, :fee, :type, :deadline, :version, :signer,
15
+ attr_accessor :timeStamp, :type, :deadline, :signer,
13
16
  :otherTrans
14
17
 
15
18
  alias timestamp timeStamp
@@ -25,23 +28,13 @@ class Nis::Struct
25
28
  end
26
29
 
27
30
  # @return [Integer]
28
- def _version
29
- (0xFFFFFFF0 & @version)
30
- end
31
-
32
- # @return [Boolean]
33
- def testnet?
34
- (0x0000000F & @version) == TESTNET
35
- end
36
-
37
- # @return [Boolean]
38
- def mainnet?
39
- (0x0000000F & @version) == MAINNET
31
+ def type
32
+ @type ||= TYPE
40
33
  end
41
34
 
42
35
  # @return [Integer]
43
36
  def fee
44
- @fee ||= calculate_fee
37
+ @fee ||= FEE
45
38
  end
46
39
 
47
40
  def mosaics
@@ -51,13 +44,9 @@ class Nis::Struct
51
44
  alias to_hash_old to_hash
52
45
 
53
46
  def to_hash
47
+ type
54
48
  fee
55
49
  to_hash_old
56
50
  end
57
-
58
- # @return [Integer]
59
- def calculate_fee
60
- FEE
61
- end
62
51
  end
63
52
  end
@@ -1,4 +1,4 @@
1
- class Nis::Struct
1
+ class Nis::Transaction
2
2
  # @attr [Integer] timeStamp
3
3
  # @attr [String] signature
4
4
  # @attr [Integer] fee
@@ -9,9 +9,12 @@ class Nis::Struct
9
9
  # @attr [Array <Nis::Struct::MultisigCosignatoryModification>] modifications
10
10
  # @attr [Hash] minCosignatories
11
11
  # @see http://bob.nem.ninja/docs/#multisigAggregateModificationTransaction
12
- class MultisigAggregateModificationTransaction
12
+ class MultisigAggregateModification
13
+ include Nis::Mixin::Network
14
+ attr_writer :version, :fee
15
+
13
16
  include Nis::Util::Assignable
14
- attr_accessor :timeStamp, :signature, :fee, :type, :deadline, :version, :signer,
17
+ attr_accessor :timeStamp, :signature, :type, :deadline, :signer,
15
18
  :modifications, :minCosignatories
16
19
 
17
20
  alias timestamp timeStamp
@@ -27,34 +30,21 @@ class Nis::Struct
27
30
  end
28
31
 
29
32
  # @return [Integer]
30
- def _version
31
- (0xFFFFFFF0 & @version)
32
- end
33
-
34
- # @return [Boolean]
35
- def testnet?
36
- (0x0000000F & @version) == Nis::Util::TESTNET
37
- end
38
-
39
- # @return [Boolean]
40
- def mainnet?
41
- (0x0000000F & @version) == Nis::Util::MAINNET
33
+ def type
34
+ @type ||= TYPE
42
35
  end
43
36
 
37
+ # @return [Integer]
44
38
  def fee
45
- @fee ||= calculate_fee
39
+ @fee ||= FEE
46
40
  end
47
41
 
48
42
  alias to_hash_old to_hash
49
43
 
50
44
  def to_hash
45
+ type
51
46
  fee
52
47
  to_hash_old
53
48
  end
54
-
55
- # @return [Integer]
56
- def calculate_fee
57
- FEE
58
- end
59
49
  end
60
50
  end
@@ -1,4 +1,4 @@
1
- class Nis::Struct
1
+ class Nis::Transaction
2
2
  # @attr [Integer] timeStamp
3
3
  # @attr [String] signature
4
4
  # @attr [Integer] fee
@@ -9,9 +9,12 @@ class Nis::Struct
9
9
  # @attr [String] otherHash
10
10
  # @attr [String] otherAccount
11
11
  # @see http://bob.nem.ninja/docs/#multisigSignatureTransaction
12
- class MultisigSignatureTransaction
12
+ class MultisigSignature
13
+ include Nis::Mixin::Network
14
+ attr_writer :version, :fee
15
+
13
16
  include Nis::Util::Assignable
14
- attr_accessor :timeStamp, :signature, :fee, :type, :deadline, :version, :signer,
17
+ attr_accessor :timeStamp, :signature, :type, :deadline, :signer,
15
18
  :otherHash, :otherAccount
16
19
 
17
20
  alias timestamp timeStamp
@@ -28,18 +31,15 @@ class Nis::Struct
28
31
  end
29
32
 
30
33
  # @return [Integer]
31
- def _version
32
- (0xFFFFFFF0 & @version)
34
+ def type
35
+ @type ||= TYPE
33
36
  end
34
37
 
35
- # @return [Boolean]
36
- def testnet?
37
- (0x0000000F & @version) == Nis::Util::TESTNET
38
- end
38
+ alias to_hash_old to_hash
39
39
 
40
- # @return [Boolean]
41
- def mainnet?
42
- (0x0000000F & @version) == Nis::Util::MAINNET
40
+ def to_hash
41
+ type
42
+ to_hash_old
43
43
  end
44
44
  end
45
45
  end
@@ -1,4 +1,4 @@
1
- class Nis::Struct
1
+ class Nis::Transaction
2
2
  # @attr [Integer] timeStamp
3
3
  # @attr [String] signature
4
4
  # @attr [Integer] fee
@@ -11,9 +11,12 @@ class Nis::Struct
11
11
  # @attr [String] newPart
12
12
  # @attr [String] parent
13
13
  # @see http://bob.nem.ninja/docs/#provisionNamespaceTransaction
14
- class ProvisionNamespaceTransaction
14
+ class ProvisionNamespace
15
+ include Nis::Mixin::Network
16
+ attr_writer :version, :fee
17
+
15
18
  include Nis::Util::Assignable
16
- attr_accessor :timeStamp, :signature, :fee, :type, :deadline, :version, :signer,
19
+ attr_accessor :timeStamp, :signature, :type, :deadline, :signer,
17
20
  :rentalFeeSink, :rentalFee, :newPart, :parent
18
21
 
19
22
  alias timestamp timeStamp
@@ -33,35 +36,21 @@ class Nis::Struct
33
36
  end
34
37
 
35
38
  # @return [Integer]
36
- def _version
37
- (0xFFFFFFF0 & @version)
38
- end
39
-
40
- # @return [Boolean]
41
- def testnet?
42
- (0x0000000F & @version) == Nis::Util::TESTNET
43
- end
44
-
45
- # @return [Boolean]
46
- def mainnet?
47
- (0x0000000F & @version) == Nis::Util::MAINNET
39
+ def type
40
+ @type ||= TYPE
48
41
  end
49
42
 
50
43
  # @return [Integer]
51
44
  def fee
52
- @fee ||= calculate_fee
45
+ @fee ||= FEE
53
46
  end
54
47
 
55
48
  alias to_hash_old to_hash
56
49
 
57
50
  def to_hash
51
+ type
58
52
  fee
59
53
  to_hash_old
60
54
  end
61
-
62
- # @return [Integer]
63
- def calculate_fee
64
- FEE
65
- end
66
55
  end
67
56
  end
@@ -1,4 +1,4 @@
1
- class Nis::Struct
1
+ class Nis::Transaction
2
2
  # @attr [Integer] timestamp
3
3
  # @attr [Integer] amount
4
4
  # @attr [Integer] fee
@@ -13,33 +13,27 @@ class Nis::Struct
13
13
  # @see http://bob.nem.ninja/docs/#initiating-a-transfer-transaction
14
14
  # @see http://bob.nem.ninja/docs/#version-1-transfer-transactions
15
15
  # @see http://bob.nem.ninja/docs/#version-2-transfer-transactions
16
- class TransferTransaction
16
+ class Transfer
17
+ include Nis::Mixin::Network
18
+ attr_writer :version, :fee
19
+
17
20
  include Nis::Util::Assignable
18
- attr_accessor :timeStamp, :amount, :fee, :recipient, :type, :deadline, :message, :version, :signer,
21
+ attr_accessor :timeStamp, :amount, :recipient, :type, :deadline, :message, :signer,
19
22
  :mosaics
20
23
 
21
24
  alias :timestamp :timeStamp
22
25
  alias :timestamp= :timeStamp=
23
26
 
24
27
  TYPE = 0x0101 # 257 (transfer transaction)
28
+ FEE = 25
25
29
 
26
30
  def self.build(attrs)
27
31
  new(attrs)
28
32
  end
29
33
 
30
34
  # @return [Integer]
31
- def _version
32
- (0xFFFFFFF0 & @version)
33
- end
34
-
35
- # @return [Boolean]
36
- def testnet?
37
- (0x0000000F & @version) == Nis::Util::TESTNET
38
- end
39
-
40
- # @return [Boolean]
41
- def mainnet?
42
- (0x0000000F & @version) == Nis::Util::MAINNET
35
+ def type
36
+ @type ||= TYPE
43
37
  end
44
38
 
45
39
  # @return [Integer]
@@ -54,6 +48,7 @@ class Nis::Struct
54
48
  alias to_hash_old to_hash
55
49
 
56
50
  def to_hash
51
+ type
57
52
  fee
58
53
  to_hash_old
59
54
  end
@@ -62,11 +57,11 @@ class Nis::Struct
62
57
  def calculate_fee
63
58
  if mosaics.empty?
64
59
  tmp_fee = [1, amount / 1_000_000 / 10_000].max
65
- fee = (tmp_fee > 25 ? 25 : tmp_fee)
60
+ fee = (tmp_fee > FEE ? FEE : tmp_fee)
66
61
  else
67
62
  # TODO: calc mosaics fee
68
63
  raise NotImplementedError, 'not implemented calculation mosaic fee.'
69
- fee = 25
64
+ fee = FEE
70
65
  end
71
66
 
72
67
  if message.bytesize > 0
data/lib/nis/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Nis
2
- VERSION = '0.0.10'.freeze
2
+ VERSION = '0.0.11.1'.freeze
3
3
  end
@@ -1,11 +1,11 @@
1
1
  require 'nis'
2
2
  hr = '-' * 64
3
3
 
4
- # create NIS instance
5
4
  nis = Nis.new
6
5
 
7
- puts nis.block_at_public(block_height: 895492)
6
+ block = nis.block_at_public(block_height: 890761)
7
+ puts block.to_hash
8
8
  puts hr
9
9
 
10
- puts nis.block_get(block_hash: '74998229fa8a6eebfce9bcc313c552528bf82caac6166ae05e65578b4fb1f2da')
10
+ puts nis.block_get(block_hash: 'fb5e76bf137eb27451926d29fd2b308e672e5d9ec405d9cbcd47cc0f83492cd0')
11
11
  puts hr
@@ -2,7 +2,6 @@ require 'pp'
2
2
  require 'nis'
3
3
  hr = '-' * 64
4
4
 
5
- # create NIS instance
6
5
  nis = Nis.new
7
6
 
8
7
  incoming = nis.debug_connections_incoming
@@ -10,15 +10,13 @@ A_PUBLIC_KEY = '5aff2e991f85d44eed8f449ede365a920abbefc22f1a2f731d4a00225867351
10
10
  B_PUBLIC_KEY = 'cc6c9485d15b992501e57fe3799487e99de272f79c5442de94eeb998b45e0144'.freeze
11
11
 
12
12
  # build Transaction Object
13
- tx = Nis::Struct::ImportanceTransferTransaction.new(
14
- timeStamp: Nis::Util.timestamp,
15
- fee: 6_000_000,
16
- mode: Nis::Struct::ImportanceTransferTransaction::ACTIVATE,
13
+ tx = Nis::Transaction::ImportanceTransfer.new(
14
+ mode: Nis::Transaction::ImportanceTransfer::ACTIVATE,
17
15
  remoteAccount: B_PUBLIC_KEY,
18
- type: Nis::Struct::ImportanceTransferTransaction::TYPE,
16
+ signer: A_PUBLIC_KEY,
17
+ timeStamp: Nis::Util.timestamp,
19
18
  deadline: Nis::Util.timestamp + 43_200,
20
- version: Nis::Util::TESTNET_VERSION_1,
21
- signer: A_PUBLIC_KEY
19
+ version: Nis::Util::TESTNET_VERSION_1
22
20
  )
23
21
 
24
22
  # build RequestPrepareAnnounce Object
@@ -7,14 +7,18 @@ page = Nis::Struct::AccountPrivateKeyTransactionsPage.new(
7
7
  value: '00b4a68d16dc505302e9631b860664ba43a8183f0903bc5782a2403b2f9eb3c8a1'
8
8
  )
9
9
 
10
- puts nis.local_account_transfers_incoming(page: page)
10
+ incoming = nis.local_account_transfers_incoming(page: page)
11
+ puts incoming.last.to_hash
11
12
  puts hr
12
13
 
13
- puts nis.local_account_transfers_outgoing(page: page)
14
+ outgoing = nis.local_account_transfers_outgoing(page: page)
15
+ puts outgoing.last.to_hash
14
16
  puts hr
15
17
 
16
- puts nis.local_account_transfers_all(page: page)
18
+ all = nis.local_account_transfers_all(page: page)
19
+ puts all.last.to_hash
17
20
  puts hr
18
21
 
19
- puts nis.local_chain_blocks_after(block_height: 2649)
22
+ blocks = nis.local_chain_blocks_after(block_height: 2649)
23
+ puts blocks.last
20
24
  puts hr
@@ -8,7 +8,7 @@ A_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a003
8
8
 
9
9
  mosaic_id = Nis::Struct::MosaicId.new(
10
10
  namespaceId: 'kon',
11
- name: "teas"
11
+ name: 'teas'
12
12
  )
13
13
 
14
14
  properties = Nis::Struct::MosaicProperties.new(
@@ -37,15 +37,14 @@ definition = Nis::Struct::MosaicDefinition.new(
37
37
  )
38
38
 
39
39
  # build Transaction Object
40
- tx = Nis::Struct::MosaicDefinitionCreationTransaction.new(
41
- timeStamp: Nis::Util.timestamp,
42
- type: Nis::Struct::MosaicDefinitionCreationTransaction::TYPE,
43
- deadline: Nis::Util.timestamp + 43_200,
44
- version: Nis::Util::TESTNET_VERSION_1,
45
- signer: A_PUBLIC_KEY,
40
+ tx = Nis::Transaction::MosaicDefinitionCreation.new(
41
+ mosaicDefinition: definition,
46
42
  creationFee: 500_000_000,
47
43
  creationFeeSink: Nis::Util::MOSAIC_SINK[:testnet],
48
- mosaicDefinition: definition
44
+ signer: A_PUBLIC_KEY,
45
+ timeStamp: Nis::Util.timestamp,
46
+ deadline: Nis::Util.timestamp + 43_200,
47
+ version: Nis::Util::TESTNET_VERSION_1
49
48
  )
50
49
 
51
50
  # build RequestPrepareAnnounce Object
@@ -8,19 +8,18 @@ A_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a003
8
8
 
9
9
  mosaic_id = Nis::Struct::MosaicId.new(
10
10
  namespaceId: 'kon',
11
- name: "teas"
11
+ name: 'teas'
12
12
  )
13
13
 
14
14
  # build Transaction Object
15
- tx = Nis::Struct::MosaicSupplyChangeTransaction.new(
15
+ tx = Nis::Transaction::MosaicSupplyChange.new(
16
+ mosaicId: mosaic_id,
17
+ supplyType: Nis::Transaction::MosaicSupplyChange::INCREASE,
18
+ delta: 1_000,
19
+ signer: A_PUBLIC_KEY,
16
20
  timeStamp: Nis::Util.timestamp,
17
- type: Nis::Struct::MosaicSupplyChangeTransaction::TYPE,
18
21
  deadline: Nis::Util.timestamp + 43_200,
19
- version: Nis::Util::TESTNET_VERSION_1,
20
- signer: A_PUBLIC_KEY,
21
- supplyType: Nis::Struct::MosaicSupplyChangeTransaction::INCREASE,
22
- delta: 1_000,
23
- mosaicId: mosaic_id
22
+ version: Nis::Util::TESTNET_VERSION_1
24
23
  )
25
24
 
26
25
  # build RequestPrepareAnnounce Object
@@ -29,10 +28,8 @@ rpa = Nis::Struct::RequestPrepareAnnounce.new(
29
28
  privateKey: A_PRIVATE_KEY
30
29
  )
31
30
 
32
- # Create NIS instance
33
31
  nis = Nis.new
34
32
 
35
- # Send XEM request.
36
33
  res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
37
- puts res.inspect
34
+ puts res.to_hash
38
35
  puts hr
@@ -22,27 +22,25 @@ mcm = Nis::Struct::MultisigCosignatoryModification.new(
22
22
  )
23
23
 
24
24
  # build Transaction Object
25
- tx = Nis::Struct::MultisigAggregateModificationTransaction.new(
26
- timeStamp: Nis::Util.timestamp,
27
- type: Nis::Struct::MultisigAggregateModificationTransaction::TYPE,
28
- deadline: Nis::Util.timestamp + 43_200,
29
- version: Nis::Util::TESTNET_VERSION_1,
30
- signer: A_PUBLIC_KEY,
25
+ tx = Nis::Transaction::MultisigAggregateModification.new(
31
26
  modifications: [
32
27
  mcm
33
28
  ],
34
29
  minCosignatories: {
35
30
  relativeChange: 2
36
- }
31
+ },
32
+ signer: A_PUBLIC_KEY,
33
+ timeStamp: Nis::Util.timestamp,
34
+ deadline: Nis::Util.timestamp + 43_200,
35
+ version: Nis::Util::TESTNET_VERSION_1
37
36
  )
38
37
 
39
- mtx = Nis::Struct::MultisigTransaction.new(
40
- timeStamp: Nis::Util.timestamp,
38
+ mtx = Nis::Transaction::Multisig.new(
39
+ otherTrans: tx,
41
40
  signer: B_PUBLIC_KEY,
42
- type: Nis::Struct::MultisigTransaction::TYPE,
41
+ timeStamp: Nis::Util.timestamp,
43
42
  deadline: Nis::Util.timestamp + 43_200,
44
- version: Nis::Struct::Transaction::TESTNET_VERSION_1,
45
- otherTrans: tx
43
+ version: Nis::Util::TESTNET_VERSION_1
46
44
  )
47
45
 
48
46
  # build RequestPrepareAnnounce Object
@@ -17,18 +17,17 @@ mcm = Nis::Struct::MultisigCosignatoryModification.new(
17
17
  )
18
18
 
19
19
  # build Transaction Object
20
- tx = Nis::Struct::MultisigAggregateModificationTransaction.new(
21
- timeStamp: Nis::Util.timestamp,
22
- type: Nis::Struct::MultisigAggregateModificationTransaction::TYPE,
23
- deadline: Nis::Util.timestamp + 43_200,
24
- version: Nis::Util::TESTNET_VERSION_1,
25
- signer: A_PUBLIC_KEY,
20
+ tx = Nis::Transaction::MultisigAggregateModification.new(
26
21
  modifications: [
27
22
  mcm
28
23
  ],
29
24
  minCosignatories: {
30
25
  relativeChange: 1
31
- }
26
+ },
27
+ signer: A_PUBLIC_KEY,
28
+ timeStamp: Nis::Util.timestamp,
29
+ deadline: Nis::Util.timestamp + 43_200,
30
+ version: Nis::Util::TESTNET_VERSION_1
32
31
  )
33
32
 
34
33
  # build RequestPrepareAnnounce Object
@@ -16,8 +16,6 @@ C_ADDRESS = 'TA4TX6U5HG2MROAESH2JE5524T4ZOY2EQKQ6ELHF'.freeze
16
16
  C_PRIVATE_KEY = '1d13af2c31ee6fb0c3c7aaaea818d9b305dcadba130ba663fc42d9f25b24ded1'.freeze
17
17
  C_PUBLIC_KEY = '9e7ab2924cd1a3482df784db190614cfc8a33671f5d80a5b15a9c9e8b4d13933'.freeze
18
18
 
19
- require 'pry'
20
-
21
19
  nis = Nis.new
22
20
  txes = nis.account_unconfirmed_transactions(address: C_ADDRESS)
23
21
 
@@ -32,17 +30,13 @@ puts "Unconfirmed Transaction Hash: #{hash}"
32
30
  puts hr
33
31
 
34
32
  # build Transaction Object
35
- tx = Nis::Struct::MultisigSignatureTransaction.new(
33
+ tx = Nis::Transaction::MultisigSignature.new(
34
+ otherHash: { data: hash },
35
+ otherAccount: A_ADDRESS,
36
+ signer: C_PUBLIC_KEY,
36
37
  timeStamp: Nis::Util.timestamp,
37
- type: Nis::Struct::MultisigSignatureTransaction::TYPE,
38
38
  deadline: Nis::Util.timestamp + 43_200,
39
- version: Nis::Util::TESTNET_VERSION_1,
40
- signer: C_PUBLIC_KEY,
41
- fee: 6_000_000,
42
- otherHash: {
43
- data: hash
44
- },
45
- otherAccount: A_ADDRESS
39
+ version: Nis::Util::TESTNET_VERSION_1
46
40
  )
47
41
 
48
42
  # build RequestPrepareAnnounce Object
@@ -12,24 +12,22 @@ B_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b83421
12
12
  B_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
13
13
 
14
14
  # build Transaction Object
15
- tx = Nis::Struct::Transaction.new(
16
- amount: 10_000_000,
15
+ tx = Nis::Transaction::Transfer.new(
16
+ amount: 1_000_000,
17
17
  recipient: B_ADDRESS,
18
- signer: A_PUBLIC_KEY,
19
18
  message: Nis::Struct::Message.new('Hello'),
20
- type: Nis::Struct::Transaction::TRANSFER,
19
+ signer: A_PUBLIC_KEY,
21
20
  timeStamp: Nis::Util.timestamp,
22
21
  deadline: Nis::Util.timestamp + 43_200,
23
- version: Nis::Struct::Transaction::TESTNET_VERSION_1
22
+ version: Nis::Util::TESTNET_VERSION_1
24
23
  )
25
24
 
26
- mtx = Nis::Struct::MultisigTransaction.new(
27
- timeStamp: Nis::Util.timestamp,
25
+ mtx = Nis::Transaction::Multisig.new(
26
+ otherTrans: tx,
28
27
  signer: B_PUBLIC_KEY,
29
- type: Nis::Struct::MultisigTransaction::TYPE,
28
+ timeStamp: Nis::Util.timestamp,
30
29
  deadline: Nis::Util.timestamp + 43_200,
31
- version: Nis::Struct::Transaction::TESTNET_VERSION_1,
32
- otherTrans: tx
30
+ version: Nis::Util::TESTNET_VERSION_1
33
31
  )
34
32
 
35
33
  # automatically calculate minimum fee if fee is not set.
@@ -1,11 +1,12 @@
1
1
  require 'nis'
2
2
  hr = '-' * 64
3
3
 
4
- # create NIS instance
5
4
  nis = Nis.new
6
5
 
7
- puts nis.namespace_mosaic_definition_page(namespace: 'alice.misc')
6
+ ns_mosaics = nis.namespace_mosaic_definition_page(namespace: 'alice.misc')
7
+ puts ns_mosaics.first.to_hash
8
8
  puts hr
9
9
 
10
- puts nis.namespace_root_page
10
+ ns_root = nis.namespace_root_page
11
+ puts ns_root.first.to_hash
11
12
  puts hr
@@ -1,25 +1,30 @@
1
1
  require 'nis'
2
2
  hr = '-' * 64
3
3
 
4
- # create NIS instance
5
4
  nis = Nis.new
6
5
 
7
- puts nis.node_info
6
+ node_info = nis.node_info
7
+ puts node_info.to_hash
8
8
  puts hr
9
9
 
10
- puts nis.node_extended_info
10
+ ext_node_info = nis.node_extended_info
11
+ puts ext_node_info.to_hash
11
12
  puts hr
12
13
 
13
- puts nis.node_experiences
14
+ node_exp = nis.node_experiences
15
+ puts node_exp.first.to_hash
14
16
  puts hr
15
17
 
16
- puts nis.node_peerlist_all
18
+ peer_all = nis.node_peerlist_all
19
+ puts peer_all.to_hash
17
20
  puts hr
18
21
 
19
- puts nis.node_peerlist_reachable
22
+ reachables = nis.node_peerlist_reachable
23
+ puts reachables.first.to_hash
20
24
  puts hr
21
25
 
22
- puts nis.node_peerlist_active
26
+ actives = nis.node_peerlist_active
27
+ puts actives.first.to_hash
23
28
  puts hr
24
29
 
25
30
  puts nis.node_active_peers_max_chain_height
@@ -39,5 +44,10 @@ bnr = Nis::Struct::BootNodeRequest.new(
39
44
  name: 'Alice'
40
45
  }
41
46
  )
42
- puts nis.node_boot(boot_node_request: bnr)
47
+
48
+ begin
49
+ puts nis.node_boot(boot_node_request: bnr)
50
+ rescue => ex
51
+ puts ex
52
+ end
43
53
  puts hr
@@ -7,16 +7,15 @@ A_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b83421
7
7
  A_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
8
8
 
9
9
  # build Transaction Object
10
- tx = Nis::Struct::ProvisionNamespaceTransaction.new(
11
- timeStamp: Nis::Util.timestamp,
12
- type: Nis::Struct::ProvisionNamespaceTransaction::TYPE,
13
- deadline: Nis::Util.timestamp + 43_200,
14
- version: Nis::Util::TESTNET_VERSION_1,
15
- signer: A_PUBLIC_KEY,
10
+ tx = Nis::Transaction::ProvisionNamespace.new(
11
+ newPart: 'kon',
12
+ parent: nil,
16
13
  rentalFeeSink: Nis::Util::NAMESPACE_SINK[:testnet],
17
14
  rentalFee: 5_000_000_000,
18
- newPart: 'kon',
19
- parent: nil
15
+ signer: A_PUBLIC_KEY,
16
+ timeStamp: Nis::Util.timestamp,
17
+ deadline: Nis::Util.timestamp + 43_200,
18
+ version: Nis::Util::TESTNET_VERSION_1
20
19
  )
21
20
 
22
21
  # build RequestPrepareAnnounce Object
@@ -25,10 +24,8 @@ rpa = Nis::Struct::RequestPrepareAnnounce.new(
25
24
  privateKey: A_PRIVATE_KEY
26
25
  )
27
26
 
28
- # Create NIS instance
29
27
  nis = Nis.new
30
28
 
31
- # Send XEM request.
32
29
  res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
33
30
  puts res.message
34
31
  puts hr
@@ -10,11 +10,10 @@ A_PUBLIC_KEY = '5aff2e991f85d44eed8f449ede365a920abbefc22f1a2f731d4a00225867351
10
10
  B_ADDRESS = 'TA4TX6U5HG2MROAESH2JE5524T4ZOY2EQKQ6ELHF'.freeze
11
11
 
12
12
  # build Transaction Object
13
- tx = Nis::Struct::TransferTransaction.new(
13
+ tx = Nis::Transaction::Transfer.new(
14
14
  amount: 1_000_000,
15
15
  # fee: 3_000_000, # see below.
16
16
  recipient: B_ADDRESS,
17
- type: Nis::Struct::TransferTransaction::TYPE,
18
17
  signer: A_PUBLIC_KEY,
19
18
  message: Nis::Struct::Message.new('Hello'),
20
19
  timeStamp: Nis::Util.timestamp,
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.10
4
+ version: 0.0.11.1
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-06-13 00:00:00.000000000 Z
11
+ date: 2017-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -211,6 +211,8 @@ files:
211
211
  - lib/nis/endpoint/transaction/announce.rb
212
212
  - lib/nis/endpoint/transaction/prepareAnnounce.rb
213
213
  - lib/nis/error.rb
214
+ - lib/nis/mixin.rb
215
+ - lib/nis/mixin/network.rb
214
216
  - lib/nis/struct.rb
215
217
  - lib/nis/struct/account_importance_view_model.rb
216
218
  - lib/nis/struct/account_info.rb
@@ -230,22 +232,16 @@ files:
230
232
  - lib/nis/struct/explorer_view_model_transaction.rb
231
233
  - lib/nis/struct/extended_node_experience_pair.rb
232
234
  - lib/nis/struct/harvest_info.rb
233
- - lib/nis/struct/importance_transfer_transaction.rb
234
235
  - lib/nis/struct/key_pair_view_model.rb
235
236
  - lib/nis/struct/message.rb
236
237
  - lib/nis/struct/mosaic.rb
237
238
  - lib/nis/struct/mosaic_definition.rb
238
- - lib/nis/struct/mosaic_definition_creation_transaction.rb
239
239
  - lib/nis/struct/mosaic_definition_meta_data.rb
240
240
  - lib/nis/struct/mosaic_definition_meta_data_pair.rb
241
241
  - lib/nis/struct/mosaic_id.rb
242
242
  - lib/nis/struct/mosaic_levy.rb
243
243
  - lib/nis/struct/mosaic_properties.rb
244
- - lib/nis/struct/mosaic_supply_change_transaction.rb
245
- - lib/nis/struct/multisig_aggregate_modification_transaction.rb
246
244
  - lib/nis/struct/multisig_cosignatory_modification.rb
247
- - lib/nis/struct/multisig_signature_transaction.rb
248
- - lib/nis/struct/multisig_transaction.rb
249
245
  - lib/nis/struct/namespace.rb
250
246
  - lib/nis/struct/namespace_meta_data.rb
251
247
  - lib/nis/struct/namespace_meta_data_pair.rb
@@ -256,16 +252,23 @@ files:
256
252
  - lib/nis/struct/node.rb
257
253
  - lib/nis/struct/node_collection.rb
258
254
  - lib/nis/struct/node_experience.rb
259
- - lib/nis/struct/provision_namespace_transaction.rb
260
255
  - lib/nis/struct/request_announce.rb
261
256
  - lib/nis/struct/request_prepare_announce.rb
262
257
  - lib/nis/struct/time_synchronization_result.rb
263
258
  - lib/nis/struct/transaction.rb
264
259
  - lib/nis/struct/transaction_meta_data.rb
265
260
  - lib/nis/struct/transaction_meta_data_pair.rb
266
- - lib/nis/struct/transfer_transaction.rb
267
261
  - lib/nis/struct/unconfirmed_transaction_meta_data.rb
268
262
  - lib/nis/struct/unconfirmed_transaction_meta_data_pair.rb
263
+ - lib/nis/transaction.rb
264
+ - lib/nis/transaction/importance_transfer.rb
265
+ - lib/nis/transaction/mosaic_definition_creation.rb
266
+ - lib/nis/transaction/mosaic_supply_change.rb
267
+ - lib/nis/transaction/multisig.rb
268
+ - lib/nis/transaction/multisig_aggregate_modification.rb
269
+ - lib/nis/transaction/multisig_signature.rb
270
+ - lib/nis/transaction/provision_namespace.rb
271
+ - lib/nis/transaction/transfer.rb
269
272
  - lib/nis/unit.rb
270
273
  - lib/nis/unit/address.rb
271
274
  - lib/nis/unit/balance.rb
@@ -293,7 +296,6 @@ files:
293
296
  - samples/request_nis.rb
294
297
  - samples/request_node.rb
295
298
  - samples/request_provision_namespace_transaction.rb
296
- - samples/request_transaction.rb
297
299
  - samples/request_transfer_transaction.rb
298
300
  homepage: https://github.com/44uk/nis-ruby
299
301
  licenses:
@@ -1,48 +0,0 @@
1
- require 'nis'
2
- hr = '-' * 64
3
-
4
- # Account A (Source)
5
- A_ADDRESS = 'TAH4MBR6MNLZKJAVW5ZJCMFAL7RS5U2YODUQKLCT'.freeze
6
- A_PRIVATE_KEY = '00b4a68d16dc505302e9631b860664ba43a8183f0903bc5782a2403b2f9eb3c8a1'.freeze
7
- A_PUBLIC_KEY = '5aff2e991f85d44eed8f449ede365a920abbefc22f1a2f731d4a002258673519'.freeze
8
-
9
- # Account B (Dist)
10
- B_ADDRESS = 'TA4TX6U5HG2MROAESH2JE5524T4ZOY2EQKQ6ELHF'.freeze
11
-
12
- # build Transaction Object
13
- tx = Nis::Struct::Transaction.new(
14
- amount: 1_000_000,
15
- # fee: 3_000_000, # see below.
16
- recipient: B_ADDRESS,
17
- signer: A_PUBLIC_KEY,
18
- message: Nis::Struct::Message.new('Hello'),
19
- type: Nis::Struct::Transaction::TRANSFER,
20
- timeStamp: Nis::Util.timestamp,
21
- deadline: Nis::Util.timestamp + 43_200,
22
- version: Nis::Struct::Transaction::TESTNET_VERSION_1
23
- )
24
-
25
- # automatically calculate minimum fee if fee is not set.
26
- puts 'Fee: %d' % tx.fee
27
-
28
- # build RequestPrepareAnnounce Object
29
- rpa = Nis::Struct::RequestPrepareAnnounce.new(
30
- transaction: tx,
31
- privateKey: A_PRIVATE_KEY
32
- )
33
-
34
- # Create NIS instance
35
- nis = Nis.new
36
-
37
- # check banalces before sending XEM.
38
- puts 'Account A => balance: %d' %
39
- (nis.account_get address: A_ADDRESS)[:account][:balance]
40
- puts 'Account B => balance: %d' %
41
- (nis.account_get address: B_ADDRESS)[:account][:balance]
42
- puts hr
43
-
44
- # Send XEM request.
45
- res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
46
- puts res.message
47
-
48
- # After several minutes, check Account A and B Balance.