Skip to content

bug(cast): cast interface generates unexpected library instead of interface #9960

Open
@sakulstra

Description

@sakulstra

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-castCommand: castT-bugType: bug

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions