Class: TonSdk::Abi::Signer

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

Constant Summary collapse

TYPES =
[:none, :external, :keys, :signing_box]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type_:, public_key: nil, keys: nil, handle: nil) ⇒ Signer

Returns a new instance of Signer.



68
69
70
71
72
73
74
75
76
77
# File 'lib/ton_sdk_client/abi.rb', line 68

def initialize(type_:, public_key: nil, keys: nil, handle: nil)
  unless TYPES.include?(type_)
    raise ArgumentError.new("type #{type_} is unknown; known types: #{TYPES}")
  end

  @type_ = type_
  @public_key = public_key
  @keys = keys
  @handle = handle
end

Instance Attribute Details

#handleObject (readonly)

Returns the value of attribute handle.



66
67
68
# File 'lib/ton_sdk_client/abi.rb', line 66

def handle
  @handle
end

#keysObject (readonly)

Returns the value of attribute keys.



66
67
68
# File 'lib/ton_sdk_client/abi.rb', line 66

def keys
  @keys
end

#public_keyObject (readonly)

Returns the value of attribute public_key.



66
67
68
# File 'lib/ton_sdk_client/abi.rb', line 66

def public_key
  @public_key
end

#type_Object (readonly)

Returns the value of attribute type_.



66
67
68
# File 'lib/ton_sdk_client/abi.rb', line 66

def type_
  @type_
end

Instance Method Details

#to_hObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/ton_sdk_client/abi.rb', line 79

def to_h
  h1 = {
    type: Helper.sym_to_capitalized_case_str(@type_)
  }

  h2 = case @type_
  when :none
    { }
  when :external
  {
    public_key: @public_key
  }
  when :keys
    {
      keys: @keys.to_h
    }
  when :signing_box
    {
      handle: @handle
    }
  end

  h1.merge(h2)
end