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

native String utils cheatcodes #6818

Closed
mattsse opened this issue Jan 16, 2024 · 10 comments · Fixed by #6891
Closed

native String utils cheatcodes #6818

mattsse opened this issue Jan 16, 2024 · 10 comments · Fixed by #6891
Assignees
Labels
A-cheatcodes Area: cheatcodes good first issue Good for newcomers T-feature Type: feature

Comments

@mattsse
Copy link
Member

mattsse commented Jan 16, 2024

Component

Forge

Describe the feature you would like

such as

replace
lowercase
uppercase
trim
split
...

Additional context

No response

@mattsse mattsse added good first issue Good for newcomers T-feature Type: feature A-cheatcodes Area: cheatcodes labels Jan 16, 2024
@1010adigupta
Copy link
Contributor

can take this

@1010adigupta
Copy link
Contributor

@mattsse can you provide some more context of these features here?

@mattsse
Copy link
Member Author

mattsse commented Jan 19, 2024

here are some docs/instructions

https://github.com/foundry-rs/foundry/blob/master/docs/dev/cheatcodes.md#cheatcodes-implementation

what we want is something like:

function toLowercase(string) returns string

the rust cheatcode then simply returns .to_lowercase()

see EnvBool cheatcode for example:

/// Gets the environment variable `name` and parses it as `bool`.
/// Reverts if the variable was not found or could not be parsed.
#[cheatcode(group = Environment)]
function envBool(string calldata name) external view returns (bool value);

impl Cheatcode for envBool_0Call {
fn apply(&self, _state: &mut Cheatcodes) -> Result {
let Self { name } = self;
env(name, &DynSolType::Bool)
}
}

@bolajahmad
Copy link

Are you currently working on this @1010adigupta? I find it interesting and would like to work on it especially after the great guide from @mattsse

@bolajahmad
Copy link

@mattsse a few questions, for the native string utils are you suggesting adding the following and any other suggestions?
replace, lowercase, uppercase, trim, split

Implementing the string to the respective cheat code and returning the response, will that suffice to close this issue?

@1010adigupta
Copy link
Contributor

yes currently working on it :)

@mattsse
Copy link
Member Author

mattsse commented Jan 22, 2024

Implementing the string to the respective cheat code and returning the response, will that suffice to close this issue?

yes, I guess we also want these:

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol

@1010adigupta
Copy link
Contributor

1010adigupta commented Jan 24, 2024

In what group should these Utils go?
string, env, or utilities?

@1010adigupta
Copy link
Contributor

Hey @mattsse I have created a pr for string utils of lowercase, uppercase, trim, replace, split if that's lgtm you can merge it

@1010adigupta
Copy link
Contributor

1010adigupta commented Jan 24, 2024

Implementing the string to the respective cheat code and returning the response, will that suffice to close this issue?

yes, I guess we also want these:

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol

I will start working on these with a new pr
I think we would need to add the following:
toHexString and toStringSigned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cheatcodes Area: cheatcodes good first issue Good for newcomers T-feature Type: feature
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants