<commit_before>module StraightEngine
  module BlockchainAdapter

    class HelloblockIo < Base

      # When we call calculate_confirmations, it doesn't always make a new
      # request to the blockchain API. Instead, it checks if cached_id matches the one in
      # the hash. It's useful when we want to calculate confirmations for all transactions for
      # a certain address without making any new requests to the Blockchain API.
      @@latest_block = { cache_timestamp: nil, block: nil }

      API_BASE_URL = "https://mainnet.helloblock.io/v1"

      class << self
      
        # Returns transaction info for the tid
        def fetch_transaction(tid)
          straighten_transaction JSON.parse(http_request("#{API_BASE_URL}/transactions/#{tid}"))['data']['transaction']
        end

        # Returns all transactions for the address
        def fetch_transactions_for(address)
          address      = JSON.parse(http_request("#{API_BASE_URL}/addresses/#{address}/transactions"))['data']
          transactions = address['transactions']
          transactions.map { |t| straighten_transaction(t) }
        end

        # Returns the current balance of the address
        def fetch_balance_for(address)
          JSON.parse(http_request("#{API_BASE_URL}/addresses/#{address}"))['data']['address']['balance']
        end

        private

          # Converts transaction info received from the source into the
          # unified format expected by users of BlockchainAdapter instances.
          def straighten_transaction(transaction)
            outs = transaction['outputs'].map do |out| 
              { amount: out['value'], receiving_address: out['address'] }
            end
            {
              total_amount:  transaction['totalOutputsValue'],
              confirmations: transaction['confirmations'],
              outs:          outs
            }
          end

      end

    end

  end
end
<commit_msg>Remove the some BlockchainInfo adapter related code from HelloblockIo adapter<commit_after>module StraightEngine
  module BlockchainAdapter

    class HelloblockIo < Base

      API_BASE_URL = "https://mainnet.helloblock.io/v1"

      class << self
      
        # Returns transaction info for the tid
        def fetch_transaction(tid)
          straighten_transaction JSON.parse(http_request("#{API_BASE_URL}/transactions/#{tid}"))['data']['transaction']
        end

        # Returns all transactions for the address
        def fetch_transactions_for(address)
          address      = JSON.parse(http_request("#{API_BASE_URL}/addresses/#{address}/transactions"))['data']
          transactions = address['transactions']
          transactions.map { |t| straighten_transaction(t) }
        end

        # Returns the current balance of the address
        def fetch_balance_for(address)
          JSON.parse(http_request("#{API_BASE_URL}/addresses/#{address}"))['data']['address']['balance']
        end

        private

          # Converts transaction info received from the source into the
          # unified format expected by users of BlockchainAdapter instances.
          def straighten_transaction(transaction)
            outs = transaction['outputs'].map do |out| 
              { amount: out['value'], receiving_address: out['address'] }
            end
            {
              total_amount:  transaction['totalOutputsValue'],
              confirmations: transaction['confirmations'],
              outs:          outs
            }
          end

      end

    end

  end
end

{'fraction_non_alphanumeric': 0.08898305084745763, 'fraction_numerical': 0.0005649717514124294, 'mean_word_length': 2.4445525291828796, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5933080', 'n_tokens_mistral': 884, 'n_tokens_neox': 854, 'n_words': 242}