Class: Casper::Entity::StoredContractByName

Inherits:
DeployExecutableItemInternal show all
Defined in:
lib/entity/stored_contract_by_name.rb

Overview

Stored contract referenced by a named key existing in the signer's Account context,

entry point and an instance of RuntimeArgs.

Instance Attribute Summary

Attributes inherited from DeployExecutableItemInternal

#args

Instance Method Summary collapse

Methods inherited from DeployExecutableItemInternal

#get_arg_by_name, #set_arg

Constructor Details

#initialize(name, entry_point, args) ⇒ StoredContractByName

Returns a new instance of StoredContractByName.

Parameters:



12
13
14
15
16
17
# File 'lib/entity/stored_contract_by_name.rb', line 12

def initialize(name, entry_point, args)
  @tag = 2
  @name = name
  @entry_point = entry_point
  @args = args
end

Instance Method Details

#get_argsObject



31
32
33
# File 'lib/entity/stored_contract_by_name.rb', line 31

def get_args
  @args
end

#get_entry_pointObject



27
28
29
# File 'lib/entity/stored_contract_by_name.rb', line 27

def get_entry_point
  @entry_point
end

#get_nameObject



23
24
25
# File 'lib/entity/stored_contract_by_name.rb', line 23

def get_name
  @name
end

#get_tagObject



19
20
21
# File 'lib/entity/stored_contract_by_name.rb', line 19

def get_tag
  @tag
end

#to_bytesObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/entity/stored_contract_by_name.rb', line 36

def to_bytes
  serializer = DeployNamedArgSerializer.new
  num_of_args = @args.length
  bytes = Utils::ByteUtils.to_u8(@tag) 
  bytes += CLValueBytesParsers::CLStringBytesParser.to_bytes(@name)
  bytes += CLValueBytesParsers::CLStringBytesParser.to_bytes(@entry_point)
  bytes += Utils::ByteUtils.to_u32(num_of_args)
  @args.each do |arg|
    arg.each do |item|
      bytes += serializer.to_bytes(item)
    end
  end
  Utils::ByteUtils.hex_to_byte_array(bytes)
end