Skip to content

Add support for solidity structs#493

Merged
zemse merged 13 commits intodethcrypto:masterfrom
zemse:ethers-v5-structs
Oct 21, 2021
Merged

Add support for solidity structs#493
zemse merged 13 commits intodethcrypto:masterfrom
zemse:ethers-v5-structs

Conversation

@zemse
Copy link
Contributor

@zemse zemse commented Oct 6, 2021

Example:

struct Amount {
    address token;
    uint96 value;
}
// before
function deposit(amount: {token: string, value: BigNumberish}): Promise<ContractTransaction>;


// after
export type AmountStruct = {token: string, value: BigNumberish};

function deposit(amount: AmountStruct): Promise<ContractTransaction>;

Closes #398

@changeset-bot
Copy link

changeset-bot bot commented Oct 6, 2021

🦋 Changeset detected

Latest commit: a55e6c4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@typechain/ethers-v5 Minor
typechain Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@zemse zemse changed the title ethers v5 structs Add support for solidity structs Oct 6, 2021
Copy link
Contributor

@hasparus hasparus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one! I actually asked Krzysztof about emitting struct types earlier this week, and reading this gave a better insight into TypeChain internals :)

The only comment I have is a nitpick about naming of insertStruct — have you considered registerStruct? It wasn't obvious to me what insertStruct does before reading the implementation. Feel free to disregard this comment — it's just something that's been on my mind that I wanted to mention.

The PR looks good to me.

@zemse zemse force-pushed the ethers-v5-structs branch from 86b454b to eeb77fe Compare October 7, 2021 19:55
@zemse
Copy link
Contributor Author

zemse commented Oct 7, 2021

I just made the change for the name, registerStruct definitely makes better sense. Now just rebasing for this conflict problem.

Copy link
Member

@krzkaczor krzkaczor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

One last thing is a missing changeset. While writing one could you attach an example of how newly generated code is different from the old one?

@zemse zemse force-pushed the ethers-v5-structs branch from e7b2ae4 to a80965c Compare October 16, 2021 21:00
@zemse zemse merged commit 95517e9 into dethcrypto:master Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: auto-generated types for solidity structs and events

3 participants