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.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.rubocop.yml +119 -0
- data/.travis.yml +23 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/README.md +81 -0
- data/Rakefile +6 -0
- data/examples/apostille_audit.rb +22 -0
- data/examples/apostille_create.rb +31 -0
- data/examples/endpoint/account.rb +73 -0
- data/examples/endpoint/account_local.rb +21 -0
- data/examples/endpoint/block.rb +14 -0
- data/examples/endpoint/chain.rb +15 -0
- data/examples/endpoint/debug.rb +17 -0
- data/examples/endpoint/local.rb +17 -0
- data/examples/endpoint/mosaic.rb +9 -0
- data/examples/endpoint/namespace.rb +13 -0
- data/examples/endpoint/node.rb +24 -0
- data/examples/endpoint/timesync.rb +9 -0
- data/examples/endpoint/transaction.rb +42 -0
- data/examples/localnode.rb +0 -0
- data/examples/nis.rb +34 -0
- data/examples/node_pool.rb +23 -0
- data/examples/transaction/importance_transfer.rb +23 -0
- data/examples/transaction/mosaic_definition_creation.rb +52 -0
- data/examples/transaction/mosaic_supply_change.rb +25 -0
- data/examples/transaction/multisig_add_cosignatory.rb +31 -0
- data/examples/transaction/multisig_aggregate_modification.rb +29 -0
- data/examples/transaction/multisig_signature.rb +41 -0
- data/examples/transaction/multisig_transfer.rb +35 -0
- data/examples/transaction/provision_namespace.rb +20 -0
- data/examples/transaction/transfer.rb +32 -0
- data/examples/transaction/transfer_mosaic.rb +72 -0
- data/examples/transaction/transfer_with_encrypted_message.rb +40 -0
- data/examples/transaction/transfer_with_local.rb +34 -0
- data/lib/nem.rb +21 -0
- data/lib/nem/apostille.rb +104 -0
- data/lib/nem/apostille_audit.rb +47 -0
- data/lib/nem/client.rb +170 -0
- data/lib/nem/configuration.rb +29 -0
- data/lib/nem/endpoint.rb +4 -0
- data/lib/nem/endpoint/account.rb +264 -0
- data/lib/nem/endpoint/base.rb +45 -0
- data/lib/nem/endpoint/block.rb +15 -0
- data/lib/nem/endpoint/chain.rb +17 -0
- data/lib/nem/endpoint/debug.rb +54 -0
- data/lib/nem/endpoint/local/account.rb +54 -0
- data/lib/nem/endpoint/local/chain.rb +15 -0
- data/lib/nem/endpoint/mosaic.rb +13 -0
- data/lib/nem/endpoint/namespace.rb +37 -0
- data/lib/nem/endpoint/node.rb +83 -0
- data/lib/nem/endpoint/timesync.rb +9 -0
- data/lib/nem/endpoint/transaction.rb +34 -0
- data/lib/nem/error.rb +6 -0
- data/lib/nem/fee.rb +2 -0
- data/lib/nem/fee/importance_transfer.rb +24 -0
- data/lib/nem/fee/mosaic_definition_creation.rb +24 -0
- data/lib/nem/fee/mosaic_supply_change_transfer.rb +24 -0
- data/lib/nem/fee/multisig.rb +24 -0
- data/lib/nem/fee/multisig_aggregation_modification.rb +28 -0
- data/lib/nem/fee/provision_namespace.rb +34 -0
- data/lib/nem/fee/transfer.rb +66 -0
- data/lib/nem/keypair.rb +44 -0
- data/lib/nem/mixin.rb +2 -0
- data/lib/nem/mixin/assignable.rb +12 -0
- data/lib/nem/model.rb +3 -0
- data/lib/nem/model/account.rb +67 -0
- data/lib/nem/model/account_historical.rb +19 -0
- data/lib/nem/model/block.rb +33 -0
- data/lib/nem/model/chain.rb +14 -0
- data/lib/nem/model/connection.rb +23 -0
- data/lib/nem/model/experience.rb +20 -0
- data/lib/nem/model/explorer_block.rb +21 -0
- data/lib/nem/model/harvest.rb +23 -0
- data/lib/nem/model/heartbeat.rb +21 -0
- data/lib/nem/model/importance.rb +29 -0
- data/lib/nem/model/importance_transfer_transaction.rb +16 -0
- data/lib/nem/model/keypair.rb +19 -0
- data/lib/nem/model/message.rb +91 -0
- data/lib/nem/model/mosaic.rb +21 -0
- data/lib/nem/model/mosaic_attachment.rb +22 -0
- data/lib/nem/model/mosaic_definition.rb +65 -0
- data/lib/nem/model/mosaic_definition_creation_transaction.rb +18 -0
- data/lib/nem/model/mosaic_id.rb +27 -0
- data/lib/nem/model/mosaic_levy.rb +32 -0
- data/lib/nem/model/mosaic_owned.rb +22 -0
- data/lib/nem/model/mosaic_properties.rb +44 -0
- data/lib/nem/model/mosaic_supply.rb +21 -0
- data/lib/nem/model/mosaic_supply_change_transaction.rb +18 -0
- data/lib/nem/model/multisig_aggregate_modification_transaction.rb +21 -0
- data/lib/nem/model/multisig_info.rb +16 -0
- data/lib/nem/model/multisig_signature_transaction.rb +17 -0
- data/lib/nem/model/multisig_transaction.rb +21 -0
- data/lib/nem/model/namespace.rb +24 -0
- data/lib/nem/model/nem_announce_result.rb +19 -0
- data/lib/nem/model/network_time.rb +16 -0
- data/lib/nem/model/nis_node_info.rb +26 -0
- data/lib/nem/model/node.rb +41 -0
- data/lib/nem/model/provision_namespace_transaction.rb +18 -0
- data/lib/nem/model/status.rb +21 -0
- data/lib/nem/model/timer.rb +31 -0
- data/lib/nem/model/timesync.rb +19 -0
- data/lib/nem/model/transaction.rb +71 -0
- data/lib/nem/model/transfer_transaction.rb +24 -0
- data/lib/nem/model/unlocked_info.rb +24 -0
- data/lib/nem/mosaic.rb +2 -0
- data/lib/nem/mosaic/dim_coin.rb +21 -0
- data/lib/nem/mosaic/dim_token.rb +21 -0
- data/lib/nem/mosaic/ecobit_eco.rb +21 -0
- data/lib/nem/mosaic/xem.rb +21 -0
- data/lib/nem/node.rb +29 -0
- data/lib/nem/node_pool.rb +31 -0
- data/lib/nem/request.rb +2 -0
- data/lib/nem/request/announce.rb +76 -0
- data/lib/nem/transaction.rb +3 -0
- data/lib/nem/transaction/base.rb +45 -0
- data/lib/nem/transaction/importance_transfer.rb +42 -0
- data/lib/nem/transaction/mosaic_definition_creation.rb +45 -0
- data/lib/nem/transaction/mosaic_supply_change.rb +45 -0
- data/lib/nem/transaction/multisig.rb +29 -0
- data/lib/nem/transaction/multisig_aggregate_modification.rb +30 -0
- data/lib/nem/transaction/multisig_cosignatory_modification.rb +33 -0
- data/lib/nem/transaction/multisig_signature.rb +31 -0
- data/lib/nem/transaction/provision_namespace.rb +65 -0
- data/lib/nem/transaction/transfer.rb +63 -0
- data/lib/nem/util.rb +44 -0
- data/lib/nem/util/assignable.rb +51 -0
- data/lib/nem/util/convert.rb +112 -0
- data/lib/nem/util/deserializer.rb +158 -0
- data/lib/nem/util/ed25519.rb +316 -0
- data/lib/nem/util/serializer.rb +260 -0
- data/lib/nem/version.rb +3 -0
- data/nem-ruby.gemspec +46 -0
- metadata +350 -0
data/lib/nem/mixin.rb
ADDED
data/lib/nem/model.rb
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
module Nem
|
|
2
|
+
module Model
|
|
3
|
+
class Account
|
|
4
|
+
include Nem::Mixin::Assignable
|
|
5
|
+
|
|
6
|
+
attr_reader :address,
|
|
7
|
+
:balance,
|
|
8
|
+
:vested_balance,
|
|
9
|
+
:importance,
|
|
10
|
+
:public_key,
|
|
11
|
+
:label,
|
|
12
|
+
:harvested_blocks,
|
|
13
|
+
:multisig_info,
|
|
14
|
+
:cosignatory_of,
|
|
15
|
+
:cosignatories,
|
|
16
|
+
:status,
|
|
17
|
+
:remote_status
|
|
18
|
+
|
|
19
|
+
def self.new_from_account_meta_data_pair(hash)
|
|
20
|
+
meta = hash[:meta]
|
|
21
|
+
account = hash[:account]
|
|
22
|
+
new(
|
|
23
|
+
address: account[:address],
|
|
24
|
+
balance: account[:balance],
|
|
25
|
+
vested_balance: account[:vestedBalance],
|
|
26
|
+
importance: account[:importance],
|
|
27
|
+
public_key: account[:publicKey],
|
|
28
|
+
label: account[:label],
|
|
29
|
+
harvested_blocks: account[:harvestedBlocks],
|
|
30
|
+
cosignatory_of: meta[:cosignatoryOf],
|
|
31
|
+
cosignatories: meta[:cosignatories],
|
|
32
|
+
status: meta[:status],
|
|
33
|
+
remote_status: meta[:remoteStatus]
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.new_from_account_meta_data(hash)
|
|
38
|
+
cosignatory_of = hash[:cosignatoryOf].map do |account|
|
|
39
|
+
Account.new_from_account_data(account)
|
|
40
|
+
end
|
|
41
|
+
cosignatories = hash[:cosignatories].map do |account|
|
|
42
|
+
Account.new_from_account_data(account)
|
|
43
|
+
end
|
|
44
|
+
new(
|
|
45
|
+
cosignatory_of: cosignatory_of,
|
|
46
|
+
cosignatories: cosignatories,
|
|
47
|
+
status: hash[:status],
|
|
48
|
+
remote_status: hash[:remoteStatus]
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def self.new_from_account_data(hash)
|
|
53
|
+
multisig_info = MultisigInfo.new_from_multisig_info(hash[:multisigInfo])
|
|
54
|
+
new(
|
|
55
|
+
address: hash[:address],
|
|
56
|
+
balance: hash[:balance],
|
|
57
|
+
vested_balance: hash[:vestedBalance],
|
|
58
|
+
importance: hash[:importance],
|
|
59
|
+
public_key: hash[:publicKey],
|
|
60
|
+
label: hash[:label],
|
|
61
|
+
harvested_blocks: hash[:harvestedBlocks],
|
|
62
|
+
multisig_info: multisig_info
|
|
63
|
+
)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Nem
|
|
2
|
+
module Model
|
|
3
|
+
class AccountHistorical
|
|
4
|
+
include Nem::Mixin::Assignable
|
|
5
|
+
|
|
6
|
+
attr_reader :page_rank,
|
|
7
|
+
:address,
|
|
8
|
+
:balance,
|
|
9
|
+
:importance,
|
|
10
|
+
:vested_balance,
|
|
11
|
+
:unvested_balance,
|
|
12
|
+
:height
|
|
13
|
+
|
|
14
|
+
def self.new_from_account_historical(hash)
|
|
15
|
+
new(hash)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Nem
|
|
2
|
+
module Model
|
|
3
|
+
class Block
|
|
4
|
+
include Nem::Mixin::Assignable
|
|
5
|
+
|
|
6
|
+
attr_reader :timestamp,
|
|
7
|
+
:signature,
|
|
8
|
+
:prev_block_hash,
|
|
9
|
+
:type,
|
|
10
|
+
:transactions,
|
|
11
|
+
:version,
|
|
12
|
+
:signer,
|
|
13
|
+
:height
|
|
14
|
+
|
|
15
|
+
def self.new_from_block(hash)
|
|
16
|
+
txes = hash[:transactions].map do |tx|
|
|
17
|
+
Transaction.new_from_account_transaction(tx)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
new(
|
|
21
|
+
timestamp: hash[:timeStamp],
|
|
22
|
+
signature: hash[:signature],
|
|
23
|
+
prev_block_hash: hash[:prevBlockHash][:data],
|
|
24
|
+
type: hash[:type],
|
|
25
|
+
transactions: txes,
|
|
26
|
+
version: hash[:version],
|
|
27
|
+
signer: hash[:signer],
|
|
28
|
+
height: hash[:height]
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Nem
|
|
2
|
+
module Model
|
|
3
|
+
class Connection
|
|
4
|
+
include Nem::Mixin::Assignable
|
|
5
|
+
|
|
6
|
+
attr_reader:path,
|
|
7
|
+
:start_time,
|
|
8
|
+
:host,
|
|
9
|
+
:elapsed_time,
|
|
10
|
+
:id
|
|
11
|
+
|
|
12
|
+
def self.new_from_connection(hash)
|
|
13
|
+
new(
|
|
14
|
+
path: hash[:path],
|
|
15
|
+
start_time: hash[:"start-time"],
|
|
16
|
+
host: hash[:host],
|
|
17
|
+
elapsed_time: hash[:"elapsed-time"],
|
|
18
|
+
id: hash[:id]
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Nem
|
|
2
|
+
module Model
|
|
3
|
+
class Experience
|
|
4
|
+
include Nem::Mixin::Assignable
|
|
5
|
+
|
|
6
|
+
attr_reader :node, :syncs, :experience
|
|
7
|
+
|
|
8
|
+
ExperienceData = Struct.new(:s, :f)
|
|
9
|
+
|
|
10
|
+
def self.new_from_experience(hash)
|
|
11
|
+
exp = hash[:experience]
|
|
12
|
+
new(
|
|
13
|
+
node: Nem::Model::Node.new_from_node(hash[:node]),
|
|
14
|
+
syncs: hash[:syncs],
|
|
15
|
+
experience: ExperienceData.new(exp[:s], exp[:f])
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Nem
|
|
2
|
+
module Model
|
|
3
|
+
class ExpelorerBlock
|
|
4
|
+
include Nem::Mixin::Assignable
|
|
5
|
+
|
|
6
|
+
attr_reader :difficulty, :txes, :block, :hash
|
|
7
|
+
|
|
8
|
+
def self.new_from_explorer_block(hash)
|
|
9
|
+
txes = hash[:txes].map do |tx|
|
|
10
|
+
Transaction.new_from_transaction(tx)
|
|
11
|
+
end
|
|
12
|
+
new(
|
|
13
|
+
difficulty: hash[:difficulty],
|
|
14
|
+
txes: txes,
|
|
15
|
+
block: Block.new_from_block(hash[:block]),
|
|
16
|
+
hash: hash[:hash]
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Nem
|
|
2
|
+
module Model
|
|
3
|
+
class Harvest
|
|
4
|
+
include Nem::Mixin::Assignable
|
|
5
|
+
|
|
6
|
+
attr_reader :timestamp,
|
|
7
|
+
:difficulty,
|
|
8
|
+
:total_fee,
|
|
9
|
+
:id,
|
|
10
|
+
:height
|
|
11
|
+
|
|
12
|
+
def self.new_from_harvest(hash)
|
|
13
|
+
new(
|
|
14
|
+
timestamp: hash[:timeStamp],
|
|
15
|
+
difficulty: hash[:difficulty],
|
|
16
|
+
total_fee: hash[:totalFee],
|
|
17
|
+
id: hash[:id],
|
|
18
|
+
height: hash[:height]
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Nem
|
|
2
|
+
module Model
|
|
3
|
+
class Heartbeat
|
|
4
|
+
include Nem::Mixin::Assignable
|
|
5
|
+
|
|
6
|
+
attr_reader :code,
|
|
7
|
+
:type,
|
|
8
|
+
:message
|
|
9
|
+
|
|
10
|
+
# 0: Unknown status.
|
|
11
|
+
# 1: NIS is stopped.
|
|
12
|
+
# 2: NIS is starting.
|
|
13
|
+
# 3: NIS is running.
|
|
14
|
+
# 4: NIS is booting the local node (implies NIS is running).
|
|
15
|
+
# 5: The local node is booted (implies NIS is running).
|
|
16
|
+
# 6: The local node is synchronized (implies NIS is running and the local node is booted).
|
|
17
|
+
# 7: NIS local node does not see any remote NIS node (implies running and booted).
|
|
18
|
+
# 8: NIS is currently loading the block chain from the database. In this state NIS cannot serve any requests.
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Nem
|
|
2
|
+
module Model
|
|
3
|
+
class Importance
|
|
4
|
+
include Nem::Mixin::Assignable
|
|
5
|
+
|
|
6
|
+
attr_accessor :address,
|
|
7
|
+
:score,
|
|
8
|
+
:ev,
|
|
9
|
+
:is_set,
|
|
10
|
+
:height
|
|
11
|
+
|
|
12
|
+
def self.new_from_account_importance_view_model(hash)
|
|
13
|
+
importance = hash[:importance]
|
|
14
|
+
new(
|
|
15
|
+
address: hash[:address],
|
|
16
|
+
score: importance[:score],
|
|
17
|
+
ev: importance[:ev],
|
|
18
|
+
is_set: importance[:isSet],
|
|
19
|
+
height: importance[:height]
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# @return [Boolean]
|
|
24
|
+
def set?
|
|
25
|
+
@is_set == 1
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Nem
|
|
2
|
+
module Model
|
|
3
|
+
class ImportanceTransferTransaction < Transaction
|
|
4
|
+
attr_reader :mode, :remote_account
|
|
5
|
+
|
|
6
|
+
def self.new_from_transaction_meta_data_pair(hash)
|
|
7
|
+
transaction = hash[:transaction]
|
|
8
|
+
attrs = common_part_meta_data_pair(hash).merge(
|
|
9
|
+
mode: transaction[:mode],
|
|
10
|
+
remote_account: transaction[:remoteAccount]
|
|
11
|
+
)
|
|
12
|
+
new(attrs)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Nem
|
|
2
|
+
module Model
|
|
3
|
+
class Keypair
|
|
4
|
+
include Nem::Mixin::Assignable
|
|
5
|
+
|
|
6
|
+
attr_reader :private_key,
|
|
7
|
+
:public_key,
|
|
8
|
+
:address
|
|
9
|
+
|
|
10
|
+
def self.new_from_key_pair_view_model(hash)
|
|
11
|
+
new(
|
|
12
|
+
private_key: hash[:privateKey],
|
|
13
|
+
public_key: hash[:publicKey],
|
|
14
|
+
address: hash[:address]
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
module Nem
|
|
2
|
+
module Model
|
|
3
|
+
# @attr [String] value
|
|
4
|
+
# @attr [Integer] type
|
|
5
|
+
# @attr [String] payload
|
|
6
|
+
# @attr [String] public_key
|
|
7
|
+
# @attr [String] private_key
|
|
8
|
+
class Message
|
|
9
|
+
TYPE_PLAIN = 1
|
|
10
|
+
TYPE_ENCRYPTED = 2
|
|
11
|
+
|
|
12
|
+
include Nem::Mixin::Assignable
|
|
13
|
+
|
|
14
|
+
attr_reader :value, :type
|
|
15
|
+
attr_accessor :public_key, :private_key
|
|
16
|
+
|
|
17
|
+
def self.new_from_message(hash)
|
|
18
|
+
new(
|
|
19
|
+
hash[:payload],
|
|
20
|
+
type: (hash[:type] == TYPE_ENCRYPTED) ? :encrypted : :plain
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def initialize(value = '', type: :plain, private_key: nil, public_key: nil)
|
|
25
|
+
@value = value
|
|
26
|
+
@type = (type == :encrypted) ? TYPE_ENCRYPTED : TYPE_PLAIN
|
|
27
|
+
@private_key = private_key
|
|
28
|
+
@public_key = public_key
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def encrypt!
|
|
32
|
+
bin_sk = fix_private_key(@private_key).scan(/../).map(&:hex).reverse.pack('C*')
|
|
33
|
+
bin_pk = (public_key || @public_key).scan(/../).map(&:hex).pack('C*')
|
|
34
|
+
@value = Nem::Util::Ed25519.encrypt(bin_sk, bin_pk, value)
|
|
35
|
+
@type = TYPE_ENCRYPTED
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def decrypt!
|
|
39
|
+
bin_sk = fix_private_key(@private_key).scan(/../).map(&:hex).reverse.pack('C*')
|
|
40
|
+
bin_pk = (public_key || @public_key).scan(/../).map(&:hex).pack('C*')
|
|
41
|
+
@value = Nem::Util::Ed25519.decrypt(bin_sk, bin_pk, payload)
|
|
42
|
+
@type = TYPE_PLAIN
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# @return [Boolean]
|
|
46
|
+
def encrypted?
|
|
47
|
+
@type == TYPE_ENCRYPTED
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @return [Boolean]
|
|
51
|
+
def plain?
|
|
52
|
+
@type == TYPE_PLAIN
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# @return [Integer]
|
|
56
|
+
def bytesize
|
|
57
|
+
payload.bytesize
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# @return [Boolean]
|
|
61
|
+
def valid?
|
|
62
|
+
bytesize <= 512
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# @return [Hash]
|
|
66
|
+
def to_hash
|
|
67
|
+
{ payload: payload, type: @type }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# @return [String]
|
|
71
|
+
def to_s
|
|
72
|
+
@value.to_s
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# @return [Boolean]
|
|
76
|
+
def ==(other)
|
|
77
|
+
@value == other.value
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def payload
|
|
81
|
+
(value =~ /\Afe/ || encrypted?) ? value : value.unpack('H*').first
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
private
|
|
85
|
+
|
|
86
|
+
def fix_private_key(key)
|
|
87
|
+
"#{'0' * 64}#{key.sub(/^00/i, '')}"[-64, 64]
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Nem
|
|
2
|
+
module Model
|
|
3
|
+
class Mosaic
|
|
4
|
+
include Nem::Mixin::Assignable
|
|
5
|
+
|
|
6
|
+
extend Forwardable
|
|
7
|
+
|
|
8
|
+
def_delegators :@mosaic_id, :fqn
|
|
9
|
+
|
|
10
|
+
attr_reader :mosaic_id, :quantity
|
|
11
|
+
|
|
12
|
+
def self.new_from_mosaic(hash)
|
|
13
|
+
mosaic_id = Nem::Model::MosaicId.new_from_mosaic_id(hash[:mosaicId])
|
|
14
|
+
new(
|
|
15
|
+
quantity: hash[:quantity],
|
|
16
|
+
mosaic_id: mosaic_id
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|