@@ -19,22 +19,15 @@ export { proto };
19
19
export class DecodedMessage implements IDecodedMessage {
20
20
constructor ( protected proto : proto . WakuMessage ) { }
21
21
22
- get _rawPayload ( ) : Uint8Array | undefined {
23
- if ( this . proto . payload ) {
24
- return new Uint8Array ( this . proto . payload ) ;
25
- }
26
- return ;
27
- }
28
-
29
22
get ephemeral ( ) : boolean {
30
23
return Boolean ( this . proto . ephemeral ) ;
31
24
}
32
25
33
- get payload ( ) : Uint8Array | undefined {
34
- return this . _rawPayload ;
26
+ get payload ( ) : Uint8Array {
27
+ return this . proto . payload ;
35
28
}
36
29
37
- get contentTopic ( ) : string | undefined {
30
+ get contentTopic ( ) : string {
38
31
return this . proto . contentTopic ;
39
32
}
40
33
@@ -51,18 +44,15 @@ export class DecodedMessage implements IDecodedMessage {
51
44
const timestamp = this . proto . timestamp / OneMillion ;
52
45
return new Date ( Number ( timestamp ) ) ;
53
46
}
54
-
55
- if ( this . proto . timestampDeprecated ) {
56
- return new Date ( this . proto . timestampDeprecated * 1000 ) ;
57
- }
47
+ return ;
58
48
} catch ( e ) {
59
49
return ;
60
50
}
61
- return ;
62
51
}
63
52
64
53
get version ( ) : number {
65
- // https://github.com/status-im/js-waku/issues/921
54
+ // https://rfc.vac.dev/spec/14/
55
+ // > If omitted, the value SHOULD be interpreted as version 0.
66
56
return this . proto . version ?? 0 ;
67
57
}
68
58
@@ -115,8 +105,8 @@ export class Decoder implements IDecoder<DecodedMessage> {
115
105
const protoMessage = proto . WakuMessage . decode ( bytes ) ;
116
106
log ( "Message decoded" , protoMessage ) ;
117
107
return Promise . resolve ( {
118
- payload : protoMessage . payload ?? undefined ,
119
- contentTopic : protoMessage . contentTopic ?? undefined ,
108
+ payload : protoMessage . payload ,
109
+ contentTopic : protoMessage . contentTopic ,
120
110
version : protoMessage . version ?? undefined ,
121
111
timestamp : protoMessage . timestamp ?? undefined ,
122
112
rateLimitProof : protoMessage . rateLimitProof ?? undefined ,
@@ -127,12 +117,9 @@ export class Decoder implements IDecoder<DecodedMessage> {
127
117
async fromProtoObj (
128
118
proto : IProtoMessage
129
119
) : Promise < DecodedMessage | undefined > {
130
- // https://github.com/status-im/js-waku/issues/921
131
- if ( proto . version === undefined ) {
132
- proto . version = 0 ;
133
- }
134
-
135
- if ( proto . version !== Version ) {
120
+ // https://rfc.vac.dev/spec/14/
121
+ // > If omitted, the value SHOULD be interpreted as version 0.
122
+ if ( proto . version ?? 0 !== Version ) {
136
123
log (
137
124
"Failed to decode due to incorrect version, expected:" ,
138
125
Version ,
0 commit comments