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

[Bug] sol! only accepts string literal #651

Closed
wtdcode opened this issue Jun 10, 2024 · 3 comments
Closed

[Bug] sol! only accepts string literal #651

wtdcode opened this issue Jun 10, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@wtdcode
Copy link
Contributor

wtdcode commented Jun 10, 2024

Component

sol! macro

What version of Alloy are you on?

0.7.4

Operating System

Linux

Describe the bug

sol! seems only to support string literals, i.e., LitStr. For instance:

sol!(T, "[]"); // Works
sol!(T, concat!("[","]")); // Doesn't work
const s: &str = "[]";
sol!(T, s); // Doesn't work either

Is it possible to support a constant &str instead? This would be helpful to support something like concat!(std::env!("OUT_DIR"), ...)

@wtdcode wtdcode added the bug Something isn't working label Jun 10, 2024
@wtdcode
Copy link
Contributor Author

wtdcode commented Jun 10, 2024

Seems not possible as rust-lang/rust#69133

@wtdcode wtdcode closed this as completed Jun 10, 2024
@DaniPopes
Copy link
Member

DaniPopes commented Jun 10, 2024

We parse out environment variables with $ENV inside of the literal, but that's about as much as you can do unfortunately

@chris13524
Copy link

Bumping this, is there a way to reference environment variables in the latest version of sol!? This doesn't seem to work:

sol!(
    #[allow(missing_docs)]
    #[sol(rpc)]
    SafeProxyFactory,
    "$OUT_DIR/../../../../.foundry/forge/out/SafeProxyFactory.sol/SafeProxyFactory.json"
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants