Method: Casper::Entity::ModuleBytes#to_bytes

Defined in:
lib/entity/module_bytes.rb

#to_bytesArray<Integer>

Returns the byte serialization of ModuleByte object.

Returns:

  • (Array<Integer>)

    the byte serialization of ModuleByte object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/entity/module_bytes.rb', line 40

def to_bytes
  puts "ModuleBytes::to_bytes is called"
  bytes = ""
  serializer = DeployNamedArgSerializer.new
  num_of_args = @args.length
  bytes += Utils::ByteUtils.to_u8(@tag)
  if @module_bytes == ""
    bytes += Utils::ByteUtils.to_u32(0)
  end
  bytes += Utils::ByteUtils.to_u32(num_of_args)
  # puts args[0][0].get_name
  # puts args[0][0].get_value
  @args.each do |arg|
    arg.each do |item|
      bytes += serializer.to_bytes(item)
      # puts item.get_name
      # puts item.get_value
    end
  end
  Utils::ByteUtils.hex_to_byte_array(bytes)
  # bytes
end