TypeChain icon indicating copy to clipboard operation
TypeChain copied to clipboard

Feature request: generate-type doesn't understand name of fields for structures in Solidity

Open lebed2045 opened this issue 4 years ago • 0 comments

Consider this contract:

    struct S {
        uint256 a;
        address b; 
    }

    mapping(uint256 => S) public map;

and you would like to check that mapping has desirable values with something like this code: (await contractInstance.map(user)).a === <some sort of comparison> Unfortunately you can't do it right now, and have to use only numbers (await contractInstance.map(user))[0] === <some sort of comparison> because the type generated is this:

  map(
    arg0: string,
    txDetails?: Truffle.TransactionDetails
  ): Promise<{ 0: BN;  1: string}>;

If you add one field you might have to rewire many tests to keep this working. So working with names field rather than numbers would make it much for simpler. Types.d.ts however, has recognised event names and that's cool.

lebed2045 avatar Oct 12 '21 15:10 lebed2045