-
Notifications
You must be signed in to change notification settings - Fork 8
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
Interacts using typechain #12
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work 💯
Just a comment related to git ignore of interacts.
@@ -14,3 +14,6 @@ build/ | |||
|
|||
# NPM package generated files: | |||
dist/contracts.json | |||
|
|||
# Do not track generated wrapper, it should be part of build script | |||
interacts/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see that you have added postinstall
script.
Its mentioned in the typechain documentation not to commit the interacts. What will be the disadvantages if the interacts are committed?
I am thinking in general, If we publish an NPM package, will the interacts be available? Or the project that consumes the package needs to handle the interact generation separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interacts would still be part of the published package in my opinion, just not part of the repository. That way, it is guaranteed that the interacts are always up to date with the latest code changes on the solidity layer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Interacts will be available in the published package, it's just they are not tracked by git rather generated each time. This will make sure that everyone has the latest interacts.
At the time of publishing, the latest interacts will be generated(as a build step)and published.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Interacts will be available in the published package, it's just they are not tracked by git rather generated each time.
Will it not be confusing on github if there are modules/libraries/helpers written on top of generated interacts 💭 ? Written modules will be tracked in git but the dynamic interacts will not be.
e.g. https://github.com/OpenST/openst.js/blob/develop/lib/helper/User.js
User.js is written on top of multiple contract interacts. So we will commit User.js in github calling generated interacts methods which will not be tracked in github.
One option is we describe this clearly in readme but I just feel it will be confusing for open source community looking at the code.
What do you think 🤔 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the contract repository, there shouldn't be any complex class which uses multiple interacts. They should go into Interaction layer like mosaic.js, openst.js where these thin interact will always be available with published npm of contracts in my opinion.
Reviewing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice 👍
Should we somehow provide something to the consumer to ease deployment or do we expect them to write that themselves? 🤔
@@ -14,3 +14,6 @@ build/ | |||
|
|||
# NPM package generated files: | |||
dist/contracts.json | |||
|
|||
# Do not track generated wrapper, it should be part of build script | |||
interacts/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interacts would still be part of the published package in my opinion, just not part of the repository. That way, it is guaranteed that the interacts are always up to date with the latest code changes on the solidity layer.
"target": "web3-1.0.0", | ||
"outDir" : "interacts" | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😱
I also feel theoretically it should be possible to deploy contracts from generated interacts as they extend from I have created a ticket to research on this. #13 |
Nice work 💯Typechain looks like a simple to use option. I have few questions comparing with our existing interacts approach:
This means positive/negative unit tests needs to be manually written using sinon after generating the interacts covering all the cases. Right ❓ |
Typechain generates interacts in typescript where types are checked at compile time. Which means you can't pass a complex object at the place of string.
No, I don't think unit testing of generated interacts is required that would mean we will be testing the generator tool(that it generates the correct classes). However, we should definitely use these interacts for unit testing of contract logic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost done, just these minor remarks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🐧
fixes #7
This PR generates type script contract interacts. Generated interacts are not committed, they should be generated as part of the build process.
Currently interacts are generated with
npm run generate
and post hook ofnpm install
Interacts are manually tested, to check script refer 0xsarvesh@a508b20
Also, check discussion about Typechain Vs 0x@ab-gen in the ticket