Class: Scale::Types::BoxProposal
- Inherits:
-
Object
- Object
- Scale::Types::BoxProposal
show all
- Includes:
- Base
- Defined in:
- lib/scale/types.rb
Instance Attribute Summary
Attributes included from Base
#value
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Base
#==, included, #initialize, #to_human
Class Method Details
.decode(scale_bytes, metadata, chain_spec) ⇒ Object
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
|
# File 'lib/scale/types.rb', line 890
def self.decode(scale_bytes, metadata, chain_spec)
puts "BEGIN " + self::TYPE_NAME + ": #{scale_bytes}" if Scale::Types.debug == true
call_index = scale_bytes.get_next_bytes(2).bytes_to_hex[2..]
call_module, call = metadata.value.call_index[call_index]
call_args = call[:args].map do |arg|
arg_obj = Scale::Types.get(arg[:type], chain_spec).decode(scale_bytes)
{name: arg[:name], type: arg[:type], value: arg_obj.encode, value_raw: arg_obj.value}
end
puts " END " + self::TYPE_NAME + ": #{scale_bytes}" if Scale::Types.debug == true
self.new({
call_index: call_index,
call_function: call[:name],
call_module: call_module[:name],
call_args: call_args
})
end
|
Instance Method Details
#encode ⇒ Object
909
910
911
912
913
914
|
# File 'lib/scale/types.rb', line 909
def encode
value[:call_index] +
value[:call_args]
.map {|call_arg| call_arg[:value]}
.join("")
end
|