Class: TonSdk::Abi::AbiContract

Inherits:
Object
  • Object
show all
Defined in:
lib/ton_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.



626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
# File 'lib/ton_sdk_client/abi.rb', line 626

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.



624
625
626
# File 'lib/ton_sdk_client/abi.rb', line 624

def abi_version
  @abi_version
end

#dataObject (readonly)

Returns the value of attribute data.



624
625
626
# File 'lib/ton_sdk_client/abi.rb', line 624

def data
  @data
end

#eventsObject (readonly)

Returns the value of attribute events.



624
625
626
# File 'lib/ton_sdk_client/abi.rb', line 624

def events
  @events
end

#fieldsObject (readonly)

Returns the value of attribute fields.



624
625
626
# File 'lib/ton_sdk_client/abi.rb', line 624

def fields
  @fields
end

#functionsObject (readonly)

Returns the value of attribute functions.



624
625
626
# File 'lib/ton_sdk_client/abi.rb', line 624

def functions
  @functions
end

#headerObject (readonly)

Returns the value of attribute header.



624
625
626
# File 'lib/ton_sdk_client/abi.rb', line 624

def header
  @header
end

#versionObject (readonly)

Returns the value of attribute version.



624
625
626
# File 'lib/ton_sdk_client/abi.rb', line 624

def version
  @version
end

Class Method Details

.from_json(j) ⇒ Object



657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
# File 'lib/ton_sdk_client/abi.rb', line 657

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



644
645
646
647
648
649
650
651
652
653
654
655
# File 'lib/ton_sdk_client/abi.rb', line 644

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