Skip to content

Conversation

@zZoMROT
Copy link
Contributor

@zZoMROT zZoMROT commented Jun 5, 2025

Static Code Analysis (readability, compactness):

  • Introduced an autoLoadEnv flag in the Networks constructor to control whether environment variables should be automatically loaded via dotenv.config().
  • Added a loadEnv() utility function that loads environment variables, by default from .env, but accepts standard dotenv.config options (e.g., custom path or encoding).

These changes remove hidden side effects, improve clarity, and preserve backward compatibility.

Dynamic Code Analysis (external APIs, interaction flows):

Previously, environment variables were always loaded implicitly during Networks instantiation, which could lead to issues if process.env was accessed before that (e.g., in hardhat.config.ts). The new approach allows developers to load environment variables explicitly using loadEnv(options?) at the appropriate point in the setup flow.

Efficiency (gas costs, computational complexity, memory requirements):

No impact. The change only affects how environment variables are loaded during setup and does not impact runtime or on-chain behavior.

Opinion, trade-offs and other thoughts (optional):

This change slightly increases the API surface but improves flexibility and makes environment handling explicit and predictable. It aligns with library design best practices by avoiding implicit side effects and supporting more advanced dotenv usage via options.

@codecov
Copy link

codecov bot commented Jun 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (948af77) to head (618ea75).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #189   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           17        17           
  Lines          346       346           
  Branches        65        65           
=========================================
  Hits           346       346           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zZoMROT zZoMROT requested review from SevenSwen and byshape June 5, 2025 21:25
@galekseev galekseev merged commit 35fb1b0 into master Jul 4, 2025
9 checks passed
@galekseev galekseev deleted the feature/optional-env-load branch July 4, 2025 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants