Skip to content

Commit

Permalink
🚀 feat: change external visibility of environment variable getter fun…
Browse files Browse the repository at this point in the history
…ctions to internal and add view modifier (#242)
  • Loading branch information
gnkz authored Feb 26, 2024
1 parent 3c1edfb commit 7e04abf
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions src/_internal/Env.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,55 +120,55 @@ library env {
/// @param name The name of the environment variable to read.
/// @param defaultValue The value to return if the environment variable doesn't exists.
/// @return value The value of the environment variable as `bool`.
function getBool(string memory name, bool defaultValue) internal returns (bool value) {
function getBool(string memory name, bool defaultValue) internal view returns (bool value) {
return vulcan.hevm.envOr(name, defaultValue);
}

/// @dev Reads the environment variable with name `name` and returns the value as `uint256`.
/// @param name The name of the environment variable to read.
/// @param defaultValue The value to return if the environment variable doesn't exists.
/// @return value The value of the environment variable as `uint256`.
function getUint(string memory name, uint256 defaultValue) external returns (uint256 value) {
function getUint(string memory name, uint256 defaultValue) internal view returns (uint256 value) {
return vulcan.hevm.envOr(name, defaultValue);
}

/// @dev Reads the environment variable with name `name` and returns the value as `int256`.
/// @param name The name of the environment variable to read.
/// @param defaultValue The value to return if the environment variable doesn't exists.
/// @return value The value of the environment variable as `int256`.
function getInt(string memory name, int256 defaultValue) external returns (int256 value) {
function getInt(string memory name, int256 defaultValue) internal view returns (int256 value) {
return vulcan.hevm.envOr(name, defaultValue);
}

/// @dev Reads the environment variable with name `name` and returns the value as `address`.
/// @param name The name of the environment variable to read.
/// @param defaultValue The value to return if the environment variable doesn't exists.
/// @return value The value of the environment variable as `address`.
function getAddress(string memory name, address defaultValue) external returns (address value) {
function getAddress(string memory name, address defaultValue) internal view returns (address value) {
return vulcan.hevm.envOr(name, defaultValue);
}

/// @dev Reads the environment variable with name `name` and returns the value as `bytes32`.
/// @param name The name of the environment variable to read.
/// @param defaultValue The value to return if the environment variable doesn't exists.
/// @return value The value of the environment variable as `bytes32`.
function getBytes32(string memory name, bytes32 defaultValue) external returns (bytes32 value) {
function getBytes32(string memory name, bytes32 defaultValue) internal view returns (bytes32 value) {
return vulcan.hevm.envOr(name, defaultValue);
}

/// @dev Reads the environment variable with name `name` and returns the value as `string`.
/// @param name The name of the environment variable to read.
/// @param defaultValue The value to return if the environment variable doesn't exists.
/// @return value The value of the environment variable as `string`.
function getString(string memory name, string memory defaultValue) external returns (string memory value) {
function getString(string memory name, string memory defaultValue) internal view returns (string memory value) {
return vulcan.hevm.envOr(name, defaultValue);
}

/// @dev Reads the environment variable with name `name` and returns the value as `bytes`.
/// @param name The name of the environment variable to read.
/// @param defaultValue The value to return if the environment variable doesn't exists.
/// @return value The value of the environment variable as `bytes`.
function getBytes(string memory name, bytes memory defaultValue) external returns (bytes memory value) {
function getBytes(string memory name, bytes memory defaultValue) internal view returns (bytes memory value) {
return vulcan.hevm.envOr(name, defaultValue);
}

Expand All @@ -178,7 +178,8 @@ library env {
/// @param defaultValue The value to return if the environment variable doesn't exists.
/// @return value The value of the environment variable as `bool[]`.
function getBoolArray(string memory name, string memory delim, bool[] memory defaultValue)
external
internal
view
returns (bool[] memory value)
{
return vulcan.hevm.envOr(name, delim, defaultValue);
Expand All @@ -190,7 +191,8 @@ library env {
/// @param defaultValue The value to return if the environment variable doesn't exists.
/// @return value The value of the environment variable as `uint256[]`.
function getUintArray(string memory name, string memory delim, uint256[] memory defaultValue)
external
internal
view
returns (uint256[] memory value)
{
return vulcan.hevm.envOr(name, delim, defaultValue);
Expand All @@ -202,7 +204,8 @@ library env {
/// @param defaultValue The value to return if the environment variable doesn't exists.
/// @return value The value of the environment variable as `int256[]`.
function getIntArray(string memory name, string memory delim, int256[] memory defaultValue)
external
internal
view
returns (int256[] memory value)
{
return vulcan.hevm.envOr(name, delim, defaultValue);
Expand All @@ -214,7 +217,8 @@ library env {
/// @param defaultValue The value to return if the environment variable doesn't exists.
/// @return value The value of the environment variable as `address[]`.
function getAddressArray(string memory name, string memory delim, address[] memory defaultValue)
external
internal
view
returns (address[] memory value)
{
return vulcan.hevm.envOr(name, delim, defaultValue);
Expand All @@ -226,7 +230,8 @@ library env {
/// @param defaultValue The value to return if the environment variable doesn't exists.
/// @return value The value of the environment variable as `bytes32[]`.
function getBytes32Array(string memory name, string memory delim, bytes32[] memory defaultValue)
external
internal
view
returns (bytes32[] memory value)
{
return vulcan.hevm.envOr(name, delim, defaultValue);
Expand All @@ -238,7 +243,8 @@ library env {
/// @param defaultValue The value to return if the environment variable doesn't exists.
/// @return value The value of the environment variable as `string[]`.
function getStringArray(string memory name, string memory delim, string[] memory defaultValue)
external
internal
view
returns (string[] memory value)
{
return vulcan.hevm.envOr(name, delim, defaultValue);
Expand All @@ -250,7 +256,8 @@ library env {
/// @param defaultValue The value to return if the environment variable doesn't exists.
/// @return value The value of the environment variable as `bytes[]`.
function getBytesArray(string memory name, string memory delim, bytes[] memory defaultValue)
external
internal
view
returns (bytes[] memory value)
{
return vulcan.hevm.envOr(name, delim, defaultValue);
Expand Down

0 comments on commit 7e04abf

Please sign in to comment.