-
Notifications
You must be signed in to change notification settings - Fork 189
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
feat(store): add codegen for all types for tightcoder #396
Conversation
fbda72b
to
2320b6d
Compare
2320b6d
to
02a7a4b
Compare
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.
Great PR! Just very minor questions/nits.
Also, do you think this PR would be a good place to rename TightCoder
into Serializer
(as proposed by @holic in #387 (comment))?
************************************************************************/ | ||
<% for (let i = 8; i <= 256; i += 8) { -%> | ||
|
||
function decodeArray_uint<%= i %>(Slice self) internal pure returns (uint<%= i %>[] memory output) { |
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.
ooc why did you decide for this naming format (decodeArray_uint256
) instead of something like decodeUint256Array
? Also, since the library is called DecodeSlice
, I would have expected the function to be called something like toUint256Array
, but no strong opinion.
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 short I'm going for <method>_<T>
as a way to resemble generics
why did you decide for this naming format (decodeArray_uint256) instead of something like decodeUint256Array?
The main reason is autogen. After _ comes the exact type name. I'd rather not do more manipulations than necessary since this is already quite complicated.
Also, since the library is called DecodeSlice, I would have expected the function to be called something like toUint256Array
Similar reason - I want the "method name" to be purely as a prefix, and "type name" purely as a postfix, both separated by _
.
For encode
/decode
- I feel like while writing it I had a harder time remembering which methods did what with to
/from
. With decode I had a better analogy to abi.decode etc.
@@ -0,0 +1,81 @@ | |||
// SPDX-License-Identifier: MIT | |||
pragma solidity >=0.8.0; | |||
|
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.
Should we put a comment on the top of the file saying something like "Autogenerated from DecodeSlice.ejs via yarn codegen, do not edit manually"?
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.
Added one, see if it's ok. I'm not sure we need the comment customized to filename, but mentioning which file shouldn't be edited seems important
(for schema autogen I just write /* Autogenerated file. Do not edit manually. */
but since here both files are together, it's not very clear)
Co-authored-by: alvarius <[email protected]>
I'd rather do such encompassing renamings closer to v2 completion when we have world and autogen merged, to avoid changing WIP branches often. Will give more time to think about the name too |
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!
Depends on #395
Not sure what to do with autogenerated files, tentatively not gitignoring them for now