defi-wonderland / smock

The Solidity mocking library
MIT License
319 stars 40 forks source link

Fakes are incompatible with ABIs that have a 'gas' parameter #104

Closed wei3erHase closed 2 years ago

wei3erHase commented 2 years ago

When using ETH-SDK, for example, the exported ABIs come with a gas parameter into the ABI, for example:

   {
      "stateMutability":"view",
      "type":"function",
      "name":"balanceOf",
      "inputs":[
         {
            "name":"arg0",
            "type":"address"
         }
      ],
      "outputs":[
         {
            "name":"",
            "type":"uint256"
         }
      ],
      "gas":3533
   }

When creating a Fake out of the exported ABIs, the typings of the fake warns the error

import ExportedABI from '../../eth-sdk/abis/mainnet/exported.json';

async()=>{
await smock.fake(ExportedABI);

Typing Error: Types of property 'gas' are incompatible.

Expected behaviour would be to ignore the property.

0xng commented 2 years ago

I believe this should be easily solvable with some Typescript adjustments maybe using Pick or Omit in order to grab only the necessary parameters.

wei3erHase commented 2 years ago

id go for Pick, since you never really know what the devs are going to import to the ABIs