class TonSdk::Abi::DecodedMessageBody

Constants

MESSAGE_BODY_TYPE_VALUES

Attributes

body_type[R]
header[R]
name[R]
value[R]

Public Class Methods

from_json(j) click to toggle source
# File lib/ton_sdk_client/abi.rb, line 305
def self.from_json(j)
  return nil if j.nil?

  hdr = if !j["header"].nil?
    FunctionHeader.new(
      expire: j["header"]["expire"],
      time: j["header"]["time"],
      pubkey: j["header"]["pubkey"]
    )
  else
    nil
  end

  self.new(
    body_type: self.parse_body_type(j["body_type"]),
    name: j["name"],
    value: j["value"],
    header: hdr
  )
end
new(body_type:, name:, value: nil, header: nil) click to toggle source
# File lib/ton_sdk_client/abi.rb, line 285
def initialize(body_type:, name:, value: nil, header: nil)
  unless MESSAGE_BODY_TYPE_VALUES.include?(body_type)
    raise ArgumentError.new("unknown body_type: #{body_type}; known ones: #{MESSAGE_BODY_TYPE_VALUES}")
  end

  @body_type = body_type
  @name = name
  @value = value
  @header = header
end

Private Class Methods

parse_body_type(s) click to toggle source
# File lib/ton_sdk_client/abi.rb, line 328
def self.parse_body_type(s)
  case s.downcase
  when 'input'
    :input
  when 'output'
    :output
  when 'internaloutput'
    :internal_output
  when 'event'
    :event
  else
    raise ArgumentError.new("unknown body_type: #{s}; known ones: #{MESSAGE_BODY_TYPE_VALUES}")
  end
end

Public Instance Methods

to_h() click to toggle source
# File lib/ton_sdk_client/abi.rb, line 296
def to_h
  {
    body_type: Helper.sym_to_capitalized_case_str(@body_type),
    name: @name,
    value: @value,
    header: @header
  }
end