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] Solidity type alias yields unresolved custom type: #744

Open
gpsanant opened this issue Sep 24, 2024 · 7 comments
Open

[Bug] Solidity type alias yields unresolved custom type: #744

gpsanant opened this issue Sep 24, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@gpsanant
Copy link

Component

sol! macro

What version of Alloy are you on?

v0.8.3

Operating System

macOS (Apple Silicon)

Describe the bug

The following abi

DelegationManager.json

along with the following code

mod core {
    alloy::sol!(
        #[allow(missing_docs)]
        #[sol(rpc)]
        DelegationManager,
        "../abis/DelegationManager.json"
    );
}
error: unresolved custom type: DelegatedShares
  --> scenario-generator/src/bin/populate_src.rs:63:5
   |
63 | /     alloy::sol!(
64 | |         #[allow(missing_docs)]
65 | |         #[sol(rpc)]
66 | |         DelegationManager,
67 | |         "../abis/DelegationManager.json"
68 | |     );
   | |_____^
   |
   = note: this error originates in the macro `$crate::sol_types::sol` which comes from the expansion of the macro `alloy::sol` (in Nightly builds, run with -Z macro-backtrace for more info)

If you prefer to build the contracts yourself:

git clone git@github.com:Layr-Labs/eigenlayer-contracts.git
git checkout slashing-magnitues
forge b -C src/contracts

See out/DelegationManager.sol/DelegationManager.json.

I'm using a type alias DelegatedShares for uint256.

@gpsanant gpsanant added the bug Something isn't working label Sep 24, 2024
@mattsse
Copy link
Member

mattsse commented Sep 24, 2024

yeah this looks like an issue with type aliases

         {
            "name": "delegatedShares",
            "type": "uint256[]",
            "internalType": "DelegatedShares[]"
          }

@DaniPopes
Copy link
Member

There's 2 issues here:

  1. We're ignoring UDVT arrays, fixed in fix(json-abi): correct to-sol for UDVT arrays in structs #745
  2. After this fix, it still fails because the type doesn't have an assigned contract because it is declared globally, this requires a bit more work to fix

@gpsanant
Copy link
Author

Thanks for the prompt response.

For now, I'm actually not using the functions with the custom types so I'll just redefine interfaces.

If I included the types inside of the library contract in which they're defined, would that address (2)?

@DaniPopes
Copy link
Member

DaniPopes commented Sep 24, 2024

Yes I think so, if you were to move the type DelegatedShares is uint256; inside of one of the interfaces or libraries referenced by the ABI

@gpsanant
Copy link
Author

Cool, confirming that

  1. getting rid of the alias array
  2. stuffing the alias definition inside of the library

Made the contract get imported correctly.

Unfortunately, that makes the solidity syntax quite gross, so I'm temporarily going with

sed -i '' 's/DelegatedShares/uint256/g' out/DelegationManager.sol/DelegationManager.json

which seems to work? :)

@dobbobalina2
Copy link

@DaniPopes Any solutions for using the entrypoint.sol contract from the account abstraction lib found here?

Importing PackedUserOperation is an issue

@kayabaNerve
Copy link

I believe I have a similar issue here when using the sol macro. I defined an interface which inherits and used types from its parent. When not using the sol macro, yet my own expander which outputs to a file (I need a preprocessor per #602), I get a distinct error of:

proc-macro-error2 API cannot be used outside of entry_point invocation, perhaps you forgot to annotate your #[proc_macro] function with #[proc_macro_error]

I'm unsure exactly how that became my error yet wanted to log it here.

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

5 participants