-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add protocol version #191
Add protocol version #191
Conversation
🦋 Changeset detectedLatest commit: f9cb8af The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
TBDocs Report ✅ No errors or warnings @tbdex/protocol
@tbdex/http-client
@tbdex/http-server
TBDocs Report Updated at 2024-03-12T19:09:09Z |
tests won't pass until TBD54566975/tbdex#244 is merged |
packages/protocol/src/message.ts
Outdated
@@ -44,6 +46,11 @@ export abstract class Message { | |||
return typeid(messageKind).toString() | |||
} | |||
|
|||
/** Gets the 'x.x' major/minor formatted version based on the current protocol release version */ | |||
static getProtocolVersion(): `${number}` { |
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.
Parsing this as a number is going to lead to weird comparisons, e.g. Version 1.2 > 1.12. What do you think of returning a string?
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.
Oh wait this is the version of the SDK, not the TBDex version. I think those two versions will be different, no? What are we using the SDK version for within the SDK?
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.
Parsing this as a number is going to lead to weird comparisons, e.g. Version 1.2 > 1.12. What do you think of returning a string?
this is a template literal type. it returns a number as a string. so we will get major and minor versions even if we pass '1.12.1' (we will get "1.12"
) and we will get a compiler error if we try to pass hello, diane!
tl;dr: it is returning a string :)
Oh wait this is the version of the SDK, not the TBDex version. I think those two versions will be different, no? What are we using the SDK version for within the SDK?
yep realized afterward I conflated the two. there are weird gotchas with both so will be discussing more this week. its likely the source of the version will change but the rest in this pr will look about the same.
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.
TIL template literals. thanks!
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.
would this still allow number of any format to be passed in (i.e. 9000
or 0.12345
?
the pattern we want is x.x
like 1.1
or 2.0
, per initial proposal https://hackmd.io/TucOUP8UQt-XKj8G9UsJ2Q ?
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.
wow TIL template literal as well, very cool
9b4e633
to
21674a8
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #191 +/- ##
==========================================
+ Coverage 93.22% 93.23% +0.01%
==========================================
Files 37 37
Lines 3011 3047 +36
Branches 329 338 +9
==========================================
+ Hits 2807 2841 +34
- Misses 204 206 +2
|
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.
Suggestion: populate protocol
within .create()
rather than passing it as an parameter. This package only supports one possible version currently, so it could simplify DX.
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.
agreed. i think protocol
should be set internally and optionally overridable
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.
So, default to 1.0 for now with no validation? Or hardcode the versions somewhere the way Kirah previously had it?
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.
I'm not sure what you mean by no validation, but either option sounds sufficient to me
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.
default to 1.0
with no validation feels like easiest path forward right now. wdyt @phoebe-lew ?
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.
@mistermoe agree that's easiest.
@diehuxx if overridable with no validation, someone could put in 666.6
or not even a number
as the version
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.
we can create an issue to track validating protocol
and tackle post 1.0. i think we'll have a better sense for what "validation" entails beyond just the actual value (e.g. is this message conformant to the version specified) when we're closer to introducing a change to the protocol
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.
@mistermoe ah i see, thanks! agreed let's not do validation for now and we'll follow up on it later
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.
issue created: TBD54566975/tbdex#270
@@ -8,7 +8,7 @@ import { Parser } from '../parser.js' | |||
*/ | |||
export type CreateCloseOptions = { | |||
data: CloseData | |||
metadata: Omit<CloseMetadata, 'id' | 'kind' | 'createdAt'> | |||
metadata: Omit<CloseMetadata, 'id' | 'kind' | 'createdAt' | 'protocol'> & { protocol?: CloseMetadata['protocol'] } |
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.
Non-blocking: I kinda hate indexed access type syntax in typescript. Instead I prefer to just use the underlying type, in this case,
`${number}`
metadata: Omit<CloseMetadata, 'id' | 'kind' | 'createdAt' | 'protocol'> & { protocol?: CloseMetadata['protocol'] } | |
metadata: Omit<CloseMetadata, 'id' | 'kind' | 'createdAt' | 'protocol'> & { protocol?: `${number}` } |
Up to you if you feel like doing this. Just a personal preference on my part.
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.
Curious what you don't like about it! the way it looks, or is there something about the way it works that you dislike?
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.
it's a readability thing. it's an abstraction that i personally don't find helpful. i don't like needing to have to look at a separate file or type to figure out what i'm actually working with, especially if it's as simple as a number or string.
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.
Oh got it. I'm leaning towards leaving it as is because theoretically, the types could drift between CloseMetadata
and this field if it's not referencing CloseMetadata
.
closes #172