[Bug] Error when using sol! to parse a Solidity file
Closed this issue ยท 4 comments
Component
sol! macro
What version of Alloy are you on?
v0.7.4
Operating System
macOS (Apple Silicon)
Describe the bug
From the docs, I understand that I should be able to use the sol! macro like this as well: sol!(Erc20, "../examples/erc20/src/test.sol");
However, when I try to do that, I get a "names are not allowed outside of JSON ABI" error, which comes from
core/crates/sol-macro-input/src/input.rs
Line 128 in f5e04aa
when importing .sol
files, there's no need for a name, as the name will be picked up from the contract MyContract
definition in the solidity file. Given a file may contain multiple contract _____
definitions, renaming by adding a name there would also be pretty unreliable. So for those reasons, solidity files can only be imported without a name
The following should work for you:
sol!("../examples/erc20/src/test.sol");
Gotcha, makes sense. Maybe update the error message with a suggestion?
Also, I'm guessing if you wanted rpc calls you just do:
sol!(
#[sol(rpc)]
"../examples/erc20/src/test.sol"
);
Feel free to close ๐
yes, I think the invocation with #[sol(rpc)]
will work as exepcted