-
Notifications
You must be signed in to change notification settings - Fork 772
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
refactor(experimental): add prefixCodec to @solana/codecs-core #2397
Conversation
🦋 Changeset detectedLatest commit: 2a1b158 The changes in this PR will be included in the next version bump. This PR includes changesets to release 35 packages
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 |
72d7c47
to
76dba15
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.
tl;dr unless I missed it, I think you need something to prevent the actual size of the data from being larger than that which you can represent using the length prefix. We either need to throw when that's the case, or truncate the data to the actual length that will eventually be decoded.
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.
76dba15
to
2e28def
Compare
192b23f
to
e8153b8
Compare
2e28def
to
a5c316f
Compare
Merge activity
|
e8153b8
to
5133167
Compare
a5c316f
to
2a1b158
Compare
…ze and prefixCodecSize (#2411) This PR renames `fixCodec` to `fixCodecSize` and `prefixCodec` to `prefixCodecSize` [as discussed here](#2397 (comment)). Note that I created a new changeset describing the change for `fixCodec` but not for `prefixCodec` as this is not yet merged and I thought it'd be better to update the changeset created by a previous PR of this stack.
🎉 This PR is included in version 1.91.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up. |
This PR adds a new
prefixCodec
primitive to@solana/codecs-core
. This primitives accepts any codec and prefixes its size using aNumberCodec
provided as a second argument.For instance:
This PR also updates the
getStringCodec
andgetBytesCodec
as they can now use theprefixCodec
primitive to simplify their internal logic.P.S.: Now that
getStringCodec
andgetBytesCodec
are simple aggregator offixCodec
andprefixCodec
, we should consider removing them or adjusting them further. (Pros: no default values => better tree-shakeability, Cons: slightly less friendly API?).