This repository was archived by the owner on Jan 22, 2025. It is now read-only.
feat: add VersionedMessage.deserializeMessageVersion utility function#27415
Merged
jstarry merged 1 commit intosolana-labs:masterfrom Aug 29, 2022
Merged
feat: add VersionedMessage.deserializeMessageVersion utility function#27415jstarry merged 1 commit intosolana-labs:masterfrom
jstarry merged 1 commit intosolana-labs:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #27415 +/- ##
========================================
Coverage 76.9% 76.9%
========================================
Files 48 51 +3
Lines 2505 2660 +155
Branches 355 364 +9
========================================
+ Hits 1927 2048 +121
- Misses 448 481 +33
- Partials 130 131 +1 |
steveluscher
approved these changes
Aug 29, 2022
| @@ -5,17 +5,26 @@ import {MessageV0} from './v0'; | |||
| export type VersionedMessage = Message | MessageV0; | |||
| // eslint-disable-next-line no-redeclare | |||
| export const VersionedMessage = { | |||
Contributor
There was a problem hiding this comment.
I haven't checked how tree-shakers treat this. If I do:
import {VersionedMessage} from 'src/message/versioned';
// ...but then only use one function
if (VersionedMessage.deserializeMessageVersion(message) === 'legacy') {
/* ... */
}
…does the compiler shake out the other methods I haven't used?
I know it definitely works if you export each function.
export function deserializeMessageVersion(...) { ... }
…then
import {deserializeMessageVersion} from 'src/message/versioned';
if (deserializeMessageVersion(message) === 'legacy') {
/* ... */
}
Contributor
Author
There was a problem hiding this comment.
Oh good question, I'd like to punt on this for now and would happily accept / implement a change that's more tree-shaker friendly if it's an issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
Lack of utility function to check the version of a serialized message without fully deserializing the message
Summary of Changes
VersionedMessage.deserializeMessageVersionFixes #