Class: PolarLoop::Configuration
- Inherits:
-
Object
- Object
- PolarLoop::Configuration
- Defined in:
- lib/polarloop/configuration.rb
Instance Attribute Summary collapse
-
#chains ⇒ Object
readonly
Returns the value of attribute chains.
-
#index ⇒ Object
Returns the value of attribute index.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#mnemonic ⇒ Object
Returns the value of attribute mnemonic.
Instance Method Summary collapse
- #chain(name) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #register(chain_name, rpc_url:, contract_address:, chain_id:, gas_multiplier: 1.2, tx_timeout: 120) ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
17 18 19 20 21 22 |
# File 'lib/polarloop/configuration.rb', line 17 def initialize @chains = {} @logger = nil @mnemonic = nil @index = 0 end |
Instance Attribute Details
#chains ⇒ Object (readonly)
Returns the value of attribute chains.
15 16 17 |
# File 'lib/polarloop/configuration.rb', line 15 def chains @chains end |
#index ⇒ Object
Returns the value of attribute index.
14 15 16 |
# File 'lib/polarloop/configuration.rb', line 14 def index @index end |
#logger ⇒ Object
Returns the value of attribute logger.
14 15 16 |
# File 'lib/polarloop/configuration.rb', line 14 def logger @logger end |
#mnemonic ⇒ Object
Returns the value of attribute mnemonic.
14 15 16 |
# File 'lib/polarloop/configuration.rb', line 14 def mnemonic @mnemonic end |
Instance Method Details
#chain(name) ⇒ Object
34 35 36 |
# File 'lib/polarloop/configuration.rb', line 34 def chain(name) @chains[name.to_sym] || raise(ChainNotRegisteredError, "Chain :#{name} not registered") end |
#register(chain_name, rpc_url:, contract_address:, chain_id:, gas_multiplier: 1.2, tx_timeout: 120) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/polarloop/configuration.rb', line 24 def register(chain_name, rpc_url:, contract_address:, chain_id:, gas_multiplier: 1.2, tx_timeout: 120) @chains[chain_name.to_sym] = ChainConfig.new( rpc_url: rpc_url, contract_address: contract_address, chain_id: chain_id, gas_multiplier: gas_multiplier, tx_timeout: tx_timeout ) end |
#validate! ⇒ Object
38 39 40 41 |
# File 'lib/polarloop/configuration.rb', line 38 def validate! raise ConfigurationError, "Mnemonic is required" if mnemonic.nil? || mnemonic.strip.empty? raise ConfigurationError, "At least one chain must be registered" if chains.empty? end |