Class: PolarLoop::Types::BatchResult

Inherits:
Struct
  • Object
show all
Defined in:
lib/polarloop/types/batch_result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#mandate_idObject

Returns the value of attribute mandate_id

Returns:

  • (Object)

    the current value of mandate_id



5
6
7
# File 'lib/polarloop/types/batch_result.rb', line 5

def mandate_id
  @mandate_id
end

#reasonObject

Returns the value of attribute reason

Returns:

  • (Object)

    the current value of reason



5
6
7
# File 'lib/polarloop/types/batch_result.rb', line 5

def reason
  @reason
end

#successObject

Returns the value of attribute success

Returns:

  • (Object)

    the current value of success



5
6
7
# File 'lib/polarloop/types/batch_result.rb', line 5

def success
  @success
end

Class Method Details

.from_abi_array(tuples) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/polarloop/types/batch_result.rb', line 11

def self.from_abi_array(tuples)
  tuples.map do |tuple|
    new(
      mandate_id: to_hex_bytes32(tuple[0]),
      success: tuple[1],
      reason: tuple[2]
    )
  end
end

.to_hex_bytes32(binary) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/polarloop/types/batch_result.rb', line 21

def self.to_hex_bytes32(binary)
  if binary.is_a?(String) && binary.start_with?("0x")
    binary.downcase
  elsif binary.is_a?(String)
    "0x" + binary.unpack1("H*")
  else
    "0x" + binary.to_s(16).rjust(64, "0")
  end
end