Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add struct parsing to @typechain/web3-v1 #779

Merged
merged 4 commits into from
Jan 23, 2023

Conversation

mihai9-lab
Copy link

@mihai9-lab mihai9-lab commented Oct 6, 2022

This PR adds support for struct parsing to @typechain/web3-v1, similarly to @typechain/ethers-v5.

Target from this PR is on NPM if you want to try it out

@changeset-bot
Copy link

changeset-bot bot commented Oct 6, 2022

🦋 Changeset detected

Latest commit: 5c04f68

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

This PR includes changesets to release 1 package
Name Type
@typechain/web3-v1 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

@sigmachirality
Copy link

+1 to this fix/issue, we ran into TS types missing Solidity struct key names in trying to integrate types for this target into our webapp. I hope some form of this get merged soon!

@sigmachirality
Copy link

Hi @krzkaczor, can you provide some feedback?

We use web3-v1 in prod and we often access the struct objects returned from function calls, so having the properties typed by name is imperative before we can adopt this typechain target into our workflow.

Alternatively, would you prefer an implementation which generates types as

export type ReturnStruct = GenericReturnStruct<{
  property1: string;
  property2: string;
  0: string;
  1: string;
}>;

Similar to how Events types are generated in this target, as opposed to ReturnStructAsAnObject & ReturnStructAsAnArray (how they are generated in the ethers target)? If so, I'm down to work on this PR on more to get it into a state that's able to be merged.

Please let me know, and thanks in advance!

@mihai9-lab
Copy link
Author

Hi @sigmachirality, i think that the issues you mentioned are already covered by this PR. If not, could you elaborate a bit more?

A few days ago i published this as a package on npm, under the name typechain-target-web3-v1-3mihai3, you could try adding it to your project and seeing if it works for you. Just set the target to web3-v1-3mihai3.

@sigmachirality
Copy link

@mihai9-lab I think your solution is fine as is/solves our use case! Just wanted to figure out why @krzkaczor and others haven't merged this PR yet, and my comment just asks about one possible reason I think could be blocking this PR.

@krzkaczor krzkaczor changed the base branch from master to mihal9-pr January 23, 2023 11:23
@krzkaczor krzkaczor merged commit 2a97695 into dethcrypto:mihal9-pr Jan 23, 2023
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.

None yet

3 participants