Skip to content

Commit

Permalink
Rename exposed API
Browse files Browse the repository at this point in the history
  • Loading branch information
andreogle committed Jul 5, 2023
1 parent b6e1b55 commit 2d8f98f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/hardhat.ts → src/hardhat-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import { Chain, HardhatEtherscanConfig, HardhatNetworksConfig } from './types';

export function getEnvVariableNames(): string[] {
const hardhatApiKeyEnvNames = CHAINS.filter((chain) => chain.explorer?.api?.key?.required).map((chain) =>
buildEtherscanApiKeyName(chain)
etherscanApiKeyName(chain)
);

return ['MNEMONIC', ...hardhatApiKeyEnvNames];
}

export function buildEtherscanApiKeyName(chain: Chain): string {
export function etherscanApiKeyName(chain: Chain): string {
return `ETHERSCAN_API_KEY_${toUpperSnakeCase(chain.alias)}`;
}

// https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-verify#multiple-api-keys-and-alternative-block-explorers
export function buildEtherscanConfig(): HardhatEtherscanConfig {
export function etherscan(): HardhatEtherscanConfig {
if (typeof window !== 'undefined') {
throw new Error('Cannot be run outside of a Node.js environment');
}
Expand All @@ -28,7 +28,7 @@ export function buildEtherscanConfig(): HardhatEtherscanConfig {

const apiKey = chain.explorer.api.key;

const apiKeyEnvName = buildEtherscanApiKeyName(chain);
const apiKeyEnvName = etherscanApiKeyName(chain);
const apiKeyValue = apiKey.required ? process.env[apiKeyEnvName] || 'NOT_FOUND' : 'DUMMY_VALUE';

if (apiKey.hardhatEtherscanAlias) {
Expand All @@ -53,7 +53,7 @@ export function buildEtherscanConfig(): HardhatEtherscanConfig {
);
}

export function buildNetworksConfig(): HardhatNetworksConfig {
export function networks(): HardhatNetworksConfig {
if (typeof window !== 'undefined') {
throw new Error('Cannot be called outside of a Node.js environment');
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// NOTE: the following file is generated with the generate-chains.ts script
export { CHAINS } from './generated/chains';

export * as hardhat from './hardhat';
export * as hardhatConfig from './hardhat-config';
export * from './types';

0 comments on commit 2d8f98f

Please sign in to comment.