Sha256: fd99220bbfc63274e85b5bec8dc2513dd0379feb29e51d017f8cde9065acbd2a

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

module Peatio
  module Infura
    module Hooks
      BLOCKCHAIN_VERSION_REQUIREMENT = "~> 1.0.0"
      WALLET_VERSION_REQUIREMENT = "~> 1.0.0"

      class << self
        def check_compatibility
          unless Gem::Requirement.new(BLOCKCHAIN_VERSION_REQUIREMENT)
                                 .satisfied_by?(Gem::Version.new(Peatio::Blockchain::VERSION))
            [
              "Infura blockchain version requiremnt was not suttisfied by Peatio::Blockchain.",
              "Infura blockchain requires #{BLOCKCHAIN_VERSION_REQUIREMENT}.",
              "Peatio::Blockchain version is #{Peatio::Blockchain::VERSION}"
            ].join('\n').tap { |s| Kernel.abort s }
          end

          unless Gem::Requirement.new(WALLET_VERSION_REQUIREMENT)
                                 .satisfied_by?(Gem::Version.new(Peatio::Wallet::VERSION))
            [
              "Infura wallet version requiremnt was not suttisfied by Peatio::Wallet.",
              "Infura wallet requires #{WALLET_VERSION_REQUIREMENT}.",
              "Peatio::Wallet version is #{Peatio::Wallet::VERSION}"
            ].join('\n').tap { |s| Kernel.abort s }
          end
        end

        def register
          Peatio::Blockchain.registry[:infura] = Infura::Blockchain.new
          Peatio::Wallet.registry[:infurad] = Infura::Wallet.new
        end
      end

      if defined?(Rails::Railtie)
        require "peatio/infura/railtie"
      else
        check_compatibility
        register
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
module-render-xyz-0.1.3 lib/peatio/infura/hooks.rb
module-render-xyz-0.1.2 lib/peatio/infura/hooks.rb
module-render-xyz-0.1.1 lib/peatio/infura/hooks.rb