Class: Casper::Entity::ModuleBytes
- Inherits:
-
DeployExecutableItemInternal
- Object
- DeployExecutableItemInternal
- Casper::Entity::ModuleBytes
- Defined in:
- lib/entity/module_bytes.rb
Overview
Executable specified as raw bytes that represent Wasm code and an instance of RuntimeArgs.
Instance Attribute Summary
Attributes inherited from DeployExecutableItemInternal
Instance Method Summary collapse
- #get_args ⇒ Object
- #get_module_bytes ⇒ Object
- #get_tag ⇒ Object
-
#initialize(module_bytes = nil, args = []) ⇒ ModuleBytes
constructor
A new instance of ModuleBytes.
- #set_arg(deploy_named_arg) ⇒ Object
- #to_bytes ⇒ Object
Methods inherited from DeployExecutableItemInternal
Constructor Details
#initialize(module_bytes = nil, args = []) ⇒ ModuleBytes
Returns a new instance of ModuleBytes.
10 11 12 13 14 |
# File 'lib/entity/module_bytes.rb', line 10 def initialize(module_bytes=nil, args = []) @tag = 0 @module_bytes = module_bytes @args = args end |
Instance Method Details
#get_args ⇒ Object
24 25 26 |
# File 'lib/entity/module_bytes.rb', line 24 def get_args @args end |
#get_module_bytes ⇒ Object
20 21 22 |
# File 'lib/entity/module_bytes.rb', line 20 def get_module_bytes @module_bytes end |
#get_tag ⇒ Object
16 17 18 |
# File 'lib/entity/module_bytes.rb', line 16 def get_tag @tag end |
#set_arg(deploy_named_arg) ⇒ Object
28 29 30 |
# File 'lib/entity/module_bytes.rb', line 28 def set_arg(deploy_named_arg) @args << [deploy_named_arg] end |
#to_bytes ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/entity/module_bytes.rb', line 32 def to_bytes 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) @args.each do |arg| arg.each do |item| bytes += serializer.to_bytes(item) end end Utils::ByteUtils.hex_to_byte_array(bytes) end |