-
Notifications
You must be signed in to change notification settings - Fork 42
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
chore: move protocols CreateOptions
into interfaces and
#1145
Conversation
add possible TODO
size-limit report 📦
|
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.
cool 😎
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.
Some remaining work to tackle.
@@ -66,18 +55,21 @@ export type UnsubscribeFunction = () => Promise<void>; | |||
*/ | |||
class Filter implements IFilter { | |||
multicodec: string; | |||
pubSubTopic: string; | |||
options: ProtocolCreateOptions; |
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.
Changelog update needed to highlight breaking change in API.
/** | ||
* Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/). | ||
*/ | ||
class LightPush implements ILightPush { | ||
multicodec: string; | ||
pubSubTopic: string; | ||
options: ProtocolCreateOptions; |
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.
update changelog to highlight api breaking change
super(components, options); | ||
this.multicodecs = constants.RelayCodecs; | ||
|
||
this.observers = new Map(); | ||
|
||
this.pubSubTopic = options?.pubSubTopic ?? DefaultPubSubTopic; | ||
this.options = options ?? {}; |
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.
you end up applyuing the default pubsub topic and every usage of this.option
. This is cumbersome and prone to developer error.
Apply the default values in the constructor:
this.options = Object.assign({pubSubTopic: DefaultPubSubTopic}, options, {})
Or same logic in a getter get options(): ProtocolOptions
Or create a class that handles the ProtocolOptions
and automatically apply default values
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.
TypeScript doesn't know if a particular value as been assigned to an object (``Object.assign) so would need to explicitly typecast it. Instead, I've replaced
this.options` with a private `pubSubTopic` variable.
@@ -88,7 +88,8 @@ export async function createLightNode( | |||
const store = wakuStore(options); | |||
const lightPush = wakuLightPush(options); | |||
const filter = wakuFilter(options); | |||
const peerExchange = wakuPeerExchange(options); | |||
|
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.
odd
// we can probably move `peerId` into `ProtocolCreateOptions` and remove `ProtocolOptions` and pass it in the constructor | ||
// however, filter protocol can use multiple peers, so we need to think about this |
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.
All protocol can use multiple peers. I don't think PeerId
belongs to CreateOptions
.
Do note that it makes sense to have PubSubTopic
in ProtocolOptions
(too). Let's see how Waku scaling goes:
For now I'd remove this todo and leave it as it is and we can decide later once we ahve more information on sharding and Waku usage.
@@ -88,7 +88,8 @@ export async function createLightNode( | |||
const store = wakuStore(options); |
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.
You have not removed the CreateOptions
definition in this file. I expect it to be replaced with CreateProtocolOPtions
from @waku/interfaces
@fryorcraken the above have been addressed here #1153 |
* address comments from #1145 * fix: typedoc * address comments in #1146 (review) - update changelog - change naming for `EciesEncoderOptions` and `SymmetricEncoderOptions`
ref: #1000