nis-ruby 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/nis/endpoint/account/unconfirmed_transactions.rb +1 -1
- data/lib/nis/endpoint/node/boot.rb +1 -1
- data/lib/nis/struct/boot_node_request.rb +4 -10
- data/lib/nis/struct/importance_transfer_transaction.rb +45 -0
- data/lib/nis/struct/mosaic_definition.rb +1 -1
- data/lib/nis/struct/mosaic_definition_creation_transaction.rb +66 -0
- data/lib/nis/struct/mosaic_properties.rb +16 -1
- data/lib/nis/struct/mosaic_supply_change_transaction.rb +63 -0
- data/lib/nis/struct/multisig_aggregate_modification_transaction.rb +60 -0
- data/lib/nis/struct/multisig_cosignatory_modification.rb +19 -0
- data/lib/nis/struct/multisig_signature_transaction.rb +45 -0
- data/lib/nis/struct/multisig_transaction.rb +63 -0
- data/lib/nis/struct/provision_namespace_transaction.rb +67 -0
- data/lib/nis/struct/transfer_transaction.rb +79 -0
- data/lib/nis/struct/unconfirmed_transaction_meta_data.rb +4 -0
- data/lib/nis/unit/address.rb +5 -0
- data/lib/nis/util.rb +29 -0
- data/lib/nis/version.rb +1 -1
- data/samples/request_importance_transfer_transaction.rb +36 -0
- data/samples/request_mosaic_definition_creation_transaction.rb +63 -0
- data/samples/request_mosaic_supply_change_transaction.rb +38 -0
- data/samples/request_multisig_add_cosignatory_transaction.rb +60 -0
- data/samples/request_multisig_aggregate_modification_transaction.rb +46 -0
- data/samples/request_multisig_signature_transaction.rb +59 -0
- data/samples/request_multisig_transaction.rb +56 -0
- data/samples/request_node.rb +16 -4
- data/samples/request_provision_namespace_transaction.rb +34 -0
- data/samples/request_transaction.rb +5 -2
- data/samples/request_transfer_transaction.rb +48 -0
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4287fd9c5da8d0d63e15449b9aaf58ff283040b8
|
4
|
+
data.tar.gz: c0aeef4e827e1161a8868227dd48cde26ab131fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 928f54fe0c8d1013df7efcecd068b386a189a973a5715b54d85057d406c3a04097bb642af3ab718985630587efac8bcde0d6d213b04eb539d2ad6ee4351a1b84
|
7
|
+
data.tar.gz: d231b8271bfbb964fe205ade11e8fb9388224255ad1316ff63a3e56a309631d8c75a1facd2cd8e0551ce23a97cae47a364c960347894f0e47777154f5c81d5e7
|
@@ -4,7 +4,7 @@ module Nis::Endpoint
|
|
4
4
|
# @return [nil]
|
5
5
|
# @see http://bob.nem.ninja/docs/#booting-the-local-node
|
6
6
|
def node_boot(boot_node_request:)
|
7
|
-
request!(:post, '/node/boot', boot_node_request
|
7
|
+
request!(:post, '/node/boot', boot_node_request)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -1,17 +1,11 @@
|
|
1
1
|
class Nis::Struct
|
2
|
-
# @attr [
|
3
|
-
# @attr [
|
4
|
-
# @attr [
|
5
|
-
# @attr [String] protocol
|
6
|
-
# @attr [String] port
|
7
|
-
# @attr [String] host
|
8
|
-
# @attr [String] identity
|
9
|
-
# @attr [String] private_key
|
10
|
-
# @attr [String] name
|
2
|
+
# @attr [Hash] metaData
|
3
|
+
# @attr [Hash] endpoint
|
4
|
+
# @attr [Hash] identity
|
11
5
|
# @see http://bob.nem.ninja/docs/#bootNodeRequest
|
12
6
|
class BootNodeRequest
|
13
7
|
include Nis::Util::Assignable
|
14
|
-
attr_accessor :metaData, :
|
8
|
+
attr_accessor :metaData, :endpoint, :identity
|
15
9
|
|
16
10
|
alias metadata metaData
|
17
11
|
alias metadata= metaData=
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Nis::Struct
|
2
|
+
# @attr [Integer] timeStamp
|
3
|
+
# @attr [String] signature
|
4
|
+
# @attr [Integer] fee
|
5
|
+
# @attr [Integer] mode
|
6
|
+
# @attr [String] remoteAccount
|
7
|
+
# @attr [Integer] type
|
8
|
+
# @attr [Integer] deadline
|
9
|
+
# @attr [Integer] version
|
10
|
+
# @attr [String] signer
|
11
|
+
# @see http://bob.nem.ninja/docs/#importanceTransferTransaction
|
12
|
+
class ImportanceTransferTransaction
|
13
|
+
include Nis::Util::Assignable
|
14
|
+
attr_accessor :timeStamp, :signature, :fee, :mode, :remoteAccount, :type, :deadline, :version, :signer
|
15
|
+
|
16
|
+
alias timestamp timeStamp
|
17
|
+
alias timestamp= timeStamp=
|
18
|
+
alias remote_account remoteAccount
|
19
|
+
alias remote_account= remoteAccount=
|
20
|
+
|
21
|
+
TYPE = 0x0801 # 2049 (importance transfer transaction)
|
22
|
+
|
23
|
+
ACTIVATE = 0x0001
|
24
|
+
DEACTIVATE = 0x0002
|
25
|
+
|
26
|
+
def self.build(attrs)
|
27
|
+
new(attrs)
|
28
|
+
end
|
29
|
+
|
30
|
+
# @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
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
class Nis::Struct
|
2
|
+
# @attr [Integer] timeStamp
|
3
|
+
# @attr [Integer] signature
|
4
|
+
# @attr [Integer] fee
|
5
|
+
# @attr [Integer] type
|
6
|
+
# @attr [Integer] deadline
|
7
|
+
# @attr [Integer] version
|
8
|
+
# @attr [String] signer
|
9
|
+
# @attr [Integer] creationFee
|
10
|
+
# @attr [Integer] creationFeeSink
|
11
|
+
# @attr [Nis::Struct::MosaicDefinition] mosaicDefinition
|
12
|
+
# @see http://bob.nem.ninja/docs/#mosaicDefinitionCreationTransaction
|
13
|
+
class MosaicDefinitionCreationTransaction
|
14
|
+
include Nis::Util::Assignable
|
15
|
+
attr_accessor :timeStamp, :signature, :fee, :type, :deadline, :version, :signer,
|
16
|
+
:creationFee, :creationFeeSink, :mosaicDefinition
|
17
|
+
|
18
|
+
alias timestamp timeStamp
|
19
|
+
alias timestamp= timeStamp=
|
20
|
+
alias creation_fee creationFee
|
21
|
+
alias creation_fee= creationFee=
|
22
|
+
alias creation_feeSink creationFeeSink
|
23
|
+
alias creation_feeSink= creationFeeSink=
|
24
|
+
alias mosaic_definition mosaicDefinition
|
25
|
+
alias mosaic_definition= mosaicDefinition=
|
26
|
+
|
27
|
+
TYPE = 0x4001 # 16385 (mosaic definition creation transaction)
|
28
|
+
FEE = 20_000_000
|
29
|
+
|
30
|
+
def self.build(attrs)
|
31
|
+
new(attrs)
|
32
|
+
end
|
33
|
+
|
34
|
+
# @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
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [Integer]
|
50
|
+
def fee
|
51
|
+
@fee ||= calculate_fee
|
52
|
+
end
|
53
|
+
|
54
|
+
alias to_hash_old to_hash
|
55
|
+
|
56
|
+
def to_hash
|
57
|
+
fee
|
58
|
+
to_hash_old
|
59
|
+
end
|
60
|
+
|
61
|
+
# @return [Integer]
|
62
|
+
def calculate_fee
|
63
|
+
FEE
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
class Nis::Struct
|
2
|
-
# @attr [Array] properties
|
3
2
|
# @attr [Integer] divisibility
|
4
3
|
# @attr [Integer] initialSupply
|
5
4
|
# @attr [Boolean] supplyMutable
|
@@ -27,5 +26,21 @@ class Nis::Struct
|
|
27
26
|
def transferable?
|
28
27
|
@transferable == 'true'
|
29
28
|
end
|
29
|
+
|
30
|
+
def to_hash
|
31
|
+
[{
|
32
|
+
name: 'divisibility',
|
33
|
+
value: divisibility.to_s
|
34
|
+
},{
|
35
|
+
name: 'initialSupply',
|
36
|
+
value: initial_supply.to_s
|
37
|
+
},{
|
38
|
+
name: 'supplyMutable',
|
39
|
+
value: supply_mutable ? 'true' : 'false'
|
40
|
+
},{
|
41
|
+
name: 'transferable',
|
42
|
+
value: transferable ? 'true' : 'false'
|
43
|
+
}]
|
44
|
+
end
|
30
45
|
end
|
31
46
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class Nis::Struct
|
2
|
+
# @attr [Integer] timeStamp
|
3
|
+
# @attr [Integer] signature
|
4
|
+
# @attr [Integer] fee
|
5
|
+
# @attr [Integer] type
|
6
|
+
# @attr [Integer] deadline
|
7
|
+
# @attr [Integer] version
|
8
|
+
# @attr [String] signer
|
9
|
+
# @see http://bob.nem.ninja/docs/#mosaicSupplyChangeTransaction
|
10
|
+
class MosaicSupplyChangeTransaction
|
11
|
+
include Nis::Util::Assignable
|
12
|
+
attr_accessor :timeStamp, :signature, :fee, :type, :deadline, :version, :signer,
|
13
|
+
:supplyType, :delta, :mosaicId
|
14
|
+
|
15
|
+
alias timestamp timeStamp
|
16
|
+
alias timestamp= timeStamp=
|
17
|
+
alias supply_type supplyType
|
18
|
+
alias supply_type= supplyType=
|
19
|
+
alias mosaid_id mosaicId
|
20
|
+
alias mosaid_id= mosaicId=
|
21
|
+
|
22
|
+
TYPE = 0x4002 # 16386 (mosaic supply change transaction)
|
23
|
+
FEE = 20_000_000
|
24
|
+
INCREASE = 1
|
25
|
+
DECREASE = 2
|
26
|
+
|
27
|
+
def self.build(attrs)
|
28
|
+
new(attrs)
|
29
|
+
end
|
30
|
+
|
31
|
+
# @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
|
44
|
+
end
|
45
|
+
|
46
|
+
# @return [Integer]
|
47
|
+
def fee
|
48
|
+
@fee ||= calculate_fee
|
49
|
+
end
|
50
|
+
|
51
|
+
alias to_hash_old to_hash
|
52
|
+
|
53
|
+
def to_hash
|
54
|
+
fee
|
55
|
+
to_hash_old
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return [Integer]
|
59
|
+
def calculate_fee
|
60
|
+
FEE
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class Nis::Struct
|
2
|
+
# @attr [Integer] timeStamp
|
3
|
+
# @attr [String] signature
|
4
|
+
# @attr [Integer] fee
|
5
|
+
# @attr [Integer] type
|
6
|
+
# @attr [Integer] deadline
|
7
|
+
# @attr [Integer] version
|
8
|
+
# @attr [String] signer
|
9
|
+
# @attr [Array <Nis::Struct::MultisigCosignatoryModification>] modifications
|
10
|
+
# @attr [Hash] minCosignatories
|
11
|
+
# @see http://bob.nem.ninja/docs/#multisigAggregateModificationTransaction
|
12
|
+
class MultisigAggregateModificationTransaction
|
13
|
+
include Nis::Util::Assignable
|
14
|
+
attr_accessor :timeStamp, :signature, :fee, :type, :deadline, :version, :signer,
|
15
|
+
:modifications, :minCosignatories
|
16
|
+
|
17
|
+
alias timestamp timeStamp
|
18
|
+
alias timestamp= timeStamp=
|
19
|
+
alias min_cosignatories minCosignatories
|
20
|
+
alias min_cosignatories= minCosignatories=
|
21
|
+
|
22
|
+
TYPE = 0x1001 # 4097 (multisig aggregate modification transfer transaction)
|
23
|
+
FEE = 16_000_000
|
24
|
+
|
25
|
+
def self.build(attrs)
|
26
|
+
new(attrs)
|
27
|
+
end
|
28
|
+
|
29
|
+
# @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
|
42
|
+
end
|
43
|
+
|
44
|
+
def fee
|
45
|
+
@fee ||= calculate_fee
|
46
|
+
end
|
47
|
+
|
48
|
+
alias to_hash_old to_hash
|
49
|
+
|
50
|
+
def to_hash
|
51
|
+
fee
|
52
|
+
to_hash_old
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [Integer]
|
56
|
+
def calculate_fee
|
57
|
+
FEE
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Nis::Struct
|
2
|
+
# @attr [Integer] modificationType
|
3
|
+
# @attr [String] cosignatoryAccount
|
4
|
+
# @see http://bob.nem.ninja/docs/#multisigCosignatoryModification
|
5
|
+
class MultisigCosignatoryModification
|
6
|
+
include Nis::Util::Assignable
|
7
|
+
attr_accessor :modificationType, :cosignatoryAccount
|
8
|
+
|
9
|
+
alias modification_type modificationType
|
10
|
+
alias cosignatory_account cosignatoryAccount
|
11
|
+
|
12
|
+
TYPE_ADD = 0x0001
|
13
|
+
TYPE_DELETE = 0x0002
|
14
|
+
|
15
|
+
def self.build(attrs)
|
16
|
+
new(attrs)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class Nis::Struct
|
2
|
+
# @attr [Integer] timeStamp
|
3
|
+
# @attr [String] signature
|
4
|
+
# @attr [Integer] fee
|
5
|
+
# @attr [Integer] type
|
6
|
+
# @attr [Integer] deadline
|
7
|
+
# @attr [Integer] version
|
8
|
+
# @attr [String] signer
|
9
|
+
# @attr [String] otherHash
|
10
|
+
# @attr [String] otherAccount
|
11
|
+
# @see http://bob.nem.ninja/docs/#multisigSignatureTransaction
|
12
|
+
class MultisigSignatureTransaction
|
13
|
+
include Nis::Util::Assignable
|
14
|
+
attr_accessor :timeStamp, :signature, :fee, :type, :deadline, :version, :signer,
|
15
|
+
:otherHash, :otherAccount
|
16
|
+
|
17
|
+
alias timestamp timeStamp
|
18
|
+
alias timestamp= timeStamp=
|
19
|
+
alias other_hash otherHash
|
20
|
+
alias other_hash= otherHash=
|
21
|
+
alias other_account otherAccount
|
22
|
+
alias other_account= otherAccount=
|
23
|
+
|
24
|
+
TYPE = 0x1002 # 4098 (multisig signature transaction)
|
25
|
+
|
26
|
+
def self.build(attrs)
|
27
|
+
new(attrs)
|
28
|
+
end
|
29
|
+
|
30
|
+
# @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
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class Nis::Struct
|
2
|
+
# @attr [Integer] timeStamp
|
3
|
+
# @attr [Integer] fee
|
4
|
+
# @attr [Integer] type
|
5
|
+
# @attr [Integer] deadline
|
6
|
+
# @attr [Integer] version
|
7
|
+
# @attr [String] signer
|
8
|
+
# @attr [Nis::Struct::TransferTransaction] otherTrans
|
9
|
+
# @see http://bob.nem.ninja/docs/#multisigTransaction
|
10
|
+
class MultisigTransaction
|
11
|
+
include Nis::Util::Assignable
|
12
|
+
attr_accessor :timeStamp, :fee, :type, :deadline, :version, :signer,
|
13
|
+
:otherTrans
|
14
|
+
|
15
|
+
alias timestamp timeStamp
|
16
|
+
alias timestamp= timeStamp=
|
17
|
+
alias other_trans otherTrans
|
18
|
+
alias other_trans= otherTrans=
|
19
|
+
|
20
|
+
TYPE = 0x1004 # 4099 (multisig transaction)
|
21
|
+
FEE = 6_000_000
|
22
|
+
|
23
|
+
def self.build(attrs)
|
24
|
+
new(attrs)
|
25
|
+
end
|
26
|
+
|
27
|
+
# @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
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [Integer]
|
43
|
+
def fee
|
44
|
+
@fee ||= calculate_fee
|
45
|
+
end
|
46
|
+
|
47
|
+
def mosaics
|
48
|
+
@mosaics ||= []
|
49
|
+
end
|
50
|
+
|
51
|
+
alias to_hash_old to_hash
|
52
|
+
|
53
|
+
def to_hash
|
54
|
+
fee
|
55
|
+
to_hash_old
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return [Integer]
|
59
|
+
def calculate_fee
|
60
|
+
FEE
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class Nis::Struct
|
2
|
+
# @attr [Integer] timeStamp
|
3
|
+
# @attr [String] signature
|
4
|
+
# @attr [Integer] fee
|
5
|
+
# @attr [Integer] type
|
6
|
+
# @attr [Integer] deadline
|
7
|
+
# @attr [Integer] version
|
8
|
+
# @attr [String] signer
|
9
|
+
# @attr [String] rentalFeeSink
|
10
|
+
# @attr [Integer] rentalFee
|
11
|
+
# @attr [String] newPart
|
12
|
+
# @attr [String] parent
|
13
|
+
# @see http://bob.nem.ninja/docs/#provisionNamespaceTransaction
|
14
|
+
class ProvisionNamespaceTransaction
|
15
|
+
include Nis::Util::Assignable
|
16
|
+
attr_accessor :timeStamp, :signature, :fee, :type, :deadline, :version, :signer,
|
17
|
+
:rentalFeeSink, :rentalFee, :newPart, :parent
|
18
|
+
|
19
|
+
alias timestamp timeStamp
|
20
|
+
alias timestamp= timeStamp=
|
21
|
+
alias rental_fee_sink rentalFeeSink
|
22
|
+
alias rental_fee_sink= rentalFeeSink=
|
23
|
+
alias rental_fee rentalFee
|
24
|
+
alias rental_fee= rentalFee=
|
25
|
+
alias new_part newPart
|
26
|
+
alias new_part= newPart=
|
27
|
+
|
28
|
+
TYPE = 0x2001 # 8193 (provision namespace transaction)
|
29
|
+
FEE = 20_000_000
|
30
|
+
|
31
|
+
def self.build(attrs)
|
32
|
+
new(attrs)
|
33
|
+
end
|
34
|
+
|
35
|
+
# @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
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [Integer]
|
51
|
+
def fee
|
52
|
+
@fee ||= calculate_fee
|
53
|
+
end
|
54
|
+
|
55
|
+
alias to_hash_old to_hash
|
56
|
+
|
57
|
+
def to_hash
|
58
|
+
fee
|
59
|
+
to_hash_old
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [Integer]
|
63
|
+
def calculate_fee
|
64
|
+
FEE
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
class Nis::Struct
|
2
|
+
# @attr [Integer] timestamp
|
3
|
+
# @attr [Integer] amount
|
4
|
+
# @attr [Integer] fee
|
5
|
+
# @attr [String] recipient
|
6
|
+
# @attr [Integer] type
|
7
|
+
# @attr [Integer] deadline
|
8
|
+
# @attr [Nis::Struct::Message] message
|
9
|
+
# @attr [Integer] version
|
10
|
+
# @attr [String] signer
|
11
|
+
# @attr [Array <Nis::Struct::MosaicId>] mosaics
|
12
|
+
# @see http://bob.nem.ninja/docs/#transferTransaction
|
13
|
+
# @see http://bob.nem.ninja/docs/#initiating-a-transfer-transaction
|
14
|
+
# @see http://bob.nem.ninja/docs/#version-1-transfer-transactions
|
15
|
+
# @see http://bob.nem.ninja/docs/#version-2-transfer-transactions
|
16
|
+
class TransferTransaction
|
17
|
+
include Nis::Util::Assignable
|
18
|
+
attr_accessor :timeStamp, :amount, :fee, :recipient, :type, :deadline, :message, :version, :signer,
|
19
|
+
:mosaics
|
20
|
+
|
21
|
+
alias :timestamp :timeStamp
|
22
|
+
alias :timestamp= :timeStamp=
|
23
|
+
|
24
|
+
TYPE = 0x0101 # 257 (transfer transaction)
|
25
|
+
|
26
|
+
def self.build(attrs)
|
27
|
+
new(attrs)
|
28
|
+
end
|
29
|
+
|
30
|
+
# @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
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [Integer]
|
46
|
+
def fee
|
47
|
+
@fee ||= calculate_fee
|
48
|
+
end
|
49
|
+
|
50
|
+
def mosaics
|
51
|
+
@mosaics ||= []
|
52
|
+
end
|
53
|
+
|
54
|
+
alias to_hash_old to_hash
|
55
|
+
|
56
|
+
def to_hash
|
57
|
+
fee
|
58
|
+
to_hash_old
|
59
|
+
end
|
60
|
+
|
61
|
+
# @return [Integer]
|
62
|
+
def calculate_fee
|
63
|
+
if mosaics.empty?
|
64
|
+
tmp_fee = [1, amount / 1_000_000 / 10_000].max
|
65
|
+
fee = (tmp_fee > 25 ? 25 : tmp_fee)
|
66
|
+
else
|
67
|
+
# TODO: calc mosaics fee
|
68
|
+
raise NotImplementedError, 'not implemented calculation mosaic fee.'
|
69
|
+
fee = 25
|
70
|
+
end
|
71
|
+
|
72
|
+
if message.bytesize > 0
|
73
|
+
fee += [1, (message.bytesize / 2 / 32) + 1].max
|
74
|
+
end
|
75
|
+
|
76
|
+
fee * 1_000_000
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/lib/nis/unit/address.rb
CHANGED
data/lib/nis/util.rb
CHANGED
@@ -1,6 +1,35 @@
|
|
1
1
|
module Nis::Util
|
2
|
+
TESTNET = 0x98000000 # -1744830464
|
3
|
+
MAINNET = 0x68000000 # 1744830464
|
4
|
+
|
5
|
+
VERSION_1 = 0x00000001 # 1
|
6
|
+
VERSION_2 = 0x00000002 # 2
|
7
|
+
|
8
|
+
TESTNET_VERSION_1 = TESTNET | VERSION_1 # 0x98000001 = -1744830463
|
9
|
+
TESTNET_VERSION_2 = TESTNET | VERSION_2 # 0x98000002 = -1744830462
|
10
|
+
MAINNET_VERSION_1 = MAINNET | VERSION_1 # 0x68000001 = 1744830465
|
11
|
+
MAINNET_VERSION_2 = MAINNET | VERSION_2 # 0x68000002 = 1744830466
|
12
|
+
|
2
13
|
NEM_EPOCH = Time.utc(2015, 3, 29, 0, 6, 25, 0)
|
3
14
|
|
15
|
+
#
|
16
|
+
# @see http://www.nem.ninja/docs/#namespaces
|
17
|
+
NAMESPACE_SINK = {
|
18
|
+
testnet: 'TAMESPACEWH4MKFMBCVFERDPOOP4FK7MTDJEYP35',
|
19
|
+
mainnet: 'NAMESPACEWH4MKFMBCVFERDPOOP4FK7MTBXDPZZA'
|
20
|
+
}
|
21
|
+
|
22
|
+
# @see http://www.nem.ninja/docs/#mosaics
|
23
|
+
MOSAIC_SINK = {
|
24
|
+
testnet: 'TBMOSAICOD4F54EE5CDMR23CCBGOAM2XSJBR5OLC',
|
25
|
+
mainnet: 'NBMOSAICOD4F54EE5CDMR23CCBGOAM2XSIUX6TRS'
|
26
|
+
}
|
27
|
+
|
28
|
+
APOSTILLE_SINK = {
|
29
|
+
testnet: 'TC7MCY5AGJQXZQ4BN3BOPNXUVIGDJCOHBPGUM2GE',
|
30
|
+
mainnet: 'NCZSJHLTIMESERVBVKOW6US64YDZG2PFGQCSV23J'
|
31
|
+
}
|
32
|
+
|
4
33
|
def self.timestamp
|
5
34
|
(Time.now - NEM_EPOCH).to_i
|
6
35
|
end
|
data/lib/nis/version.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
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
|
+
# Remote Account B (Dist)
|
10
|
+
B_PUBLIC_KEY = 'cc6c9485d15b992501e57fe3799487e99de272f79c5442de94eeb998b45e0144'.freeze
|
11
|
+
|
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,
|
17
|
+
remoteAccount: B_PUBLIC_KEY,
|
18
|
+
type: Nis::Struct::ImportanceTransferTransaction::TYPE,
|
19
|
+
deadline: Nis::Util.timestamp + 43_200,
|
20
|
+
version: Nis::Util::TESTNET_VERSION_1,
|
21
|
+
signer: A_PUBLIC_KEY
|
22
|
+
)
|
23
|
+
|
24
|
+
# build RequestPrepareAnnounce Object
|
25
|
+
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
26
|
+
transaction: tx,
|
27
|
+
privateKey: A_PRIVATE_KEY
|
28
|
+
)
|
29
|
+
|
30
|
+
# Create NIS instance
|
31
|
+
nis = Nis.new
|
32
|
+
|
33
|
+
# Send XEM request.
|
34
|
+
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
35
|
+
puts res.message
|
36
|
+
puts hr
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'nis'
|
2
|
+
hr = '-' * 64
|
3
|
+
|
4
|
+
# Account A
|
5
|
+
A_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'.freeze
|
6
|
+
A_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'.freeze
|
7
|
+
A_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
|
8
|
+
|
9
|
+
mosaic_id = Nis::Struct::MosaicId.new(
|
10
|
+
namespaceId: 'kon',
|
11
|
+
name: "teas"
|
12
|
+
)
|
13
|
+
|
14
|
+
properties = Nis::Struct::MosaicProperties.new(
|
15
|
+
divisibility: 0,
|
16
|
+
initialSupply: 10_000,
|
17
|
+
supplyMutable: true,
|
18
|
+
transferable: true
|
19
|
+
)
|
20
|
+
|
21
|
+
levy = Nis::Struct::MosaicLevy.new(
|
22
|
+
type: 1,
|
23
|
+
recipient: A_ADDRESS,
|
24
|
+
mosaicId: {
|
25
|
+
namespaceId: 'nem',
|
26
|
+
name: 'xem'
|
27
|
+
},
|
28
|
+
fee: 1_000
|
29
|
+
)
|
30
|
+
|
31
|
+
definition = Nis::Struct::MosaicDefinition.new(
|
32
|
+
creator: A_PUBLIC_KEY,
|
33
|
+
id: mosaic_id,
|
34
|
+
description: 'Ho-kago Tea Time',
|
35
|
+
properties: properties,
|
36
|
+
levy: levy
|
37
|
+
)
|
38
|
+
|
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,
|
46
|
+
creationFee: 500_000_000,
|
47
|
+
creationFeeSink: Nis::Util::MOSAIC_SINK[:testnet],
|
48
|
+
mosaicDefinition: definition
|
49
|
+
)
|
50
|
+
|
51
|
+
# build RequestPrepareAnnounce Object
|
52
|
+
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
53
|
+
transaction: tx,
|
54
|
+
privateKey: A_PRIVATE_KEY
|
55
|
+
)
|
56
|
+
|
57
|
+
# Create NIS instance
|
58
|
+
nis = Nis.new
|
59
|
+
|
60
|
+
# Send XEM request.
|
61
|
+
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
62
|
+
puts res.message
|
63
|
+
puts hr
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'nis'
|
2
|
+
hr = '-' * 64
|
3
|
+
|
4
|
+
# Account A
|
5
|
+
A_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'.freeze
|
6
|
+
A_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'.freeze
|
7
|
+
A_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
|
8
|
+
|
9
|
+
mosaic_id = Nis::Struct::MosaicId.new(
|
10
|
+
namespaceId: 'kon',
|
11
|
+
name: "teas"
|
12
|
+
)
|
13
|
+
|
14
|
+
# build Transaction Object
|
15
|
+
tx = Nis::Struct::MosaicSupplyChangeTransaction.new(
|
16
|
+
timeStamp: Nis::Util.timestamp,
|
17
|
+
type: Nis::Struct::MosaicSupplyChangeTransaction::TYPE,
|
18
|
+
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
|
24
|
+
)
|
25
|
+
|
26
|
+
# build RequestPrepareAnnounce Object
|
27
|
+
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
28
|
+
transaction: tx,
|
29
|
+
privateKey: A_PRIVATE_KEY
|
30
|
+
)
|
31
|
+
|
32
|
+
# Create NIS instance
|
33
|
+
nis = Nis.new
|
34
|
+
|
35
|
+
# Send XEM request.
|
36
|
+
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
37
|
+
puts res.inspect
|
38
|
+
puts hr
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'nis'
|
2
|
+
hr = '-' * 64
|
3
|
+
|
4
|
+
# Account A (multisig)
|
5
|
+
A_ADDRESS = 'TDJNDAQ7F7AQRXKP2YVTH67QYCWWKE6QLSJFWN64'.freeze
|
6
|
+
A_PRIVATE_KEY = '00f077782658ae91b77f238ba5fcd7ef110564b5c189072e4d4590d9b17f9d76f3'.freeze
|
7
|
+
A_PUBLIC_KEY = '6d72b57d2bc199d328e7ea3e24775f7f614760bc18f3f8501cd3daa9870cc40c'.freeze
|
8
|
+
|
9
|
+
# Account B (cosignatory)
|
10
|
+
B_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'.freeze
|
11
|
+
B_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'.freeze
|
12
|
+
B_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
|
13
|
+
|
14
|
+
# Account C (cosignatory)
|
15
|
+
C_ADDRESS = 'TA4TX6U5HG2MROAESH2JE5524T4ZOY2EQKQ6ELHF'.freeze
|
16
|
+
C_PRIVATE_KEY = '1d13af2c31ee6fb0c3c7aaaea818d9b305dcadba130ba663fc42d9f25b24ded1'.freeze
|
17
|
+
C_PUBLIC_KEY = '9e7ab2924cd1a3482df784db190614cfc8a33671f5d80a5b15a9c9e8b4d13933'.freeze
|
18
|
+
|
19
|
+
mcm = Nis::Struct::MultisigCosignatoryModification.new(
|
20
|
+
modificationType: 1, # Add
|
21
|
+
cosignatoryAccount: C_PUBLIC_KEY
|
22
|
+
)
|
23
|
+
|
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,
|
31
|
+
modifications: [
|
32
|
+
mcm
|
33
|
+
],
|
34
|
+
minCosignatories: {
|
35
|
+
relativeChange: 2
|
36
|
+
}
|
37
|
+
)
|
38
|
+
|
39
|
+
mtx = Nis::Struct::MultisigTransaction.new(
|
40
|
+
timeStamp: Nis::Util.timestamp,
|
41
|
+
signer: B_PUBLIC_KEY,
|
42
|
+
type: Nis::Struct::MultisigTransaction::TYPE,
|
43
|
+
deadline: Nis::Util.timestamp + 43_200,
|
44
|
+
version: Nis::Struct::Transaction::TESTNET_VERSION_1,
|
45
|
+
otherTrans: tx
|
46
|
+
)
|
47
|
+
|
48
|
+
# build RequestPrepareAnnounce Object
|
49
|
+
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
50
|
+
transaction: mtx,
|
51
|
+
privateKey: B_PRIVATE_KEY
|
52
|
+
)
|
53
|
+
|
54
|
+
# Create NIS instance
|
55
|
+
nis = Nis.new
|
56
|
+
|
57
|
+
# Send XEM request.
|
58
|
+
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
59
|
+
puts res.message
|
60
|
+
puts hr
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'nis'
|
2
|
+
hr = '-' * 64
|
3
|
+
|
4
|
+
# Account A (change to multisig)
|
5
|
+
A_ADDRESS = 'TDJNDAQ7F7AQRXKP2YVTH67QYCWWKE6QLSJFWN64'.freeze
|
6
|
+
A_PRIVATE_KEY = '00f077782658ae91b77f238ba5fcd7ef110564b5c189072e4d4590d9b17f9d76f3'.freeze
|
7
|
+
A_PUBLIC_KEY = '6d72b57d2bc199d328e7ea3e24775f7f614760bc18f3f8501cd3daa9870cc40c'.freeze
|
8
|
+
|
9
|
+
# Account B (cosignatory)
|
10
|
+
B_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'.freeze
|
11
|
+
B_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'.freeze
|
12
|
+
B_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
|
13
|
+
|
14
|
+
mcm = Nis::Struct::MultisigCosignatoryModification.new(
|
15
|
+
modificationType: 1, # Add
|
16
|
+
cosignatoryAccount: B_PUBLIC_KEY
|
17
|
+
)
|
18
|
+
|
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,
|
26
|
+
modifications: [
|
27
|
+
mcm
|
28
|
+
],
|
29
|
+
minCosignatories: {
|
30
|
+
relativeChange: 1
|
31
|
+
}
|
32
|
+
)
|
33
|
+
|
34
|
+
# build RequestPrepareAnnounce Object
|
35
|
+
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
36
|
+
transaction: tx,
|
37
|
+
privateKey: A_PRIVATE_KEY
|
38
|
+
)
|
39
|
+
|
40
|
+
# Create NIS instance
|
41
|
+
nis = Nis.new
|
42
|
+
|
43
|
+
# Send XEM request.
|
44
|
+
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
45
|
+
puts res.message
|
46
|
+
puts hr
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'nis'
|
2
|
+
hr = '-' * 64
|
3
|
+
|
4
|
+
# Account A (change to multisig)
|
5
|
+
A_ADDRESS = 'TDJNDAQ7F7AQRXKP2YVTH67QYCWWKE6QLSJFWN64'.freeze
|
6
|
+
A_PRIVATE_KEY = '00f077782658ae91b77f238ba5fcd7ef110564b5c189072e4d4590d9b17f9d76f3'.freeze
|
7
|
+
A_PUBLIC_KEY = '6d72b57d2bc199d328e7ea3e24775f7f614760bc18f3f8501cd3daa9870cc40c'.freeze
|
8
|
+
|
9
|
+
# Account B (cosignatory)
|
10
|
+
B_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'.freeze
|
11
|
+
B_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'.freeze
|
12
|
+
B_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
|
13
|
+
|
14
|
+
# Account C (cosignatory)
|
15
|
+
C_ADDRESS = 'TA4TX6U5HG2MROAESH2JE5524T4ZOY2EQKQ6ELHF'.freeze
|
16
|
+
C_PRIVATE_KEY = '1d13af2c31ee6fb0c3c7aaaea818d9b305dcadba130ba663fc42d9f25b24ded1'.freeze
|
17
|
+
C_PUBLIC_KEY = '9e7ab2924cd1a3482df784db190614cfc8a33671f5d80a5b15a9c9e8b4d13933'.freeze
|
18
|
+
|
19
|
+
require 'pry'
|
20
|
+
|
21
|
+
nis = Nis.new
|
22
|
+
txes = nis.account_unconfirmed_transactions(address: C_ADDRESS)
|
23
|
+
|
24
|
+
unless txes.size > 0
|
25
|
+
puts 'There are no transactions to sign.'
|
26
|
+
exit
|
27
|
+
end
|
28
|
+
|
29
|
+
hash = txes.first.meta.data
|
30
|
+
|
31
|
+
puts "Unconfirmed Transaction Hash: #{hash}"
|
32
|
+
puts hr
|
33
|
+
|
34
|
+
# build Transaction Object
|
35
|
+
tx = Nis::Struct::MultisigSignatureTransaction.new(
|
36
|
+
timeStamp: Nis::Util.timestamp,
|
37
|
+
type: Nis::Struct::MultisigSignatureTransaction::TYPE,
|
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
|
46
|
+
)
|
47
|
+
|
48
|
+
# build RequestPrepareAnnounce Object
|
49
|
+
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
50
|
+
transaction: tx,
|
51
|
+
privateKey: C_PRIVATE_KEY
|
52
|
+
)
|
53
|
+
|
54
|
+
# Create NIS instance
|
55
|
+
nis = Nis.new
|
56
|
+
|
57
|
+
# Send XEM request.
|
58
|
+
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
59
|
+
puts res.message
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'nis'
|
2
|
+
hr = '-' * 64
|
3
|
+
|
4
|
+
# Account A (multisig)
|
5
|
+
A_ADDRESS = 'TDJNDAQ7F7AQRXKP2YVTH67QYCWWKE6QLSJFWN64'.freeze
|
6
|
+
A_PRIVATE_KEY = '00f077782658ae91b77f238ba5fcd7ef110564b5c189072e4d4590d9b17f9d76f3'.freeze
|
7
|
+
A_PUBLIC_KEY = '6d72b57d2bc199d328e7ea3e24775f7f614760bc18f3f8501cd3daa9870cc40c'.freeze
|
8
|
+
|
9
|
+
# Account B (cosignatory)
|
10
|
+
B_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'.freeze
|
11
|
+
B_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'.freeze
|
12
|
+
B_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
|
13
|
+
|
14
|
+
# build Transaction Object
|
15
|
+
tx = Nis::Struct::Transaction.new(
|
16
|
+
amount: 10_000_000,
|
17
|
+
recipient: B_ADDRESS,
|
18
|
+
signer: A_PUBLIC_KEY,
|
19
|
+
message: Nis::Struct::Message.new('Hello'),
|
20
|
+
type: Nis::Struct::Transaction::TRANSFER,
|
21
|
+
timeStamp: Nis::Util.timestamp,
|
22
|
+
deadline: Nis::Util.timestamp + 43_200,
|
23
|
+
version: Nis::Struct::Transaction::TESTNET_VERSION_1
|
24
|
+
)
|
25
|
+
|
26
|
+
mtx = Nis::Struct::MultisigTransaction.new(
|
27
|
+
timeStamp: Nis::Util.timestamp,
|
28
|
+
signer: B_PUBLIC_KEY,
|
29
|
+
type: Nis::Struct::MultisigTransaction::TYPE,
|
30
|
+
deadline: Nis::Util.timestamp + 43_200,
|
31
|
+
version: Nis::Struct::Transaction::TESTNET_VERSION_1,
|
32
|
+
otherTrans: tx
|
33
|
+
)
|
34
|
+
|
35
|
+
# automatically calculate minimum fee if fee is not set.
|
36
|
+
puts 'Fee: %d' % tx.fee
|
37
|
+
|
38
|
+
# build RequestPrepareAnnounce Object
|
39
|
+
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
40
|
+
transaction: mtx,
|
41
|
+
privateKey: B_PRIVATE_KEY
|
42
|
+
)
|
43
|
+
|
44
|
+
# Create NIS instance
|
45
|
+
nis = Nis.new
|
46
|
+
|
47
|
+
# check banalces before sending XEM.
|
48
|
+
puts 'Account A => balance: %d' %
|
49
|
+
(nis.account_get address: A_ADDRESS)[:account][:balance]
|
50
|
+
puts 'Account B => balance: %d' %
|
51
|
+
(nis.account_get address: B_ADDRESS)[:account][:balance]
|
52
|
+
puts hr
|
53
|
+
|
54
|
+
# Send XEM request.
|
55
|
+
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
56
|
+
puts res.message
|
data/samples/request_node.rb
CHANGED
@@ -25,7 +25,19 @@ puts hr
|
|
25
25
|
puts nis.node_active_peers_max_chain_height
|
26
26
|
puts hr
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
bnr = Nis::Struct::BootNodeRequest.new(
|
29
|
+
metaData: {
|
30
|
+
application: 'NIS'
|
31
|
+
},
|
32
|
+
endpoint: {
|
33
|
+
protocol: 'http',
|
34
|
+
port: 7890,
|
35
|
+
host: 'localhost'
|
36
|
+
},
|
37
|
+
identity: {
|
38
|
+
'private-key': 'a6cbd01d04edecfaef51df9486c111abb6299c764a00206eb1d01f4587491b3f',
|
39
|
+
name: 'Alice'
|
40
|
+
}
|
41
|
+
)
|
42
|
+
puts nis.node_boot(boot_node_request: bnr)
|
43
|
+
puts hr
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'nis'
|
2
|
+
hr = '-' * 64
|
3
|
+
|
4
|
+
# Account A
|
5
|
+
A_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'.freeze
|
6
|
+
A_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'.freeze
|
7
|
+
A_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'.freeze
|
8
|
+
|
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,
|
16
|
+
rentalFeeSink: Nis::Util::NAMESPACE_SINK[:testnet],
|
17
|
+
rentalFee: 5_000_000_000,
|
18
|
+
newPart: 'kon',
|
19
|
+
parent: nil
|
20
|
+
)
|
21
|
+
|
22
|
+
# build RequestPrepareAnnounce Object
|
23
|
+
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
24
|
+
transaction: tx,
|
25
|
+
privateKey: A_PRIVATE_KEY
|
26
|
+
)
|
27
|
+
|
28
|
+
# Create NIS instance
|
29
|
+
nis = Nis.new
|
30
|
+
|
31
|
+
# Send XEM request.
|
32
|
+
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
33
|
+
puts res.message
|
34
|
+
puts hr
|
@@ -12,7 +12,7 @@ B_ADDRESS = 'TA4TX6U5HG2MROAESH2JE5524T4ZOY2EQKQ6ELHF'.freeze
|
|
12
12
|
# build Transaction Object
|
13
13
|
tx = Nis::Struct::Transaction.new(
|
14
14
|
amount: 1_000_000,
|
15
|
-
fee: 3_000_000,
|
15
|
+
# fee: 3_000_000, # see below.
|
16
16
|
recipient: B_ADDRESS,
|
17
17
|
signer: A_PUBLIC_KEY,
|
18
18
|
message: Nis::Struct::Message.new('Hello'),
|
@@ -22,6 +22,9 @@ tx = Nis::Struct::Transaction.new(
|
|
22
22
|
version: Nis::Struct::Transaction::TESTNET_VERSION_1
|
23
23
|
)
|
24
24
|
|
25
|
+
# automatically calculate minimum fee if fee is not set.
|
26
|
+
puts 'Fee: %d' % tx.fee
|
27
|
+
|
25
28
|
# build RequestPrepareAnnounce Object
|
26
29
|
rpa = Nis::Struct::RequestPrepareAnnounce.new(
|
27
30
|
transaction: tx,
|
@@ -42,4 +45,4 @@ puts hr
|
|
42
45
|
res = nis.transaction_prepare_announce(request_prepare_announce: rpa)
|
43
46
|
puts res.message
|
44
47
|
|
45
|
-
# After several minutes, check
|
48
|
+
# After several minutes, check Account A and B Balance.
|
@@ -0,0 +1,48 @@
|
|
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::TransferTransaction.new(
|
14
|
+
amount: 1_000_000,
|
15
|
+
# fee: 3_000_000, # see below.
|
16
|
+
recipient: B_ADDRESS,
|
17
|
+
type: Nis::Struct::TransferTransaction::TYPE,
|
18
|
+
signer: A_PUBLIC_KEY,
|
19
|
+
message: Nis::Struct::Message.new('Hello'),
|
20
|
+
timeStamp: Nis::Util.timestamp,
|
21
|
+
deadline: Nis::Util.timestamp + 43_200,
|
22
|
+
version: Nis::Util::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.
|
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.
|
4
|
+
version: 0.0.10
|
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-
|
11
|
+
date: 2017-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -230,15 +230,22 @@ files:
|
|
230
230
|
- lib/nis/struct/explorer_view_model_transaction.rb
|
231
231
|
- lib/nis/struct/extended_node_experience_pair.rb
|
232
232
|
- lib/nis/struct/harvest_info.rb
|
233
|
+
- lib/nis/struct/importance_transfer_transaction.rb
|
233
234
|
- lib/nis/struct/key_pair_view_model.rb
|
234
235
|
- lib/nis/struct/message.rb
|
235
236
|
- lib/nis/struct/mosaic.rb
|
236
237
|
- lib/nis/struct/mosaic_definition.rb
|
238
|
+
- lib/nis/struct/mosaic_definition_creation_transaction.rb
|
237
239
|
- lib/nis/struct/mosaic_definition_meta_data.rb
|
238
240
|
- lib/nis/struct/mosaic_definition_meta_data_pair.rb
|
239
241
|
- lib/nis/struct/mosaic_id.rb
|
240
242
|
- lib/nis/struct/mosaic_levy.rb
|
241
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
|
+
- lib/nis/struct/multisig_cosignatory_modification.rb
|
247
|
+
- lib/nis/struct/multisig_signature_transaction.rb
|
248
|
+
- lib/nis/struct/multisig_transaction.rb
|
242
249
|
- lib/nis/struct/namespace.rb
|
243
250
|
- lib/nis/struct/namespace_meta_data.rb
|
244
251
|
- lib/nis/struct/namespace_meta_data_pair.rb
|
@@ -249,12 +256,14 @@ files:
|
|
249
256
|
- lib/nis/struct/node.rb
|
250
257
|
- lib/nis/struct/node_collection.rb
|
251
258
|
- lib/nis/struct/node_experience.rb
|
259
|
+
- lib/nis/struct/provision_namespace_transaction.rb
|
252
260
|
- lib/nis/struct/request_announce.rb
|
253
261
|
- lib/nis/struct/request_prepare_announce.rb
|
254
262
|
- lib/nis/struct/time_synchronization_result.rb
|
255
263
|
- lib/nis/struct/transaction.rb
|
256
264
|
- lib/nis/struct/transaction_meta_data.rb
|
257
265
|
- lib/nis/struct/transaction_meta_data_pair.rb
|
266
|
+
- lib/nis/struct/transfer_transaction.rb
|
258
267
|
- lib/nis/struct/unconfirmed_transaction_meta_data.rb
|
259
268
|
- lib/nis/struct/unconfirmed_transaction_meta_data_pair.rb
|
260
269
|
- lib/nis/unit.rb
|
@@ -272,11 +281,20 @@ files:
|
|
272
281
|
- samples/request_account.rb
|
273
282
|
- samples/request_block.rb
|
274
283
|
- samples/request_debug.rb
|
284
|
+
- samples/request_importance_transfer_transaction.rb
|
275
285
|
- samples/request_local.rb
|
286
|
+
- samples/request_mosaic_definition_creation_transaction.rb
|
287
|
+
- samples/request_mosaic_supply_change_transaction.rb
|
288
|
+
- samples/request_multisig_add_cosignatory_transaction.rb
|
289
|
+
- samples/request_multisig_aggregate_modification_transaction.rb
|
290
|
+
- samples/request_multisig_signature_transaction.rb
|
291
|
+
- samples/request_multisig_transaction.rb
|
276
292
|
- samples/request_namespace.rb
|
277
293
|
- samples/request_nis.rb
|
278
294
|
- samples/request_node.rb
|
295
|
+
- samples/request_provision_namespace_transaction.rb
|
279
296
|
- samples/request_transaction.rb
|
297
|
+
- samples/request_transfer_transaction.rb
|
280
298
|
homepage: https://github.com/44uk/nis-ruby
|
281
299
|
licenses:
|
282
300
|
- MIT
|