<commit_before>"use strict";

import { isHexString } from "@ethersproject/bytes";
import * as errors from "@ethersproject/errors";
import { Network } from "@ethersproject/networks";

import { UrlJsonRpcProvider } from "./url-json-rpc-provider";


const defaultProjectId = "<KEY>"

export class InfuraProvider extends UrlJsonRpcProvider {
    get projectId(): string { return this.apiKey; }

    static getApiKey(apiKey: string): string {
        if (apiKey == null) { return defaultProjectId; }
        if (!isHexString(apiKey, 16)) {
            errors.throwArgumentError("invalid projectId", "projectId", apiKey);
        }
        return apiKey;
    }

    static getUrl(network: Network, apiKey: string): string {
        let host = null;
        switch(network.name) {
            case "homestead":
                host = "mainnet.infura.io";
                break;
            case "ropsten":
                host = "ropsten.infura.io";
                break;
            case "rinkeby":
                host = "rinkeby.infura.io";
                break;
            case "kovan":
                host = "kovan.infura.io";
                break;
            case "goerli":
                host = "goerli.infura.io";
                break;
            default:
                errors.throwError("unsupported network", errors.INVALID_ARGUMENT, {
                    argument: "network",
                    value: network
                });
        }

        return "https://" + host + "/v3/" + apiKey;
    }
}<commit_msg>Fixed INFURA project ID checking (#534).<commit_after>"use strict";

import * as errors from "@ethersproject/errors";
import { Network } from "@ethersproject/networks";

import { UrlJsonRpcProvider } from "./url-json-rpc-provider";


const defaultProjectId = "<KEY>"

export class InfuraProvider extends UrlJsonRpcProvider {
    get projectId(): string { return this.apiKey; }

    static getApiKey(apiKey: string): string {
        if (apiKey == null) { return defaultProjectId; }
        return apiKey;
    }

    static getUrl(network: Network, apiKey: string): string {
        let host = null;
        switch(network.name) {
            case "homestead":
                host = "mainnet.infura.io";
                break;
            case "ropsten":
                host = "ropsten.infura.io";
                break;
            case "rinkeby":
                host = "rinkeby.infura.io";
                break;
            case "kovan":
                host = "kovan.infura.io";
                break;
            case "goerli":
                host = "goerli.infura.io";
                break;
            default:
                errors.throwError("unsupported network", errors.INVALID_ARGUMENT, {
                    argument: "network",
                    value: network
                });
        }

        return "https:/" + "/" + host + "/v3/" + apiKey;
    }
}
{'fraction_non_alphanumeric': 0.11566265060240964, 'fraction_numerical': 0.0024096385542168677, 'mean_word_length': 1.6514598540145986, 'pattern_counts': {'":': 10, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, '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': '4813903', 'n_tokens_mistral': 828, 'n_tokens_neox': 783, 'n_words': 190}