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(cast): cast interface generates unexpected library instead of interface #9960

Open
2 tasks done
sakulstra opened this issue Feb 26, 2025 · 1 comment
Open
2 tasks done
Labels
C-cast Command: cast T-bug Type: bug T-to-reproduce Type: requires reproduction

Comments

@sakulstra
Copy link
Contributor

sakulstra commented Feb 26, 2025

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

9bcfbaa

What version of Foundryup are you on?

No response

What command(s) is the bug in?

cast interface

Operating System

None

Describe the bug

Hey, i think there is a regression in cast interface (or at least an unexpected change).

I have a:

interface ITestContract {
  struct TestStruct {
    address asset;
  }
}

contract TestContract is ITestContract {
  function test(TestStruct memory) external {}
}

Now cast interface ./src/Test.sol:TestContract will yield:

pragma solidity ^0.8.4;

library ITestContract {
    struct TestStruct {
        address asset;
    }
}

interface TestContract {
    function test(ITestContract.TestStruct memory) external;
}

Which I think different to previous versions as i'm pretty sure that before structs were included in the generated interface. Is this change intentional?, as ux wise it's a bit weird.


More of a question out of curiosity: Would it be possible to include the natspec on the generated interface?
In most smart contracts i'm reading i have to constantly jump between interface and contract to fully understand the code. Therefore i'm wondering if it wouldn't be a better approach to just have all the natspec on the actual contract (not the interface) and then simply generate the interface.

@sakulstra sakulstra added T-bug Type: bug T-needs-triage Type: this issue needs to be labelled labels Feb 26, 2025
@github-project-automation github-project-automation bot moved this to Todo in Foundry Feb 26, 2025
@zerosnacks
Copy link
Member

This is likely related to us moving from Solang to Solar

/// Converts a vector of tuples containing the ABI and contract name into a vector of
/// `InterfaceSource` objects.
fn get_interfaces(abis: Vec<(JsonAbi, String)>) -> Result<Vec<InterfaceSource>> {
abis.into_iter()
.map(|(contract_abi, name)| {
let source = match foundry_cli::utils::abi_to_solidity(&contract_abi, &name) {
Ok(generated_source) => generated_source,
Err(e) => {
warn!("Failed to format interface for {name}: {e}");
contract_abi.to_sol(&name, None)
}
};
Ok(InterfaceSource { json_abi: serde_json::to_string_pretty(&contract_abi)?, source })
})
.collect()
}

@zerosnacks zerosnacks added the C-cast Command: cast label Feb 26, 2025
@zerosnacks zerosnacks changed the title cast interface generates unexpected library bug(cast): cast interface generates unexpected library instead of interface Feb 26, 2025
@zerosnacks zerosnacks added T-to-reproduce Type: requires reproduction and removed T-needs-triage Type: this issue needs to be labelled labels Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cast Command: cast T-bug Type: bug T-to-reproduce Type: requires reproduction
Projects
Status: Todo
Development

No branches or pull requests

2 participants