File tree 1 file changed +38
-0
lines changed
packages/core/src/lib/metadata
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { proto_metadata as proto } from "@waku/proto" ;
2
+ import type { Uint8ArrayList } from "uint8arraylist" ;
3
+ import { v4 as uuid } from "uuid" ;
4
+
5
+ export class MetadataRpc {
6
+ public constructor ( public proto : proto . MetadataRpc ) { }
7
+
8
+ static createRequest (
9
+ clusterId : number | undefined ,
10
+ shards : number [ ]
11
+ ) : MetadataRpc {
12
+ return new MetadataRpc ( {
13
+ requestId : uuid ( ) ,
14
+ request : {
15
+ clusterId : clusterId ,
16
+ shards : shards
17
+ } ,
18
+ response : undefined
19
+ } ) ;
20
+ }
21
+
22
+ static decode ( bytes : Uint8ArrayList ) : MetadataRpc {
23
+ const res = proto . MetadataRpc . decode ( bytes ) ;
24
+ return new MetadataRpc ( res ) ;
25
+ }
26
+
27
+ encode ( ) : Uint8Array {
28
+ return proto . MetadataRpc . encode ( this . proto ) ;
29
+ }
30
+
31
+ get query ( ) : proto . WakuMetadataRequest | undefined {
32
+ return this . proto . request ;
33
+ }
34
+
35
+ get response ( ) : proto . WakuMetadataResponse | undefined {
36
+ return this . proto . response ;
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments