From 4b1f0ef79582cbf50880959bcee404ea7d04122d Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Fri, 28 Oct 2022 09:33:05 +1100 Subject: [PATCH] chore: clean-up store protocol --- CHANGELOG.md | 2 +- src/lib/waku_store/history_rpc.ts | 24 +++++++++---------- src/lib/waku_store/index.ts | 7 +++--- .../{store_v2beta4.proto => store.proto} | 0 src/proto/{store_v2beta4.ts => store.ts} | 0 5 files changed, 16 insertions(+), 17 deletions(-) rename src/proto/{store_v2beta4.proto => store.proto} (100%) rename src/proto/{store_v2beta4.ts => store.ts} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a90753ebe..929ce2ab96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed -- Support for Waku Store 2.0.0-beta4. +- Support for Waku Store 2.0.0-beta3. ## [0.29.0] - 2022-09-21 diff --git a/src/lib/waku_store/history_rpc.ts b/src/lib/waku_store/history_rpc.ts index 8be7038fb1..ec83d9c0ff 100644 --- a/src/lib/waku_store/history_rpc.ts +++ b/src/lib/waku_store/history_rpc.ts @@ -1,7 +1,7 @@ import type { Uint8ArrayList } from "uint8arraylist"; import { v4 as uuid } from "uuid"; -import * as protoV2Beta4 from "../../proto/store_v2beta4"; +import * as proto from "../../proto/store"; const OneMillion = BigInt(1_000_000); @@ -17,17 +17,17 @@ export interface Params { pageSize: number; startTime?: Date; endTime?: Date; - cursor?: protoV2Beta4.Index; + cursor?: proto.Index; } export class HistoryRPC { - private constructor(public readonly proto: protoV2Beta4.HistoryRPC) {} + private constructor(public readonly proto: proto.HistoryRPC) {} - get query(): protoV2Beta4.HistoryQuery | undefined { + get query(): proto.HistoryQuery | undefined { return this.proto.query; } - get response(): protoV2Beta4.HistoryResponse | undefined { + get response(): proto.HistoryResponse | undefined { return this.proto.response; } @@ -45,7 +45,7 @@ export class HistoryRPC { pageSize: BigInt(params.pageSize), cursor: params.cursor, direction, - } as protoV2Beta4.PagingInfo; + } as proto.PagingInfo; let startTime, endTime; if (params.startTime) { @@ -71,24 +71,24 @@ export class HistoryRPC { } decode(bytes: Uint8ArrayList): HistoryRPC { - const res = protoV2Beta4.HistoryRPC.decode(bytes); + const res = proto.HistoryRPC.decode(bytes); return new HistoryRPC(res); } encode(): Uint8Array { - return protoV2Beta4.HistoryRPC.encode(this.proto); + return proto.HistoryRPC.encode(this.proto); } } function directionToProto( pageDirection: PageDirection -): protoV2Beta4.PagingInfo.Direction { +): proto.PagingInfo.Direction { switch (pageDirection) { case PageDirection.BACKWARD: - return protoV2Beta4.PagingInfo.Direction.DIRECTION_BACKWARD_UNSPECIFIED; + return proto.PagingInfo.Direction.DIRECTION_BACKWARD_UNSPECIFIED; case PageDirection.FORWARD: - return protoV2Beta4.PagingInfo.Direction.DIRECTION_FORWARD; + return proto.PagingInfo.Direction.DIRECTION_FORWARD; default: - return protoV2Beta4.PagingInfo.Direction.DIRECTION_BACKWARD_UNSPECIFIED; + return proto.PagingInfo.Direction.DIRECTION_BACKWARD_UNSPECIFIED; } } diff --git a/src/lib/waku_store/index.ts b/src/lib/waku_store/index.ts index 42f3594b54..9a7f833b1f 100644 --- a/src/lib/waku_store/index.ts +++ b/src/lib/waku_store/index.ts @@ -8,8 +8,7 @@ import { pipe } from "it-pipe"; import { Libp2p } from "libp2p"; import { Uint8ArrayList } from "uint8arraylist"; -import * as protoV2Beta4 from "../../proto/store_v2beta4"; -import { HistoryResponse } from "../../proto/store_v2beta4"; +import * as proto from "../../proto/store"; import { DefaultPubSubTopic } from "../constants"; import { Decoder, Message } from "../interfaces"; import { selectConnection } from "../select_connection"; @@ -18,7 +17,7 @@ import { toProtoMessage } from "../to_proto_message"; import { HistoryRPC, PageDirection, Params } from "./history_rpc"; -import HistoryError = HistoryResponse.HistoryError; +import HistoryError = proto.HistoryResponse.HistoryError; const log = debug("waku:store"); @@ -316,7 +315,7 @@ async function* paginate( break; } - const response = reply.response as protoV2Beta4.HistoryResponse; + const response = reply.response as proto.HistoryResponse; if ( response.error && diff --git a/src/proto/store_v2beta4.proto b/src/proto/store.proto similarity index 100% rename from src/proto/store_v2beta4.proto rename to src/proto/store.proto diff --git a/src/proto/store_v2beta4.ts b/src/proto/store.ts similarity index 100% rename from src/proto/store_v2beta4.ts rename to src/proto/store.ts