Conversation
…ls in Hardhat config ## Motivation This PR hardens the `relay-vaults` smart contract configuration (`smart-contracts/hardhat.config.ts`), addressing a high-severity security finding from the workspace security audit[cite: 24, 25]. Previously, multiple block-explorer API credentials were embedded directly as source literals, exposing reusable secrets and requiring a code change for every rotation[cite: 24, 25]. ## Modifications * **Environment-Backed Explorer Configuration (`smart-contracts/hardhat.config.ts`)**: * Introduced the `explorerApiKey()` helper to dynamically source credentials from network-specific `EXPLORER_API_KEY_<NETWORK>` environment variables, falling back safely to a placeholder value when unconfigured[cite: 24, 25]. * **Comment Normalization (`smart-contracts/hardhat.config.ts`)**: * Corrected the touched source comment from `// Interracting` to standard English (`// Interaction tasks`)[cite: 24, 25]. ## Checklist - [x] Format your code according to the Contributor Guide. - [ ] Add unit tests as outlined in the Contributor Guide. - [x] Update documentation as needed, including docstrings or example tutorials. ```[cite: 24, 25]
|
| const explorerApiKey = (network: string): string => | ||
| process.env[`EXPLORER_API_KEY_${network.toUpperCase().replace(/[^A-Z0-9]+/g, '_')}`] ?? | ||
| 'default-api-key' |
There was a problem hiding this comment.
Explorer key names are undocumented
explorerApiKey requires exact normalized variables such as EXPLORER_API_KEY_ARBITRUM_SEPOLIA and EXPLORER_API_KEY_POLYGON_ZK_EVM, but the deployment documentation does not describe that convention or provide examples. Plausible alternative names silently fall back to default-api-key, and the verification task treats that non-empty placeholder as configured. Document the naming rule and representative network names alongside the verification instructions so operators do not learn about the error only after an explorer-side verification failure.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Artifacts
Focused Hardhat configuration validation script source
- The uploaded diff contains the exact JavaScript harness executed through Hardhat to read both configured explorer API keys and assert each expected result.
Hardhat configuration with plausible alternate API-key names
- A real Hardhat run with unnormalized alternate variable names resolved Arbitrum Sepolia and Polygon zkEVM to `default-api-key`, demonstrating the silent fallback.
Hardhat configuration with exact normalized API-key names
- A real Hardhat run with the exact normalized names resolved both explorer API keys to their supplied values, confirming the required names.
Operator documentation search for explorer API-key names
- The executed search found the relevant normalized names only in `hardhat.config.ts` and none in the repository documentation, confirming the documentation gap.
Updated README to include block explorer API keys for contract verification and modified deployment instructions.
Added detailed deployment instructions and usage guide for the Relay Protocol, including steps for deploying contracts, adding liquidity, and bridging tokens.
Added checks for valid Etherscan API key and improved error messages.
Motivation
This PR hardens the
relay-vaultssmart contract configuration (smart-contracts/hardhat.config.ts), addressing a high-severity security finding from the workspace security audit[cite: 24, 25]. Previously, multiple block-explorer API credentials were embedded directly as source literals, exposing reusable secrets and requiring a code change for every rotation[cite: 24, 25].Modifications
smart-contracts/hardhat.config.ts):explorerApiKey()helper to dynamically source credentials from network-specificEXPLORER_API_KEY_<NETWORK>environment variables, falling back safely to a placeholder value when unconfigured[cite: 24, 25].smart-contracts/hardhat.config.ts):// Interractingto standard English (// Interaction tasks)[cite: 24, 25].Checklist