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: foundry plugin multiple addresses referencing the same ABI #4396

Open
1 task done
0x6080 opened this issue Nov 10, 2024 · 0 comments · May be fixed by #4410
Open
1 task done

bug: foundry plugin multiple addresses referencing the same ABI #4396

0x6080 opened this issue Nov 10, 2024 · 0 comments · May be fixed by #4410
Labels
Good First Issue Misc: Good First Issue

Comments

@0x6080
Copy link

0x6080 commented Nov 10, 2024

Check existing issues

Describe the bug

At Zora, we use the foundry plugin and love it. However, if you have multiple addresses that need to share the same ABI (e.g. different ERC20 tokens) it doesn't work.

If I am reading in a deployment file and writing the addresses like in this example: https://github.com/ourzora/zora-721-contracts/blob/main/wagmi.config.ts

Example extending that:

type ContractNames =
  // ...
  | 'ERC20';

type Address = `0x${string}`;

const contractFilesToInclude: ContractNames[] = [
  // ...
  'ERC20'
];

  for (const addressesFile of addressesFiles) {
    const jsonAddress = JSON.parse(
      readFileSync(`./addresses/${addressesFile}`, 'utf-8')
    ) as {
      // ... 
      WETH: Address;
      DAI: Address;
    };

    addAddress(
      'ZoraNFTCreatorV1',
      chainId,
      jsonAddress.ZORA_NFT_CREATOR_PROXY
    );
    addAddress('ERC20', chainId, jsonAddress.DAI);
    addAddress('ERC20', chainId, jsonAddress.WETH);

only the daiConfig / daiAddress gets created, but not the WETH config.

Link to Minimal Reproducible Example

https://gist.github.com/0x6080/126272e246be09b24274acd3aae55bd5

Steps To Reproduce

If I am reading in a deployment file and writing the addresses like in this example: https://github.com/ourzora/zora-721-contracts/blob/main/wagmi.config.ts

Example extending that:

type ContractNames =
  // ...
  | 'ERC20';

type Address = `0x${string}`;

const contractFilesToInclude: ContractNames[] = [
  // ...
  'ERC20'
];

  for (const addressesFile of addressesFiles) {
    const jsonAddress = JSON.parse(
      readFileSync(`./addresses/${addressesFile}`, 'utf-8')
    ) as {
      // ... 
      WETH: Address;
      DAI: Address;
    };

    // ... 
    addAddress('ERC20', chainId, jsonAddress.DAI);
    addAddress('ERC20', chainId, jsonAddress.WETH);

only the daiConfig / daiAddress gets created:

/**
 *
 */
export const daiAddress = {
  31337: '0xF0794f5a1318CAbf8270AFeeA33cB2b7543d1839',
} as const

/**
 *
 */
export const daiConfig = {
  address: daiAddress,
  abi: erc20Abi,
} as const

but not the WETH config.

What Wagmi package(s) are you using?

@wagmi/cli

Wagmi Package(s) Version(s)

2.12.24

Viem Version

2.21.35

TypeScript Version

20

Anything else?

Ideal behavior would be for both of them to reference the same abi, for example:

export const wethConfig = {
  address: wethAddress,
  abi: erc20Abi,
} as const
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue Misc: Good First Issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants