dethcrypto / TypeChain

🔌 TypeScript bindings for Ethereum smart contracts
MIT License
2.76k stars 364 forks source link

Incorrect bindings when two contracts have the same name but different letter cases #452

Open PaulRBerg opened 3 years ago

PaulRBerg commented 3 years ago

Description

When there are two (or more?) contracts that share the same name, but which have a different letter case, TypeChain fails to generate the bindings correctly.

Reproduction

  1. Clone https://github.com/hifi-finance/hifi/tree/9aa96fd38fb727049735993c4e6180990bad58db.
  2. Install dependencies via yarn
  3. Build packages via yarn build
  4. Create a .env file by following the .env.example
  5. Run yarn workspace @hifi/flash-swap typechain
  6. Open the packages/flash-swap/typechain/IErc20.d.ts file.

You should see the same output as in this gist. Notice that:

  1. The file name is IErc20.d.ts, although the class defined inside is IERC20.
  2. There is no other IERC20.d.ts file in the typechain folder.

Possible Solutions

  1. Consider two contracts that differ even in the case of one letter case as two different contracts, and fix the bug.
  2. Alert the user that they can't use two contracts with the same name, even if they may have different letter cases.

Environment

zemse commented 3 years ago

At a quick glance, normalizeName doesn't seem to cause IERC20 to IErc20. Need to investigate what causes that.