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

feat(store): add codegen for all types for tightcoder #396

Merged
merged 4 commits into from
Feb 22, 2023

Conversation

dk1a
Copy link
Contributor

@dk1a dk1a commented Feb 11, 2023

Depends on #395
Not sure what to do with autogenerated files, tentatively not gitignoring them for now

@dk1a dk1a force-pushed the dk1a/v2-storagecoder-codegen branch from fbda72b to 2320b6d Compare February 17, 2023 21:44
@dk1a dk1a marked this pull request as ready for review February 17, 2023 21:45
@dk1a dk1a requested a review from alvrs as a code owner February 17, 2023 21:45
@dk1a dk1a changed the title feat(store): add codegen for all types for storagecoder feat(store): add codegen for all types for tightcoder Feb 17, 2023
@alvrs alvrs self-assigned this Feb 17, 2023
Copy link
Member

@alvrs alvrs left a 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))?

packages/store/package.json Outdated Show resolved Hide resolved
************************************************************************/
<% for (let i = 8; i <= 256; i += 8) { -%>

function decodeArray_uint<%= i %>(Slice self) internal pure returns (uint<%= i %>[] memory output) {
Copy link
Member

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.

Copy link
Contributor Author

@dk1a dk1a Feb 21, 2023

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;

Copy link
Member

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"?

Copy link
Contributor Author

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)

@dk1a
Copy link
Contributor Author

dk1a commented Feb 21, 2023

Also, do you think this PR would be a good place to rename TightCoder into Serializer (as proposed by @holic in #387 (comment))?

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

Copy link
Member

@alvrs alvrs left a comment

Choose a reason for hiding this comment

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

lgtm!

@alvrs alvrs merged commit b686e08 into v2 Feb 22, 2023
@dk1a dk1a deleted the dk1a/v2-storagecoder-codegen branch May 9, 2023 16:23
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.

2 participants