mirror of https://github.com/status-im/js-waku.git
chore: do not use `Partial` when not needed
This commit is contained in:
parent
f80c3ded0f
commit
a4ddb45af1
|
@ -60,7 +60,7 @@ class WakuLightPush implements LightPush {
|
|||
|
||||
async push(
|
||||
encoder: Encoder,
|
||||
message: Partial<Message>,
|
||||
message: Message,
|
||||
opts?: ProtocolOptions
|
||||
): Promise<SendResult> {
|
||||
const pubSubTopic = opts?.pubSubTopic ? opts.pubSubTopic : this.pubSubTopic;
|
||||
|
|
|
@ -74,11 +74,11 @@ export class DecodedMessage implements IDecodedMessage {
|
|||
export class Encoder implements IEncoder {
|
||||
constructor(public contentTopic: string, public ephemeral: boolean = false) {}
|
||||
|
||||
async toWire(message: Partial<Message>): Promise<Uint8Array> {
|
||||
async toWire(message: Message): Promise<Uint8Array> {
|
||||
return proto.WakuMessage.encode(await this.toProtoObj(message));
|
||||
}
|
||||
|
||||
async toProtoObj(message: Partial<Message>): Promise<ProtoMessage> {
|
||||
async toProtoObj(message: Message): Promise<ProtoMessage> {
|
||||
const timestamp = message.timestamp ?? new Date();
|
||||
|
||||
return {
|
||||
|
|
|
@ -99,10 +99,7 @@ class WakuRelay extends GossipSub implements Relay {
|
|||
/**
|
||||
* Send Waku message.
|
||||
*/
|
||||
public async send(
|
||||
encoder: Encoder,
|
||||
message: Partial<Message>
|
||||
): Promise<SendResult> {
|
||||
public async send(encoder: Encoder, message: Message): Promise<SendResult> {
|
||||
const msg = await encoder.toWire(message);
|
||||
if (!msg) {
|
||||
log("Failed to encode message, aborting publish");
|
||||
|
|
|
@ -37,16 +37,14 @@ class Encoder implements IEncoder {
|
|||
public ephemeral: boolean = false
|
||||
) {}
|
||||
|
||||
async toWire(message: Partial<Message>): Promise<Uint8Array | undefined> {
|
||||
async toWire(message: Message): Promise<Uint8Array | undefined> {
|
||||
const protoMessage = await this.toProtoObj(message);
|
||||
if (!protoMessage) return;
|
||||
|
||||
return proto.WakuMessage.encode(protoMessage);
|
||||
}
|
||||
|
||||
async toProtoObj(
|
||||
message: Partial<Message>
|
||||
): Promise<ProtoMessage | undefined> {
|
||||
async toProtoObj(message: Message): Promise<ProtoMessage | undefined> {
|
||||
const timestamp = message.timestamp ?? new Date();
|
||||
if (!message.payload) {
|
||||
log("No payload to encrypt, skipping: ", message);
|
||||
|
|
|
@ -36,16 +36,14 @@ class Encoder implements IEncoder {
|
|||
public ephemeral: boolean = false
|
||||
) {}
|
||||
|
||||
async toWire(message: Partial<Message>): Promise<Uint8Array | undefined> {
|
||||
async toWire(message: Message): Promise<Uint8Array | undefined> {
|
||||
const protoMessage = await this.toProtoObj(message);
|
||||
if (!protoMessage) return;
|
||||
|
||||
return proto.WakuMessage.encode(protoMessage);
|
||||
}
|
||||
|
||||
async toProtoObj(
|
||||
message: Partial<Message>
|
||||
): Promise<ProtoMessage | undefined> {
|
||||
async toProtoObj(message: Message): Promise<ProtoMessage | undefined> {
|
||||
const timestamp = message.timestamp ?? new Date();
|
||||
if (!message.payload) {
|
||||
log("No payload to encrypt, skipping: ", message);
|
||||
|
|
Loading…
Reference in New Issue