Class: TonSdkRuby::StateInit

Inherits:
Object
  • Object
show all
Extended by:
TonSdkRuby
Includes:
TonSdkRuby
Defined in:
lib/ton-sdk-ruby/types/block.rb

Constant Summary

Constants included from TonSdkRuby

DEPTH_BITS, FLAG_BOUNCEABLE, FLAG_NON_BOUNCEABLE, FLAG_TEST_ONLY, HASH_BITS, INT32_MAX, INT32_MIN, LEAN_BOC_MAGIC_PREFIX, LEAN_BOC_MAGIC_PREFIX_CRC, REACH_BOC_MAGIC_PREFIX, VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TonSdkRuby

augment, base64_to_bytes, bits_to_big_int, bits_to_big_uint, bits_to_bytes, bits_to_hex, bits_to_int_uint, breadth_first_sort, bytes_compare, bytes_needed_for_words_bip39, bytes_to_base64, bytes_to_bits, bytes_to_data_string, bytes_to_hex, bytes_to_string, bytes_to_uint, crc16, crc16_bytes_be, crc32c, crc32c_bytes_le, depth_first_sort, deserialize, deserialize_cell, deserialize_fift, deserialize_header, generate_words_bip39, get_mapper, hex_to_bits, hex_to_bytes, hex_to_data_string, read_json_from_link, read_post_json_from_link, require_type, rollback, serialize, serialize_cell, sha256, sha512, sign_cell, slice_into_chunks, string_to_bytes, uint_to_hex, validate_library_reference, validate_merkle_proof, validate_merkle_update, validate_ordinary, validate_pruned_branch

Constructor Details

#initialize(state_init_options) ⇒ StateInit

Returns a new instance of StateInit.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/ton-sdk-ruby/types/block.rb', line 92

def initialize(state_init_options)
  @data = state_init_options

  b = Builder.new

  # split_depth
  if data.split_depth
    b.store_uint(data.split_depth, 5)
  else
    b.store_bit(0)
  end

  # special
  b.store_maybe_ref(data.special&.cell)
  # code
  b.store_maybe_ref(data.code)
  b.store_maybe_ref(data.data)
  b.store_dict(data.library)

  @cell = b.cell
end

Instance Attribute Details

#cellObject (readonly)

Returns the value of attribute cell.



90
91
92
# File 'lib/ton-sdk-ruby/types/block.rb', line 90

def cell
  @cell
end

#dataObject (readonly)

Returns the value of attribute data.



90
91
92
# File 'lib/ton-sdk-ruby/types/block.rb', line 90

def data
  @data
end

Class Method Details

.parse(cs) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/ton-sdk-ruby/types/block.rb', line 114

def self.parse(cs)
  options = StateInitOptions.new()

  options.split_depth = cs.load_bit.nonzero? ? cs.load_uint(5) : nil
  options.special = TickTock.parse(cs) if cs.load_bit.nonzero?
  options.code = cs.load_ref if cs.load_bit.nonzero?
  options.data = cs.load_ref if cs.load_bit.nonzero?

  deserializers = {
    key: ->(k) { k },
    value: ->(v) { SimpleLib.parse(Slice.parse(v.parse)) }
  }

  options.library = HashmapE.parse(256, cs, deserializers)

  new(options)
end