Class: Sigma::ErgoBoxCandidate

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/sigma/ergo_box.rb

Overview

Contains the same fields as “ErgoBox“, except for transaction id and index, that will be calculated after full transaction formation. Use “ErgoBoxCandidateBuilder“ to create an instance

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



176
177
178
# File 'lib/sigma/ergo_box.rb', line 176

def pointer
  @pointer
end

Class Method Details

.with_raw_pointer(pointer) ⇒ ErgoBoxCandidate

Note:

A user of sigma_rb generally does not need to call this function

Takes ownership of an existing ErgoBoxCandidate Pointer.

Parameters:

  • pointer (FFI::MemoryPointer)

Returns:



182
183
184
# File 'lib/sigma/ergo_box.rb', line 182

def self.with_raw_pointer(pointer)
  init(pointer)
end

Instance Method Details

#==(ebc_two) ⇒ bool

Equality check

Parameters:

Returns:

  • (bool)


234
235
236
# File 'lib/sigma/ergo_box.rb', line 234

def ==(ebc_two)
  ergo_lib_ergo_box_candidate_eq(self.pointer, ebc_two.pointer)
end

#get_box_valueBoxValue

Get box value

Returns:



225
226
227
228
229
# File 'lib/sigma/ergo_box.rb', line 225

def get_box_value
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_ergo_box_candidate_box_value(self.pointer, pointer)
  Sigma::BoxValue.with_raw_pointer(pointer)
end

#get_creation_heightInteger

Get box creation height

Returns:

  • (Integer)


203
204
205
# File 'lib/sigma/ergo_box.rb', line 203

def get_creation_height
  ergo_lib_ergo_box_candidate_creation_height(self.pointer)
end

#get_ergo_treeErgoTree

Get ErgoTree for box

Returns:



217
218
219
220
221
# File 'lib/sigma/ergo_box.rb', line 217

def get_ergo_tree
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_ergo_box_candidate_ergo_tree(self.pointer, pointer)
  Sigma::ErgoTree.with_raw_pointer(pointer)
end

#get_register_value(register_id) ⇒ Constant?

Returns value (ErgoTree constant) stored in the register or ‘nil` if the register is empty

Parameters:

  • register_id (Integer)

Returns:

See Also:



190
191
192
193
194
195
196
197
198
199
# File 'lib/sigma/ergo_box.rb', line 190

def get_register_value(register_id)
  constant_ptr = FFI::MemoryPointer.new(:pointer)
  res = ergo_lib_ergo_box_candidate_register_value(self.pointer, register_id, constant_ptr)
  Util.check_error!(res[:error])
  if res[:is_some]
    Sigma::Constant.with_raw_pointer(constant_ptr)
  else
    nil
  end
end

#get_tokensTokens

Get tokens for box

Returns:



209
210
211
212
213
# File 'lib/sigma/ergo_box.rb', line 209

def get_tokens
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_ergo_box_candidate_tokens(self.pointer, pointer)
  Sigma::Tokens.with_raw_pointer(pointer)
end