-
Notifications
You must be signed in to change notification settings - Fork 48
feat: introduce Send API #2583
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
base: master
Are you sure you want to change the base?
feat: introduce Send API #2583
Changes from 20 commits
d29994d
97f0fb2
01288ff
e54645a
3de906a
4fe8bfd
37ee490
998c2a1
0c852e4
9e7719e
ad675d8
7c67abe
4385104
7f98bb1
da11478
62b43f0
80cef4b
82be279
969330d
de70791
e39c6c9
974fb21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export const OneMillion = BigInt(1_000_000); | ||
| export const Version = 0; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| export * as version_0 from "./version_0.js"; | ||
| export { OneMillion, Version } from "./constants.js"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,21 @@ export interface IMessage { | |
| rateLimitProof?: IRateLimitProof; | ||
| } | ||
|
|
||
| /** | ||
| * Send message data structure used in {@link IWaku.send}. | ||
| */ | ||
| export interface ISendMessage { | ||
| contentTopic: string; | ||
| payload: Uint8Array; | ||
| ephemeral?: boolean; | ||
| rateLimitProof?: boolean; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think the API consumer should be exposed to the rate limit proof, this sit behind the Waku API. see |
||
| } | ||
|
|
||
| /** | ||
| * Request ID of attempt to send a message. | ||
| */ | ||
| export type RequestId = string; | ||
|
|
||
| export interface IMetaSetter { | ||
| (message: IProtoMessage & { meta: undefined }): Uint8Array; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,13 @@ import type { IFilter } from "./filter.js"; | |
| import type { HealthStatus } from "./health_status.js"; | ||
| import type { Libp2p } from "./libp2p.js"; | ||
| import type { ILightPush } from "./light_push.js"; | ||
| import { IDecodedMessage, IDecoder, IEncoder } from "./message.js"; | ||
| import { | ||
| IDecodedMessage, | ||
| IDecoder, | ||
| IEncoder, | ||
| ISendMessage, | ||
| RequestId | ||
| } from "./message.js"; | ||
| import type { Protocols } from "./protocols.js"; | ||
| import type { IRelay } from "./relay.js"; | ||
| import type { ShardId } from "./sharding.js"; | ||
|
|
@@ -58,9 +64,22 @@ export type IWakuEventEmitter = TypedEventEmitter<IWakuEvents>; | |
|
|
||
| export interface IWaku { | ||
| libp2p: Libp2p; | ||
|
|
||
| /** | ||
| * @deprecated should not be accessed directly, use {@link IWaku.send} and {@link IWaku.subscribe} instead | ||
| */ | ||
| relay?: IRelay; | ||
|
|
||
| store?: IStore; | ||
|
|
||
| /** | ||
| * @deprecated should not be accessed directly, use {@link IWaku.subscribe} instead | ||
| */ | ||
| filter?: IFilter; | ||
|
|
||
| /** | ||
| * @deprecated should not be accessed directly, use {@link IWaku.send} instead | ||
| */ | ||
| lightPush?: ILightPush; | ||
|
|
||
| /** | ||
|
|
@@ -251,6 +270,14 @@ export interface IWaku { | |
| */ | ||
| createEncoder(params: CreateEncoderParams): IEncoder; | ||
|
|
||
| /** | ||
| * Sends a message to the Waku network. | ||
| * | ||
| * @param {ISendMessage} message - The message to send. | ||
| * @returns {Promise<RequestId>} A promise that resolves to the request ID | ||
| */ | ||
| send(message: ISendMessage): Promise<RequestId>; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the Waku message Id must be exposed in the API to enable SDS's retrieval hints. I strongly recommend for it to be returned by |
||
|
|
||
| /** | ||
| * @returns {boolean} `true` if the node was started and `false` otherwise | ||
| */ | ||
|
|
||
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 am not convinced we need a type here, it just makes it harder to understand the API.
Just do