Module: CardanoUp

Defined in:
lib/cardano-up.rb,
lib/cardano-up/err.rb,
lib/cardano-up/tar.rb,
lib/cardano-up/bins.rb,
lib/cardano-up/ping.rb,
lib/cardano-up/tail.rb,
lib/cardano-up/utils.rb,
lib/cardano-up/configs.rb,
lib/cardano-up/session.rb,
lib/cardano-up/version.rb,
lib/cardano-up/launcher.rb

Overview

Version

Defined Under Namespace

Modules: Bins, Configs, Launcher, Ping, Session, Tail, Tar, Utils Classes: ConfigNotSetError, EnvNotSupportedError, NoScreenError, SessionEnvNotUpError, SessionHasNodeError, SessionHasWalletError, SessionNotExistsError, SessionServiceNotUpError, VersionNotSupportedError, WalletPortError, WalletPortUsedError

Constant Summary collapse

CONFIGS_BASE_URL =
'https://book.world.dev.cardano.org/environments'
BINS_BASE_URL =
'https://github.com/input-output-hk/cardano-wallet'
ENVS =
%w[mainnet preview preprod shelley-qa
staging vasil-qa vasil-dev mixed testnet].freeze
CONFIG_FILES =
['alonzo-genesis.json', 'byron-genesis.json', 'shelley-genesis.json',
'config.json', 'topology.json'].freeze
MAINNET_TOKEN_SERVER =
'https://tokens.cardano.org'
TESTNET_TOKEN_SERVER =
'https://metadata.cardano-testnet.iohkdev.io'

Class Method Summary collapse

Class Method Details

.base_dirObject



44
45
46
# File 'lib/cardano-up.rb', line 44

def self.base_dir
  @base_dir
end

.base_dir=(value) ⇒ Object



48
49
50
51
52
# File 'lib/cardano-up.rb', line 48

def self.base_dir=(value)
  @base_dir = value
  @cardano_up_config = File.join(@base_dir, 'config.json')
  @base_dir
end

.cardano_up_configObject



54
55
56
# File 'lib/cardano-up.rb', line 54

def self.cardano_up_config
  @cardano_up_config
end

.cardano_up_config=(value) ⇒ Object



58
59
60
# File 'lib/cardano-up.rb', line 58

def self.cardano_up_config=(value)
  @cardano_up_config = value
end

.clean_config_dir(dir) ⇒ Object

dir [String] config dir



107
108
109
# File 'lib/cardano-up.rb', line 107

def self.clean_config_dir(dir)
  FileUtils.rm_f(config[dir])
end

.configObject

Get config values



95
96
97
98
99
# File 'lib/cardano-up.rb', line 95

def self.config
  raise CardanoUp::ConfigNotSetError unless configured?

  CardanoUp::Utils.from_json(@cardano_up_config)
end

.configure(bin_dir, state_dir, logs_dir, config_dir) ⇒ Object

Set custom config for CardanoUp



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/cardano-up.rb', line 76

def self.configure(bin_dir, state_dir, logs_dir, config_dir)
  FileUtils.mkdir_p(@base_dir)
  c = if configured?
        CardanoUp.config
      else
        { bin_dir: File.join(@base_dir, 'bins'),
          state_dir: File.join(@base_dir, 'state'),
          log_dir: File.join(@base_dir, 'state'),
          config_dir: File.join(@base_dir, 'configs') }
      end
  c[:bin_dir] = bin_dir if bin_dir
  c[:state_dir] = state_dir if state_dir
  c[:log_dir] = logs_dir if logs_dir
  c[:config_dir] = config_dir if config_dir
  CardanoUp::Utils.to_json(@cardano_up_config, c)
  CardanoUp::Utils.from_json(@cardano_up_config)
end

.configure_defaultObject

Set default config for CardanoUp



68
69
70
71
72
73
# File 'lib/cardano-up.rb', line 68

def self.configure_default
  configure(File.join(@base_dir, 'bins'),
            File.join(@base_dir, 'state'),
            File.join(@base_dir, 'logs'),
            File.join(@base_dir, 'configs'))
end

.configured?Boolean

Check if CardanoUp config exists

Returns:

  • (Boolean)


63
64
65
# File 'lib/cardano-up.rb', line 63

def self.configured?
  File.exist?(@cardano_up_config)
end

.remove_cardano_up_configObject

Remove configuration file



102
103
104
# File 'lib/cardano-up.rb', line 102

def self.remove_cardano_up_config
  FileUtils.rm_f(@cardano_up_config)
end