Skip to content

Commit fa922b4

Browse files
add rpc and interfaces
1 parent ee2b446 commit fa922b4

File tree

1 file changed

+38
-0
lines changed
  • packages/core/src/lib/metadata

1 file changed

+38
-0
lines changed

packages/core/src/lib/metadata/rpc.ts

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
}

0 commit comments

Comments
 (0)