Class: TonSdk::Abi::AbiFunction

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(name:, inputs:, outputs:, id_: nil) ⇒ AbiFunction

Returns a new instance of AbiFunction.



565
566
567
568
569
570
# File 'lib/ton_sdk_client/abi.rb', line 565

def initialize(name:, inputs:, outputs:, id_: nil)
  @name = name
  @inputs = inputs
  @outputs = outputs
  @id_ = id_
end

Instance Attribute Details

#id_Object (readonly)

Returns the value of attribute id_.



563
564
565
# File 'lib/ton_sdk_client/abi.rb', line 563

def id_
  @id_
end

#inputsObject (readonly)

Returns the value of attribute inputs.



563
564
565
# File 'lib/ton_sdk_client/abi.rb', line 563

def inputs
  @inputs
end

#nameObject (readonly)

Returns the value of attribute name.



563
564
565
# File 'lib/ton_sdk_client/abi.rb', line 563

def name
  @name
end

#outputsObject (readonly)

Returns the value of attribute outputs.



563
564
565
# File 'lib/ton_sdk_client/abi.rb', line 563

def outputs
  @outputs
end

Class Method Details

.from_json(j) ⇒ Object



593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
# File 'lib/ton_sdk_client/abi.rb', line 593

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

  inp_s = if j["inputs"].nil?
      []
    else
      j["inputs"].compact.map do |x|
        # TODO recursive parsing of AbiParam
        AbiParam.from_json(x)
      end
    end

  out_s = if j["outputs"].nil?
    []
  else
    j["outputs"].compact.map do |x|
      # TODO recursive parsing of AbiParam
      AbiParam.from_json(x)
    end
  end

  self.new(
    name: j["name"],
    inputs: inp_s,
    outputs: out_s,
    id_: j["id"]
  )
end

Instance Method Details

#to_hObject



572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
# File 'lib/ton_sdk_client/abi.rb', line 572

def to_h
  in_h_s = if !@inputs.nil?
    @inputs.compact.map(&:to_h)
  else
    []
  end

  ou_h_s = if !@outputs.nil?
    @outputs.compact.map(&:to_h)
  else
    []
  end

  {
    name: @name,
    inputs: in_h_s,
    outputs: ou_h_s,
    id: @id_
  }
end