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

fix(protocol-parser): only append packed counter if there is dynamic data #1097

Merged
merged 3 commits into from Jul 3, 2023

Conversation

alvrs
Copy link
Member

@alvrs alvrs commented Jul 3, 2023

@alvrs alvrs requested a review from holic as a code owner July 3, 2023 15:29
@changeset-bot
Copy link

changeset-bot bot commented Jul 3, 2023

⚠️ No Changeset found

Latest commit: a425d2d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

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

holic
holic previously approved these changes Jul 3, 2023
Copy link
Member

@holic holic left a comment

Choose a reason for hiding this comment

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

do we want a test for this?

@alvrs
Copy link
Member Author

alvrs commented Jul 3, 2023

do we want a test for this?

good call, that would be good, also as a baseline for folks who want to port this

? `${encodeField("uint56", dynamicTotalByteLength).replace(/^0x/, "")}${dynamicFieldByteLengths
.map((length) => encodeField("uint40", length).replace(/^0x/, ""))
.join("")}`.padEnd(64, "0")
: "";
Copy link
Member

@holic holic Jul 3, 2023

Choose a reason for hiding this comment

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

sorry, one more thing

it might make sense to do this check and return early so we avoid all the other work above and inner conditionals and such

shortly after const staticData = ..., do something like

if (!dynamicValues.length) {
  return `0x${staticData}`;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

agree, this also mirrors the on-chain logic better

Base automatically changed from alvrs/add-is-dynamic-schema to main July 3, 2023 17:41
@alvrs alvrs dismissed holic’s stale review July 3, 2023 17:41

The base branch was changed.

@alvrs alvrs merged commit 8619d15 into main Jul 3, 2023
10 checks passed
@alvrs alvrs deleted the alvrs/fix-encode-record branch July 3, 2023 19:28
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

2 participants