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

CLI does not exclude testing contracts & exclude option broken #4107

Closed
1 task done
norswap opened this issue Jul 3, 2024 · 1 comment
Closed
1 task done

CLI does not exclude testing contracts & exclude option broken #4107

norswap opened this issue Jul 3, 2024 · 1 comment

Comments

@norswap
Copy link

norswap commented Jul 3, 2024

Check existing issues

Describe the bug

Using a pretty straightforward wagmi.config.ts:

export default defineConfig({
    out: "src/generated.ts",
    contracts: [],
    plugins: [
        react(),
        foundry({
            project: "../contracts",
        }),
    ],
})

The generated file contains abis & hooks for testing contracts that it should exclude by default (according to this). e.g.

export const scriptAbi = [
  {
    type: 'function',
    inputs: [],
    name: 'IS_SCRIPT',
    outputs: [{ name: '', internalType: 'bool', type: 'bool' }],
    stateMutability: 'view',
  },
] as const

I am testing this with only a single empty contract, as well as dummy test and deploy script, both of which should be excluded on the basis of the .s.sol and .t.sol extensions.

I've tried to work around this by setting the exclude option inside the foundry plugin, but I have never gotten it to do anything at all.

e.g.

export default defineConfig({
    out: "src/generated.ts",
    contracts: [],
    plugins: [
        react(),
        foundry({
            project: "../contracts",
            exclude: [
              "Main.sol/Main.json",
            ],
        }),
    ],
})

will still include the ABI for my Main (empty contract, not imported anywhere).

Trying broad exclude patterns like *.json or **/*.json also produces no changes whatsoever.

The way I remember this worked in previous versions is that I used the include option to only specify my own contracts, and it would generate the ABI & hooks only for those. That doesn't work anymore either.

Link to Minimal Reproducible Example

No response

Steps To Reproduce

No response

What Wagmi package(s) are you using?

@wagmi/cli

Wagmi Package(s) Version(s)

2.1.13

Viem Version

2.17.0

TypeScript Version

5.5.3

Anything else?

No response

@norswap
Copy link
Author

norswap commented Jul 3, 2024

Unrelated to the issue at hand, but I also think the contracts option is super confusing as it requires specifying ABI, which wagmi should be able to pull out from the artifacts itself.

My understanding is you don't need to specify any contract there, but that isn't clear from the docs. I'm also unsure about the use case — generating hooks for contracts whose ABI you have but whose code isn't in your contracts repo (and so the ABI does not get generated by foundry)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants