xf00f / web3x

Ethereum TypeScript Client Library - for perfect types and tiny builds.
211 stars 27 forks source link

Add named fields to codegen-generated return types #59

Closed uhhhh2 closed 5 years ago

uhhhh2 commented 5 years ago

When calling a smart contract method with multiple return values in web3 or web3x, one can access the return values by their names and/or by their indexes. However, web3x-codegen generated interfaces only allow access to return values by indexes.

Example smart contract method:

    function getInfo() public view returns (
        address theRichest,
        uint theMostSent,
        string theScreenName,
        address thisAddress
    )

Generated code before this change:

getInfo(): TxCall<[Address, string, string, Address]>;

which is equivalent to:

getInfo(): TxCall<{
        0: Address;
        1: string;
        2: string;
        3: Address;
    }>;

Generated code after this change:

getInfo(): TxCall<{
        "theRichest": Address;
        0: Address;
        "theMostSent": string;
        1: string;
        "theScreenName": string;
        2: string;
        "thisAddress": Address;
        3: Address;
    }>;
xf00f commented 5 years ago

Merged into v4.0.4.