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

Add bytes to Base64 encoding in VM #6744

Closed
ernestognw opened this issue Jan 9, 2024 · 0 comments · Fixed by #6785
Closed

Add bytes to Base64 encoding in VM #6744

ernestognw opened this issue Jan 9, 2024 · 0 comments · Fixed by #6785
Labels
D-easy Difficulty: easy good first issue Good for newcomers T-feature Type: feature

Comments

@ernestognw
Copy link
Contributor

ernestognw commented Jan 9, 2024

Component

Forge

Describe the feature you would like

Motivation

Base64 encoding has become relevant in Solidity development for reasons like on-chain metadata (NFTs), and seems there's an upcoming demand for Base64-URL encoding driven by passkey-based authentication (relying on WebAuthn).

As of OZ Contracts, we're working on a Base64URL implementation and we'd love to fuzz the implementation. It'd be great if the Vm.sol had a set of functions for Base64 encoding.

Proposal

Consider adding the following function signatures to Vm.sol:

// crates/cheatcodes/spec/src/vm.rs
// ======== Utilities ========

...

// -------- Base64 --------
#[cheatcode(group = Base64)]
function toBase64(bytes calldata data) external pure returns (string memory);
#[cheatcode(group = Base64)]
function toBase64(string calldata data) external pure returns (string memory);
#[cheatcode(group = Base64)]
function toBase64URL(bytes calldata data) external pure returns (string memory);
#[cheatcode(group = Base64)]
function toBase64URL(string calldata data) external pure returns (string memory);

Such functions can be implemented using this Base64 create, which would provide a reference implementation to fuzz the Solidity version against.

Additional context

No response

@ernestognw ernestognw added the T-feature Type: feature label Jan 9, 2024
@gakonst gakonst added this to Foundry Jan 9, 2024
@github-project-automation github-project-automation bot moved this to Todo in Foundry Jan 9, 2024
@Evalir Evalir added good first issue Good for newcomers D-easy Difficulty: easy labels Jan 11, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D-easy Difficulty: easy good first issue Good for newcomers T-feature Type: feature
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants