chore: do not use `Partial` when not needed

This commit is contained in:
fryorcraken.eth 2022-12-02 19:48:55 +11:00
parent f80c3ded0f
commit a4ddb45af1
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
5 changed files with 8 additions and 15 deletions

View File

@ -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;

View File

@ -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 {

View File

@ -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");

View File

@ -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);

View File

@ -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);