Class: BlockGiven::Configuration
- Inherits:
-
Object
- Object
- BlockGiven::Configuration
- Defined in:
- lib/block_given/configuration.rb
Overview
Global configuration set through BlockGiven.configure { |c| ... }.
Instance Attribute Summary collapse
-
#abi_path ⇒ Object
Returns the value of attribute abi_path.
-
#base_fee_multiplier ⇒ Object
Returns the value of attribute base_fee_multiplier.
-
#chain ⇒ Object
Returns the value of attribute chain.
-
#confirmations ⇒ Object
Returns the value of attribute confirmations.
-
#connector ⇒ Object
Returns the value of attribute connector.
-
#gas_multiplier ⇒ Object
Returns the value of attribute gas_multiplier.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_block_range ⇒ Object
Returns the value of attribute max_block_range.
-
#polling_interval ⇒ Object
Returns the value of attribute polling_interval.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #chain! ⇒ Object
- #connector! ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#logger_configured? ⇒ Boolean
true once an application set its own logger (the Rails railtie respects it).
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/block_given/configuration.rb', line 12 def initialize @connector = nil @chain = nil @polling_interval = 2.0 # seconds between two polls (receipts, blocks, events) @timeout = 180 # seconds before wait_for_transaction_receipt gives up @gas_multiplier = 1.2 # safety margin applied on top of eth_estimateGas @base_fee_multiplier = 1.2 # viem default: maxFeePerGas = baseFee * 1.2 + priorityFee @confirmations = 1 @max_block_range = 2_000 # eth_getLogs ranges are split in chunks of this many blocks @abi_path = nil # directory abi_file resolves relative paths against (e.g. Rails.root.join("abis")) @logger = Logger.new($stderr, level: Logger::WARN, progname: "block_given") @logger_configured = false end |
Instance Attribute Details
#abi_path ⇒ Object
Returns the value of attribute abi_path.
8 9 10 |
# File 'lib/block_given/configuration.rb', line 8 def abi_path @abi_path end |
#base_fee_multiplier ⇒ Object
Returns the value of attribute base_fee_multiplier.
8 9 10 |
# File 'lib/block_given/configuration.rb', line 8 def base_fee_multiplier @base_fee_multiplier end |
#chain ⇒ Object
Returns the value of attribute chain.
10 11 12 |
# File 'lib/block_given/configuration.rb', line 10 def chain @chain end |
#confirmations ⇒ Object
Returns the value of attribute confirmations.
8 9 10 |
# File 'lib/block_given/configuration.rb', line 8 def confirmations @confirmations end |
#connector ⇒ Object
Returns the value of attribute connector.
8 9 10 |
# File 'lib/block_given/configuration.rb', line 8 def connector @connector end |
#gas_multiplier ⇒ Object
Returns the value of attribute gas_multiplier.
8 9 10 |
# File 'lib/block_given/configuration.rb', line 8 def gas_multiplier @gas_multiplier end |
#logger ⇒ Object
Returns the value of attribute logger.
10 11 12 |
# File 'lib/block_given/configuration.rb', line 10 def logger @logger end |
#max_block_range ⇒ Object
Returns the value of attribute max_block_range.
8 9 10 |
# File 'lib/block_given/configuration.rb', line 8 def max_block_range @max_block_range end |
#polling_interval ⇒ Object
Returns the value of attribute polling_interval.
8 9 10 |
# File 'lib/block_given/configuration.rb', line 8 def polling_interval @polling_interval end |
#timeout ⇒ Object
Returns the value of attribute timeout.
8 9 10 |
# File 'lib/block_given/configuration.rb', line 8 def timeout @timeout end |
Instance Method Details
#chain! ⇒ Object
44 45 46 |
# File 'lib/block_given/configuration.rb', line 44 def chain! chain || raise(ConfigurationError, "no chain configured: set BlockGiven.config.chain (e.g. :base)") end |
#connector! ⇒ Object
39 40 41 42 |
# File 'lib/block_given/configuration.rb', line 39 def connector! connector || raise(ConfigurationError, "no connector configured: set BlockGiven.config.connector " \ "(e.g. BlockGiven::Connectors::Alchemy.new(api_key: ...))") end |
#logger_configured? ⇒ Boolean
true once an application set its own logger (the Rails railtie respects it).
32 |
# File 'lib/block_given/configuration.rb', line 32 def logger_configured? = @logger_configured |