class Scale::Types::EventRecord
Public Class Methods
decode(scale_bytes)
click to toggle source
# File lib/scale/block.rb, line 134 def self.decode(scale_bytes) metadata = Scale::TypeRegistry.instance.metadata.value result = {} phase = scale_bytes.get_next_bytes(1).first if phase == 0 result[:extrinsic_idx] = U32.decode(scale_bytes).value end index = scale_bytes.get_next_bytes(2).bytes_to_hex[2..] event = metadata.event_index[index][1] the_module = metadata.event_index[index][0] result[:event_index] = index result[:event_metadata] = event result[:module_metadata] = the_module result[:params] = [] event[:args].each do |arg_type| value = Scale::Types.get(arg_type).decode(scale_bytes).to_human result[:params] << { name: event[:name], type: arg_type, value: value } end result[:topics] = Scale::Types.get("Vec<Hash>").decode(scale_bytes).value.map(&:value) EventRecord.new(result) end