wevm/wagmi

bug: foundry plugin multiple addresses referencing the same ABI

Open

#4,396 opened on 2024年11月10日

GitHub で見る
 (2 comments) (2 reactions) (0 assignees)TypeScript (6,711 stars) (1,399 forks)user submission
Good First Issue

説明

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

コントリビューターガイド

bug: foundry plugin multiple addresses referencing the same ABI · wevm/wagmi#4396 | Good First Issue