Class: Casper::Entity::DeployNamedArgument
- Inherits:
-
Object
- Object
- Casper::Entity::DeployNamedArgument
- Defined in:
- lib/entity/deploy_named_argument.rb
Overview
Named arguments passed as input in a Deploy item.
Instance Method Summary collapse
- #get_name ⇒ Object
- #get_value ⇒ Object
-
#initialize(name, clvalue) ⇒ DeployNamedArgument
constructor
A new instance of DeployNamedArgument.
- #to_byte_array(num) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(name, clvalue) ⇒ DeployNamedArgument
Returns a new instance of DeployNamedArgument.
6 7 8 9 |
# File 'lib/entity/deploy_named_argument.rb', line 6 def initialize(name, clvalue) @name = name @clvalue = clvalue end |
Instance Method Details
#get_name ⇒ Object
11 12 13 |
# File 'lib/entity/deploy_named_argument.rb', line 11 def get_name @name end |
#get_value ⇒ Object
15 16 17 |
# File 'lib/entity/deploy_named_argument.rb', line 15 def get_value @clvalue end |
#to_byte_array(num) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/entity/deploy_named_argument.rb', line 19 def to_byte_array(num) result = [] begin result << (num & 0xff) num >>= 8 end until (num == 0 || num == -1) && (result.last[7] == num[7]) # result.reverse result end |
#to_hash ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/entity/deploy_named_argument.rb', line 30 def to_hash serializer = CLValueSerializer.new value = @clvalue.get_value type = @clvalue.get_cl_type if @name == "amount" bytes = Utils::ByteUtils.byte_array_to_hex(to_byte_array(value))[0...-2] num_of_bytes = bytes.length/2 [num_of_bytes].pack("C*").unpack1("H*") + bytes [ @name, { # "bytes": serializer.to_bytes(@clvalue.get_), "bytes": [num_of_bytes].pack("C*").unpack1("H*") + bytes, "parsed": @clvalue.get_value, "cl_type": @clvalue.get_cl_type } ] elsif @name == "target" && type == "PublicKey" [ @name, { "bytes": @clvalue.to_hex, # "bytes": [num_of_bytes].pack("C*").unpack1("H*") + bytes, "parsed": @clvalue.to_hex, "cl_type": @clvalue.get_cl_type } ] elsif @name == "id" # puts @clvalue.get_cl_type data = @clvalue.get_value inner_type = data.get_cl_type # puts inner_type inner_value = data.get_value parsed = inner_value bytes = "01" + serializer.only_value(data) # puts "01" + bytes # inner_data = @clvalue.get_value # inner_type = inner_data[:cl_type] # value = inner_data[:] # puts inner_data # puts inner_type [ @name, { "bytes": bytes, # "bytes": [num_of_bytes].pack("C*").unpack1("H*") + bytes, "parsed": parsed, "cl_type": { "#{type}": inner_type } } ] end end |