dethcrypto / dethcrypto/TypeChain

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

Open
#515 0 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
2.8k
Forks
376
PR merge metrics
No merged PRs in 30d

Description

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 === `
Unfortunately you can't do it right now, and have to use only numbers
`(await contractInstance.map(user))[0] === ` 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.