Class: Coinbase::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/coinbase/validator.rb

Overview

A representation of a staking validator.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ Validator

Returns a new Validator object.

Parameters:



8
9
10
# File 'lib/coinbase/validator.rb', line 8

def initialize(model)
  @model = model
end

Class Method Details

.fetch(network, asset_id, validator_id) ⇒ Coinbase::Validator

Returns a Validator for the provided network, asset, and validator.

Parameters:

  • network (Coinbase::Network, Symbol)

    The Network or Network ID

  • asset_id (Symbol)

    The asset ID

  • validator_id (String)

    The validator ID

Returns:



32
33
34
35
36
37
38
39
40
# File 'lib/coinbase/validator.rb', line 32

def self.fetch(network, asset_id, validator_id)
  network = Coinbase::Network.from_id(network)

  validator = Coinbase.call_api do
    stake_api.get_validator(network.normalized_id, asset_id, validator_id)
  end

  new(validator)
end

.list(network, asset_id, status: nil) ⇒ Enumerable<Coinbase::Validator>

Returns a list of Validators for the provided network and asset.

Parameters:

  • network (Coinbase::Nework, Symbol)

    The Network or Network ID

  • asset_id (Symbol)

    The asset ID

  • status (Symbol) (defaults to: nil)

    The status of the validator. Defaults to nil.

Returns:



17
18
19
20
21
22
23
24
25
# File 'lib/coinbase/validator.rb', line 17

def self.list(network, asset_id, status: nil)
  network = Coinbase::Network.from_id(network)

  Coinbase::Pagination.enumerate(lambda { |page|
    list_page(network, asset_id, status, page)
  }) do |validator|
    new(validator)
  end
end

Instance Method Details

#inspectString

Same as to_s.

Returns:

  • (String)

    a string representation of the Validator



62
63
64
# File 'lib/coinbase/validator.rb', line 62

def inspect
  to_s
end

#statusSymbol

Returns the status of the Validator.

Returns:

  • (Symbol)

    The status



50
51
52
# File 'lib/coinbase/validator.rb', line 50

def status
  @model.status
end

#to_sString

Returns a string representation of the Validator.

Returns:

  • (String)

    a string representation of the Validator



56
57
58
# File 'lib/coinbase/validator.rb', line 56

def to_s
  Coinbase.pretty_print_object(self, validator_id: validator_id, status: status)
end

#validator_idString

Returns the public identifiable id of the Validator.

Returns:

  • (String)

    The validator ID



44
45
46
# File 'lib/coinbase/validator.rb', line 44

def validator_id
  @model.validator_id
end