Class: BlockGiven::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/block_given/configuration.rb

Overview

Global configuration set through BlockGiven.configure { |c| ... }.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_pathObject

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_multiplierObject

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

#chainObject

Returns the value of attribute chain.



10
11
12
# File 'lib/block_given/configuration.rb', line 10

def chain
  @chain
end

#confirmationsObject

Returns the value of attribute confirmations.



8
9
10
# File 'lib/block_given/configuration.rb', line 8

def confirmations
  @confirmations
end

#connectorObject

Returns the value of attribute connector.



8
9
10
# File 'lib/block_given/configuration.rb', line 8

def connector
  @connector
end

#gas_multiplierObject

Returns the value of attribute gas_multiplier.



8
9
10
# File 'lib/block_given/configuration.rb', line 8

def gas_multiplier
  @gas_multiplier
end

#loggerObject

Returns the value of attribute logger.



10
11
12
# File 'lib/block_given/configuration.rb', line 10

def logger
  @logger
end

#max_block_rangeObject

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_intervalObject

Returns the value of attribute polling_interval.



8
9
10
# File 'lib/block_given/configuration.rb', line 8

def polling_interval
  @polling_interval
end

#timeoutObject

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).

Returns:

  • (Boolean)


32
# File 'lib/block_given/configuration.rb', line 32

def logger_configured? = @logger_configured