Class: EverSdk::Abi::AbiContract

Inherits:
Object
  • Object
show all
Defined in:
lib/ever_sdk_client/abi.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(abi_version: nil, version: nil, header: [], functions: [], events: [], data: [], fields: []) ⇒ AbiContract

Returns a new instance of AbiContract.



646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
# File 'lib/ever_sdk_client/abi.rb', line 646

def initialize(
  abi_version: nil,
  version: nil,
  header: [],
  functions: [],
  events: [],
  data: [],
  fields: []
)
  @abi_version = abi_version
  @version = version
  @header = header
  @functions = functions
  @events = events
  @data = data
  @fields = fields
end

Instance Attribute Details

#abi_versionObject (readonly)

Returns the value of attribute abi_version.



644
645
646
# File 'lib/ever_sdk_client/abi.rb', line 644

def abi_version
  @abi_version
end

#dataObject (readonly)

Returns the value of attribute data.



644
645
646
# File 'lib/ever_sdk_client/abi.rb', line 644

def data
  @data
end

#eventsObject (readonly)

Returns the value of attribute events.



644
645
646
# File 'lib/ever_sdk_client/abi.rb', line 644

def events
  @events
end

#fieldsObject (readonly)

Returns the value of attribute fields.



644
645
646
# File 'lib/ever_sdk_client/abi.rb', line 644

def fields
  @fields
end

#functionsObject (readonly)

Returns the value of attribute functions.



644
645
646
# File 'lib/ever_sdk_client/abi.rb', line 644

def functions
  @functions
end

#headerObject (readonly)

Returns the value of attribute header.



644
645
646
# File 'lib/ever_sdk_client/abi.rb', line 644

def header
  @header
end

#versionObject (readonly)

Returns the value of attribute version.



644
645
646
# File 'lib/ever_sdk_client/abi.rb', line 644

def version
  @version
end

Class Method Details

.from_json(j) ⇒ Object



677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
# File 'lib/ever_sdk_client/abi.rb', line 677

def self.from_json(j)
  return nil if j.nil?

  fn_s = if j["functions"].nil?
    []
  else
    j["functions"].compact.map { |x| AbiFunction.from_json(x) }
  end

  ev_s = if j["events"].nil?
    []
  else
    j["events"].compact.map { |x| AbiEvent.from_json(x) }
  end

  dt_s = if j["data"].nil?
    []
  else
    j["data"].compact.map {|x| AbiData.from_json(x) }
  end

  fl_s = if j["fields"].nil?
    []
  else
    j["fields"].compact.map {|x| AbiParam.from_json(x) }
  end

  self.new(
    abi_version: j["ABI version"],
    version: j["version"],
    header: j["header"],
    functions: fn_s,
    events: ev_s,
    data: dt_s,
    fields: fl_s
  )
end

Instance Method Details

#to_hObject



664
665
666
667
668
669
670
671
672
673
674
675
# File 'lib/ever_sdk_client/abi.rb', line 664

def to_h
  {
    abi_version: @abi_version,
    :"ABI version" => @abi_version, #TODO
    version: @version,
    header: @header,
    functions: @functions&.map(&:to_h),
    events: @events&.map(&:to_h),
    data: @data&.map(&:to_h),
    fields: @fields&.map(&:to_h)
  }
end