Module: Solana::Ruby::Kit::Rpc::Api::GetEpochInfo

Extended by:
T::Sig
Included in:
Client
Defined in:
lib/solana/ruby/kit/rpc/api/get_epoch_info.rb

Overview

Fetch information about the current epoch. Mirrors TypeScript’s GetEpochInfoApi.getEpochInfo.

Instance Method Summary collapse

Instance Method Details

#get_epoch_info(commitment: nil) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/solana/ruby/kit/rpc/api/get_epoch_info.rb', line 29

def get_epoch_info(commitment: nil)
  config = {}
  config['commitment'] = commitment.to_s if commitment

  raw = transport.request('getEpochInfo', config.empty? ? [] : [config])

  EpochInfo.new(
    absolute_slot:     Kernel.Integer(raw['absoluteSlot']),
    block_height:      Kernel.Integer(raw['blockHeight']),
    epoch:             Kernel.Integer(raw['epoch']),
    slot_index:        Kernel.Integer(raw['slotIndex']),
    slots_in_epoch:    Kernel.Integer(raw['slotsInEpoch']),
    transaction_count: raw['transactionCount'] ? Kernel.Integer(raw['transactionCount']) : nil
  )
end