wagmi icon indicating copy to clipboard operation
wagmi copied to clipboard

bug: foundry plugin multiple addresses referencing the same ABI

Open decafboba opened this issue 1 year ago • 1 comments

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

decafboba avatar Nov 10 '24 18:11 decafboba

hii @tmm @decafboba is this issue is closed !!

Sourya07 avatar Nov 13 '25 18:11 Sourya07