test_sdk1 1.0.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +478 -89
- data/lib/crypto/asymmetric_key.rb +19 -18
- data/lib/crypto/ed25519_key.rb +99 -10
- data/lib/crypto/keys.rb +1 -2
- data/lib/crypto/keys_util.rb +20 -0
- data/lib/entity/auction_state.rb +56 -8
- data/lib/entity/bid.rb +1 -1
- data/lib/entity/bid_info.rb +1 -1
- data/lib/entity/block.rb +39 -0
- data/lib/entity/block_body.rb +35 -0
- data/lib/entity/block_header.rb +81 -0
- data/lib/entity/block_info.rb +56 -0
- data/lib/entity/block_proof.rb +24 -0
- data/lib/entity/deploy.rb +154 -1
- data/lib/entity/deploy_executable.rb +108 -6
- data/lib/entity/deploy_executable_item_internal.rb +1 -1
- data/lib/entity/deploy_header.rb +17 -0
- data/lib/entity/deploy_named_argument.rb +69 -2
- data/lib/entity/era_summary.rb +13 -12
- data/lib/entity/module_bytes.rb +16 -2
- data/lib/entity/status.rb +80 -0
- data/lib/entity/stored_value.rb +86 -11
- data/lib/entity/transfer.rb +7 -7
- data/lib/include.rb +2 -0
- data/lib/serialization/cl_value_serializer.rb +69 -12
- data/lib/serialization/cl_value_serializer1.rb +314 -0
- data/lib/serialization/cl_value_serializer_update.rb +320 -0
- data/lib/serialization/deploy_header_serializer.rb +1 -0
- data/lib/serialization/deploy_named_arg_serializer.rb +1 -0
- data/lib/serialization/deploy_serializer.rb +144 -10
- data/lib/serialization/deploy_serializer1.rb +392 -0
- data/lib/serialization/deploy_serializer_update.rb +397 -0
- data/lib/serialization/test.rb +33 -13
- data/lib/test_sdk1.rb +29 -10
- data/lib/types/cl_option.rb +8 -2
- data/lib/types/cl_public_key.rb +2 -0
- data/lib/types/cl_value.rb +8 -0
- data/lib/utils/byte_utils.rb +28 -0
- data/lib/utils/helpers.rb +10 -0
- data/lib/version.rb +1 -1
- data/spec/cl_value_serializer_spec.rb +16 -1
- data/spec/dene_spec.rb +186 -0
- data/spec/deploy_executable_spec.rb +90 -0
- data/spec/deploy_executable_test_spec.rb +117 -0
- data/spec/deploy_serializer_spec.rb +5 -3
- data/spec/deploy_serializer_test_spec.rb +7 -1
- data/spec/testnet_spec.rb +3 -1
- data/spec/time_utils_spec.rb +3 -0
- metadata +20 -5
- data/lib/crypto/key_pair.rb +0 -40
- data/spec/deploy_executable_serializer_spec.rb +0 -0
@@ -1,20 +1,120 @@
|
|
1
1
|
require_relative './deploy_named_argument.rb'
|
2
2
|
require_relative './module_bytes.rb'
|
3
3
|
require_relative './deploy_executable_transfer.rb'
|
4
|
-
|
4
|
+
require_relative '../utils/helpers.rb'
|
5
|
+
require_relative '../serialization/deploy_serializer.rb'
|
5
6
|
module Casper
|
6
7
|
module Entity
|
7
8
|
# DeployExecutable
|
8
9
|
class DeployExecutable
|
10
|
+
include Utils::Helpers
|
9
11
|
attr_accessor :module_bytes, :transfer, :stored_contract_by_hash, :stored_contract_by_name,
|
10
12
|
:stored_versioned_contract_by_hash, :stored_versioned_contract_by_name
|
11
|
-
|
12
|
-
|
13
|
+
|
14
|
+
def initialize(h = {})
|
15
|
+
deploy_serializer = DeploySerializer.new()
|
16
|
+
temp_args = []
|
17
|
+
deploy_serializer = DeploySerializer.new
|
18
|
+
# puts h.keys[0] # => ModuleByte
|
19
|
+
# @module_bytes = nil
|
20
|
+
if h.keys[0] == :ModuleBytes
|
21
|
+
args = h[:ModuleBytes][:args]
|
22
|
+
# puts args
|
23
|
+
args.each do |arg|
|
24
|
+
name1 = arg[0]
|
25
|
+
clvalue_hash = arg[1]
|
26
|
+
# puts clvalue_hash # => {:bytes=>"0400f90295", :parsed=>"2500000000", :cl_type=>"U512"}
|
27
|
+
clvalue = deploy_serializer.build_cl_value(arg[1])
|
28
|
+
# puts clvalue # => <CLu512:0x00000000015cbd58>
|
29
|
+
|
30
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
31
|
+
# puts temp_args[0][1]
|
32
|
+
end
|
33
|
+
@module_bytes = Casper::Entity::ModuleBytes.new(h[:ModuleBytes][:module_bytes], temp_args)
|
34
|
+
# puts @module_bytes.get_module_bytes # => Return empty, since module_bytes = ""
|
35
|
+
# puts @module_bytes.get_args[0][0].get_name # => amount
|
36
|
+
# puts @module_bytes.get_args[0][0].get_value # => <CLu512:0x0000000002fc54c0>
|
37
|
+
elsif h.keys[0] == :Transfer
|
38
|
+
# temp_args = []
|
39
|
+
# args = h[:Transfer][:args]
|
40
|
+
# # @transfer = Casper::Entity::DeployExecutableTransfer.new(args)
|
41
|
+
# args.each do |arg|
|
42
|
+
# name1 = arg[0]
|
43
|
+
# if name1 == "amount" || name1 == "target"
|
44
|
+
# clvalue_hash = arg[1]
|
45
|
+
# clvalue = deploy_serializer.build_cl_value(arg[1])
|
46
|
+
# # puts "clvalue.get_value: #{clvalue.get_value}"
|
47
|
+
# temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
48
|
+
# elsif name1 == "id"
|
49
|
+
# bytes = arg[1][:bytes]
|
50
|
+
# puts bytes
|
51
|
+
# parsed = arg[1][:parsed]
|
52
|
+
# puts parsed
|
53
|
+
# h = arg[1][:cl_type]
|
54
|
+
# key, value = h.first
|
55
|
+
# cl_type = h.keys[0]
|
56
|
+
# puts key, value
|
57
|
+
# # inner_type = value
|
58
|
+
# # inner_clvalue = Utils::Helpers.construct_inner_clvalue(cl_type, parsed)
|
59
|
+
# # # data = { "cl_type": inner_type, "bytes": bytes, "parsed": parsed}
|
60
|
+
# # clvalue = CLOption.new(inner_clvalue, inner_type)
|
61
|
+
# # temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
62
|
+
# end
|
63
|
+
temp_args = []
|
64
|
+
args = h[:Transfer][:args]
|
65
|
+
|
66
|
+
transfer = Casper::Entity::DeployExecutableTransfer.new(args)
|
67
|
+
# args.each do |arg|
|
68
|
+
# name1 = arg[0] # => "amount"
|
69
|
+
# clvalue_hash = arg[1] # => {:cl_type=>"I32", :bytes=>"e8030000", :parsed=>1000}
|
70
|
+
# clvalue = build_cl_value(arg[1])
|
71
|
+
# # puts clvalue
|
72
|
+
# temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
73
|
+
# end
|
74
|
+
|
75
|
+
args.each do |arg|
|
76
|
+
name1 = arg[0]
|
77
|
+
if name1 == "amount" || name1 == "target"
|
78
|
+
clvalue_hash = arg[1]
|
79
|
+
clvalue = deploy_serializer.build_cl_value(arg[1])
|
80
|
+
# puts "clvalue.get_value: #{clvalue.get_value}"
|
81
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
82
|
+
elsif name1 == "id"
|
83
|
+
bytes = arg[1][:bytes]
|
84
|
+
parsed = arg[1][:parsed]
|
85
|
+
h = arg[1][:cl_type]
|
86
|
+
key, value = h.first
|
87
|
+
cl_type = h.keys[0]
|
88
|
+
# puts key, value
|
89
|
+
inner_type = value
|
90
|
+
# puts "Inner Type = #{value}"
|
91
|
+
# data = { "cl_type": inner_type, "bytes": bytes, "parsed": parsed}
|
92
|
+
# clvalue = CLOption.new(data, inner_type)
|
93
|
+
|
94
|
+
inner_clvalue = Utils::Helpers.construct_inner_clvalue(inner_type, parsed)
|
95
|
+
clvalue = CLOption.new(inner_clvalue, inner_type)
|
96
|
+
# type = clvalue.get_cl_type
|
97
|
+
# puts type
|
98
|
+
# value = clvalue.get_value
|
99
|
+
# puts value
|
100
|
+
# tag = CLType::TAGS[type.to_sym]
|
101
|
+
# puts tag
|
102
|
+
# cl_value = { "cl_type": cl_type, "bytes": bytes, "parsed": parsed}
|
103
|
+
# clvalue = build_cl_value(cloption)
|
104
|
+
# puts cloption.get_value
|
105
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
106
|
+
end
|
107
|
+
end
|
108
|
+
@transfer = Casper::Entity::DeployExecutableTransfer.new(temp_args)
|
109
|
+
# puts @transfer
|
110
|
+
# puts args
|
111
|
+
end
|
112
|
+
# puts @transfer
|
13
113
|
@stored_contract_by_hash = nil
|
14
114
|
@stored_contract_by_name = nil
|
15
115
|
@stored_versioned_contract_by_hash = nil
|
16
116
|
@stored_versioned_contract_by_name = nil
|
17
|
-
|
117
|
+
# @transfer = nil
|
18
118
|
end
|
19
119
|
|
20
120
|
def standard_payment(payment_amount)
|
@@ -140,6 +240,7 @@ module Casper
|
|
140
240
|
|
141
241
|
def to_bytes
|
142
242
|
if module_bytes?
|
243
|
+
# puts "DeployExecutable::to_bytes " + module_bytes?.to_s
|
143
244
|
@module_bytes.to_bytes
|
144
245
|
elsif stored_contract_by_name?
|
145
246
|
@stored_contract_by_name.to_bytes
|
@@ -154,9 +255,10 @@ module Casper
|
|
154
255
|
elsif stored_versioned_contract_by_hash?
|
155
256
|
@stored_versioned_contract_by_hash.to_bytes
|
156
257
|
elsif transfer?
|
157
|
-
@transfer.to_bytes
|
258
|
+
@transfer.to_bytes
|
259
|
+
else
|
260
|
+
raise "failed to serialize ExecutableDeployItemJsonWrapper"
|
158
261
|
end
|
159
|
-
raise "failed to serialize ExecutableDeployItemJsonWrapper"
|
160
262
|
end
|
161
263
|
end
|
162
264
|
end
|
data/lib/entity/deploy_header.rb
CHANGED
@@ -47,6 +47,10 @@ module Casper
|
|
47
47
|
@body_hash
|
48
48
|
end
|
49
49
|
|
50
|
+
def set_body_hash(body_hash)
|
51
|
+
@body_hash = body_hash
|
52
|
+
end
|
53
|
+
|
50
54
|
# @return [Array] dependencies
|
51
55
|
def get_dependencies
|
52
56
|
@dependencies
|
@@ -56,6 +60,19 @@ module Casper
|
|
56
60
|
def get_chain_name
|
57
61
|
@chain_name
|
58
62
|
end
|
63
|
+
|
64
|
+
# @return [Hash] Deploy header
|
65
|
+
def to_hash
|
66
|
+
header = {}
|
67
|
+
header[:ttl] = @ttl
|
68
|
+
header[:account] = @account
|
69
|
+
header[:body_hash] = @body_hash
|
70
|
+
header[:gas_price] = @gas_price
|
71
|
+
header[:timestamp] = @timestamp
|
72
|
+
header[:chain_name] = @chain_name
|
73
|
+
header[:dependencies] = @dependencies
|
74
|
+
return header
|
75
|
+
end
|
59
76
|
end
|
60
77
|
end
|
61
78
|
end
|
@@ -5,7 +5,7 @@ module Casper
|
|
5
5
|
|
6
6
|
def initialize(name, clvalue)
|
7
7
|
@name = name
|
8
|
-
@
|
8
|
+
@clvalue = clvalue
|
9
9
|
end
|
10
10
|
|
11
11
|
def get_name
|
@@ -13,7 +13,74 @@ module Casper
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def get_value
|
16
|
-
@
|
16
|
+
@clvalue
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_byte_array(num)
|
20
|
+
result = []
|
21
|
+
begin
|
22
|
+
result << (num & 0xff)
|
23
|
+
num >>= 8
|
24
|
+
end until (num == 0 || num == -1) && (result.last[7] == num[7])
|
25
|
+
# result.reverse
|
26
|
+
result
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def to_hash
|
31
|
+
serializer = CLValueSerializer.new
|
32
|
+
value = @clvalue.get_value
|
33
|
+
type = @clvalue.get_cl_type
|
34
|
+
if @name == "amount"
|
35
|
+
bytes = Utils::ByteUtils.byte_array_to_hex(to_byte_array(value))[0...-2]
|
36
|
+
num_of_bytes = bytes.length/2
|
37
|
+
[num_of_bytes].pack("C*").unpack1("H*") + bytes
|
38
|
+
[
|
39
|
+
@name,
|
40
|
+
{
|
41
|
+
# "bytes": serializer.to_bytes(@clvalue.get_),
|
42
|
+
"bytes": [num_of_bytes].pack("C*").unpack1("H*") + bytes,
|
43
|
+
"parsed": @clvalue.get_value,
|
44
|
+
"cl_type": @clvalue.get_cl_type
|
45
|
+
}
|
46
|
+
]
|
47
|
+
elsif @name == "target" && type == "PublicKey"
|
48
|
+
[
|
49
|
+
@name,
|
50
|
+
{
|
51
|
+
"bytes": @clvalue.to_hex,
|
52
|
+
# "bytes": [num_of_bytes].pack("C*").unpack1("H*") + bytes,
|
53
|
+
"parsed": @clvalue.to_hex,
|
54
|
+
"cl_type": @clvalue.get_cl_type
|
55
|
+
}
|
56
|
+
]
|
57
|
+
elsif @name == "id"
|
58
|
+
# puts @clvalue.get_cl_type
|
59
|
+
data = @clvalue.get_value
|
60
|
+
inner_type = data.get_cl_type
|
61
|
+
# puts inner_type
|
62
|
+
inner_value = data.get_value
|
63
|
+
parsed = inner_value
|
64
|
+
bytes = "01" + serializer.only_value(data)
|
65
|
+
# puts "01" + bytes
|
66
|
+
# inner_data = @clvalue.get_value
|
67
|
+
# inner_type = inner_data[:cl_type]
|
68
|
+
# value = inner_data[:]
|
69
|
+
# puts inner_data
|
70
|
+
# puts inner_type
|
71
|
+
[
|
72
|
+
@name,
|
73
|
+
{
|
74
|
+
"bytes": bytes,
|
75
|
+
# "bytes": [num_of_bytes].pack("C*").unpack1("H*") + bytes,
|
76
|
+
"parsed": parsed,
|
77
|
+
"cl_type": {
|
78
|
+
"#{type}": inner_type
|
79
|
+
}
|
80
|
+
}
|
81
|
+
]
|
82
|
+
end
|
83
|
+
|
17
84
|
end
|
18
85
|
end
|
19
86
|
end
|
data/lib/entity/era_summary.rb
CHANGED
@@ -3,17 +3,18 @@ module Casper
|
|
3
3
|
# The summary of an era.
|
4
4
|
class EraSummary
|
5
5
|
|
6
|
-
# @param [
|
7
|
-
# @
|
8
|
-
# @
|
9
|
-
# @
|
10
|
-
# @
|
11
|
-
|
12
|
-
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
6
|
+
# @param [Hash] era_summary
|
7
|
+
# @option era_summary [String] :block_hash
|
8
|
+
# @option era_summary [Integer] :era_id
|
9
|
+
# @option era_summary [Hash] :stored_value
|
10
|
+
# @option era_summary [String] :state_root_hash
|
11
|
+
# @option era_summary [String] :merkle_proof
|
12
|
+
def initialize(era_summary = {})
|
13
|
+
@block_hash = era_summary[:block_hash]
|
14
|
+
@era_id = era_summary[:era_id]
|
15
|
+
@stored_value = Casper::Entity::StoredValue.new(era_summary[:stored_value])
|
16
|
+
@state_root_hash = era_summary[:state_root_hash]
|
17
|
+
@merkle_proof = era_summary[:merkle_proof]
|
17
18
|
end
|
18
19
|
|
19
20
|
# @return [String] block_hash
|
@@ -26,7 +27,7 @@ module Casper
|
|
26
27
|
@era_id
|
27
28
|
end
|
28
29
|
|
29
|
-
# @return [
|
30
|
+
# @return [Hash] StoredValue
|
30
31
|
def get_stored_value
|
31
32
|
@stored_value
|
32
33
|
end
|
data/lib/entity/module_bytes.rb
CHANGED
@@ -7,45 +7,59 @@ module Casper
|
|
7
7
|
|
8
8
|
# @param [String] module_bytes
|
9
9
|
# @param [Array<Array<DeployNamedArgument>>] args
|
10
|
-
def initialize(module_bytes
|
10
|
+
def initialize(module_bytes, args = [])
|
11
|
+
# puts args[0][0].get_name
|
12
|
+
# puts args[0][0].get_value
|
11
13
|
@tag = 0
|
12
14
|
@module_bytes = module_bytes
|
13
15
|
@args = args
|
14
16
|
end
|
15
17
|
|
18
|
+
# @return [Integer] the tag value
|
16
19
|
def get_tag
|
17
20
|
@tag
|
18
21
|
end
|
19
22
|
|
23
|
+
# @return [String] the module bytes
|
20
24
|
def get_module_bytes
|
21
25
|
@module_bytes
|
22
26
|
end
|
23
27
|
|
28
|
+
# @return [Array<DeployNamedArgument>] an array of DeployNamedArgument objects
|
24
29
|
def get_args
|
25
30
|
@args
|
26
31
|
end
|
27
32
|
|
33
|
+
# @param [DeployNamedArgument]
|
34
|
+
# @return [Array<DeployNamedArgument>] an array of DeployNamedArgument objects
|
28
35
|
def set_arg(deploy_named_arg)
|
29
36
|
@args << [deploy_named_arg]
|
30
37
|
end
|
31
38
|
|
39
|
+
# @return [Array<Integer>] the byte serialization of ModuleByte object
|
32
40
|
def to_bytes
|
41
|
+
puts "ModuleBytes::to_bytes is called"
|
33
42
|
bytes = ""
|
34
43
|
serializer = DeployNamedArgSerializer.new
|
35
44
|
num_of_args = @args.length
|
36
45
|
bytes += Utils::ByteUtils.to_u8(@tag)
|
37
|
-
|
38
46
|
if @module_bytes == ""
|
39
47
|
bytes += Utils::ByteUtils.to_u32(0)
|
40
48
|
end
|
41
49
|
bytes += Utils::ByteUtils.to_u32(num_of_args)
|
50
|
+
# puts args[0][0].get_name
|
51
|
+
# puts args[0][0].get_value
|
42
52
|
@args.each do |arg|
|
43
53
|
arg.each do |item|
|
44
54
|
bytes += serializer.to_bytes(item)
|
55
|
+
# puts item.get_name
|
56
|
+
# puts item.get_value
|
45
57
|
end
|
46
58
|
end
|
47
59
|
Utils::ByteUtils.hex_to_byte_array(bytes)
|
60
|
+
# bytes
|
48
61
|
end
|
62
|
+
|
49
63
|
end
|
50
64
|
end
|
51
65
|
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Casper
|
2
|
+
module Entity
|
3
|
+
class Status
|
4
|
+
# @param [Hash] status
|
5
|
+
# @option status [String] :api_version
|
6
|
+
# @option status [String] :chainspec_name
|
7
|
+
# @option status [String] :starting_state_root_hash
|
8
|
+
# @option status [Array<Hash>] :peers
|
9
|
+
# @option status [Hash] :last_added_block_info
|
10
|
+
# @option status [String] :our_public_signing_key
|
11
|
+
# @option status [Integer] :round_length
|
12
|
+
# @option status [String] :next_upgrade
|
13
|
+
# @option status [String] :build_version
|
14
|
+
# @option status [String] :uptime
|
15
|
+
def initialize(status = {})
|
16
|
+
@api_version = status[:api_version]
|
17
|
+
@chainspec_name = status[:chainspec_name]
|
18
|
+
@starting_state_root_hash = status[:starting_state_root_hash]
|
19
|
+
@peers = []
|
20
|
+
status[:peers].map { |peer| @peers << Casper::Entity::Peer.new(peer)}
|
21
|
+
@last_added_block_info = status[:last_added_block_info]
|
22
|
+
@our_public_signing_key = status[:our_public_signing_key]
|
23
|
+
@round_length = status[:round_length]
|
24
|
+
@next_upgrade = status[:next_upgrade]
|
25
|
+
@build_version = status[:build_version]
|
26
|
+
@uptime = status[:uptime]
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [String] the RPC API version.
|
30
|
+
def get_api_version
|
31
|
+
@api_version
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [String] the chainspec name.
|
35
|
+
def get_chainspec_name
|
36
|
+
@chainspec_name
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [String] the state root hash used at the start of the current sessio
|
40
|
+
def get_starting_state_root_hash
|
41
|
+
@starting_state_root_hash
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [Array<Peer>] the node ID and network address of each connected peer.
|
45
|
+
def get_peers
|
46
|
+
@peers
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [Hash] the minimal info of the last block from the linear chain.
|
50
|
+
def get_last_added_block_info
|
51
|
+
@last_added_block_info
|
52
|
+
end
|
53
|
+
|
54
|
+
# @return [String] Our public signing key.
|
55
|
+
def get_our_public_signing_key
|
56
|
+
@our_public_signing_key
|
57
|
+
end
|
58
|
+
|
59
|
+
# @return [Integer] the next round length if this node is a validator.
|
60
|
+
def get_round_length
|
61
|
+
@round_length
|
62
|
+
end
|
63
|
+
|
64
|
+
# @return [String] information about the next scheduled upgrade.
|
65
|
+
def get_next_upgrade
|
66
|
+
@next_upgrade
|
67
|
+
end
|
68
|
+
|
69
|
+
# @return [String] the compiled node version.
|
70
|
+
def get_build_version
|
71
|
+
@build_version
|
72
|
+
end
|
73
|
+
|
74
|
+
# @return [String] the time that passed since the node has started.
|
75
|
+
def get_uptime
|
76
|
+
@uptime
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/lib/entity/stored_value.rb
CHANGED
@@ -1,57 +1,132 @@
|
|
1
|
+
|
1
2
|
module Casper
|
2
3
|
module Entity
|
3
4
|
|
4
5
|
# A class that represents a value stored in global state.
|
5
6
|
class StoredValue
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
8
|
+
# @param [Hash] stored_value
|
9
|
+
# @option stored_value [CLValue] :CLValue
|
10
|
+
# @option stored_value [Account] :Account
|
11
|
+
# @option stored_value [String] :ContractWasm
|
12
|
+
# @option stored_value [Contract] :Contract
|
13
|
+
# @option stored_value [ContractPackage] :ContractPackage
|
14
|
+
# @option stored_value [Transfer] :Transfer
|
15
|
+
# @option stored_value [DeployInfo] :DeployInfo
|
16
|
+
# @option stored_value [EraInfo] :EraInfo
|
17
|
+
# @option stored_value [Bid] :Bid
|
18
|
+
# @option stored_value [Array] :Withdraw
|
19
|
+
def initialize(stored_value = {})
|
20
|
+
@stored_value = stored_value
|
21
|
+
@cl_value = nil
|
22
|
+
@account = nil
|
23
|
+
@contract_wasm = nil
|
24
|
+
@contract = nil
|
25
|
+
@contract_package = nil
|
26
|
+
@transfer = nil
|
27
|
+
@deploy_info = nil
|
28
|
+
@era_info = nil
|
29
|
+
@bid = nil
|
30
|
+
@withdraw = nil
|
31
|
+
@key = nil
|
32
|
+
if stored_value.has_key?(:CLValue)
|
33
|
+
@cl_value = stored_value[:CLValue]
|
34
|
+
@key = :CLValue
|
35
|
+
end
|
36
|
+
if stored_value.has_key?(:Account)
|
37
|
+
@account = stored_value[:Account]
|
38
|
+
@key = :Account
|
39
|
+
end
|
40
|
+
if stored_value.has_key?(:ContractWasm)
|
41
|
+
@contract_wasm = stored_value[:ContractWasm]
|
42
|
+
@key = :ContractWasm
|
43
|
+
end
|
44
|
+
if stored_value.has_key?(:Contract)
|
45
|
+
@contract = stored_value[:Contract]
|
46
|
+
@key = :Contract
|
47
|
+
end
|
48
|
+
if stored_value.has_key?(:ContractPackage)
|
49
|
+
@contract_package = stored_value[:ContractPackage]
|
50
|
+
@key = :ContractPackage
|
51
|
+
end
|
52
|
+
if stored_value.has_key?(:Transfer)
|
53
|
+
@transfer = stored_value[:Transfer]
|
54
|
+
@key = :Transfer
|
55
|
+
end
|
56
|
+
if stored_value.has_key?(:DeployInfo)
|
57
|
+
@transfer = stored_value[:DeployInfo]
|
58
|
+
@key = :Deploy
|
59
|
+
end
|
60
|
+
if stored_value.has_key?(:EraInfo)
|
61
|
+
@era_info = stored_value[:EraInfo]
|
62
|
+
@key = :EraInfo
|
63
|
+
end
|
64
|
+
if stored_value.has_key?(:Bid)
|
65
|
+
@bid = stored_value[:Bid]
|
66
|
+
@key = :Bid
|
67
|
+
end
|
68
|
+
if stored_value.has_key?(:Withdraw)
|
69
|
+
@withdraw = stored_value[:Withdraw]
|
70
|
+
@key = :Withdraw
|
71
|
+
end
|
17
72
|
end
|
18
73
|
|
74
|
+
# @return [CLValue] a CasperLabs value.
|
19
75
|
def get_cl_value
|
20
76
|
@cl_value
|
21
77
|
end
|
22
78
|
|
79
|
+
# @return [Account] an account.
|
23
80
|
def get_account
|
24
81
|
@account
|
25
82
|
end
|
26
83
|
|
84
|
+
# @return [String] a contract’s Wasm
|
27
85
|
def get_contract
|
28
86
|
@contract
|
29
87
|
end
|
30
|
-
|
88
|
+
|
89
|
+
# @return [Contract] methods and type signatures supported by a contract.
|
90
|
+
def get_contract
|
91
|
+
@contract
|
92
|
+
end
|
93
|
+
# @return [ContractPackage] contract definition, metadata, and security container.
|
31
94
|
def get_contract_package
|
32
95
|
@contract_package
|
33
96
|
end
|
34
97
|
|
98
|
+
# @return [Transfer] record of a transfer
|
35
99
|
def get_transfer
|
36
100
|
@transfer
|
37
101
|
end
|
38
102
|
|
103
|
+
# @return [DeployInfo] record of a deploy
|
39
104
|
def get_deploy_info
|
40
105
|
@deploy_info
|
41
106
|
end
|
42
107
|
|
108
|
+
# @return [EraInfo] auction metadata
|
43
109
|
def get_era_info
|
44
110
|
@era_info
|
45
111
|
end
|
46
112
|
|
113
|
+
# @return [Bid] a bid
|
47
114
|
def get_bid
|
48
115
|
@bid
|
49
116
|
end
|
50
117
|
|
118
|
+
# @return [Array] a withdraw
|
51
119
|
def get_withdraw
|
52
120
|
@withdraw
|
53
121
|
end
|
54
122
|
|
123
|
+
def get_stored_value
|
124
|
+
@stored_value[@key]
|
125
|
+
end
|
126
|
+
|
127
|
+
def get_key
|
128
|
+
@key
|
129
|
+
end
|
55
130
|
end
|
56
131
|
end
|
57
132
|
end
|
data/lib/entity/transfer.rb
CHANGED
@@ -23,32 +23,32 @@ module Casper
|
|
23
23
|
@id = transfer[:id]
|
24
24
|
end
|
25
25
|
|
26
|
-
# @return [String]
|
26
|
+
# @return [String] deploy that created the transfer
|
27
27
|
def get_deploy_hash
|
28
28
|
@deploy_hash
|
29
29
|
end
|
30
30
|
|
31
|
-
# @return [String] from
|
31
|
+
# @return [String] account from which transfer was executed
|
32
32
|
def get_from
|
33
33
|
@from
|
34
34
|
end
|
35
35
|
|
36
|
-
# @return [String] to
|
36
|
+
# @return [String] account to which funds are transferred
|
37
37
|
def get_to
|
38
38
|
@to
|
39
39
|
end
|
40
40
|
|
41
|
-
# @return [String]
|
41
|
+
# @return [String] tource purse
|
42
42
|
def get_source
|
43
43
|
@source
|
44
44
|
end
|
45
45
|
|
46
|
-
# @return [String] target
|
46
|
+
# @return [String] target purse
|
47
47
|
def get_target
|
48
48
|
@target
|
49
49
|
end
|
50
50
|
|
51
|
-
# @return [String] amount
|
51
|
+
# @return [String] transfer amount
|
52
52
|
def get_amount
|
53
53
|
@amount
|
54
54
|
end
|
@@ -57,7 +57,7 @@ module Casper
|
|
57
57
|
def get_gas
|
58
58
|
@gas
|
59
59
|
end
|
60
|
-
# @return [Integer] id
|
60
|
+
# @return [Integer] user-defined id
|
61
61
|
def get_id
|
62
62
|
@id
|
63
63
|
end
|
data/lib/include.rb
CHANGED
@@ -7,6 +7,8 @@ Dir[File.join(
|
|
7
7
|
File.dirname(File.dirname(File.absolute_path(__FILE__))), "/lib/rpc/*.rb")].each {|file| require file }
|
8
8
|
Dir[File.join(
|
9
9
|
File.dirname(File.dirname(File.absolute_path(__FILE__))), "/lib/utils/*.rb")].each {|file| require file }
|
10
|
+
# Dir[File.join(
|
11
|
+
# File.dirname(File.dirname(File.absolute_path(__FILE__))), "/lib/crypto/*.rb")].each {|file| require file }
|
10
12
|
# path = File.join(
|
11
13
|
# File.dirname(File.dirname(File.absolute_path(__FILE__))),
|
12
14
|
# '/lib/types/cl_bool'
|