Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: envWithDefault cheatcode initial implementation #3732 #3810

Merged
merged 3 commits into from
Dec 1, 2022

Conversation

slvDev
Copy link
Contributor

@slvDev slvDev commented Dec 1, 2022

Implementation of Issue #3732

That is my first PR to Foundry - please correct me if I got anything wrong.

Motivation

As noted by @vicnaum, there is a demand for non-reverting cheatcode for reading from Environment

Solution

Based on @mds1 suggestion: a new cheatcode was created named vm.envWithDefault(string name, <defaultVal>), where type determines the type and encoding of the Environment Variable

@slvDev slvDev mentioned this pull request Dec 1, 2022
Copy link
Member

@gakonst gakonst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautiful - pending CI fixes

@@ -41,6 +41,20 @@ ethers::contract::abigen!(
envBytes32(string,string)(bytes32[])
envString(string,string)(string[])
envBytes(string,string)(bytes[])
envWithDefault(string,bool)(bool)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to suggest an alternative name here:

envOr or even variants for all types like envStringOr

imo Default is not really fitting here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with envOr, just originally chose envWithDefault cause it felt more explicit, though envOr is more aligned with rust-like syntax

@gakonst
Copy link
Member

gakonst commented Dec 1, 2022

envOr 👍

@gakonst
Copy link
Member

gakonst commented Dec 1, 2022

full send - thanks @slvDev

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.

None yet

4 participants