test_sdk1 1.0.3 → 1.1.3
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
@@ -0,0 +1,392 @@
|
|
1
|
+
require_relative './deploy_header_serializer'
|
2
|
+
require_relative './deploy_approval_serializer'
|
3
|
+
require_relative './deploy_executable_serializer'
|
4
|
+
require_relative './deploy_named_arg_serializer'
|
5
|
+
require_relative '../utils/byte_utils.rb'
|
6
|
+
require_relative '../types/cl_option.rb'
|
7
|
+
# Byte serializer for Deploy object
|
8
|
+
class DeploySerializer
|
9
|
+
attr_accessor :payment_session_serializer, :transfer_serializer, :payment_serializer
|
10
|
+
def initialize
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_bytes(deploy)
|
14
|
+
@payment_session_serializer = ""
|
15
|
+
@amount_serializer = ""
|
16
|
+
@target_serializer = ""
|
17
|
+
@id_serializer = ""
|
18
|
+
@transfer_serializer = ""
|
19
|
+
@payment_serializer = ""
|
20
|
+
result = ""
|
21
|
+
deploy_header = Casper::Entity::DeployHeader.new(deploy.get_header)
|
22
|
+
result += DeployHeaderSerializer.new().to_bytes(deploy_header)
|
23
|
+
|
24
|
+
deploy_hash = Casper::Entity::DeployHash.new(deploy.get_hash)
|
25
|
+
result += deploy_hash.get_hash
|
26
|
+
payment = deploy.get_payment
|
27
|
+
session = deploy.get_session
|
28
|
+
if payment.keys[0] == :ModuleBytes
|
29
|
+
temp_args = []
|
30
|
+
module_bytes = payment[:ModuleBytes][:module_bytes]
|
31
|
+
args = payment[:ModuleBytes][:args]
|
32
|
+
# module_bytes = Casper::Entity::ModuleBytes.new(module_bytes, args)
|
33
|
+
args.each do |arg|
|
34
|
+
name1 = arg[0]
|
35
|
+
clvalue_hash = arg[1]
|
36
|
+
clvalue = build_cl_value(arg[1])
|
37
|
+
# puts clvalue
|
38
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
39
|
+
end
|
40
|
+
temp = Utils::ByteUtils.byte_array_to_hex(Casper::Entity::ModuleBytes.new(module_bytes, temp_args).to_bytes)
|
41
|
+
result += temp
|
42
|
+
@payment_serializer += temp
|
43
|
+
@payment_session_serializer += temp
|
44
|
+
temp = nil
|
45
|
+
elsif payment.keys[0] == :StoredContractByHash
|
46
|
+
temp_args = []
|
47
|
+
hash = payment[:StoredContractByHash][:hash]
|
48
|
+
entry_point = payment[:StoredContractByHash][:entry_point]
|
49
|
+
args = payment[:StoredContractByHash][:args]
|
50
|
+
stored_contract_by_hash = Casper::Entity::StoredContractByHash.new(hash, entry_point, args)
|
51
|
+
|
52
|
+
args.each do |arg|
|
53
|
+
name1 = arg[0] # => "quantity"
|
54
|
+
clvalue_hash = arg[1] # => {:cl_type=>"I32", :bytes=>"e8030000", :parsed=>1000}
|
55
|
+
clvalue = build_cl_value(arg[1])
|
56
|
+
# puts clvalue
|
57
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
58
|
+
end
|
59
|
+
temp = Utils::ByteUtils.byte_array_to_hex(Casper::Entity::StoredContractByHash.new(name, entry_point, temp_args).to_bytes)
|
60
|
+
result += temp
|
61
|
+
@payment_session_serializer += temp
|
62
|
+
temp = nil
|
63
|
+
elsif payment.keys[0] == :StoredContractByName
|
64
|
+
temp_args = []
|
65
|
+
name = payment[:StoredContractByName][:name]
|
66
|
+
entry_point = payment[:StoredContractByName][:entry_point]
|
67
|
+
args = payment[:StoredContractByName][:args]
|
68
|
+
|
69
|
+
stored_contract_by_name = Casper::Entity::StoredContractByName.new(name, entry_point, args)
|
70
|
+
args.each do |arg|
|
71
|
+
name1 = arg[0] # => "quantity"
|
72
|
+
clvalue_hash = arg[1] # => {:cl_type=>"I32", :bytes=>"e8030000", :parsed=>1000}
|
73
|
+
clvalue = build_cl_value(arg[1])
|
74
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
75
|
+
end
|
76
|
+
temp = Utils::ByteUtils.byte_array_to_hex(Casper::Entity::StoredContractByName.new(name, entry_point, temp_args).to_bytes)
|
77
|
+
result += temp
|
78
|
+
@payment_session_serializer += temp
|
79
|
+
temp = nil
|
80
|
+
elsif payment.keys[0] == :StoredVersionedContractByHash
|
81
|
+
temp_args = []
|
82
|
+
hash = payment[:StoredVersionedContractByHash][:name]
|
83
|
+
version = payment[:StoredVersionedContractByHash][:version]
|
84
|
+
entry_point = payment[:StoredVersionedContractByHash][:entry_point]
|
85
|
+
args = payment[:StoredVersionedContractByHash][:args]
|
86
|
+
|
87
|
+
stored_versioned_contract_by_hash = Casper::Entity::StoredVersionedContractByHash.new(hash, version, entry_point, args)
|
88
|
+
args.each do |arg|
|
89
|
+
name1 = arg[0]
|
90
|
+
clvalue_hash = arg[1]
|
91
|
+
clvalue = build_cl_value(arg[1])
|
92
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
93
|
+
end
|
94
|
+
temp = Utils::ByteUtils.byte_array_to_hex(Casper::Entity::StoredVersionedContractByHash.new(name, version,entry_point, temp_args).to_bytes)
|
95
|
+
result += temp
|
96
|
+
@payment_session_serializer += temp
|
97
|
+
temp = nil
|
98
|
+
elsif payment.keys[0] == :StoredVersionedContractByName
|
99
|
+
temp_args = []
|
100
|
+
name = payment[:StoredVersionedContractByName][:name]
|
101
|
+
version = payment[:StoredVersionedContractByName][:version]
|
102
|
+
entry_point = payment[:StoredVersionedContractByName][:entry_point]
|
103
|
+
args = payment[:StoredVersionedContractByName][:args]
|
104
|
+
|
105
|
+
stored_versioned_contract_by_name = Casper::Entity::StoredVersionedContractByName.new(name, version, entry_point, args)
|
106
|
+
args.each do |arg|
|
107
|
+
name1 = arg[0]
|
108
|
+
clvalue_hash = arg[1]
|
109
|
+
clvalue = build_cl_value(arg[1])
|
110
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
111
|
+
end
|
112
|
+
temp = Utils::ByteUtils.byte_array_to_hex(Casper::Entity::StoredVersionedContractByName.new(name, version,entry_point, temp_args).to_bytes)
|
113
|
+
result += temp
|
114
|
+
@payment_session_serializer += temp
|
115
|
+
temp = nil
|
116
|
+
elsif payment.keys[0] == :Transfer
|
117
|
+
temp_args = []
|
118
|
+
args = payment[:Transfer][:args]
|
119
|
+
|
120
|
+
transfer = Casper::Entity::DeployExecutableTransfer.new(args)
|
121
|
+
args.each do |arg|
|
122
|
+
name1 = arg[0] # => "amount"
|
123
|
+
clvalue_hash = arg[1] # => {:cl_type=>"I32", :bytes=>"e8030000", :parsed=>1000}
|
124
|
+
clvalue = build_cl_value(arg[1])
|
125
|
+
# puts clvalue
|
126
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
127
|
+
end
|
128
|
+
temp = Utils::ByteUtils.byte_array_to_hex(Casper::Entity::DeployExecutableTransfer.new(temp_args).to_bytes)
|
129
|
+
result += temp
|
130
|
+
@payment_session_serializer += temp
|
131
|
+
temp = nil
|
132
|
+
end
|
133
|
+
|
134
|
+
if session.keys[0] == :ModuleBytes
|
135
|
+
temp_args = []
|
136
|
+
module_bytes = session[:ModuleBytes][:module_bytes]
|
137
|
+
args = session[:ModuleBytes][:args]
|
138
|
+
# module_bytes = Casper::Entity::ModuleBytes.new(module_bytes, args)
|
139
|
+
args.each do |arg|
|
140
|
+
name1 = arg[0]
|
141
|
+
clvalue_hash = arg[1]
|
142
|
+
clvalue = build_cl_value(arg[1])
|
143
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
144
|
+
end
|
145
|
+
temp = Utils::ByteUtils.byte_array_to_hex(Casper::Entity::ModuleBytes.new(module_bytes, temp_args).to_bytes)
|
146
|
+
result += temp
|
147
|
+
@payment_session_serializer += temp
|
148
|
+
temp = nil
|
149
|
+
elsif session.keys[0] == :StoredContractByHash
|
150
|
+
temp_args = []
|
151
|
+
hash = session[:StoredContractByHash][:hash]
|
152
|
+
entry_point = session[:StoredContractByHash][:entry_point]
|
153
|
+
args = session[:StoredContractByHash][:args]
|
154
|
+
stored_contract_by_hash = Casper::Entity::StoredContractByHash.new(hash, entry_point, args)
|
155
|
+
|
156
|
+
args.each do |arg|
|
157
|
+
name1 = arg[0] # => "quantity"
|
158
|
+
clvalue_hash = arg[1] # => {:cl_type=>"I32", :bytes=>"e8030000", :parsed=>1000}
|
159
|
+
clvalue = build_cl_value(arg[1])
|
160
|
+
# puts clvalue
|
161
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
162
|
+
end
|
163
|
+
temp = Utils::ByteUtils.byte_array_to_hex(Casper::Entity::StoredContractByHash.new(name, entry_point, temp_args).to_bytes)
|
164
|
+
result += temp
|
165
|
+
@payment_session_serializer += temp
|
166
|
+
temp = nil
|
167
|
+
elsif session.keys[0] == :StoredContractByName
|
168
|
+
temp_args = []
|
169
|
+
name = session[:StoredContractByName][:name]
|
170
|
+
entry_point = session[:StoredContractByName][:entry_point]
|
171
|
+
args = session[:StoredContractByName][:args]
|
172
|
+
|
173
|
+
stored_contract_by_name = Casper::Entity::StoredContractByName.new(name, entry_point, args)
|
174
|
+
args.each do |arg|
|
175
|
+
name1 = arg[0] # => "quantity"
|
176
|
+
clvalue_hash = arg[1] # => {:cl_type=>"I32", :bytes=>"e8030000", :parsed=>1000}
|
177
|
+
clvalue = build_cl_value(arg[1])
|
178
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
179
|
+
end
|
180
|
+
temp = Utils::ByteUtils.byte_array_to_hex(Casper::Entity::StoredContractByName.new(name, entry_point, temp_args).to_bytes)
|
181
|
+
result += temp
|
182
|
+
@payment_session_serializer += temp
|
183
|
+
temp = nil
|
184
|
+
elsif session.keys[0] == :StoredVersionedContractByHash
|
185
|
+
temp_args = []
|
186
|
+
hash = session[:StoredVersionedContractByHash][:name]
|
187
|
+
version = session[:StoredVersionedContractByHash][:version]
|
188
|
+
entry_point = session[:StoredVersionedContractByHash][:entry_point]
|
189
|
+
args = session[:StoredVersionedContractByHash][:args]
|
190
|
+
|
191
|
+
stored_versioned_contract_by_hash = Casper::Entity::StoredVersionedContractByHash.new(hash, version, entry_point, args)
|
192
|
+
args.each do |arg|
|
193
|
+
name1 = arg[0]
|
194
|
+
clvalue_hash = arg[1]
|
195
|
+
clvalue = build_cl_value(arg[1])
|
196
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
197
|
+
end
|
198
|
+
temp = Utils::ByteUtils.byte_array_to_hex(Casper::Entity::StoredVersionedContractByHash.new(name, version,entry_point, temp_args).to_bytes)
|
199
|
+
result += temp
|
200
|
+
@payment_session_serializer += temp
|
201
|
+
temp = nil
|
202
|
+
elsif session.keys[0] == :StoredVersionedContractByName
|
203
|
+
temp_args = []
|
204
|
+
name = session[:StoredVersionedContractByName][:name]
|
205
|
+
version = session[:StoredVersionedContractByName][:version]
|
206
|
+
entry_point = session[:StoredVersionedContractByName][:entry_point]
|
207
|
+
args = session[:StoredVersionedContractByName][:args]
|
208
|
+
|
209
|
+
stored_versioned_contract_by_name = Casper::Entity::StoredVersionedContractByName.new(name, version, entry_point, args)
|
210
|
+
args.each do |arg|
|
211
|
+
name1 = arg[0]
|
212
|
+
clvalue_hash = arg[1]
|
213
|
+
clvalue = build_cl_value(arg[1])
|
214
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
215
|
+
end
|
216
|
+
temp = Utils::ByteUtils.byte_array_to_hex(Casper::Entity::StoredVersionedContractByName.new(name, version,entry_point, temp_args).to_bytes)
|
217
|
+
result += temp
|
218
|
+
@payment_session_serializer += temp
|
219
|
+
temp = nil
|
220
|
+
|
221
|
+
elsif session.keys[0] == :Transfer
|
222
|
+
temp_args = []
|
223
|
+
args = session[:Transfer][:args]
|
224
|
+
|
225
|
+
transfer = Casper::Entity::DeployExecutableTransfer.new(args)
|
226
|
+
# args.each do |arg|
|
227
|
+
# name1 = arg[0] # => "amount"
|
228
|
+
# clvalue_hash = arg[1] # => {:cl_type=>"I32", :bytes=>"e8030000", :parsed=>1000}
|
229
|
+
# clvalue = build_cl_value(arg[1])
|
230
|
+
# # puts clvalue
|
231
|
+
# temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
232
|
+
# end
|
233
|
+
|
234
|
+
args.each do |arg|
|
235
|
+
name1 = arg[0]
|
236
|
+
if name1 == "amount" || name1 == "target"
|
237
|
+
clvalue_hash = arg[1]
|
238
|
+
clvalue = build_cl_value(arg[1])
|
239
|
+
puts "clvalue.get_value: #{clvalue.get_value}"
|
240
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
241
|
+
elsif name1 == "id"
|
242
|
+
bytes = arg[1][:bytes]
|
243
|
+
parsed = arg[1][:parsed]
|
244
|
+
h = arg[1][:cl_type]
|
245
|
+
key, value = h.first
|
246
|
+
cl_type = h.keys[0]
|
247
|
+
# puts key, value
|
248
|
+
inner_type = value
|
249
|
+
data = { "cl_type": inner_type, "bytes": bytes, "parsed": parsed}
|
250
|
+
clvalue = CLOption.new(data, inner_type)
|
251
|
+
# type = clvalue.get_cl_type
|
252
|
+
# puts type
|
253
|
+
# value = clvalue.get_value
|
254
|
+
# puts value
|
255
|
+
# tag = CLType::TAGS[type.to_sym]
|
256
|
+
# puts tag
|
257
|
+
# cl_value = { "cl_type": cl_type, "bytes": bytes, "parsed": parsed}
|
258
|
+
# clvalue = build_cl_value(cloption)
|
259
|
+
# puts cloption.get_value
|
260
|
+
temp_args << [Casper::Entity::DeployNamedArgument.new(name1, clvalue)]
|
261
|
+
end
|
262
|
+
end
|
263
|
+
temp = Utils::ByteUtils.byte_array_to_hex(Casper::Entity::DeployExecutableTransfer.new(temp_args).to_bytes)
|
264
|
+
@target_serializer = temp
|
265
|
+
# puts @target_serializer
|
266
|
+
result += temp
|
267
|
+
@transfer_serializer += temp
|
268
|
+
@payment_session_serializer += temp
|
269
|
+
temp = nil
|
270
|
+
end
|
271
|
+
|
272
|
+
approvals = deploy.get_approvals
|
273
|
+
num_of_approvals = approvals.size
|
274
|
+
puts "num_of_approvals: #{num_of_approvals}"
|
275
|
+
approval_serializer = ""
|
276
|
+
deploy_approval_serializer = DeployApprovalSerializer.new
|
277
|
+
result += Utils::ByteUtils.to_u32(num_of_approvals)
|
278
|
+
approval_serializer += Utils::ByteUtils.to_u32(num_of_approvals)
|
279
|
+
# @payment_session_serializer += Utils::ByteUtils.to_u32(num_of_approvals)
|
280
|
+
for approval in approvals
|
281
|
+
deploy_approval = Casper::Entity::DeployApproval.new(approval)
|
282
|
+
# @payment_session_serializer += deploy_approval_serializer.to_bytes(deploy_approval)
|
283
|
+
result += deploy_approval_serializer.to_bytes(deploy_approval)
|
284
|
+
approval_serializer += deploy_approval_serializer.to_bytes(deploy_approval)
|
285
|
+
end
|
286
|
+
puts "approval_serializer: #{approval_serializer}"
|
287
|
+
# result
|
288
|
+
Utils::ByteUtils.hex_to_byte_array(result)
|
289
|
+
end
|
290
|
+
|
291
|
+
def build_cl_value(h = {})
|
292
|
+
cl_type = h[:cl_type]
|
293
|
+
bytes = h[:bytes]
|
294
|
+
# puts bytes
|
295
|
+
parsed = h[:parsed]
|
296
|
+
if cl_type == "Bool"
|
297
|
+
CLValueBytesParsers::CLBoolBytesParser.from_bytes([bytes])
|
298
|
+
elsif cl_type == "I32"
|
299
|
+
value = Utils::ByteUtils.hex_to_integer(bytes)
|
300
|
+
CLi32.new(value)
|
301
|
+
elsif cl_type == "I64"
|
302
|
+
value = Utils::ByteUtils.hex_to_i64_value(bytes)
|
303
|
+
CLi64.new(value)
|
304
|
+
elsif cl_type == "U8"
|
305
|
+
value = Utils::ByteUtils.hex_to_u8_value(bytes)
|
306
|
+
CLu8.new(value)
|
307
|
+
elsif cl_type == "U32"
|
308
|
+
value = Utils::ByteUtils.hex_to_u32_value(bytes)
|
309
|
+
CLu32.new(value)
|
310
|
+
elsif cl_type == "U64"
|
311
|
+
value = Utils::ByteUtils.hex_to_u64_value(bytes)
|
312
|
+
CLu32.new(value)
|
313
|
+
elsif cl_type == "U512"
|
314
|
+
bytes = h[:bytes] # => 0400e1f505
|
315
|
+
num_of_bytes = bytes[0..1] # => 04
|
316
|
+
bytes = bytes[2..] # => "00e1f505"
|
317
|
+
puts "bytes: #{bytes}"
|
318
|
+
value = [bytes].pack("H*").unpack("L*").first
|
319
|
+
puts "build_cl_value --> value: #{value}"
|
320
|
+
# CLu512.new(value)
|
321
|
+
CLu512.new(parsed.to_i)
|
322
|
+
# value = Utils::ByteUtils.hex_to_u64_value(bytes)
|
323
|
+
# CLu512.new(value)
|
324
|
+
# value = Utils::ByteUtils.hex_to_u512_value(bytes)
|
325
|
+
# CLu512.new(value)
|
326
|
+
elsif cl_type == "Unit"
|
327
|
+
# value = CLValueBytesParsers::CLUnitBytesParser.from_bytes(bytes)
|
328
|
+
if bytes == ""
|
329
|
+
value = nil
|
330
|
+
CLUnit.new(value)
|
331
|
+
end
|
332
|
+
elsif cl_type == "String"
|
333
|
+
value = CLValueBytesParsers::CLStringBytesParser.from_bytes(bytes)
|
334
|
+
CLString.new(value)
|
335
|
+
elsif cl_type == "URef"
|
336
|
+
value = Utils::ByteUtils.hex_to_byte_array(bytes)
|
337
|
+
CLValueBytesParsers::CLURefBytesParser.from_bytes(value)
|
338
|
+
# elsif cl_type = "Option"
|
339
|
+
|
340
|
+
elsif cl_type == "PublicKey"
|
341
|
+
CLPublicKey.from_hex(bytes)
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
def build_cl_value_with_option(h = {})
|
346
|
+
cl_type = h[:cl_type]
|
347
|
+
bytes = h[:bytes]
|
348
|
+
# puts bytes
|
349
|
+
parsed = h[:parsed]
|
350
|
+
if cl_type == "Bool"
|
351
|
+
CLValueBytesParsers::CLBoolBytesParser.from_bytes([bytes])
|
352
|
+
elsif cl_type == "I32"
|
353
|
+
value = Utils::ByteUtils.hex_to_integer(bytes)
|
354
|
+
CLi32.new(value)
|
355
|
+
elsif cl_type == "I64"
|
356
|
+
value = Utils::ByteUtils.hex_to_i64_value(bytes)
|
357
|
+
CLi64.new(value)
|
358
|
+
elsif cl_type == "U8"
|
359
|
+
value = Utils::ByteUtils.hex_to_u8_value(bytes)
|
360
|
+
CLu8.new(value)
|
361
|
+
elsif cl_type == "U32"
|
362
|
+
value = Utils::ByteUtils.hex_to_u32_value(bytes)
|
363
|
+
CLu32.new(value)
|
364
|
+
elsif cl_type == "U64"
|
365
|
+
value = Utils::ByteUtils.hex_to_u64_value(bytes)
|
366
|
+
CLu32.new(value)
|
367
|
+
elsif cl_type == "U512"
|
368
|
+
value = Utils::ByteUtils.hex_to_u64_value(bytes)
|
369
|
+
CLu512.new(value)
|
370
|
+
# value = Utils::ByteUtils.hex_to_u512_value(bytes)
|
371
|
+
# CLu512.new(value)
|
372
|
+
elsif cl_type == "Unit"
|
373
|
+
# value = CLValueBytesParsers::CLUnitBytesParser.from_bytes(bytes)
|
374
|
+
if bytes == ""
|
375
|
+
value = nil
|
376
|
+
CLUnit.new(value)
|
377
|
+
end
|
378
|
+
elsif cl_type == "String"
|
379
|
+
value = CLValueBytesParsers::CLStringBytesParser.from_bytes(bytes)
|
380
|
+
CLString.new(value)
|
381
|
+
elsif cl_type == "URef"
|
382
|
+
value = Utils::ByteUtils.hex_to_byte_array(bytes)
|
383
|
+
CLValueBytesParsers::CLURefBytesParser.from_bytes(value)
|
384
|
+
# elsif cl_type = "Option"
|
385
|
+
|
386
|
+
elsif cl_type == "PublicKey"
|
387
|
+
CLPublicKey.from_hex(bytes)
|
388
|
+
end
|
389
|
+
|
390
|
+
|
391
|
+
end
|
392
|
+
end
|